Merge pull request #130 from UltimateHackingKeyboard/key-release-debouncing

Fix key chattering
This commit is contained in:
László Monda
2018-06-27 14:13:05 +02:00
committed by GitHub
3 changed files with 6 additions and 6 deletions

View File

@@ -11,8 +11,8 @@ void PIT_KEY_DEBOUNCER_HANDLER(void)
for (uint8_t slotId=0; slotId<SLOT_COUNT; slotId++) {
for (uint8_t keyId=0; keyId<MAX_KEY_COUNT_PER_MODULE; keyId++) {
uint8_t *debounceCounter = &KeyStates[slotId][keyId].debounceCounter;
if (*debounceCounter < 0xff) {
(*debounceCounter)++;
if (*debounceCounter) {
--(*debounceCounter);
}
}
}

View File

@@ -9,7 +9,7 @@
// Macros:
#define KEY_DEBOUNCER_INTERVAL_MSEC 1
#define KEY_DEBOUNCER_TIMEOUT_MSEC 100
#define KEY_DEBOUNCER_TIMEOUT_MSEC 5
// Functions:

View File

@@ -324,10 +324,10 @@ static void updateActiveUsbReports(void)
key_state_t *keyState = &KeyStates[slotId][keyId];
key_action_t *action = &CurrentKeymap[activeLayer][slotId][keyId];
if (keyState->debounceCounter < KEY_DEBOUNCER_TIMEOUT_MSEC) {
if (keyState->debounceCounter) {
keyState->current = keyState->previous;
} else if (!keyState->previous && keyState->current) {
keyState->debounceCounter = 0;
} else if (keyState->previous != keyState->current) {
keyState->debounceCounter = KEY_DEBOUNCER_TIMEOUT_MSEC + 1;
}
if (keyState->current) {