def checkbutton(self):
"""
debounced button
:return:
"""
ret = 0
ts = time.time()
if ts - self._last_check <= 0.05:
ret = 0
else:
state = GPIO.input(self._button) # Read button state
if (not self._last_state) and state:
print("got it")
ret = 1
self._last_state = state
self._last_check = time.time()
return ret
评论列表
文章目录