summaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authoruvok2025-07-15 18:42:03 +0200
committeruvok2025-07-15 18:42:03 +0200
commitf4349b5d61df3b30105bdac98efbb8f9a17051ae (patch)
treea25e8fb9eb1648caa83d31d8cd8b860b5f878418 /src/main.cpp
parent66ecb693177f3a209a0ddd7c7629c5ed9e4f673f (diff)
Add cheetah image, s/ArduinoOTA/WebServer
firewall problems...
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp64
1 files changed, 39 insertions, 25 deletions
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 <GxEPD2_BW.h>
#include <GxEPD2_3C.h>
#include <Fonts/FreeMonoBold9pt7b.h>
-#include <Fonts/FreeMonoBold24pt7b.h>
+#include <Fonts/FreeMonoBold18pt7b.h>
#include <NimBLEDevice.h>
#include <WiFi.h>
-#include <ArduinoOTA.h>
+// #include <ArduinoOTA.h>
+#include <WebServer.h>
+#include <HTTPUpdateServer.h>
#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());
+}