simple designed achived

This commit is contained in:
2026-02-06 11:16:31 +01:00
parent 51d81c6780
commit c2f027f18f
4 changed files with 150 additions and 6 deletions
+61 -3
View File
@@ -235,9 +235,66 @@ void handleMulticolorText() {
}
else
{
server.send(400, "text/plain", "Invalid arguments for /modify-text");
}
} void handleGetNodes()
server.send(400, "text/plain", "Invalid arguments for /modify-text");
}
}
void handleModifyMultiColorText()
{
if (server.hasArg("id") && server.hasArg("colors") && server.hasArg("text"))
{
unsigned char id = server.arg("id").toInt();
String colors_str = server.arg("colors");
String text_str = server.arg("text");
char text[TEXT_MAX_LENGTH + 1];
text_str.toCharArray(text, TEXT_MAX_LENGTH + 1);
RGBWithIndex colors[4];
int color_count = 0;
String color_part = "";
int last_comma = -1;
for (int i = 0; i < colors_str.length() && color_count < 4; i++) {
if (colors_str.charAt(i) == ',') {
color_part = colors_str.substring(last_comma + 1, i);
last_comma = i;
if (color_part.length() > 0) {
long color_val = strtol(color_part.substring(1).c_str(), NULL, 16);
colors[color_count].r = (color_val >> 16) & 0xFF;
colors[color_count].g = (color_val >> 8) & 0xFF;
colors[color_count].b = color_val & 0xFF;
color_count++;
}
}
}
if (color_count < 4) {
color_part = colors_str.substring(last_comma + 1);
if (color_part.length() > 0) {
long color_val = strtol(color_part.substring(1).c_str(), NULL, 16);
colors[color_count].r = (color_val >> 16) & 0xFF;
colors[color_count].g = (color_val >> 8) & 0xFF;
colors[color_count].b = color_val & 0xFF;
color_count++;
}
}
if (color_count > 0) {
int text_len = text_str.length();
int part_len = text_len / color_count;
for (int i = 0; i < color_count; i++) {
colors[i].start_index = i * part_len;
}
}
modifyMultiColorTextNodeById(id, text, colors, color_count);
server.send(200, "text/plain", "OK");
}
else
{
server.send(400, "text/plain", "Invalid arguments for /modify-multicolor-text");
}
}
void handleGetNodes()
{
StaticJsonDocument<2048> jsonDoc;
JsonArray nodes = jsonDoc.to<JsonArray>();
@@ -299,6 +356,7 @@ void handleMulticolorText() {
server.on("/text", HTTP_POST, handleText);
server.on("/modify-text", HTTP_POST, handleModifyText);
server.on("/multicolor-text", HTTP_POST, handleMulticolorText);
server.on("/modify-multicolor-text", HTTP_POST, handleModifyMultiColorText);
server.on("/brightness", HTTP_POST, handleBrightness);
server.on("/upload-page", HTTP_GET, handleUploadPage);
server.on("/upload-bmp", HTTP_POST, []() {