Added effect diamond.

This commit is contained in:
Fabian Schlenz 2020-04-30 06:51:02 +02:00
parent caa86551a0
commit 075823220a
3 changed files with 28 additions and 1 deletions

11
include/effect_diamond.h Normal file
View File

@ -0,0 +1,11 @@
#pragma once
#include "Effect.h"
class DiamondEffect : public Effect {
private:
Window* window = &Window::window_with_clock;
public:
void loop(uint16_t ms) override;
bool can_be_shown_with_clock() override;
String get_name() override { return "diamond"; }
};

14
src/effect_diamond.cpp Normal file
View File

@ -0,0 +1,14 @@
#include "effect_diamond.h"
#include "my_fastled.h"
void DiamondEffect::loop(uint16_t ms) {
for (int x=0; x<window->width; x++) {
for (int y=0; y<window->height; y++) {
uint8_t distance = abs(window->height/2 - y) + abs(window->width/2 - x);
CRGB col = CHSV(distance*8 - (millis()>>5)%255, 255, 255);
window->setPixel(x, y, &col);
}
}
}
bool DiamondEffect::can_be_shown_with_clock() { return true; }

View File

@ -24,6 +24,7 @@
#include "effect_blur2d.h"
#include "effect_tv_static.h"
#include "effect_lightspeed.h"
#include "effect_diamond.h"
Effect* current_effect;
@ -64,8 +65,9 @@ EffectEntry effects[] = {
/* 29 */ {"koopa", 0, [](){ return new AnimationEffect("/koopa.pia"); }},
/* 30 */ {"cake", 0, [](){ return new AnimationEffect("/cake.pia"); }},
/* 31 */ {"kid", 0, [](){ return new AnimationEffect("/kid.pia"); }},
/* 32 */ {"diamond", true, [](){ return new DiamondEffect(); }},
};
const uint8_t effects_size = 32;
const uint8_t effects_size = 33;
Effect* select_effect(const char* name) {