port to platformio

This commit is contained in:
2021-03-29 01:10:55 -07:00
parent 9a3bf84214
commit a6534bcb20
131 changed files with 1537 additions and 1148 deletions

32
src/inputs/ColorCycle.h Normal file
View File

@@ -0,0 +1,32 @@
#include <Figments.h>
#include <ArduinoLog.h>
template<int Period>
class ColorSequenceInput: public InputSource {
public:
ColorSequenceInput(const std::vector<CRGB> &colors, const char* name, Task::State initialState)
: InputSource(name, initialState), m_colors(colors) {}
InputEvent read() override {
EVERY_N_SECONDS(Period) {
m_idx %= m_colors.size();
m_reset = true;
m_idx++;
}
if (m_reset) {
m_reset = false;
Log.notice("Cycling %s color to %d [%d, %d, %d]", name, m_idx, m_colors[m_idx].r, m_colors[m_idx].g, m_colors[m_idx].b);
return InputEvent{InputEvent::SetColor, m_colors[m_idx]};
}
return InputEvent{};
}
void onStart() override {
m_reset = true;
}
private:
std::vector<CRGB> m_colors;
unsigned int m_idx = 0;
bool m_reset = true;
};