Changed NightClock to be a special form of BigClock.
This commit is contained in:
@ -11,35 +11,43 @@ void BigClockEffect::loop(uint16_t ms) {
|
||||
time(&now);
|
||||
localtime_r(&now, &timeinfo);
|
||||
uint8_t h = timeinfo.tm_hour;
|
||||
window->drawChar(&font_numbers3x5_blocky, 6<<8, 2<<8, '0' + (h / 10), &_color_font);
|
||||
window->drawChar(&font_numbers3x5_blocky, 11<<8, 2<<8, '0' + (h % 10), &_color_font);
|
||||
CRGB color = _get_color_font();
|
||||
window->drawChar(&font_numbers3x5_blocky, 6<<8, 2<<8, '0' + (h / 10), &color);
|
||||
window->drawChar(&font_numbers3x5_blocky, 11<<8, 2<<8, '0' + (h % 10), &color);
|
||||
|
||||
uint8_t m = timeinfo.tm_min;
|
||||
window->drawChar(&font_numbers3x5_blocky, 6<<8, 9<<8, '0' + (m / 10), &_color_font);
|
||||
window->drawChar(&font_numbers3x5_blocky, 11<<8, 9<<8, '0' + (m % 10), &_color_font);
|
||||
window->drawChar(&font_numbers3x5_blocky, 6<<8, 9<<8, '0' + (m / 10), &color);
|
||||
window->drawChar(&font_numbers3x5_blocky, 11<<8, 9<<8, '0' + (m % 10), &color);
|
||||
|
||||
uint8_t s = timeinfo.tm_sec;
|
||||
if (s & 1) {
|
||||
window->setPixel(3, 10, &_color_font);
|
||||
window->setPixel(3, 12, &_color_font);
|
||||
}
|
||||
_draw_colon(s & 1);
|
||||
|
||||
_draw_seconds(timeinfo.tm_sec);
|
||||
}
|
||||
|
||||
void BigClockEffect::_draw_colon(bool odd) {
|
||||
if (odd) {
|
||||
CRGB color = _get_color_font();
|
||||
window->setPixel(3, 10, &color);
|
||||
window->setPixel(3, 12, &color);
|
||||
}
|
||||
}
|
||||
|
||||
void BigClockEffect::_draw_seconds(uint8_t seconds) {
|
||||
for (int i=1; i<=seconds; i++) {
|
||||
_draw_border_pixel(i<<8, (i%5==0) ? &_color_seconds_light : &_color_seconds_dark);
|
||||
}
|
||||
|
||||
uint16_t mil = millis() % 1000;
|
||||
|
||||
/*timeval tv;
|
||||
gettimeofday(&tv, nullptr);
|
||||
uint16_t mil = (tv.tv_usec / 1000) % 1000;
|
||||
accum88 pos = (seconds<<8) + ((settings.effects.big_clock.spacing-1)<<8) * (1000 - mil) / 1000 + (1<<8);
|
||||
uint8_t sec = seconds + 1;
|
||||
while (pos < (60<<8)) {
|
||||
_draw_border_pixel(pos, sec%5==0 ? &_color_seconds_moving_light : &_color_seconds_moving_dark);
|
||||
pos += settings.effects.big_clock.spacing<<8;
|
||||
sec++;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
void BigClockEffect::_draw_border_pixel(accum88 i, CRGB* color) {
|
||||
|
@ -4,18 +4,6 @@
|
||||
#include "fonts.h"
|
||||
#include "ntp.h"
|
||||
|
||||
NightClockEffect::NightClockEffect() {
|
||||
window = Window::getFullWindow();
|
||||
}
|
||||
|
||||
void NightClockEffect::loop(uint16_t ms) {
|
||||
uint16_t minutes = minutes16();
|
||||
//uint8_t y = minutes % ((window->height - 5) * 2 - 2);
|
||||
//if (y > window->height - 5) y = 2*window->height - 2*y;
|
||||
uint8_t y = minutes % 10;
|
||||
ClockEffect::loop(false, CRGB(0x200000), CRGB(0x000000), y);
|
||||
}
|
||||
|
||||
void ClockEffect::loop(uint16_t ms) {
|
||||
loop_with_invert(false);
|
||||
}
|
||||
@ -66,7 +54,3 @@ void ClockEffect::loop(boolean invert, CRGB fg_color, CRGB bg_color, uint8_t yPo
|
||||
ClockEffect::~ClockEffect() {
|
||||
delete window;
|
||||
}
|
||||
|
||||
NightClockEffect::~NightClockEffect() {
|
||||
delete window;
|
||||
}
|
Reference in New Issue
Block a user