Skip to content

Commit 6acbe5c

Browse files
committed
chmod -x
1 parent 20fbeda commit 6acbe5c

File tree

5 files changed

+35
-1
lines changed

5 files changed

+35
-1
lines changed

src/main/config.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ constexpr int SCREEN_UPDATE_TIME = 1000; // Time to wait before
3232
constexpr int SCREEN_STARTUP_DISPLAY_TIME = 3000; // Startup screen delay time (ms)
3333
bool SHOW_STARTUP = true; // Set to true to show the startup sequence
3434
bool SHOW_BITMAP = true; // Set to true to show the bitmap
35+
constexpr char BITMAP_URL[] = "https://connerwill.com/static/bitmaps/esp32-bitmap-128x64.bmp"; // URL to online bitmap image
3536
bool SHOW_IP_INFO = true; // Set to true to show IP information
3637
constexpr char STARTUP_TEXT[] = ":)"; // Startup custom text
3738
bool INTERRUPT_WITH_BITMAP = true; // Periodically show bitmap

src/main/main.ino

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
#include "ESPAsyncWebServer.h"
1010
#include "DHTesp.h"
1111
#include <ArduinoJson.h>
12+
#include <WiFiClientSecure.h>
13+
#include <HTTPClient.h>
1214
#include <Wire.h>
1315
#include <Adafruit_GFX.h>
1416
#include <Adafruit_SSD1306.h>
@@ -27,6 +29,9 @@ KASAUtil kasaUtil; // Kasa utilit
2729
KASASmartPlug *intakePlug = NULL; // Smart plug pointers (Intake)
2830
KASASmartPlug *exhaustPlug = NULL; // Smart plug pointers (Exhaust)
2931
KASASmartPlug *humidifierPlug = NULL; // Smart plug pointers (Humidifier)
32+
WiFiClientSecure client; // Secure WiFi client
33+
HTTPClient http; // HTTP client
34+
uint8_t bitmap_data[1024]; // Buffer for the image data
3035
// ============================================================================
3136

3237
// ============================================================================
@@ -332,10 +337,38 @@ void showStart() {
332337
display.clearDisplay();
333338
}
334339

340+
// Function to fetchBitmap from server
341+
bool fetchBitmap() {
342+
client.setInsecure(); // Disables SSL certificate verification (Not secure for production)
343+
http.begin(client, image_url);
344+
int httpCode = http.GET();
345+
if (httpCode == HTTP_CODE_OK) {
346+
WiFiClient* stream = http.getStreamPtr();
347+
int index = 0;
348+
while (http.connected() && stream->available() && index < sizeof(bitmap_online_data)) {
349+
bitmap_online_data[index++] = stream->read();
350+
}
351+
352+
http.end();
353+
Serial.println("Image downloaded successfully!");
354+
return true;
355+
} else {
356+
Serial.printf("Failed to fetch image. HTTP Code: %d\n", httpCode);
357+
return false;
358+
}
359+
}
360+
361+
362+
335363
// Function to show bitmap image
336364
void showBitmap() {
337365
display.clearDisplay();
338-
display.drawBitmap(0, 0, bitmap_image, SCREEN_WIDTH, SCREEN_HEIGHT, SSD1306_WHITE);
366+
if (fetchBitmap()) {
367+
display.drawBitmap(0, 0, bitmap_online_data, SCREEN_WIDTH, SCREEN_HEIGHT, SSD1306_WHITE);
368+
369+
} else {
370+
display.drawBitmap(0, 0, bitmap_image, SCREEN_WIDTH, SCREEN_HEIGHT, SSD1306_WHITE);
371+
}
339372
display.display();
340373
delay(SCREEN_STARTUP_DISPLAY_TIME);
341374

static/img/esp32-wiring.jpeg

100755100644
File mode changed.

static/img/gen4-transparent.bmp

1.06 KB
Binary file not shown.

static/img/gen4-transparent.png

1.51 MB
Loading

0 commit comments

Comments
 (0)