diff --git a/interface/src/app/main/types.ts b/interface/src/app/main/types.ts index 3b31b8b0b..b2fc93525 100644 --- a/interface/src/app/main/types.ts +++ b/interface/src/app/main/types.ts @@ -21,6 +21,7 @@ export interface Settings { dallas_gpio: number; dallas_parasite: boolean; led_gpio: number; + led_type: number; hide_led: boolean; low_clock: boolean; notoken_api: boolean; @@ -262,6 +263,7 @@ export const BOARD_PROFILES: BoardProfiles = { export interface BoardProfile { board_profile: string; led_gpio: number; + led_type: number; dallas_gpio: number; rx_gpio: number; tx_gpio: number; diff --git a/interface/src/app/settings/ApplicationSettings.tsx b/interface/src/app/settings/ApplicationSettings.tsx index ae2e369ba..7ff37415c 100644 --- a/interface/src/app/settings/ApplicationSettings.tsx +++ b/interface/src/app/settings/ApplicationSettings.tsx @@ -550,6 +550,23 @@ const ApplicationSettings = () => { margin="normal" /> + {data.led_gpio !== 0 && ( + + + LED + RGB-LED + + + )} & data, const std::string & board_profile) { if (board_profile == "S32") { - data = {2, 18, 23, 5, 0, PHY_type::PHY_TYPE_NONE, 0, 0, 0}; // BBQKees Gateway S32 + data = {2, 18, 23, 5, 0, PHY_type::PHY_TYPE_NONE, 0, 0, 0, 0}; // BBQKees Gateway S32 } else if (board_profile == "E32") { - data = {2, 4, 5, 17, 33, PHY_type::PHY_TYPE_LAN8720, 16, 1, 0}; // BBQKees Gateway E32 + data = {2, 4, 5, 17, 33, PHY_type::PHY_TYPE_LAN8720, 16, 1, 0, 0}; // BBQKees Gateway E32 } else if (board_profile == "E32V2") { - data = {2, 14, 4, 5, 34, PHY_type::PHY_TYPE_LAN8720, 15, 0, 1}; // BBQKees Gateway E32 V2 + data = {2, 14, 4, 5, 34, PHY_type::PHY_TYPE_LAN8720, 15, 0, 1, 0}; // BBQKees Gateway E32 V2 } else if (board_profile == "MH-ET") { - data = {2, 18, 23, 5, 0, PHY_type::PHY_TYPE_NONE, 0, 0, 0}; // MH-ET Live D1 Mini + data = {2, 18, 23, 5, 0, PHY_type::PHY_TYPE_NONE, 0, 0, 0, 0}; // MH-ET Live D1 Mini } else if (board_profile == "NODEMCU") { - data = {2, 18, 23, 5, 0, PHY_type::PHY_TYPE_NONE, 0, 0, 0}; // NodeMCU 32S + data = {2, 18, 23, 5, 0, PHY_type::PHY_TYPE_NONE, 0, 0, 0, 0}; // NodeMCU 32S } else if (board_profile == "LOLIN") { - data = {2, 18, 17, 16, 0, PHY_type::PHY_TYPE_NONE, 0, 0, 0}; // Lolin D32 + data = {2, 18, 17, 16, 0, PHY_type::PHY_TYPE_NONE, 0, 0, 0, 0}; // Lolin D32 } else if (board_profile == "OLIMEX") { - data = {0, 0, 36, 4, 34, PHY_type::PHY_TYPE_LAN8720, -1, 0, 0}; // Olimex ESP32-EVB (uses U1TXD/U1RXD/BUTTON, no LED or Temperature sensor) + data = {0, 0, 36, 4, 34, PHY_type::PHY_TYPE_LAN8720, -1, 0, 0, 0}; // Olimex ESP32-EVB (uses U1TXD/U1RXD/BUTTON, no LED or Temperature sensor) } else if (board_profile == "OLIMEXPOE") { - data = {0, 0, 36, 4, 34, PHY_type::PHY_TYPE_LAN8720, 12, 0, 3}; // Olimex ESP32-POE + data = {0, 0, 36, 4, 34, PHY_type::PHY_TYPE_LAN8720, 12, 0, 3, 0}; // Olimex ESP32-POE } else if (board_profile == "C3MINI") { - data = {7, 1, 4, 5, 9, PHY_type::PHY_TYPE_NONE, 0, 0, 0}; // Lolin C3 Mini +#if defined(BOARD_C3_MINI_V1) + data = {7, 1, 4, 5, 9, PHY_type::PHY_TYPE_NONE, 0, 0, 0, 0}; // Lolin C3 Mini V1 +#else + data = {7, 1, 4, 5, 9, PHY_type::PHY_TYPE_NONE, 0, 0, 0, 1}; // Lolin C3 Mini with RGB Led +#endif } else if (board_profile == "S2MINI") { - data = {15, 7, 11, 12, 0, PHY_type::PHY_TYPE_NONE, 0, 0, 0}; // Lolin S2 Mini + data = {15, 7, 11, 12, 0, PHY_type::PHY_TYPE_NONE, 0, 0, 0, 0}; // Lolin S2 Mini } else if (board_profile == "S3MINI") { - data = {17, 18, 8, 5, 0, PHY_type::PHY_TYPE_NONE, 0, 0, 0}; // Liligo S3 + data = {17, 18, 8, 5, 0, PHY_type::PHY_TYPE_NONE, 0, 0, 0, 0}; // Liligo S3 } else if (board_profile == "S32S3") { - data = {2, 18, 5, 17, 0, PHY_type::PHY_TYPE_NONE, 0, 0, 0}; // BBQKees Gateway S3 + data = {2, 18, 5, 17, 0, PHY_type::PHY_TYPE_NONE, 0, 0, 0, 0}; // BBQKees Gateway S3 } else if (board_profile == "CUSTOM") { // send back current values data = {(int8_t)EMSESP::system_.led_gpio_, @@ -1870,7 +1859,8 @@ bool System::load_board_profile(std::vector & data, const std::string & (int8_t)EMSESP::system_.phy_type_, EMSESP::system_.eth_power_, (int8_t)EMSESP::system_.eth_phy_addr_, - (int8_t)EMSESP::system_.eth_clock_mode_}; + (int8_t)EMSESP::system_.eth_clock_mode_, + (int8_t)EMSESP::system_.led_type_}; } else { LOG_DEBUG("Couldn't identify board profile %s", board_profile.c_str()); return false; // unknown, return false @@ -2064,9 +2054,7 @@ bool System::uploadFirmwareURL(const char * url) { // TODO do we need to stop the UART first with EMSuart::stop() ? // set a callback so we can monitor progress in the WebUI - Update.onProgress([](size_t progress, size_t total) { - EMSESP::system_.systemStatus(SYSTEM_STATUS::SYSTEM_STATUS_UPLOADING+(progress * 100 / total)); - }); + Update.onProgress([](size_t progress, size_t total) { EMSESP::system_.systemStatus(SYSTEM_STATUS::SYSTEM_STATUS_UPLOADING + (progress * 100 / total)); }); // get tcp stream and send it to Updater WiFiClient * stream = http.getStreamPtr(); diff --git a/src/core/system.h b/src/core/system.h index 8573bee20..96daa20eb 100644 --- a/src/core/system.h +++ b/src/core/system.h @@ -394,6 +394,7 @@ class System { std::string hostname_; String locale_; bool hide_led_; + uint8_t led_type_; uint8_t led_gpio_; bool analog_enabled_; bool low_clock_; diff --git a/src/web/WebSettingsService.cpp b/src/web/WebSettingsService.cpp index 0b7f8780b..7781bf0f4 100644 --- a/src/web/WebSettingsService.cpp +++ b/src/web/WebSettingsService.cpp @@ -59,6 +59,7 @@ void WebSettings::read(WebSettings & settings, JsonObject root) { root["dallas_parasite"] = settings.dallas_parasite; root["led_gpio"] = settings.led_gpio; root["hide_led"] = settings.hide_led; + root["led_type"] = settings.led_type; root["low_clock"] = settings.low_clock; root["telnet_enabled"] = settings.telnet_enabled; root["notoken_api"] = settings.notoken_api; @@ -103,6 +104,7 @@ StateUpdateResult WebSettings::update(JsonObject root, WebSettings & settings) { #endif // get the current board profile saved in the settings file + String org_board_profile = settings.board_profile; settings.board_profile = root["board_profile"] | EMSESP_DEFAULT_BOARD_PROFILE; // this is set at compile time in platformio.ini, other it's "default" String old_board_profile = settings.board_profile; @@ -133,7 +135,12 @@ StateUpdateResult WebSettings::update(JsonObject root, WebSettings & settings) { (int8_t)(root["phy_type"] | PHY_type::PHY_TYPE_NONE), (int8_t)(root["eth_power"] | 0), (int8_t)(root["eth_phy_addr"] | 0), - (int8_t)(root["eth_clock_mode"] | 0)}; + (int8_t)(root["eth_clock_mode"] | 0), +#if defined(ARDUINO_LOLIN_C3_MINI) && !defined(BOARD_C3_MINI_V1) + (int8_t)(root["led_type"] | 1)}; +#else + (int8_t)(root["led_type"] | 0)}; +#endif } // check valid pins in this board profile if (!System::is_valid_gpio(data[0], psram) || !System::is_valid_gpio(data[1], psram) || !System::is_valid_gpio(data[2], psram) @@ -180,11 +187,11 @@ StateUpdateResult WebSettings::update(JsonObject root, WebSettings & settings) { // override if we know the target from the build config like C3, S2, S3 etc.. #elif CONFIG_IDF_TARGET_ESP32C3 - settings.board_profile = "C3MINI"; + settings.board_profile = "C3MINI"; #elif CONFIG_IDF_TARGET_ESP32S2 - settings.board_profile = "S2MINI"; + settings.board_profile = "S2MINI"; #elif CONFIG_IDF_TARGET_ESP32S3 - settings.board_profile = "S32S3"; // BBQKees Gateway S3 + settings.board_profile = "S32S3"; // BBQKees Gateway S3 #endif // apply the new board profile setting @@ -194,8 +201,9 @@ StateUpdateResult WebSettings::update(JsonObject root, WebSettings & settings) { if (old_board_profile != settings.board_profile) { // see if need to override the set board profile (e.g. forced by NVS boot string) EMSESP::logger().info("Setting new Board profile %s (was %s)", settings.board_profile.c_str(), old_board_profile.c_str()); - } else { - EMSESP::logger().info("Board profile set to %s", settings.board_profile.c_str()); + } else if (org_board_profile != settings.board_profile) { + // EMSESP::logger().info("Board profile set to %s", settings.board_profile.c_str()); + EMSESP::logger().info("Setting new Board profile %s (was %s)", settings.board_profile.c_str(), org_board_profile.c_str()); } int prev; @@ -229,6 +237,9 @@ StateUpdateResult WebSettings::update(JsonObject root, WebSettings & settings) { prev = settings.eth_clock_mode; settings.eth_clock_mode = data[8]; check_flag(prev, settings.eth_clock_mode, ChangeFlags::RESTART); + prev = settings.led_type; + settings.led_type = data[9]; + check_flag(prev, settings.led_type, ChangeFlags::LED); // tx_mode, rx and tx pins prev = settings.tx_mode; @@ -304,6 +315,7 @@ StateUpdateResult WebSettings::update(JsonObject root, WebSettings & settings) { settings.low_clock = root["low_clock"]; check_flag(prev, settings.low_clock, ChangeFlags::RESTART); + // Modbus settings prev = settings.modbus_enabled; settings.modbus_enabled = root["modbus_enabled"] | EMSESP_DEFAULT_MODBUS_ENABLED; check_flag(prev, settings.modbus_enabled, ChangeFlags::RESTART); @@ -455,6 +467,7 @@ void WebSettingsService::board_profile(AsyncWebServerRequest * request) { root["eth_power"] = data[6]; root["eth_phy_addr"] = data[7]; root["eth_clock_mode"] = data[8]; + root["led_type"] = data[9]; response->setLength(); request->send(response); diff --git a/src/web/WebSettingsService.h b/src/web/WebSettingsService.h index 07797bf24..ba1e9abc4 100644 --- a/src/web/WebSettingsService.h +++ b/src/web/WebSettingsService.h @@ -54,6 +54,7 @@ class WebSettings { bool dallas_parasite; uint8_t led_gpio; bool hide_led; + uint8_t led_type; bool low_clock; bool telnet_enabled; bool notoken_api;