mirror of
https://github.com/1technophile/OpenMQTTGateway.git
synced 2026-02-19 16:21:44 +01:00
[LED] Add LED STRIP macros and a third Addressable pin (#2063)
* [LED] Add LED STRIP macros and a third Addressable pin --------- Co-authored-by: Florian <1technophile@users.noreply.github.com>
This commit is contained in:
@@ -54,6 +54,10 @@ void LEDManager::setMode(int stripIndex, int ledIndex, Mode mode, uint32_t color
|
||||
} else if (ledIndex >= 0 && ledIndex < ledStrips[stripIndex].ledStates.size()) {
|
||||
setModeForSingleLED(stripIndex, ledIndex, mode, color, durationOrBlinkCount);
|
||||
}
|
||||
} else if (stripIndex == -1) {
|
||||
for (int i = 0; i < ledStrips.size(); i++) {
|
||||
setMode(i, ledIndex, mode, color, durationOrBlinkCount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -62,10 +62,10 @@ void setup() {
|
||||
|
||||
void loop() {
|
||||
#ifdef LED_ADDRESSABLE
|
||||
// Set all LEDs on the strip to static green
|
||||
// Set all LEDs on the first strip to static green
|
||||
ledManager.setMode(0, -1, LEDManager::STATIC, LED_COLOR_GREEN);
|
||||
|
||||
// Blink first 5 LEDs red for 3 times
|
||||
// Blink first 5 LEDs red for 3 times on the first strip
|
||||
for (int i = 0; i < 5; i++) {
|
||||
ledManager.setMode(0, i, LEDManager::BLINK, LED_COLOR_RED, 3);
|
||||
}
|
||||
@@ -73,7 +73,7 @@ void loop() {
|
||||
// Set first LED to static green
|
||||
ledManager.setMode(0, 0, LEDManager::STATIC, LED_COLOR_GREEN);
|
||||
|
||||
// Blink second LED red
|
||||
// Blink second strip LED red
|
||||
ledManager.setMode(1, 0, LEDManager::BLINK, LED_COLOR_RED, 3);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -447,8 +447,22 @@ ss_cnt_parameters cnt_parameters_array[cnt_parameters_array_size] = {
|
||||
#ifndef LED_NETWORK
|
||||
# define LED_NETWORK 0
|
||||
#endif
|
||||
#ifndef LED_POWER
|
||||
# define LED_POWER -1
|
||||
|
||||
// LED Strip index
|
||||
#ifndef STRIP_ERROR
|
||||
# define STRIP_ERROR 0
|
||||
#endif
|
||||
#ifndef STRIP_PROCESSING
|
||||
# define STRIP_PROCESSING 0
|
||||
#endif
|
||||
#ifndef STRIP_BROKER
|
||||
# define STRIP_BROKER 0
|
||||
#endif
|
||||
#ifndef STRIP_NETWORK
|
||||
# define STRIP_NETWORK 0
|
||||
#endif
|
||||
#ifndef STRIP_POWER
|
||||
# define STRIP_POWER 0
|
||||
#endif
|
||||
|
||||
// Single standard LED pin
|
||||
|
||||
@@ -1230,65 +1230,65 @@ void updateAndHandleLEDsTask() {
|
||||
static GatewayState previousGatewayState;
|
||||
if (previousGatewayState != gatewayState) {
|
||||
#ifdef LED_POWER
|
||||
ledManager.setMode(0, LED_POWER, LEDManager::STATIC, LED_POWER_COLOR, -1);
|
||||
ledManager.setMode(STRIP_POWER, LED_POWER, LEDManager::STATIC, LED_POWER_COLOR, -1);
|
||||
#endif
|
||||
switch (gatewayState) {
|
||||
case PROCESSING:
|
||||
#ifdef LED_PROCESSING
|
||||
ledManager.setMode(0, LED_PROCESSING, LEDManager::BLINK, LED_PROCESSING_COLOR, 3);
|
||||
ledManager.setMode(STRIP_PROCESSING, LED_PROCESSING, LEDManager::BLINK, LED_PROCESSING_COLOR, 3);
|
||||
#endif
|
||||
break;
|
||||
case WAITING_ONBOARDING:
|
||||
#ifdef LED_BROKER
|
||||
ledManager.setMode(0, LED_BROKER, LEDManager::STATIC, LED_WAITING_ONBOARD_COLOR, -1);
|
||||
ledManager.setMode(STRIP_BROKER, LED_BROKER, LEDManager::STATIC, LED_WAITING_ONBOARD_COLOR, -1);
|
||||
#endif
|
||||
break;
|
||||
case ONBOARDING:
|
||||
#ifdef LED_BROKER
|
||||
ledManager.setMode(0, LED_BROKER, LEDManager::STATIC, LED_ONBOARD_COLOR, -1);
|
||||
ledManager.setMode(STRIP_BROKER, LED_BROKER, LEDManager::STATIC, LED_ONBOARD_COLOR, -1);
|
||||
#endif
|
||||
break;
|
||||
case NTWK_CONNECTED:
|
||||
#ifdef LED_NETWORK
|
||||
ledManager.setMode(0, LED_NETWORK, LEDManager::STATIC, LED_NETWORK_OK_COLOR, -1);
|
||||
ledManager.setMode(STRIP_NETWORK, LED_NETWORK, LEDManager::STATIC, LED_NETWORK_OK_COLOR, -1);
|
||||
#endif
|
||||
break;
|
||||
case BROKER_CONNECTED:
|
||||
#ifdef LED_BROKER
|
||||
ledManager.setMode(0, LED_BROKER, LEDManager::STATIC, LED_BROKER_OK_COLOR, -1);
|
||||
ledManager.setMode(STRIP_BROKER, LED_BROKER, LEDManager::STATIC, LED_BROKER_OK_COLOR, -1);
|
||||
#endif
|
||||
break;
|
||||
case NTWK_DISCONNECTED:
|
||||
#ifdef LED_NETWORK
|
||||
ledManager.setMode(0, LED_NETWORK, LEDManager::BLINK, LED_NETWORK_ERROR_COLOR, -1);
|
||||
ledManager.setMode(STRIP_NETWORK, LED_NETWORK, LEDManager::BLINK, LED_NETWORK_ERROR_COLOR, -1);
|
||||
#endif
|
||||
break;
|
||||
case BROKER_DISCONNECTED:
|
||||
#ifdef LED_BROKER
|
||||
ledManager.setMode(0, LED_BROKER, LEDManager::BLINK, LED_BROKER_ERROR_COLOR, -1);
|
||||
ledManager.setMode(STRIP_BROKER, LED_BROKER, LEDManager::BLINK, LED_BROKER_ERROR_COLOR, -1);
|
||||
#endif
|
||||
break;
|
||||
case SLEEPING:
|
||||
ledManager.setMode(0, -1, LEDManager::OFF, 0, -1);
|
||||
ledManager.setMode(-1, -1, LEDManager::OFF, 0, -1);
|
||||
break;
|
||||
case OFFLINE:
|
||||
#ifdef LED_NETWORK
|
||||
ledManager.setMode(0, LED_NETWORK, LEDManager::BLINK, LED_OFFLINE_COLOR, -1);
|
||||
ledManager.setMode(STRIP_NETWORK, LED_NETWORK, LEDManager::BLINK, LED_OFFLINE_COLOR, -1);
|
||||
#endif
|
||||
break;
|
||||
case LOCAL_OTA_IN_PROGRESS:
|
||||
#ifdef LED_PROCESSING
|
||||
ledManager.setMode(0, LED_PROCESSING, LEDManager::BLINK, LED_OTA_LOCAL_COLOR, -1);
|
||||
ledManager.setMode(STRIP_PROCESSING, LED_PROCESSING, LEDManager::BLINK, LED_OTA_LOCAL_COLOR, -1);
|
||||
#endif
|
||||
break;
|
||||
case REMOTE_OTA_IN_PROGRESS:
|
||||
#ifdef LED_PROCESSING
|
||||
ledManager.setMode(0, LED_PROCESSING, LEDManager::BLINK, LED_OTA_REMOTE_COLOR, -1);
|
||||
ledManager.setMode(STRIP_PROCESSING, LED_PROCESSING, LEDManager::BLINK, LED_OTA_REMOTE_COLOR, -1);
|
||||
#endif
|
||||
break;
|
||||
case ERROR:
|
||||
#ifdef LED_ERROR
|
||||
ledManager.setMode(0, LED_ERROR, LEDManager::BLINK, LED_ERROR_COLOR, 3);
|
||||
ledManager.setMode(STRIP_ERROR, LED_ERROR, LEDManager::BLINK, LED_ERROR_COLOR, 3);
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
@@ -1323,6 +1323,9 @@ void setup() {
|
||||
# endif
|
||||
# ifdef LED_ADDRESSABLE_PIN2
|
||||
ledManager.addLEDStrip(LED_ADDRESSABLE_PIN2, LED_ADDRESSABLE_NUM);
|
||||
# endif
|
||||
# ifdef LED_ADDRESSABLE_PIN3
|
||||
ledManager.addLEDStrip(LED_ADDRESSABLE_PIN3, LED_ADDRESSABLE_NUM);
|
||||
# endif
|
||||
ledManager.setBrightness(SYSConfig.rgbbrightness);
|
||||
#elif LED_PIN
|
||||
|
||||
Reference in New Issue
Block a user