Status LED support in Bus manager
This commit is contained in:
parent
11c7ffad4e
commit
48339b19d4
@ -1166,6 +1166,8 @@ uint32_t WS2812FX::gamma32(uint32_t color)
|
|||||||
}
|
}
|
||||||
|
|
||||||
WS2812FX* WS2812FX::instance = nullptr;
|
WS2812FX* WS2812FX::instance = nullptr;
|
||||||
|
|
||||||
|
//Bus static member definition, would belong in bus_manager.cpp
|
||||||
int16_t Bus::_cct = -1;
|
int16_t Bus::_cct = -1;
|
||||||
uint8_t Bus::_cctBlend = 0;
|
uint8_t Bus::_cctBlend = 0;
|
||||||
uint8_t Bus::_autoWhiteMode = RGBW_MODE_DUAL;
|
uint8_t Bus::_autoWhiteMode = RGBW_MODE_DUAL;
|
@ -85,10 +85,11 @@ class Bus {
|
|||||||
|
|
||||||
virtual void show() {}
|
virtual void show() {}
|
||||||
virtual bool canShow() { return true; }
|
virtual bool canShow() { return true; }
|
||||||
virtual void setPixelColor(uint16_t pix, uint32_t c) {};
|
virtual void setStatusPixel(uint32_t c) {}
|
||||||
virtual uint32_t getPixelColor(uint16_t pix) { return 0; };
|
virtual void setPixelColor(uint16_t pix, uint32_t c) {}
|
||||||
virtual void setBrightness(uint8_t b) {};
|
virtual uint32_t getPixelColor(uint16_t pix) { return 0; }
|
||||||
virtual void cleanup() {};
|
virtual void setBrightness(uint8_t b) {}
|
||||||
|
virtual void cleanup() {}
|
||||||
virtual uint8_t getPins(uint8_t* pinArray) { return 0; }
|
virtual uint8_t getPins(uint8_t* pinArray) { return 0; }
|
||||||
inline uint16_t getLength() { return _len; }
|
inline uint16_t getLength() { return _len; }
|
||||||
virtual void setColorOrder() {}
|
virtual void setColorOrder() {}
|
||||||
@ -192,6 +193,15 @@ class BusDigital : public Bus {
|
|||||||
PolyBus::setBrightness(_busPtr, _iType, b);
|
PolyBus::setBrightness(_busPtr, _iType, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//If LEDs are skipped, it is possible to use the first as a status LED.
|
||||||
|
//TODO only show if no new show due in the next 50ms
|
||||||
|
void setStatusPixel(uint32_t c) {
|
||||||
|
if (_skip && canShow()) {
|
||||||
|
PolyBus::setPixelColor(_busPtr, _iType, 0, c, _colorOrder);
|
||||||
|
PolyBus::show(_busPtr, _iType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void setPixelColor(uint16_t pix, uint32_t c) {
|
void setPixelColor(uint16_t pix, uint32_t c) {
|
||||||
if (_type == TYPE_SK6812_RGBW || _type == TYPE_TM1814) c = autoWhiteCalc(c);
|
if (_type == TYPE_SK6812_RGBW || _type == TYPE_TM1814) c = autoWhiteCalc(c);
|
||||||
if (_cct >= 1900) c = colorBalanceFromKelvin(_cct, c); //color correction from CCT
|
if (_cct >= 1900) c = colorBalanceFromKelvin(_cct, c); //color correction from CCT
|
||||||
@ -292,10 +302,10 @@ class BusPwm : public Bus {
|
|||||||
|
|
||||||
void setPixelColor(uint16_t pix, uint32_t c) {
|
void setPixelColor(uint16_t pix, uint32_t c) {
|
||||||
if (pix != 0 || !_valid) return; //only react to first pixel
|
if (pix != 0 || !_valid) return; //only react to first pixel
|
||||||
if (_type == TYPE_ANALOG_3CH && _cct >= 1900) {
|
if (_type != TYPE_ANALOG_3CH) c = autoWhiteCalc(c);
|
||||||
|
if (_cct >= 1900 && (_type == TYPE_ANALOG_3CH || _type == TYPE_ANALOG_4CH)) {
|
||||||
c = colorBalanceFromKelvin(_cct, c); //color correction from CCT
|
c = colorBalanceFromKelvin(_cct, c); //color correction from CCT
|
||||||
}
|
}
|
||||||
if (_type != TYPE_ANALOG_3CH) c = autoWhiteCalc(c);
|
|
||||||
uint8_t r = R(c);
|
uint8_t r = R(c);
|
||||||
uint8_t g = G(c);
|
uint8_t g = G(c);
|
||||||
uint8_t b = B(c);
|
uint8_t b = B(c);
|
||||||
@ -562,6 +572,12 @@ class BusManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setStatusPixel(uint32_t c) {
|
||||||
|
for (uint8_t i = 0; i < numBusses; i++) {
|
||||||
|
busses[i]->setStatusPixel(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void setPixelColor(uint16_t pix, uint32_t c, int16_t cct=-1) {
|
void setPixelColor(uint16_t pix, uint32_t c, int16_t cct=-1) {
|
||||||
for (uint8_t i = 0; i < numBusses; i++) {
|
for (uint8_t i = 0; i < numBusses; i++) {
|
||||||
Bus* b = busses[i];
|
Bus* b = busses[i];
|
||||||
|
@ -124,7 +124,7 @@
|
|||||||
// - 0b010 (dec. 32-47) analog (PWM)
|
// - 0b010 (dec. 32-47) analog (PWM)
|
||||||
// - 0b011 (dec. 48-63) digital (data + clock / SPI)
|
// - 0b011 (dec. 48-63) digital (data + clock / SPI)
|
||||||
// - 0b100 (dec. 64-79) unused/reserved
|
// - 0b100 (dec. 64-79) unused/reserved
|
||||||
// - 0b101 (dec. 80-95) digital (data + clock / SPI)
|
// - 0b101 (dec. 80-95) virtual network busses
|
||||||
// - 0b110 (dec. 96-111) unused/reserved
|
// - 0b110 (dec. 96-111) unused/reserved
|
||||||
// - 0b111 (dec. 112-127) unused/reserved
|
// - 0b111 (dec. 112-127) unused/reserved
|
||||||
//bit 7 is reserved and set to 0
|
//bit 7 is reserved and set to 0
|
||||||
|
@ -22,7 +22,7 @@ private:
|
|||||||
ColorCallbackFunction _callbackCol = nullptr;
|
ColorCallbackFunction _callbackCol = nullptr;
|
||||||
uint8_t _val, _val_last, _sat = 0;
|
uint8_t _val, _val_last, _sat = 0;
|
||||||
uint16_t _hue = 0, _ct = 0;
|
uint16_t _hue = 0, _ct = 0;
|
||||||
float _x = 0.5, _y = 0.5;
|
float _x = 0.5f, _y = 0.5f;
|
||||||
uint32_t _rgb = 0;
|
uint32_t _rgb = 0;
|
||||||
uint8_t _id = 0;
|
uint8_t _id = 0;
|
||||||
EspalexaDeviceType _type;
|
EspalexaDeviceType _type;
|
||||||
|
Loading…
Reference in New Issue
Block a user