Added PicelClockEffect.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
dc40653fea
commit
3edbf6b252
16
include/effect_pixelclock.h
Normal file
16
include/effect_pixelclock.h
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Effect.h"
|
||||||
|
#include "my_fastled.h"
|
||||||
|
|
||||||
|
class PixelClockEffect : public Effect {
|
||||||
|
private:
|
||||||
|
CRGB* _color_seconds;
|
||||||
|
CRGB* _color_minutes;
|
||||||
|
public:
|
||||||
|
PixelClockEffect();
|
||||||
|
void start();
|
||||||
|
void stop();
|
||||||
|
void loop();
|
||||||
|
bool can_be_shown_with_clock();
|
||||||
|
};
|
37
src/effect_pixelclock.cpp
Normal file
37
src/effect_pixelclock.cpp
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
#include "effect_pixelclock.h"
|
||||||
|
#include "ntp.h"
|
||||||
|
|
||||||
|
PixelClockEffect::PixelClockEffect() {
|
||||||
|
window = new Window(0, 0, LED_WIDTH, LED_HEIGHT-7);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PixelClockEffect::start() {
|
||||||
|
_color_seconds = new CRGB(0x00FF00);
|
||||||
|
_color_minutes = new CRGB(0xFFFF00);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PixelClockEffect::stop() {
|
||||||
|
delete _color_seconds;
|
||||||
|
delete _color_minutes;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PixelClockEffect::loop() {
|
||||||
|
uint8_t x, y; // Temporary variables for calculating positions
|
||||||
|
window->clear();
|
||||||
|
// Seconds
|
||||||
|
uint8_t seconds = ntpClient.getSeconds();
|
||||||
|
for (uint8_t s=0; s<60; s++) {
|
||||||
|
x = window->width - 1 - s/10;
|
||||||
|
y = window->height - 1 - (s % 10);
|
||||||
|
if (s<=seconds) window->setPixel(x, y, _color_seconds);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t minutes = ntpClient.getMinutes();
|
||||||
|
for (uint8_t m=0; m<60; m++) {
|
||||||
|
x = 6 - m/10;
|
||||||
|
y = window->height - 1 - (m % 10);
|
||||||
|
if (m<=minutes) window->setPixel(x, y, _color_seconds);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool PixelClockEffect::can_be_shown_with_clock() { return true; }
|
@ -17,6 +17,7 @@
|
|||||||
#include "effect_fire.h"
|
#include "effect_fire.h"
|
||||||
#include "effect_firework.h"
|
#include "effect_firework.h"
|
||||||
#include "effect_gol.h"
|
#include "effect_gol.h"
|
||||||
|
#include "effect_pixelclock.h"
|
||||||
|
|
||||||
SimpleList<EffectEntry>* effects;
|
SimpleList<EffectEntry>* effects;
|
||||||
SimpleList<Effect*>* cycle_effects;
|
SimpleList<Effect*>* cycle_effects;
|
||||||
@ -41,6 +42,7 @@ SnakeEffect effect_snake;
|
|||||||
FireEffect effect_fire;
|
FireEffect effect_fire;
|
||||||
FireworkEffect effect_firework;
|
FireworkEffect effect_firework;
|
||||||
GolEffect effect_gol;
|
GolEffect effect_gol;
|
||||||
|
PixelClockEffect effect_pixelclock;
|
||||||
|
|
||||||
Effect* current_effect;
|
Effect* current_effect;
|
||||||
|
|
||||||
@ -67,6 +69,7 @@ void setup_effects() {
|
|||||||
effects->add((EffectEntry){"firework", (Effect *)&effect_firework});
|
effects->add((EffectEntry){"firework", (Effect *)&effect_firework});
|
||||||
effects->add((EffectEntry){"gol", (Effect *)&effect_gol});
|
effects->add((EffectEntry){"gol", (Effect *)&effect_gol});
|
||||||
effects->add((EffectEntry){"cake", (Effect *)&effect_anim_cake});
|
effects->add((EffectEntry){"cake", (Effect *)&effect_anim_cake});
|
||||||
|
effects->add((EffectEntry){"pixel_clock", (Effect *)&effect_pixelclock});
|
||||||
|
|
||||||
cycle_effects->add(&effect_sinematrix3);
|
cycle_effects->add(&effect_sinematrix3);
|
||||||
cycle_effects->add(&effect_multi_dynamic);
|
cycle_effects->add(&effect_multi_dynamic);
|
||||||
|
Loading…
Reference in New Issue
Block a user