理解OLED屏显和汉字点阵编码原理,使用STM32F103的SPI或IIC接口实现以下功能:显示AHT20的温度和湿度
一、前情提要
在之前的章节中,我实现了基于STM32的基于I2C协议实现温湿度采集,在这一篇博客之中:https://blog.csdn.net/chelseafall/article/details/121443439?spm=1001.2014.3001.5501
还实现了使用OLED显示屏显示数据,在这一篇博客之中:
https://blog.csdn.net/chelseafall/article/details/121449456
现在,我需要将两者结合,实现在OLED显示屏上显示使用AHT20采集到的温湿度信息。需要在实现串口显示的工程中,添加有关于OLED显示的代码。
二、使用OLED显示屏显示温湿度采集信息
1、下载代码
在这个链接中下载OLED数据显示的代码,下载框选出的代码:
https://github.com/Sunlight-Dazzling/stm32_AHT20_OLED/tree/main/User/usart
下载完成后,将代码文件添加到之前串口输出AHT20的工程中的USER
中
2、修改代码
(1)温湿度显示代码
首先是显示温湿度的代码,如下
void read_AHT20(void)
{
uint8_t i;
for(i=0; i<6; i++)
{
readByte[i]=0;
}
I2C_Start();
I2C_WriteByte(0x71);
ack_status = Receive_ACK();
readByte[0]= I2C_ReadByte();
Send_ACK();
readByte[1]= I2C_ReadByte();
Send_ACK();
readByte[2]= I2C_ReadByte();
Send_ACK();
readByte[3]= I2C_ReadByte();
Send_ACK();
readByte[4