Debounce on release

This commit is contained in:
Jeremy Soller 2020-02-10 15:53:32 -07:00
parent 31eca35b40
commit 4ca434c6d1
No known key found for this signature in database
GPG Key ID: E988B49EE78A7FB1

View File

@ -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);