** Function: InputHandler ** Handles the variables PrevPress, NextPress, SelPress, AnyKeyPress and EscPress **********************************************************************/
| 47 | ** Handles the variables PrevPress, NextPress, SelPress, AnyKeyPress and EscPress |
| 48 | **********************************************************************/ |
| 49 | void InputHandler(void) { |
| 50 | static unsigned long tm = launcherMillis(); // debauce for buttons |
| 51 | static int posDifference = 0; |
| 52 | static int lastPos = 0; |
| 53 | bool sel = !BTN_ACT; |
| 54 | |
| 55 | int newPos = encoder->getPosition(); |
| 56 | if (newPos != lastPos) { |
| 57 | posDifference += (newPos - lastPos); |
| 58 | lastPos = newPos; |
| 59 | } |
| 60 | |
| 61 | if (launcherMillis() - tm < 200 && !LongPress) return; |
| 62 | |
| 63 | sel = launcherGpioRead(ENCODER_KEY); |
| 64 | |
| 65 | if (posDifference != 0 || sel == BTN_ACT) { |
| 66 | if (!wakeUpScreen()) AnyKeyPress = true; |
| 67 | else return; |
| 68 | } |
| 69 | if (posDifference > 0) { |
| 70 | PrevPress = true; |
| 71 | posDifference--; |
| 72 | } |
| 73 | if (posDifference < 0) { |
| 74 | NextPress = true; |
| 75 | posDifference++; |
| 76 | } |
| 77 | |
| 78 | if (sel == BTN_ACT) { |
| 79 | posDifference = 0; |
| 80 | SelPress = true; |
| 81 | tm = launcherMillis(); |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | /********************************************************************* |
| 86 | ** Function: powerOff |
nothing calls this directly
no test coverage detected