本文整理汇总了Python中LMK.GPIO.remove_event_detect方法的典型用法代码示例。如果您正苦于以下问题:Python GPIO.remove_event_detect方法的具体用法?Python GPIO.remove_event_detect怎么用?Python GPIO.remove_event_detect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LMK.GPIO
的用法示例。
在下文中一共展示了GPIO.remove_event_detect方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_switchbounce
# 需要导入模块: from LMK import GPIO [as 别名]
# 或者: from LMK.GPIO import remove_event_detect [as 别名]
def test_switchbounce(self):
self.switchcount = 0
print "\nSwitch bounce test. Press switch at least 10 times and count..."
GPIO.add_event_detect(SWITCH_PIN, GPIO.FALLING, callback=self.cb, bouncetime=200)
while self.switchcount < 10:
time.sleep(1)
GPIO.remove_event_detect(SWITCH_PIN)
示例2: test_event_detected
# 需要导入模块: from LMK import GPIO [as 别名]
# 或者: from LMK.GPIO import remove_event_detect [as 别名]
def test_event_detected(self):
self.switchcount = 0
print "\nGPIO.event_detected() switch bounce test. Press switch at least 10 times and count..."
GPIO.add_event_detect(SWITCH_PIN, GPIO.FALLING, bouncetime=200)
while self.switchcount < 10:
if GPIO.event_detected(SWITCH_PIN):
self.switchcount += 1
print 'Button press',self.switchcount
GPIO.remove_event_detect(SWITCH_PIN)
示例3: testRisingEventDetected
# 需要导入模块: from LMK import GPIO [as 别名]
# 或者: from LMK.GPIO import remove_event_detect [as 别名]
def testRisingEventDetected(self):
GPIO.output(LOOP_OUT, GPIO.LOW)
GPIO.add_event_detect(LOOP_IN, GPIO.RISING)
time.sleep(0.001)
self.assertEqual(GPIO.event_detected(LOOP_IN), False)
GPIO.output(LOOP_OUT, GPIO.HIGH)
time.sleep(0.001)
self.assertEqual(GPIO.event_detected(LOOP_IN), True)
GPIO.output(LOOP_OUT, GPIO.LOW)
time.sleep(0.001)
self.assertEqual(GPIO.event_detected(LOOP_IN), False)
GPIO.remove_event_detect(LOOP_IN)
示例4: testEventDetect
# 需要导入模块: from LMK import GPIO [as 别名]
# 或者: from LMK.GPIO import remove_event_detect [as 别名]
def testEventDetect(pin, trigger):
switchCnt = 0
GPIO.setup(pin, GPIO.IN, GPIO.PUD_UP)
GPIO.add_event_detect(pin, trigger)
while switchCnt < 2:
if GPIO.event_detected(pin):
switchCnt += 1
print 'The event has been detected'
print "\n value_%d = %d\n" %(pin,GPIO.input(pin))
GPIO.remove_event_detect(pin)
示例5: testExceptionInCallback
# 需要导入模块: from LMK import GPIO [as 别名]
# 或者: from LMK.GPIO import remove_event_detect [as 别名]
def testExceptionInCallback(self):
self.run_cb = False
def cb(channel):
with self.assertRaises(ZeroDivisionError):
self.run_cb = True
a = 1/0
GPIO.output(LOOP_OUT, GPIO.LOW)
GPIO.add_event_detect(LOOP_IN, GPIO.RISING, callback=cb)
time.sleep(0.001)
GPIO.output(LOOP_OUT, GPIO.HIGH)
time.sleep(0.001)
self.assertEqual(self.run_cb, True)
GPIO.remove_event_detect(LOOP_IN)
示例6: testAddEventCallback
# 需要导入模块: from LMK import GPIO [as 别名]
# 或者: from LMK.GPIO import remove_event_detect [as 别名]
def testAddEventCallback(self):
def cb(channel):
self.callback_count += 1
# falling test
self.callback_count = 0
GPIO.output(LOOP_OUT, GPIO.HIGH)
GPIO.add_event_detect(LOOP_IN, GPIO.FALLING)
GPIO.add_event_callback(LOOP_IN, cb)
time.sleep(0.001)
for i in range(5):
GPIO.output(LOOP_OUT, GPIO.LOW)
time.sleep(0.001)
GPIO.output(LOOP_OUT, GPIO.HIGH)
time.sleep(0.001)
self.assertEqual(self.callback_count, 5)
GPIO.remove_event_detect(LOOP_IN)
# rising test
self.callback_count = 0
GPIO.output(LOOP_OUT, GPIO.LOW)
GPIO.add_event_detect(LOOP_IN, GPIO.RISING, callback=cb)
time.sleep(0.001)
for i in range(5):
GPIO.output(LOOP_OUT, GPIO.HIGH)
time.sleep(0.001)
GPIO.output(LOOP_OUT, GPIO.LOW)
time.sleep(0.001)
self.assertEqual(self.callback_count, 5)
GPIO.remove_event_detect(LOOP_IN)
# both test
self.callback_count = 0
GPIO.output(LOOP_OUT, GPIO.LOW)
GPIO.add_event_detect(LOOP_IN, GPIO.BOTH, callback=cb)
time.sleep(0.001)
for i in range(5):
GPIO.output(LOOP_OUT, GPIO.HIGH)
time.sleep(0.001)
GPIO.output(LOOP_OUT, GPIO.LOW)
time.sleep(0.001)
self.assertEqual(self.callback_count, 10)
GPIO.remove_event_detect(LOOP_IN)
示例7:
# 需要导入模块: from LMK import GPIO [as 别名]
# 或者: from LMK.GPIO import remove_event_detect [as 别名]
#!/usr/bin/env python
import LMK.GPIO as GPIO
import time
from threading import Timer
SWITCH_PIN = 18
GPIO.setmode(GPIO.BOARD)
GPIO.setup(SWITCH_PIN,GPIO.IN,GPIO.PUD_UP)
print "\n value_%d = %d\n" %(SWITCH_PIN,GPIO.input(SWITCH_PIN))
GPIO.add_event_detect(SWITCH_PIN, GPIO.RISING,bouncetime=200) # add rising edge detection on a channel
switchcount = 0
while switchcount < 2:
if GPIO.event_detected(SWITCH_PIN):
switchcount += 1
print 'Button pressed',switchcount
print "\n value_%d = %d\n" %(SWITCH_PIN,GPIO.input(SWITCH_PIN))
GPIO.remove_event_detect(SWITCH_PIN)
示例8: testCallback
# 需要导入模块: from LMK import GPIO [as 别名]
# 或者: from LMK.GPIO import remove_event_detect [as 别名]
import LMK.GPIO as GPIO
import time
#The following pins support the external event detected on the 40Pin Header of the LeMake Guitar
'''P8 P10 P12 P13 P15 P16 P22 P19 P23'''
#The following pins support the external event detected on the 40Pin Header of the BananaPro
'''P7 P8 P10 P11 P13 P15 P16 P18 P19 P21 P22 P23 P24 P26'''
testPinOnGt = 8 #For LeMaker Guitar
testPinOnBP = 18 #For BananaPro
GPIO.setmode(GPIO.BOARD)
GPIO.setup(testPinOnGt, GPIO.IN, GPIO.PUD_UP)
def testCallback(channel):
print "running callback function", channel
GPIO.add_event_detect(testPinOnGt, GPIO.RISING, callback=testCallback, bouncetime=300)
try:
while True:
time.sleep(1)
except KeyboardInterrupt:
pass
GPIO.remove_event_detect(testPinOnGt)
GPIO.cleanup()