** Function: InputHandler ** Handles the variables PrevPress, NextPress, SelPress, AnyKeyPress and EscPress **********************************************************************/
| 52 | ** Handles the variables PrevPress, NextPress, SelPress, AnyKeyPress and EscPress |
| 53 | **********************************************************************/ |
| 54 | void InputHandler(void) { |
| 55 | static unsigned long tm = millis(); |
| 56 | static unsigned long esc_tm = millis(); |
| 57 | static bool esc_armed = false; |
| 58 | if (!(millis() - tm > 200 || LongPress)) return; |
| 59 | |
| 60 | bool u = digitalRead(UP_BTN); |
| 61 | bool d = digitalRead(DW_BTN); |
| 62 | bool r = digitalRead(R_BTN); |
| 63 | bool l = digitalRead(L_BTN); |
| 64 | bool s = digitalRead(SEL_BTN); |
| 65 | if (!s || !u || !d || !r || !l) { |
| 66 | tm = millis(); |
| 67 | if (!wakeUpScreen()) AnyKeyPress = true; |
| 68 | else return; |
| 69 | } |
| 70 | if (!l && !s) { |
| 71 | EscPress = true; |
| 72 | return; |
| 73 | } |
| 74 | if (!l) { |
| 75 | PrevPress = true; |
| 76 | if (esc_armed == false) { |
| 77 | esc_tm = millis(); |
| 78 | esc_armed = true; |
| 79 | } |
| 80 | } |
| 81 | if (esc_armed && millis() - esc_tm > 1000) { |
| 82 | esc_armed = false; |
| 83 | esc_tm = millis(); |
| 84 | PrevPress = false; |
| 85 | EscPress = true; |
| 86 | } |
| 87 | if (!r) NextPress = true; |
| 88 | if (!u) UpPress = true; |
| 89 | if (!d) DownPress = true; |
| 90 | if (!s) SelPress = true; |
| 91 | } |
| 92 | |
| 93 | /********************************************************************* |
| 94 | ** Function: powerOff |
nothing calls this directly
no test coverage detected