exclude some code when USE_LV_GROUP 0

This commit is contained in:
Gabor Kiss-Vamosi
2018-10-09 15:03:46 +02:00
parent a4b4ebaf7d
commit 7d1e1e6147
8 changed files with 55 additions and 17 deletions

View File

@@ -411,6 +411,9 @@ static void indev_keypad_proc(lv_indev_t * i, lv_indev_data_t * data)
i->proc.last_state = data->state; i->proc.last_state = data->state;
i->proc.last_key = data->key; i->proc.last_key = data->key;
#else
(void)data; /*Unused*/
(void)i; /*Unused*/
#endif #endif
} }
@@ -504,6 +507,9 @@ static void indev_encoder_proc(lv_indev_t * i, lv_indev_data_t * data)
i->proc.last_state = data->state; i->proc.last_state = data->state;
i->proc.last_key = data->key; i->proc.last_key = data->key;
#else
(void)data; /*Unused*/
(void)i; /*Unused*/
#endif #endif
} }

View File

@@ -80,7 +80,7 @@ lv_obj_t * lv_arc_create(lv_obj_t * par, const lv_obj_t * copy)
/*Set the default styles*/ /*Set the default styles*/
lv_theme_t * th = lv_theme_get_current(); lv_theme_t * th = lv_theme_get_current();
if(th) { if(th) {
lv_arc_set_style(new_arc, LV_ARC_STYLE_MAIN, th->preload); lv_arc_set_style(new_arc, LV_ARC_STYLE_MAIN, th->arc);
} else { } else {
lv_arc_set_style(new_arc, LV_ARC_STYLE_MAIN, &lv_style_plain_color); lv_arc_set_style(new_arc, LV_ARC_STYLE_MAIN, &lv_style_plain_color);
} }

View File

@@ -233,6 +233,8 @@ void lv_btn_set_ink_in_time(lv_obj_t * btn, uint16_t time)
lv_btn_ext_t * ext = lv_obj_get_ext_attr(btn); lv_btn_ext_t * ext = lv_obj_get_ext_attr(btn);
ext->ink_in_time = time; ext->ink_in_time = time;
#else #else
(void)btn; /*Unused*/
(void)time; /*Unused*/
LV_LOG_WARN("`lv_btn_set_ink_ink_time` has no effect if LV_BTN_INK_EFEFCT or USE_LV_ANIMATION is disabled") LV_LOG_WARN("`lv_btn_set_ink_ink_time` has no effect if LV_BTN_INK_EFEFCT or USE_LV_ANIMATION is disabled")
#endif #endif
} }
@@ -249,6 +251,8 @@ void lv_btn_set_ink_wait_time(lv_obj_t * btn, uint16_t time)
lv_btn_ext_t * ext = lv_obj_get_ext_attr(btn); lv_btn_ext_t * ext = lv_obj_get_ext_attr(btn);
ext->ink_wait_time = time; ext->ink_wait_time = time;
#else #else
(void)btn; /*Unused*/
(void)time; /*Unused*/
LV_LOG_WARN("`lv_btn_set_ink_wait_time` has no effect if LV_BTN_INK_EFEFCT or USE_LV_ANIMATION is disabled") LV_LOG_WARN("`lv_btn_set_ink_wait_time` has no effect if LV_BTN_INK_EFEFCT or USE_LV_ANIMATION is disabled")
#endif #endif
} }
@@ -264,6 +268,8 @@ void lv_btn_set_ink_out_time(lv_obj_t * btn, uint16_t time)
lv_btn_ext_t * ext = lv_obj_get_ext_attr(btn); lv_btn_ext_t * ext = lv_obj_get_ext_attr(btn);
ext->ink_out_time = time; ext->ink_out_time = time;
#else #else
(void)btn; /*Unused*/
(void)time; /*Unused*/
LV_LOG_WARN("`lv_btn_set_ink_out_time` has no effect if LV_BTN_INK_EFEFCT or USE_LV_ANIMATION is disabled") LV_LOG_WARN("`lv_btn_set_ink_out_time` has no effect if LV_BTN_INK_EFEFCT or USE_LV_ANIMATION is disabled")
#endif #endif
} }
@@ -352,6 +358,7 @@ uint16_t lv_btn_get_ink_in_time(const lv_obj_t * btn)
lv_btn_ext_t * ext = lv_obj_get_ext_attr(btn); lv_btn_ext_t * ext = lv_obj_get_ext_attr(btn);
return ext->ink_in_time; return ext->ink_in_time;
#else #else
(void)btn; /*Unused*/
return 0; return 0;
#endif #endif
} }
@@ -368,6 +375,7 @@ uint16_t lv_btn_get_ink_wait_time(const lv_obj_t * btn)
lv_btn_ext_t * ext = lv_obj_get_ext_attr(btn); lv_btn_ext_t * ext = lv_obj_get_ext_attr(btn);
return ext->ink_wait_time; return ext->ink_wait_time;
#else #else
(void)btn; /*Unused*/
return 0; return 0;
#endif #endif
} }
@@ -382,6 +390,7 @@ uint16_t lv_btn_get_ink_out_time(const lv_obj_t * btn)
lv_btn_ext_t * ext = lv_obj_get_ext_attr(btn); lv_btn_ext_t * ext = lv_obj_get_ext_attr(btn);
return ext->ink_in_time; return ext->ink_in_time;
#else #else
(void)btn; /*Unused*/
return 0; return 0;
#endif #endif
} }

View File

@@ -526,10 +526,12 @@ static lv_res_t lv_ddlist_signal(lv_obj_t * ddlist, lv_signal_t sign, void * par
} else if(sign == LV_SIGNAL_CLEANUP) { } else if(sign == LV_SIGNAL_CLEANUP) {
ext->label = NULL; ext->label = NULL;
} else if(sign == LV_SIGNAL_FOCUS) { } else if(sign == LV_SIGNAL_FOCUS) {
bool editing = false;
#if USE_LV_GROUP
lv_group_t * g = lv_obj_get_group(ddlist); lv_group_t * g = lv_obj_get_group(ddlist);
bool editing = lv_group_get_editing(g); editing = lv_group_get_editing(g);
#endif
lv_hal_indev_type_t indev_type = lv_indev_get_type(lv_indev_get_act()); lv_hal_indev_type_t indev_type = lv_indev_get_type(lv_indev_get_act());
/*Encoders need special handling*/ /*Encoders need special handling*/
if(indev_type == LV_INDEV_TYPE_ENCODER) { if(indev_type == LV_INDEV_TYPE_ENCODER) {
/*Open the list if editing*/ /*Open the list if editing*/
@@ -587,10 +589,11 @@ static lv_res_t lv_ddlist_signal(lv_obj_t * ddlist, lv_signal_t sign, void * par
ext->sel_opt_id_ori = ext->sel_opt_id; ext->sel_opt_id_ori = ext->sel_opt_id;
ext->opened = 0; ext->opened = 0;
if(ext->action) ext->action(ddlist); if(ext->action) ext->action(ddlist);
#if USE_LV_GROUP
lv_group_t * g = lv_obj_get_group(ddlist); lv_group_t * g = lv_obj_get_group(ddlist);
bool editing = lv_group_get_editing(g); bool editing = lv_group_get_editing(g);
if(editing) lv_group_set_editing(g, false); /*In edit mode go to navigate mode if an option is selected*/ if(editing) lv_group_set_editing(g, false); /*In edit mode go to navigate mode if an option is selected*/
#endif
} else { } else {
ext->opened = 1; ext->opened = 1;
} }

View File

@@ -89,7 +89,9 @@ lv_obj_t * lv_list_create(lv_obj_t * par, const lv_obj_t * copy)
ext->styles_btn[LV_BTN_STATE_TGL_PR] = &lv_style_btn_tgl_pr; ext->styles_btn[LV_BTN_STATE_TGL_PR] = &lv_style_btn_tgl_pr;
ext->styles_btn[LV_BTN_STATE_INA] = &lv_style_btn_ina; ext->styles_btn[LV_BTN_STATE_INA] = &lv_style_btn_ina;
ext->anim_time = LV_LIST_FOCUS_TIME; ext->anim_time = LV_LIST_FOCUS_TIME;
#if USE_LV_GROUP
ext->selected_btn = NULL; ext->selected_btn = NULL;
#endif
lv_obj_set_signal_func(new_list, lv_list_signal); lv_obj_set_signal_func(new_list, lv_list_signal);
@@ -625,8 +627,6 @@ static lv_res_t lv_list_signal(lv_obj_t * list, lv_signal_t sign, void * param)
res = ancestor_page_signal(list, sign, param); res = ancestor_page_signal(list, sign, param);
if(res != LV_RES_OK) return res; if(res != LV_RES_OK) return res;
lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
if(sign == LV_SIGNAL_CORD_CHG) { if(sign == LV_SIGNAL_CORD_CHG) {
/*Be sure the width of the buttons are correct*/ /*Be sure the width of the buttons are correct*/
lv_coord_t w = lv_obj_get_width(list); lv_coord_t w = lv_obj_get_width(list);
@@ -637,10 +637,11 @@ static lv_res_t lv_list_signal(lv_obj_t * list, lv_signal_t sign, void * param)
/*Because of the possible change of horizontal and vertical padding refresh buttons width */ /*Because of the possible change of horizontal and vertical padding refresh buttons width */
refr_btn_width(list); refr_btn_width(list);
} else if(sign == LV_SIGNAL_FOCUS) { } else if(sign == LV_SIGNAL_FOCUS) {
#if USE_LV_GROUP
lv_hal_indev_type_t indev_type = lv_indev_get_type(lv_indev_get_act()); lv_hal_indev_type_t indev_type = lv_indev_get_type(lv_indev_get_act());
/*With ENCODER select the first button only in edit mode*/ /*With ENCODER select the first button only in edit mode*/
if(indev_type == LV_INDEV_TYPE_ENCODER) { if(indev_type == LV_INDEV_TYPE_ENCODER) {
lv_group_t * g = lv_obj_get_group(list); lv_group_t * g = lv_obj_get_group(list);
if(lv_group_get_editing(g)) { if(lv_group_get_editing(g)) {
lv_list_set_btn_selected(list, lv_list_get_next_btn(list, NULL)); lv_list_set_btn_selected(list, lv_list_get_next_btn(list, NULL));
@@ -658,17 +659,25 @@ static lv_res_t lv_list_signal(lv_obj_t * list, lv_signal_t sign, void * param)
lv_list_set_btn_selected(list, lv_list_get_next_btn(list, NULL)); lv_list_set_btn_selected(list, lv_list_get_next_btn(list, NULL));
} }
} }
#endif
} else if(sign == LV_SIGNAL_DEFOCUS) { } else if(sign == LV_SIGNAL_DEFOCUS) {
#if USE_LV_GROUP
/*De-select the selected btn*/ /*De-select the selected btn*/
lv_list_set_btn_selected(list, NULL); lv_list_set_btn_selected(list, NULL);
last_clicked_btn = NULL; /*button click will be set if click happens before focus*/ last_clicked_btn = NULL; /*button click will be set if click happens before focus*/
lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
ext->selected_btn = NULL; ext->selected_btn = NULL;
#endif
} else if(sign == LV_SIGNAL_GET_EDITABLE) { } else if(sign == LV_SIGNAL_GET_EDITABLE) {
bool * editable = (bool *)param; bool * editable = (bool *)param;
*editable = true; *editable = true;
} else if(sign == LV_SIGNAL_CONTROLL) { } else if(sign == LV_SIGNAL_CONTROLL) {
#if USE_LV_GROUP
char c = *((char *)param); char c = *((char *)param);
if(c == LV_GROUP_KEY_RIGHT || c == LV_GROUP_KEY_DOWN) { if(c == LV_GROUP_KEY_RIGHT || c == LV_GROUP_KEY_DOWN) {
lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
/*If there is a valid selected button the make the previous selected*/ /*If there is a valid selected button the make the previous selected*/
if(ext->selected_btn) { if(ext->selected_btn) {
lv_obj_t * btn_prev = lv_list_get_next_btn(list, ext->selected_btn); lv_obj_t * btn_prev = lv_list_get_next_btn(list, ext->selected_btn);
@@ -680,6 +689,7 @@ static lv_res_t lv_list_signal(lv_obj_t * list, lv_signal_t sign, void * param)
if(btn) lv_list_set_btn_selected(list, btn); /*If there are no buttons on the list then there is no first button*/ if(btn) lv_list_set_btn_selected(list, btn); /*If there are no buttons on the list then there is no first button*/
} }
} else if(c == LV_GROUP_KEY_LEFT || c == LV_GROUP_KEY_UP) { } else if(c == LV_GROUP_KEY_LEFT || c == LV_GROUP_KEY_UP) {
lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
/*If there is a valid selected button the make the next selected*/ /*If there is a valid selected button the make the next selected*/
if(ext->selected_btn != NULL) { if(ext->selected_btn != NULL) {
lv_obj_t * btn_next = lv_list_get_prev_btn(list, ext->selected_btn); lv_obj_t * btn_next = lv_list_get_prev_btn(list, ext->selected_btn);
@@ -704,14 +714,15 @@ static lv_res_t lv_list_signal(lv_obj_t * list, lv_signal_t sign, void * param)
rel_action = lv_btn_get_action(btn, LV_BTN_ACTION_CLICK); rel_action = lv_btn_get_action(btn, LV_BTN_ACTION_CLICK);
if(rel_action != NULL) rel_action(btn); if(rel_action != NULL) rel_action(btn);
} }
} else if(sign == LV_SIGNAL_GET_TYPE) {
lv_obj_type_t * buf = param;
uint8_t i;
for(i = 0; i < LV_MAX_ANCESTOR_NUM - 1; i++) { /*Find the last set data*/
if(buf->type[i] == NULL) break;
}
buf->type[i] = "lv_list";
} }
#endif
} else if(sign == LV_SIGNAL_GET_TYPE) {
lv_obj_type_t * buf = param;
uint8_t i;
for(i = 0; i < LV_MAX_ANCESTOR_NUM - 1; i++) { /*Find the last set data*/
if(buf->type[i] == NULL) break;
}
buf->type[i] = "lv_list";
} }
return res; return res;
} }

View File

@@ -224,6 +224,7 @@ void lv_mbox_start_auto_close(lv_obj_t * mbox, uint16_t delay)
lv_obj_animate(mbox, LV_ANIM_NONE, ext->anim_time, delay, (void (*)(lv_obj_t *))lv_obj_del); lv_obj_animate(mbox, LV_ANIM_NONE, ext->anim_time, delay, (void (*)(lv_obj_t *))lv_obj_del);
} }
#else #else
(void)delay; /*Unused*/
lv_obj_del(mbox); lv_obj_del(mbox);
#endif #endif
} }
@@ -236,6 +237,8 @@ void lv_mbox_stop_auto_close(lv_obj_t * mbox)
{ {
#if USE_LV_ANIMATION #if USE_LV_ANIMATION
lv_anim_del(mbox, NULL); lv_anim_del(mbox, NULL);
#else
(void)mbox; /*Unused*/
#endif #endif
} }

View File

@@ -315,8 +315,11 @@ static lv_res_t lv_roller_signal(lv_obj_t * roller, lv_signal_t sign, void * par
refr_position(roller, false); refr_position(roller, false);
} }
} else if(sign == LV_SIGNAL_FOCUS) { } else if(sign == LV_SIGNAL_FOCUS) {
bool editing = false;
#if USE_LV_GROUP
lv_group_t * g = lv_obj_get_group(roller); lv_group_t * g = lv_obj_get_group(roller);
bool editing = lv_group_get_editing(g); editing = lv_group_get_editing(g);
#endif
lv_hal_indev_type_t indev_type = lv_indev_get_type(lv_indev_get_act()); lv_hal_indev_type_t indev_type = lv_indev_get_type(lv_indev_get_act());
/*Encoders need special handling*/ /*Encoders need special handling*/
@@ -357,10 +360,12 @@ static lv_res_t lv_roller_signal(lv_obj_t * roller, lv_signal_t sign, void * par
} else if(c == LV_GROUP_KEY_ENTER) { } else if(c == LV_GROUP_KEY_ENTER) {
ext->ddlist.sel_opt_id_ori = ext->ddlist.sel_opt_id; /*Set the entered value as default*/ ext->ddlist.sel_opt_id_ori = ext->ddlist.sel_opt_id; /*Set the entered value as default*/
if(ext->ddlist.action) ext->ddlist.action(roller); if(ext->ddlist.action) ext->ddlist.action(roller);
#if USE_LV_GROUP
lv_group_t * g = lv_obj_get_group(roller); lv_group_t * g = lv_obj_get_group(roller);
bool editing = lv_group_get_editing(g); bool editing = lv_group_get_editing(g);
if(editing) lv_group_set_editing(g, false); /*In edit mode go to navigate mode if an option is selected*/ if(editing) lv_group_set_editing(g, false); /*In edit mode go to navigate mode if an option is selected*/
#endif
} }
} else if(sign == LV_SIGNAL_GET_TYPE) { } else if(sign == LV_SIGNAL_GET_TYPE) {
lv_obj_type_t * buf = param; lv_obj_type_t * buf = param;

View File

@@ -486,6 +486,7 @@ static lv_res_t lv_slider_signal(lv_obj_t * slider, lv_signal_t sign, void * par
} }
} else if(sign == LV_SIGNAL_CONTROLL) { } else if(sign == LV_SIGNAL_CONTROLL) {
char c = *((char *)param); char c = *((char *)param);
#if USE_LV_GROUP
lv_group_t * g = lv_obj_get_group(slider); lv_group_t * g = lv_obj_get_group(slider);
bool editing = lv_group_get_editing(g); bool editing = lv_group_get_editing(g);
lv_hal_indev_type_t indev_type = lv_indev_get_type(lv_indev_get_act()); lv_hal_indev_type_t indev_type = lv_indev_get_type(lv_indev_get_act());
@@ -494,7 +495,7 @@ static lv_res_t lv_slider_signal(lv_obj_t * slider, lv_signal_t sign, void * par
if(indev_type == LV_INDEV_TYPE_ENCODER && c == LV_GROUP_KEY_ENTER) { if(indev_type == LV_INDEV_TYPE_ENCODER && c == LV_GROUP_KEY_ENTER) {
if(editing) lv_group_set_editing(g, false); if(editing) lv_group_set_editing(g, false);
} }
#endif
if(c == LV_GROUP_KEY_RIGHT || c == LV_GROUP_KEY_UP) { if(c == LV_GROUP_KEY_RIGHT || c == LV_GROUP_KEY_UP) {
lv_slider_set_value(slider, lv_slider_get_value(slider) + 1); lv_slider_set_value(slider, lv_slider_get_value(slider) + 1);
if(ext->action != NULL) ext->action(slider); if(ext->action != NULL) ext->action(slider);