Merge pull request #130 from UltimateHackingKeyboard/key-release-debouncing
Fix key chattering
This commit is contained in:
@@ -11,8 +11,8 @@ void PIT_KEY_DEBOUNCER_HANDLER(void)
|
|||||||
for (uint8_t slotId=0; slotId<SLOT_COUNT; slotId++) {
|
for (uint8_t slotId=0; slotId<SLOT_COUNT; slotId++) {
|
||||||
for (uint8_t keyId=0; keyId<MAX_KEY_COUNT_PER_MODULE; keyId++) {
|
for (uint8_t keyId=0; keyId<MAX_KEY_COUNT_PER_MODULE; keyId++) {
|
||||||
uint8_t *debounceCounter = &KeyStates[slotId][keyId].debounceCounter;
|
uint8_t *debounceCounter = &KeyStates[slotId][keyId].debounceCounter;
|
||||||
if (*debounceCounter < 0xff) {
|
if (*debounceCounter) {
|
||||||
(*debounceCounter)++;
|
--(*debounceCounter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
// Macros:
|
// Macros:
|
||||||
|
|
||||||
#define KEY_DEBOUNCER_INTERVAL_MSEC 1
|
#define KEY_DEBOUNCER_INTERVAL_MSEC 1
|
||||||
#define KEY_DEBOUNCER_TIMEOUT_MSEC 100
|
#define KEY_DEBOUNCER_TIMEOUT_MSEC 5
|
||||||
|
|
||||||
// Functions:
|
// Functions:
|
||||||
|
|
||||||
|
|||||||
@@ -324,10 +324,10 @@ static void updateActiveUsbReports(void)
|
|||||||
key_state_t *keyState = &KeyStates[slotId][keyId];
|
key_state_t *keyState = &KeyStates[slotId][keyId];
|
||||||
key_action_t *action = &CurrentKeymap[activeLayer][slotId][keyId];
|
key_action_t *action = &CurrentKeymap[activeLayer][slotId][keyId];
|
||||||
|
|
||||||
if (keyState->debounceCounter < KEY_DEBOUNCER_TIMEOUT_MSEC) {
|
if (keyState->debounceCounter) {
|
||||||
keyState->current = keyState->previous;
|
keyState->current = keyState->previous;
|
||||||
} else if (!keyState->previous && keyState->current) {
|
} else if (keyState->previous != keyState->current) {
|
||||||
keyState->debounceCounter = 0;
|
keyState->debounceCounter = KEY_DEBOUNCER_TIMEOUT_MSEC + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (keyState->current) {
|
if (keyState->current) {
|
||||||
|
|||||||
Reference in New Issue
Block a user