Use sacrificial pixel as a STATUSLED
This commit is contained in:
parent
d6be7b4cae
commit
0f8d464706
@ -87,11 +87,12 @@ 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 void setPixelColor(uint16_t pix, uint32_t c, uint8_t cct) {};
|
virtual void setPixelColor(uint16_t pix, uint32_t c) {}
|
||||||
virtual uint32_t getPixelColor(uint16_t pix) { return 0; };
|
virtual void setPixelColor(uint16_t pix, uint32_t c, uint8_t cct) {}
|
||||||
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() {}
|
||||||
@ -180,6 +181,13 @@ class BusDigital : public Bus {
|
|||||||
PolyBus::setBrightness(_busPtr, _iType, b);
|
PolyBus::setBrightness(_busPtr, _iType, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setStatusPixel(uint32_t c) {
|
||||||
|
if (_skip && canShow()) {
|
||||||
|
for (uint8_t i=0; i<_skip; i--) PolyBus::setPixelColor(_busPtr, _iType, i, c, _colorOrder);
|
||||||
|
PolyBus::show(_busPtr, _iType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void setPixelColor(uint16_t pix, uint32_t c) {
|
void setPixelColor(uint16_t pix, uint32_t c) {
|
||||||
if (getAutoWhiteMode() != RGBW_MODE_MANUAL_ONLY) c = autoWhiteCalc(c);
|
if (getAutoWhiteMode() != RGBW_MODE_MANUAL_ONLY) c = autoWhiteCalc(c);
|
||||||
if (reversed) pix = _len - pix -1;
|
if (reversed) pix = _len - pix -1;
|
||||||
@ -559,6 +567,10 @@ 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];
|
||||||
|
@ -264,7 +264,7 @@ void WLED::setup()
|
|||||||
DEBUG_PRINTLN(F("Reading config"));
|
DEBUG_PRINTLN(F("Reading config"));
|
||||||
deserializeConfigFromFS();
|
deserializeConfigFromFS();
|
||||||
|
|
||||||
#if STATUSLED
|
#if defined(STATUSLED) && STATUSLED>=0
|
||||||
if (!pinManager.isPinAllocated(STATUSLED)) {
|
if (!pinManager.isPinAllocated(STATUSLED)) {
|
||||||
// NOTE: Special case: The status LED should *NOT* be allocated.
|
// NOTE: Special case: The status LED should *NOT* be allocated.
|
||||||
// See comments in handleStatusLed().
|
// See comments in handleStatusLed().
|
||||||
@ -711,32 +711,48 @@ void WLED::handleConnection()
|
|||||||
// else turn the status LED off
|
// else turn the status LED off
|
||||||
void WLED::handleStatusLED()
|
void WLED::handleStatusLED()
|
||||||
{
|
{
|
||||||
#if STATUSLED
|
#if defined(STATUSLED)
|
||||||
|
uint32_t c = 0;
|
||||||
static unsigned long ledStatusLastMillis = 0;
|
static unsigned long ledStatusLastMillis = 0;
|
||||||
static unsigned short ledStatusType = 0; // current status type - corresponds to number of blinks per second
|
static unsigned short ledStatusType = 0; // current status type - corresponds to number of blinks per second
|
||||||
static bool ledStatusState = 0; // the current LED state
|
static bool ledStatusState = false; // the current LED state
|
||||||
|
|
||||||
|
#if STATUSLED>=0
|
||||||
if (pinManager.isPinAllocated(STATUSLED)) {
|
if (pinManager.isPinAllocated(STATUSLED)) {
|
||||||
return; //lower priority if something else uses the same pin
|
return; //lower priority if something else uses the same pin
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
ledStatusType = WLED_CONNECTED ? 0 : 2;
|
if (WLED_CONNECTED) {
|
||||||
if (mqttEnabled && ledStatusType != 2) { // Wi-Fi takes precendence over MQTT
|
c = RGBW32(0,255,0,0);
|
||||||
ledStatusType = WLED_MQTT_CONNECTED ? 0 : 4;
|
ledStatusType = 2;
|
||||||
|
} else if (WLED_MQTT_CONNECTED) {
|
||||||
|
c = RGBW32(0,128,0,0);
|
||||||
|
ledStatusType = 4;
|
||||||
|
} else if (apActive) {
|
||||||
|
c = RGBW32(0,0,255,0);
|
||||||
|
ledStatusType = 2;
|
||||||
}
|
}
|
||||||
if (ledStatusType) {
|
if (ledStatusType) {
|
||||||
if (millis() - ledStatusLastMillis >= (1000/ledStatusType)) {
|
if (millis() - ledStatusLastMillis >= (1000/ledStatusType)) {
|
||||||
ledStatusLastMillis = millis();
|
ledStatusLastMillis = millis();
|
||||||
ledStatusState = ledStatusState ? 0 : 1;
|
ledStatusState = !ledStatusState;
|
||||||
|
#if STATUSLED>=0
|
||||||
digitalWrite(STATUSLED, ledStatusState);
|
digitalWrite(STATUSLED, ledStatusState);
|
||||||
|
#else
|
||||||
|
busses.setStatusPixel(ledStatusState ? c : 0);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
#ifdef STATUSLEDINVERTED
|
#if STATUSLED>=0
|
||||||
|
#ifdef STATUSLEDINVERTED
|
||||||
digitalWrite(STATUSLED, HIGH);
|
digitalWrite(STATUSLED, HIGH);
|
||||||
#else
|
#else
|
||||||
digitalWrite(STATUSLED, LOW);
|
digitalWrite(STATUSLED, LOW);
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
busses.setStatusPixel(0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// version code in format yymmddb (b = daily build)
|
// version code in format yymmddb (b = daily build)
|
||||||
#define VERSION 2111251
|
#define VERSION 2111301
|
||||||
|
|
||||||
//uncomment this if you have a "my_config.h" file you'd like to use
|
//uncomment this if you have a "my_config.h" file you'd like to use
|
||||||
//#define WLED_USE_MY_CONFIG
|
//#define WLED_USE_MY_CONFIG
|
||||||
|
Loading…
Reference in New Issue
Block a user