38 lines
930 B
C++
38 lines
930 B
C++
|
#include "effect_pixelclock.h"
|
||
|
#include "ntp.h"
|
||
|
|
||
|
PixelClockEffect::PixelClockEffect() {
|
||
|
window = new Window(0, 0, LED_WIDTH, LED_HEIGHT-7);
|
||
|
}
|
||
|
|
||
|
void PixelClockEffect::start() {
|
||
|
_color_seconds = new CRGB(0x00FF00);
|
||
|
_color_minutes = new CRGB(0xFFFF00);
|
||
|
}
|
||
|
|
||
|
void PixelClockEffect::stop() {
|
||
|
delete _color_seconds;
|
||
|
delete _color_minutes;
|
||
|
}
|
||
|
|
||
|
void PixelClockEffect::loop() {
|
||
|
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);
|
||
|
if (s<=seconds) window->setPixel(x, y, _color_seconds);
|
||
|
}
|
||
|
|
||
|
uint8_t minutes = ntpClient.getMinutes();
|
||
|
for (uint8_t m=0; m<60; m++) {
|
||
|
x = 6 - m/10;
|
||
|
y = window->height - 1 - (m % 10);
|
||
|
if (m<=minutes) window->setPixel(x, y, _color_seconds);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
bool PixelClockEffect::can_be_shown_with_clock() { return true; }
|