Description
all 4 roller also have same behaviour sometime return wrong value.
What MCU/Processor/Board and compiler are you using?
ESP32 with arduino
What do you want to achieve?
4 roller to set temperature setting
What have you tried so far?
lv_roller_get_selected_str(roller, buf, buf_size);
lv_roller_get_selected(roller)`
Code to reproduce
The code block(s) should be formatted like:
roller0 = lv_roller_create(h, NULL);
lv_obj_set_pos(roller0, -320, 50); //set roller position --Aaron
lv_obj_set_width(roller0, 50); //set roller width --Aaron
lv_roller_set_options(roller0,
" 0 \n"
" 1 \n"
" 2 \n"
" 3 \n"
" 4 \n"
" 5 \n"
" 6 \n"
" 7 \n"
" 8 \n"
" 9 ",
LV_ROLLER_MODE_NORMAL);
lv_roller_set_visible_row_count(roller0, 3);
lv_obj_set_event_cb(roller0, B0roller_event);
lv_obj_align(roller0, NULL, LV_ALIGN_OUT_RIGHT_BOTTOM, -240, 0);
static void B0roller_event(lv_obj_t * obj, lv_event_t event)
{
if(event == LV_EVENT_VALUE_CHANGED) {
char buf0[32];
char buf1[32];
char buf2[32];
char buf3[32];
lv_roller_get_selected_str(roller0, buf0, sizeof(buf0));
lv_roller_get_selected_str(roller1, buf1, sizeof(buf1));
lv_roller_get_selected_str(roller2, buf2, sizeof(buf2));
lv_roller_get_selected_str(roller3, buf3, sizeof(buf3));
BTRolSave = BTRolSelected0 + BTRolSelected1 + BTRolSelected2 + BTRolSelected3 ;
Serial.print("BTRolSave:");
Serial.print(BTRolSave);
Serial.println(":BTRolSave");
int rol0 = lv_roller_get_selected(roller0);
int rol1 = lv_roller_get_selected(roller1);
int rol2 = lv_roller_get_selected(roller2);
int rol3 = lv_roller_get_selected(roller3);
char buff0[10];
snprintf(buff0, 10, “%d%”, rol0);
lv_label_set_text(rol0label, buff0);
char buff1[10];
snprintf(buff1, 10, “%d%”, rol1);
lv_label_set_text(rol1label, buff1);
char buff2[10];
snprintf(buff2, 10, “%d%”, rol2);
lv_label_set_text(rol2label, buff2);
char buff3[10];
snprintf(buff3, 10, “%d%”, rol3);
lv_label_set_text(rol3label, buff3);
Serial.print(“rol0 :” );
Serial.println(rol0);
Serial.print(“rol1 :” );
Serial.println(rol1);
Serial.print(“rol2 :” );
Serial.println(rol2);
Serial.print(“rol3 :” );
Serial.println(rol3);
}
}
Screenshot and/or video
lv6 roller.zip (1.8 MB)