]> git.earman.xyz Git - sensor-watch.git/commitdiff
Merge PR #437 - debouncing logic
authorMatheus Afonso Martins Moreira <matheus@matheusmoreira.com>
Wed, 28 Aug 2024 13:30:44 +0000 (10:30 -0300)
committerMatheus Afonso Martins Moreira <matheus@matheusmoreira.com>
Fri, 30 Aug 2024 19:44:38 +0000 (16:44 -0300)
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

1  2 
movement/movement.c
movement/movement.h

Simple merge
Simple merge