Ejemplo n.º 1
0
 def __init__(self, dev='/dev/spidev1.0', spd=1000000):
     spi.openSPI(device=dev, speed=spd)
     #    GPIO.setmode(GPIO.BOARD)
     GPIO.setcfg(22, GPIO.OUTPUT)
     GPIO.output(self.NRSTPD, 1)
     self.Write_MFRC522(self.RFCfgReg, (0x07 << 4))
     self.MFRC522_Init()
Ejemplo n.º 2
0
 def __init__(self, dev='/dev/spidev0.0', spd=500000):
   spi.openSPI(device=dev,speed=spd)
   GPIO.setmode(GPIO.BCM)
   GPIO.setwarnings(False)
   #GPIO.setup(self.NRSTPD, GPIO.OUT)
   #GPIO.output(self.NRSTPD, 1)
   self.MFRC522_Init()
Ejemplo n.º 3
0
 def __init__(self, dev='/dev/spidev0.1', spd=1000000, verbose=False):
     spi.openSPI(device=dev, speed=spd)
     GPIO.setmode(GPIO.BOARD)
     GPIO.setup(self.NRSTPD, GPIO.OUT)
     GPIO.output(self.NRSTPD, 1)
     self.MFRC522_Init()
     self.verbose = verbose
Ejemplo n.º 4
0
    def __init__(self, device='/dev/spidev0.0', speed=1000000):

        spi.openSPI(device=device, speed=speed)
        GPIO.setmode(GPIO.BOARD)
        GPIO.setup(self.NRSTPD, GPIO.OUT)
        GPIO.output(self.NRSTPD, 1)
        self.init()
Ejemplo n.º 5
0
 def __init__(self):
     GPIO.setmode(GPIO.BOARD)
     # pin15=GPIO22 is linked to MAX3420 -RST
     GPIO.setup(15, GPIO.OUT)
     GPIO.output(15, GPIO.LOW)
     GPIO.output(15, GPIO.HIGH)
     spi.openSPI(speed=26000000)
Ejemplo n.º 6
0
def main():
    # Open file descriptor for 
    # spi device 0 using the CE0 pin for chip select
    device_0 =  spi.openSPI(device="/dev/spidev0.0",
                            mode=0,
                            speed=1000000)

    # Open file descriptor for
    # spi device 0 using the CE1 pin for chip select
    device_1 = spi.openSPI(device="/dev/spidev0.1",
                        mode=0,
                        speed=1000000)

    # Transact data
    data_out = (0xFF, 0x00, 0xFF)

    # This is not necessary, not just demonstrate loop-back
    data_in = (0x00, 0x00, 0x00)
    data_in = spi.transfer(device_0, data_out)
    print("Received from device 0:")
    print(data_in)

    data_in = (0x00, 0x00, 0x00)
    data_in = spi.transfer(device_1, data_out)
    print("Received from device 1:")
    print(data_in)

    # Close file descriptors
    spi.closeSPI(device_0)
    spi.closeSPI(device_1)
Ejemplo n.º 7
0
 def __init__(self, dev='/dev/spidev0.0', spd=1000000):
     spi.openSPI(device=dev, speed=spd)
     GPIO.setmode(GPIO.BOARD)
     GPIO.setup(self.NRSTPD, GPIO.OUT)
     GPIO.setup(3, GPIO.IN)
     GPIO.output(self.NRSTPD, 1)
     self.MFRC522_Init()
Ejemplo n.º 8
0
  def __init__(self, dev='/dev/spidev0.0', spd=1000000):
    spi.openSPI(device=dev,speed=spd)
    GPIO.setmode(GPIO.BOARD)
    GPIO.setup(22, GPIO.OUT)
	GPIO.setup(12, GPIO.OUT)
	GPIO.setup(16, GPIO.OUT)
	GPIO.setup(36, GPIO.OUT)
Ejemplo n.º 9
0
    def __init__(self, *args, **kargs):
#        GPIO.setmode(GPIO.BOARD)
#        # pin15=GPIO22 is linked to MAX3420 -RST
#        GPIO.setup(15, GPIO.OUT)
#        GPIO.output(15,GPIO.LOW)
#        GPIO.output(15,GPIO.HIGH)
        spi.openSPI(device="/dev/spidev1.0", speed=26000000)
Ejemplo n.º 10
0
 def __init__(self, *args, **kargs):
     GPIO.setmode(GPIO.BOARD)
     # pin15=GPIO22 is linked to MAX3420 -RST
     GPIO.setup(15, GPIO.OUT)
     GPIO.output(15,GPIO.LOW)
     GPIO.output(15,GPIO.HIGH)
     spi.openSPI(speed=26000000)
Ejemplo n.º 11
0
 def __init__(self, dev='/dev/spidev0.1', spd=1000000):
      
   spi.openSPI(device=dev,speed=spd)
   GPIO.setmode(GPIO.BOARD)
   GPIO.setup(22, GPIO.OUT)
   GPIO.output(self.NRSTPD, 1)
   self.MFRC522_Init()
Ejemplo n.º 12
0
 def __init__(self,spd=1000000):
   spi.openSPI(speed=spd)
   GPIO.setmode(GPIO.BOARD)
   GPIO.setwarnings(False)
   GPIO.setup(22, GPIO.OUT)
   GPIO.output(self.NRSTPD, 1)
   self.MFRC522_Init()
Ejemplo n.º 13
0
 def __init__(self, spd=1000000):
     spi.openSPI(speed=spd)
     GPIO.setmode(GPIO.BOARD)
     GPIO.setwarnings(False)
     GPIO.setup(22, GPIO.OUT)
     GPIO.output(self.NRSTPD, 1)
     self.MFRC522_Init()
Ejemplo n.º 14
0
 def __init__(self, dev='/dev/spidev0.0', spd=1000000, log_level=LOG_NONE):
     self.LOG_LEVEL = log_level
     spi.openSPI(device=dev, speed=spd)
     GPIO.setmode(GPIO.BCM)
     GPIO.setup(self.NRSTPD, GPIO.OUT)
     GPIO.output(self.NRSTPD, 1)
     self.MFRC522_Init()
Ejemplo n.º 15
0
 def __init__(self,spd=1000000):
   spi.openSPI(speed=spd)
   #GPIO.cleanup()
   GPIO.setmode(GPIO.BOARD)
   GPIO.setup(self.NRSTPD, GPIO.OUT)
   GPIO.output(self.NRSTPD, GPIO.HIGH)
   self.MFRC522_Init()
Ejemplo n.º 16
0
 def checkReaders(self):
     global stopMonitor
     global reader
     global stopMonitorForCheck
     if stopMonitor != True:
         if reader == 1:
             spi.openSPI(device='/dev/spidev0.0', speed=1000000)
         elif reader == -1:
             spi.openSPI(device='/dev/spidev0.1', speed=1000000)
         try:
             id, text = monitorInstance.read()
             print(id)
             print(text)
         finally:
             GPIO.cleanup()
             if id == 0:
                 reader = reader * -1
                 gui.after(400, self.checkReaders)
             else:
                 stopMonitorForCheck = True
     now = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
     if stopMonitorForCheck == True:
         self.checkPerson(id, now, reader)
         stopMonitorForCheck = False
         gui.after(400, self.checkReaders)
Ejemplo n.º 17
0
 def __init__(self, device=0, reset=22, spd=1000000):
     spidevice = '/dev/spidev0.{}'.format(device)
     self.NRSTPD = reset
     spi.openSPI(device=spidevice, speed=spd)
     GPIO.setmode(GPIO.BOARD)
     GPIO.setup(reset, GPIO.OUT)
     GPIO.output(reset, 1)
     self.MFRC522_Init()
Ejemplo n.º 18
0
 def __init__(self, dev='/dev/spidev0.0', spd=1000000):
   spi.openSPI(device=dev,speed=spd)
   GPIO.setmode(GPIO.BCM)
   GPIO.setup(self.NRSTPD, GPIO.OUT)
   GPIO.output(self.NRSTPD, 0)
   GPIO.setup(self.SDA, GPIO.OUT)
   GPIO.output(self.SDA, 0)
   self.MFRC522_Init()
Ejemplo n.º 19
0
 def __init__(self, dev='/dev/spidev0.0', spd=1000000):
     spi.openSPI(device=dev, speed=spd)
     GPIO.setmode(GPIO.BOARD)
     GPIO.setup(
         self.NRSTPD,
         GPIO.OUT)  # changed to use self.NRSTPD instead of literal 11
     GPIO.output(self.NRSTPD, 1)
     self.MFRC522_Init()
Ejemplo n.º 20
0
 def __init__(self, dev='/dev/spidev0.0', spd=1000000, pin=-1):
   if pin != -1:
       spi.openSPI(device=dev,speed=spd)
       self.NRSTPD = pin
       GPIO.setmode(GPIO.BOARD)
       GPIO.setup(self.NRSTPD, GPIO.OUT)
       GPIO.output(self.NRSTPD, 1)
       self.MFRC522_Init()
Ejemplo n.º 21
0
    def __init__(self, dev='/dev/spidev0.0', spd=1000000, *args, **kwargs):
        super(RFIDController, self).__init__(*args, **kwargs)

        spi.openSPI(device=dev, speed=spd)
        GPIO.setwarnings(False)
        GPIO.setmode(GPIO.BOARD)
        GPIO.setup(22, GPIO.OUT)
        self._initialize()
Ejemplo n.º 22
0
    def __init__(self, motors):
        self.device_0 = spi.openSPI(device="/dev/spidev1.1",
                                    mode=0,
                                    speed=1957000)
        self.device_1 = spi.openSPI(device="/dev/spidev1.0",
                                    mode=0,
                                    speed=1957000)

        self.data_out_0 = list([0] * 60)
        self.data_in_0 = list([0] * 60)

        self.data_out_1 = list([0] * 60)
        self.data_in_1 = list([0] * 60)

        self.data_out_0[0] = 3
        self.data_out_0[28] = 3
        self.data_out_1[0] = 3
        self.data_out_1[28] = 3

        self.data_out_0[1] = 1
        self.data_out_0[10] = 2
        self.data_out_0[19] = 3

        self.data_out_0[29] = 1
        self.data_out_0[38] = 2
        self.data_out_0[47] = 3

        self.data_out_1[1] = 1
        self.data_out_1[10] = 2
        self.data_out_1[19] = 3

        self.data_out_1[29] = 1
        self.data_out_1[38] = 2
        self.data_out_1[47] = 3

        # Control sums
        self.data_out_0[56] = 0xAD
        self.data_out_0[57] = 0xAD
        self.data_out_0[58] = 0xAD
        self.data_out_0[59] = 0xAD

        self.data_out_1[56] = 0xAD
        self.data_out_1[57] = 0xAD
        self.data_out_1[58] = 0xAD
        self.data_out_1[59] = 0xAD

        self.motors = motors['LF_leg'] + motors['RF_leg'] + motors[
            'LB_leg'] + motors['RB_leg']
        self.motors_IDs = list(
            map(lambda x: [x.CAN_ID, x.motor_id], self.motors))

        self.spi_box_placing_0 = [[[0, 2], [1, 10]], [[0, 1], [10, 19]],
                                  [[0, 0], [19, 28]], [[1, 2], [29, 38]],
                                  [[1, 1], [38, 47]], [[1, 0], [47, 56]]]

        self.spi_box_placing_1 = [[[2, 2], [1, 10]], [[2, 1], [10, 19]],
                                  [[2, 0], [19, 28]], [[3, 2], [29, 38]],
                                  [[3, 1], [38, 47]], [[3, 0], [47, 56]]]
Ejemplo n.º 23
0
 def __init__(self, dev='/dev/spidev0.0', spd=1000000):
     spi.openSPI(device=dev, speed=spd)
     GPIO.setmode(GPIO.BOARD)
     GPIO.setup(22, GPIO.OUT)
     GPIO.output(self.NRSTPD, 1)
     if (self.MFRC522_Init() < 0):
         print("MFRC522 Init Failed!")
         GPIO.cleanup()
         exit(0)
Ejemplo n.º 24
0
 def __init__(self, spd=1000000):
     spi.openSPI(speed=spd)
     GPIO.setmode(GPIO.BCM)
     GPIO.setup(13, GPIO.IN, pull_up_down=GPIO.PUD_UP)
     GPIO.setup(22, GPIO.OUT)
     GPIO.setup(18, GPIO.OUT)
     GPIO.setup(21, GPIO.OUT)
     GPIO.output(self.NRSTPD, 1)
     GPIO.setwarnings(False)
     self.MFRC522_Init()
Ejemplo n.º 25
0
def lcd_cmd(cmd):
	stat = spi.openSPI(SPI_DEVICE,speed=SPI_SPEED,bits=8)
#	print "LCD CMD(1)=%X, SPI_open=" % (cmd) , stat
	spi.transfer((0,cmd>>8,0x00ff&cmd,0x11)) # 0x11 - CMD_BE const from ili9341.c 
	spi.closeSPI()
#	time.sleep(0.0001) # 100us
	stat = spi.openSPI(SPI_DEVICE,speed=SPI_SPEED,bits=8)
#	print "LCD CMD(2)=%X, SPI_open=" % (cmd) , stat
	spi.transfer((0,cmd>>8,0x00ff&cmd,0x1B)) # x01B - CMD_AF const from ili9341.c 
	spi.closeSPI()
	return
Ejemplo n.º 26
0
def lcd_data(data):
	stat = spi.openSPI(SPI_DEVICE,speed=SPI_SPEED,bits=8)
#	print "LCD DATA(1)=%X, SPI_open=" % (data) , stat
	spi.transfer((0,data>>8,0x00ff&data,0x15))	# 0x15 - DATA_BE const from ili9341.c (BE is short form "before")
	spi.closeSPI()
#	time.sleep(0.00001) # 10us
	stat = spi.openSPI(SPI_DEVICE,speed=SPI_SPEED,bits=8)
#	print "LCD DATA(2)=%X, SPI_open=" % (data) , stat
	spi.transfer((0,data>>8,0x00ff&data,0x1F)) # 0x1F - DATA_AF const from ili9341.c (AF is short form "after")
	spi.closeSPI()
	return
 def __init__(self,spd=1000000, NRSTPDpin = 25, GPIO = None):
   spi.openSPI(speed=spd)
   if not GPIO:
     import RPi.GPIO as GPIO
   
   
   self.GPIO = GPIO
   self.GPIO.setmode(GPIO.BCM)
   self.NRSTPD = NRSTPDpin;
   self.GPIO.setup(self.NRSTPD, GPIO.OUT)
   self.GPIO.output(self.NRSTPD, 1)
   self.MFRC522_Init()
Ejemplo n.º 28
0
    def issue_setup(self, data):
        """
            Sets up the Raspdancer to communicate with the MAX324x.
        """
        # pin15=GPIO22 is linked to MAX3420 -RST
        GPIO.setup(15, GPIO.OUT)
        GPIO.output(15,GPIO.LOW)
        GPIO.output(15,GPIO.HIGH)

        spi.openSPI(speed=26000000)

        return b''
Ejemplo n.º 29
0
    def issue_setup(self, data):
        """
            Sets up the Raspdancer to communicate with the MAX324x.
        """
        # pin15=GPIO22 is linked to MAX3420 -RST
        GPIO.setup(15, GPIO.OUT)
        GPIO.output(15, GPIO.LOW)
        GPIO.output(15, GPIO.HIGH)

        spi.openSPI(speed=26000000)

        return b''
Ejemplo n.º 30
0
    def MRFC522_AdvanceDevice(self):
        # Advance to the next device in device_list
        #    (wrapping back to the first device after we reach the end)
        self.curr_device_id = self.curr_device_id + 1
        if (self.curr_device_id >= len(self.device_list)):
            self.curr_device_id = 0

        # Close the current SPI device, and open the next
        spi.closeSPI()
        spi.openSPI(device=self.device_list[self.curr_device_id],
                    speed=self.curr_speed)

        # Finally call MFRC522's MFRC522_Init() method
        super(MRFC522TeamTrack, self).MFRC522_Init()
Ejemplo n.º 31
0
def lcd_reset():
	# for reset I use slow clock - just my habit
	stat = spi.openSPI(SPI_DEVICE,speed=1000000,bits=8)
#	print "LCD RESET(1), SPI_open=",stat
	spi.transfer((0,0,0,0)) # set 0 on U1-Q2
	spi.closeSPI()
	time.sleep(0.05) # 50ms reset
	# unreset
	stat = spi.openSPI(SPI_DEVICE,speed=1000000,bits=8)
#	print "LCD RESET(2), SPI_open=",stat
	spi.transfer((0,0,0,2)) # set 1 on U1-Q2
	spi.closeSPI()
	time.sleep(0.1) # 100ms after reset
	return
Ejemplo n.º 32
0
    def __init__(self, bus, channel, _3wire=True):
        device = "/dev/spidev%s.%s" % (bus, channel)

        spi.openSPI(speed=100000, mode=1, device=device)

        self.config = self.__REG_CONF_VBIAS_ON | self.__REG_CONF_50HZ_FILTER | self.__REG_CONF_CONVERSION_MODE_AUTO
        if(_3wire):
            self.config |= self.__REG_CONF_3WIRE_RTD

        self.__write__(self.__REG_CONFIGURATION, self.config | self.__REG_CONF_FAULT_STATUS_AUTO_CLEAR)
        self.__write__(self.__REG_LF_MSB, 0x00)
        self.__write__(self.__REG_LF_LSB, 0x00)
        self.__write__(self.__REG_HF_MSB, 0xFF)
        self.__write__(self.__REG_HF_LSB, 0xFF)
Ejemplo n.º 33
0
 def __init__(self,spd=1000000):
   spi.openSPI(speed=spd)
   GPIO.setmode(GPIO.BOARD)
   GPIO.setup(22, GPIO.OUT)
   GPIO.output(self.NRSTPD, 1)
   GPIO.setup(5, GPIO.OUT)
   GPIO.output(5, 1)
   GPIO.setup(12, GPIO.OUT)
   GPIO.output(12, 1)
   GPIO.setup(16, GPIO.OUT)
   GPIO.output(16, 1)
   GPIO.setup(18, GPIO.OUT)
   GPIO.output(18, 1)
   self.MFRC522_Init()
Ejemplo n.º 34
0
    def __init__(self, name, bus, channel, _3wire=True):
        self.serial = name
        device = "/dev/spidev%s.%s" % (bus, channel)

        spi.openSPI(speed=100000, mode=1, device=device)

        self.config = REG_CONF_VBIAS_ON | REG_CONF_50HZ_FILTER | REG_CONF_CONVERSION_MODE_AUTO
        if(_3wire):
            self.config |= REG_CONF_3WIRE_RTD

        self.__write__(REG_CONFIGURATION, self.config | REG_CONF_FAULT_STATUS_AUTO_CLEAR)
        self.__write__(REG_LF_MSB, 0x00)
        self.__write__(REG_LF_LSB, 0x00)
        self.__write__(REG_HF_MSB, 0xFF)
        self.__write__(REG_HF_LSB, 0xFF)
Ejemplo n.º 35
0
    def __init__(self):
        self.xDefault = 148
        self.yDefault = 176 
        
        self.xMin = 128
        self.xMax = 168
        self.yMin = 136
        self.yMax = 216

        self.devMaxX = None
        self.devMinX = None
        self.devMaxY = None
        self.devMinY = None

        spi.openSPI(speed=1000000, mode=0)
Ejemplo n.º 36
0
    def __init__(self, devMaxX, devMinX, devMaxY, devMinY):
        self.xDefault = 148
        self.yDefault = 176

        self.xMin = 128
        self.xMax = 168
        self.yMin = 146
        self.yMax = 206

        self.devMaxX = devMaxX
        self.devMinX = devMinX
        self.devMaxY = devMinY
        self.devMinY = devMaxY

        spi.openSPI(speed=1000000, mode=0)
Ejemplo n.º 37
0
    def __init__(self, dev='/dev/spidev0.0', speed=1000000, pin_rst=22):
        self.pin_rst = pin_rst

        SPI.openSPI(device=dev, speed=speed)
        GPIO.setmode(GPIO.BOARD)
        GPIO.setup(pin_rst, GPIO.OUT)
        GPIO.output(pin_rst, 1)
        self.reset()
        self.dev_write(0x2A, 0x8D)
        self.dev_write(0x2B, 0x3E)
        self.dev_write(0x2D, 30)
        self.dev_write(0x2C, 0)
        self.dev_write(0x15, 0x40)
        self.dev_write(0x11, 0x3D)
        self.set_antenna(True)
Ejemplo n.º 38
0
    def __init__(self, devMaxX, devMinX, devMaxY, devMinY):
        self.xDefault = 148
        self.yDefault = 176 
        
        self.xMin = 128
        self.xMax = 168
        self.yMin = 146
        self.yMax = 206

        self.devMaxX = devMaxX
        self.devMinX = devMinX
        self.devMaxY = devMinY
        self.devMinY = devMaxY


        spi.openSPI(speed=1000000, mode=0)
Ejemplo n.º 39
0
 def __init__(self, dev='/dev/spidev0.0', spd=1000000):
     global spidev
     spidev = spi.openSPI(device=dev, speed=spd)
     #GPIO.setboard(GPIO.PCPCPLUS)
     GPIO.setmode(GPIO.BOARD)
     GPIO.setup(22, GPIO.OUT)
     GPIO.output(self.NRSTPD, 1)
     self.MFRC522_Init()
Ejemplo n.º 40
0
    def __init__(self, speed, a0_port):
        import RPi.GPIO as GPIO
        import spi

        self.a0_port = a0_port
        self.spi_device = spi.openSPI(speed=speed)
        GPIO.setmode(GPIO.BCM)
        GPIO.setup(self.a0_port, GPIO.OUT)
Ejemplo n.º 41
0
    def __init__(self, ce=0):
        super().__init__()
        self.ce = ce
        self.dev = spi.openSPI(device="/dev/spidev0.0")

        self.alphabet = Alphabet()
        self.emotions = Emotions()
        self.pictures = Pictures()
Ejemplo n.º 42
0
 def __init__(self, dev=None, spd=1000000):
     if dev is None:
         self._dev = '/dev/spidev0.0'
     else:
         self._dev = dev
     self._spd = spd
     self._ret = spi.openSPI(device=self._dev, speed=self._spd)
     self.MFRC522_Init()
Ejemplo n.º 43
0
    def __init__(self, dev='/dev/spidev0.0', spd=1000000):
        spi.openSPI(device=dev, speed=spd)
        GPIO.setmode(GPIO.BOARD)
        GPIO.setup(22, GPIO.OUT)
        GPIO.output(self.NRSTPD, 1)

        GPIO.output(self.NRSTPD, 1)

        self.reset()

        self.write(self.TModeReg, 0x8D)
        self.write(self.TPrescalerReg, 0x3E)
        self.write(self.TReloadRegL, 30)
        self.write(self.TReloadRegH, 0)

        self.write(self.TxAutoReg, 0x40)
        self.write(self.ModeReg, 0x3D)
        self.antenna_on()
Ejemplo n.º 44
0
def init():
    status = spi.openSPI(speed=1000000)
    print "SPI configuration = ", status

    send_byte(MAX7219_REG_SCANLIMIT, 7)   # show all 8 digits
    send_byte(MAX7219_REG_DECODEMODE, 0)  # using a LED matrix (not digits)
    send_byte(MAX7219_REG_DISPLAYTEST, 0) # no display test
    clear()
    brightness(7)                         # character intensity: range: 0..15
    send_byte(MAX7219_REG_SHUTDOWN, 1)    # not in shutdown mode (i.e start it up)
Ejemplo n.º 45
0
 def __init__(self):
     # Mode 0, default speed
     spi.openSPI()
     
     self.temperature = 0
     self.pump_led = 0
     self.heater_led = 0
     self.heat_led = 0
     self.light_led = 0
     self.temp_led = 0
     self.temperature_led = 0
     self.curTemp = 0
     self.setPoint = 0
     self.clients = {}
     self.MAX_TEMP = 40
     self.COOL_TEMP = 30
     
     # Setup the threading callback
     self.refreshThreadStop = Event()
     self.refreshThread = Thread(target = self.refreshThread, args=(self.refreshThreadStop,))
     self.refreshThread.start()
Ejemplo n.º 46
0
 def __init__(self, ledmap_file, debug=0):
 
     # Set class memebers
     self.debug = debug
 
     # Read in LED maps
     with open(ledmap_file, 'r') as f:
         content = f.read()
     self.led_dict = eval(content)
     
     # Set pin modes
     if debug < 2:
         MODE = 2
         MODE_FILE = '/sys/devices/virtual/misc/gpio/mode/gpio'
         for i in range(10, 14):
             file = MODE_FILE + str(i)
             os.system('echo ' + str(MODE) + ' > ' + file)
         
     # Initialize SPI
     if debug < 2:
         spi.openSPI(speed=100000, mode=0, device='/dev/spidev0.0')
         
     # Clear eyes
     self.clear_eyes()
Ejemplo n.º 47
0
    def __init__(self):
        self.root = tk.Tk()
        self._job = None
        self.spi_device = spi.openSPI()
        
        slider_horiz_text = tk.Label(self.root, text="Horizontal")
        slider_horiz_text.pack()
        self.slider_horiz = tk.Scale(self.root, from_=0, to=180,
                                     orient="horizontal",
                                     command=self.updateValueHoriz)
        self.slider_horiz.pack()
        
        slider_vertical_text = tk.Label(self.root, text="Vertical")
        slider_vertical_text.pack()
        self.slider_vert = tk.Scale(self.root, from_=0, to=180,
									orient="horizontal",
									command=self.updateValueVert)
        self.slider_vert.pack()
        self.root.mainloop()
Ejemplo n.º 48
0
def main():
  try:
    # Specify GPIO mode
    GPIO.setmode(GPIO.BOARD)
    
    webserver = WebServer(port=8888, debug=True)

    # Open and configure SPI interface
    status = spi.openSPI(speed=1000000, mode=0)
    print "SPI configuration: ",status
    GPIO.setup(SPI_SEL1_PIN, GPIO.OUT)
    GPIO.setup(SPI_SEL2_PIN, GPIO.OUT)
    GPIO.setup(SPI_SEL3_PIN, GPIO.OUT)
    print 'GPIOs initialized'
    
    volume.change_handlers.append(volume_updated)
    volume.open_handlers.append(volume_open)
    volume.close_handlers.append(airset_close)
    tone.change_handlers.append(tone_updated)
    tone.open_handlers.append(tone_open)
    tone.close_handlers.append(airset_close)
    sustain.change_handlers.append(sustain_updated)
    sustain.open_handlers.append(sustain_open)
    sustain.close_handlers.append(airset_close)

    webserver.websocket('/volume-value',volume)
    webserver.websocket('/tone-value',tone)
    webserver.websocket('/sustain-value',sustain)
    webserver.websocket('/save-preset',
        SharedValue(value=read_preset(), on_change=save_preset))
    webserver.websocket('/get-preset',
        SharedValue(on_change=get_preset))

    webserver.static_files('/', './static')
    print('Listening on %s' % webserver.url)
    webserver.run()
    
  except (KeyboardInterrupt, SystemExit):
    print "Closing SPI..."
    spi.closeSPI()
    print "Cleaning up GPIO..."
    GPIO.cleanup()
Ejemplo n.º 49
0
led_file = open(LEDMAP_FILE, 'r')
content = led_file.read()
led_file.close()
led_dict = eval(content)

print led_dict['1 left']

# Set pin modes
MODE = 2
MODE_FILE = '/sys/devices/virtual/misc/gpio/mode/gpio'
for i in range(10, 14):
        file = MODE_FILE + str(i)
        os.system('echo ' + str(MODE) + ' > ' + file)

# Init SPI
spi.openSPI(speed=100000, mode=0, device='/dev/spidev0.0')

# Initialize wtih number of boards
data = [0x25, 0x01]
spi.transfer(tuple(data))

# Clear LED matrix
data = [0x26]
spi.transfer(tuple(data))
data = []
for i in range(0, 64):
        data.append(0x00)
spi.transfer(tuple(data))

# Send ledmap
data = [0x26]
Ejemplo n.º 50
0
#   https://github.com/lthiery/SPI-Py
#
# 26 Mar 2013 - Mike Hord, SparkFun Electronics
#
# This code is beerware- if you find it useful, please buy me (or, for that
# matter, any other SparkFun employee you met) a pint next time you meet us at
# the local.
#
##############################################################################

#!/usr/bin/env python

import spi

## The openSPI() function is where the SPI interface is configured. There are
##   three possible configuration options, and they all expect integer values:
##   speed - the clock speed in Hz
##   mode - the SPI mode (0, 1, 2, 3)
##   bits - the length of each word, in bits (defaults to 8, which is standard)
## It is also possible to pass a device name, but the default, spidev0.0, is
##   the only device currently supported by the pcDuino.

spi.openSPI(speed=1000000, mode=0)

## Data is sent as a tuple, so you can construct a tuple as long as you want 
##   and the result will come back as a tuple of the same length.
print spi.transfer((0x0B, 0x02, 0x00))

## Finally, close the SPI connection. This is probably not necessary but it's
##   good practice.
spi.closeSPI()
Ejemplo n.º 51
0
#!/usr/bin/python
import spi
from time import sleep
import random, time

width = 26
height = 16
thresh = 100  # charge threshold
charge = 1    # charging rate
sync = 13     # boost given to neighbors
rate = 20     # frames per sec

status = spi.openSPI(speed=5000000)
print "SPI configuration = ", status
# print "PY: initialising SPI mode, reading data, reading length . . . \n"

pixels = 424

class display(object):
   def __init__(self, pixels):
      self.pixels = pixels
      self.clear()
   def update(self):
      spi.transferrgb(self.red, self.green, self.blue)
   def set(self, pos, rv, gv, bv):
      '''set pixel at pos to rgb'''
      self.red[pos] = rv
      self.green[pos] = gv
      self.blue[pos] = bv
   def set2d(self, x, y, rv, gv, bv):
      if y & 1:
Ejemplo n.º 52
0
        assert p == 1000.5

        # but it doesn't make a difference with these values :)
        t, p = self.read(True)
        assert t == 20.15
        assert p == 1000.5

if __name__ == "__main__":
    test_crc4()
    MS5803_14BA_Test().test()

    # In living room conditions SPI works up to SCLK = 31249999Hz. But the data
    # sheet defines SCLKmax = 20MHz. So lets stay with that, 'cause it seems to
    # be a pretty safe choice.

    spi.openSPI(mode = 0, speed = 20000000, delay = 0)

    s = MS5803_14BA()
    s.reset()
    time.sleep(.003) # startup time
    s.prom()
    d = []
    tmax = pmax = 0.
    tmin = pmin = 1E6
    def f(x):
        return "%.02f" % x
    while True:
        d.append(s.read())
        if len(d) > 5:
            d[:-5] = []
        t = sum([x[0] for x in d]) / len(d)
Ejemplo n.º 53
0
	def __init__(self):
		spi.openSPI(speed=30000000)
Ejemplo n.º 54
0
Archivo: lcd.py Proyecto: diresi/ms5803
def setup():
    spi.openSPI(mode = 0, speed = 20000000, delay = 0)
    lcd = Nokia3310()
    lcd.setup()
    return lcd
Ejemplo n.º 55
0
 def __init__(self, dev='/dev/spidev0.0', spd=1000000):
   spi.openSPI(device=dev,speed=spd)
   wiringpi2.wiringPiSetupSys()
   wiringpi2.pinMode(self.NRSTPD, 1)
   wiringpi2.digitalWrite(self.NRSTPD, 1)
   self.MFRC522_Init()