/* * UI kit - shared look for the hand-coded screens (Settings, Gauge Tuning). * * Car-sized touch targets (>= 56 px), 20/24 px body text, no shadows or * animated transitions (every extra redraw of this 1024x600 PSRAM framebuffer * costs frame time). All functions need the LVGL lock, like any LVGL call. */ #pragma once #include #include #define UI_COL_BG lv_color_hex(0x101418) #define UI_COL_PANEL lv_color_hex(0x1B2128) #define UI_COL_PANEL2 lv_color_hex(0x252D36) // pressed / selected rows #define UI_COL_TEXT lv_color_hex(0xE8EDF2) #define UI_COL_MUTED lv_color_hex(0x8894A0) #define UI_COL_ACCENT lv_color_hex(0x3DA9FC) #define UI_COL_OK lv_color_hex(0x3DD68C) #define UI_COL_WARN lv_color_hex(0xE5484D) #define UI_COL_AMBER lv_color_hex(0xF5A524) namespace UiKit { typedef enum { BTN_PRIMARY, BTN_SECONDARY, BTN_DANGER, BTN_SUCCESS } btn_style_t; /** Plain full-screen background object. */ lv_obj_t* screen(); /** Title top-left and a "< Driveline" button top-right that calls back_cb. */ void header(lv_obj_t* scr, const char* title, lv_event_cb_t back_cb); lv_obj_t* label(lv_obj_t* parent, const char* text, const lv_font_t* font, lv_color_t color); /** Button with a centred label; the label is the button's first child. */ lv_obj_t* button(lv_obj_t* parent, const char* text, lv_coord_t w, lv_coord_t h, btn_style_t style, lv_event_cb_t cb, void* user); void setButtonText(lv_obj_t* btn, const char* text); lv_obj_t* toggle(lv_obj_t* parent, lv_event_cb_t cb, void* user); void setChecked(lv_obj_t* obj, bool on); /** Transparent flex row/column container without padding or scrolling. */ lv_obj_t* box(lv_obj_t* parent, lv_flex_flow_t flow); /** Rounded panel (card). */ lv_obj_t* card(lv_obj_t* parent); /** lv_label_set_text only when the text changed - avoids needless redraws. */ void setText(lv_obj_t* lbl, const char* text); void setTextColor(lv_obj_t* lbl, lv_color_t c); void setVisible(lv_obj_t* obj, bool visible); /** Modal Cancel / OK dialog; cb(true, user) on OK, cb(false, user) on Cancel. */ void confirm(const char* title, const char* text, const char* ok_text, void (*cb)(bool ok, void* user), void* user); } // namespace UiKit