Lv6 roller sometime return wrong value

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)

Please format your code blocks correctly. You appear to have ignored the guidelines provided in the template.


Have you updated to the latest master branch? I think this issue was reported before and fixed.

Another suggestion is to try a larger font - maybe the roller items are too small for you to accurately press them and/or your touchscreen is not calibrated correctly.

hi embeddedt thank you for helping me.
any idea where i can find the code blocks format?

i use arduino IDE install LittlevGL Version 2.0.1 via Library Manager .
i will try larger font.

before i have read few site and say capacitive touchscreen no need to calibrated, but i also feel my capacitive touchscreen someting is like a bit not respone very smooth. do you have any idea how to calibrate capacitive touchscreen ?

It’s provided in the template.

You should format the code blocks like this:
```c
/*You code here*/
```

code to create 4 roller and 4 label.

static void create_tab1(lv_obj_t * parent)
{
    lv_page_set_scrl_layout(parent, LV_LAYOUT_PRETTY);

    lv_theme_t * th = lv_theme_get_current();

    static lv_style_t h_style;
    lv_style_copy(&h_style, &lv_style_transp);
    h_style.body.padding.inner = LV_DPI / 10;
    h_style.body.padding.left = LV_DPI / 4;
    h_style.body.padding.right = LV_DPI / 4;
    h_style.body.padding.top = LV_DPI / 10;
    h_style.body.padding.bottom = LV_DPI / 10;

    lv_obj_t * h = lv_cont_create(parent, NULL);
    lv_obj_set_style(h, &h_style);
    lv_obj_set_click(h, false);
    lv_cont_set_fit(h, LV_FIT_TIGHT);
  /*  lv_cont_set_layout(h, LV_LAYOUT_COL_M); */


   rol0label = lv_label_create(h, NULL);
   lv_label_set_text(rol0label, "N1");
   lv_obj_set_style(rol0label, th->style.label.prim);
   lv_obj_align(rol0label, NULL, LV_ALIGN_IN_TOP_LEFT, -30, 0); 

   rol1label = lv_label_create(h, NULL);
   lv_label_set_text(rol1label, "N2");
   lv_obj_set_style(rol1label, th->style.label.sec);
   lv_obj_align(rol1label, rol0label, LV_ALIGN_OUT_RIGHT_TOP, 30, 0); 

   rol2label = lv_label_create(h, NULL);
   lv_label_set_text(rol2label, "N2");
   lv_obj_set_style(rol2label, th->style.label.hint);
   lv_obj_align(rol2label, rol1label, LV_ALIGN_OUT_RIGHT_MID,   30, 0);

   rol3label = lv_label_create(h, NULL);
   lv_label_set_text(rol3label, "N2");
   lv_obj_set_style(rol3label, th->style.label.hint);
   lv_obj_align(rol3label, rol2label, LV_ALIGN_OUT_RIGHT_MID,   30, 0);


     roller0 = lv_roller_create(h, NULL);  
     lv_obj_set_pos(roller0, -320, 50); 
     lv_obj_set_width(roller0, 50); 
     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);  
 
 
    roller1 = lv_roller_create(h, NULL);
    lv_roller_set_options(roller1,
                           " 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(roller1, 3);
    lv_obj_align(roller1, roller0, LV_ALIGN_OUT_RIGHT_TOP, 15, 0);        
    lv_obj_set_event_cb(roller1, B0roller_event);


lv_obj_t * btnDot = lv_btn_create(h, NULL); 
lv_obj_set_size(btnDot, 5, 5);
lv_obj_align(btnDot, roller1, LV_ALIGN_OUT_RIGHT_BOTTOM, 10, 0);    

    roller2 = lv_roller_create(h, NULL);
    lv_roller_set_options(roller2,
                           " 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(roller2, 3);
    lv_obj_align(roller2, btnDot, LV_ALIGN_OUT_RIGHT_MID,   10, -40);  
    lv_obj_set_event_cb(roller2, B0roller_event);
 
    roller3 = lv_roller_create(h, NULL);
    lv_roller_set_options(roller3,
                           " 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(roller3, 3);
    lv_obj_align(roller3, roller2, LV_ALIGN_OUT_RIGHT_TOP, 15, 0);      
    lv_obj_set_event_cb(roller3, B0roller_event);

 
}

below is roller event update the label

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);
             
    }
}

after few days testing. i found sometime when slide the roller, the roller not moving but the value change and label get update with new value.

I’ve tried this code but it worked well for me in the simulator. :frowning:

hi kisvegabor,

thank you for your geat work with geat support. i will buy another ESP32 to test out. i will report back here the result.