Improve software 180deg rotation and add LVGL perf monitor

This commit is contained in:
Raphael Coeffic
2022-06-11 15:38:08 +02:00
committed by Raphael Coeffic
parent 06746b4722
commit 96f5621bc5
6 changed files with 70 additions and 16 deletions
+5 -1
View File
@@ -25,7 +25,11 @@
#define configUSE_PREEMPTION 1
#define configUSE_IDLE_HOOK 0
#define configUSE_TICK_HOOK 0
#if defined(COLORLCD)
#define configUSE_TICK_HOOK 1
#else
#define configUSE_TICK_HOOK 0
#endif
#define configCPU_CLOCK_HZ ( SystemCoreClock )
#define configTICK_RATE_HZ ( ( TickType_t ) 1000 )
#define configMAX_PRIORITIES ( 5 )
+5
View File
@@ -143,6 +143,11 @@ if(WINDOWS_INSPECT_BORDERS)
add_definitions(-DWINDOWS_INSPECT_BORDERS)
endif()
option(UI_PERF_MONITOR "Draw frame rate and CPU usage" OFF)
if(UI_PERF_MONITOR)
add_definition(-DUI_PERF_MONITOR)
endif()
# includes libopenui
set(LIBOPENUI_SRC_DIR thirdparty/libopenui)
set(LVGL_SRC_DIR ${LIBOPENUI_SRC_DIR}/thirdparty/lvgl/src)
+2 -5
View File
@@ -62,13 +62,8 @@ extern "C" void keyboardDriverRead(lv_indev_drv_t *drv, lv_indev_data_t *data)
static void copy_ts_to_indev_data(const TouchState &st, lv_indev_data_t *data)
{
#if defined(LCD_VERTICAL_INVERT)
data->point.x = LCD_W - st.x;
data->point.y = LCD_H - st.y;
#else
data->point.x = st.x;
data->point.y = st.y;
#endif
}
static lv_indev_data_t indev_data_backup;
@@ -386,8 +381,10 @@ LvglWrapper::LvglWrapper()
void LvglWrapper::run()
{
#if defined(SIMU)
tmr10ms_t tick = get_tmr10ms();
lv_tick_inc((tick - lastTick) * 10);
lastTick = tick;
#endif
lv_timer_handler();
}
+44 -9
View File
@@ -58,6 +58,41 @@ void lcdSetFlushCb(void (*cb)(lv_disp_drv_t *, uint16_t*, const rect_t&))
static lv_disp_drv_t* refr_disp = nullptr;
#if defined (LCD_VERTICAL_INVERT)
static void buf_rotate_180(lv_area_t * area, uint16_t* color_p)
{
lv_coord_t area_w = lv_area_get_width(area);
lv_coord_t area_h = lv_area_get_height(area);
uint32_t total = area_w * area_h;
/*Swap the beginning and end values*/
uint32_t tmp;
uint32_t* c_tail = (uint32_t*)(color_p + (total & 1));
uint32_t* c_head = (uint32_t*)color_p;
uint32_t i = total/2 - 1, j = 0;
while(i > j) {
tmp = c_tail[i];
c_tail[i] = ((c_head[j] & 0xFFFF0000) >> 16) | ((c_head[j] & 0xFFFF) << 16);
c_head[j] = ((tmp & 0xFFFF0000) >> 16) | ((tmp & 0xFFFF) << 16);
i--;
j++;
}
if (total & 1) {
uint16_t tmp = color_p[i * 2 + 1];
color_p[j * 2] = color_p[i * 2 + 1];
color_p[i * 2 + 1] = tmp;
}
lv_coord_t tmp_coord;
tmp_coord = area->y2;
area->y2 = LCD_H - area->y1 - 1;
area->y1 = LCD_H - tmp_coord - 1;
tmp_coord = area->x2;
area->x2 = LCD_W - area->x1 - 1;
area->x1 = LCD_W - tmp_coord - 1;
}
#endif
static void flushLcd(lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p)
{
lv_area_t refr_area;
@@ -73,12 +108,17 @@ static void flushLcd(lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_
}
#endif
rect_t copy_area = {refr_area.x1, refr_area.y1,
refr_area.x2 - refr_area.x1 + 1,
refr_area.y2 - refr_area.y1 + 1};
if (lcd_flush_cb) {
refr_disp = disp_drv;
#if defined (LCD_VERTICAL_INVERT)
buf_rotate_180(&refr_area, (uint16_t*)color_p);
#endif
rect_t copy_area = {refr_area.x1, refr_area.y1,
refr_area.x2 - refr_area.x1 + 1,
refr_area.y2 - refr_area.y1 + 1};
lcd_flush_cb(disp_drv, (uint16_t*)color_p, copy_area);
} else {
lv_disp_flush_ready(disp_drv);
@@ -105,11 +145,6 @@ void lcdInitDisplayDriver()
disp_drv.full_refresh = 0;
disp_drv.direct_mode = 0;
#if defined (LCD_VERTICAL_INVERT)
disp_drv.rotated = LV_DISP_ROT_180;
disp_drv.sw_rotate = 1;
#endif
// Register the driver and save the created display object
disp = lv_disp_drv_register(&disp_drv);
+5 -1
View File
@@ -268,7 +268,11 @@
*-----------*/
/*1: Show CPU usage and FPS count*/
#define LV_USE_PERF_MONITOR 0
#if !defined(BOOT) && defined(UI_PERF_MONITOR)
#define LV_USE_PERF_MONITOR 1
#else
#define LV_USE_PERF_MONITOR 0
#endif
#if LV_USE_PERF_MONITOR
#define LV_USE_PERF_MONITOR_POS LV_ALIGN_BOTTOM_RIGHT
#endif
+9
View File
@@ -84,3 +84,12 @@ void vApplicationGetTimerTaskMemory( StaticTask_t **ppxTimerTaskTCBBuffer,
#endif // configUSE_TIMERS
#endif // configSUPPORT_STATIC_ALLOCATION
#if configUSE_TICK_HOOK > 0
#include <lvgl/lvgl.h>
void vApplicationTickHook( void )
{
lv_tick_inc(1);
}
#endif