目录
1. 颜色深度
2. 更新disp_init
3. 更新disp_flush
4. 改为IPA更新数据
5. 死机问题
学习过程中发现GD32平台的显示效果不佳,而且会出现死机的问题,需要优化一下平台代码。
1. 颜色深度
修改颜色深度为32bit。
#define LV_COLOR_DEPTH 32
2. 更新disp_init
修改GD32F450图层格式
static void disp_init(void)
{
/*You code here*/
lv_color_t *pTFTBuf = (lv_color_t *)GUI_TFT_BUF_START;
tliLayer_t layer;
layer.alpha = 0xFF;
layer.bufAddr = (uint32_t)pTFTBuf;
layer.defalutColor = 0x00FFFFFF;
layer.format = FORMAT_ARGB8888;
layer.x = 0;
layer.y = 0;
layer.w = TFT_WIDTH;
layer.h = TFT_HEIGHT;
tliLayerInit(0, layer, 1);
}
3. 更新disp_flush
static void disp_flush(lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p)
{
/*The most simple case (but also the slowest) to put all pixels to the screen one-by-one*/
int32_t x;
int32_t y;
lv_color_t *pTFTBuf = (lv_color_t *)GUI_TFT_BUF_START;
//Printf("draw:(%d, %d) - (%d, %d)\n", area->x1, area->y1, area->x2, area->y2);
for(y = area->y1; y <= area->y2; y++) {
for(x = area->x1; x <= area->x2; x++) {
/*Put a pixel to the display. For example:*/
/*put_px(x, y, *color_p)*/
(*(lv_color_t *)(pTFTBuf + y * TFT_WIDTH + x)).full = (*color_p).full;
color_p++;
}
}
/*IMPORTANT!!!
*Inform the graphics library that you are ready with the flushing*/
lv_disp_flush_ready(disp_drv);
}
将颜色更新部分改为lv_color_t格式。
这时候发现颜色不对,显示效果还是很差。
调试这部分发现GD32F450使用SDRAM的情况下,SDRAM部分还有问题,导致显存数据不对,显示的效果才差。需要将SDRAM的时钟配置为3个HCLK。
4. 改为IPA更新数据
static void disp_flush(lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p)
{
ipaBG_t bgSetting;
ipaFG_t fgSetting;
lv_color_t *pTFTBuf = (lv_color_t *)GUI_TFT_BUF_START;
ipaSetConvertMode(IPA_CONVERT_MODE_DIRECT);
bgSetting.addr = (uint32_t)pTFTBuf;
bgSetting.preColor = 0xFF0000FF;
bgSetting.xOffset = area->x1;
bgSetting.yOffset = area->y1;
bgSetting.w = (area->x2 - area->x1 + 1);
bgSetting.h = (area->y2 - area->y1 + 1);
ipaConfigBg(0, bgSetting);
fgSetting.addr = (uint32_t)color_p;
fgSetting.offset = 0;
fgSetting.format = FORMAT_ARGB8888;
fgSetting.alphaAlgorithm = 0;
fgSetting.preColor = 0;
fgSetting.w = (area->x2 - area->x1 + 1);
fgSetting.h = (area->y2 - area->y1 + 1);
ipaConfigFg(fgSetting);
ipaEnable(1);
/*IMPORTANT!!!
*Inform the graphics library that you are ready with the flushing*/
lv_disp_flush_ready(disp_drv);
}
5. 死机问题
调试发现死机是增加Group(lv_indev_set_group(indev_keypad, groupRect);这句引起的)造成的。
groupRect = lv_group_create();
lv_indev_set_group(indev_keypad, groupRect);
lv_group_add_obj(groupRect, obj1);
lv_group_add_obj(groupRect, obj2);
lv_group_add_obj(groupRect, obj3);
结果发现没有调用lv_port_indev_init初始化输入设备。