home screen mockup

This commit is contained in:
leo 2023-08-08 17:18:26 +02:00
parent f6a2f62fad
commit 619de01707
Signed by: leo
GPG Key ID: 0DD993BFB2B307DB

View File

@ -9,6 +9,8 @@
#include "lvgl.h" #include "lvgl.h"
#define PSE_UNITS_NUM 4 // number of units (4 in our case, X, Y, Z and extr)
static void run_handler(lv_event_t * e){ static void run_handler(lv_event_t * e){
lv_event_code_t code = lv_event_get_code(e); lv_event_code_t code = lv_event_get_code(e);
@ -25,13 +27,51 @@ static void run_handler(lv_event_t * e){
} }
} }
static lv_coord_t units_col_dsc[] = {LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_TEMPLATE_LAST};
static lv_coord_t units_row_dsc[] = {LV_GRID_FR(1), LV_GRID_TEMPLATE_LAST};
static lv_obj_t* PSE_unit_widget(lv_obj_t* parent){
// The main container
lv_obj_t* cont = lv_obj_create(parent);
lv_obj_set_size(cont, lv_pct(24), lv_pct(100));
lv_obj_set_flex_flow(cont, LV_FLEX_FLOW_COLUMN);
// flow setting
lv_obj_t* flow = lv_label_create(cont);
lv_obj_set_width(flow, lv_pct(100));
lv_obj_set_flex_grow(flow, 1);
lv_label_set_text(flow, "-----.--\nuL/mn");
// volume delivered readout
lv_obj_t* vol = lv_label_create(cont);
lv_obj_set_width(vol, lv_pct(100));
lv_obj_set_flex_grow(vol, 1);
lv_label_set_text(vol, "-----.--\nmL");
// home button
lv_obj_t* home = lv_btn_create(cont);
lv_obj_t* home_label = lv_label_create(home);
lv_obj_set_flex_grow(home, 1);
lv_obj_center(home_label);
lv_label_set_text(home_label, LV_SYMBOL_HOME);
// enabled button
lv_obj_t* enabled = lv_btn_create(cont);
lv_obj_t* enabled_label = lv_label_create(enabled);
lv_obj_add_flag(enabled, LV_OBJ_FLAG_CHECKABLE);
lv_obj_set_flex_grow(enabled, 1);
lv_obj_center(enabled_label);
lv_label_set_text(enabled_label, LV_SYMBOL_OK);
return cont;
}
void Home_Screen_Gen(void){ void Home_Screen_Gen(void){
// Create a new screen // Create a new screen
lv_obj_t* scr = lv_obj_create(NULL); lv_obj_t* scr = lv_obj_create(NULL);
// create the top menu on the top 20% // create the top menu on the top 20%
lv_obj_t* top_menu = lv_obj_create(scr); lv_obj_t* top_menu = lv_obj_create(scr);
lv_obj_set_align(top_menu, LV_ALIGN_OUT_TOP_LEFT); lv_obj_set_align(top_menu, LV_ALIGN_TOP_LEFT);
lv_obj_set_size(top_menu, lv_pct(100), lv_pct(20)); lv_obj_set_size(top_menu, lv_pct(100), lv_pct(20));
lv_obj_set_style_pad_all(top_menu, 5, 0); lv_obj_set_style_pad_all(top_menu, 5, 0);
@ -47,6 +87,20 @@ void Home_Screen_Gen(void){
lv_label_set_text(run_label, LV_SYMBOL_PLAY); lv_label_set_text(run_label, LV_SYMBOL_PLAY);
lv_obj_center(run_label); lv_obj_center(run_label);
// grid layout for the 4 differents units
lv_obj_t* units_grid = lv_obj_create(scr);
lv_obj_align_to(units_grid, top_menu, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 0);
lv_obj_set_size(units_grid, lv_pct(100), lv_pct(80));
lv_obj_set_style_pad_all(units_grid, 5, 0);
lv_obj_set_layout(units_grid, LV_LAYOUT_GRID);
lv_obj_set_grid_dsc_array(units_grid, units_col_dsc, units_row_dsc);
for(int i = 0; i < PSE_UNITS_NUM; i++){
lv_obj_t* obj = PSE_unit_widget(units_grid);
lv_obj_set_grid_cell(obj, LV_GRID_ALIGN_CENTER, i, 1, LV_GRID_ALIGN_CENTER, 0, 1);
}
// fade in the new screen // fade in the new screen
lv_scr_load_anim(scr, LV_SCR_LOAD_ANIM_FADE_ON, 100, 100, false); lv_scr_load_anim(scr, LV_SCR_LOAD_ANIM_FADE_ON, 100, 100, false);
} }