Skip to content

Commit

Permalink
Add key auto-repeat
Browse files Browse the repository at this point in the history
  • Loading branch information
Ralim committed Jul 12, 2017
1 parent e6f343c commit c8f49d1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
7 changes: 5 additions & 2 deletions workspace/ts100/inc/Interrupt.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ inline void resetLastButtonPress() {

}
inline void resetButtons() {
lastKeyPress = millis();
keyState = 0;
}

inline uint32_t getLastMovement() {
return lastMovement;
}
Expand All @@ -39,7 +39,10 @@ inline uint16_t getButtons() {
inline uint16_t getRawButtons() {
return rawKeys;
}

inline void restoreButtons()
{
keyState=getRawButtons();
}

/*IRQ prototypes*/
void NMI_Handler(void);
Expand Down
9 changes: 5 additions & 4 deletions workspace/ts100/src/Modes.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@ uint32_t temporaryTempStorage = 0;
void ProcessUI() {
uint8_t Buttons = getButtons(); //read the buttons status
static uint32_t lastModeChange = 0;
if (millis() - getLastButtonPress() < 30)
if (getRawButtons() && ((millis() - getLastButtonPress()) > 1000)) {
lastKeyPress = millis() - 600;
Buttons = getRawButtons();
} else if (millis() - getLastButtonPress() < 80) {
Buttons = 0;
else if (Buttons != 0) {
resetLastButtonPress();
} else if (Buttons != 0) {
resetButtons();
}
//rough prevention for de-bouncing and allocates settling time

switch (operatingMode) {
case STARTUP:
Expand Down

0 comments on commit c8f49d1

Please sign in to comment.