Effect#loop now gets the time since the last run of the loop in ms. This enables

the effects to show animations that stay fluid independent of the current frame rate.
This commit is contained in:
2019-10-01 06:29:32 +02:00
parent 096d13438a
commit 382631d7d7
44 changed files with 78 additions and 67 deletions

View File

@ -9,7 +9,7 @@ protected:
Window* window = Window::getFullWindow(); // Use a full screen window per default.
public:
virtual ~Effect() {};
virtual void loop() = 0;
virtual void loop(uint16_t ms) = 0;
virtual String get_name() = 0;
boolean supports_window = false;
virtual boolean can_be_shown_with_clock() { return false; };

View File

@ -4,6 +4,6 @@
class AnalogClockEffect : public Effect {
public:
void loop();
void loop(uint16_t ms);
String get_name() override { return "analog_clock"; }
};

View File

@ -17,6 +17,6 @@ public:
AnimationEffect(const char* name, uint32_t bg_color, int x, int y);
~AnimationEffect();
AnimationEffect* setFgColor(uint32_t c);
void loop();
void loop(uint16_t ms);
String get_name() override;
};

View File

@ -9,7 +9,7 @@ private:
CRGB color_off = CRGB(0x000000);
boolean invert = false;
public:
void loop();
void loop(uint16_t ms);
String get_name() override { return "bell"; }
};

View File

@ -11,6 +11,6 @@ private:
void _draw_border_pixel(uint8_t second, CRGB* color);
public:
void loop();
void loop(uint16_t ms);
String get_name() override { return "big_clock"; }
};

View File

@ -11,7 +11,7 @@ public:
~Blur2DEffect();
boolean supports_window = true;
boolean can_be_shown_with_clock();
void loop();
void loop(uint16_t ms);
String get_name() override { return "blur2d"; }
};

View File

@ -11,7 +11,7 @@ protected:
public:
~ClockEffect();
virtual void loop();
virtual void loop(uint16_t ms);
String get_name() override { return "clock"; }
void loop_with_invert(bool invert);
void loop(boolean invert, CRGB fg_color, CRGB bg_color, uint8_t y);
@ -20,5 +20,5 @@ public:
class NightClockEffect : public ClockEffect {
public:
NightClockEffect();
void loop() override;
void loop(uint16_t ms) override;
};

View File

@ -7,7 +7,7 @@ class ConfettiEffect : public Effect {
protected:
virtual CRGB _getColor();
public:
void loop();
void loop(uint16_t ms);
boolean can_be_shown_with_clock();
String get_name() override { return "confetti"; }
};

View File

@ -17,5 +17,5 @@ public:
boolean clock_as_mask();
String get_name() override;
void loop();
void loop(uint16_t ms);
};

View File

@ -12,7 +12,7 @@ private:
public:
DvdEffect();
~DvdEffect();
void loop() override;
void loop(uint16_t ms) override;
bool can_be_shown_with_clock() override;
String get_name() override { return "dvd"; }
};

View File

@ -13,14 +13,14 @@ public:
SingleDynamicEffect();
void init();
boolean can_be_shown_with_clock();
virtual void loop();
virtual void loop(uint16_t ms);
void draw();
String get_name() override { return "single_dynamic"; }
};
class MultiDynamicEffect : public SingleDynamicEffect {
public:
void loop();
void loop(uint16_t ms);
String get_name() override { return "multi_dynamic"; }
};
@ -28,7 +28,7 @@ class BigDynamicEffect : public Effect {
private:
Window* window = new Window(0, 0, LED_WIDTH, LED_HEIGHT-6);
public:
void loop();
void loop(uint16_t ms);
~BigDynamicEffect();
boolean can_be_shown_with_clock() override;
String get_name() override { return "big_dynamic"; }

View File

@ -15,6 +15,6 @@ private:
public:
FireEffect();
~FireEffect();
void loop();
void loop(uint16_t ms);
String get_name() override { return "fire"; }
};

View File

@ -56,7 +56,7 @@ public:
void skyburst(accum88 x, accum88 y, saccum78 xv, saccum78 yv, CRGB c);
boolean supports_window = true;
boolean can_be_shown_with_clock();
void loop();
void loop(uint16_t ms);
String get_name() override { return "firework"; }
};

View File

@ -17,7 +17,7 @@ private:
public:
GolEffect();
~GolEffect();
void loop();
void loop(uint16_t ms);
bool can_be_shown_with_clock();
String get_name() override { return "gol"; }
};

View File

@ -12,7 +12,7 @@ private:
public:
boolean supports_window = true;
boolean can_be_shown_with_clock();
void loop();
void loop(uint16_t ms);
void apply_option(String key, String value) override;
String get_name() override { return "marquee"; }
};

View File

@ -27,9 +27,9 @@ public:
MatrixEffectColumn(Window* win, uint8_t direction=0, bool random_direction=false);
virtual ~MatrixEffectColumn() {};
void advance();
void advance(uint16_t ms);
void draw();
void loop();
void loop(uint16_t ms);
};
class RainbowMatrixEffectColumn : public MatrixEffectColumn {
@ -55,7 +55,7 @@ public:
boolean can_be_shown_with_clock();
MatrixEffect();
virtual ~MatrixEffect();
void loop();
void loop(uint16_t ms);
String get_name() override { return "matrix"; }
};

View File

@ -10,7 +10,7 @@ private:
public:
PixelClockEffect();
~PixelClockEffect();
void loop();
void loop(uint16_t ms);
bool can_be_shown_with_clock();
String get_name() override { return "pixel_clock"; }
};

View File

@ -30,7 +30,7 @@ public:
boolean supports_window = true;
boolean can_be_shown_with_clock();
boolean clock_as_mask();
void loop();
void loop(uint16_t ms);
String get_name() override { return "sinematrix3"; }
};

View File

@ -15,7 +15,7 @@ private:
CRGB _color;
public:
SinesEffectSinus(Window* w);
void loop();
void loop(uint16_t ms);
};
class SinesEffect : public Effect {
@ -27,7 +27,7 @@ public:
~SinesEffect();
boolean supports_window = true;
boolean can_be_shown_with_clock();
void loop();
void loop(uint16_t ms);
String get_name() override { return "sines"; }
};

View File

@ -17,7 +17,7 @@ private:
public:
SnakeEffect();
~SnakeEffect();
void loop();
void loop(uint16_t ms);
boolean valid_position(Coords c);
Coords update_position(Coords c, uint8_t direction);
boolean can_be_shown_with_clock();

View File

@ -9,7 +9,7 @@ private:
public:
StaticEffect(CRGB col);
boolean supports_window = true;
void loop();
void loop(uint16_t ms);
String get_name() override { return "static"; }
};

View File

@ -10,7 +10,7 @@ private:
double _real_center_x = LED_WIDTH / 2;
double _real_center_y = LED_HEIGHT / 2;
public:
void loop();
void loop(uint16_t ms);
boolean can_be_shown_with_clock() override;
boolean clock_as_mask() override;
String get_name() override { return "twirl"; }