** Function: InputHandler ** Handles the variables PrevPress, NextPress, SelPress, AnyKeyPress and EscPress **********************************************************************/
| 109 | ** Handles the variables PrevPress, NextPress, SelPress, AnyKeyPress and EscPress |
| 110 | **********************************************************************/ |
| 111 | void InputHandler(void) { |
| 112 | static unsigned long tm = 0; |
| 113 | if (millis() - tm < 200 && !LongPress) return; |
| 114 | #ifdef HAS_TOUCH |
| 115 | TouchPoint t; |
| 116 | checkPowerSaveTime(); |
| 117 | bool _IH_touched = tft.getTouch(&t.x, &t.y); |
| 118 | if (_IH_touched) { |
| 119 | NextPress = false; |
| 120 | PrevPress = false; |
| 121 | UpPress = false; |
| 122 | DownPress = false; |
| 123 | SelPress = false; |
| 124 | EscPress = false; |
| 125 | AnyKeyPress = false; |
| 126 | NextPagePress = false; |
| 127 | PrevPagePress = false; |
| 128 | touchPoint.pressed = false; |
| 129 | _IH_touched = false; |
| 130 | Serial.printf("\nRAW: Touch Pressed on x=%d, y=%d", t.x, t.y); |
| 131 | if (bruceConfigPins.rotation == 3) { |
| 132 | t.y = (tftHeight + 20) - t.y; |
| 133 | t.x = tftWidth - t.x; |
| 134 | } |
| 135 | if (bruceConfigPins.rotation == 0) { |
| 136 | uint16_t tmp = t.x; |
| 137 | t.x = map((tftHeight + 20) - t.y, 0, 320, 0, 240); |
| 138 | t.y = map(tmp, 0, 240, 0, 320); |
| 139 | } |
| 140 | if (bruceConfigPins.rotation == 2) { |
| 141 | uint16_t tmp = t.x; |
| 142 | t.x = map(t.y, 0, 320, 0, 240); |
| 143 | t.y = map(tftWidth - tmp, 0, 240, 0, 320); |
| 144 | } |
| 145 | |
| 146 | Serial.printf("\nROT: Touch Pressed on x=%d, y=%d, rot=%d\n", t.x, t.y, bruceConfigPins.rotation); |
| 147 | |
| 148 | if (!wakeUpScreen()) AnyKeyPress = true; |
| 149 | else return; |
| 150 | |
| 151 | // Touch point global variable |
| 152 | touchPoint.x = t.x; |
| 153 | touchPoint.y = t.y; |
| 154 | touchPoint.pressed = true; |
| 155 | touchHeatMap(touchPoint); |
| 156 | tm = millis(); |
| 157 | } |
| 158 | |
| 159 | #endif |
| 160 | #ifdef HAS_3_BUTTONS |
| 161 | bool upPressed = (digitalRead(UP_BTN) == LOW); |
| 162 | bool selPressed = (digitalRead(SEL_BTN) == LOW); |
| 163 | bool dwPressed = (digitalRead(DW_BTN) == LOW); |
| 164 | |
| 165 | bool anyPressed = upPressed || selPressed || dwPressed; |
| 166 | if (anyPressed) tm = millis(); |
| 167 | if (anyPressed && wakeUpScreen()) return; |
| 168 |
nothing calls this directly
no test coverage detected