Browse Source

garland: improve anim_assemble

mcspr-patch-1
DmitryBlinov 3 years ago
committed by Maxim Prokhorov
parent
commit
3fe6874863
1 changed files with 36 additions and 8 deletions
  1. +36
    -8
      code/espurna/garland/animations/anim_assemble.h

+ 36
- 8
code/espurna/garland/animations/anim_assemble.h View File

@ -8,6 +8,13 @@
//------------------------------------------------------------------------------
class AnimAssemble : public Anim {
enum class Phases {
Assemmble,
Glow,
Fade
};
Phases phase = Phases::Assemmble;
public:
AnimAssemble() : Anim("Assemble") {
cycleFactor = 2;
@ -33,20 +40,41 @@ class AnimAssemble : public Anim {
}
initSeq();
shuffleSeq();
glowSetUp();
pos = 0;
}
void Run() override {
if (pos < numLeds) {
byte cur_point = seq[pos];
leds[cur_point] = ledstmp[cur_point];
++pos;
if (phase == Phases::Assemmble) {
if (pos < numLeds) {
byte cur_point = seq[pos];
leds[cur_point] = ledstmp[cur_point];
++pos;
} else {
pos = 0;
phase = Phases::Glow;
}
} else if (phase == Phases::Glow) {
if (pos < numLeds/2) {
for (int i = 0; i < numLeds; ++i) {
leds[i] = ledstmp[i];
glowForEachLed(i);
}
glowRun();
++pos;
} else {
pos = 0;
phase = Phases::Fade;
}
} else {
int del_pos = pos - numLeds;
byte cur_point = seq[del_pos];
leds[cur_point] = 0;
if (++pos >= numLeds * 2)
if (pos < numLeds) {
byte cur_point = seq[pos];
leds[cur_point] = 0;
++pos;
} else {
pos = 0;
phase = Phases::Assemmble;
}
}
}
};


Loading…
Cancel
Save