From 0ecc843dd4635af7591798572474c7494f0de734 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 12 Jul 2019 22:30:03 +0000 Subject: [PATCH] further improve parameters and documentation --- chch-power.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/chch-power.py b/chch-power.py index 2156c81..835b760 100644 --- a/chch-power.py +++ b/chch-power.py @@ -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