src.nth.io/

summaryrefslogtreecommitdiff
path: root/main/app_main.c
diff options
context:
space:
mode:
Diffstat (limited to 'main/app_main.c')
-rw-r--r--main/app_main.c27
1 files changed, 20 insertions, 7 deletions
diff --git a/main/app_main.c b/main/app_main.c
index 4ac925d..126bf15 100644
--- a/main/app_main.c
+++ b/main/app_main.c
@@ -4,6 +4,7 @@
#include "mdns_service.h"
#include "net_eth.h"
#include "nvs_config.h"
+#include "state_machine.h"
#include "viewport_state.h"
#include "esp_event.h"
@@ -30,25 +31,37 @@ void app_main(void)
ESP_LOGW(TAG, "no DHCP lease after 30s, will keep retrying in the background");
}
+ ESP_ERROR_CHECK(state_machine_init());
ESP_ERROR_CHECK(mdns_service_start());
ESP_ERROR_CHECK(http_api_start());
// Display is best-effort — a missing/miswired panel must not kill
- // networking + /state. M3 acceptance: show a test pattern.
+ // networking + /state.
if (display_init() == ESP_OK) {
- display_test_pattern();
- ESP_LOGI(TAG, "display up — test pattern on screen");
+ // Reconcile panel with current run-state:
+ // UNCONFIGURED -> placeholder test pattern (M8 replaces with IP screen)
+ // ASLEEP -> backlight off (configured device booted asleep)
+ // AWAKE -> leave on (shouldn't happen on a fresh boot)
+ viewport_state_lock();
+ viewport_run_state_t s = viewport_state_get()->state;
+ viewport_state_unlock();
+
+ if (s == VIEWPORT_STATE_ASLEEP) {
+ display_sleep();
+ ESP_LOGI(TAG, "display up — configured, backlight off (asleep)");
+ } else {
+ display_test_pattern();
+ ESP_LOGI(TAG, "display up — test pattern (unconfigured)");
+ }
} else {
ESP_LOGW(TAG, "display init failed — continuing without panel");
}
- // JPEG decoder is the M5 dependency for POST /frame. Best-effort:
- // if it fails (e.g. hardware not present in sim) /frame just returns 500.
+ // JPEG decoder is the M5 dependency for POST /frame. Best-effort.
if (jpeg_decoder_init() != ESP_OK) {
ESP_LOGW(TAG, "jpeg decoder init failed — /frame will be unavailable");
}
- // TODO M6: POST /state + idle timer
- // TODO M7: Capacitive touch -> outbound /state POST
+ // TODO M7: Capacitive touch -> outbound /state POST to <scrypted>/state
// TODO M8: Local screens (IP, loading) + BOOT button
}