Moved the display initialization code to it's own file as part of some code cleanup
This commit is contained in:
parent
af85b9b594
commit
74d48ada96
103
src/W800 SDK v1.00.08/lvgl/lvgl_port/lv_port_disp.c
Normal file
103
src/W800 SDK v1.00.08/lvgl/lvgl_port/lv_port_disp.c
Normal file
@ -0,0 +1,103 @@
|
||||
/**
|
||||
* @file lv_port_disp.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*Copy this file as "lv_port_disp.c" and set this value to "1" to enable content*/
|
||||
#if 1
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lvgl.h"
|
||||
#include "lcd.h"
|
||||
#include "app_common.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define LVGL_GFX_BUFFER_SIZE (LCD_PIXEL_WIDTH * LCD_PIXEL_HEIGHT / 2)
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static void lvgl_display_flush_cb(lv_disp_drv_t *disp_drv, const lv_area_t *area, lv_color_t *color_p);
|
||||
|
||||
static void lcd_draw_finished_cb(void *arg);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_color_t lvgl_draw_buffer[LVGL_GFX_BUFFER_SIZE];
|
||||
static lv_disp_draw_buf_t lvgl_draw_buffer_dsc;
|
||||
|
||||
static lv_disp_drv_t display_driver;
|
||||
|
||||
/**********************
|
||||
* GLOBAL VARIABLES
|
||||
**********************/
|
||||
/* WARNING : Global object used in gfx_task.c */
|
||||
LCDConfig_t LCDConfig;
|
||||
|
||||
void lv_port_disp_init(void)
|
||||
{
|
||||
/* Create, initialize and register the display driver */
|
||||
lv_disp_drv_init(&display_driver);
|
||||
|
||||
display_driver.hor_res = LCD_PIXEL_WIDTH;
|
||||
display_driver.ver_res = LCD_PIXEL_HEIGHT;
|
||||
|
||||
display_driver.rotated = LV_DISP_ROT_NONE;
|
||||
|
||||
lv_disp_draw_buf_init(&lvgl_draw_buffer_dsc, lvgl_draw_buffer, NULL, LVGL_GFX_BUFFER_SIZE);
|
||||
|
||||
display_driver.draw_buf = &lvgl_draw_buffer_dsc;
|
||||
display_driver.flush_cb = &(lvgl_display_flush_cb);
|
||||
|
||||
/* Initialize the LCD display */
|
||||
lcd_config_init(&LCDConfig);
|
||||
lcd_register_draw_finished_cb(&LCDConfig, &(lcd_draw_finished_cb), &display_driver);
|
||||
|
||||
#if defined(W800)
|
||||
LCDConfig.LCDPWMBacklightPin = WM_IO_PA_07;
|
||||
LCDConfig.LCDClockPin = WM_IO_PB_06;
|
||||
LCDConfig.LCDDataPin = WM_IO_PB_07;
|
||||
LCDConfig.LCDChipSelectPin = WM_IO_PB_10;
|
||||
LCDConfig.LCDDataCommandPin = WM_IO_PB_08;
|
||||
LCDConfig.LCDResetPin = WM_IO_PB_09;
|
||||
#elif defined(W801)
|
||||
LCDConfig.LCDPWMBacklightPin = WM_IO_PA_08;
|
||||
LCDConfig.LCDClockPin = WM_IO_PA_09;
|
||||
LCDConfig.LCDDataPin = WM_IO_PA_10;
|
||||
LCDConfig.LCDChipSelectPin = WM_IO_PA_13;
|
||||
LCDConfig.LCDDataCommandPin = WM_IO_PA_11;
|
||||
LCDConfig.LCDResetPin = WM_IO_PA_12;
|
||||
#endif
|
||||
lcd_init(&LCDConfig);
|
||||
|
||||
if (!lv_disp_drv_register(&display_driver))
|
||||
{
|
||||
APP_LOG_ERROR("Failed to register display driver");
|
||||
}
|
||||
}
|
||||
|
||||
static void lvgl_display_flush_cb(lv_disp_drv_t *disp_drv, const lv_area_t *area, lv_color_t *color_p)
|
||||
{
|
||||
lcd_draw_rect_frame(&LCDConfig, area->x1, area->y1, area->x2 - area->x1 + 1, area->y2 - area->y1 + 1, (uint8_t *)color_p);
|
||||
/* lv_disp_flush_ready is called in the LCD driver registered callback */
|
||||
}
|
||||
|
||||
static void lcd_draw_finished_cb(void *arg)
|
||||
{
|
||||
lv_disp_flush_ready((lv_disp_drv_t *)arg);
|
||||
}
|
||||
|
||||
#else /*Enable this file at the top*/
|
||||
|
||||
/*This dummy typedef exists purely to silence -Wpedantic.*/
|
||||
typedef int keep_pedantic_happy;
|
||||
#endif
|
44
src/W800 SDK v1.00.08/lvgl/lvgl_port/lv_port_disp.h
Normal file
44
src/W800 SDK v1.00.08/lvgl/lvgl_port/lv_port_disp.h
Normal file
@ -0,0 +1,44 @@
|
||||
|
||||
/**
|
||||
* @file lv_port_disp.h
|
||||
*
|
||||
*/
|
||||
|
||||
/*Copy this file as "lv_port_disp.h" and set this value to "1" to enable content*/
|
||||
#if 1
|
||||
|
||||
#ifndef LV_PORT_DISP_H
|
||||
#define LV_PORT_DISP_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
void lv_port_disp_init(void);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_PORT_DISP_H*/
|
||||
|
||||
#endif /*Disable/Enable content*/
|
Loading…
Reference in New Issue
Block a user