Alexa swipe effect

This commit is contained in:
Martin Bauer
2021-11-19 17:22:09 +01:00
parent 484db9bdfa
commit aa76900244
20 changed files with 342 additions and 894 deletions

View File

@@ -3,7 +3,6 @@
#include "helpers/ColorRGBW.h"
#include "Arduino.h" // TODO
#include <cstdint>
template <int TNumLeds>
@@ -12,16 +11,19 @@ class LedStripRGBW
public:
static constexpr int NUM_LEDS = TNumLeds;
static constexpr int normalizeIdx(int idx)
{
return (idx < 0) ? (idx + NUM_LEDS) : (idx >= NUM_LEDS ? idx - NUM_LEDS : idx);
}
void set(int idx, uint8_t r, uint8_t g, uint8_t b, uint8_t w)
{
// green: 0
// red: 8
// blue: 16
// white: 24
if (idx < 0 || idx >= NUM_LEDS)
Serial.printf("Out of bounds idx %i\n", idx);
else
data_[idx] = (g << 0) | (r << 8) | (b << 16) | (w << 24);
idx = normalizeIdx(idx);
data_[idx] = (g << 0) | (r << 8) | (b << 16) | (w << 24);
}
const uint32_t *rawData() const { return data_; }