【ST NUCLEO-U5A5ZJ-Q开发板测评】ADC之五 基于touchGFX LCD多彩电压表
<div class='showpostmsg'><p><a href="https://bbs.eeworld.com.cn/thread-1271887-1-1.html">【ST NUCLEO-U5A5ZJ-Q开发板测评】ADC体验之一 </a></p><p><a href="https://bbs.eeworld.com.cn/thread-1271892-1-1.html">【ST NUCLEO-U5A5ZJ-Q开发板测评】ADC体验之二 </a></p>
<p><a href="https://bbs.eeworld.com.cn/thread-1271909-1-1.html">【ST NUCLEO-U5A5ZJ-Q开发板测评】ADC体验之三 </a></p>
<p><a href="https://bbs.eeworld.com.cn/thread-1271722-1-1.html">【ST NUCLEO-U5A5ZJ-Q开发板测评】移植TouchGFX实现数字时钟 </a></p>
<p><a href="https://bbs.eeworld.com.cn/thread-1272049-1-1.html">【ST NUCLEO-U5A5ZJ-Q开发板测评】ADC之四 基于touchGFX的电压表 </a></p>
<p>在上面的几篇文章中,我使用的是OLED屏他是基于sh1106的SPI接口的,只是单色屏,还有像素也非常有限,经过两天的摸索,今天综于把touchGFX移植到了ILI9488这年LCD屏上面。</p>
<p>在前面的基础上,工程做了如下修改:</p>
<p>1、修改spi的时钟极性,原来sh1106的CPOL是HIGH,而ILI9488为LOW,CPHA由2修心为1。</p>
<p> 2、进入touchGFX修改颜色值为RGB565,同时修改像素,如下图所示:</p>
<p> </p>
<p>3、把ili9488的驱动,替换掉sh1106的驱动,修改TouchGFXHAL::flushFrameBuffer函数如以下代码所示:</p>
<pre>
<code>/**
* 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.
*
* @see 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;
for(i=0;i<rect.width;i++)
{
uint8_t r = (buffer & 0xF800) >> 11;
uint8_t g = (buffer & 0x07E0) >> 5;
uint8_t b = buffer & 0x001F;
spisend_buff = (r * 255) / 31;
spisend_buff = (g * 255) / 63;
spisend_buff = (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;
}
}</code></pre>
<p>到此就完成了程序的迁移。</p>
<p>实现的效果如下:</p>
<p> </p>
<p>【总结】</p>
<p>其实touchgfx在显示方便的移植,主要就是获得像素点,然后发送给屏。了解了这个原理之后还是比较容易的。</p>
<p>【感谢】</p>
<p>这次能成功要感谢为篇文章:<a href="https://smallash.blog.csdn.net/article/details/129830406?spm=1001.2101.3001.6650.3&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-3-129830406-blog-117124726.235%5Ev43%5Econtrol&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-3-129830406-blog-117124726.235%5Ev43%5Econtrol&utm_relevant_index=6">基于正点原子F407开发版和SPI接口屏移植touchgfx完整教程(一)_touchgfx 正点原子-CSDN博客</a></p>
<p> </p>
</div><script> var loginstr = '<div class="locked">查看本帖全部内容,请<a href="javascript:;" style="color:#e60000" class="loginf">登录</a>或者<a href="https://bbs.eeworld.com.cn/member.php?mod=register_eeworld.php&action=wechat" style="color:#e60000" target="_blank">注册</a></div>';
if(parseInt(discuz_uid)==0){
(function($){
var postHeight = getTextHeight(400);
$(".showpostmsg").html($(".showpostmsg").html());
$(".showpostmsg").after(loginstr);
$(".showpostmsg").css({height:postHeight,overflow:"hidden"});
})(jQuery);
} </script><script type="text/javascript">(function(d,c){var a=d.createElement("script"),m=d.getElementsByTagName("script"),eewurl="//counter.eeworld.com.cn/pv/count/";a.src=eewurl+c;m.parentNode.insertBefore(a,m)})(document,523)</script> <p>玩屏幕肯定要去学习一下Adobe Illustrator或者PS,自己画原型图~</p>
wangerxian 发表于 2024-2-20 17:26
玩屏幕肯定要去学习一下Adobe Illustrator或者PS,自己画原型图~
<p>恩恩,看来学的东西太多了,如果身体有这样的高手,那多好呀!</p>
lugl4313820 发表于 2024-2-20 17:38
恩恩,看来学的东西太多了,如果身体有这样的高手,那多好呀!
<p>哈哈,只能自己学呀~加油加油!</p>
wangerxian 发表于 2024-2-20 17:40
哈哈,只能自己学呀~加油加油!
<p>不能学太多了,没有这么多的精力了,有些还是给专业的人去干吧!</p>
<p>主要的疑虑就是touchgfx的控制速度与自主的控制速度谁更快 </p>
秦天qintian0303 发表于 2024-2-21 09:14
主要的疑虑就是touchgfx的控制速度与自主的控制速度谁更快
<p>touchgfx的显示,如果屏有同步信号线,是可以做一致的,但是SPI这个屏没有。</p>
<p>TouchGFX只有是LCD屏,都支持吗?有什么要求吗?</p>
怀揣少年梦 发表于 2024-2-22 11:28
TouchGFX只有是LCD屏,都支持吗?有什么要求吗?
<p>都支持的,只要是显示屏就支持,支持i2c、spi、8080接口的都支持。</p>
lugl4313820 发表于 2024-2-22 13:32
都支持的,只要是显示屏就支持,支持i2c、spi、8080接口的都支持。
<p>可以可以</p>
<p>你这是铁了心要搞块万用表啊。<img height="48" src="https://bbs.eeworld.com.cn/static/editor/plugins/hkemoji/sticker/facebook/congra.gif" width="48" /></p>
页:
[1]