2019-06-15 12:18:35 +00:00
|
|
|
#include "effect_pixelclock.h"
|
|
|
|
#include "ntp.h"
|
|
|
|
|
|
|
|
PixelClockEffect::PixelClockEffect() {
|
2019-06-16 10:43:34 +00:00
|
|
|
window = new Window(0, 0, LED_WIDTH, LED_HEIGHT-6);
|
2019-06-15 12:18:35 +00:00
|
|
|
_color_seconds = new CRGB(0x00FF00);
|
|
|
|
_color_minutes = new CRGB(0xFFFF00);
|
|
|
|
}
|
|
|
|
|
2019-06-18 16:09:05 +00:00
|
|
|
PixelClockEffect::~PixelClockEffect() {
|
2019-06-15 12:18:35 +00:00
|
|
|
delete _color_seconds;
|
|
|
|
delete _color_minutes;
|
2019-06-19 20:23:49 +00:00
|
|
|
delete window;
|
2019-06-15 12:18:35 +00:00
|
|
|
}
|
|
|
|
|
2019-10-01 04:29:32 +00:00
|
|
|
void PixelClockEffect::loop(uint16_t ms) {
|
2019-06-15 12:18:35 +00:00
|
|
|
uint8_t x, y; // Temporary variables for calculating positions
|
|
|
|
window->clear();
|
|
|
|
// Seconds
|
|
|
|
uint8_t seconds = ntpClient.getSeconds();
|
|
|
|
for (uint8_t s=0; s<60; s++) {
|
|
|
|
x = window->width - 1 - s/10;
|
|
|
|
y = window->height - 1 - (s % 10);
|
2019-06-16 10:43:34 +00:00
|
|
|
if (s<seconds) window->setPixel(x, y, _color_seconds);
|
2019-06-15 12:18:35 +00:00
|
|
|
}
|
2019-06-16 10:43:34 +00:00
|
|
|
|
2019-06-15 12:18:35 +00:00
|
|
|
uint8_t minutes = ntpClient.getMinutes();
|
|
|
|
for (uint8_t m=0; m<60; m++) {
|
|
|
|
x = 6 - m/10;
|
|
|
|
y = window->height - 1 - (m % 10);
|
2019-06-16 10:43:34 +00:00
|
|
|
if (m<minutes) window->setPixel(x, y, _color_minutes);
|
2019-06-15 12:18:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool PixelClockEffect::can_be_shown_with_clock() { return true; }
|