Beispiel #1
0
   def __init__(self, gpio_0, gpio_1, callback, bit_timeout=5):

      """
      Instantiate with the gpio for 0 (green wire), the gpio for 1 (white wire),
      the callback function, and the bit timeout in milliseconds which indicates
      the end of a code.

      The callback is passed the code length in bits and the value.
      """

      self.gpio_0 = gpio_0
      self.gpio_1 = gpio_1

      self.callback = callback

      self.bit_timeout = bit_timeout

      self.in_code = False

      pigpio.set_mode(gpio_0, pigpio.INPUT)
      pigpio.set_mode(gpio_1, pigpio.INPUT)

      pigpio.set_pull_up_down(gpio_0, pigpio.PUD_UP)
      pigpio.set_pull_up_down(gpio_1, pigpio.PUD_UP)

      self.cb_0 = pigpio.callback(gpio_0, pigpio.FALLING_EDGE, self._cb)
      self.cb_1 = pigpio.callback(gpio_1, pigpio.FALLING_EDGE, self._cb)
Beispiel #2
0
def t1():

    print("Mode/PUD/read/write tests.")

    pigpio.set_mode(GPIO, pigpio.INPUT)
    v = pigpio.get_mode(GPIO)
    CHECK(1, 1, v, 0, 0, "set mode, get mode")

    pigpio.set_pull_up_down(GPIO, pigpio.PUD_UP)
    v = pigpio.read(GPIO)
    CHECK(1, 2, v, 1, 0, "set pull up down, read")

    pigpio.set_pull_up_down(GPIO, pigpio.PUD_DOWN)
    v = pigpio.read(GPIO)
    CHECK(1, 3, v, 0, 0, "set pull up down, read")

    pigpio.write(GPIO, pigpio.LOW)
    v = pigpio.get_mode(GPIO)
    CHECK(1, 4, v, 1, 0, "write, get mode")

    v = pigpio.read(GPIO)
    CHECK(1, 5, v, 0, 0, "read")

    pigpio.write(GPIO, pigpio.HIGH)
    v = pigpio.read(GPIO)
    CHECK(1, 6, v, 1, 0, "write, read")
Beispiel #3
0
def t1():

   print("Mode/PUD/read/write tests.")

   pigpio.set_mode(GPIO, pigpio.INPUT)
   v = pigpio.get_mode(GPIO)
   CHECK(1, 1, v, 0, 0, "set mode, get mode")

   pigpio.set_pull_up_down(GPIO, pigpio.PUD_UP)
   v = pigpio.read(GPIO)
   CHECK(1, 2, v, 1, 0, "set pull up down, read")

   pigpio.set_pull_up_down(GPIO, pigpio.PUD_DOWN)
   v = pigpio.read(GPIO)
   CHECK(1, 3, v, 0, 0, "set pull up down, read")

   pigpio.write(GPIO, pigpio.LOW)
   v = pigpio.get_mode(GPIO)
   CHECK(1, 4, v, 1, 0, "write, get mode")

   v = pigpio.read(GPIO)
   CHECK(1, 5, v, 0, 0, "read")

   pigpio.write(GPIO, pigpio.HIGH)
   v = pigpio.read(GPIO)
   CHECK(1, 6, v, 1, 0, "write, read")
Beispiel #4
0
def read_gpio(ValueHeating):
    CountGpio = 0
    Matrix_Heating_Value = dict_heating_value[ValueHeating]
    for ValuePin in Matrix_Heating_Value:
        GpioPin = dict_gpio_heating_relay[CountGpio]
        if str(ValuePin) != ".":
            #print (ValuePin)
            #print (GpioPin)
            #print (CountGpio)
            if ValuePin == "1":
                pi.set_pull_up_down(int(GpioPin), pigpio.PUD_UP)
                #print (ValuePin,GpioPin)
            else:
                pi.set_pull_up_down(int(GpioPin), pigpio.PUD_DOWN)
                #print (ValuePin,GpioPin)
            print(pi.read(int(GpioPin)))
            CountGpio = CountGpio + 1
Beispiel #5
0
   def __init__(self, gpio):
      """
      Instantiate with the gpio to which the DHT22 output pin is connected.
      """

      self.gpio = gpio

      self.bad_CS = 0 # checksum
      self.bad_TO = 0 # time-out

      self.accumulating = False

      self.rhum = -999
      self.temp = -999

      self.tov = None

      self.tick = 0

      pigpio.set_mode(gpio, pigpio.INPUT)

      pigpio.set_pull_up_down(gpio, pigpio.PUD_OFF)

      self.cb = pigpio.callback(gpio, pigpio.EITHER_EDGE, self._cb)
		imageList.append(im)
		if listFull > 0:
			del imageList[0]
		print "List Length = " + str(len(imageList))
	listFull = updateDisplay(imageList, False)
	pygame.event.clear(BUTTON_PRESSED)

# ########################################################################
#
# Main Program
#
# ########################################################################
#Setup the GPIO stuff

pigpio.start()
pigpio.set_pull_up_down(24, pigpio.PUD_UP)
cb = pigpio.callback(24, pigpio.FALLING_EDGE, cbf)

myDirs = readDirs()
print myDirs
if myDirs:
	lastDirectory = len(myDirs)-1 #List is zero-referenced, first directory begins with 1
else:
	lastDirectory = 1

loadFiles(lastDirectory) # This should populate the list of images with something...
listFull = updateDisplay(imageList) #Make sure that the faces are displayed onscreen
print "Length of myDirs is " + str(len(myDirs))
#create a directory for this run's worth of files
currentDir = os.path.join(imageRoot, 'imagesFolder/', str(len(myDirs)+1))
print currentDir
        if listFull > 0:
            del imageList[0]
        print "List Length = " + str(len(imageList))
    listFull = updateDisplay(imageList, False)
    pygame.event.clear(BUTTON_PRESSED)


# ########################################################################
#
# Main Program
#
# ########################################################################
#Setup the GPIO stuff

pigpio.start()
pigpio.set_pull_up_down(24, pigpio.PUD_UP)
cb = pigpio.callback(24, pigpio.FALLING_EDGE, cbf)

myDirs = readDirs()
print myDirs
if myDirs:
    lastDirectory = len(
        myDirs) - 1  #List is zero-referenced, first directory begins with 1
else:
    lastDirectory = 1

loadFiles(
    lastDirectory)  # This should populate the list of images with something...
listFull = updateDisplay(
    imageList)  #Make sure that the faces are displayed onscreen
print "Length of myDirs is " + str(len(myDirs))