** Function: InputHandler ** Handles touch and button inputs ** Maps to PrevPress, NextPress, SelPress, AnyKeyPress, EscPress **********************************************************************/
| 179 | ** Maps to PrevPress, NextPress, SelPress, AnyKeyPress, EscPress |
| 180 | **********************************************************************/ |
| 181 | void InputHandler(void) { |
| 182 | static long tm = 0; |
| 183 | |
| 184 | if (millis() - tm > 200 || LongPress) { |
| 185 | // ---- Touch Screen Input ---- |
| 186 | if (touchInitialized) { |
| 187 | int16_t raw_x, raw_y; |
| 188 | if (ft6336_read_touch(raw_x, raw_y)) { |
| 189 | tm = millis(); |
| 190 | |
| 191 | // Apply rotation transformation |
| 192 | int16_t t_x = raw_x; |
| 193 | int16_t t_y = raw_y; |
| 194 | |
| 195 | if (bruceConfigPins.rotation == 1) { |
| 196 | // Landscape: swap and mirror |
| 197 | t_x = raw_y; |
| 198 | t_y = (TFT_WIDTH - 1) - raw_x; |
| 199 | } else if (bruceConfigPins.rotation == 2) { |
| 200 | // Portrait inverted |
| 201 | t_x = (TFT_WIDTH - 1) - raw_x; |
| 202 | t_y = (TFT_HEIGHT - 1) - raw_y; |
| 203 | } else if (bruceConfigPins.rotation == 3) { |
| 204 | // Landscape inverted |
| 205 | t_x = (TFT_HEIGHT - 1) - raw_y; |
| 206 | t_y = raw_x; |
| 207 | } |
| 208 | // rotation == 0: portrait default, no transform needed |
| 209 | |
| 210 | if (!wakeUpScreen()) AnyKeyPress = true; |
| 211 | else return; |
| 212 | |
| 213 | // Set global touch point |
| 214 | touchPoint.x = t_x; |
| 215 | touchPoint.y = t_y; |
| 216 | touchPoint.pressed = true; |
| 217 | touchHeatMap(touchPoint); |
| 218 | } |
| 219 | } |
| 220 | |
| 221 | // ---- BOOT Button Input ---- |
| 222 | if (digitalRead(ES3C28P_BTN_PIN) == ES3C28P_BTN_ACT) { |
| 223 | if (!wakeUpScreen()) { |
| 224 | AnyKeyPress = true; |
| 225 | SelPress = true; |
| 226 | } |
| 227 | // Debounce |
| 228 | while (digitalRead(ES3C28P_BTN_PIN) == ES3C28P_BTN_ACT) delay(10); |
| 229 | } |
| 230 | } |
| 231 | } |
| 232 | |
| 233 | /********************************************************************* |
| 234 | ** Function: powerOff |
nothing calls this directly
no test coverage detected