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

Function InputHandler

boards/marauder-touch/interface.cpp:63–136  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

61** Handles the variables PrevPress, NextPress, SelPress, AnyKeyPress and EscPress
62**********************************************************************/
63void InputHandler(void) {
64 static unsigned long tm = millis();
65 if (millis() - tm > 300 || LongPress) { // don´t allow multiple readings in less than 200ms
66 if (touch.touched()) {
67 auto t = touch.getPointScaled();
68 t = touch.getPointScaled();
69 tm = millis();
70 if (bruceConfigPins.rotation == 3) {
71 t.y = (tftHeight + 20) - t.y;
72 t.x = tftWidth - t.x;
73 }
74 if (bruceConfigPins.rotation == 0) {
75 int tmp = t.x;
76 t.x = tftWidth - t.y;
77 t.y = tmp;
78 }
79 if (bruceConfigPins.rotation == 2) {
80 int tmp = t.x;
81 t.x = t.y;
82 t.y = (tftHeight + 20) - tmp;
83 }
84 Serial.printf("Touched at x=%d, y=%d, rot=%d\n", t.x, t.y, bruceConfigPins.rotation);
85
86 if (!wakeUpScreen()) AnyKeyPress = true;
87 else return;
88
89 // Touch point global variable
90 touchPoint.x = t.x;
91 touchPoint.y = t.y;
92 touchPoint.pressed = true;
93 touchHeatMap(touchPoint);
94 } else touchPoint.pressed = false;
95 }
96
97#ifdef WAVESENTRY
98 static unsigned long lastEncoderMoveMs = 0;
99 static int posDifference = 0;
100 static int lastPos = 0;
101 bool sel = !BTN_ACT;
102
103 int newPos = encoder->getPosition();
104 if (newPos != lastPos) {
105 posDifference += (newPos - lastPos);
106 lastPos = newPos;
107 lastEncoderMoveMs = millis();
108 } else if (posDifference != 0 && millis() - lastEncoderMoveMs > 30) {
109 // Drop any stale queued steps once the encoder has stopped moving.
110 posDifference = 0;
111 }
112
113 if (millis() - tm < 200 && !LongPress) return;
114
115 sel = digitalRead(ENCODER_KEY);
116
117 if (posDifference != 0 || sel == BTN_ACT) {
118 if (!wakeUpScreen()) AnyKeyPress = true;
119 else return;
120 }

Callers

nothing calls this directly

Calls 6

millisFunction · 0.85
wakeUpScreenFunction · 0.85
touchHeatMapFunction · 0.85
touchedMethod · 0.45
getPointScaledMethod · 0.45
printfMethod · 0.45

Tested by

no test coverage detected