MCPcopy Create free account
hub / github.com/bmorcelli/Launcher / InputHandler

Function InputHandler

boards/m5stack-dinmeter/interface.cpp:49–83  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

47** Handles the variables PrevPress, NextPress, SelPress, AnyKeyPress and EscPress
48**********************************************************************/
49void InputHandler(void) {
50 static unsigned long tm = launcherMillis(); // debauce for buttons
51 static int posDifference = 0;
52 static int lastPos = 0;
53 bool sel = !BTN_ACT;
54
55 int newPos = encoder->getPosition();
56 if (newPos != lastPos) {
57 posDifference += (newPos - lastPos);
58 lastPos = newPos;
59 }
60
61 if (launcherMillis() - tm < 200 && !LongPress) return;
62
63 sel = launcherGpioRead(ENCODER_KEY);
64
65 if (posDifference != 0 || sel == BTN_ACT) {
66 if (!wakeUpScreen()) AnyKeyPress = true;
67 else return;
68 }
69 if (posDifference > 0) {
70 PrevPress = true;
71 posDifference--;
72 }
73 if (posDifference < 0) {
74 NextPress = true;
75 posDifference++;
76 }
77
78 if (sel == BTN_ACT) {
79 posDifference = 0;
80 SelPress = true;
81 tm = launcherMillis();
82 }
83}
84
85/*********************************************************************
86** Function: powerOff

Callers

nothing calls this directly

Calls 3

launcherMillisFunction · 0.85
launcherGpioReadFunction · 0.85
wakeUpScreenFunction · 0.85

Tested by

no test coverage detected