From 4c611da6d17808dcdc0f1a913ceddc4c008de235 Mon Sep 17 00:00:00 2001 From: Fabian Schlenz Date: Fri, 11 Oct 2019 17:56:18 +0200 Subject: [PATCH] Finally, big_clock is working correctly with smoothly moving seconds and stuff. Also, the spacing of the moving seconds is now configurable. --- include/effect_big_clock.h | 6 ++++-- include/settings.h | 6 +++++- src/effect_big_clock.cpp | 37 +++++++++++++++++++------------------ src/settings.cpp | 18 ++++++++++-------- 4 files changed, 38 insertions(+), 29 deletions(-) diff --git a/include/effect_big_clock.h b/include/effect_big_clock.h index e4791df..c7fe495 100644 --- a/include/effect_big_clock.h +++ b/include/effect_big_clock.h @@ -6,10 +6,12 @@ class BigClockEffect : public Effect { private: CRGB _color_font = CRGB(0xAAAAAA); CRGB _color_seconds_light = CRGB(0xFFFF00); - CRGB _color_seconds_dark = CRGB(0xFF0000); + CRGB _color_seconds_dark = CRGB(0xAA0000); + CRGB _color_seconds_moving_light = CRGB(0x666600); + CRGB _color_seconds_moving_dark = CRGB(0x660000); void _draw_seconds(); - void _draw_border_pixel(uint8_t second, uint8_t part, CRGB* color); + void _draw_border_pixel(accum88 pos, CRGB* color); public: void loop(uint16_t ms); diff --git a/include/settings.h b/include/settings.h index f0349d0..07a5455 100644 --- a/include/settings.h +++ b/include/settings.h @@ -32,6 +32,10 @@ struct Settings { uint16_t random_count = 32; } matrix; + struct /* big_clock */ { + uint16_t spacing = 5; + } big_clock; + struct /* confetti */ { uint16_t pixels_per_loop = 2; } confetti; @@ -75,7 +79,7 @@ struct Settings { uint16_t direction_change = 5; uint16_t slowdown = 2; } snake; - + struct /* tv_static */ { uint16_t black_bar_speed = 3500; } tv_static; diff --git a/src/effect_big_clock.cpp b/src/effect_big_clock.cpp index dc5e9b6..33569d6 100644 --- a/src/effect_big_clock.cpp +++ b/src/effect_big_clock.cpp @@ -2,6 +2,7 @@ #include "effect_big_clock.h" #include "fonts.h" #include "ntp.h" +#include "settings.h" void BigClockEffect::loop(uint16_t ms) { window->clear(); @@ -25,35 +26,35 @@ 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, 0, (i%5==0) ? &_color_seconds_light : &_color_seconds_dark); + _draw_border_pixel(i<<8, (i%5==0) ? &_color_seconds_light : &_color_seconds_dark); } uint16_t millis = ntpClient.getEpochMillis() % 1000; - uint8_t offset = 5 - (millis / 200); - uint8_t part = 255 - ((millis % 200) * 256 / 200); - uint8_t number_to_show = (60 - seconds - offset) / 5 + 1; - for(uint8_t i = 0; i 0) { int pos = s.lastIndexOf('\n'); String part = s.substring(pos + 1);