| 65 | void powerOff() { axp192.PowerOff(); } |
| 66 | |
| 67 | void checkReboot() { |
| 68 | static unsigned long time_count = 0; |
| 69 | static bool armed = false; |
| 70 | int countDown; |
| 71 | /* Long press power off */ |
| 72 | if (axp192.GetBtnPress()) { |
| 73 | if (armed == false) { |
| 74 | time_count = launcherMillis(); |
| 75 | armed = true; |
| 76 | return; |
| 77 | } |
| 78 | if (launcherMillis() - time_count < 500) return; |
| 79 | |
| 80 | while (axp192.GetBtnPress()) { |
| 81 | // Display poweroff bar only if holding button |
| 82 | if (launcherMillis() - time_count > 500) { |
| 83 | tft->setCursor(60, 12); |
| 84 | tft->setTextSize(1); |
| 85 | tft->setTextColor(FGCOLOR, BGCOLOR); |
| 86 | countDown = (launcherMillis() - time_count) / 1000 + 1; |
| 87 | tft->printf(" PWR OFF IN %d/3\n", countDown); |
| 88 | launcherDelayMs(10); |
| 89 | } |
| 90 | } |
| 91 | // Clear text after releasing the button |
| 92 | tft->fillRect(60, 12, tftWidth - 60, 8, BGCOLOR); |
| 93 | } |
| 94 | armed = false; |
| 95 | } |
nothing calls this directly
no test coverage detected