MCPcopy Create free account
hub / github.com/BruceDevices/firmware / InputHandler

Function InputHandler

boards/phantom/interface.cpp:64–119  ·  view source on GitHub ↗

** Function: InputHandler ** Handles the variables PrevPress, NextPress, SelPress, AnyKeyPress and EscPress **********************************************************************/

Source from the content-addressed store, hash-verified

62** Handles the variables PrevPress, NextPress, SelPress, AnyKeyPress and EscPress
63**********************************************************************/
64void InputHandler(void) {
65 static unsigned long tm = 0;
66 if (millis() - tm > 200 || LongPress) {
67 // I know R3CK.. I Should NOT nest if statements..
68 // but it is needed to not keep SPI bus used without need, it save resources
69 TouchPoint t;
70 // TouchPoint t2;
71 checkPowerSaveTime();
72 digitalWrite(TFT_CS, HIGH);
73 digitalWrite(TOUCH_CS, LOW);
74 bool _IH_touched = tft.getTouch(&t.x, &t.y);
75 // tft.getTouchRaw(&t2.x, &t2.y);
76 digitalWrite(TOUCH_CS, HIGH);
77 if (_IH_touched) {
78 NextPress = false;
79 PrevPress = false;
80 UpPress = false;
81 DownPress = false;
82 SelPress = false;
83 EscPress = false;
84 AnyKeyPress = false;
85 NextPagePress = false;
86 PrevPagePress = false;
87 touchPoint.pressed = false;
88 _IH_touched = false;
89
90 // Serial.printf("\nRAWRaw: Touch Pressed on x=%d, y=%d", t2.x, t2.y);
91 // Serial.printf("\nRAW: Touch Pressed on x=%d, y=%d", t.x, t.y);
92 if (bruceConfigPins.rotation == 0) {
93 t.y = (tftHeight + 20) - t.y;
94 t.x = tftWidth - t.x;
95 }
96 if (bruceConfigPins.rotation == 3) {
97 uint16_t tmp = t.x;
98 t.x = map((tftHeight + 20) - t.y, 0, 240, 0, 320);
99 t.y = map(tmp, 0, 320, 0, 240);
100 }
101 if (bruceConfigPins.rotation == 1) {
102 uint16_t tmp = t.x;
103 t.x = map(t.y, 0, 240, 0, 320);
104 t.y = map(tftWidth - tmp, 0, 320, 0, 240);
105 }
106 // Serial.printf("\nROT: Touch Pressed on x=%d, y=%d, rot: %d\n", t.x, t.y,
107 // bruceConfigPins.rotation);
108 tm = millis();
109 if (!wakeUpScreen()) AnyKeyPress = true;
110 else return;
111
112 // Touch point global variable
113 touchPoint.x = t.x;
114 touchPoint.y = t.y;
115 touchPoint.pressed = true;
116 touchHeatMap(touchPoint);
117 }
118 }
119}
120
121/*********************************************************************

Callers

nothing calls this directly

Calls 5

millisFunction · 0.85
checkPowerSaveTimeFunction · 0.85
wakeUpScreenFunction · 0.85
touchHeatMapFunction · 0.85
getTouchMethod · 0.80

Tested by

no test coverage detected