editing normal nodetText
This commit is contained in:
+74
-10
@@ -214,18 +214,80 @@ void handleMulticolorText() {
|
||||
addNewMultiColor(text, colors, color_count, false, x, y, slowness, true, is_small, disappear_time, is_repeating);
|
||||
|
||||
server.send(200, "text/plain", "OK");
|
||||
} else {
|
||||
server.send(400, "text/plain", "Invalid arguments for /multicolor-text");
|
||||
} else {
|
||||
server.send(400, "text/plain", "Invalid arguments for /multicolor-text");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void start_server()
|
||||
{
|
||||
WiFi.begin(ssid, password);
|
||||
while (WiFi.status() != WL_CONNECTED)
|
||||
|
||||
void handleModifyText()
|
||||
{
|
||||
if (server.hasArg("id") && server.hasArg("color"))
|
||||
{
|
||||
unsigned char id = server.arg("id").toInt();
|
||||
String colorStr = server.arg("color");
|
||||
uint32_t color = strtol(colorStr.substring(1).c_str(), NULL, 16);
|
||||
String text_str = server.arg("text");
|
||||
char text[TEXT_MAX_LENGTH + 1];
|
||||
text_str.toCharArray(text, TEXT_MAX_LENGTH + 1);
|
||||
unsigned char slowness = server.arg("slowness").toInt();
|
||||
modifyTextNodeById(id, color, text, slowness);
|
||||
server.send(200, "text/plain", "OK");
|
||||
}
|
||||
else
|
||||
{
|
||||
server.send(400, "text/plain", "Invalid arguments for /modify-text");
|
||||
}
|
||||
} void handleGetNodes()
|
||||
{
|
||||
StaticJsonDocument<2048> jsonDoc;
|
||||
JsonArray nodes = jsonDoc.to<JsonArray>();
|
||||
|
||||
for (int i = 0; i < MAX_TEXT_NODES_COUNT; i++)
|
||||
{
|
||||
if (text_nodes[i].disappear_time != 0)
|
||||
{
|
||||
JsonObject node = nodes.createNestedObject();
|
||||
node["id"] = text_nodes[i].id; node["text"] = text_nodes[i].content;
|
||||
node["color"] = text_nodes[i].color;
|
||||
node["x"] = text_nodes[i].pos_x;
|
||||
node["y"] = text_nodes[i].pos_y;
|
||||
node["slowness"] = text_nodes[i].scroll_slowness;
|
||||
node["is_repeating"] = text_nodes[i].is_repeating;
|
||||
node["type"] = "text";
|
||||
node["slowness"] = text_nodes[i].scroll_slowness;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < MAX_TEXT_NODES_COUNT; i++)
|
||||
{
|
||||
if (multi_color_text_node[i].disappear_time != 0)
|
||||
{
|
||||
JsonObject node = nodes.createNestedObject();
|
||||
node["id"] = multi_color_text_node[i].id; node["text"] = multi_color_text_node[i].content;
|
||||
JsonArray colors = node.createNestedArray("colors");
|
||||
for(int j = 0; j < multi_color_text_node[i].color_count; j++)
|
||||
{
|
||||
JsonObject color = colors.createNestedObject();
|
||||
color["r"] = multi_color_text_node[i].colors[j].r;
|
||||
color["g"] = multi_color_text_node[i].colors[j].g;
|
||||
color["b"] = multi_color_text_node[i].colors[j].b;
|
||||
}
|
||||
node["x"] = multi_color_text_node[i].pos_x;
|
||||
node["y"] = multi_color_text_node[i].pos_y;
|
||||
node["slowness"] = multi_color_text_node[i].scroll_slowness;
|
||||
node["is_repeating"] = multi_color_text_node[i].is_repeating;
|
||||
node["type"] = "multi-color";
|
||||
node["slowness"] = multi_color_text_node[i].scroll_slowness;
|
||||
}
|
||||
}
|
||||
String jsonString;
|
||||
serializeJson(jsonDoc, jsonString);
|
||||
server.send(200, "application/json", jsonString);
|
||||
}
|
||||
|
||||
void start_server()
|
||||
{
|
||||
WiFi.begin(ssid, password);
|
||||
while (WiFi.status() != WL_CONNECTED) {
|
||||
delay(1000);
|
||||
Serial.println("Connecting to WiFi...");
|
||||
}
|
||||
@@ -233,7 +295,9 @@ void start_server()
|
||||
Serial.println(WiFi.localIP());
|
||||
|
||||
server.on("/", handleRoot);
|
||||
server.on("/nodes", HTTP_GET, handleGetNodes);
|
||||
server.on("/text", HTTP_POST, handleText);
|
||||
server.on("/modify-text", HTTP_POST, handleModifyText);
|
||||
server.on("/multicolor-text", HTTP_POST, handleMulticolorText);
|
||||
server.on("/brightness", HTTP_POST, handleBrightness);
|
||||
server.on("/upload-page", HTTP_GET, handleUploadPage);
|
||||
|
||||
Reference in New Issue
Block a user