src.nth.io/

summaryrefslogtreecommitdiff
path: root/main/state_machine.h
blob: 176b93ef6869ff0a543d7d78a7f6efc84ca2aa9e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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);