** Function: checkReboot ** location: mykeyboard.cpp ** Btn logic to tornoff the device (name is odd btw) **********************************************************************/
| 79 | ** Btn logic to tornoff the device (name is odd btw) |
| 80 | **********************************************************************/ |
| 81 | void 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 | } |
nothing calls this directly
no test coverage detected