Skip to content

it need 3 times push the next navigation button to next to seconds object in Flex Layout (BSP-733) #666

@kayip-adam

Description

@kayip-adam

Board

ESP32 WROVER

Hardware Description

ESP32 WROVER , OLED DS1307 128x64 pixel display

IDE Name

VScode

Operating System

linux mint

Description

I am trying to control OLED DS1307 with ESP32 Wrover. Firtsly I used old version and i need push next button 4 times to next second object in flex layout. I tried so many thing but not worked. I update esp_lvgl_port 2.6.2 . it was solved. However my new problem that :
imagine please : you create the 5 buttons object and create Scroll. You want to go to next / previous button object by push navigation buttons for next or previous navigation input buttons. You need push the next navigation button for 3 times to next the button object in flex layout and scroll (in addition, it move without create scroll ) but I can pass by push next or previous button just one time after push next button 3 times on first times. However It is the event repeats when I jump to first button from fifth . I didn't understand what is problem why i need push navigation button 3 times instead of 1 time.

I am using VS code .

Sketch

void scroll_TK_ui(lv_disp_t *disp) {

    /*DEFINATIONS OF STYLES*/

    /*Style Buttons*/
    static lv_style_t style_btn;
    lv_style_init(&style_btn);
    lv_style_set_text_font(&style_btn,&lv_font_montserrat_14);
    lv_style_set_width(&style_btn,128);
    lv_style_set_height(&style_btn,LV_PCT(100));
    lv_style_set_outline_color (&style_btn,lv_color_hex(0x000000)) ;
    lv_style_set_outline_width (&style_btn,2);
    lv_style_set_outline_opa (&style_btn,LV_OPA_100);
    lv_style_set_radius (&style_btn,5);
    lv_style_set_align(&style_btn,LV_ALIGN_LEFT_MID);  
    

    /* DEFINATION OF SCREEN & GROUP */
    lv_obj_t *scr0 = lv_disp_get_scr_act(disp);
    lv_obj_t *scroll_p= lv_obj_create(scr0);
    lv_group_t *g = lv_group_create();
    lv_group_set_default(g);
    lv_indev_set_group(buttons_handle,g);
    lv_group_add_obj(g,scroll_p);

    /*SCROLL & FLEX LAYOUT*/
    lv_obj_set_size(scroll_p,128,24);
    lv_obj_set_flex_flow(scroll_p,LV_FLEX_FLOW_COLUMN );
    lv_obj_add_flag(scroll_p,LV_OBJ_FLAG_SCROLL_CHAIN);
    lv_obj_set_scroll_snap_y(scroll_p, LV_SCROLL_SNAP_CENTER);
    lv_obj_add_flag(scroll_p,LV_OBJ_FLAG_SCROLL_ONE);
    lv_obj_align(scroll_p,LV_ALIGN_BOTTOM_MID,0,0 );

    
    // lv_obj_add_flag(scroll_p, LV_OBJ_FLAG_SCROLL_CHAIN_VER);
    
    
     /*HEADER AREA SCREEN */
    lv_obj_t *header_s= lv_obj_create(scr0);
    lv_group_add_obj(g,header_s);
    lv_obj_set_size(header_s,128,16);
    lv_obj_align(header_s,LV_ALIGN_TOP_MID,0,22);
    lv_obj_t *header_l =lv_label_create(header_s);
    lv_obj_set_style_text_font(header_l ,&lv_font_montserrat_14,0);
    lv_obj_set_size(header_l ,lv_pct(100),lv_pct(100));
    lv_label_set_text(header_l, "ANASAYFA--------------------");
    lv_label_set_long_mode(header_l, LV_LABEL_LONG_SCROLL);
    lv_obj_center(header_l);
    // const char *title = "Temp";   // Text from variable
    // int temp = 25;                       // Integer value
    // const char *unit = "°C";             // Unit text
    // // Combine them into one label text
    // lv_label_set_text_fmt(header_l, "%s: %d%s", title, temp, unit);

    /*INDICATOR AREA SCREEN */
    lv_obj_t *battery_l =lv_label_create(scr0);
    lv_obj_set_style_text_font(battery_l,&lv_font_montserrat_14,0);
    lv_obj_set_size(battery_l,lv_pct(100),lv_pct(100));
    lv_obj_align(battery_l,LV_ALIGN_TOP_LEFT,110,0);
    lv_label_set_text(battery_l, LV_SYMBOL_BATTERY_1);
    lv_obj_t *wifi =lv_label_create(scr0);
    lv_obj_set_style_text_font(wifi,&lv_font_montserrat_14,0);
    lv_obj_set_size(wifi,lv_pct(100),lv_pct(100));
    lv_obj_align(wifi,LV_ALIGN_OUT_LEFT_TOP,0,0);
    lv_label_set_text(wifi, LV_SYMBOL_WIFI);
    lv_obj_t *alarm =lv_label_create(scr0);
    lv_obj_set_style_text_font(alarm,&lv_font_montserrat_14,0);
    lv_obj_set_size(alarm,lv_pct(100),lv_pct(100));
    lv_obj_align(alarm,LV_ALIGN_OUT_LEFT_TOP,80,0); 
    lv_label_set_text(alarm, LV_SYMBOL_WARNING);
 
    for (uint32_t i = 0; i < 6; i++)
    {
        /* code */
        lv_obj_t *btn_point;
        lv_obj_t *label_point;
        btn_point =lv_btn_create(scroll_p);
        lv_obj_add_style(btn_point,&style_btn,0);
        
        label_point = lv_label_create(btn_point);
        lv_obj_set_style_pad_left(label_point,4,0);
        lv_label_set_text_fmt(label_point, "%s",menu_AS[i]);
        lv_obj_set_align(label_point,LV_ALIGN_LEFT_MID);  
    }
   
    lv_obj_add_event_cb(scroll_p, store_scroll_value_event_cb, LV_EVENT_SCROLL, NULL);
    

}
void store_scroll_value_event_cb (lv_event_t* e) 
    {
        static int scroll_value_x = 0;
        static int scroll_value_y = 0;
        lv_obj_t* screen = lv_event_get_target(e);
        scroll_value_x = lv_obj_get_scroll_left(screen);
        scroll_value_y = lv_obj_get_scroll_top(screen);
        printf("%d pixels are scrolled out on the left\n ,%d pixels are scrolled out on the top\n  ", scroll_value_x,scroll_value_y);
    }

Other Steps to Reproduce

No response

I have checked existing issues, README.md and ESP32 Forum

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.

Metadata

Metadata

Assignees

Labels

Area: LVGLrelated to LVGL and LVGL portType: BugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions