further improve parameters and documentation

This commit is contained in:
root 2019-07-12 22:30:03 +00:00
parent 13c93e37fb
commit 0ecc843dd4
1 changed files with 5 additions and 5 deletions

View File

@ -6,9 +6,9 @@ from subprocess import call
import sys
button_count = 2
longpress_delay = 0.6
shortpress_count_max_delay = 0.5
inter_press_max_delay = 0.5
longpress_delay = 0.6 # minimum time in s for a long press
inter_press_max_delay = 0.8 # maximum time in s between two presses
button_debounce_wait = 0.08 # time in s befor signal stabilizes
pin = {
0: {
@ -112,7 +112,7 @@ def switch_shortpressed(event):
c_pin['shortpress']['last_unpress'] = c_pin['last_unpress']
# determine delay between last rise of the switch and current rise
shortpress_delay = c_pin['last_unpress'] - c_pin['shortpress']['last_unpress']
if shortpress_delay > shortpress_count_max_delay:
if shortpress_delay > inter_press_max_delay:
c_pin['shortpress']['count'] = 1
else:
c_pin['shortpress']['count'] += 1
@ -124,7 +124,7 @@ def switch_pressed(event):
c_pin = pin[event.pin_num]
# debouncing
c_pin['last_press'] = 0
time.sleep(0.08)
time.sleep(button_debounce_wait)
if event.chip.input_pins[event.pin_num].value == 0:
return
# remove scheduled event