From 86e7b3a471491bfcf77a7e8c88dfdf16c5bfee97 Mon Sep 17 00:00:00 2001 From: Jeka Der Date: Mon, 12 Aug 2024 16:50:59 +0200 Subject: [PATCH 1/3] ESP32: use FastLED version from lib_deps Remove FastLed override present on ESP32_generic target, use version specified in common.lib_deps instead --- platformio.ini | 1 - 1 file changed, 1 deletion(-) diff --git a/platformio.ini b/platformio.ini index 95e7586..6cdbfad 100644 --- a/platformio.ini +++ b/platformio.ini @@ -79,7 +79,6 @@ platform_packages = toolchain-xtensa32@~2.80400.0 lib_deps = ${common.lib_deps} - fastled/FastLED@^3.5.0 Hash = https://github.com/bbx10/Hash_tng.git plerup/EspSoftwareSerial@^6.11.4 WiFiManager = https://github.com/tzapu/WiFiManager.git#v2.0.15-rc.1 From 6ea73439f1584c9a327973fc3e94245d077fd3c0 Mon Sep 17 00:00:00 2001 From: Jeka Der Date: Thu, 29 Aug 2024 15:04:44 +0200 Subject: [PATCH 2/3] common library versions across all targets --- platformio.ini | 11 +++----- src/PixelIt.ino | 68 ++++++++++++++++++++++++++++++++++++------------- 2 files changed, 55 insertions(+), 24 deletions(-) diff --git a/platformio.ini b/platformio.ini index 6cdbfad..c285a8c 100644 --- a/platformio.ini +++ b/platformio.ini @@ -53,15 +53,17 @@ lib_deps = bblanchon/ArduinoJson@5.13.4 beegee-tokyo/DHT sensor library for ESPx@1.19.0 claws/BH1750@1.3.0 - ColorConverter=https://github.com/luisllamasbinaburo/Arduino-ColorConverter.git#v2.0.0 fastled/FastLED@3.7.0 knolleary/PubSubClient@2.8.0 + Hash = https://github.com/bbx10/Hash_tng.git LightDependentResistor=https://github.com/QuentinCG/Arduino-Light-Dependent-Resistor-Library.git#1.4.0 links2004/WebSockets@2.4.1 marcmerlin/FastLED NeoMatrix@1.2.0 powerbroker2/DFPlayerMini_Fast@1.2.4 + plerup/EspSoftwareSerial@^8.2.0 robtillaart/Max44009@0.6.0 TimeLib = https://github.com/PaulStoffregen/Time.git#v1.6.1 + WiFiManager = https://github.com/tzapu/WiFiManager.git#v2.0.17 [env:ESP32_generic] platform = espressif32 @@ -79,12 +81,9 @@ platform_packages = toolchain-xtensa32@~2.80400.0 lib_deps = ${common.lib_deps} - Hash = https://github.com/bbx10/Hash_tng.git - plerup/EspSoftwareSerial@^6.11.4 - WiFiManager = https://github.com/tzapu/WiFiManager.git#v2.0.15-rc.1 [env:ESP8266_generic] -platform = espressif8266@2.6.3 +platform = espressif8266@4.2.1 board = esp12e framework = ${common.framework} board_build.filesystem = littlefs @@ -96,8 +95,6 @@ build_flags = -DBUILD_SECTION="ESP8266_generic" lib_deps = ${common.lib_deps} - mr-glt/SHA-1 Hash@^1.1.0 - tzapu/WiFiManager@^0.16.0 [env:ESP8266_d1_mini] extends = env:ESP8266_generic diff --git a/src/PixelIt.ino b/src/PixelIt.ino index 39ec930..0fbd260 100644 --- a/src/PixelIt.ino +++ b/src/PixelIt.ino @@ -38,7 +38,6 @@ #include #include #include -#include "ColorConverterLib.h" #include #include #include @@ -508,8 +507,8 @@ void SaveConfig() json["clockTimeZone"] = clockTimeZone; String clockColorHex; - ColorConverter::RgbToHex(clockColorR, clockColorG, clockColorB, clockColorHex); - json["clockColor"] = "#" + clockColorHex; + RgbToHex(clockColorR, clockColorG, clockColorB, clockColorHex); + json["clockColor"] = clockColorHex; json["clockSwitchAktiv"] = clockSwitchAktiv; json["clockSwitchSec"] = clockSwitchSec; @@ -692,7 +691,7 @@ void SetConfigVariables(JsonObject &json) if (json.containsKey("clockColor")) { - ColorConverter::HexToRgb(json["clockColor"].as(), clockColorR, clockColorG, clockColorB); + HexToRgb(json["clockColor"].as(), clockColorR, clockColorG, clockColorB); } if (json.containsKey("clockSwitchAktiv")) @@ -1112,7 +1111,8 @@ void HandleAndSendButtonPress(uint button, bool state) { for (uint i = 0; i < sizeof websocketConnection / sizeof websocketConnection[0]; i++) { - webSocket.sendTXT(i, "{\"buttons\":{\"" + btnAPINames[button] + "\":" + (state ? "true" : "false") + "}}"); + String payload = "{\"buttons\":{\"" + btnAPINames[button] + "\":" + (state ? "true" : "false") + "}}"; + webSocket.sendTXT(i, payload); } } @@ -1235,8 +1235,10 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t *payload, size_t length) SendLDR(true); SendSensor(true); SendConfig(); - webSocket.sendTXT(num, "{\"buttons\":" + GetButtons() + "}"); - webSocket.sendTXT(num, "{\"telemetry\":" + GetTelemetry() + "}"); + String payload = "{\"buttons\":" + GetButtons() + "}"; + webSocket.sendTXT(num, payload); + payload = "{\"telemetry\":" + GetTelemetry() + "}"; + webSocket.sendTXT(num, payload); break; } case WStype_TEXT: @@ -1545,7 +1547,7 @@ void CreateFrames(JsonObject &json, int forceDuration) uint8_t b = 255; if (json["switchAnimation"]["hexColor"].as() != NULL) { - ColorConverter::HexToRgb(json["switchAnimation"]["hexColor"].as(), r, g, b); + HexToRgb(json["switchAnimation"]["hexColor"].as(), r, g, b); } else if (json["switchAnimation"]["color"]["r"].as() != NULL) { @@ -1628,7 +1630,7 @@ void CreateFrames(JsonObject &json, int forceDuration) else if (json["clock"]["hexColor"].as() != NULL) { logMessage += F("hexColor, "); - ColorConverter::HexToRgb(json["clock"]["hexColor"].as(), clockColorR, clockColorG, clockColorB); + HexToRgb(json["clock"]["hexColor"].as(), clockColorR, clockColorG, clockColorB); } if (logMessage.endsWith(", ")) { @@ -1651,7 +1653,7 @@ void CreateFrames(JsonObject &json, int forceDuration) uint8_t r, g, b; if (json["bar"]["hexColor"].as() != NULL) { - ColorConverter::HexToRgb(json["bar"]["hexColor"].as(), r, g, b); + HexToRgb(json["bar"]["hexColor"].as(), r, g, b); } else { @@ -1671,7 +1673,7 @@ void CreateFrames(JsonObject &json, int forceDuration) uint8_t r, g, b; if (x["hexColor"].as() != NULL) { - ColorConverter::HexToRgb(x["hexColor"].as(), r, g, b); + HexToRgb(x["hexColor"].as(), r, g, b); } else { @@ -1797,7 +1799,7 @@ void CreateFrames(JsonObject &json, int forceDuration) uint8_t r, g, b; if (json["text"]["hexColor"].as() != NULL) { - ColorConverter::HexToRgb(json["text"]["hexColor"].as(), r, g, b); + HexToRgb(json["text"]["hexColor"].as(), r, g, b); } else { @@ -4218,7 +4220,8 @@ void SendMatrixInfo() { for (uint i = 0; i < sizeof websocketConnection / sizeof websocketConnection[0]; i++) { - webSocket.sendTXT(i, "{\"sysinfo\":" + matrixInfo + "}"); + String payload = "{\"sysinfo\":" + matrixInfo + "}"; + webSocket.sendTXT(i, payload); } } } @@ -4252,7 +4255,8 @@ void SendLDR(bool force) { for (unsigned int i = 0; i < sizeof websocketConnection / sizeof websocketConnection[0]; i++) { - webSocket.sendTXT(i, "{\"sensor\":" + luxSensor + "}"); + String payload = "{\"sensor\":" + luxSensor + "}"; + webSocket.sendTXT(i, payload); } } @@ -4299,7 +4303,8 @@ void SendSensor(bool force) { for (uint i = 0; i < sizeof websocketConnection / sizeof websocketConnection[0]; i++) { - webSocket.sendTXT(i, "{\"sensor\":" + Sensor + "}"); + String payload = "{\"sensor\":" + Sensor + "}"; + webSocket.sendTXT(i, payload); } } @@ -4312,8 +4317,8 @@ void SendConfig() { for (uint i = 0; i < sizeof websocketConnection / sizeof websocketConnection[0]; i++) { - String config = GetConfig(); - webSocket.sendTXT(i, "{\"config\":" + config + "}"); + String payload = "{\"config\":" + GetConfig() + "}"; + webSocket.sendTXT(i, payload); } } } @@ -4374,6 +4379,35 @@ void sendNTPpacket(String &address) udp.endPacket(); } +//decode hex string into R G B decimals +void HexToRgb(String hex, uint8_t& red, uint8_t& green, uint8_t& blue) +{ + const char* hexString = (hex[0] == '#') ? hex.c_str() + 1 : hex.c_str(); + long number = strtol(hexString, nullptr, 16); + red = (number >> 16) & 0xFF; + green = (number >> 8) & 0xFF; + blue = number & 0xFF; +} + +// convert R G B decimal values to hex string +void RgbToHex(uint8_t red, uint8_t green, uint8_t blue, String &hex) +{ + String redHex = String(red, HEX); + if (redHex.length() < 2) { + redHex = "0" + redHex; + } + String greenHex = String(green, HEX); + if (greenHex.length() < 2) { + greenHex = "0" + greenHex; + } + String blueHex = String(blue, HEX); + if (blueHex.length() < 2) { + blueHex = "0" + blueHex; + } + hex = "#" + redHex + greenHex + blueHex; + hex.toUpperCase(); +} + void Log(String function, String message) { From e63912a53616c0233b40130c9f961f65169b2cf8 Mon Sep 17 00:00:00 2001 From: Fab!an Date: Thu, 29 Aug 2024 15:39:11 +0200 Subject: [PATCH 3/3] Update platformio.ini --- platformio.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio.ini b/platformio.ini index c285a8c..8c32a66 100644 --- a/platformio.ini +++ b/platformio.ini @@ -55,7 +55,7 @@ lib_deps = claws/BH1750@1.3.0 fastled/FastLED@3.7.0 knolleary/PubSubClient@2.8.0 - Hash = https://github.com/bbx10/Hash_tng.git + Hash = https://github.com/bbx10/Hash_tng.git#1f100823284a28e8aedeae7e7f593e189fe16982 LightDependentResistor=https://github.com/QuentinCG/Arduino-Light-Dependent-Resistor-Library.git#1.4.0 links2004/WebSockets@2.4.1 marcmerlin/FastLED NeoMatrix@1.2.0