From f4349b5d61df3b30105bdac98efbb8f9a17051ae Mon Sep 17 00:00:00 2001 From: uvok Date: Tue, 15 Jul 2025 18:42:03 +0200 Subject: Add cheetah image, s/ArduinoOTA/WebServer firewall problems... --- src/main.cpp | 64 ++++++++++++++++++++++++++++++++++++------------------------ 1 file changed, 39 insertions(+), 25 deletions(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index 83321a5..cd0739c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5,11 +5,13 @@ #include #include #include -#include +#include #include #include -#include +// #include +#include +#include #include "badge_config.h" @@ -40,6 +42,9 @@ unsigned long releasedTime = 0; #define SLEEP_TIME 10000 NimBLEAdvertising *pAdvertising; +WebServer httpServer(80); +HTTPUpdateServer httpUpdater; + void display_helloWorld(); void setup() @@ -68,7 +73,11 @@ void setup() WiFi.begin(BADGE_SSID_NAME, BADGE_SSID_PASS); while (WiFi.status() != WL_CONNECTED) delay(500); - ArduinoOTA.begin(); + Serial.printf("> My IP is %s\n", WiFi.localIP().toString()); + + httpUpdater.setup(&httpServer); + httpServer.begin(); + #endif // doesn't work as expected? @@ -80,10 +89,10 @@ void setup() void loop() { #if BADGE_USE_WIFI - ArduinoOTA.handle(); + httpServer.handleClient(); #endif -static int lastState = HIGH; + static int lastState = HIGH; int buttonState = digitalRead(BUTTON_PIN); if (lastState == HIGH && buttonState == LOW) { @@ -112,25 +121,30 @@ static int lastState = HIGH; }; } +#include "chee.c" + void display_helloWorld() { - // display.clearScreen(); - static const char HelloWorld[] = "Hello World!"; - display.setRotation(1); - display.setFont(&FreeMonoBold24pt7b); - display.setTextColor(GxEPD_BLACK); - int16_t tbx, tby; - uint16_t tbw, tbh; - display.getTextBounds(HelloWorld, 0, 0, &tbx, &tby, &tbw, &tbh); - // center the bounding box by transposition of the origin: - uint16_t x = ((display.width() - tbw) / 2) - tbx; - uint16_t y = ((display.height() - tbh) / 2) - tby; - display.setFullWindow(); - display.firstPage(); - do - { - display.fillScreen(GxEPD_YELLOW); - display.setCursor(x, y); - display.print(HelloWorld); - } while (display.nextPage()); -} \ No newline at end of file + // display.clearScreen(); + static const char s_hungry[] = "hungry"; + display.setRotation(1); + display.setTextColor(GxEPD_BLACK); + int16_t tbx, tby; + uint16_t tbw, tbh; + display.setFont(&FreeMonoBold9pt7b); + display.getTextBounds(s_hungry, 0, 0, &tbx, &tby, &tbw, &tbh); + // center the bounding box by transposition of the origin: + uint16_t x = ((display.width() - tbw) / 2) - tbx; + uint16_t y = ((display.height() - tbh) / 2) - tby; + display.setFullWindow(); + display.firstPage(); + do + { + display.drawXBitmap(0, 0, chee_bits, chee_width, chee_height, GxEPD_BLACK); + display.getTextBounds(s_hungry, x, y, &tbx, &tby, &tbw, &tbh); + display.fillRect(tbx, tby, tbw, tbh, GxEPD_WHITE); + + display.setCursor(x, y); + display.print(s_hungry); + } while (display.nextPage()); +} -- cgit v1.2.3