一、显示自己的姓名学号
生成字模
找到所需文件
打开文件
将下列函数添加进test.c中
//学号显示函数
void show_my_num(void)
{
GUI_ShowString(15,0,"631807030419",16,1);
}
//姓名显示函数
void show_my_name(void)
{
GUI_ShowCHinese(45,16,16,"小罗",1);
}
修改mian.c如下
#include "delay.h"
#include "sys.h"
#include "oled.h"
#include "gui.h"
#include "test.h"
int main(void)
{
delay_init(); //延时函数初始化
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); //设置NVIc中断分组2:2位抢占优先级,2位响应优先级
OLED_Init(); //初始化OLED
OLED_Clear(0); //清屏,全黑
while(1)
{
TEST_MainPage(); //主页面显示姓名与学号
OLED_Clear(0);
}
}
把之前生成的字模添加到oledfont.h中
"小",0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x11,0x10,0x11,0x08,0x11,0x04,
0x21,0x04,0x21,0x02,0x41,0x02,0x81,0x02,0x01,0x00,0x01,0x00,0x05,0x00,0x02,0x00,/*"小",0*/
"罗",0x00,0x00,0x3F,0xF8,0x24,0x48,0x24,0x48,0x24,0x48,0x3F,0xF8,0x02,0x00,0x04,0x00,
0x0F,0xF0,0x10,0x10,0x68,0x20,0x04,0x40,0x02,0x80,0x03,0x00,0x1C,0x00,0xE0,0x00,/*"罗",1*/
按照如图所示连接
编译并烧录程序,显示结果如下:
二、显示温度与湿度
将所需代码添加到USER中
读取温湿度的代码
void read_AHT20(void)
{
uint8_t i;
for(i=0; i<6; i++)