valconomy/firmware/main/ui.c

55 lines
1.4 KiB
C

#include "lvgl.h"
#include "ui.h"
static const lv_font_t *font_normal = &lv_font_montserrat_24;
static lv_color_t color_primary, color_secondary;
static lv_color_t color_text_hero;
static lv_style_t s_hero;
static void b_cfg_cb(lv_event_t *e) {
lv_obj_t *box = lv_msgbox_create(NULL);
lv_msgbox_add_title(box, "Hello");
lv_msgbox_add_text(box, "test message");
lv_msgbox_add_close_button(box);
}
static void ui_home() {
lv_obj_t *i_bg = lv_image_create(lv_screen_active());
lv_image_set_src(i_bg, &ui_img_bg);
lv_obj_t *l_test = lv_label_create(lv_screen_active());
lv_obj_add_style(l_test, &s_hero, 0);
lv_label_set_text(l_test, "VAL TIME");
lv_obj_t *b_cfg = lv_button_create(lv_screen_active());
lv_obj_align(b_cfg, LV_ALIGN_BOTTOM_RIGHT, -10, -10);
lv_obj_add_event_cb(b_cfg, b_cfg_cb, LV_EVENT_CLICKED, NULL);
lv_obj_t *l_cfg = lv_label_create(b_cfg);
lv_label_set_text(l_cfg, LV_SYMBOL_SETTINGS);
lv_obj_center(l_cfg);
}
void val_lvgl_ui(lv_display_t *disp) {
color_primary = lv_color_hex(0xff4655);
color_secondary = lv_color_hex(0xf7518f);
color_text_hero = lv_palette_lighten(LV_PALETTE_GREY, 2);
// init default theme
lv_theme_default_init(
disp, color_primary, color_secondary,
true, // dark theme
font_normal);
// lv_sysmon_hide_performance(disp);
lv_style_init(&s_hero);
lv_style_set_text_font(&s_hero, &lv_font_tungsten_120);
lv_style_set_text_color(&s_hero, color_text_hero);
ui_home();
}