Refresh screen via call back set by lcdSetFlushCb
This commit is contained in:
committed by
Raphael Coeffic
parent
66cdab37ff
commit
db684893e2
@@ -50,14 +50,19 @@ static lv_area_t screen_area = {
|
|||||||
0, 0, LCD_W-1, LCD_H-1
|
0, 0, LCD_W-1, LCD_H-1
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Call backs
|
||||||
static void (*lcd_wait_cb)(lv_disp_drv_t *) = nullptr;
|
static void (*lcd_wait_cb)(lv_disp_drv_t *) = nullptr;
|
||||||
|
static void (*lcd_flush_cb)(lv_disp_drv_t *, uint16_t* buffer, const rect_t& area) = nullptr;
|
||||||
|
|
||||||
void lcdSetWaitCb(void (*cb)(lv_disp_drv_t *))
|
void lcdSetWaitCb(void (*cb)(lv_disp_drv_t *))
|
||||||
{
|
{
|
||||||
lcd_wait_cb = cb;
|
lcd_wait_cb = cb;
|
||||||
}
|
}
|
||||||
|
|
||||||
void newLcdRefresh(uint16_t* buffer, const rect_t& copy_area);
|
void lcdSetFlushCb(void (*cb)(lv_disp_drv_t *, uint16_t*, const rect_t&))
|
||||||
|
{
|
||||||
|
lcd_flush_cb = cb;
|
||||||
|
}
|
||||||
|
|
||||||
static void flushLcd(lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p)
|
static void flushLcd(lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p)
|
||||||
{
|
{
|
||||||
@@ -76,7 +81,11 @@ static void flushLcd(lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_
|
|||||||
refr_area.x2 - refr_area.x1 + 1,
|
refr_area.x2 - refr_area.x1 + 1,
|
||||||
refr_area.y2 - refr_area.y1 + 1};
|
refr_area.y2 - refr_area.y1 + 1};
|
||||||
|
|
||||||
newLcdRefresh((uint16_t*)color_p, copy_area);
|
if (lcd_flush_cb) {
|
||||||
|
lcd_flush_cb(disp_drv, (uint16_t*)color_p, copy_area);
|
||||||
|
} else {
|
||||||
|
lv_disp_flush_ready(disp_drv);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void lcdInitDisplayDriver()
|
void lcdInitDisplayDriver()
|
||||||
|
|||||||
@@ -41,7 +41,9 @@
|
|||||||
struct _lv_disp_drv_t;
|
struct _lv_disp_drv_t;
|
||||||
typedef _lv_disp_drv_t lv_disp_drv_t;
|
typedef _lv_disp_drv_t lv_disp_drv_t;
|
||||||
|
|
||||||
|
// Call backs
|
||||||
void lcdSetWaitCb(void (*cb)(lv_disp_drv_t *));
|
void lcdSetWaitCb(void (*cb)(lv_disp_drv_t *));
|
||||||
|
void lcdSetFlushCb(void (*cb)(lv_disp_drv_t *, uint16_t*, const rect_t&));
|
||||||
|
|
||||||
// Init LVGL and its display driver
|
// Init LVGL and its display driver
|
||||||
void lcdInitDisplayDriver();
|
void lcdInitDisplayDriver();
|
||||||
|
|||||||
@@ -43,7 +43,22 @@
|
|||||||
#define VFP 2
|
#define VFP 2
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
uint8_t LCD_FRAME_BUFFER[DISPLAY_BUFFER_SIZE * sizeof(pixel_t)] __SDRAM;
|
static uint8_t LCD_FRAME_BUFFER[DISPLAY_BUFFER_SIZE * sizeof(pixel_t)] __SDRAM;
|
||||||
|
|
||||||
|
static uint16_t* next_frame_buffer;
|
||||||
|
static rect_t next_frame_area;
|
||||||
|
|
||||||
|
static void startLcdRefresh(lv_disp_drv_t *disp_drv, uint16_t *buffer,
|
||||||
|
const rect_t ©_area)
|
||||||
|
{
|
||||||
|
(void)disp_drv;
|
||||||
|
|
||||||
|
next_frame_buffer = buffer;
|
||||||
|
next_frame_area = copy_area;
|
||||||
|
|
||||||
|
// Enable line IRQ
|
||||||
|
LTDC_ITConfig(LTDC_IER_LIE, ENABLE);
|
||||||
|
}
|
||||||
|
|
||||||
inline void LCD_NRST_LOW()
|
inline void LCD_NRST_LOW()
|
||||||
{
|
{
|
||||||
@@ -321,6 +336,8 @@ void lcdInit()
|
|||||||
|
|
||||||
// Enable LCD display
|
// Enable LCD display
|
||||||
LTDC_Cmd(ENABLE);
|
LTDC_Cmd(ENABLE);
|
||||||
|
|
||||||
|
lcdSetFlushCb(startLcdRefresh);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DMAFillRect(uint16_t *dest, uint16_t destw, uint16_t desth, uint16_t x,
|
void DMAFillRect(uint16_t *dest, uint16_t destw, uint16_t desth, uint16_t x,
|
||||||
@@ -575,9 +592,6 @@ void lcdCopy(void * dest, void * src)
|
|||||||
while (DMA2D_GetFlagStatus(DMA2D_FLAG_TC) == RESET);
|
while (DMA2D_GetFlagStatus(DMA2D_FLAG_TC) == RESET);
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint16_t* next_frame_buffer;
|
|
||||||
static rect_t next_frame_area;
|
|
||||||
|
|
||||||
extern "C" void LTDC_IRQHandler(void)
|
extern "C" void LTDC_IRQHandler(void)
|
||||||
{
|
{
|
||||||
// clear interrupt flag
|
// clear interrupt flag
|
||||||
@@ -594,12 +608,3 @@ extern "C" void LTDC_IRQHandler(void)
|
|||||||
lcdFlushed();
|
lcdFlushed();
|
||||||
}
|
}
|
||||||
|
|
||||||
void newLcdRefresh(uint16_t * buffer, const rect_t& copy_area)
|
|
||||||
{
|
|
||||||
next_frame_buffer = buffer;
|
|
||||||
next_frame_area = copy_area;
|
|
||||||
|
|
||||||
// Enable line IRQ
|
|
||||||
LTDC_ITConfig(LTDC_IER_LIE, ENABLE);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,22 @@
|
|||||||
#include "libopenui_config.h"
|
#include "libopenui_config.h"
|
||||||
#include "lcd.h"
|
#include "lcd.h"
|
||||||
|
|
||||||
uint8_t LCD_FRAME_BUFFER[DISPLAY_BUFFER_SIZE * sizeof(pixel_t)] __SDRAM;
|
static uint8_t LCD_FRAME_BUFFER[DISPLAY_BUFFER_SIZE * sizeof(pixel_t)] __SDRAM;
|
||||||
|
|
||||||
|
static uint16_t* next_frame_buffer;
|
||||||
|
static rect_t next_frame_area;
|
||||||
|
|
||||||
|
static void startLcdRefresh(lv_disp_drv_t *disp_drv, uint16_t *buffer,
|
||||||
|
const rect_t ©_area)
|
||||||
|
{
|
||||||
|
(void)disp_drv;
|
||||||
|
|
||||||
|
next_frame_buffer = buffer;
|
||||||
|
next_frame_area = copy_area;
|
||||||
|
|
||||||
|
// Enable line IRQ
|
||||||
|
LTDC_ITConfig(LTDC_IER_LIE, ENABLE);
|
||||||
|
}
|
||||||
|
|
||||||
lcdSpiInitFucPtr lcdInitFunction;
|
lcdSpiInitFucPtr lcdInitFunction;
|
||||||
lcdSpiInitFucPtr lcdOffFunction;
|
lcdSpiInitFucPtr lcdOffFunction;
|
||||||
@@ -1312,6 +1327,8 @@ void lcdInit(void)
|
|||||||
LCD_LayerInit();
|
LCD_LayerInit();
|
||||||
LTDC_Cmd(ENABLE);
|
LTDC_Cmd(ENABLE);
|
||||||
LTDC_ReloadConfig(LTDC_IMReload);
|
LTDC_ReloadConfig(LTDC_IMReload);
|
||||||
|
|
||||||
|
lcdSetFlushCb(startLcdRefresh);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DMAFillRect(uint16_t *dest, uint16_t destw, uint16_t desth, uint16_t x,
|
void DMAFillRect(uint16_t *dest, uint16_t destw, uint16_t desth, uint16_t x,
|
||||||
@@ -1566,9 +1583,6 @@ void lcdCopy(void * dest, void * src)
|
|||||||
while (DMA2D_GetFlagStatus(DMA2D_FLAG_TC) == RESET);
|
while (DMA2D_GetFlagStatus(DMA2D_FLAG_TC) == RESET);
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint16_t* next_frame_buffer;
|
|
||||||
static rect_t next_frame_area;
|
|
||||||
|
|
||||||
extern "C" void LTDC_IRQHandler(void)
|
extern "C" void LTDC_IRQHandler(void)
|
||||||
{
|
{
|
||||||
// clear interrupt flag
|
// clear interrupt flag
|
||||||
@@ -1584,12 +1598,3 @@ extern "C" void LTDC_IRQHandler(void)
|
|||||||
// TODO: call on "Transfer Complete" IRQ
|
// TODO: call on "Transfer Complete" IRQ
|
||||||
lcdFlushed();
|
lcdFlushed();
|
||||||
}
|
}
|
||||||
|
|
||||||
void newLcdRefresh(uint16_t * buffer, const rect_t& copy_area)
|
|
||||||
{
|
|
||||||
next_frame_buffer = buffer;
|
|
||||||
next_frame_area = copy_area;
|
|
||||||
|
|
||||||
// Enable line IRQ
|
|
||||||
LTDC_ITConfig(LTDC_IER_LIE, ENABLE);
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -146,13 +146,6 @@ static void* bootloaderThread(void*)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void lcdExitHandler(lv_disp_drv_t*)
|
|
||||||
{
|
|
||||||
if (simu_shutdown) {
|
|
||||||
lcdFlushed();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void simuStart(bool tests, const char * sdPath, const char * settingsPath)
|
void simuStart(bool tests, const char * sdPath, const char * settingsPath)
|
||||||
{
|
{
|
||||||
if (simu_running)
|
if (simu_running)
|
||||||
@@ -211,8 +204,6 @@ void simuStart(bool tests, const char * sdPath, const char * settingsPath)
|
|||||||
try {
|
try {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
lcdSetWaitCb(lcdExitHandler);
|
|
||||||
|
|
||||||
#if !defined(SIMU_BOOTLOADER)
|
#if !defined(SIMU_BOOTLOADER)
|
||||||
simuMain();
|
simuMain();
|
||||||
#else
|
#else
|
||||||
|
|||||||
@@ -54,7 +54,9 @@ void lcdRefresh()
|
|||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
void newLcdRefresh(uint16_t *buffer, const rect_t& copy_area)
|
#include <lvgl/lvgl.h>
|
||||||
|
|
||||||
|
static void simuRefreshLcd(lv_disp_drv_t * disp_drv, uint16_t *buffer, const rect_t& copy_area)
|
||||||
{
|
{
|
||||||
#if defined(LCD_VERTICAL_INVERT)
|
#if defined(LCD_VERTICAL_INVERT)
|
||||||
coord_t x1 = LCD_W - copy_area.w - copy_area.x;
|
coord_t x1 = LCD_W - copy_area.w - copy_area.x;
|
||||||
@@ -84,13 +86,28 @@ void newLcdRefresh(uint16_t *buffer, const rect_t& copy_area)
|
|||||||
dst += LCD_W - copy_area.w;
|
dst += LCD_W - copy_area.w;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mark screen dirty for async refresh
|
if (lv_disp_flush_is_last(disp_drv)) {
|
||||||
simuLcdRefresh = true;
|
// Mark screen dirty for async refresh
|
||||||
|
simuLcdRefresh = true;
|
||||||
|
} else {
|
||||||
|
lv_disp_flush_ready(disp_drv);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extern bool simu_shutdown;
|
||||||
|
|
||||||
|
static void simuLcdExitHandler(lv_disp_drv_t* disp_drv)
|
||||||
|
{
|
||||||
|
if (simu_shutdown) {
|
||||||
|
lv_disp_flush_ready(disp_drv);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void lcdInit()
|
void lcdInit()
|
||||||
{
|
{
|
||||||
memset(simuLcdBuf, 0, sizeof(simuLcdBuf));
|
memset(simuLcdBuf, 0, sizeof(simuLcdBuf));
|
||||||
|
lcdSetWaitCb(simuLcdExitHandler);
|
||||||
|
lcdSetFlushCb(simuRefreshLcd);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DMAFillRect(uint16_t *dest, uint16_t destw, uint16_t desth, uint16_t x,
|
void DMAFillRect(uint16_t *dest, uint16_t destw, uint16_t desth, uint16_t x,
|
||||||
|
|||||||
Reference in New Issue
Block a user