Reorganized effect selection stuff: No longer a big case clause comparing CRC32. Instead an array of structs. Much nicer. Also, other code can now see which effects there are.

This commit is contained in:
2019-10-02 06:16:07 +02:00
parent 3f6d4cb0be
commit 083564caef
6 changed files with 77 additions and 51 deletions

View File

@ -8,6 +8,7 @@ private:
Effect* effect = NULL;
uint16_t effect_id = -1;
unsigned long effectSince = 0;
uint8_t _effects_count;
public:
CycleEffect();
~CycleEffect();

View File

@ -1,17 +1,20 @@
#ifndef effects_H
#define effects_H
#pragma once
#include "Effect.h"
#include "effect_clock.h"
extern const char* cycle_effects[];
extern uint8_t cycle_effects_count;
struct EffectEntry {
const char* name;
bool use_in_cycle;
std::function<Effect*()> create;
};
extern const EffectEntry effects[];
extern const uint8_t effects_size;
extern Effect* current_effect;
extern ClockEffect effect_clock;
Effect* select_effect(uint32_t c);
Effect* select_effect(char* name);
Effect* select_effect(uint8_t id);
bool change_current_effect(String s);
void setup_effects();
#endif