diff --git a/include/effect_big_clock.h b/include/effect_big_clock.h index adfc6ed..e4791df 100644 --- a/include/effect_big_clock.h +++ b/include/effect_big_clock.h @@ -5,10 +5,11 @@ class BigClockEffect : public Effect { private: CRGB _color_font = CRGB(0xAAAAAA); - CRGB _color_seconds = CRGB(0xFF0000); + CRGB _color_seconds_light = CRGB(0xFFFF00); + CRGB _color_seconds_dark = CRGB(0xFF0000); void _draw_seconds(); - void _draw_border_pixel(uint8_t second, CRGB* color); + void _draw_border_pixel(uint8_t second, uint8_t part, CRGB* color); public: void loop(uint16_t ms); diff --git a/src/effect_big_clock.cpp b/src/effect_big_clock.cpp index 727c808..854cb36 100644 --- a/src/effect_big_clock.cpp +++ b/src/effect_big_clock.cpp @@ -25,17 +25,28 @@ void BigClockEffect::loop(uint16_t ms) { void BigClockEffect::_draw_seconds() { uint8_t seconds = ntpClient.getSeconds(); for (int i=1; i<=seconds; i++) { - _draw_border_pixel(i, &_color_seconds); + _draw_border_pixel(i, 0, (i%5==0) ? &_color_seconds_light : &_color_seconds_dark); } + uint16_t millis = ntpClient.getEpochMillis() % 1000; + /* + // Enable this to have the next pixel move smoothly to its position if (millis > 0) { uint8_t part = 60 - ((60 - seconds) * millis / 1000); _draw_border_pixel(part, &_color_seconds); } + */ + uint8_t offset = 5 - ((millis % 1000) / 200); + uint8_t part = scale8(millis % 200, 200); + uint8_t number_to_show = (60 - seconds - offset) / 5 + 1; + for(uint8_t i = 0; isetPixel(x, y, color); + window->setPixel(x, y, color);*/ + accum88 x, y; + if (i<=8) { + x = ((7+i)<<8) + part; + y = 0; + } else if (i<=23) { + x = 15<<8; + y = ((i-8)<<8) + part; + } else if (i<=38) { + x = ((38-i)<<8) - part; + y = 15<<8; + } else if (i<=53) { + x = 0; + y = ((53-i)<<8) - part; + } else if (i<=60) { + x = ((i-53)<<8) + part; + y = 0; + } else { + return; + } + window->setSubPixel(x, y, color); }