Merge PR #437 - debouncing logic
Mechanical switches exhibit temporary voltage fluctuations when electrical contact is made, which manifest as "bouncing" between the logical high and low states. Sampling the switch's state during this period of stability produces invalid results. The switch must be debounced by ignoring the generated interrupts until the switch's state has stabilized. This is implemented by delaying the input events until an empirically determined time has elapsed. As such this pull request introduces customizable high resolution timers for debouncing button down and up events. This software debouncing unfortunately increases the sensor watch's input latency. This is an acceptable tradeoff due to better usability: watch faces which require holding down buttons such as the pulsometer should work much more reliably after this patch. Reviewed-by: Matheus Afonso Martins Moreira <matheus@matheusmoreira.com> Tested-on-hardware-by: Krzysztof Gałka <@kshysztof@Discord> GitHub-Pull-Request: https://github.com/joeycastillo/Sensor-Watch/pull/437 References: https://en.wikipedia.org/wiki/Switch#Contact_bounce
This commit is contained in:
@@ -272,6 +272,10 @@ typedef struct {
|
||||
|
||||
// low energy mode countdown
|
||||
int32_t le_mode_ticks;
|
||||
uint8_t debounce_ticks_light;
|
||||
uint8_t debounce_ticks_alarm;
|
||||
uint8_t debounce_ticks_mode;
|
||||
bool ignore_alarm_btn_after_sleep;
|
||||
|
||||
// app resignation countdown (TODO: consolidate with LE countdown?)
|
||||
int16_t timeout_ticks;
|
||||
|
||||
Reference in New Issue
Block a user