fixed characters drawing orientation and array handling
This commit is contained in:
+28
-3
@@ -1,8 +1,21 @@
|
||||
#include <WiFi.h>
|
||||
#include <WebServer.h>
|
||||
#include <ArduinoJson.h>
|
||||
|
||||
const char* ssid = "PPIA";
|
||||
const char* password = "pawelpdaldonejta";
|
||||
|
||||
WebServer server(80);
|
||||
|
||||
// Declare the new_image buffer to temporarily store uploaded image
|
||||
struct Pixel {
|
||||
unsigned short x;
|
||||
unsigned short y;
|
||||
uint32_t color;
|
||||
};
|
||||
|
||||
Pixel new_image[16][16];
|
||||
|
||||
void handleRoot() {
|
||||
server.send(200, "text/html", index_html);
|
||||
}
|
||||
@@ -20,15 +33,27 @@ void handleUpload() {
|
||||
for (JsonVariant val : arr) {
|
||||
int col = 0;
|
||||
for (JsonVariant val2 : val.as<JsonArray>()) {
|
||||
long color = strtol(val2.as<const char*>(), NULL, 16);
|
||||
unsigned long color = strtoul(val2.as<const char*>(), NULL, 16);
|
||||
new_image[row][col] = { (unsigned short)col, (unsigned short)row, (uint32_t)color };
|
||||
col++;
|
||||
}
|
||||
row++;
|
||||
}
|
||||
|
||||
// Save the new image to the next slot
|
||||
if (saved_images_count < 11) { // Ensure we don't overflow (max index is 11)
|
||||
saved_images_count++;
|
||||
}
|
||||
|
||||
// Copy new_image data to saved_imaged array
|
||||
for (int r = 0; r < 16; r++) {
|
||||
for (int c = 0; c < 16; c++) {
|
||||
saved_imaged[saved_images_count][r][c] = new_image[r][c].color;
|
||||
}
|
||||
}
|
||||
|
||||
pixels.clear();
|
||||
drawImageFromArr(0, 0);
|
||||
drawImageFromSaved(0, 0, saved_images_count);
|
||||
pixels.show();
|
||||
server.send(200, "text/plain", "OK");
|
||||
}
|
||||
@@ -57,4 +82,4 @@ void start_server() {
|
||||
|
||||
void handle_server() {
|
||||
server.handleClient();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user