Skip to content

Commit b96b63a

Browse files
committed
Removed color convertion libary
1 parent 09f0fca commit b96b63a

4 files changed

Lines changed: 51 additions & 16 deletions

File tree

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,10 @@ Thanks to these great people for supporting this project.
144144

145145
<!-- ** WORK IN PROGRESS ** -->
146146

147-
### 2.5.2 (2024-10-05)
147+
### 2.5.2 (2024-10-07)
148148

149149
- (foorschtbar) Fixed ESP32 Battery Pin Definition
150+
- (foorschtbar) Removed color convertion libary
150151

151152
### 2.5.1 (2024-04-07)
152153

platformio.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ lib_deps =
5353
bblanchon/ArduinoJson@5.13.4
5454
beegee-tokyo/DHT sensor library for ESPx@1.19.0
5555
claws/BH1750@1.3.0
56-
ColorConverter=https://github.com/luisllamasbinaburo/Arduino-ColorConverter.git#v2.0.0
5756
fastled/FastLED@3.7.0
5857
knolleary/PubSubClient@2.8.0
5958
LightDependentResistor=https://github.com/QuentinCG/Arduino-Light-Dependent-Resistor-Library.git#1.4.0

src/PixelIt.ino

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
#include <DHTesp.h>
3939
#include <DFPlayerMini_Fast.h>
4040
#include <SoftwareSerial.h>
41-
#include "ColorConverterLib.h"
4241
#include <TimeLib.h>
4342
#include <ArduinoJson.h>
4443
#include <ArduinoHttpClient.h>
@@ -506,11 +505,7 @@ void SaveConfig()
506505
json["matrixTempCorrection"] = matrixTempCorrection;
507506
json["ntpServer"] = ntpServer;
508507
json["clockTimeZone"] = clockTimeZone;
509-
510-
String clockColorHex;
511-
ColorConverter::RgbToHex(clockColorR, clockColorG, clockColorB, clockColorHex);
512-
json["clockColor"] = "#" + clockColorHex;
513-
508+
json["clockColor"] = "#" + RGBtoHEX(clockColorR, clockColorG, clockColorB);
514509
json["clockSwitchAktiv"] = clockSwitchAktiv;
515510
json["clockSwitchSec"] = clockSwitchSec;
516511
json["clock24Hours"] = clock24Hours;
@@ -692,7 +687,7 @@ void SetConfigVariables(JsonObject &json)
692687

693688
if (json.containsKey("clockColor"))
694689
{
695-
ColorConverter::HexToRgb(json["clockColor"].as<String>(), clockColorR, clockColorG, clockColorB);
690+
HEXtoRGB(json["clockColor"].as<String>(), clockColorR, clockColorG, clockColorB);
696691
}
697692

698693
if (json.containsKey("clockSwitchAktiv"))
@@ -1545,7 +1540,7 @@ void CreateFrames(JsonObject &json, int forceDuration)
15451540
uint8_t b = 255;
15461541
if (json["switchAnimation"]["hexColor"].as<char *>() != NULL)
15471542
{
1548-
ColorConverter::HexToRgb(json["switchAnimation"]["hexColor"].as<char *>(), r, g, b);
1543+
HEXtoRGB(json["switchAnimation"]["hexColor"].as<char *>(), r, g, b);
15491544
}
15501545
else if (json["switchAnimation"]["color"]["r"].as<char *>() != NULL)
15511546
{
@@ -1628,7 +1623,7 @@ void CreateFrames(JsonObject &json, int forceDuration)
16281623
else if (json["clock"]["hexColor"].as<char *>() != NULL)
16291624
{
16301625
logMessage += F("hexColor, ");
1631-
ColorConverter::HexToRgb(json["clock"]["hexColor"].as<char *>(), clockColorR, clockColorG, clockColorB);
1626+
HEXtoRGB(json["clock"]["hexColor"].as<char *>(), clockColorR, clockColorG, clockColorB);
16321627
}
16331628
if (logMessage.endsWith(", "))
16341629
{
@@ -1651,7 +1646,7 @@ void CreateFrames(JsonObject &json, int forceDuration)
16511646
uint8_t r, g, b;
16521647
if (json["bar"]["hexColor"].as<char *>() != NULL)
16531648
{
1654-
ColorConverter::HexToRgb(json["bar"]["hexColor"].as<char *>(), r, g, b);
1649+
HEXtoRGB(json["bar"]["hexColor"].as<char *>(), r, g, b);
16551650
}
16561651
else
16571652
{
@@ -1671,7 +1666,7 @@ void CreateFrames(JsonObject &json, int forceDuration)
16711666
uint8_t r, g, b;
16721667
if (x["hexColor"].as<char *>() != NULL)
16731668
{
1674-
ColorConverter::HexToRgb(x["hexColor"].as<char *>(), r, g, b);
1669+
HEXtoRGB(x["hexColor"].as<char *>(), r, g, b);
16751670
}
16761671
else
16771672
{
@@ -1797,7 +1792,7 @@ void CreateFrames(JsonObject &json, int forceDuration)
17971792
uint8_t r, g, b;
17981793
if (json["text"]["hexColor"].as<char *>() != NULL)
17991794
{
1800-
ColorConverter::HexToRgb(json["text"]["hexColor"].as<char *>(), r, g, b);
1795+
HEXtoRGB(json["text"]["hexColor"].as<char *>(), r, g, b);
18011796
}
18021797
else
18031798
{

src/Tools.h

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ byte Utf8ToAscii(byte ascii)
119119
case 0XE29885: // Star ★
120120
result = 0xE3;
121121
break;
122-
case 0xF09F9384: // File 📄
122+
case 0xF09F9384: // File 📄
123123
result = 0xE4;
124124
break;
125125
case 0xE299A5: // Heart ♥
@@ -136,7 +136,7 @@ byte Utf8ToAscii(byte ascii)
136136
break;
137137
case 0xF09F9381: // Folder 📁
138138
result = 0xE9;
139-
break;
139+
break;
140140
}
141141

142142
// Legal UTF-8 Byte Sequences
@@ -251,4 +251,44 @@ int GetRSSIasQuality(int rssi)
251251
float CelsiusToFahrenheit(float celsius)
252252
{
253253
return (celsius * 9 / 5) + 32;
254+
}
255+
256+
// RGBtoHEX
257+
String RGBtoHEX(int r, int g, int b)
258+
{
259+
String rs = String(r, HEX);
260+
String gs = String(g, HEX);
261+
String bs = String(b, HEX);
262+
263+
if (rs.length() == 1)
264+
rs = "0" + rs;
265+
if (gs.length() == 1)
266+
gs = "0" + gs;
267+
if (bs.length() == 1)
268+
bs = "0" + bs;
269+
270+
return rs + gs + bs;
271+
}
272+
273+
// HEXtoRGB
274+
void HEXtoRGB(String hex, uint8_t &r, uint8_t &g, uint8_t &b)
275+
{
276+
// Remove # if it exists
277+
hex.replace("#", "");
278+
// trim to 6 characters
279+
hex = hex.substring(0, 6);
280+
// check of the string is a valid hex color
281+
// regex: ^#?([a-f0-9]{6}|[a-f0-9]{3})$
282+
if (hex.length() == 6)
283+
{
284+
r = strtol(hex.substring(0, 2).c_str(), nullptr, 16);
285+
g = strtol(hex.substring(2, 4).c_str(), nullptr, 16);
286+
b = strtol(hex.substring(4, 6).c_str(), nullptr, 16);
287+
}
288+
else
289+
{
290+
r = 0;
291+
g = 0;
292+
b = 0;
293+
}
254294
}

0 commit comments

Comments
 (0)