Files
t-embed-insecam-widget/main/ui.h
T
Juli f238cfc9bf Battery/USB readout and wrap-around menu scrolling
BAT_ADC (GPIO4) sits between two 100k resistors on the switched supply
rail, so it reads the cell on battery and ~4.4 V on USB; above 4.25 V is
reported as USB power. On battery the caption shows a glyph + percentage
from a LiPo OCV table; the menu shows voltage and source. Menu lists now
wrap at both ends.
2026-09-17 01:28:59 +02:00

39 lines
1.5 KiB
C

#pragma once
#include <stdbool.h>
#include <stdint.h>
// All calls take the LVGL lock themselves; safe from any task.
void ui_init(void);
// Full-screen text page (boot, Wi-Fi setup, fatal errors).
void ui_status(const char *title, const char *msg);
// Switch to the camera page.
void ui_show_camera_page(void);
// Hand a freshly decoded 320x170 RGB565 frame to the canvas. The buffer stays
// owned by the caller and must not be written until the next swap.
void ui_present_frame(uint16_t *rgb565);
void ui_set_caption(const char *place, const char *meta);
// Badge in the top-right corner: "LIVE", "PAUSED", "..." — NULL hides it.
void ui_set_badge(const char *text, uint32_t rgb);
// 0..1000 countdown bar; <0 hides the bar.
void ui_set_progress(int permille);
void ui_toast(const char *msg, uint32_t ms);
void ui_set_overlay_visible(bool visible);
bool ui_overlay_visible(void);
// Small marker in the top-left corner of the camera page ("FAV 3"); NULL hides it.
void ui_set_marker(const char *text);
// Battery readout at the right end of the caption bar; NULL hides it.
void ui_set_battery(const char *text);
// --- menu page ---
#define UI_MENU_ROWS 6
typedef struct {
const char *label;
const char *value; // right-aligned; may be NULL
bool dim; // informational row, drawn greyed
} ui_menu_row_t;
// Draws rows[top .. top+UI_MENU_ROWS) with `selected` highlighted; `editing` recolours the value.
void ui_menu_show(const char *title, const ui_menu_row_t *rows, int count, int top, int selected, bool editing);
void ui_menu_hide(void);