diff --git a/include/effect_big_clock.h b/include/effect_big_clock.h index 740b0d8..e61523c 100644 --- a/include/effect_big_clock.h +++ b/include/effect_big_clock.h @@ -8,7 +8,7 @@ private: CRGB _color_seconds = 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(); diff --git a/src/effect_big_clock.cpp b/src/effect_big_clock.cpp index 669a1fe..aa1c7d0 100644 --- a/src/effect_big_clock.cpp +++ b/src/effect_big_clock.cpp @@ -25,32 +25,33 @@ void BigClockEffect::loop() { 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, &_color_seconds); } uint16_t millis = ntpClient.getEpochMillis() % 1000; if (millis > 0) { - uint8_t part = 60 - ((60 - seconds) * millis / 1000); - _draw_border_pixel(part, &_color_seconds); + uint16_t position = ((60 - (60 - seconds) * millis) << 8) / 1000; + //uint8_t position = 60 - ((60 - seconds) * millis / 1000); + _draw_border_pixel(position>>8, position&0xFF, &_color_seconds); } } -void BigClockEffect::_draw_border_pixel(uint8_t i, CRGB* color) { - uint8_t x, y; +void BigClockEffect::_draw_border_pixel(uint8_t i, uint8_t part, CRGB* color) { + accum88 x, y; if (i<=8) { - x = 7 + i; + x = (7 + i)<<8 | part; y = 0; } else if (i<=23) { - x = 15; - y = i - 8; + x = 15 << 8; + y = (i - 8) << 8 | (255 - part); } else if (i<= 38) { - x = 15 - i + 23; - y = 15; + x = (15 - i + 23) << 8 | (255 - part); + y = 15 << 8; } else if (i <= 53) { x = 0; - y = 15 - i + 38; + y = (15 - i + 38) << 8 | part; } else { - x = i - 53; + x = (i - 53) << 8 | part; y = 0; } - window->setPixel(x, y, color); + window->setSubPixel(x, y, color); }