def disable_rx(self): """Disable RX, remove GPIO event detection.""" if self.rx_enabled: GPIO.remove_event_detect(self.gpio) self.rx_enabled = False _LOGGER.debug("RX disabled") return True
def cleanup(self): GPIO.remove_event_detect(self.__pconfig['button']) GPIO.output(self.__pconfig['rec_light'], GPIO.LOW) GPIO.output(self.__pconfig['plb_light'], GPIO.LOW)
GPIO.output("CSID0", GPIO.LOW) print "LOW", GPIO.input("XIO-P0") # ============================================== # EDGE DETECTION - AP-EINT1 print "SETTING UP EDGE DETECTION ON AP-EINT1" GPIO.setup("AP-EINT1", GPIO.IN) GPIO.add_event_detect("AP-EINT1",GPIO.FALLING) print "VERIFYING EDGE DETECT" f = open("/sys/class/gpio/gpio193/edge","r") edge = f.read() f.close() print "EDGE: %s" % edge GPIO.remove_event_detect("AP-EINT1") # ============================================== # EDGE DETECTION - AP-EINT3 print "SETTING UP EDGE DETECTION ON AP-EINT3" GPIO.setup("AP-EINT3", GPIO.IN) GPIO.add_event_detect("AP-EINT3",GPIO.FALLING) print "VERIFYING EDGE DETECT" f = open("/sys/class/gpio/gpio35/edge","r") edge = f.read() f.close() print "EDGE: %s" % edge GPIO.remove_event_detect("AP-EINT3") # ==============================================
def cleanup(self): GPIO.remove_event_detect(self.__pconfig['button']) GPIO.output(self.__pconfig['rec_light'], GPIO.LOW) GPIO.output(self.__pconfig['plb_light'], GPIO.LOW)
GPIO.output("CSID0", GPIO.LOW) print "LOW", GPIO.input("GPIO1") assert (GPIO.input("GPIO1") == GPIO.LOW) # ============================================== # EDGE DETECTION - AP-EINT1 print("\nSETTING UP RISING EDGE DETECTION ON AP-EINT1") GPIO.setup("AP-EINT1", GPIO.IN) GPIO.add_event_detect("AP-EINT1", GPIO.RISING, myfuncallback) print("VERIFYING EDGE DETECT WAS SET PROPERLY") f = open("/sys/class/gpio/gpio193/edge", "r") edge = f.read() f.close() assert (edge == "rising\n") GPIO.remove_event_detect("AP-EINT1") # ============================================== # EDGE DETECTION - AP-EINT3 print("\nSETTING UP BOTH EDGE DETECTION ON AP-EINT3") GPIO.setup("AP-EINT3", GPIO.IN) GPIO.add_event_detect("AP-EINT3", GPIO.BOTH, myfuncallback) print("VERIFYING EDGE DETECT WAS SET PROPERLY") f = open("/sys/class/gpio/gpio35/edge", "r") edge = f.read() f.close() assert (edge == "both\n") GPIO.remove_event_detect("AP-EINT3") # ============================================== # EDGE DETECTION - EXPANDED GPIO
import CHIP_IO.GPIO as GPIO import time # Define callback function def mycallback(channel): # Sample is just to print something, but other logic could go here print("Sensor Touch Activated!") # GPIO3 = XIO-P4, using PocketCHIP nomenclature GPIO.setup("GPIO1", GPIO.IN) # Trigger when we go from LOW to HIGH to match code above GPIO.add_event_detect("GPIO1", GPIO.RISING, mycallback) # Dummy loop to keep the script alive dead = False while not dead: try: time.sleep(0.2) except KeyboardInterrupt: dead = True # Cleanup GPIO.remove_event_detect("GPIO1") GPIO.cleanup()
def close(self): GPIO.remove_event_detect(self.pin_clk) GPIO.remove_event_detect(self.pin_dt)