wow images
This commit is contained in:
@@ -28,6 +28,12 @@ const char index_html[] PROGMEM = R"rawliteral(
|
||||
<button class="button" onclick="showSavedPixels()">Show Saved Pixels</button>
|
||||
<button class="button" onclick="location.href='/upload-page'">Upload Image</button>
|
||||
<br>
|
||||
<div>
|
||||
<label for="brightness">Brightness: </label>
|
||||
<input type="range" id="brightness" min="0" max="100" value="100" onchange="updateBrightness()">
|
||||
<span id="brightnessValue">100</span>
|
||||
</div>
|
||||
<br>
|
||||
<textarea id="jsonInput" placeholder="Paste your JSON image data here..."></textarea>
|
||||
<br>
|
||||
<button class="button" onclick="uploadAndDraw()">Upload and Draw</button>
|
||||
@@ -46,6 +52,15 @@ const char index_html[] PROGMEM = R"rawliteral(
|
||||
xhr.setRequestHeader("Content-Type", "application/json");
|
||||
xhr.send(jsonData);
|
||||
}
|
||||
|
||||
function updateBrightness() {
|
||||
var brightness = document.getElementById("brightness").value;
|
||||
document.getElementById("brightnessValue").innerText = brightness;
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("POST", "/brightness", true);
|
||||
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||
xhr.send("value=" + brightness);
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -133,13 +133,13 @@ void scrollAllScrollableTexts(bool split_scroll_mode = false)
|
||||
}
|
||||
}
|
||||
|
||||
void drawImageFromMemoryByIndex(unsigned char image_index, short pos_x, short pos_y, unsigned char dim_percentage = 0)
|
||||
void drawImageFromMemoryByIndex(unsigned char image_index, short pos_x, short pos_y, unsigned char brightness)
|
||||
{
|
||||
Image* img = &saved_images[image_index];
|
||||
|
||||
auto dimBy = [dim_percentage](unsigned char color)
|
||||
auto dimBy = [brightness](unsigned char color)
|
||||
{
|
||||
return color * (100 - dim_percentage) / 100;
|
||||
return color * brightness / 100;
|
||||
};
|
||||
|
||||
for (unsigned char y = 0; y < img->height; y++)
|
||||
@@ -173,7 +173,7 @@ void loop()
|
||||
|
||||
if (saved_images[0].width > 0)
|
||||
{
|
||||
drawImageFromMemoryByIndex(0, 0, 0);
|
||||
drawImageFromMemoryByIndex(0, 0, 0, brightness);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
+2
-1
@@ -9,9 +9,10 @@ extern Image saved_images[MAX_IMAGES_SAVED];
|
||||
extern unsigned char saved_images_count;
|
||||
extern TextNode text_nodes[MAX_TEXT_NODES_COUNT];
|
||||
extern Cursor cursor;
|
||||
extern unsigned char brightness;
|
||||
|
||||
|
||||
void drawImageFromMemoryByIndex(unsigned char image_index, short pos_x, short pos_y, unsigned char dim_percentage = 0);
|
||||
void drawImageFromMemoryByIndex(unsigned char image_index, short pos_x, short pos_y, unsigned char brightness = 100);
|
||||
void setPixel(short x, short y, uint32_t color);
|
||||
void start_server();
|
||||
void handle_server();
|
||||
|
||||
+10
-1
@@ -7,6 +7,7 @@
|
||||
|
||||
const char* ssid = "PPIA";
|
||||
const char* password = "pawelpdaldonejta";
|
||||
unsigned char brightness = 100;
|
||||
|
||||
WebServer server(80);
|
||||
|
||||
@@ -16,6 +17,13 @@ size_t fileContent_len = 0;
|
||||
String upload_error_message = "";
|
||||
|
||||
|
||||
void handleBrightness() {
|
||||
if (server.hasArg("value")) {
|
||||
brightness = server.arg("value").toInt();
|
||||
}
|
||||
server.send(200, "text/plain", "OK");
|
||||
}
|
||||
|
||||
void handleRoot()
|
||||
{
|
||||
server.send(200, "text/html", index_html);
|
||||
@@ -91,7 +99,7 @@ void handleBmpUpload() {
|
||||
void handleShowSaved()
|
||||
{
|
||||
pixels.clear();
|
||||
drawImageFromMemoryByIndex(0, 0, 0, 100);
|
||||
drawImageFromMemoryByIndex(0, 0, 0, brightness);
|
||||
pixels.show();
|
||||
server.send(200, "text/plain", "OK");
|
||||
}
|
||||
@@ -108,6 +116,7 @@ void start_server()
|
||||
Serial.println(WiFi.localIP());
|
||||
|
||||
server.on("/", handleRoot);
|
||||
server.on("/brightness", HTTP_POST, handleBrightness);
|
||||
server.on("/show-saved", handleShowSaved);
|
||||
server.on("/upload-page", HTTP_GET, handleUploadPage);
|
||||
server.on("/upload-bmp", HTTP_POST, []() {
|
||||
|
||||
Reference in New Issue
Block a user