many changes :Py

This commit is contained in:
kazu
2018-07-08 17:47:59 +02:00
parent 11ed5a9159
commit 528a00b0e9
14 changed files with 843 additions and 91 deletions

View File

@@ -97,6 +97,10 @@ public:
return Color(r+o.r, g+o.g, b+o.g);
}
Color operator * (const float f) const {
return Color(r*f, g*f, b*f);
}
};
template <int numLEDs> class WS2812B {
@@ -117,6 +121,10 @@ template <int numLEDs> class WS2812B {
/** ctor */
WS2812B() {
init();
}
void init() {
LED_SET_PIN_TO_OUTPUT;
}
@@ -125,11 +133,25 @@ template <int numLEDs> class WS2812B {
colors[idx] = rgb;
}
/** set the color for all LEDs */
void setColor(const Color rgb) {
for (int idx = 0; idx < numLEDs; ++idx) {
colors[idx] = rgb;
}
}
/** enable/disable the given LED */
void setEnabled(const uint8_t idx, const bool en) {
enabled[idx] = en;
}
/** enable/disable all LEDs */
void setEnabled(const bool en) {
for (int idx = 0; idx < numLEDs; ++idx) {
enabled[idx] = en;
}
}
/** is the given LED enabled? */
bool isEnabled(const uint8_t idx) const {
return enabled[idx];
@@ -140,11 +162,11 @@ template <int numLEDs> class WS2812B {
}
/** flush configured changes */
void flush() {
void flush() {
LED_SET_PIN_TO_OUTPUT;
// cli();
ets_intr_lock();
// process each LED
for (uint8_t i = 0; i < numLEDs; ++i) {
@@ -163,9 +185,9 @@ template <int numLEDs> class WS2812B {
}
reset();
ets_intr_unlock();
//sei();
reset();
}