pitrix/src/effects/night_clock.cpp

27 lines
729 B
C++

#include "Effect.h"
#include "effects/night_clock.h"
#include "fonts.h"
#include <time.h>
void NightClockEffect::loop(uint16_t ms) {
window->clear();
time_t now;
tm timeinfo;
time(&now);
localtime_r(&now, &timeinfo);
uint8_t h = timeinfo.tm_hour;
CRGB color = CRGB(0x440000);
window->drawChar(&font5x7, 4<<8, 0<<8, '0' + (h / 10), &color);
window->drawChar(&font5x7, 10<<8, 0<<8, '0' + (h % 10), &color);
uint8_t m = timeinfo.tm_min;
window->drawChar(&font5x7, 4<<8, 9<<8, '0' + (m / 10), &color);
window->drawChar(&font5x7, 10<<8, 9<<8, '0' + (m % 10), &color);
uint8_t s = timeinfo.tm_sec;
if(s & 1) {
window->setPixel(2, 11, &color);
window->setPixel(2, 13, &color);
}
}