From 7cd4a913502e47cdef6e1c2ed539198a7aa2be12 Mon Sep 17 00:00:00 2001 From: jimmy Date: Sun, 8 Feb 2026 13:51:15 +1300 Subject: [PATCH] Add favicon handler and heartbeat LED blink. This keeps the UI console clean and makes device status visible. Co-authored-by: Cursor --- src/main.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/main.py b/src/main.py index f3d60b7..9c478f0 100644 --- a/src/main.py +++ b/src/main.py @@ -2,6 +2,7 @@ import asyncio import gc import json import machine +from machine import Pin from microdot import Microdot, send_file from microdot.websocket import with_websocket from microdot.session import Session @@ -23,6 +24,7 @@ from models.espnow import ESPNow async def main(port=80): settings = Settings() + print(settings) print("Starting") sta = network.WLAN(network.STA_IF) @@ -72,6 +74,11 @@ async def main(port=80): """Serve the settings page.""" return send_file('templates/settings.html') + # Favicon: avoid 404 in browser console (no file needed) + @app.route('/favicon.ico') + def favicon(request): + return '', 204 + # Static file route @app.route("/static/") def static_handler(request, path): @@ -107,10 +114,20 @@ async def main(port=80): #wdt = machine.WDT(timeout=10000) #wdt.feed() + # Initialize heartbeat LED (XIAO ESP32S3 built-in LED on GPIO 21) + + led = Pin(21, Pin.OUT) + + + led_state = False + while True: gc.collect() for i in range(60): #wdt.feed() + # Heartbeat: toggle LED every 500 ms + + led.value(not led.value()) await asyncio.sleep_ms(500) # cleanup before ending the application