Adding timing based debounce code
- Uses expiry timer to decide on when to allow a state change - Initial state transitions are unaffected - Use MinDebounceTime define in kll to configure - ms granularity
This commit is contained in:
parent
f708ce720c
commit
98f796d4df
3 changed files with 54 additions and 7 deletions
|
@ -40,6 +40,12 @@
|
|||
#error "Debounce threshold is too high... 32 bit max. Check .kll defines."
|
||||
#endif
|
||||
|
||||
#if ( MinDebounceTime_define > 0xFF )
|
||||
#error "MinDebounceTime is a maximum of 255 ms"
|
||||
#elif ( MinDebounceTime_define < 0x00 )
|
||||
#error "MinDebounceTime is a minimum 0 ms"
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
// ----- Enums -----
|
||||
|
@ -126,11 +132,12 @@ typedef struct GPIO_Pin {
|
|||
|
||||
// Debounce Element
|
||||
typedef struct KeyState {
|
||||
KeyPosition prevState;
|
||||
KeyPosition curState;
|
||||
DebounceCounter activeCount;
|
||||
DebounceCounter inactiveCount;
|
||||
} KeyState;
|
||||
KeyPosition prevState;
|
||||
KeyPosition curState;
|
||||
uint8_t prevDecisionTime;
|
||||
} __attribute__((packed)) KeyState;
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue