Layout main UI screen
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
static const char *TAG = "spincoat-plater-firmware/ui";
|
||||
|
||||
static lv_obj_t * rpm_label = NULL;
|
||||
static lv_obj_t * coat_time_label = NULL;
|
||||
|
||||
/**
|
||||
* Callback for pressing the top button
|
||||
@@ -35,26 +36,28 @@ void bottom_cb(lv_event_t * e) {
|
||||
/**
|
||||
* Factory function that creates a "numberstack" widget and returns the label for it
|
||||
*/
|
||||
void build_numberstack(lv_obj_t * parent,
|
||||
lv_obj_t * build_numberstack(lv_obj_t * parent,
|
||||
const char * label_text,
|
||||
lv_obj_t ** label_value,
|
||||
ns_btn_cb_t top_btn_cb,
|
||||
ns_btn_cb_t bottom_btn_cb) {
|
||||
|
||||
lv_obj_t * container = lv_obj_create(parent);
|
||||
lv_obj_set_size(container , lv_pct(100), lv_pct(100));
|
||||
//lv_obj_set_size(container , lv_pct(100), lv_pct(100));
|
||||
lv_obj_set_flex_flow(container, LV_FLEX_FLOW_COLUMN);
|
||||
lv_obj_set_flex_align(container,
|
||||
LV_FLEX_ALIGN_START,
|
||||
LV_FLEX_ALIGN_CENTER,
|
||||
LV_FLEX_ALIGN_CENTER);
|
||||
|
||||
lv_obj_set_style_pad_all(container, 10, 0);
|
||||
lv_obj_set_style_pad_gap(container, 8, 0);
|
||||
lv_obj_set_style_pad_all(container, 0, 0);
|
||||
//lv_obj_set_style_pad_gap(container, 8, 0);
|
||||
|
||||
/* -------- Top label -------- */
|
||||
lv_obj_t * label_cont = lv_obj_create(container);
|
||||
|
||||
lv_obj_remove_flag(label_cont, LV_OBJ_FLAG_SCROLLABLE);
|
||||
|
||||
lv_obj_set_flex_grow(label_cont, 1);
|
||||
lv_obj_set_width(label_cont, lv_pct(100));
|
||||
|
||||
@@ -63,7 +66,7 @@ void build_numberstack(lv_obj_t * parent,
|
||||
|
||||
lv_obj_set_style_bg_opa(label, LV_OPA_COVER, 0);
|
||||
|
||||
lv_obj_set_style_text_font(label, &lv_font_montserrat_14, 0);
|
||||
lv_obj_set_style_text_font(label, &lv_font_montserrat_12, 0);
|
||||
lv_obj_center(label);
|
||||
|
||||
/* -------- Top button -------- */
|
||||
@@ -77,16 +80,18 @@ void build_numberstack(lv_obj_t * parent,
|
||||
|
||||
/* -------- Center label -------- */
|
||||
lv_obj_t * label2_cont = lv_obj_create(container);
|
||||
|
||||
lv_obj_remove_flag(label2_cont, LV_OBJ_FLAG_SCROLLABLE);
|
||||
|
||||
lv_obj_set_flex_grow(label2_cont, 1);
|
||||
lv_obj_set_width(label2_cont, lv_pct(100));
|
||||
|
||||
* label_value = lv_label_create(label2_cont);
|
||||
lv_label_set_text(*label_value, "");
|
||||
lv_label_set_text(*label_value, "nil");
|
||||
|
||||
lv_obj_set_style_bg_opa(*label_value, LV_OPA_COVER, 0);
|
||||
|
||||
lv_obj_set_style_text_font(*label_value, &lv_font_montserrat_14, 0);
|
||||
lv_obj_set_style_text_font(*label_value, &lv_font_montserrat_12, 0);
|
||||
lv_obj_center(*label_value);
|
||||
|
||||
/* -------- Bottom button -------- */
|
||||
@@ -97,6 +102,8 @@ void build_numberstack(lv_obj_t * parent,
|
||||
lv_obj_set_flex_grow(btn_bottom, 1);
|
||||
lv_obj_set_width(btn_bottom, lv_pct(100));
|
||||
lv_obj_center(lbl_bottom);
|
||||
|
||||
return container;
|
||||
}
|
||||
|
||||
void update_rpm_readout(uint16_t rpm) {
|
||||
@@ -107,6 +114,38 @@ void update_rpm_readout(uint16_t rpm) {
|
||||
|
||||
void build_ui(void) {
|
||||
rpm_label = NULL;
|
||||
build_numberstack(lv_screen_active(), "RPM", &rpm_label, top_cb, bottom_cb);
|
||||
coat_time_label = NULL;
|
||||
|
||||
lv_obj_t * container = lv_obj_create(lv_screen_active());
|
||||
lv_obj_set_size(container, lv_pct(100), lv_pct(100));
|
||||
lv_obj_set_flex_flow(container, LV_FLEX_FLOW_COLUMN);
|
||||
lv_obj_set_flex_align(container,
|
||||
LV_FLEX_ALIGN_START,
|
||||
LV_FLEX_ALIGN_CENTER,
|
||||
LV_FLEX_ALIGN_CENTER);
|
||||
|
||||
lv_obj_t * numberstacks_container = lv_obj_create(container);
|
||||
lv_obj_set_size(numberstacks_container , lv_pct(100), lv_pct(70));
|
||||
lv_obj_set_flex_flow(numberstacks_container, LV_FLEX_FLOW_ROW);
|
||||
lv_obj_set_flex_align(numberstacks_container,
|
||||
LV_FLEX_ALIGN_SPACE_EVENLY,
|
||||
LV_FLEX_ALIGN_CENTER,
|
||||
LV_FLEX_ALIGN_CENTER);
|
||||
|
||||
lv_obj_t * rpm_container = build_numberstack(numberstacks_container, "RPM", &rpm_label, top_cb, bottom_cb);
|
||||
lv_obj_t * coat_time_container = build_numberstack(numberstacks_container, "Coat Time", &coat_time_label, top_cb, bottom_cb);
|
||||
|
||||
lv_obj_set_size(rpm_container, lv_pct(48), lv_pct(96));
|
||||
lv_obj_set_size(coat_time_container, lv_pct(48), lv_pct(96));
|
||||
|
||||
lv_obj_set_style_pad_all(container, 0, 0);
|
||||
lv_obj_set_style_pad_all(numberstacks_container, 0, 0);
|
||||
lv_obj_set_style_pad_all(rpm_container, 0, 0);
|
||||
lv_obj_set_style_pad_all(coat_time_container, 0, 0);
|
||||
|
||||
/* -------- Run/Stop button -------- */
|
||||
lv_obj_t * run_stop_cont = lv_button_create(container);
|
||||
lv_obj_set_size(run_stop_cont, lv_pct(96), lv_pct(18));
|
||||
lv_obj_set_style_pad_all(run_stop_cont, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user