| CMD_SWITCH_LED, | CMD_SWITCH_LED, | ||||
| CMD_CHG_COLOR, | CMD_CHG_COLOR, | ||||
| CMD_CHG_BRIGHTNESS, | CMD_CHG_BRIGHTNESS, | ||||
| CMD_CHG_CFG_PARAM, | |||||
| CMD_RESET_WIFI_CFG | CMD_RESET_WIFI_CFG | ||||
| }; | }; | ||||
| return "CHG_COLOR"; | return "CHG_COLOR"; | ||||
| case CMD_CHG_BRIGHTNESS: | case CMD_CHG_BRIGHTNESS: | ||||
| return "CHG_BRIGHTNESS"; | return "CHG_BRIGHTNESS"; | ||||
| case CMD_CHG_CFG_PARAM: | |||||
| return "CHG_CFG_PARAM"; | |||||
| case CMD_RESET_WIFI_CFG: | case CMD_RESET_WIFI_CFG: | ||||
| return "RESET_WIFI_CFG"; | return "RESET_WIFI_CFG"; | ||||
| default: | default: | ||||
| return CMD_CHG_COLOR; | return CMD_CHG_COLOR; | ||||
| if (strcmp(cmd, "CHG_BRIGHTNESS") == 0) | if (strcmp(cmd, "CHG_BRIGHTNESS") == 0) | ||||
| return CMD_CHG_BRIGHTNESS; | return CMD_CHG_BRIGHTNESS; | ||||
| if (strcmp(cmd, "CHG_CFG_PARAM") == 0) | |||||
| return CMD_CHG_CFG_PARAM; | |||||
| if (strcmp(cmd, "RESET_WIFI_CFG") == 0) | if (strcmp(cmd, "RESET_WIFI_CFG") == 0) | ||||
| return CMD_RESET_WIFI_CFG; | return CMD_RESET_WIFI_CFG; | ||||
| _config = setToDefaultWiFiConfig(_config); | _config = setToDefaultWiFiConfig(_config); | ||||
| _config = setToDefaultLEDConfig(_config); | _config = setToDefaultLEDConfig(_config); | ||||
| // String ssid = ""; | |||||
| // String pass = ""; | |||||
| // ssid.toCharArray(_config.ssid, sizeof(_config.ssid)); | |||||
| // pass.toCharArray(_config.pass, sizeof(_config.pass)); | |||||
| // | |||||
| // _config.wifiValid = false; | |||||
| // _config.mode = LM_SINGLE_COLOR; | |||||
| // _config.singleColor.r = 0; | |||||
| // _config.singleColor.g = 0; | |||||
| // _config.singleColor.b = 0; | |||||
| // _config.singleColor.w = 255; | |||||
| // | |||||
| // _config.brightness = 128; | |||||
| // | |||||
| // _config.segmentColor1.r = 255; | |||||
| // _config.segmentColor1.g = 0; | |||||
| // _config.segmentColor1.b = 0; | |||||
| // _config.segmentColor1.w = 0; | |||||
| // | |||||
| // _config.segmentColor2.r = 0; | |||||
| // _config.segmentColor2.g = 255; | |||||
| // _config.segmentColor2.b = 0; | |||||
| // _config.segmentColor2.w = 0; | |||||
| // | |||||
| // _config.segmentColor3.r = 0; | |||||
| // _config.segmentColor3.g = 0; | |||||
| // _config.segmentColor3.b = 255; | |||||
| // _config.segmentColor3.w = 0; | |||||
| // | |||||
| // _config.rainbowDelay = 20; | |||||
| // | |||||
| // _config.spectralStepTime = 10000; | |||||
| // | |||||
| // _config.fadingHoldTime = 5000; | |||||
| // _config.fadingFadeTime = 1000; | |||||
| // | |||||
| // _config.flashOnTime = 1000; | |||||
| // _config.flashOffTime = 500; | |||||
| EEPROM.begin(sizeof(Config)); | EEPROM.begin(sizeof(Config)); | ||||
| EEPROM.put(0, _config); | EEPROM.put(0, _config); | ||||
| EEPROM.commit(); | EEPROM.commit(); |
| } else if (strToCommand(cmd) == CMD_CHG_COLOR) { | } else if (strToCommand(cmd) == CMD_CHG_COLOR) { | ||||
| const char *value = doc["val"]; | const char *value = doc["val"]; | ||||
| const char *color = doc["clr"]; | |||||
| unsigned int r, g, b, w; | unsigned int r, g, b, w; | ||||
| if (sscanf(value, "%u,%u,%u,%u", &r, &g, &b, &w) == 4) { | |||||
| ledMngr.onColorChange(r, g, b, w); | |||||
| if (sscanf(color, "%u,%u,%u,%u", &r, &g, &b, &w) == 4) { | |||||
| ledMngr.onColorChange(value, r, g, b, w); | |||||
| } | } | ||||
| } else if (strToCommand(cmd) == CMD_CHG_BRIGHTNESS) { | } else if (strToCommand(cmd) == CMD_CHG_BRIGHTNESS) { | ||||
| const char *value = doc["val"]; | const char *value = doc["val"]; | ||||
| if (sscanf(value, "%u", &br) == 1) { | if (sscanf(value, "%u", &br) == 1) { | ||||
| ledMngr.onBrightnessChange(br); | ledMngr.onBrightnessChange(br); | ||||
| } | } | ||||
| } else if (strToCommand(cmd) == CMD_CHG_CFG_PARAM) { | |||||
| const char *value = doc["val"]; | |||||
| const char *amount = doc["amt"]; | |||||
| uint32_t amountVal; | |||||
| if (sscanf(amount, "%u", &amountVal) == 1) { | |||||
| ledMngr.onCfgParamChange(value, amountVal); | |||||
| } | |||||
| } else if (strToCommand(cmd) == CMD_RESET_WIFI_CFG) { | } else if (strToCommand(cmd) == CMD_RESET_WIFI_CFG) { | ||||
| resetWifiConfiguration(num); | resetWifiConfiguration(num); | ||||
| } else { | } else { | ||||
| String s = "ACK UNKNOWN: " + msg; | String s = "ACK UNKNOWN: " + msg; |
| } | } | ||||
| } | } | ||||
| void LEDStripManager::onColorChange(uint8_t red, uint8_t green, uint8_t blue, uint8_t white) { | |||||
| void LEDStripManager::onColorChange(String cfgVal, uint8_t red, uint8_t green, uint8_t blue, uint8_t white) { | |||||
| Config cfg = configManager.getConfig(); | Config cfg = configManager.getConfig(); | ||||
| cfg.singleColor.r = red; | |||||
| cfg.singleColor.g = green; | |||||
| cfg.singleColor.b = blue; | |||||
| cfg.singleColor.w = white; | |||||
| configManager.saveConfig(cfg); | |||||
| this->setAll(red, green, blue, white); | |||||
| RGBWColor *color = nullptr; | |||||
| if (cfgVal == "singleColor") | |||||
| color = &cfg.singleColor; | |||||
| else if (cfgVal == "segmentColor1") | |||||
| color = &cfg.segmentColor1; | |||||
| else if (cfgVal == "segmentColor2") | |||||
| color = &cfg.segmentColor2; | |||||
| else if (cfgVal == "segmentColor3") | |||||
| color = &cfg.segmentColor3; | |||||
| if (color != nullptr) { | |||||
| color->r = red; | |||||
| color->g = green; | |||||
| color->b = blue; | |||||
| color->w = white; | |||||
| configManager.saveConfig(cfg); | |||||
| } | |||||
| if (cfgVal == "singleColor") { | |||||
| this->setAll(red, green, blue, white); | |||||
| } else { | |||||
| setSegments(); | |||||
| } | |||||
| } | } | ||||
| void LEDStripManager::onBrightnessChange(uint8_t brightness) { | void LEDStripManager::onBrightnessChange(uint8_t brightness) { | ||||
| this->setBrightness(brightness); | this->setBrightness(brightness); | ||||
| } | } | ||||
| void LEDStripManager::onCfgParamChange(String cfgVal, uint32_t amount) { | |||||
| Config cfg = configManager.getConfig(); | |||||
| if (cfgVal == "rainbowDelay") | |||||
| cfg.rainbowDelay = amount; | |||||
| else if (cfgVal == "spectralStepTime") | |||||
| cfg.spectralStepTime = amount; | |||||
| else if (cfgVal == "fadingHoldTime") | |||||
| cfg.fadingHoldTime = amount; | |||||
| else if (cfgVal == "fadingFadeTime") | |||||
| cfg.fadingFadeTime = amount; | |||||
| else if (cfgVal == "flashOnTime") | |||||
| cfg.flashOnTime = amount; | |||||
| else if (cfgVal == "flashOffTime") | |||||
| cfg.flashOffTime = amount; | |||||
| configManager.saveConfig(cfg); | |||||
| } | |||||
| void LEDStripManager::setSegments() { | void LEDStripManager::setSegments() { | ||||
| Config cfg = configManager.getConfig(); | Config cfg = configManager.getConfig(); | ||||
| } | } | ||||
| } | } | ||||
| void LEDStripManager::doSpectral() { | void LEDStripManager::doSpectral() { | ||||
| Config cfg = configManager.getConfig(); | Config cfg = configManager.getConfig(); | ||||
| static uint8_t currentColor = 0; | static uint8_t currentColor = 0; | ||||
| static uint32_t stateStart = millis(); | static uint32_t stateStart = millis(); | ||||
| const uint32_t holdTime = cfg.fadingHoldTime; | |||||
| const uint32_t fadeTime = cfg.fadingFadeTime; | |||||
| if (digitalRead(LED_STRIP_POWER_PIN) == HIGH) { | if (digitalRead(LED_STRIP_POWER_PIN) == HIGH) { | ||||
| uint32_t holdTime = cfg.fadingHoldTime; | |||||
| uint32_t fadeTime = cfg.fadingFadeTime; | |||||
| uint32_t now = millis(); | uint32_t now = millis(); | ||||
| uint32_t elapsed = now - stateStart; | uint32_t elapsed = now - stateStart; | ||||
| void LEDStripManager::flash() { | void LEDStripManager::flash() { | ||||
| Config cfg = configManager.getConfig(); | |||||
| static const uint32_t onMillis = cfg.flashOnTime; | |||||
| static const uint32_t offMillis = cfg.flashOffTime; | |||||
| static bool ledOn = false; | static bool ledOn = false; | ||||
| static uint32_t lastChange = 0; | static uint32_t lastChange = 0; | ||||
| if (digitalRead(LED_STRIP_POWER_PIN) == HIGH) { | if (digitalRead(LED_STRIP_POWER_PIN) == HIGH) { | ||||
| Config cfg = configManager.getConfig(); | Config cfg = configManager.getConfig(); | ||||
| uint32_t onMillis = cfg.flashOnTime; | |||||
| uint32_t offMillis = cfg.flashOffTime; | |||||
| uint32_t now = millis(); | uint32_t now = millis(); | ||||
| if (ledOn) { | if (ledOn) { | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| void onModeChange(LEDModes mode); | void onModeChange(LEDModes mode); | ||||
| void onColorChange(uint8_t red, uint8_t green, uint8_t blue, uint8_t white); | |||||
| void onColorChange(String cfgVal, uint8_t red, uint8_t green, uint8_t blue, uint8_t white); | |||||
| void onBrightnessChange(uint8_t brightness); | void onBrightnessChange(uint8_t brightness); | ||||
| void onCfgParamChange(String cfgVal, uint32_t amount); | |||||
| private: | private: | ||||
| Adafruit_NeoPixel strip; | Adafruit_NeoPixel strip; | ||||
| //This is a automatic generated file | //This is a automatic generated file | ||||
| //Please do not modify this file | //Please do not modify this file | ||||
| //If you touch this file your change will be overwritten during the next build | //If you touch this file your change will be overwritten during the next build | ||||
| //This file has been generated on 2026-06-29 13:40:40 | |||||
| //This file has been generated on 2026-06-29 15:24:39 | |||||
| #include "Arduino.h" | #include "Arduino.h" | ||||
| #include "Arduino.h" | #include "Arduino.h" |