Skip to content

Commit

Permalink
feat: add tap twice on TT key to go to target layer permanently
Browse files Browse the repository at this point in the history
  • Loading branch information
DriftKingTW committed May 11, 2023
1 parent 8fbe48c commit b6575fe
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ const long LED_INTERVAL = 5 * 1000;
unsigned long networkInfoPreviousMillis = 0;
const long NETWORK_INFO_INTERVAL = 5 * 1000;

// Tap-Toggle timer
unsigned long tapTogglePreviousMillis = 0;
uint8_t tapToggleCount = 0;

unsigned long currentMillis = 0;

bool isLowBattery = false;
Expand Down Expand Up @@ -919,7 +923,17 @@ void tapToggleActive(size_t index) {
*/
void tapToggleRelease(size_t orginalLayerIndex) {
isTemporaryToggled = false;
currentLayoutIndex = orginalLayerIndex;
tapToggleCount++;
if (currentMillis - tapTogglePreviousMillis < 300) {
if (tapToggleCount > 1) {
tapToggleCount = 0;
currentLayoutIndex = orginalLayerIndex;
}
} else {
tapToggleCount = 0;
currentLayoutIndex = orginalLayerIndex;
}
tapTogglePreviousMillis = currentMillis;
initKeys();
}

Expand Down

0 comments on commit b6575fe

Please sign in to comment.