This commit is contained in:
2026-02-05 14:40:45 +01:00
parent 84a047f67b
commit 88bf1e3bb2
9 changed files with 305 additions and 125 deletions
+26 -7
View File
@@ -96,14 +96,33 @@ void handleBmpUpload() {
void handleShowSaved()
{
pixels.clear();
drawImageFromMemoryByIndex(0, 0, 0, brightness);
pixels.show();
server.send(200, "text/plain", "OK");
void handleText() {
if (server.hasArg("text") && server.hasArg("color") && server.hasArg("position") && server.hasArg("slowness")) {
String text_str = server.arg("text");
String colorStr = server.arg("color");
String position = server.arg("position");
unsigned char slowness = server.arg("slowness").toInt();
char text[TEXT_MAX_LENGTH + 1];
text_str.toCharArray(text, TEXT_MAX_LENGTH + 1);
uint32_t color = strtol(colorStr.substring(1).c_str(), NULL, 16);
if (position == "top") {
addNewTextNode(text, color, false, 43, 0, slowness, true, false);
} else if (position == "bottom") {
addNewTextNode(text, color, false, -text_str.length() * 6, 9, slowness, true, false);
}
server.send(200, "text/plain", "OK");
} else {
server.send(400, "text/plain", "Invalid arguments");
}
}
void start_server()
{
WiFi.begin(ssid, password);
@@ -116,8 +135,8 @@ void start_server()
Serial.println(WiFi.localIP());
server.on("/", handleRoot);
server.on("/text", HTTP_POST, handleText);
server.on("/brightness", HTTP_POST, handleBrightness);
server.on("/show-saved", handleShowSaved);
server.on("/upload-page", HTTP_GET, handleUploadPage);
server.on("/upload-bmp", HTTP_POST, []() {
if (upload_error_message.length() > 0) {