2019-05-29 22:49:54 +00:00
|
|
|
#include "Effect.h"
|
|
|
|
#include "effect_big_clock.h"
|
2019-06-11 17:48:09 +00:00
|
|
|
#include "fonts.h"
|
2019-05-29 22:49:54 +00:00
|
|
|
#include "ntp.h"
|
|
|
|
|
|
|
|
void BigClockEffect::drawNumber(uint8_t number, int x, int y, CRGB color) {
|
2019-06-07 04:24:16 +00:00
|
|
|
char buffer[7];
|
|
|
|
sprintf(buffer, "%02d", number);
|
|
|
|
drawText(buffer, x, y, color);
|
2019-05-29 22:49:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void BigClockEffect::drawText(char *text, int x, int y, CRGB color) {
|
2019-06-07 04:24:16 +00:00
|
|
|
for (uint8_t i = 0; i < strlen(text); i++) {
|
2019-06-11 17:48:09 +00:00
|
|
|
window->drawChar(&font_numbers4x7, text[i], x + i * 4, y, &color);
|
2019-05-29 22:49:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void BigClockEffect::loop() {
|
2019-06-11 17:48:09 +00:00
|
|
|
window->clear();
|
2019-06-07 04:24:16 +00:00
|
|
|
drawNumber(ntpClient.getHours(), 0, 0, color_h);
|
|
|
|
drawNumber(ntpClient.getMinutes(), 8, 0, color_m);
|
2019-06-11 17:48:09 +00:00
|
|
|
drawNumber(ntpClient.getSeconds(), 8, 8, color_colon);
|
2019-05-29 22:49:54 +00:00
|
|
|
}
|