Experiment in getting the differing delays in Single/MultiDynamic effects to work. Unsuccessful, for now.

This commit is contained in:
Fabian Schlenz 2019-06-03 06:43:50 +02:00
parent 7fdc28fe48
commit b2bc8aa75e
4 changed files with 25 additions and 9 deletions

View File

@ -4,9 +4,8 @@
#include "effect_single_dynamic.h" #include "effect_single_dynamic.h"
class MultiDynamicEffect : public SingleDynamicEffect { class MultiDynamicEffect : public SingleDynamicEffect {
protected:
int getLoopTime();
public: public:
MultiDynamicEffect();
void update(); void update();
}; };

View File

@ -8,12 +8,13 @@ class SingleDynamicEffect : 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(); int loopTime = 200;
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;
public: public:
SingleDynamicEffect(); SingleDynamicEffect();
void init();
virtual void update(); virtual void update();
boolean can_be_shown_with_clock(); boolean can_be_shown_with_clock();
virtual void loop(); virtual void loop();

View File

@ -2,7 +2,11 @@
#include "effect_single_dynamic.h" #include "effect_single_dynamic.h"
#include "config.h" #include "config.h"
int MultiDynamicEffect::getLoopTime() { return EFFECT_MULTI_DYNAMIC_LOOP_TIME; } MultiDynamicEffect::MultiDynamicEffect() {
init();
loopTime = EFFECT_MULTI_DYNAMIC_LOOP_TIME;
}
void MultiDynamicEffect::update() { void MultiDynamicEffect::update() {
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);
} }

View File

@ -2,17 +2,22 @@
#include "functions.h" #include "functions.h"
SingleDynamicEffect::SingleDynamicEffect() { SingleDynamicEffect::SingleDynamicEffect() {
init();
loopTime = EFFECT_SINGLE_DYNAMIC_LOOP_TIME;
}
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);
} }
int SingleDynamicEffect::getLoopTime() {
return EFFECT_SINGLE_DYNAMIC_LOOP_TIME;
}
void SingleDynamicEffect::update() { void SingleDynamicEffect::update() {
tiles[random8(tile_count)] = CHSV(baseHue + random8(64), 180, 255); tiles[random8(tile_count)] = CHSV(baseHue + random8(64), 180, 255);
} }
boolean SingleDynamicEffect::can_be_shown_with_clock() { return true; } boolean SingleDynamicEffect::can_be_shown_with_clock() { return true; }
void SingleDynamicEffect::loop() { void SingleDynamicEffect::loop() {
EVERY_N_MILLISECONDS(getLoopTime()) { /*EVERY_N_MILLISECONDS(loopTime) {
memcpy(old_tiles, tiles, tile_count*sizeof(CRGB)); memcpy(old_tiles, tiles, tile_count*sizeof(CRGB));
blend = 0; blend = 0;
update(); update();
@ -22,5 +27,12 @@ void SingleDynamicEffect::loop() {
int index = y/2 * window.w/2 + x/2; int index = y/2 * window.w/2 + x/2;
setPixel(window, x, y, nblend(old_tiles[index], tiles[index], blend)); setPixel(window, x, y, nblend(old_tiles[index], tiles[index], blend));
} }
if (blend < 255) blend+=20; if (blend < 255) blend+=20;*/
EVERY_N_MILLISECONDS(loopTime) {
update();
}
for (int x=0; x<window.w; x++) for (int y=0; y<window.h; y++) {
int index = y/2 * window.w/2 + x/2;
setPixel(window, x, y, tiles[index]);
}
} }