pitrix/src/effect_big_clock.cpp

24 lines
681 B
C++

#include "Effect.h"
#include "effect_big_clock.h"
#include "fonts.h"
#include "ntp.h"
void BigClockEffect::drawNumber(uint8_t number, int x, int y, CRGB color) {
char buffer[7];
sprintf(buffer, "%02d", number);
drawText(buffer, x, y, color);
}
void BigClockEffect::drawText(char *text, int x, int y, CRGB color) {
for (uint8_t i = 0; i < strlen(text); i++) {
window->drawChar(&font_numbers4x7, text[i], x + i * 4, y, &color);
}
}
void BigClockEffect::loop() {
window->clear();
drawNumber(ntpClient.getHours(), 0, 0, color_h);
drawNumber(ntpClient.getMinutes(), 8, 0, color_m);
drawNumber(ntpClient.getSeconds(), 8, 8, color_colon);
}