【ST NUCLEO-U5A5ZJ-Q开发板测评】ADC体验之一
【ST NUCLEO-U5A5ZJ-Q开发板测评】ADC体验之二
【ST NUCLEO-U5A5ZJ-Q开发板测评】ADC体验之三
【ST NUCLEO-U5A5ZJ-Q开发板测评】移植TouchGFX实现数字时钟
【ST NUCLEO-U5A5ZJ-Q开发板测评】ADC之四 基于touchGFX的电压表
在上面的几篇文章中,我使用的是OLED屏他是基于sh1106的SPI接口的,只是单色屏,还有像素也非常有限,经过两天的摸索,今天综于把touchGFX移植到了ILI9488这年LCD屏上面。
在前面的基础上,工程做了如下修改:
1、修改spi的时钟极性,原来sh1106的CPOL是HIGH,而ILI9488为LOW,CPHA由2修心为1。
2、进入touchGFX修改颜色值为RGB565,同时修改像素,如下图所示:
3、把ili9488的驱动,替换掉sh1106的驱动,修改TouchGFXHAL::flushFrameBuffer函数如以下代码所示:
/**
* This function is called whenever the framework has performed a partial draw.
*
* @param rect The area of the screen that has been drawn, expressed in absolute coordinates.
*
* [url=home.php?mod=space&uid=418085]@see[/url] flushFrameBuffer().
*/
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
TouchGFXGeneratedHAL::flushFrameBuffer(rect);
// const unsigned char* bitmap = (const unsigned char*) getClientFrameBuffer();
// SSD1306_Fill(0x00);
// SSD1306_DrawBitmap(0, 0, bitmap, 128, 64, 0x01);
// SSD1306_UpdateScreen();
volatile uint16_t* buffer = getClientFrameBuffer()+(rect.y*320)+rect.x;
uint16_t height,i;
setAddrWindow(rect.x,rect.y,rect.x+rect.width-1,rect.y+rect.height-1);
DC_DATA();
CS_A();
for(height=0;height<rect.height;height++)
{
//定义�?个buff
uint8_t spisend_buff[rect.width*3];
for(i=0;i<rect.width;i++)
{
uint8_t r = (buffer[i] & 0xF800) >> 11;
uint8_t g = (buffer[i] & 0x07E0) >> 5;
uint8_t b = buffer[i] & 0x001F;
spisend_buff[i*3] = (r * 255) / 31;
spisend_buff[i*3+1] = (g * 255) / 63;
spisend_buff[i*3+2] = (b * 255) / 31;
}
ILI9488_Disp.state = ILI9488_STATE_BUSY;
HAL_SPI_Transmit_DMA(&hspi1, spisend_buff,rect.width*3);
while(ILI9488_Disp.state == ILI9488_STATE_BUSY);
buffer += DISPLAY_WIDTH;
}
}
到此就完成了程序的迁移。
实现的效果如下:
【总结】
其实touchgfx在显示方便的移植,主要就是获得像素点,然后发送给屏。了解了这个原理之后还是比较容易的。
【感谢】
这次能成功要感谢为篇文章:基于正点原子F407开发版和SPI接口屏移植touchgfx完整教程(一)_touchgfx 正点原子-CSDN博客