22 lines
423 B
Python
Raw Normal View History

2022-06-17 14:45:52 +08:00
import TemplateDevice
io1 = TemplateDevice.GPIO()
io1.setPin('PA8')
io1.setMode('in')
io1.enable()
EVENT_SIGAL_IO_RISING_EDGE = 0x01
EVENT_SIGAL_IO_FALLING_EDGE = 0x02
2022-11-05 13:20:23 +08:00
2022-06-17 14:45:52 +08:00
def callBack1(signal):
if signal == EVENT_SIGAL_IO_RISING_EDGE:
print('get rising edge!')
elif signal == EVENT_SIGAL_IO_FALLING_EDGE:
print('get falling edge!')
2022-11-05 13:20:23 +08:00
else:
return signal
2022-06-17 14:45:52 +08:00
io1.addEventCallBack(callBack1)