50 lines
1.5 KiB
C
50 lines
1.5 KiB
C
#ifndef UI_MANAGER_H
|
|
#define UI_MANAGER_H
|
|
|
|
#include <stdbool.h>
|
|
#include <stdint.h>
|
|
|
|
#include "ha_data.h"
|
|
#include "lvgl.h"
|
|
|
|
/*
|
|
* The screen layout.
|
|
*
|
|
* This file is compiled into the desktop simulator as well as the firmware
|
|
* (see sim/README.md), so it must never touch a driver, a socket or ESP-IDF
|
|
* directly. Data arrives as ha_data_t; commands leave through the callback
|
|
* below. Everything in between is drawing.
|
|
*/
|
|
|
|
void ui_init(void);
|
|
|
|
/* Safe to call from any task -- these take the LVGL lock internally. */
|
|
|
|
/* Redraw every panel from `data`. Cheap to call when nothing changed: every
|
|
* label goes through a comparison first, so an unchanged value costs no
|
|
* invalidation and therefore no flush. */
|
|
void ui_update(const ha_data_t *data);
|
|
|
|
void ui_set_status(const char *status);
|
|
|
|
/*
|
|
* Mark the displayed readings as no longer trustworthy. Dims the temperature
|
|
* so a value that stopped updating is visibly distinct from a live one,
|
|
* rather than sitting there at full styling looking current.
|
|
*/
|
|
void ui_set_stale(bool stale);
|
|
|
|
/*
|
|
* Called when the user operates a light tile.
|
|
*
|
|
* `index` indexes HA_LIGHTS. `brightness` is 0-255, or -1 for a plain on/off
|
|
* with no brightness change (a tile tap, or any switch-domain entity).
|
|
*
|
|
* Runs on the LVGL task with the LVGL lock held, so the implementation must
|
|
* not block: hand the command to another task rather than doing HTTP here.
|
|
*/
|
|
typedef void (*ui_light_cmd_cb_t)(int index, bool on, int16_t brightness);
|
|
void ui_set_light_cb(ui_light_cmd_cb_t cb);
|
|
|
|
#endif
|