images can be send but are not drawn correctly
This commit is contained in:
+31
-3
@@ -7,9 +7,36 @@ void handleRoot() {
|
||||
server.send(200, "text/html", index_html);
|
||||
}
|
||||
|
||||
void handleShow() {
|
||||
void handleUpload() {
|
||||
if (server.hasArg("plain") == false) {
|
||||
server.send(400, "text/plain", "body not received");
|
||||
return;
|
||||
}
|
||||
String body = server.arg("plain");
|
||||
DynamicJsonDocument doc(8192);
|
||||
deserializeJson(doc, body);
|
||||
JsonArray arr = doc.as<JsonArray>();
|
||||
int row = 0;
|
||||
for (JsonVariant val : arr) {
|
||||
int col = 0;
|
||||
for (JsonVariant val2 : val.as<JsonArray>()) {
|
||||
long color = strtol(val2.as<const char*>(), NULL, 16);
|
||||
new_image[row][col] = { (unsigned short)col, (unsigned short)row, (uint32_t)color };
|
||||
col++;
|
||||
}
|
||||
row++;
|
||||
}
|
||||
|
||||
pixels.clear();
|
||||
drawImageFromArr(0, 0);
|
||||
pixels.show();
|
||||
server.send(200, "text/plain", "OK");
|
||||
}
|
||||
|
||||
void handleShowSaved() {
|
||||
pixels.clear();
|
||||
drawImageFromSaved(0, 0, 0);
|
||||
pixels.show();
|
||||
drawImageFromArr(0, 0, 0);
|
||||
server.send(200, "text/plain", "OK");
|
||||
}
|
||||
|
||||
@@ -23,7 +50,8 @@ void start_server() {
|
||||
Serial.println(WiFi.localIP());
|
||||
|
||||
server.on("/", handleRoot);
|
||||
server.on("/show", handleShow);
|
||||
server.on("/show-saved", handleShowSaved);
|
||||
server.on("/upload", HTTP_POST, handleUpload);
|
||||
server.begin();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user