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:
parent
096d13438a
commit
382631d7d7
@ -9,7 +9,7 @@ protected:
|
|||||||
Window* window = Window::getFullWindow(); // Use a full screen window per default.
|
Window* window = Window::getFullWindow(); // Use a full screen window per default.
|
||||||
public:
|
public:
|
||||||
virtual ~Effect() {};
|
virtual ~Effect() {};
|
||||||
virtual void loop() = 0;
|
virtual void loop(uint16_t ms) = 0;
|
||||||
virtual String get_name() = 0;
|
virtual String get_name() = 0;
|
||||||
boolean supports_window = false;
|
boolean supports_window = false;
|
||||||
virtual boolean can_be_shown_with_clock() { return false; };
|
virtual boolean can_be_shown_with_clock() { return false; };
|
||||||
|
@ -4,6 +4,6 @@
|
|||||||
|
|
||||||
class AnalogClockEffect : public Effect {
|
class AnalogClockEffect : public Effect {
|
||||||
public:
|
public:
|
||||||
void loop();
|
void loop(uint16_t ms);
|
||||||
String get_name() override { return "analog_clock"; }
|
String get_name() override { return "analog_clock"; }
|
||||||
};
|
};
|
||||||
|
@ -17,6 +17,6 @@ public:
|
|||||||
AnimationEffect(const char* name, uint32_t bg_color, int x, int y);
|
AnimationEffect(const char* name, uint32_t bg_color, int x, int y);
|
||||||
~AnimationEffect();
|
~AnimationEffect();
|
||||||
AnimationEffect* setFgColor(uint32_t c);
|
AnimationEffect* setFgColor(uint32_t c);
|
||||||
void loop();
|
void loop(uint16_t ms);
|
||||||
String get_name() override;
|
String get_name() override;
|
||||||
};
|
};
|
||||||
|
@ -9,7 +9,7 @@ private:
|
|||||||
CRGB color_off = CRGB(0x000000);
|
CRGB color_off = CRGB(0x000000);
|
||||||
boolean invert = false;
|
boolean invert = false;
|
||||||
public:
|
public:
|
||||||
void loop();
|
void loop(uint16_t ms);
|
||||||
String get_name() override { return "bell"; }
|
String get_name() override { return "bell"; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -11,6 +11,6 @@ private:
|
|||||||
void _draw_border_pixel(uint8_t second, CRGB* color);
|
void _draw_border_pixel(uint8_t second, CRGB* color);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void loop();
|
void loop(uint16_t ms);
|
||||||
String get_name() override { return "big_clock"; }
|
String get_name() override { return "big_clock"; }
|
||||||
};
|
};
|
||||||
|
@ -11,7 +11,7 @@ public:
|
|||||||
~Blur2DEffect();
|
~Blur2DEffect();
|
||||||
boolean supports_window = true;
|
boolean supports_window = true;
|
||||||
boolean can_be_shown_with_clock();
|
boolean can_be_shown_with_clock();
|
||||||
void loop();
|
void loop(uint16_t ms);
|
||||||
String get_name() override { return "blur2d"; }
|
String get_name() override { return "blur2d"; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ protected:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
~ClockEffect();
|
~ClockEffect();
|
||||||
virtual void loop();
|
virtual void loop(uint16_t ms);
|
||||||
String get_name() override { return "clock"; }
|
String get_name() override { return "clock"; }
|
||||||
void loop_with_invert(bool invert);
|
void loop_with_invert(bool invert);
|
||||||
void loop(boolean invert, CRGB fg_color, CRGB bg_color, uint8_t y);
|
void loop(boolean invert, CRGB fg_color, CRGB bg_color, uint8_t y);
|
||||||
@ -20,5 +20,5 @@ public:
|
|||||||
class NightClockEffect : public ClockEffect {
|
class NightClockEffect : public ClockEffect {
|
||||||
public:
|
public:
|
||||||
NightClockEffect();
|
NightClockEffect();
|
||||||
void loop() override;
|
void loop(uint16_t ms) override;
|
||||||
};
|
};
|
||||||
|
@ -7,7 +7,7 @@ class ConfettiEffect : public Effect {
|
|||||||
protected:
|
protected:
|
||||||
virtual CRGB _getColor();
|
virtual CRGB _getColor();
|
||||||
public:
|
public:
|
||||||
void loop();
|
void loop(uint16_t ms);
|
||||||
boolean can_be_shown_with_clock();
|
boolean can_be_shown_with_clock();
|
||||||
String get_name() override { return "confetti"; }
|
String get_name() override { return "confetti"; }
|
||||||
};
|
};
|
||||||
|
@ -17,5 +17,5 @@ public:
|
|||||||
boolean clock_as_mask();
|
boolean clock_as_mask();
|
||||||
String get_name() override;
|
String get_name() override;
|
||||||
|
|
||||||
void loop();
|
void loop(uint16_t ms);
|
||||||
};
|
};
|
||||||
|
@ -12,7 +12,7 @@ private:
|
|||||||
public:
|
public:
|
||||||
DvdEffect();
|
DvdEffect();
|
||||||
~DvdEffect();
|
~DvdEffect();
|
||||||
void loop() override;
|
void loop(uint16_t ms) override;
|
||||||
bool can_be_shown_with_clock() override;
|
bool can_be_shown_with_clock() override;
|
||||||
String get_name() override { return "dvd"; }
|
String get_name() override { return "dvd"; }
|
||||||
};
|
};
|
||||||
|
@ -13,14 +13,14 @@ public:
|
|||||||
SingleDynamicEffect();
|
SingleDynamicEffect();
|
||||||
void init();
|
void init();
|
||||||
boolean can_be_shown_with_clock();
|
boolean can_be_shown_with_clock();
|
||||||
virtual void loop();
|
virtual void loop(uint16_t ms);
|
||||||
void draw();
|
void draw();
|
||||||
String get_name() override { return "single_dynamic"; }
|
String get_name() override { return "single_dynamic"; }
|
||||||
};
|
};
|
||||||
|
|
||||||
class MultiDynamicEffect : public SingleDynamicEffect {
|
class MultiDynamicEffect : public SingleDynamicEffect {
|
||||||
public:
|
public:
|
||||||
void loop();
|
void loop(uint16_t ms);
|
||||||
String get_name() override { return "multi_dynamic"; }
|
String get_name() override { return "multi_dynamic"; }
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -28,7 +28,7 @@ class BigDynamicEffect : public Effect {
|
|||||||
private:
|
private:
|
||||||
Window* window = new Window(0, 0, LED_WIDTH, LED_HEIGHT-6);
|
Window* window = new Window(0, 0, LED_WIDTH, LED_HEIGHT-6);
|
||||||
public:
|
public:
|
||||||
void loop();
|
void loop(uint16_t ms);
|
||||||
~BigDynamicEffect();
|
~BigDynamicEffect();
|
||||||
boolean can_be_shown_with_clock() override;
|
boolean can_be_shown_with_clock() override;
|
||||||
String get_name() override { return "big_dynamic"; }
|
String get_name() override { return "big_dynamic"; }
|
||||||
|
@ -15,6 +15,6 @@ private:
|
|||||||
public:
|
public:
|
||||||
FireEffect();
|
FireEffect();
|
||||||
~FireEffect();
|
~FireEffect();
|
||||||
void loop();
|
void loop(uint16_t ms);
|
||||||
String get_name() override { return "fire"; }
|
String get_name() override { return "fire"; }
|
||||||
};
|
};
|
||||||
|
@ -56,7 +56,7 @@ public:
|
|||||||
void skyburst(accum88 x, accum88 y, saccum78 xv, saccum78 yv, CRGB c);
|
void skyburst(accum88 x, accum88 y, saccum78 xv, saccum78 yv, CRGB c);
|
||||||
boolean supports_window = true;
|
boolean supports_window = true;
|
||||||
boolean can_be_shown_with_clock();
|
boolean can_be_shown_with_clock();
|
||||||
void loop();
|
void loop(uint16_t ms);
|
||||||
String get_name() override { return "firework"; }
|
String get_name() override { return "firework"; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ private:
|
|||||||
public:
|
public:
|
||||||
GolEffect();
|
GolEffect();
|
||||||
~GolEffect();
|
~GolEffect();
|
||||||
void loop();
|
void loop(uint16_t ms);
|
||||||
bool can_be_shown_with_clock();
|
bool can_be_shown_with_clock();
|
||||||
String get_name() override { return "gol"; }
|
String get_name() override { return "gol"; }
|
||||||
};
|
};
|
||||||
|
@ -12,7 +12,7 @@ private:
|
|||||||
public:
|
public:
|
||||||
boolean supports_window = true;
|
boolean supports_window = true;
|
||||||
boolean can_be_shown_with_clock();
|
boolean can_be_shown_with_clock();
|
||||||
void loop();
|
void loop(uint16_t ms);
|
||||||
void apply_option(String key, String value) override;
|
void apply_option(String key, String value) override;
|
||||||
String get_name() override { return "marquee"; }
|
String get_name() override { return "marquee"; }
|
||||||
};
|
};
|
||||||
|
@ -27,9 +27,9 @@ public:
|
|||||||
|
|
||||||
MatrixEffectColumn(Window* win, uint8_t direction=0, bool random_direction=false);
|
MatrixEffectColumn(Window* win, uint8_t direction=0, bool random_direction=false);
|
||||||
virtual ~MatrixEffectColumn() {};
|
virtual ~MatrixEffectColumn() {};
|
||||||
void advance();
|
void advance(uint16_t ms);
|
||||||
void draw();
|
void draw();
|
||||||
void loop();
|
void loop(uint16_t ms);
|
||||||
};
|
};
|
||||||
|
|
||||||
class RainbowMatrixEffectColumn : public MatrixEffectColumn {
|
class RainbowMatrixEffectColumn : public MatrixEffectColumn {
|
||||||
@ -55,7 +55,7 @@ public:
|
|||||||
boolean can_be_shown_with_clock();
|
boolean can_be_shown_with_clock();
|
||||||
MatrixEffect();
|
MatrixEffect();
|
||||||
virtual ~MatrixEffect();
|
virtual ~MatrixEffect();
|
||||||
void loop();
|
void loop(uint16_t ms);
|
||||||
String get_name() override { return "matrix"; }
|
String get_name() override { return "matrix"; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ private:
|
|||||||
public:
|
public:
|
||||||
PixelClockEffect();
|
PixelClockEffect();
|
||||||
~PixelClockEffect();
|
~PixelClockEffect();
|
||||||
void loop();
|
void loop(uint16_t ms);
|
||||||
bool can_be_shown_with_clock();
|
bool can_be_shown_with_clock();
|
||||||
String get_name() override { return "pixel_clock"; }
|
String get_name() override { return "pixel_clock"; }
|
||||||
};
|
};
|
||||||
|
@ -30,7 +30,7 @@ public:
|
|||||||
boolean supports_window = true;
|
boolean supports_window = true;
|
||||||
boolean can_be_shown_with_clock();
|
boolean can_be_shown_with_clock();
|
||||||
boolean clock_as_mask();
|
boolean clock_as_mask();
|
||||||
void loop();
|
void loop(uint16_t ms);
|
||||||
String get_name() override { return "sinematrix3"; }
|
String get_name() override { return "sinematrix3"; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ private:
|
|||||||
CRGB _color;
|
CRGB _color;
|
||||||
public:
|
public:
|
||||||
SinesEffectSinus(Window* w);
|
SinesEffectSinus(Window* w);
|
||||||
void loop();
|
void loop(uint16_t ms);
|
||||||
};
|
};
|
||||||
|
|
||||||
class SinesEffect : public Effect {
|
class SinesEffect : public Effect {
|
||||||
@ -27,7 +27,7 @@ public:
|
|||||||
~SinesEffect();
|
~SinesEffect();
|
||||||
boolean supports_window = true;
|
boolean supports_window = true;
|
||||||
boolean can_be_shown_with_clock();
|
boolean can_be_shown_with_clock();
|
||||||
void loop();
|
void loop(uint16_t ms);
|
||||||
String get_name() override { return "sines"; }
|
String get_name() override { return "sines"; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ private:
|
|||||||
public:
|
public:
|
||||||
SnakeEffect();
|
SnakeEffect();
|
||||||
~SnakeEffect();
|
~SnakeEffect();
|
||||||
void loop();
|
void loop(uint16_t ms);
|
||||||
boolean valid_position(Coords c);
|
boolean valid_position(Coords c);
|
||||||
Coords update_position(Coords c, uint8_t direction);
|
Coords update_position(Coords c, uint8_t direction);
|
||||||
boolean can_be_shown_with_clock();
|
boolean can_be_shown_with_clock();
|
||||||
|
@ -9,7 +9,7 @@ private:
|
|||||||
public:
|
public:
|
||||||
StaticEffect(CRGB col);
|
StaticEffect(CRGB col);
|
||||||
boolean supports_window = true;
|
boolean supports_window = true;
|
||||||
void loop();
|
void loop(uint16_t ms);
|
||||||
String get_name() override { return "static"; }
|
String get_name() override { return "static"; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ private:
|
|||||||
double _real_center_x = LED_WIDTH / 2;
|
double _real_center_x = LED_WIDTH / 2;
|
||||||
double _real_center_y = LED_HEIGHT / 2;
|
double _real_center_y = LED_HEIGHT / 2;
|
||||||
public:
|
public:
|
||||||
void loop();
|
void loop(uint16_t ms);
|
||||||
boolean can_be_shown_with_clock() override;
|
boolean can_be_shown_with_clock() override;
|
||||||
boolean clock_as_mask() override;
|
boolean clock_as_mask() override;
|
||||||
String get_name() override { return "twirl"; }
|
String get_name() override { return "twirl"; }
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#include "my_fastled.h"
|
#include "my_fastled.h"
|
||||||
#include "ntp.h"
|
#include "ntp.h"
|
||||||
|
|
||||||
void AnalogClockEffect::loop() {
|
void AnalogClockEffect::loop(uint16_t ms) {
|
||||||
window->clear();
|
window->clear();
|
||||||
CRGB white(0xFFFFFF);
|
CRGB white(0xFFFFFF);
|
||||||
CRGB red(0xFF0000);
|
CRGB red(0xFF0000);
|
||||||
|
@ -20,7 +20,7 @@ AnimationEffect::~AnimationEffect() {
|
|||||||
delete this->animation;
|
delete this->animation;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnimationEffect::loop() {
|
void AnimationEffect::loop(uint16_t ms) {
|
||||||
this->animation->drawFrame();
|
this->animation->drawFrame();
|
||||||
this->animation->advance();
|
this->animation->advance();
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
#include "effect_bell.h"
|
#include "effect_bell.h"
|
||||||
#include "sprites.h"
|
#include "sprites.h"
|
||||||
|
|
||||||
void BellEffect::loop() {
|
void BellEffect::loop(uint16_t ms) {
|
||||||
Serial.println("This is Bell.loop()");
|
Serial.println("This is Bell.loop()");
|
||||||
for (int y = 0; y < 16; y++) {
|
for (int y = 0; y < 16; y++) {
|
||||||
for (int x = 0; x < 2; x++) {
|
for (int x = 0; x < 2; x++) {
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
#include "fonts.h"
|
#include "fonts.h"
|
||||||
#include "ntp.h"
|
#include "ntp.h"
|
||||||
|
|
||||||
void BigClockEffect::loop() {
|
void BigClockEffect::loop(uint16_t ms) {
|
||||||
window->clear();
|
window->clear();
|
||||||
uint8_t h = ntpClient.getHours();
|
uint8_t h = ntpClient.getHours();
|
||||||
window->drawChar(&font_numbers3x5_blocky, 6<<8, 2<<8, '0' + (h / 10), &_color_font);
|
window->drawChar(&font_numbers3x5_blocky, 6<<8, 2<<8, '0' + (h / 10), &_color_font);
|
||||||
|
@ -4,7 +4,7 @@ boolean Blur2DEffect::can_be_shown_with_clock() {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Blur2DEffect::loop() {
|
void Blur2DEffect::loop(uint16_t ms) {
|
||||||
uint8_t blur_amount = dim8_raw(beatsin8(3, 128, 224));
|
uint8_t blur_amount = dim8_raw(beatsin8(3, 128, 224));
|
||||||
window->blur(blur_amount);
|
window->blur(blur_amount);
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ NightClockEffect::NightClockEffect() {
|
|||||||
window = Window::getFullWindow();
|
window = Window::getFullWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
void NightClockEffect::loop() {
|
void NightClockEffect::loop(uint16_t ms) {
|
||||||
uint16_t minutes = minutes16();
|
uint16_t minutes = minutes16();
|
||||||
//uint8_t y = minutes % ((window->height - 5) * 2 - 2);
|
//uint8_t y = minutes % ((window->height - 5) * 2 - 2);
|
||||||
//if (y > window->height - 5) y = 2*window->height - 2*y;
|
//if (y > window->height - 5) y = 2*window->height - 2*y;
|
||||||
@ -16,7 +16,7 @@ void NightClockEffect::loop() {
|
|||||||
ClockEffect::loop(false, CRGB(0x200000), CRGB(0x000000), y);
|
ClockEffect::loop(false, CRGB(0x200000), CRGB(0x000000), y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClockEffect::loop() {
|
void ClockEffect::loop(uint16_t ms) {
|
||||||
loop_with_invert(false);
|
loop_with_invert(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
#include "functions.h"
|
#include "functions.h"
|
||||||
#include "prototypes.h"
|
#include "prototypes.h"
|
||||||
|
|
||||||
void ConfettiEffect::loop() {
|
void ConfettiEffect::loop(uint16_t ms) {
|
||||||
window->fadeToBlackBy(3);
|
window->fadeToBlackBy(3);
|
||||||
for (int i=0; i<EFFECT_CONFETTI_PIXELS_PER_LOOP; i++) {
|
for (int i=0; i<EFFECT_CONFETTI_PIXELS_PER_LOOP; i++) {
|
||||||
CRGB color = _getColor();
|
CRGB color = _getColor();
|
||||||
|
@ -41,9 +41,9 @@ boolean CycleEffect::clock_as_mask() {
|
|||||||
return effect->clock_as_mask();
|
return effect->clock_as_mask();
|
||||||
};
|
};
|
||||||
|
|
||||||
void CycleEffect::loop() {
|
void CycleEffect::loop(uint16_t ms) {
|
||||||
if (!effect) changeEffect(); // If this is the first run, we have to select an effect first!
|
if (!effect) changeEffect(); // If this is the first run, we have to select an effect first!
|
||||||
effect->loop();
|
effect->loop(ms);
|
||||||
// Don't use EVERY_N_SECONDS(config_effect_cycle_time) here because that function isn't relly made
|
// Don't use EVERY_N_SECONDS(config_effect_cycle_time) here because that function isn't relly made
|
||||||
// to be used with changing values.
|
// to be used with changing values.
|
||||||
EVERY_N_SECONDS(1) {
|
EVERY_N_SECONDS(1) {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include "effect_dvd.h"
|
#include "effect_dvd.h"
|
||||||
#include "my_fastled.h"
|
#include "my_fastled.h"
|
||||||
|
|
||||||
void DvdEffect::loop() {
|
void DvdEffect::loop(uint16_t ms) {
|
||||||
bool dir_changed = false;
|
bool dir_changed = false;
|
||||||
EVERY_N_MILLISECONDS( 250 ) {
|
EVERY_N_MILLISECONDS( 250 ) {
|
||||||
_x += _x_dir;
|
_x += _x_dir;
|
||||||
|
@ -10,7 +10,7 @@ void SingleDynamicEffect::init() {
|
|||||||
for (int i=0; i<tile_count; i++) tiles[i] = CHSV(baseHue + random8(64), 180, 255);
|
for (int i=0; i<tile_count; i++) tiles[i] = CHSV(baseHue + random8(64), 180, 255);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SingleDynamicEffect::loop() {
|
void SingleDynamicEffect::loop(uint16_t ms) {
|
||||||
EVERY_N_MILLISECONDS( EFFECT_SINGLE_DYNAMIC_LOOP_TIME ) {
|
EVERY_N_MILLISECONDS( EFFECT_SINGLE_DYNAMIC_LOOP_TIME ) {
|
||||||
tiles[random8(tile_count)] = CHSV(baseHue + random8(64), 180, 255);
|
tiles[random8(tile_count)] = CHSV(baseHue + random8(64), 180, 255);
|
||||||
}
|
}
|
||||||
@ -28,7 +28,7 @@ boolean SingleDynamicEffect::can_be_shown_with_clock() {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MultiDynamicEffect::loop() {
|
void MultiDynamicEffect::loop(uint16_t ms) {
|
||||||
EVERY_N_MILLISECONDS( EFFECT_MULTI_DYNAMIC_LOOP_TIME ) {
|
EVERY_N_MILLISECONDS( EFFECT_MULTI_DYNAMIC_LOOP_TIME ) {
|
||||||
for (int i=0; i<tile_count; i++) tiles[i] = CHSV(baseHue + random8(64), 180, 255);
|
for (int i=0; i<tile_count; i++) tiles[i] = CHSV(baseHue + random8(64), 180, 255);
|
||||||
}
|
}
|
||||||
@ -39,7 +39,7 @@ BigDynamicEffect::~BigDynamicEffect() {
|
|||||||
delete window;
|
delete window;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BigDynamicEffect::loop() {
|
void BigDynamicEffect::loop(uint16_t ms) {
|
||||||
EVERY_N_MILLISECONDS( EFFECT_BIG_DYNAMIC_LOOP_TIME ) {
|
EVERY_N_MILLISECONDS( EFFECT_BIG_DYNAMIC_LOOP_TIME ) {
|
||||||
uint8_t x = random8(0, window->width - EFFECT_BIG_DYNAMIC_SIZE + 1);
|
uint8_t x = random8(0, window->width - EFFECT_BIG_DYNAMIC_SIZE + 1);
|
||||||
uint8_t y = random8(0, window->height - EFFECT_BIG_DYNAMIC_SIZE + 1);
|
uint8_t y = random8(0, window->height - EFFECT_BIG_DYNAMIC_SIZE + 1);
|
||||||
|
@ -14,7 +14,7 @@ FireEffect::~FireEffect() {
|
|||||||
delete [] this->data;
|
delete [] this->data;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FireEffect::loop() {
|
void FireEffect::loop(uint16_t ms) {
|
||||||
cooldown();
|
cooldown();
|
||||||
spark();
|
spark();
|
||||||
propagate();
|
propagate();
|
||||||
|
@ -139,7 +139,7 @@ boolean FireworkEffect::can_be_shown_with_clock() {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FireworkEffect::loop() {
|
void FireworkEffect::loop(uint16_t ms) {
|
||||||
window->clear();
|
window->clear();
|
||||||
_dot->move();
|
_dot->move();
|
||||||
_dot->draw();
|
_dot->draw();
|
||||||
|
@ -29,7 +29,7 @@ GolEffect::~GolEffect() {
|
|||||||
delete window;
|
delete window;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GolEffect::loop() {
|
void GolEffect::loop(uint16_t ms) {
|
||||||
if (EFFECT_GOL_BLEND_SPEED + _blend > 255) {
|
if (EFFECT_GOL_BLEND_SPEED + _blend > 255) {
|
||||||
_blend = 0;
|
_blend = 0;
|
||||||
_advance();
|
_advance();
|
||||||
|
@ -5,8 +5,7 @@ boolean MarqueeEffect::can_be_shown_with_clock() {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MarqueeEffect::loop() {
|
void MarqueeEffect::loop(uint16_t ms) {
|
||||||
static int loop_counter = 0;
|
|
||||||
window->clear();
|
window->clear();
|
||||||
CRGB color = CHSV(0, 255, 255);
|
CRGB color = CHSV(0, 255, 255);
|
||||||
uint16_t width = _text.length() * 6;
|
uint16_t width = _text.length() * 6;
|
||||||
|
@ -43,22 +43,22 @@ void MatrixEffectColumn::restart(bool completely_random) {
|
|||||||
speed = random8(EFFECT_MATRIX_SPEED_MIN, EFFECT_MATRIX_SPEED_MAX);
|
speed = random8(EFFECT_MATRIX_SPEED_MIN, EFFECT_MATRIX_SPEED_MAX);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MatrixEffectColumn::advance() {
|
void MatrixEffectColumn::advance(uint16_t ms) {
|
||||||
switch(_direction) {
|
switch(_direction) {
|
||||||
case DIR_NORTH:
|
case DIR_NORTH:
|
||||||
y-=speed;
|
y-=speed * ms;
|
||||||
if ((y>>8) > window->height && (y>>8) + length > window->height) running=false;
|
if ((y>>8) > window->height && (y>>8) + length > window->height) running=false;
|
||||||
break;
|
break;
|
||||||
case DIR_EAST:
|
case DIR_EAST:
|
||||||
x+=speed;
|
x+=speed * ms;
|
||||||
if ((x>>8) - length > window->width) running=false;
|
if ((x>>8) - length > window->width) running=false;
|
||||||
break;
|
break;
|
||||||
case DIR_SOUTH:
|
case DIR_SOUTH:
|
||||||
y+=speed;
|
y+=speed * ms;
|
||||||
if ((y>>8) - length > window->height) running=false;
|
if ((y>>8) - length > window->height) running=false;
|
||||||
break;
|
break;
|
||||||
case DIR_WEST:
|
case DIR_WEST:
|
||||||
x-=speed;
|
x-=speed * ms;
|
||||||
if ((x>>8) > window->width && (y>>8) + length > window->width) running=false;
|
if ((x>>8) > window->width && (y>>8) + length > window->width) running=false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -79,14 +79,14 @@ void MatrixEffectColumn::draw() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MatrixEffectColumn::loop() {
|
void MatrixEffectColumn::loop(uint16_t ms) {
|
||||||
if (!running) {
|
if (!running) {
|
||||||
if (random8() < 20) {
|
if (random8() < 20) {
|
||||||
// Start the column again.
|
// Start the column again.
|
||||||
restart(false);
|
restart(false);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
advance();
|
advance(ms);
|
||||||
draw();
|
draw();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -160,7 +160,7 @@ MatrixEffect::~MatrixEffect() {
|
|||||||
delete[] _columns;
|
delete[] _columns;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MatrixEffect::loop() {
|
void MatrixEffect::loop(uint16_t ms) {
|
||||||
window->clear();
|
window->clear();
|
||||||
for (int i=0; i<window->width; i++) _columns[i]->loop();
|
for (int i=0; i<window->width; i++) _columns[i]->loop(ms);
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ PixelClockEffect::~PixelClockEffect() {
|
|||||||
delete window;
|
delete window;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PixelClockEffect::loop() {
|
void PixelClockEffect::loop(uint16_t ms) {
|
||||||
uint8_t x, y; // Temporary variables for calculating positions
|
uint8_t x, y; // Temporary variables for calculating positions
|
||||||
window->clear();
|
window->clear();
|
||||||
// Seconds
|
// Seconds
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
boolean Sinematrix3Effect::can_be_shown_with_clock() { return true; };
|
boolean Sinematrix3Effect::can_be_shown_with_clock() { return true; };
|
||||||
boolean Sinematrix3Effect::clock_as_mask() { return true; };
|
boolean Sinematrix3Effect::clock_as_mask() { return true; };
|
||||||
void Sinematrix3Effect::loop() {
|
void Sinematrix3Effect::loop(uint16_t ms) {
|
||||||
pangle = addmodpi( pangle, 0.0133 + (angle / 256) );
|
pangle = addmodpi( pangle, 0.0133 + (angle / 256) );
|
||||||
angle = cos(pangle) * PI;
|
angle = cos(pangle) * PI;
|
||||||
sx = addmodpi( sx, 0.00673 );
|
sx = addmodpi( sx, 0.00673 );
|
||||||
|
@ -9,7 +9,7 @@ SinesEffectSinus::SinesEffectSinus(Window* w) {
|
|||||||
_color = CHSV(random8(), 255, 255);
|
_color = CHSV(random8(), 255, 255);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SinesEffectSinus::loop() {
|
void SinesEffectSinus::loop(uint16_t ms) {
|
||||||
_value += _frequency;
|
_value += _frequency;
|
||||||
if ((_value == 0 || _value==128) && random8(16)==0) {
|
if ((_value == 0 || _value==128) && random8(16)==0) {
|
||||||
int8_t sign = _value == 0 ? -1 : +1;
|
int8_t sign = _value == 0 ? -1 : +1;
|
||||||
@ -38,11 +38,11 @@ boolean SinesEffect::can_be_shown_with_clock() {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SinesEffect::loop() {
|
void SinesEffect::loop(uint16_t ms) {
|
||||||
// do stuff
|
// do stuff
|
||||||
if (_step++ % 4) return; // Skip 3 out of 4 steps.
|
if (_step++ % 4) return; // Skip 3 out of 4 steps.
|
||||||
window->shift_down_and_blur();
|
window->shift_down_and_blur();
|
||||||
for (int i=0; i<EFFECT_SINES_COUNT; i++) {
|
for (int i=0; i<EFFECT_SINES_COUNT; i++) {
|
||||||
_sinus[i]->loop();
|
_sinus[i]->loop(ms);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ SnakeEffect::~SnakeEffect() {
|
|||||||
delete window;
|
delete window;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SnakeEffect::loop() {
|
void SnakeEffect::loop(uint16_t ms) {
|
||||||
if (run++ % EFFECT_SNAKE_SLOWDOWN == 0) { // Change the coordinates only on every n-th run.
|
if (run++ % EFFECT_SNAKE_SLOWDOWN == 0) { // Change the coordinates only on every n-th run.
|
||||||
if (random8(EFFECT_SNAKE_DIRECTION_CHANGE)==0 || is_turn_needed()) turn_random();
|
if (random8(EFFECT_SNAKE_DIRECTION_CHANGE)==0 || is_turn_needed()) turn_random();
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ StaticEffect::StaticEffect(CRGB col) {
|
|||||||
color = col;
|
color = col;
|
||||||
}
|
}
|
||||||
|
|
||||||
void StaticEffect::loop() {
|
void StaticEffect::loop(uint16_t ms) {
|
||||||
EVERY_N_SECONDS(1) {
|
EVERY_N_SECONDS(1) {
|
||||||
window->clear(&color);
|
window->clear(&color);
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
boolean TwirlEffect::can_be_shown_with_clock() { return true; };
|
boolean TwirlEffect::can_be_shown_with_clock() { return true; };
|
||||||
boolean TwirlEffect::clock_as_mask() { return true; };
|
boolean TwirlEffect::clock_as_mask() { return true; };
|
||||||
|
|
||||||
void TwirlEffect::loop() {
|
void TwirlEffect::loop(uint16_t ms) {
|
||||||
double center_x = _real_center_x; // - (cos8(_center_offset_angle)>>6);
|
double center_x = _real_center_x; // - (cos8(_center_offset_angle)>>6);
|
||||||
double center_y = _real_center_y; // + (sin8(_center_offset_angle)>>6);
|
double center_y = _real_center_y; // + (sin8(_center_offset_angle)>>6);
|
||||||
for (int x=0; x<window->width; x++) for (int y=0; y<window->height; y++) {
|
for (int x=0; x<window->width; x++) for (int y=0; y<window->height; y++) {
|
||||||
|
@ -16,6 +16,7 @@ int loop_timeouts = 0;
|
|||||||
long loop_started_at = 0;
|
long loop_started_at = 0;
|
||||||
uint8_t baseHue = 0; // defined as extern in prototypes.h
|
uint8_t baseHue = 0; // defined as extern in prototypes.h
|
||||||
char hostname[30]; // defined as extern in prototypes.h
|
char hostname[30]; // defined as extern in prototypes.h
|
||||||
|
unsigned long _last_effect_loop_finished_at = 0;
|
||||||
#ifdef RECORDER_ENABLE
|
#ifdef RECORDER_ENABLE
|
||||||
Recorder* recorder;
|
Recorder* recorder;
|
||||||
#endif
|
#endif
|
||||||
@ -87,9 +88,20 @@ void loop() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
EVERY_N_MILLISECONDS(1000 / FPS) {
|
EVERY_N_MILLISECONDS(1000 / FPS) {
|
||||||
//LOGln("Core * loop running");
|
// Calculate the delay since the last time loop() was called.
|
||||||
current_effect->loop();
|
// This way, the effect can handle varying frame rates.
|
||||||
//LOGln("Core * loop ran");
|
uint16_t last_loop_ago;
|
||||||
|
unsigned long now = millis();
|
||||||
|
if (now > _last_effect_loop_finished_at && _last_effect_loop_finished_at) {
|
||||||
|
last_loop_ago = now - _last_effect_loop_finished_at;
|
||||||
|
} else {
|
||||||
|
last_loop_ago = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
current_effect->loop(last_loop_ago);
|
||||||
|
|
||||||
|
// Save the time for the next run.
|
||||||
|
_last_effect_loop_finished_at = now;
|
||||||
|
|
||||||
if (current_effect->can_be_shown_with_clock()) {
|
if (current_effect->can_be_shown_with_clock()) {
|
||||||
effect_clock.loop_with_invert(current_effect->clock_as_mask());
|
effect_clock.loop_with_invert(current_effect->clock_as_mask());
|
||||||
|
Loading…
Reference in New Issue
Block a user