【ST NUCLEO-U5A5ZJ-Q开发板测评】touchGFX移植中颜色数据获取失败
[复制链接]
【原因】
我申请试用的是移植touchgfx到开发板上。
【已完成的工作】
1、驱动ILI9488屏,因为我已经移植好LVGL的,所以确定已经移植好驱动的。
2、按照官方以及其他的人的经验,我已经配置好touchgfx,touchgfx也已经能够实现刷屏的动作。
【问题】
我在获取屏屏数据并通过ili9488的填充到屏上时,总是刷出黑色的屏,也就是0x00。
【代码】
1、获取屏幕的颜色数据:
void TouchGFXHAL::flushFrameBuffer(const touchgfx::Rect& rect)
{
// Calling parent implementation of flushFrameBuffer(const touchgfx::Rect& rect).
//
// To overwrite the generated implementation, omit call to parent function
// and implemented needed functionality here.
// Please note, HAL::flushFrameBuffer(const touchgfx::Rect& rect) must
// be called to notify the touchgfx framework that flush has been performed.
// To calculate he start adress of rect,
// use advanceFrameBufferToRect(uint8_t* fbPtr, const touchgfx::Rect& rect)
// defined in TouchGFXGeneratedHAL.cpp
__IO uint16_t* ptr;
uint32_t height;
TouchGFXGeneratedHAL::flushFrameBuffer(rect);
for(height=0;height<rect.height; height++)
{
ptr = getClientFrameBuffer() + rect.x + (height + rect.y) * HAL::DISPLAY_WIDTH;//获取一行的颜色数据
mydisp_flush(0,height,320,1, (uint16_t*)ptr); //刷新到屏上
}
}
2、屏刷新函数:
void mydisp_flush(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t * color_p)
{
/*The most simple case (but also the slowest) to put all pixels to the screen one-by-one*/
uint32_t i, n, cnt, buf_size;
uint8_t r,g,b;
setAddrWindow(x, y, w, y+h-1);
n = w*h*3;
//割分发送给屏
if (n <= 65535){
cnt = 1;
buf_size = n;
}
else {
cnt = n/3;
buf_size = 3;
uint8_t min_cnt = n/(65535)+1;
for (i=min_cnt; i < n/3; i++)
{
if(n%i == 0)
{
cnt = i;
buf_size = n/i;
break;
}
}
}
DC_DATA();
CS_A();
while(cnt>0)
{
uint8_t frm_buf[buf_size];
for (i=0; i < buf_size/3; i++)
{
r = (uint8_t)(((uint16_t)color_p&0xF800>>11)*255)/31;
g = (uint8_t)(((uint16_t)color_p&0x07E0>>5)*255)/63;
b = (uint8_t)(((uint16_t)color_p&0x001F)*255)/31;
frm_buf[i*3] = r;
frm_buf[i*3+1] = g;
frm_buf[i*3+2] = b;
color_p++;
}
HAL_SPI_Transmit(&hspi1, frm_buf, buf_size, 10);
cnt -= 1;
}
CS_D();
/*IMPORTANT!!!
*Inform the graphics library that you are ready with the flushing*/
}
程序运行后,屏是黑色的。
如果我把 r=255,g=255, b=255是可以成功的把屏刷成白色。
r = (uint8_t)(((uint16_t)color_p&0xF800>>11)*255)/31;
g = (uint8_t)(((uint16_t)color_p&0x07E0>>5)*255)/63;
b = (uint8_t)(((uint16_t)color_p&0x001F)*255)/31;
希望有大神帮帮我解决这个问题。
|