Mercurial > louis > kiibohd-controller
comparison Scan/MatrixARM/matrix_scan.h @ 343:e464aaa4730f
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
author | Jacob Alexander <haata@kiibohd.com> |
---|---|
date | Fri, 19 Jun 2015 01:50:56 -0700 |
parents | 66eccdd9ced5 |
children | 293154e4aafe |
comparison
equal
deleted
inserted
replaced
342:b29c291ad130 | 343:e464aaa4730f |
---|---|
36 #define DebounceCounter uint16_t | 36 #define DebounceCounter uint16_t |
37 #elif ( DebounceDivThreshold_define < 0xFFFFFFFF + 1 ) | 37 #elif ( DebounceDivThreshold_define < 0xFFFFFFFF + 1 ) |
38 #define DebounceCounter uint32_t | 38 #define DebounceCounter uint32_t |
39 #else | 39 #else |
40 #error "Debounce threshold is too high... 32 bit max. Check .kll defines." | 40 #error "Debounce threshold is too high... 32 bit max. Check .kll defines." |
41 #endif | |
42 | |
43 #if ( MinDebounceTime_define > 0xFF ) | |
44 #error "MinDebounceTime is a maximum of 255 ms" | |
45 #elif ( MinDebounceTime_define < 0x00 ) | |
46 #error "MinDebounceTime is a minimum 0 ms" | |
41 #endif | 47 #endif |
42 | 48 |
43 | 49 |
44 | 50 |
45 // ----- Enums ----- | 51 // ----- Enums ----- |
124 Pin pin; | 130 Pin pin; |
125 } GPIO_Pin; | 131 } GPIO_Pin; |
126 | 132 |
127 // Debounce Element | 133 // Debounce Element |
128 typedef struct KeyState { | 134 typedef struct KeyState { |
135 DebounceCounter activeCount; | |
136 DebounceCounter inactiveCount; | |
129 KeyPosition prevState; | 137 KeyPosition prevState; |
130 KeyPosition curState; | 138 KeyPosition curState; |
131 DebounceCounter activeCount; | 139 uint8_t prevDecisionTime; |
132 DebounceCounter inactiveCount; | 140 } __attribute__((packed)) KeyState; |
133 } KeyState; | |
134 | 141 |
135 | 142 |
136 | 143 |
137 // ----- Functions ----- | 144 // ----- Functions ----- |
138 | 145 |