From 96e144f96b4fee007966fca26f11f064d13705e7 Mon Sep 17 00:00:00 2001 From: Fabian Schlenz Date: Wed, 25 Sep 2019 06:24:24 +0200 Subject: [PATCH] Added effect analog_clock (heavily, not-really-usable work-in-progress!). --- include/effect_analogclock.h | 8 ++++++++ src/effect_analogclock.cpp | 23 +++++++++++++++++++++++ src/effects.cpp | 4 ++++ 3 files changed, 35 insertions(+) create mode 100644 include/effect_analogclock.h create mode 100644 src/effect_analogclock.cpp diff --git a/include/effect_analogclock.h b/include/effect_analogclock.h new file mode 100644 index 0000000..747ac59 --- /dev/null +++ b/include/effect_analogclock.h @@ -0,0 +1,8 @@ +#pragma once + +#include "Effect.h" + +class AnalogClockEffect : public Effect { +public: + void loop(); +}; diff --git a/src/effect_analogclock.cpp b/src/effect_analogclock.cpp new file mode 100644 index 0000000..4e91e2a --- /dev/null +++ b/src/effect_analogclock.cpp @@ -0,0 +1,23 @@ +#include "effect_analogclock.h" +#include "my_fastled.h" +#include "ntp.h" + +void AnalogClockEffect::loop() { + window->clear(); + CRGB white(0xFFFFFF); + CRGB red(0xFF0000); + window->circle(8, 8, 7, &white); + + uint8_t seconds = ntpClient.getSeconds(); + uint8_t angle = 6 * seconds; + window->lineWithAngle(8, 8, angle, 0, 10, &red); + /*for (uint8_t i=0; i<=12; i++) { + window->lineWithAngle(8, 8, 255/12*i, 5, 2, &white); + } + + uint8_t minutes = ntpClient.getMinutes(); + uint8_t hours = ntpClient.getHours(); + + window->lineWithAngle(8, 8, 255/60*minutes, 6, &white); + window->lineWithAngle(8, 8, 255/12*(hours % 12), 4, &white);*/ +} diff --git a/src/effects.cpp b/src/effects.cpp index 2600209..b6ed067 100644 --- a/src/effects.cpp +++ b/src/effects.cpp @@ -18,6 +18,8 @@ #include "effect_gol.h" #include "effect_pixelclock.h" #include "effect_dvd.h" +#include "effect_analogclock.h" +#include "effect_sines.h" Effect* current_effect; @@ -51,6 +53,8 @@ Effect* select_effect(uint32_t code) { case 22: case 0x2C0E6962 /* big_dynamic */ : return new BigDynamicEffect(); case 23: case 0xDA6F31A5 /* random_confetti */ : return new RandomConfettiEffect(); case 24: case 0x8325C1DF /* dvd */ : return new DvdEffect(); + case 25: case 0x8CA97519 /* analog_clock */ : return new AnalogClockEffect(); + case 26: case 0xADB18CC5 /* sines */ : return new SinesEffect(); default : return NULL; }; }