btclock_v2/src/screens/countdown.cpp

43 lines
1.2 KiB
C++
Raw Normal View History

2023-06-10 19:23:31 +00:00
#include "countdown.hpp"
uint CountdownScreen::countdownMinutes = 1;
uint CountdownScreen::countdownSeconds = 0;
std::array<String, NUM_SCREENS> CountdownScreen::epdContent = {"COUNT/DOWN", "", "", "", "", "", ""};
2023-06-10 19:23:31 +00:00
void CountdownScreen::init()
{
CountdownScreen::showScreen();
}
void CountdownScreen::showScreen()
{
}
std::array<String, NUM_SCREENS> CountdownScreen::getEpdContent()
2023-06-10 19:23:31 +00:00
{
return CountdownScreen::epdContent;
}
void CountdownScreen::setCountdownSeconds(uint sec) {
countdownSeconds = sec;
}
void CountdownScreen::countdownTask(void *pvParameters)
{
for (int i = CountdownScreen::countdownSeconds; i >= 0; i--)
{
char countdownString[NUM_SCREENS];
2023-06-10 19:23:31 +00:00
sprintf(countdownString, "%02d:%02d", i / 60, i % 60);
std::string timeString = countdownString;
timeString.insert(timeString.begin(), NUM_SCREENS - timeString.length(), ' ');
2023-06-10 19:23:31 +00:00
CountdownScreen::epdContent[0] = "COUNT/DOWN";
for (uint i = 1; i < 7; i++)
{
CountdownScreen::epdContent[i] = timeString[i];
}
vTaskDelay(pdMS_TO_TICKS(1000));
}
Serial.println("Countdown finished!");
vTaskDelete(NULL);
}