2019-05-29 22:49:54 +00:00
|
|
|
#include "effects.h"
|
|
|
|
#include "my_fastled.h"
|
2019-06-18 16:14:59 +00:00
|
|
|
#include <ErriezCRC32.h>
|
2019-05-29 22:49:54 +00:00
|
|
|
#include "effect_bell.h"
|
|
|
|
#include "effect_sinematrix3.h"
|
|
|
|
#include "effect_big_clock.h"
|
|
|
|
#include "effect_clock.h"
|
|
|
|
#include "effect_static.h"
|
|
|
|
#include "effect_animation.h"
|
2019-06-05 04:27:07 +00:00
|
|
|
#include "effect_dynamic.h"
|
2019-05-29 22:49:54 +00:00
|
|
|
#include "effect_matrix.h"
|
|
|
|
#include "effect_twirl.h"
|
|
|
|
#include "effect_cycle.h"
|
2019-05-30 09:12:40 +00:00
|
|
|
#include "effect_confetti.h"
|
2019-05-31 03:45:07 +00:00
|
|
|
#include "effect_snake.h"
|
2019-06-04 03:58:23 +00:00
|
|
|
#include "effect_fire.h"
|
2019-06-05 04:27:07 +00:00
|
|
|
#include "effect_firework.h"
|
2019-06-14 03:32:17 +00:00
|
|
|
#include "effect_gol.h"
|
2019-06-15 12:18:35 +00:00
|
|
|
#include "effect_pixelclock.h"
|
2019-06-19 20:28:38 +00:00
|
|
|
#include "effect_dvd.h"
|
2019-09-25 04:24:24 +00:00
|
|
|
#include "effect_analogclock.h"
|
|
|
|
#include "effect_sines.h"
|
2019-09-25 04:41:52 +00:00
|
|
|
#include "effect_marquee.h"
|
2019-09-25 04:26:27 +00:00
|
|
|
#include "effect_blur2d.h"
|
2019-05-29 22:49:54 +00:00
|
|
|
|
2019-06-18 16:14:59 +00:00
|
|
|
Effect* current_effect;
|
2019-05-29 22:49:54 +00:00
|
|
|
|
|
|
|
ClockEffect effect_clock;
|
|
|
|
|
2019-06-19 20:26:38 +00:00
|
|
|
Effect* select_effect(uint32_t code) {
|
|
|
|
switch (code) {
|
2019-06-18 16:14:59 +00:00
|
|
|
// use e.g. https://crccalc.com/ for the conversion of name to crc.
|
2019-06-19 20:26:38 +00:00
|
|
|
case 0: case 0xD682E3C8 /* sinematrix3 */ : return new Sinematrix3Effect();
|
|
|
|
case 1: case 0x90A887DA /* big_clock */ : return new BigClockEffect();
|
|
|
|
case 2: case 0xBE7BBE92 /* clock */ : return new ClockEffect();
|
|
|
|
case 3: case 0x733BE087 /* bell */ : return new BellEffect(); //(new AnimationEffect("/bell.pia", 0x000000, 0, 0))->setFgColor(0xFFFF00);
|
|
|
|
case 4: case 0x2BBC5D43 /* off */ : return new StaticEffect(0x000000);
|
|
|
|
case 5: case 0x1D84F231 /* koopa */ : return new AnimationEffect("/koopa.pia", CRGB(0x000000), 0, 0);
|
|
|
|
case 6: case 0xAC43BCF1 /* couple_rain */ : return new AnimationEffect("/couple_rain.pia", CRGB(0x000000), -8, -16);
|
|
|
|
case 7: case 0xF1B117F7 /* single_dynamic */ : return new SingleDynamicEffect();
|
|
|
|
case 8: case 0xF52F2804 /* multi_dynamic */ : return new MultiDynamicEffect();
|
|
|
|
case 9: case 0xF83341CF /* matrix */ : return new MatrixEffect();
|
|
|
|
case 10: case 0xD2B79DD0 /* rainbow_matrix */ : return new RainbowMatrixEffect();
|
|
|
|
case 11: case 0xE8DD3433 /* random_matrix */ : return new RandomMatrixEffect();
|
|
|
|
case 12: case 0xB086D193 /* cycle */ : return new CycleEffect();
|
|
|
|
case 13: case 0x2293EF9F /* twirl */ : return new TwirlEffect();
|
|
|
|
case 14: case 0x60ECC3E6 /* heart */ : return new AnimationEffect("/heart.pia", CRGB(0x000000), 0, 0);
|
|
|
|
case 15: case 0x42090A49 /* confetti */ : return new ConfettiEffect();
|
|
|
|
case 16: case 0x516D6B9E /* snake */ : return new SnakeEffect();
|
|
|
|
case 17: case 0x58DE09CF /* fire */ : return new FireEffect();
|
|
|
|
case 18: case 0x08BA9C08 /* firework */ : return new FireworkEffect();
|
|
|
|
case 19: case 0x14B85EAC /* gol */ : return new GolEffect();
|
|
|
|
case 20: case 0xFA13015D /* cake */ : return new AnimationEffect("/cake.pia", CRGB(0x000000), 0, 0);
|
|
|
|
case 21: case 0xA2B0D68B /* pixel_clock */ : return new PixelClockEffect();
|
|
|
|
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();
|
2019-09-25 04:24:24 +00:00
|
|
|
case 25: case 0x8CA97519 /* analog_clock */ : return new AnalogClockEffect();
|
|
|
|
case 26: case 0xADB18CC5 /* sines */ : return new SinesEffect();
|
2019-09-25 04:26:27 +00:00
|
|
|
case 27: case 0x0407881E /* blur2d */ : return new Blur2DEffect();
|
2019-09-25 04:41:52 +00:00
|
|
|
case 28: case 0x935CFA7C /* marquee */ : return new MarqueeEffect();
|
2019-09-25 16:11:52 +00:00
|
|
|
case 29: case 0xE27D739E /* night_clock */ : return new NightClockEffect();
|
2019-06-18 16:14:59 +00:00
|
|
|
default : return NULL;
|
|
|
|
};
|
|
|
|
}
|
2019-05-29 22:49:54 +00:00
|
|
|
|
2019-06-19 20:28:38 +00:00
|
|
|
bool change_current_effect(String payload) {
|
|
|
|
int pos = payload.indexOf(",");
|
|
|
|
String options = "";
|
|
|
|
if (pos != -1) {
|
|
|
|
LOGln("Effects * Effect comes with options.");
|
|
|
|
options = payload.substring(pos+1);
|
|
|
|
payload.remove(pos);
|
|
|
|
LOGln("Effects * Cleaned effect name: %s", payload.c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
Effect* new_effect = select_effect( crc32String(payload.c_str()) );
|
|
|
|
if (new_effect == NULL) {
|
|
|
|
LOGln("Effects * Could not find effect with name %s", payload.c_str());
|
|
|
|
return false;
|
|
|
|
}
|
2019-09-04 04:06:47 +00:00
|
|
|
LOGln("Effects * Switching to effect %s", payload.c_str());
|
2019-06-18 16:14:59 +00:00
|
|
|
delete current_effect;
|
|
|
|
current_effect = new_effect;
|
2019-06-19 20:28:38 +00:00
|
|
|
|
|
|
|
if (options.length() > 0) {
|
|
|
|
LOGln("Effects * Parsing options: %s", options.c_str());
|
|
|
|
options += ",";
|
|
|
|
int p_colon;
|
|
|
|
while ((p_colon = options.indexOf(",")) >= 0) {
|
|
|
|
int p_equal = options.indexOf("=");
|
|
|
|
if (p_equal >= 0 && p_equal < p_colon) {
|
|
|
|
String key = options.substring(0, p_equal);
|
|
|
|
String value = options.substring(p_equal + 1, p_colon);
|
|
|
|
LOGln("Effects * Applying option: %s = %s", key.c_str(), value.c_str());
|
|
|
|
current_effect->apply_option(key, value);
|
|
|
|
}
|
|
|
|
options.remove(0, p_colon + 1);
|
|
|
|
}
|
|
|
|
}
|
2019-06-18 16:14:59 +00:00
|
|
|
return true;
|
|
|
|
}
|
2019-05-29 22:49:54 +00:00
|
|
|
|
2019-09-04 04:06:47 +00:00
|
|
|
const char* cycle_effects[] = {
|
2019-09-26 04:52:33 +00:00
|
|
|
"sinematrix3",
|
|
|
|
"single_dynamic", "multi_dynamic", "big_dynamic",
|
2019-09-04 04:06:47 +00:00
|
|
|
"matrix", "rainbow_matrix", "random_matrix",
|
2019-09-26 04:52:33 +00:00
|
|
|
"confetti", "random_confetti",
|
|
|
|
"snake",
|
2019-09-04 04:06:47 +00:00
|
|
|
"gol",
|
2019-09-25 04:42:43 +00:00
|
|
|
"twirl",
|
|
|
|
"sines",
|
|
|
|
"blur2d",
|
2019-09-26 04:52:33 +00:00
|
|
|
"firework",
|
|
|
|
"big_clock",
|
|
|
|
"dvd"};
|
|
|
|
uint8_t cycle_effects_count = 17;
|
2019-05-29 22:49:54 +00:00
|
|
|
|
2019-06-18 16:14:59 +00:00
|
|
|
void setup_effects() {
|
|
|
|
current_effect = new CycleEffect();
|
2019-05-29 22:49:54 +00:00
|
|
|
}
|