Files
lisael-box/main/ui/ui.h
T
L'électron rare 076678fb45 feat(games): tilt-maze game with IMU
New "Labyrinthe" game: guide a ball to the star by tilting the
box, read from the on-board ICM42670 accelerometer (BSP I2C bus,
added to REQUIRES). A perfect maze is carved by iterative
backtracking on a 12x8 grid, so there is one path with branches
and dead ends; only a 6x4 window is shown and the view scrolls to
follow the ball. The whole world is drawn into a single RGB565
PSRAM canvas (not one object per wall) and scrolled — layer-free,
keeps the render task light. The ball bounces off walls and edges
with speed-proportional restitution. Tilt axes calibrated on the
real board. Wired as the 5th tile in the games carousel; reuses
the festive bravo on win.
2026-06-21 15:04:06 +02:00

70 lines
3.0 KiB
C

// LVGL UI shell + mode router for Lisael Box.
//
// The UI runs entirely on the LVGL task created by the esp-box BSP
// (bsp_display_start / esp_lvgl_port). ALL LVGL calls from other tasks (e.g.
// the weather task pushing an update) MUST be wrapped in
// bsp_display_lock()/bsp_display_unlock(). Helpers here assume they are called
// while holding that lock unless noted otherwise.
#pragma once
#include "lvgl.h"
#ifdef __cplusplus
extern "C" {
#endif
// The available screens / modes.
typedef enum {
LISAEL_MODE_HOME = 0, // accueil: date FR + meteo + capteurs + tuiles
LISAEL_MODE_RADIO, // webradios enfants
LISAEL_MODE_CALM, // coin calme / respiration
LISAEL_MODE_CLOCK, // horloge / veilleuse
LISAEL_MODE_GAMES, // jeux (memory, compter)
LISAEL_MODE_HISTOIRES, // podcasts Radio France jeunesse (Oli, Bestioles)
LISAEL_MODE_LIRE, // jeu apprendre à lire (mot <-> image + voix)
LISAEL_MODE_WIFI, // réglages WiFi (force le SoftAP + portail captif)
LISAEL_MODE_ROUTINE, // routine illustrée à étapes (matin / soir)
LISAEL_MODE_COUNT,
} lisael_mode_t;
// Build the UI (call once, while holding the display lock). Loads HOME.
void lisael_ui_init(void);
// Switch to a mode. Each mode lazily (re-)builds its screen and is loaded with
// a gentle slide animation. Safe to call from LVGL callbacks.
void lisael_ui_goto(lisael_mode_t mode);
// Convenience used by every mode screen to add a top-left "← Accueil" button
// (big, icon-only) that returns HOME. Returns the button object.
lv_obj_t *lisael_ui_add_back_button(lv_obj_t *parent);
// Shared style accessors (lazily initialised). Big rounded buttons, soft
// pastel palette suited to a young child.
const lv_style_t *lisael_ui_style_tile(void); // home menu tiles
const lv_style_t *lisael_ui_style_button(void); // generic big buttons
// --- Each mode exposes a builder that returns its root screen object. --------
// (Implemented in modes/*.c.)
lv_obj_t *lisael_screen_home(void);
lv_obj_t *lisael_screen_radio(void);
lv_obj_t *lisael_screen_calm(void);
lv_obj_t *lisael_screen_clock(void);
lv_obj_t *lisael_screen_games(void);
lv_obj_t *lisael_screen_balloons(void); // "Calme ta colère" anger game
lv_obj_t *lisael_screen_maze(void); // "Labyrinthe" — tilt-maze (IMU)
lv_obj_t *lisael_screen_histoires(void); // "Histoires" — vignette podcasts
lv_obj_t *lisael_screen_wifi_setup(void); // SoftAP provisioning info screen
lv_obj_t *lisael_screen_lire(void); // "Lire" learn-to-read game
lv_obj_t *lisael_screen_wifi(void); // on-demand WiFi settings (force AP)
lv_obj_t *lisael_screen_routine(void); // "Routine" — étapes illustrées matin/soir
// Home screen live-update hooks (called from background tasks; they take the
// display lock internally — do NOT hold it when calling these).
void lisael_home_update_clock(void); // refresh date/time labels
void lisael_home_update_weather(void); // pull latest weather snapshot
void lisael_home_update_sensors(void); // pull latest sensor readings
#ifdef __cplusplus
}
#endif