diff --git a/README.md b/README.md index 2699aec..cfc7acc 100644 --- a/README.md +++ b/README.md @@ -144,9 +144,10 @@ Thanks to these great people for supporting this project. -### 2.5.2 (2024-10-05) +### 2.5.2 (2024-10-07) - (foorschtbar) Fixed ESP32 Battery Pin Definition +- (foorschtbar) Removed color convertion libary ### 2.5.1 (2024-04-07) diff --git a/platformio.ini b/platformio.ini index fdae166..d13927c 100644 --- a/platformio.ini +++ b/platformio.ini @@ -53,7 +53,6 @@ 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 LightDependentResistor=https://github.com/QuentinCG/Arduino-Light-Dependent-Resistor-Library.git#1.4.0 diff --git a/src/PixelIt.ino b/src/PixelIt.ino index 39ec930..b838535 100644 --- a/src/PixelIt.ino +++ b/src/PixelIt.ino @@ -38,7 +38,6 @@ #include #include #include -#include "ColorConverterLib.h" #include #include #include @@ -506,11 +505,7 @@ void SaveConfig() json["matrixTempCorrection"] = matrixTempCorrection; json["ntpServer"] = ntpServer; json["clockTimeZone"] = clockTimeZone; - - String clockColorHex; - ColorConverter::RgbToHex(clockColorR, clockColorG, clockColorB, clockColorHex); - json["clockColor"] = "#" + clockColorHex; - + json["clockColor"] = "#" + RGBtoHEX(clockColorR, clockColorG, clockColorB); json["clockSwitchAktiv"] = clockSwitchAktiv; json["clockSwitchSec"] = clockSwitchSec; json["clock24Hours"] = clock24Hours; @@ -692,7 +687,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")) @@ -1545,7 +1540,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 +1623,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 +1646,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 +1666,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 +1792,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 { diff --git a/src/Tools.h b/src/Tools.h index 9da0214..7235964 100644 --- a/src/Tools.h +++ b/src/Tools.h @@ -119,7 +119,7 @@ byte Utf8ToAscii(byte ascii) case 0XE29885: // Star ★ result = 0xE3; break; - case 0xF09F9384: // File 📄 + case 0xF09F9384: // File 📄 result = 0xE4; break; case 0xE299A5: // Heart ♥ @@ -136,7 +136,7 @@ byte Utf8ToAscii(byte ascii) break; case 0xF09F9381: // Folder 📁 result = 0xE9; - break; + break; } // Legal UTF-8 Byte Sequences @@ -251,4 +251,44 @@ int GetRSSIasQuality(int rssi) float CelsiusToFahrenheit(float celsius) { return (celsius * 9 / 5) + 32; +} + +// RGBtoHEX +String RGBtoHEX(int r, int g, int b) +{ + String rs = String(r, HEX); + String gs = String(g, HEX); + String bs = String(b, HEX); + + if (rs.length() == 1) + rs = "0" + rs; + if (gs.length() == 1) + gs = "0" + gs; + if (bs.length() == 1) + bs = "0" + bs; + + return rs + gs + bs; +} + +// HEXtoRGB +void HEXtoRGB(String hex, uint8_t &r, uint8_t &g, uint8_t &b) +{ + // Remove # if it exists + hex.replace("#", ""); + // trim to 6 characters + hex = hex.substring(0, 6); + // check of the string is a valid hex color + // regex: ^#?([a-f0-9]{6}|[a-f0-9]{3})$ + if (hex.length() == 6) + { + r = strtol(hex.substring(0, 2).c_str(), nullptr, 16); + g = strtol(hex.substring(2, 4).c_str(), nullptr, 16); + b = strtol(hex.substring(4, 6).c_str(), nullptr, 16); + } + else + { + r = 0; + g = 0; + b = 0; + } } \ No newline at end of file