further improve parameters and documentation
This commit is contained in:
parent
13c93e37fb
commit
0ecc843dd4
|
@ -6,9 +6,9 @@ from subprocess import call
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
button_count = 2
|
button_count = 2
|
||||||
longpress_delay = 0.6
|
longpress_delay = 0.6 # minimum time in s for a long press
|
||||||
shortpress_count_max_delay = 0.5
|
inter_press_max_delay = 0.8 # maximum time in s between two presses
|
||||||
inter_press_max_delay = 0.5
|
button_debounce_wait = 0.08 # time in s befor signal stabilizes
|
||||||
|
|
||||||
pin = {
|
pin = {
|
||||||
0: {
|
0: {
|
||||||
|
@ -112,7 +112,7 @@ def switch_shortpressed(event):
|
||||||
c_pin['shortpress']['last_unpress'] = c_pin['last_unpress']
|
c_pin['shortpress']['last_unpress'] = c_pin['last_unpress']
|
||||||
# determine delay between last rise of the switch and current rise
|
# determine delay between last rise of the switch and current rise
|
||||||
shortpress_delay = c_pin['last_unpress'] - c_pin['shortpress']['last_unpress']
|
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
|
c_pin['shortpress']['count'] = 1
|
||||||
else:
|
else:
|
||||||
c_pin['shortpress']['count'] += 1
|
c_pin['shortpress']['count'] += 1
|
||||||
|
@ -124,7 +124,7 @@ def switch_pressed(event):
|
||||||
c_pin = pin[event.pin_num]
|
c_pin = pin[event.pin_num]
|
||||||
# debouncing
|
# debouncing
|
||||||
c_pin['last_press'] = 0
|
c_pin['last_press'] = 0
|
||||||
time.sleep(0.08)
|
time.sleep(button_debounce_wait)
|
||||||
if event.chip.input_pins[event.pin_num].value == 0:
|
if event.chip.input_pins[event.pin_num].value == 0:
|
||||||
return
|
return
|
||||||
# remove scheduled event
|
# remove scheduled event
|
||||||
|
|
Loading…
Reference in New Issue