pitrix/src/effect_clock.cpp

43 lines
1.3 KiB
C++
Raw Normal View History

#include "effect_clock.h"
#include <FastLED.h>
#include "functions.h"
#include "fonts.h"
#include "ntp.h"
void ClockEffect::loop() {
loop(false, CRGB(0xFFFFFF), CRGB(0x000000));
}
void ClockEffect::loop(boolean invert, CRGB fg_color, CRGB bg_color) {
2019-06-07 04:24:16 +00:00
if (!invert) {
window->clear(&bg_color);
2019-06-07 04:24:16 +00:00
} else {
// Manually clear the needed parts
for(int i=0; i<window->width; i++) window->setPixel(i, 0, &bg_color);
2019-06-07 04:24:16 +00:00
for(int y=0; y<6; y++) {
window->setPixel(3, y, &bg_color);
2019-06-07 04:24:16 +00:00
if (y!=2 && y!=4) {
window->setPixel(7, y, &bg_color);
2019-06-07 04:24:16 +00:00
}
window->setPixel(8, y, &bg_color);
window->setPixel(12, y, &bg_color);
2019-06-07 04:24:16 +00:00
}
fg_color = bg_color;
}
if (ntpClient.isTimeSet()==false && (ntpClient.getSeconds() & 1)==0) {
window->clear(&bg_color);
2019-06-07 04:24:16 +00:00
return;
}
int h = ntpClient.getHours();
//void drawChar(Font f, uint8_t x, uint8_t y, const char c, CRGB* color, bool mask=false);
window->drawChar(&font_numbers3x5, 0, 1, '0' + (h / 10), &fg_color, invert);
window->drawChar(&font_numbers3x5, 4, 1, '0' + (h % 10), &fg_color, invert);
2019-06-07 04:24:16 +00:00
int m = ntpClient.getMinutes();
window->drawChar(&font_numbers3x5, 9, 1, '0' + (m / 10), &fg_color, invert);
window->drawChar(&font_numbers3x5, 13, 1, '0' + (m % 10), &fg_color, invert);
2019-06-07 04:24:16 +00:00
if (ntpClient.getSeconds() & 1) {
window->setPixel(7, 2, &fg_color);
window->setPixel(7, 4, &fg_color);
2019-06-07 04:24:16 +00:00
}
}