7#include "freertos/FreeRTOS.h"
8#include "freertos/task.h"
18static const char *
TAG =
"display_ui";
20#ifndef CONFIG_DISPLAY_UI_REFRESH_MS
21#define CONFIG_DISPLAY_UI_REFRESH_MS 1000
30 u8g2_SetFont(
s_u8g2, u8g2_font_6x10_tf);
31 u8g2_DrawStr(
s_u8g2, 0, 10,
"Provision WiFi");
33 u8g2_DrawStr(
s_u8g2, 0, 34,
"Password:");
35 u8g2_DrawStr(
s_u8g2, 0, 58,
"http://192.168.4.1");
42 int64_t now_epoch = 0;
45 char alarm_indicator[10];
47 static uint32_t alarm_blink_counter = 0;
55 u8g2_SetFont(
s_u8g2, u8g2_font_6x10_tf);
56 u8g2_DrawStr(
s_u8g2, 20, 10,
"ALARM ACTIVE!");
59 if ((alarm_blink_counter / 2) % 2 == 0) {
61 snprintf(time_line,
sizeof(time_line),
"%02d:%02d:%02d",
62 local_time.tm_hour, local_time.tm_min, local_time.tm_sec);
63 u8g2_SetFont(
s_u8g2, u8g2_font_logisoso20_tn);
64 u8g2_DrawStr(
s_u8g2, 0, 38, time_line);
68 alarm_blink_counter++;
73 alarm_blink_counter = 0;
78 snprintf(status_line,
sizeof(status_line),
"Setup AP");
80 snprintf(status_line,
sizeof(status_line),
"%s", snapshot->
runtime.
sta_ip);
82 snprintf(status_line,
sizeof(status_line),
"No WiFi");
85 alarm_indicator[0] =
'\0';
87 int first_h = -1, first_m = -1;
88 int enabled_count = 0;
101 if (enabled_count == 1) {
102 snprintf(alarm_indicator,
sizeof(alarm_indicator),
"%02d:%02d", first_h, first_m);
103 }
else if (enabled_count > 1) {
105 snprintf(alarm_indicator,
sizeof(alarm_indicator),
"%02d:%02d+", first_h, first_m);
109 u8g2_SetFont(
s_u8g2, u8g2_font_6x10_tf);
110 u8g2_DrawStr(
s_u8g2, 0, 10, status_line);
111 if (alarm_indicator[0] !=
'\0') {
112 u8g2_uint_t aw = u8g2_GetStrWidth(
s_u8g2, alarm_indicator);
113 u8g2_DrawStr(
s_u8g2, (u8g2_uint_t)(128u - aw), 10, alarm_indicator);
117 u8g2_DrawHLine(
s_u8g2, 0, 14, 128);
122 snprintf(time_line,
sizeof(time_line),
"%02d:%02d:%02d",
123 local_time.tm_hour, local_time.tm_min, local_time.tm_sec);
124 u8g2_SetFont(
s_u8g2, u8g2_font_logisoso24_tn);
125 u8g2_DrawStr(
s_u8g2, 10, 48, time_line);
127 snprintf(time_line,
sizeof(time_line),
"TIME NOT SET");
128 u8g2_SetFont(
s_u8g2, u8g2_font_6x10_tf);
129 u8g2_DrawStr(
s_u8g2, 28, 30, time_line);
159 ESP_LOGE(
TAG,
"Display init failed (%s)", esp_err_to_name(ret));
168 BaseType_t task_ok = xTaskCreate(
display_ui_task,
"display_ui", 4096, NULL, 4, NULL);
169 return (task_ok == pdPASS) ? ESP_OK : ESP_FAIL;
void app_state_get_snapshot(app_state_snapshot_t *snapshot)
Get a thread-safe snapshot of the full state.
Thread-safe application state and persisted configuration APIs.
#define APP_ALARM_MAX_COUNT
Maximum number of configurable alarms.
static void display_ui_task(void *arg)
static void display_ui_draw_portal_screen(const app_state_snapshot_t *snapshot)
static i2c_u8g2_handle_t s_display_handle
static void display_ui_draw_clock_screen(const app_state_snapshot_t *snapshot)
esp_err_t display_ui_start(void)
Initialize display backend and start the UI task.
#define CONFIG_DISPLAY_UI_REFRESH_MS
OLED display UI service API.
i2c_u8g2_config_t i2c_u8g2_config_default(void)
Fill a config with menuconfig-backed defaults.
u8g2_t * i2c_u8g2_get_u8g2(i2c_u8g2_handle_t *handle)
Get the U8G2 object for draw operations.
esp_err_t i2c_u8g2_init(i2c_u8g2_handle_t *handle, const i2c_u8g2_config_t *config)
Initialize I2C bus and U8G2 display.
Internal I2C + U8G2 display integration APIs.
char ap_ssid[APP_AP_SSID_MAX_LEN+1]
char ap_password[APP_AP_PASSWORD_MAX_LEN+1]
alarm_entry_t alarms[APP_ALARM_MAX_COUNT]
char sta_ip[APP_IP_ADDRESS_MAX_LEN]
Snapshot of full app state.
Configuration for I2C-backed U8G2 display initialization.
Display handle containing runtime driver state.
bool time_service_get_local_time(struct tm *out_tm, int64_t *out_epoch)
Get local time adjusted by the configured timezone offset.
Time service APIs for local time access and synchronization triggers.