Debounce on release
This commit is contained in:
parent
31eca35b40
commit
4ca434c6d1
@ -73,22 +73,25 @@ void kbscan_event(void) {
|
|||||||
if (new_b != last_b) {
|
if (new_b != last_b) {
|
||||||
// If timer 2 is running
|
// If timer 2 is running
|
||||||
if (TR2) {
|
if (TR2) {
|
||||||
// Debounce releases
|
// Debounce presses and releases
|
||||||
if (!new_b) {
|
if (new_b) {
|
||||||
|
// Restore bit, so that this press can be handled later
|
||||||
|
new &= ~(1 << j);
|
||||||
|
// Skip processing of press
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
// Restore bit, so that this release can be handled later
|
// Restore bit, so that this release can be handled later
|
||||||
new |= (1 << j);
|
new |= (1 << j);
|
||||||
// Skip processing of release
|
// Skip processing of release
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Begin debouncing on press
|
// Begin debouncing on press or release
|
||||||
if (new_b) {
|
// Run timer 2 for 20 ms
|
||||||
// Run timer 2 for 20 ms
|
// 65536-(20000 * 69 + 89)/90 = 0xC419
|
||||||
// 65536-(20000 * 69 + 89)/90 = 0xC419
|
TH2 = 0xC4;
|
||||||
TH2 = 0xC4;
|
TL2 = 0x19;
|
||||||
TL2 = 0x19;
|
TR2 = 1;
|
||||||
TR2 = 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t key = keymap(i, j, kbscan_layer);
|
uint16_t key = keymap(i, j, kbscan_layer);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user