mirror of
https://github.com/lvgl/lvgl.git
synced 2025-02-04 07:13:00 +08:00
chore(nuttx): support LV_EVENT_DELETE
for display/lcd/touchscreen (#4801)
Signed-off-by: YanXiaowei <yanxiaowei@xiaomi.com> Co-authored-by: YanXiaowei <yanxiaowei@xiaomi.com>
This commit is contained in:
parent
69d65257bb
commit
bc9139e97b
@ -29,7 +29,9 @@
|
|||||||
**********************/
|
**********************/
|
||||||
|
|
||||||
static uint32_t millis(void);
|
static uint32_t millis(void);
|
||||||
static void syslog_print(lv_log_level_t level, const char * buf);
|
#if LV_USE_LOG
|
||||||
|
static void syslog_print(lv_log_level_t level, const char * buf);
|
||||||
|
#endif
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
* STATIC VARIABLES
|
* STATIC VARIABLES
|
||||||
@ -81,7 +83,9 @@ void lv_nuttx_dsc_init(lv_nuttx_dsc_t * dsc)
|
|||||||
|
|
||||||
void lv_nuttx_init(const lv_nuttx_dsc_t * dsc, lv_nuttx_result_t * result)
|
void lv_nuttx_init(const lv_nuttx_dsc_t * dsc, lv_nuttx_result_t * result)
|
||||||
{
|
{
|
||||||
|
#if LV_USE_LOG
|
||||||
lv_log_register_print_cb(syslog_print);
|
lv_log_register_print_cb(syslog_print);
|
||||||
|
#endif
|
||||||
lv_tick_set_cb(millis);
|
lv_tick_set_cb(millis);
|
||||||
|
|
||||||
#if !LV_USE_NUTTX_CUSTOM_INIT
|
#if !LV_USE_NUTTX_CUSTOM_INIT
|
||||||
@ -132,6 +136,7 @@ static uint32_t millis(void)
|
|||||||
return tick;
|
return tick;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if LV_USE_LOG
|
||||||
static void syslog_print(lv_log_level_t level, const char * buf)
|
static void syslog_print(lv_log_level_t level, const char * buf)
|
||||||
{
|
{
|
||||||
static const int priority[_LV_LOG_LEVEL_NUM] = {
|
static const int priority[_LV_LOG_LEVEL_NUM] = {
|
||||||
@ -140,5 +145,6 @@ static void syslog_print(lv_log_level_t level, const char * buf)
|
|||||||
|
|
||||||
syslog(priority[level], "[LVGL] %s", buf);
|
syslog(priority[level], "[LVGL] %s", buf);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /*LV_USE_NUTTX*/
|
#endif /*LV_USE_NUTTX*/
|
||||||
|
@ -48,7 +48,8 @@ typedef struct {
|
|||||||
static void flush_cb(lv_display_t * disp, const lv_area_t * area, uint8_t * color_p);
|
static void flush_cb(lv_display_t * disp, const lv_area_t * area, uint8_t * color_p);
|
||||||
static int fbdev_get_pinfo(int fd, struct fb_planeinfo_s * pinfo);
|
static int fbdev_get_pinfo(int fd, struct fb_planeinfo_s * pinfo);
|
||||||
static int fbdev_init_mem2(lv_nuttx_fb_t * dsc);
|
static int fbdev_init_mem2(lv_nuttx_fb_t * dsc);
|
||||||
static void _display_refr_timer_cb(lv_timer_t * tmr);
|
static void display_refr_timer_cb(lv_timer_t * tmr);
|
||||||
|
static void display_release_cb(lv_event_t * e);
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
* STATIC VARIABLES
|
* STATIC VARIABLES
|
||||||
@ -75,6 +76,7 @@ lv_display_t * lv_nuttx_fbdev_create(void)
|
|||||||
}
|
}
|
||||||
dsc->fd = -1;
|
dsc->fd = -1;
|
||||||
lv_display_set_driver_data(disp, dsc);
|
lv_display_set_driver_data(disp, dsc);
|
||||||
|
lv_display_add_event(disp, display_release_cb, LV_EVENT_DELETE, disp);
|
||||||
lv_display_set_flush_cb(disp, flush_cb);
|
lv_display_set_flush_cb(disp, flush_cb);
|
||||||
return disp;
|
return disp;
|
||||||
}
|
}
|
||||||
@ -132,7 +134,7 @@ int lv_nuttx_fbdev_set_file(lv_display_t * disp, const char * file)
|
|||||||
(dsc->pinfo.stride * dsc->vinfo.yres), LV_DISP_RENDER_MODE_DIRECT);
|
(dsc->pinfo.stride * dsc->vinfo.yres), LV_DISP_RENDER_MODE_DIRECT);
|
||||||
lv_display_set_user_data(disp, (void *)(uintptr_t)(dsc->fd));
|
lv_display_set_user_data(disp, (void *)(uintptr_t)(dsc->fd));
|
||||||
lv_display_set_resolution(disp, dsc->vinfo.xres, dsc->vinfo.yres);
|
lv_display_set_resolution(disp, dsc->vinfo.xres, dsc->vinfo.yres);
|
||||||
lv_timer_set_cb(disp->refr_timer, _display_refr_timer_cb);
|
lv_timer_set_cb(disp->refr_timer, display_refr_timer_cb);
|
||||||
|
|
||||||
LV_LOG_INFO("Resolution is set to %dx%d at %ddpi", dsc->vinfo.xres, dsc->vinfo.yres, lv_display_get_dpi(disp));
|
LV_LOG_INFO("Resolution is set to %dx%d at %ddpi", dsc->vinfo.xres, dsc->vinfo.yres, lv_display_get_dpi(disp));
|
||||||
return 0;
|
return 0;
|
||||||
@ -147,7 +149,7 @@ errout:
|
|||||||
* STATIC FUNCTIONS
|
* STATIC FUNCTIONS
|
||||||
**********************/
|
**********************/
|
||||||
|
|
||||||
static void _display_refr_timer_cb(lv_timer_t * tmr)
|
static void display_refr_timer_cb(lv_timer_t * tmr)
|
||||||
{
|
{
|
||||||
lv_display_t * disp = lv_timer_get_user_data(tmr);
|
lv_display_t * disp = lv_timer_get_user_data(tmr);
|
||||||
lv_nuttx_fb_t * dsc = lv_display_get_driver_data(disp);
|
lv_nuttx_fb_t * dsc = lv_display_get_driver_data(disp);
|
||||||
@ -297,4 +299,21 @@ static int fbdev_init_mem2(lv_nuttx_fb_t * dsc)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void display_release_cb(lv_event_t * e)
|
||||||
|
{
|
||||||
|
lv_display_t * disp = (lv_display_t *) lv_event_get_user_data(e);
|
||||||
|
lv_nuttx_fb_t * dsc = lv_display_get_driver_data(disp);
|
||||||
|
if(dsc) {
|
||||||
|
lv_display_set_driver_data(disp, NULL);
|
||||||
|
lv_display_set_flush_cb(disp, NULL);
|
||||||
|
|
||||||
|
if(dsc->fd >= 0) {
|
||||||
|
close(dsc->fd);
|
||||||
|
dsc->fd = -1;
|
||||||
|
}
|
||||||
|
lv_free(dsc);
|
||||||
|
}
|
||||||
|
LV_LOG_INFO("Done");
|
||||||
|
}
|
||||||
|
|
||||||
#endif /*LV_USE_NUTTX*/
|
#endif /*LV_USE_NUTTX*/
|
||||||
|
@ -49,6 +49,7 @@ static void rounder_cb(lv_event_t * e);
|
|||||||
static void flush_cb(lv_display_t * disp, const lv_area_t * area_p,
|
static void flush_cb(lv_display_t * disp, const lv_area_t * area_p,
|
||||||
uint8_t * color_p);
|
uint8_t * color_p);
|
||||||
static lv_display_t * lcd_init(int fd, int hor_res, int ver_res);
|
static lv_display_t * lcd_init(int fd, int hor_res, int ver_res);
|
||||||
|
static void display_release_cb(lv_event_t * e);
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
* STATIC VARIABLES
|
* STATIC VARIABLES
|
||||||
@ -197,13 +198,41 @@ static lv_display_t * lcd_init(int fd, int hor_res, int ver_res)
|
|||||||
lcd->disp = disp;
|
lcd->disp = disp;
|
||||||
lv_display_set_draw_buffers(lcd->disp, draw_buf, draw_buf_2, buf_size, render_mode);
|
lv_display_set_draw_buffers(lcd->disp, draw_buf, draw_buf_2, buf_size, render_mode);
|
||||||
lv_display_set_flush_cb(lcd->disp, flush_cb);
|
lv_display_set_flush_cb(lcd->disp, flush_cb);
|
||||||
lv_event_add(&lcd->disp->event_list, rounder_cb, LV_EVENT_INVALIDATE_AREA, lcd);
|
lv_display_add_event(lcd->disp, rounder_cb, LV_EVENT_INVALIDATE_AREA, lcd);
|
||||||
lcd->disp->driver_data = lcd;
|
lv_display_add_event(lcd->disp, display_release_cb, LV_EVENT_DELETE, lcd->disp);
|
||||||
lcd->disp->user_data = (void *)(uintptr_t)fd;
|
lv_display_set_driver_data(lcd->disp, lcd);
|
||||||
|
lv_display_set_user_data(lcd->disp, (void *)(uintptr_t)fd);
|
||||||
|
|
||||||
return lcd->disp;
|
return lcd->disp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void display_release_cb(lv_event_t * e)
|
||||||
|
{
|
||||||
|
lv_display_t * disp = (lv_display_t *) lv_event_get_user_data(e);
|
||||||
|
lv_nuttx_lcd_t * dsc = lv_display_get_driver_data(disp);
|
||||||
|
if(dsc) {
|
||||||
|
lv_display_set_driver_data(disp, NULL);
|
||||||
|
lv_display_set_flush_cb(disp, NULL);
|
||||||
|
|
||||||
|
/* clear display buffer */
|
||||||
|
if(disp->buf_1) {
|
||||||
|
lv_free(disp->buf_1);
|
||||||
|
disp->buf_1 = NULL;
|
||||||
|
}
|
||||||
|
if(disp->buf_2) {
|
||||||
|
lv_free(disp->buf_2);
|
||||||
|
disp->buf_2 = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* close device fb */
|
||||||
|
if(dsc->fd >= 0) {
|
||||||
|
close(dsc->fd);
|
||||||
|
dsc->fd = -1;
|
||||||
|
}
|
||||||
|
lv_free(dsc);
|
||||||
|
LV_LOG_INFO("Done");
|
||||||
|
}
|
||||||
|
}
|
||||||
#endif /*LV_USE_NUTTX_LCD*/
|
#endif /*LV_USE_NUTTX_LCD*/
|
||||||
|
|
||||||
#endif /* LV_USE_NUTTX*/
|
#endif /* LV_USE_NUTTX*/
|
||||||
|
@ -112,6 +112,7 @@ void lv_nuttx_uv_deinit(void ** data)
|
|||||||
|
|
||||||
lv_free(uv_ctx);
|
lv_free(uv_ctx);
|
||||||
*data = NULL;
|
*data = NULL;
|
||||||
|
LV_LOG_INFO("Done");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
@ -162,7 +163,9 @@ static int lv_nuttx_uv_timer_init(lv_nuttx_uv_t * uv_info, lv_nuttx_uv_ctx_t * u
|
|||||||
|
|
||||||
static void lv_nuttx_uv_timer_deinit(lv_nuttx_uv_ctx_t * uv_ctx)
|
static void lv_nuttx_uv_timer_deinit(lv_nuttx_uv_ctx_t * uv_ctx)
|
||||||
{
|
{
|
||||||
|
lv_timer_handler_set_resume_cb(NULL, NULL);
|
||||||
uv_close((uv_handle_t *)&uv_ctx->uv_timer, NULL);
|
uv_close((uv_handle_t *)&uv_ctx->uv_timer, NULL);
|
||||||
|
LV_LOG_INFO("Done");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void lv_nuttx_uv_disp_poll_cb(uv_poll_t * handle, int status, int events)
|
static void lv_nuttx_uv_disp_poll_cb(uv_poll_t * handle, int status, int events)
|
||||||
@ -228,9 +231,12 @@ static int lv_nuttx_uv_fb_init(lv_nuttx_uv_t * uv_info, lv_nuttx_uv_fb_ctx_t * f
|
|||||||
|
|
||||||
static void lv_nuttx_uv_fb_deinit(lv_nuttx_uv_fb_ctx_t * fb_ctx)
|
static void lv_nuttx_uv_fb_deinit(lv_nuttx_uv_fb_ctx_t * fb_ctx)
|
||||||
{
|
{
|
||||||
|
/* should remove event */
|
||||||
|
|
||||||
if(fb_ctx->fd > 0) {
|
if(fb_ctx->fd > 0) {
|
||||||
uv_close((uv_handle_t *)&fb_ctx->fb_poll, NULL);
|
uv_close((uv_handle_t *)&fb_ctx->fb_poll, NULL);
|
||||||
}
|
}
|
||||||
|
LV_LOG_INFO("Done");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void lv_nuttx_uv_input_poll_cb(uv_poll_t * handle, int status, int events)
|
static void lv_nuttx_uv_input_poll_cb(uv_poll_t * handle, int status, int events)
|
||||||
@ -289,6 +295,7 @@ static void lv_nuttx_uv_input_deinit(lv_nuttx_uv_input_ctx_t * input_ctx)
|
|||||||
if(input_ctx->fd > 0) {
|
if(input_ctx->fd > 0) {
|
||||||
uv_close((uv_handle_t *)&input_ctx->input_poll, NULL);
|
uv_close((uv_handle_t *)&input_ctx->input_poll, NULL);
|
||||||
}
|
}
|
||||||
|
LV_LOG_INFO("Done");
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /*LV_USE_NUTTX_LIBUV*/
|
#endif /*LV_USE_NUTTX_LIBUV*/
|
||||||
|
@ -41,6 +41,7 @@ typedef struct {
|
|||||||
* STATIC PROTOTYPES
|
* STATIC PROTOTYPES
|
||||||
**********************/
|
**********************/
|
||||||
static void touchscreen_read(lv_indev_t * drv, lv_indev_data_t * data);
|
static void touchscreen_read(lv_indev_t * drv, lv_indev_data_t * data);
|
||||||
|
static void touchscreen_delete_cb(lv_event_t * e);
|
||||||
static lv_indev_t * touchscreen_init(int fd);
|
static lv_indev_t * touchscreen_init(int fd);
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
@ -119,11 +120,29 @@ static void touchscreen_read(lv_indev_t * drv, lv_indev_data_t * data)
|
|||||||
data->state = touchscreen->last_state;
|
data->state = touchscreen->last_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void touchscreen_delete_cb(lv_event_t * e)
|
||||||
|
{
|
||||||
|
lv_indev_t * indev = (lv_indev_t *) lv_event_get_user_data(e);
|
||||||
|
lv_nuttx_touchscreen_t * touchscreen = lv_indev_get_driver_data(indev);
|
||||||
|
if(touchscreen) {
|
||||||
|
lv_indev_set_driver_data(indev, NULL);
|
||||||
|
lv_indev_set_read_cb(indev, NULL);
|
||||||
|
|
||||||
|
if(touchscreen->fd >= 0) {
|
||||||
|
close(touchscreen->fd);
|
||||||
|
touchscreen->fd = -1;
|
||||||
|
}
|
||||||
|
lv_free(touchscreen);
|
||||||
|
LV_LOG_INFO("done");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static lv_indev_t * touchscreen_init(int fd)
|
static lv_indev_t * touchscreen_init(int fd)
|
||||||
{
|
{
|
||||||
lv_nuttx_touchscreen_t * touchscreen;
|
lv_nuttx_touchscreen_t * touchscreen;
|
||||||
touchscreen = malloc(sizeof(lv_nuttx_touchscreen_t));
|
lv_indev_t * indev = NULL;
|
||||||
|
|
||||||
|
touchscreen = lv_malloc_zeroed(sizeof(lv_nuttx_touchscreen_t));
|
||||||
if(touchscreen == NULL) {
|
if(touchscreen == NULL) {
|
||||||
LV_LOG_ERROR("touchscreen_s malloc failed");
|
LV_LOG_ERROR("touchscreen_s malloc failed");
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -131,14 +150,14 @@ static lv_indev_t * touchscreen_init(int fd)
|
|||||||
|
|
||||||
touchscreen->fd = fd;
|
touchscreen->fd = fd;
|
||||||
touchscreen->last_state = LV_INDEV_STATE_RELEASED;
|
touchscreen->last_state = LV_INDEV_STATE_RELEASED;
|
||||||
|
touchscreen->indev_drv = indev = lv_indev_create();
|
||||||
|
|
||||||
touchscreen->indev_drv = lv_indev_create();
|
lv_indev_set_type(indev, LV_INDEV_TYPE_POINTER);
|
||||||
touchscreen->indev_drv->type = LV_INDEV_TYPE_POINTER;
|
lv_indev_set_read_cb(indev, touchscreen_read);
|
||||||
touchscreen->indev_drv->read_cb = touchscreen_read;
|
lv_indev_set_driver_data(indev, touchscreen);
|
||||||
touchscreen->indev_drv->driver_data = touchscreen;
|
lv_indev_set_user_data(indev, (void *)(uintptr_t)fd);
|
||||||
touchscreen->indev_drv->user_data = (void *)(uintptr_t)fd;
|
lv_indev_add_event(indev, touchscreen_delete_cb, LV_EVENT_DELETE, indev);
|
||||||
|
return indev;
|
||||||
return touchscreen->indev_drv;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /*LV_USE_NUTTX_TOUCHSCREEN*/
|
#endif /*LV_USE_NUTTX_TOUCHSCREEN*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user