Skip to content

Commit

Permalink
[BSP][LVGL]An adaptation that creates a buffer in high or low versions
Browse files Browse the repository at this point in the history
  • Loading branch information
hydevcode committed Sep 24, 2024
1 parent 58055e7 commit 2bcc2f8
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 11 deletions.
9 changes: 4 additions & 5 deletions bsp/stm32/stm32f407-rt-spark/board/ports/lvgl/lv_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include <rtconfig.h>

#define LV_COLOR_DEPTH 16
#define LV_USE_PERF_MONITOR 1
#define MY_DISP_HOR_RES 240
#define MY_DISP_VER_RES 240
//#define LV_USE_LOG 1
Expand All @@ -31,13 +30,13 @@

#endif


#define LV_USE_SYSMON 1
#define LV_USE_PERF_MONITOR 1
#define LV_USE_DEMO_WIDGETS 1
#define LV_FONT_MONTSERRAT_24 1
#define LV_USE_DEMO_BENCHMARK 1


//#define LV_USE_DEMO_WIDGETS 1


//#define LV_USE_DEMO_MUSIC 1

#endif
37 changes: 31 additions & 6 deletions bsp/stm32/stm32f407-rt-spark/board/ports/lvgl/lv_port_disp.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@
#define MY_DISP_VER_RES 240
#endif

#define BYTE_PER_PIXEL (LV_COLOR_FORMAT_GET_SIZE(LV_COLOR_FORMAT_RGB565)) /*will be 2 for RGB565 */

#if (PKG_LVGL_VER_NUM >= 0x0803FF)
#define LV_DISP_TYPE lv_display_t
#define lv_COLOR_TYPE uint8_t
#else
#define LV_DISP_TYPE lv_disp_drv_t
#define lv_COLOR_TYPE lv_color_t
#endif

/**********************
* TYPEDEFS
**********************/
Expand All @@ -35,7 +45,7 @@
**********************/
static void disp_init(void);

static void disp_flush(lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p);
static void disp_flush(LV_DISP_TYPE * disp_drv, const lv_area_t * area, lv_COLOR_TYPE * color_p);
//static void gpu_fill(lv_disp_drv_t * disp_drv, lv_color_t * dest_buf, lv_coord_t dest_width,
// const lv_area_t * fill_area, lv_color_t color);

Expand Down Expand Up @@ -83,9 +93,6 @@ void lv_port_disp_init(void)
* and you only need to change the frame buffer's address.
*/

/* Example for 1) */
static lv_disp_draw_buf_t draw_buf_dsc_1;

/*GCC*/
#if defined ( __GNUC__ )
static lv_color_t buf_1[MY_DISP_HOR_RES * MY_DISP_HOR_RES / 2] __attribute__((section(".LVGLccm"))); /*A buffer for 10 rows*/
Expand All @@ -94,11 +101,26 @@ void lv_port_disp_init(void)
__attribute__((at(0x10000000))) lv_color_t buf_1[LCD_H * LCD_W / 2];
#endif

lv_disp_draw_buf_init(&draw_buf_dsc_1, buf_1, NULL, MY_DISP_HOR_RES * MY_DISP_HOR_RES / 2); /*Initialize the display buffer*/
/*-----------------------------------
* Register the display in LVGL
*----------------------------------*/

#if (PKG_LVGL_VER_NUM >= 0x0803FF)

lv_display_t *display = lv_display_create(MY_DISP_HOR_RES, MY_DISP_VER_RES);
lv_display_set_buffers(display, buf_1, NULL, sizeof(buf_1), LV_DISPLAY_RENDER_MODE_PARTIAL); /*Initialize the display buffer.*/
lv_display_set_flush_cb(display, disp_flush);

#else

/* Example for 1) */
static lv_disp_draw_buf_t draw_buf_dsc_1;

lv_disp_draw_buf_init(&draw_buf_dsc_1, buf_1, NULL, MY_DISP_HOR_RES * MY_DISP_HOR_RES / 2); /*Initialize the display buffer*/

/*-----------------------------------
* Register the display in LVGL
*----------------------------------*/
static lv_disp_drv_t disp_drv; /*Descriptor of a display driver*/
lv_disp_drv_init(&disp_drv); /*Basic initialization*/

Expand All @@ -124,6 +146,9 @@ void lv_port_disp_init(void)

/*Finally register the driver*/
lv_disp_drv_register(&disp_drv);

#endif

}

/**********************
Expand Down Expand Up @@ -155,7 +180,7 @@ void disp_disable_update(void)
/*Flush the content of the internal buffer the specific area on the display
*You can use DMA or any hardware acceleration to do this operation in the background but
*'lv_disp_flush_ready()' has to be called when finished.*/
static void disp_flush(lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p)
void disp_flush(LV_DISP_TYPE * disp_drv, const lv_area_t * area, lv_COLOR_TYPE * color_p)
{
extern void lcd_fill_array(rt_uint16_t x_start, rt_uint16_t y_start, rt_uint16_t x_end, rt_uint16_t y_end, void *pcolor);
lcd_fill_array(area->x1, area->y1, area->x2, area->y2, color_p);
Expand Down

0 comments on commit 2bcc2f8

Please sign in to comment.