diff --git a/include/effect_big_clock.h b/include/effect_big_clock.h index 20dda87..742d51e 100644 --- a/include/effect_big_clock.h +++ b/include/effect_big_clock.h @@ -19,11 +19,3 @@ public: virtual void loop(uint16_t ms); String get_name() override { return "big_clock"; } }; - -class NightClockEffect : public BigClockEffect { -private: - CRGB _color_font = CRGB(0x440000); - CRGB _color_colon = CRGB(0x000000); - void _draw_border_pixel(accum88 pos, CRGB* color) { }; - CRGB _get_color_font() { return CRGB(0x440000); } -}; diff --git a/include/effects/night_clock.h b/include/effects/night_clock.h new file mode 100644 index 0000000..fbec903 --- /dev/null +++ b/include/effects/night_clock.h @@ -0,0 +1,8 @@ +#pragma once +#include "Effect.h" + +class NightClockEffect : public Effect { +public: + virtual void loop(uint16_t ms); + String get_name() override { return "night_clock"; } +}; \ No newline at end of file diff --git a/src/effects.cpp b/src/effects.cpp index 0f911fa..f9e0345 100644 --- a/src/effects.cpp +++ b/src/effects.cpp @@ -26,6 +26,7 @@ #include "effect_diamond.h" #include "effect_tpm2_net.h" #include "SimpleEffect.h" +#include "effects/night_clock.h" Effect* current_effect; diff --git a/src/effects/night_clock.cpp b/src/effects/night_clock.cpp new file mode 100644 index 0000000..c09fc6c --- /dev/null +++ b/src/effects/night_clock.cpp @@ -0,0 +1,26 @@ +#include "Effect.h" +#include "effects/night_clock.h" +#include "fonts.h" +#include + +void NightClockEffect::loop(uint16_t ms) { + window->clear(); + time_t now; + tm timeinfo; + time(&now); + localtime_r(&now, &timeinfo); + uint8_t h = timeinfo.tm_hour; + CRGB color = CRGB(0x440000); + window->drawChar(&font5x7, 4<<8, 0<<8, '0' + (h / 10), &color); + window->drawChar(&font5x7, 10<<8, 0<<8, '0' + (h % 10), &color); + + uint8_t m = timeinfo.tm_min; + window->drawChar(&font5x7, 4<<8, 9<<8, '0' + (m / 10), &color); + window->drawChar(&font5x7, 10<<8, 9<<8, '0' + (m % 10), &color); + + uint8_t s = timeinfo.tm_sec; + if(s & 1) { + window->setPixel(2, 11, &color); + window->setPixel(2, 13, &color); + } +}