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"
|
|
|
|
|
2019-09-04 03:59:30 +00:00
|
|
|
void BigClockEffect::loop() {
|
|
|
|
window->clear();
|
|
|
|
uint8_t h = ntpClient.getHours();
|
|
|
|
window->drawChar(&font_numbers3x5_blocky, 6, 2, '0' + (h / 10), &_color_font);
|
|
|
|
window->drawChar(&font_numbers3x5_blocky, 11, 2, '0' + (h % 10), &_color_font);
|
|
|
|
|
|
|
|
uint8_t m = ntpClient.getMinutes();
|
|
|
|
window->drawChar(&font_numbers3x5_blocky, 6, 9, '0' + (m / 10), &_color_font);
|
|
|
|
window->drawChar(&font_numbers3x5_blocky, 11, 9, '0' + (m % 10), &_color_font);
|
|
|
|
|
|
|
|
uint8_t s = ntpClient.getSeconds();
|
|
|
|
if (s & 1) {
|
|
|
|
window->setPixel(3, 10, &_color_font);
|
|
|
|
window->setPixel(3, 12, &_color_font);
|
|
|
|
}
|
|
|
|
|
|
|
|
_draw_seconds();
|
2019-05-29 22:49:54 +00:00
|
|
|
}
|
|
|
|
|
2019-09-04 03:59:30 +00:00
|
|
|
void BigClockEffect::_draw_seconds() {
|
|
|
|
uint8_t seconds = ntpClient.getSeconds();
|
|
|
|
for (int i=1; i<=seconds; i++) {
|
|
|
|
_draw_border_pixel(i, &_color_seconds);
|
|
|
|
}
|
|
|
|
uint16_t millis = ntpClient.getEpochMillis() % 1000;
|
|
|
|
if (millis > 0) {
|
|
|
|
uint8_t part = 60 - ((60 - seconds) * millis / 1000);
|
|
|
|
_draw_border_pixel(part, &_color_seconds);
|
|
|
|
}
|
2019-05-29 22:49:54 +00:00
|
|
|
}
|
|
|
|
|
2019-09-04 03:59:30 +00:00
|
|
|
void BigClockEffect::_draw_border_pixel(uint8_t i, CRGB* color) {
|
|
|
|
uint8_t x, y;
|
|
|
|
if (i<=8) {
|
|
|
|
x = 7 + i;
|
|
|
|
y = 0;
|
|
|
|
} else if (i<=23) {
|
|
|
|
x = 15;
|
|
|
|
y = i - 8;
|
|
|
|
} else if (i<= 38) {
|
|
|
|
x = 15 - i + 23;
|
|
|
|
y = 15;
|
|
|
|
} else if (i <= 53) {
|
|
|
|
x = 0;
|
|
|
|
y = 15 - i + 38;
|
|
|
|
} else {
|
|
|
|
x = i - 53;
|
|
|
|
y = 0;
|
|
|
|
}
|
|
|
|
window->setPixel(x, y, color);
|
2019-05-29 22:49:54 +00:00
|
|
|
}
|