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

Function checkReboot

boards/m5stack-cplus2/interface.cpp:81–109  ·  view source on GitHub ↗

** Function: checkReboot ** location: mykeyboard.cpp ** Btn logic to tornoff the device (name is odd btw) **********************************************************************/

Source from the content-addressed store, hash-verified

79** Btn logic to tornoff the device (name is odd btw)
80**********************************************************************/
81void checkReboot() {
82 static unsigned long time_count = 0;
83 static bool armed = false;
84 int countDown;
85 /* Long press power off */
86 if (launcherGpioRead(UP_BTN) == LOW) {
87 if (armed == false) {
88 time_count = launcherMillis();
89 armed = true;
90 return;
91 }
92 if (launcherMillis() - time_count < 500) return;
93
94 while (launcherGpioRead(UP_BTN) == LOW) {
95 // Display poweroff bar only if holding button
96 if (launcherMillis() - time_count > 500) {
97 tft->setCursor(60, 12);
98 tft->setTextSize(1);
99 tft->setTextColor(FGCOLOR, BGCOLOR);
100 countDown = (launcherMillis() - time_count) / 1000 + 1;
101 tft->printf(" PWR OFF IN %d/3\n", countDown);
102 launcherDelayMs(10);
103 }
104 }
105 // Clear text after releasing the button
106 tft->fillRect(60, 12, tftWidth - 60, 8, BGCOLOR);
107 }
108 armed = false;
109}

Callers

nothing calls this directly

Calls 7

launcherGpioReadFunction · 0.85
launcherMillisFunction · 0.85
launcherDelayMsFunction · 0.85
setCursorMethod · 0.45
setTextSizeMethod · 0.45
setTextColorMethod · 0.45
fillRectMethod · 0.45

Tested by

no test coverage detected