Description
I would like to display a spinbox with the value of the needle
What MCU/Processor/Board and compiler are you using?
Waveshare ESP32-S3 Round display 2.8’ & ESP-IDF 5.3.1
What LVGL version are you using?
V 8.3
What do you want to achieve?
My code takes too much memory and then crashes when I want to change the screen (by gesture)
What have you tried so far?
Code to reproduce
static void set_value(void * indic, int32_t valeur)
{
lv_meter_set_indicator_value(MyGauge, indic, valeur);
ui_Angle = lv_spinbox_create(ui_modevent);
lv_obj_set_width(ui_Angle, 70);
lv_obj_set_height(ui_Angle, 52);
lv_obj_set_x(ui_Angle, 0);
lv_obj_set_y(ui_Angle, -14);
lv_obj_set_align(ui_Angle, LV_ALIGN_CENTER);
lv_obj_clear_flag(ui_Angle, LV_OBJ_FLAG_CLICKABLE | LV_OBJ_FLAG_PRESS_LOCK | LV_OBJ_FLAG_CLICK_FOCUSABLE |
LV_OBJ_FLAG_GESTURE_BUBBLE | LV_OBJ_FLAG_SNAPPABLE); /// Flags
lv_spinbox_set_digit_format(ui_Angle, 3, 0);
lv_spinbox_set_range(ui_Angle, 0, 360);
lv_spinbox_set_pos(ui_Angle, 0);
lv_spinbox_set_value(ui_Angle, valeur);
ui_object_set_themeable_style_property(ui_Angle, LV_PART_MAIN | LV_STATE_DEFAULT, LV_STYLE_BG_COLOR,
_ui_theme_color_fondspin);
ui_object_set_themeable_style_property(ui_Angle, LV_PART_MAIN | LV_STATE_DEFAULT, LV_STYLE_BG_OPA,
_ui_theme_alpha_fondspin);
ui_object_set_themeable_style_property(ui_Angle, LV_PART_MAIN | LV_STATE_DEFAULT, LV_STYLE_TEXT_COLOR,
_ui_theme_color_texte);
ui_object_set_themeable_style_property(ui_Angle, LV_PART_MAIN | LV_STATE_DEFAULT, LV_STYLE_TEXT_OPA,
_ui_theme_alpha_texte);
lv_obj_set_style_text_align(ui_Angle, LV_TEXT_ALIGN_CENTER, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_font(ui_Angle, &lv_font_montserrat_24, LV_PART_MAIN | LV_STATE_DEFAULT);
}
void f_gauge()
{
///////////// FLECHE et GRADUATION ////////////////////
MyGauge = lv_meter_create(ui_modevent);
lv_obj_center(MyGauge);
lv_obj_set_size(MyGauge, 490, 490);
lv_obj_remove_style(MyGauge, NULL, LV_PART_INDICATOR); //enlever point central
lv_obj_set_style_bg_opa(MyGauge, LV_OPA_TRANSP, LV_PART_MAIN | LV_STATE_DEFAULT); //fond transparent
/*Add a scale first*/
lv_meter_scale_t* scale = lv_meter_add_scale(MyGauge);
lv_meter_set_scale_range(MyGauge, scale, 0, 360, 360, -90);
lv_meter_set_scale_ticks(MyGauge, scale, 73, 2, 10, lv_palette_main(LV_PALETTE_GREY));
lv_meter_set_scale_major_ticks(MyGauge, scale, 18, 4, 15, lv_color_black(), 45);
lv_meter_indicator_t* indic;
/*Add a red arc to the end*/
indic = lv_meter_add_arc(MyGauge, scale, 10, lv_palette_main(LV_PALETTE_ORANGE), 10);
lv_meter_set_indicator_start_value(MyGauge, indic, 300);
lv_meter_set_indicator_end_value(MyGauge, indic, 320);
indic = lv_meter_add_arc(MyGauge, scale, 10, lv_palette_main(LV_PALETTE_RED), 10);
lv_meter_set_indicator_start_value(MyGauge, indic, 320);
lv_meter_set_indicator_end_value(MyGauge, indic, 360);
/*Add a color arc to the start*/
indic = lv_meter_add_arc(MyGauge, scale, 10, lv_palette_main(LV_PALETTE_RED), 10);
lv_meter_set_indicator_start_value(MyGauge, indic, 360);
lv_meter_set_indicator_end_value(MyGauge, indic, 24);
indic = lv_meter_add_arc(MyGauge, scale, 10, lv_palette_main(LV_PALETTE_ORANGE), 10);
lv_meter_set_indicator_start_value(MyGauge, indic, 24);
lv_meter_set_indicator_end_value(MyGauge, indic, 44);
indic = lv_meter_add_needle_img(MyGauge, scale, &ui_img_fleche_png, 42, 0);
/*Create an animation to set the value*/
lv_anim_t a;
lv_anim_init(&a);
lv_anim_set_exec_cb(&a, set_value);
lv_anim_set_var(&a, indic);
lv_anim_set_values(&a, 0, 360);
lv_anim_set_time(&a, 5000);
lv_anim_set_repeat_delay(&a, 1000);
lv_anim_set_playback_time(&a, 5000);
lv_anim_set_playback_delay(&a, 1000);
//lv_anim_set_repeat_count(&a, LV_ANIM_REPEAT_INFINITE);
lv_anim_start(&a);
Screenshot and/or video
Thanks