forgot to commit everything...

This commit is contained in:
2018-02-03 16:55:37 +01:00
parent 20d46af1fb
commit 3da4722748
15 changed files with 991 additions and 0 deletions

44
user/FadeOnce.h Executable file
View File

@@ -0,0 +1,44 @@
#ifndef FLASHONCE_H
#define FLASHONCE_H
#include "ESP8266lib/ext/led/WS2812B.h"
/** fade between two colors */
class FadeOnce {
Color c1;
Color c2;
int fadeOut_ticks = 0;
int ticksLeft = 0;
public:
/** ctor */
FadeOnce() {
;
}
void setColor(Color c1, Color c2) {
this->c1 = c1;
this->c2 = c2;
}
void setFadeDuration(int duration_ticks) {
this->fadeOut_ticks = duration_ticks;
this->ticksLeft = duration_ticks;
}
void update() {
if (ticksLeft > 0) {--ticksLeft;} // fade-out
}
Color getCurrent() const {
const int percent = (ticksLeft * 100 / fadeOut_ticks);
return Color::mix(c1, c2, percent);
}
};
#endif // FLASHONCE_H