46 lines
628 B
C++
46 lines
628 B
C++
#ifndef RAINBOW_H
|
|
#define RAINBOW_H
|
|
|
|
|
|
#include "ESP8266lib/ext/led/WS2812B.h"
|
|
|
|
/**
|
|
* show rainbow colors using HUE
|
|
*/
|
|
class Rainbow {
|
|
|
|
uint8_t hue = 0;
|
|
|
|
public:
|
|
|
|
/** ctor */
|
|
Rainbow() {
|
|
;
|
|
}
|
|
|
|
/** show a beat by shifting the hue color */
|
|
void shift(const int val) {
|
|
hue += val;
|
|
}
|
|
|
|
/** set hue back to 0 */
|
|
void restart() {
|
|
hue = 0;
|
|
}
|
|
|
|
/** called from the main */
|
|
void update() {
|
|
++hue;
|
|
}
|
|
|
|
/** called from the main */
|
|
Color getCurrent() const {
|
|
Color c; c.setHSV(hue, 255, 255);
|
|
return c;
|
|
}
|
|
|
|
};
|
|
|
|
|
|
#endif // RAINBOW_H
|