Updated about suggestions.

This commit is contained in:
Wayne Lin 2021-12-20 11:40:05 +08:00 committed by Bernard Xiong
parent b33967ecf4
commit de7dc291ab
7 changed files with 30 additions and 32 deletions

View File

@ -216,10 +216,15 @@ static void adc_touch_entry(void *parameter)
|| touch_point.event == RT_TOUCH_EVENT_UP
|| touch_point.event == RT_TOUCH_EVENT_MOVE)
{
#if defined(PKG_USING_LITTLEVGL2RTT) || defined(PKG_USING_LVGL)
#if defined(PKG_USING_LVGL)
extern void nu_touch_inputevent_cb(rt_int16_t x, rt_int16_t y, rt_uint8_t state);
nu_touch_inputevent_cb(touch_point.x_coordinate, touch_point.y_coordinate, touch_point.event);
#elif defined(PKG_USING_LITTLEVGL2RTT)
extern void littlevgl2rtt_send_input_event(rt_int16_t x, rt_int16_t y, rt_uint8_t state);
littlevgl2rtt_send_input_event(touch_point.x_coordinate, touch_point.y_coordinate, touch_point.event);
#endif
#if defined(PKG_USING_NUEMWIN)
extern void nuemwin_send_input_event(rt_int16_t x, rt_int16_t y, rt_uint8_t state);
nuemwin_send_input_event(touch_point.x_coordinate, touch_point.y_coordinate, touch_point.event);

View File

@ -9,17 +9,16 @@
*/
#include <rtthread.h>
#include <lvgl.h>
#include <lv_port_indev.h>
#define DBG_TAG "LVGL"
#define DBG_LVL DBG_INFO
#include <rtdbg.h>
#ifndef LV_THREAD_STACK_SIZE
#define LV_THREAD_STACK_SIZE 10240
#define LV_THREAD_STACK_SIZE 4096
#endif
#ifndef LV_THREAD_PRIO
#define LV_THREAD_PRIO 20
#define LV_THREAD_PRIO (RT_THREAD_PRIORITY_MAX*2/3)
#endif
static void lvgl_thread(void *parameter)

View File

@ -5,7 +5,7 @@
*
* Change Logs:
* Date Author Notes
* 2021-12-17 Wayne The first version
* 2021-12-17 Wayne The first version
*/
#include <lvgl.h>
@ -51,6 +51,7 @@ void lv_port_disp_init(void)
{
rt_err_t result;
void *buf_1 = RT_NULL;
void *buf_2 = RT_NULL;
lcd_device = rt_device_find("lcd");
if (lcd_device == 0)
@ -72,10 +73,11 @@ void lv_port_disp_init(void)
info.bits_per_pixel == 24 || info.bits_per_pixel == 32);
buf_1 = (void *)info.framebuffer;
rt_kprintf("lv buf_1=%08x\n", buf_1);
buf_2 = (void *)((uint32_t)buf_1 + info.height * info.width * info.bits_per_pixel / 8);
rt_kprintf("LVGL: Use two buffers - buf_1@%08x, buf_2@%08x\n", buf_1, buf_2);
/*Initialize `disp_buf` with the buffer(s).*/
lv_disp_draw_buf_init(&disp_buf, buf_1, NULL, info.width * info.height);
lv_disp_draw_buf_init(&disp_buf, buf_1, buf_2, info.width * info.height);
result = rt_device_open(lcd_device, 0);
if (result != RT_EOK)
@ -89,7 +91,6 @@ void lv_port_disp_init(void)
/*Set the resolution of the display*/
disp_drv.hor_res = info.width;
disp_drv.ver_res = info.height;
//disp_drv.full_refresh = 1;
/*Set a display buffer*/
disp_drv.draw_buf = &disp_buf;

View File

@ -6,6 +6,7 @@
* Change Logs:
* Date Author Notes
* 2021-10-18 Meco Man The first version
* 2021-12-17 Wayne Add input event
*/
#include <lvgl.h>
#include <stdbool.h>
@ -23,7 +24,7 @@ static void input_read(lv_indev_drv_t *indev_drv, lv_indev_data_t *data)
data->state = last_state;
}
void littlevgl2rtt_send_input_event(rt_int16_t x, rt_int16_t y, rt_uint8_t state)
void nu_touch_inputevent_cb(rt_int16_t x, rt_int16_t y, rt_uint8_t state)
{
switch (state)
{
@ -42,17 +43,15 @@ void littlevgl2rtt_send_input_event(rt_int16_t x, rt_int16_t y, rt_uint8_t state
}
}
lv_indev_t *button_indev;
void lv_port_indev_init(void)
{
static lv_indev_drv_t indev_drv;
lv_indev_drv_init(&indev_drv); /*Basic initialization*/
/* Basic initialization */
lv_indev_drv_init(&indev_drv);
indev_drv.type = LV_INDEV_TYPE_POINTER;
indev_drv.read_cb = input_read;
/*Register the driver in LVGL and save the created input device object*/
button_indev = lv_indev_drv_register(&indev_drv);
/* Register the driver in LVGL and save the created input device object */
lv_indev_drv_register(&indev_drv);
}

View File

@ -9,17 +9,16 @@
*/
#include <rtthread.h>
#include <lvgl.h>
#include <lv_port_indev.h>
#define DBG_TAG "LVGL"
#define DBG_LVL DBG_INFO
#include <rtdbg.h>
#ifndef LV_THREAD_STACK_SIZE
#define LV_THREAD_STACK_SIZE 10240
#define LV_THREAD_STACK_SIZE 4096
#endif
#ifndef LV_THREAD_PRIO
#define LV_THREAD_PRIO 20
#define LV_THREAD_PRIO (RT_THREAD_PRIORITY_MAX*2/3)
#endif
static void lvgl_thread(void *parameter)
@ -34,7 +33,7 @@ static void lvgl_thread(void *parameter)
}
}
static int lvgl_demo(void)
static int lvgl_demo_init(void)
{
rt_thread_t tid;
@ -47,5 +46,4 @@ static int lvgl_demo(void)
return 0;
}
INIT_APP_EXPORT(lvgl_demo);
//MSH_CMD_EXPORT(lvgl_demo, start lvgl music demo);
INIT_APP_EXPORT(lvgl_demo_init);

View File

@ -94,10 +94,8 @@ void lv_port_disp_init(void)
info.bits_per_pixel == 24 || info.bits_per_pixel == 32);
buf_1 = (void *)info.framebuffer;
rt_kprintf("lv buf_1=%08x\n", buf_1);
buf_2 = (void *)((uint32_t)info.framebuffer + info.height * info.width * info.bits_per_pixel / 8);
rt_kprintf("lv buf_2=%08x\n", buf_2);
buf_2 = (void *)((uint32_t)buf_1 + info.height * info.width * info.bits_per_pixel / 8);
rt_kprintf("LVGL: Use two buffers - buf_1@%08x, buf_2@%08x\n", buf_1, buf_2);
/*Initialize `disp_buf` with the buffer(s).*/
lv_disp_draw_buf_init(&disp_buf, buf_1, buf_2, info.width * info.height);

View File

@ -24,7 +24,7 @@ static void input_read(lv_indev_drv_t *indev_drv, lv_indev_data_t *data)
data->state = last_state;
}
void littlevgl2rtt_send_input_event(rt_int16_t x, rt_int16_t y, rt_uint8_t state)
void nu_touch_inputevent_cb(rt_int16_t x, rt_int16_t y, rt_uint8_t state)
{
switch (state)
{
@ -43,17 +43,15 @@ void littlevgl2rtt_send_input_event(rt_int16_t x, rt_int16_t y, rt_uint8_t state
}
}
lv_indev_t *button_indev;
void lv_port_indev_init(void)
{
static lv_indev_drv_t indev_drv;
lv_indev_drv_init(&indev_drv); /*Basic initialization*/
/* Basic initialization */
lv_indev_drv_init(&indev_drv);
indev_drv.type = LV_INDEV_TYPE_POINTER;
indev_drv.read_cb = input_read;
/*Register the driver in LVGL and save the created input device object*/
button_indev = lv_indev_drv_register(&indev_drv);
/* Register the driver in LVGL and save the created input device object */
lv_indev_drv_register(&indev_drv);
}