src.nth.io/

summaryrefslogtreecommitdiff
path: root/main/app_main.c
diff options
context:
space:
mode:
authorLuke Hoersten <[email protected]>2026-06-13 23:15:27 -0500
committerLuke Hoersten <[email protected]>2026-06-13 23:15:27 -0500
commitfdb8a1299eafdedf68902c4c785f9fb0390e80c4 (patch)
treef15376e132de8feef61023a511f0a313943a0fd7 /main/app_main.c
parent1d6cbb222ced226fcb482c0b19130774d181c8f8 (diff)
M8: local screens (IP + Loading) + BOOT button
local_screens.{h,c}: - Embedded 8x8 bitmap font sized to a 95-char table; only the glyphs used by today's strings (viewport.local, the IPv4 string, Loading...) are populated. Unsupported chars render blank. - 768 KB PSRAM scratch FB at panel-native dims. - local_screens_show_ip() — two centered lines: "viewport.local" <current IP> Scale 3x portrait / 4x landscape; centered vertically. - local_screens_show_loading() — centered "Loading..." at scale 4x/5x. - local_screens_restore_for_state() — repaint after BOOT-overlay expiry: UNCONFIGURED -> IP screen; AWAKE/ASLEEP -> black FB (next /frame or sleep handles the rest). - All paths go through display_present_rgb565() so orientation rotation is automatic. button.{h,c}: - Polling task at 30ms, active-low with internal pull-up. - Short press (<5s, released) → backlight on, IP overlay for 15s via esp_timer one-shot, then restore. - Hold ≥ 5s → nvs_config_reset() + esp_restart(). - PIN_BOOT_BUTTON = GPIO 0 is a TODO placeholder. ESP32-P4 strap pin GPIO35 is owned by RMII TXD1 at runtime so Waveshare must expose a separate user button on a free pin; confirm against the schematic. Fail-soft if mis-wired: input reads stuck-high and the task never fires. state_machine on AWAKE transition now calls local_screens_show_loading() right after display_wake() — so every wake (tap or POST /state) flashes a clear "Loading..." until the next /frame paints over it. app_main on boot: - Calls local_screens_init() after display_init(). - UNCONFIGURED → paint IP screen (replaces the M3 test pattern). - ASLEEP → backlight off (unchanged). - After all subsystems: button_init(). Build clean against ESP-IDF 5.4 (binary ~870 KB; the font/glyph data is under 800 bytes). TESTING.md M8 documents the visual checks, the BOOT-pin placeholder caveat, the AWAKE-overlay-overwrite behavior, the open follow-up about post-overlay backlight when ASLEEP, and the font fallback policy.
Diffstat (limited to 'main/app_main.c')
-rw-r--r--main/app_main.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/main/app_main.c b/main/app_main.c
index e7bff0a..4f7a949 100644
--- a/main/app_main.c
+++ b/main/app_main.c
@@ -1,6 +1,8 @@
+#include "button.h"
#include "display.h"
#include "http_api.h"
#include "jpeg_decoder.h"
+#include "local_screens.h"
#include "mdns_service.h"
#include "net_eth.h"
#include "nvs_config.h"
@@ -41,10 +43,12 @@ void app_main(void)
// Display is best-effort — a missing/miswired panel must not kill
// networking + /state.
if (display_init() == ESP_OK) {
+ local_screens_init();
+
// Reconcile panel with current run-state:
- // UNCONFIGURED -> placeholder test pattern (M8 replaces with IP screen)
+ // UNCONFIGURED -> IP screen (so operator can register from Scrypted)
// ASLEEP -> backlight off (configured device booted asleep)
- // AWAKE -> leave on (shouldn't happen on a fresh boot)
+ // AWAKE -> leave on (not reached on fresh boot)
viewport_state_lock();
viewport_run_state_t s = viewport_state_get()->state;
viewport_state_unlock();
@@ -53,8 +57,8 @@ void app_main(void)
display_sleep();
ESP_LOGI(TAG, "display up — configured, backlight off (asleep)");
} else {
- display_test_pattern();
- ESP_LOGI(TAG, "display up — test pattern (unconfigured)");
+ local_screens_show_ip();
+ ESP_LOGI(TAG, "display up — IP screen (unconfigured)");
}
} else {
ESP_LOGW(TAG, "display init failed — continuing without panel");
@@ -72,5 +76,9 @@ void app_main(void)
}
}
- // TODO M8: Local screens (IP, loading) + BOOT button
+ // BOOT button — short press = IP overlay, hold 5s = factory reset.
+ // GPIO is a guess until confirmed against the Waveshare schematic.
+ if (button_init() != ESP_OK) {
+ ESP_LOGW(TAG, "BOOT button init failed — overlay + factory reset disabled");
+ }
}