Effect parameters are now mostly defined from within config.h

This commit is contained in:
Fabian Schlenz 2019-05-27 18:13:01 +02:00
parent 49494a3cc3
commit a1efacdc0a
2 changed files with 17 additions and 6 deletions

View File

@ -27,4 +27,14 @@ uint8_t config_brightness = 20; // Can be overwritten via MQTT_TOPIC_BRIGHTNESS
#define FPS 50 #define FPS 50
#define SHOW_TEXT_DELAY 100 #define SHOW_TEXT_DELAY 100
// Effect config
uint16_t config_effect_cycle_time = 300; // Time in seconds between cycling effects. uint16_t config_effect_cycle_time = 300; // Time in seconds between cycling effects.
uint16_t config_effect_matrix_length_min = 4;
uint16_t config_effect_matrix_length_max = 20;
uint16_t config_effect_matrix_speed_min = 50;
uint16_t config_effect_matrix_speed_max = 135;
uint16_t config_effect_single_dynamic_loop_time = 200;
uint16_t config_effect_multi_dynamic_loop_time = 1400;

View File

@ -272,7 +272,7 @@ class SingleDynamic : public Effect {
protected: protected:
static const int factor = 2; static const int factor = 2;
static const int tile_count = LED_WIDTH/factor * LED_HEIGHT/factor; static const int tile_count = LED_WIDTH/factor * LED_HEIGHT/factor;
virtual int getLoopTime() { return 200; } virtual int getLoopTime() { return config_effect_single_dynamic_loop_time; }
CRGB tiles[tile_count]; CRGB tiles[tile_count];
CRGB old_tiles[tile_count]; CRGB old_tiles[tile_count];
uint8_t blend = 0; uint8_t blend = 0;
@ -281,7 +281,7 @@ class SingleDynamic : public Effect {
for (int i=0; i<tile_count; i++) tiles[i] = CHSV(random8(), 180, 255); for (int i=0; i<tile_count; i++) tiles[i] = CHSV(random8(), 180, 255);
} }
virtual void update() { virtual void update() {
tiles[random8() % tile_count] = CHSV(random8(), 180, 255); tiles[random8(tile_count)] = CHSV(random8(), 180, 255);
} }
boolean can_be_shown_with_clock() { return true; } boolean can_be_shown_with_clock() { return true; }
virtual void loop() { virtual void loop() {
@ -301,7 +301,7 @@ class SingleDynamic : public Effect {
class MultiDynamic : public SingleDynamic { class MultiDynamic : public SingleDynamic {
protected: protected:
virtual int getLoopTime() { return 1400; } int getLoopTime() { return config_effect_multi_dynamic_loop_time; }
public: public:
void update() { void update() {
for (int i=0; i<tile_count; i++) tiles[i] = CHSV(random8(), 180, 255); for (int i=0; i<tile_count; i++) tiles[i] = CHSV(random8(), 180, 255);
@ -321,14 +321,15 @@ class MatrixColumn {
MatrixColumn(Window* win, int xPos) { MatrixColumn(Window* win, int xPos) {
window = win; window = win;
x = xPos; x = xPos;
running = false; start();
y = random8(0, win->h);
} }
void start() { void start() {
y=-1; y=-1;
length = random8()%16+4; length = random8(config_effect_matrix_length_min, config_effect_matrix_length_max);
running = true; running = true;
speed = random8()/3 + 50; speed = random8(config_effect_matrix_speed_min, config_effect_matrix_speed_max);
} }
void advance() { void advance() {