diff options
Diffstat (limited to 'main/viewport_state.h')
| -rw-r--r-- | main/viewport_state.h | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/main/viewport_state.h b/main/viewport_state.h new file mode 100644 index 0000000..b580ff7 --- /dev/null +++ b/main/viewport_state.h @@ -0,0 +1,49 @@ +#pragma once + +#include <stdbool.h> +#include <stdint.h> + +#define VIEWPORT_VERSION "0.1.0" +#define VIEWPORT_PANEL_WIDTH 800 +#define VIEWPORT_PANEL_HEIGHT 480 + +typedef enum { + VIEWPORT_ORIENTATION_PORTRAIT = 0, // effective: 480x800 + VIEWPORT_ORIENTATION_LANDSCAPE, // effective: 800x480 +} viewport_orientation_t; + +typedef enum { + VIEWPORT_STATE_UNCONFIGURED = 0, + VIEWPORT_STATE_AWAKE, + VIEWPORT_STATE_ASLEEP, +} viewport_run_state_t; + +// Read-mostly snapshot of device state used by /state. Counters are +// updated under a mutex by the modules that own them. +typedef struct { + char viewport_name[64]; // empty before /config + char scrypted_url[256]; // empty before /config + bool configured; + viewport_run_state_t state; + + uint8_t brightness; // 0–100, default 80 + uint32_t idle_timeout_ms; // 0 = disabled, else >= 5000, default 60000 + viewport_orientation_t orientation; // default portrait + + uint64_t boot_us; // esp_timer_get_time() at boot + int64_t last_frame_us; // -1 if no frame received yet + + uint64_t frames_received; + uint64_t decode_errors; + uint64_t state_post_failures; +} viewport_state_t; + +void viewport_state_init(void); +viewport_state_t *viewport_state_get(void); +void viewport_state_lock(void); +void viewport_state_unlock(void); + +// Returns the effective resolution string ("480x800" or "800x480") based +// on the current orientation. Caller-owned static storage; safe to read +// without the lock (atomic snapshot). +const char *viewport_state_resolution_str(void); |
