8000 Tab View does not send a LV_EVENT_VALUE_CHANGED event, despite the documentation saying it does · Issue #8420 · lvgl/lvgl · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Tab View does not send a LV_EVENT_VALUE_CHANGED event, despite the documentation saying it does #8420
Open
@RLH-2110

Description

@RLH-2110

LVGL version

9.3.0

Platform

STM32MPU135F-DK with OpenSTLinux
LVGL with SDL2

What happened?

The documentation says that:

LV_EVENT_VALUE_CHANGED Sent when a new tab is selected by sliding or clicking the tab button.

But that event never seems to occur when a tab is pressed

How to reproduce?

Here is a program that I would expect to work. It works if I use LV_EVENT_ALL instead of LV_EVENT_VALUE_CHANGED.

#include <stdint.h>
#include <pthread.h>
#include <unistd.h>
#include <signal.h>

#include "lvgl/lvgl.h"
#include "lvgl/src/drivers/sdl/lv_sdl_mouse.h"

#define H_RES (480)
#define V_RES (272)

#define LVGL_DESIRED_TICK_INCREASE_MS 5

#define MICROSECOND_TO_MILISECOND_RATE 1000

/* lvgl stuff and threats */
static lv_display_t *disp;
static lv_indev_t *lvMouse;

static pthread_t tickThread;
static void* tick_thread(void* data);
volatile sig_atomic_t stop = 0; /* programms runs as long as this is set */

/* callbacks */
void tab_view_value_changed_cb(lv_event_t *e);
uint32_t u32Temp;

int main(){

  lv_init();

  pthread_create( &tickThread, NULL, tick_thread,NULL);

  disp = lv_sdl_window_create(H_RES, V_RES);
  lvMouse = lv_sdl_mouse_create();

  lv_obj_t *screen = lv_obj_create(NULL);

  lv_obj_t *tabView = lv_tabview_create(screen);

  lv_obj_t *tabHome = lv_tabview_add_tab(tabView, "Home");
  lv_obj_t *tabExit = lv_tabview_add_tab(tabView, "Exit");

  u32Temp = lv_obj_get_index(tabExit);
  lv_obj_add_event_cb(tabView,tab_view_value_changed_cb,LV_EVENT_VALUE_CHANGED, &u32Temp);

  lv_screen_load_anim(screen,LV_SCR_LOAD_ANIM_NONE,0,0,true);

  while(!stop){
    uint32_t timeTillNext = lv_timer_handler();
    usleep(timeTillNext*MICROSECOND_TO_MILISECOND_RATE );
  }

  pthread_join(tickThread,NULL);
  lv_indev_delete(lvMouse);
  lv_disp_remove(disp);
  lv_sdl_quit();
  lv_deinit();
}

/* callbacks */
void tab_view_value_changed_cb(lv_event_t *e){
  lv_obj_t *tabView = lv_event_get_target_obj(e);
  int32_t exitTabId = *((int32_t*)lv_event_get_user_data(e));

  if (lv_tabview_get_tab_active(tabView) == exitTabId)
    stop = 1;
}

/* other functions */
static void *tick_thread(void* data) {
  (void) data;
  while(!stop) {
    usleep(LVGL_DESIRED_TICK_INCREASE_MS * MICROSECOND_TO_MILISECOND_RATE);
    lv_tick_inc(LVGL_DESIRED_TICK_INCREASE_MS);
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0