src.nth.io/

summaryrefslogtreecommitdiff
path: root/main/state_machine.h
diff options
context:
space:
mode:
Diffstat (limited to 'main/state_machine.h')
-rw-r--r--main/state_machine.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/main/state_machine.h b/main/state_machine.h
new file mode 100644
index 0000000..176b93e
--- /dev/null
+++ b/main/state_machine.h
@@ -0,0 +1,20 @@
+#pragma once
+
+#include "esp_err.h"
+#include "viewport_state.h"
+
+esp_err_t state_machine_init(void);
+
+// Transition to AWAKE or ASLEEP. Idempotent: no-op if already there.
+// Returns ESP_ERR_INVALID_STATE if the device is unconfigured.
+// Side-effects (under one critical section):
+// AWAKE -> backlight on, idle timer (re)armed
+// ASLEEP -> backlight off, idle timer cancelled, framebuffer discarded
+esp_err_t state_machine_set(viewport_run_state_t target);
+
+// Called by /frame after a successful paint. Restarts the idle timer
+// while awake; no-op otherwise.
+void state_machine_frame_painted(void);
+
+// Snapshot of current state.
+viewport_run_state_t state_machine_current(void);