STM32——OLED菜单

文章目录

  • 一.补充
  • 二. 二级菜单代码

简介:首先在我的51 I2C里面有OLED详细讲解,本期代码从51OLED基础上移植过来的,可以先看完那篇文章,在看这个,然后按键我是用的定时器扫描不会堵塞程序,可以翻开我的文章有单独的定时器按键扫描,DHT11文章也有,我的菜单从一级界面点进去二级界面,二级界面开启的内容,退出到一级界面后,会保留二级界面开启的功能并且再一次从一级界面进入二级界面后,页面保留之前开启部分的页面,然后功能之间互不影响,标志位有点多,看完肯定对标志位运用更加熟悉,看完以后开发三级四级也是很简单,思路不堵塞。

一.补充

这里补充OLED颜色反转,怎么取模
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

二. 二级菜单代码

main.c

#include "stm32f10x.h"                  // Device header
#include "OLED.h"
#include "Key.h"
#include "LED.h"
#include "Motor.h"
#include "Timer.h"
#include "Delay.h"
#include "Dht11.h"
#include "OLEDShow.h"int32_t Beep_time=0;//蜂鸣器定时器标志位uint8_t flag =1;//显示哪页OLED标志位,一级OLED按键可以向上向下移动
uint8_t uuflag=0;//多级菜单标志位,决定几级菜单
int8_t Speed;//电机速度值
uint8_t fsflag=0;//风扇打开或者关闭标志位
uint8_t fsclose=0;//风扇打开或者关闭决定转速标志位
uint8_t LEDGreenflag=0;//绿灯开关标志位
uint8_t LEDRedflag=0;//红灯开关标志位
uint8_t LLflag =0;//记录绿灯开关标志位
uint8_t PPflag =0;//记录红灯开关标志位uint8_t tuichudata=0;//从一级点进去二级实现红绿灯功能再退出再进入,保留之前的OLED页面
uint8_t fstuichudata=0;//从一级点进去二级实现风扇功能再退出再进入,保留之前的OLED页面uint8_t T_flag =0;//DHT11模块是否启用标志位/*主界面一级界面
按键零作用:向下选择
按键一作用:向上选择
按键二作用:确定选择颜色灯二级界面
初始界面-->	*红灯:关绿灯:关按键零作用:开关绿灯--->对红灯不影响
按键一作用:开关红灯--->对绿灯不影响
按键三作用:退出,保留灯的状态和使用的页面温湿度二级界面
初始界面-->温湿度显示数据
按键三作用:退出风扇开关选择二级界面
初始界面-->风扇:关,转速0
按键零作用:打开风扇或者关闭风扇
按键一作用:进行以20数值增加风扇转速,如果风扇处于关闭状态,则按键一按下还是0
按键二作用:进行以20数值减少风扇转速,如果风扇处于关闭状态,则按键一按下还是0
按键三作用:退出和使用的页面*/void Key_Show1(void)//一级界面
{if(uuflag ==0)
{switch(KeyFlag)//按键短按,按下即可开始实现功能,不用松手{case KEY0_PRES://1,按键0,向下{++flag;if(flag == 1){Oled_clear();Oledshow1();//光标选中选择灯颜色}if(flag == 2){Oled_clear();Oledshow2();//光标选中查看温度}if(flag == 3){Oled_clear();Oledshow3();//光标选中风扇开关选择}if(flag ==4){Oled_clear();Oledshow1();//光标选中选择灯颜色flag =1;}KeyFlag = 0;//注意按键标志清零,防止程序跑飞}break;case KEY1_PRES://2,按键1,向上{--flag;if(flag == 0){Oled_clear();Oledshow3();//光标选中风扇开关选择flag =3;}if(flag == 1){Oled_clear();Oledshow1();//光标选中选择灯颜色}if(flag == 2){Oled_clear();Oledshow2();//光标选中查看温度}if(flag == 3){Oled_clear();Oledshow3();//光标选中风扇开关选择}if(flag ==4){Oled_clear();Oledshow1();//光标选中选择灯颜色flag =1;}KeyFlag = 0;//注意按键标志清零,防止程序跑飞						}break;case KEY2_PRES:	//3,按键2,确定{if(flag == 1)//颜色灯,二级界面从这里标志位确定更新新的界面,后续添加其他一级界面确定,flag=其他等等{if(tuichudata == 0)//从一级界面点进去二级界面之后再一次退出出来,然后第二次点进去的二级界面保留之前二级页面的状态{Oled_clear();Oledshow4();//红灯关和绿灯关}if(tuichudata == 1){Oled_clear();Oledshow6();}if(tuichudata == 2){Oled_clear();Oledshow8();}if(tuichudata == 3){Oled_clear();Oledshow15();}if(tuichudata == 4){Oled_clear();Oledshow17();}if(tuichudata == 5){Oled_clear();Oledshow5();}if(tuichudata == 6){Oled_clear();Oledshow14();}if(tuichudata == 7){Oled_clear();Oledshow16();}uuflag=1;//颜色灯标志位}if(flag == 2)//查看温度,二级界面从这里标志位确定更新新的界面,后续添加其他一级界面确定,flag=其他等等{Oled_clear();Oledshow13();//温湿度模块显示数据T_flag = 1;    //温湿度标志位,让按键二确认之后置1,以便在主函数循环里面2s检测一次DHT11模块,因为按键按下松开后只能检测一次uuflag=2;//温湿度标志位}if(flag == 3)//风扇开关选择,二级界面从这里标志位确定更新新的界面,后续添加其他一级界面确定,flag=其他等等{if(fstuichudata ==0)//从一级界面点进去二级界面之后再一次退出出来,然后第二次点进去的二级界面保留之前二级页面的状态{Oled_clear();Oledshow9();//风扇关和转速数值fsclose =2;//风扇关着}if(fstuichudata ==1){Oled_clear();Oledshow10();//风扇开,初始转速100fsclose =1;//风扇开着}if(fstuichudata ==3){Oled_clear();Oledshow11();//风扇开转速Oled_8_16A(48,2,Speed/100%10);Oled_8_16A(56,2,Speed/10%10);Oled_8_16A(64,2,Speed/1%10);fsclose =1;//风扇开着}if(fstuichudata ==4){Oled_clear();Oledshow12();//风扇关转速0fsclose =2;//风扇关着}if(fstuichudata ==5)//{Oled_clear();Oledshow11();//风扇开转速Oled_8_16A(48,2,Speed/100%10);Oled_8_16A(56,2,Speed/10%10);Oled_8_16A(64,2,Speed/1%10);fsclose =1;//风扇开着}if(fstuichudata ==6){Oled_clear();Oledshow12();//风扇关转速0fsclose =2;//风扇开着}uuflag=3;//风扇开关标志位}KeyFlag = 0;//注意按键标志清零,防止程序跑飞			}break;}}
}void Key_show2(void)//二级界面
{		if(uuflag == 1)//选择灯颜色二级界面功能,后续可添加其他二级界面,用uuflag=其他判断{switch(KeyFlag){case KEY0_PRES://1,按键0,开绿灯{if(LEDGreenflag==0 & PPflag==0)//绿灯开 | 红灯关{// 红灯:关//*绿灯:开(颜色反转)Oledshow6();LED_Green=0;++LEDGreenflag;LLflag=1;//绿灯开tuichudata = 1;//从一级界面点进去二级界面之后再一次退出出来,然后第二次点进去的二级界面保留之前二级页面的状态}else if(LEDGreenflag==1 & PPflag==0)//绿灯关 | 红灯关{// 红灯:关//*绿灯:关(颜色反转)Oledshow8();LED_Green =1;//绿灯关LEDGreenflag =0;LLflag=0;//绿灯关tuichudata = 2;//从一级界面点进去二级界面之后再一次退出出来,然后第二次点进去的二级界面保留之前二级页面的状态}if(LEDGreenflag==0 & PPflag==1)//绿灯开 | 红灯开{// 红灯:开//*绿灯:开(颜色反转)Oledshow15();LED_Green=0;LEDGreenflag=1;LLflag=1;//绿灯开tuichudata = 3;//从一级界面点进去二级界面之后再一次退出出来,然后第二次点进去的二级界面保留之前二级页面的状态}else if(LEDGreenflag==1 & PPflag==1)//绿灯关 | 红灯开{// 红灯:开//*绿灯:关(颜色反转)Oledshow17();LED_Green =1;LEDGreenflag =0;LLflag=0;//绿灯关tuichudata = 4;//从一级界面点进去二级界面之后再一次退出出来,然后第二次点进去的二级界面保留之前二级页面的状态}KeyFlag = 0;//注意按键标志清零,防止程序跑飞		}break;case KEY1_PRES://2,按键1//开红灯{if(LEDRedflag ==0 & LLflag==0)//红灯开 | 绿灯关{//*红灯:开(颜色反转)// 绿灯:关Oledshow5();LED_Red = 0;++LEDRedflag;PPflag=1;//红灯开tuichudata = 5;//从一级界面点进去二级界面之后再一次退出出来,然后第二次点进去的二级界面保留之前二级页面的状态}else if(LEDRedflag ==1 & LLflag==0)//红灯关 | 绿灯关{//*红灯:关(颜色反转)// 绿灯:关Oledshow7();LED_Red = 1;LEDRedflag=0;PPflag=0;//红灯关tuichudata = 0;//从一级界面点进去二级界面之后再一次退出出来,然后第二次点进去的二级界面保留之前二级页面的状态}if(LEDRedflag ==0 & LLflag==1)//红灯开 | 绿灯开{//*红灯:开(颜色反转)// 绿灯:开Oledshow14();LED_Red = 0;LEDRedflag=1;PPflag=1;//红灯开tuichudata = 6;//从一级界面点进去二级界面之后再一次退出出来,然后第二次点进去的二级界面保留之前二级页面的状态}else if(LEDRedflag ==1 & LLflag==1)//红灯关 | 绿灯开{//*红灯:关(颜色反转)// 绿灯:开Oledshow16();LED_Red = 1;LEDRedflag=0;PPflag=0;//红灯关tuichudata = 7;//从一级界面点进去二级界面之后再一次退出出来,然后第二次点进去的二级界面保留之前二级页面的状态}KeyFlag = 0;//注意按键标志清零,防止程序跑飞		}break;case KEY3_PRES://4,按键三,退出{	Oled_clear();Oledshow1();//一级界面flag = 1;uuflag =0;KeyFlag = 0;//注意按键标志清零,防止程序跑飞		}break;}}if(uuflag == 2)//查看温度二级界面功能,后续可添加其他二级界面,用uuflag=其他判断{switch(KeyFlag){case KEY3_PRES://4,按键三,退出{	Oled_clear();Oledshow18();//一级界面flag = 1;uuflag =0;T_flag = 0;//温湿度模块退出检测KeyFlag = 0;//注意按键标志清零,防止程序跑飞		}break;}}if(uuflag == 3)//风扇开关选择二级界面功能,后续可添加其他二级界面,用uuflag=其他判断{switch(KeyFlag){case KEY0_PRES://1,按键0,风扇:开  转速:100{					if(fsflag ==0){Oled_clear();Oledshow10();//风扇开,初始转速100Motor_SetSpeed(100);++fsflag;fsclose =1;//风扇开着fstuichudata = 1 ;//从一级界面点进去二级界面之后再一次退出出来,然后第二次点进去的二级界面保留之前二级页面的状态}else if(fsflag ==1)//这里不能用if否则上面的fsflag会立马进入这个条件{Oled_clear();Oledshow9();//风扇关,初始转速0Motor_SetSpeed(0);fsflag =0;fsclose =2;//风扇关着fstuichudata =0 ;//从一级界面点进去二级界面之后再一次退出出来,然后第二次点进去的二级界面保留之前二级页面的状态}KeyFlag = 0;//注意按键标志清零,防止程序跑飞		}break;case KEY1_PRES://2,按键1,风扇:开  转速增加,每次增加20{if(fsclose ==1)//如果第一行的风扇开着,这里就可以不断调节转速{Oled_clear();Oledshow11();//风扇开转速fsflag =1;//让点按键一的时候增加风扇转速,如果点按键零可以直接关掉风扇Speed +=20;if(Speed > 100){Speed = 20;}Motor_SetSpeed(Speed);Oled_8_16A(48,2,Speed/100%10);Oled_8_16A(56,2,Speed/10%10);Oled_8_16A(64,2,Speed/1%10);fstuichudata =3;//从一级界面点进去二级界面之后再一次退出出来,然后第二次点进去的二级界面保留之前二级页面的状态}else if(fsclose ==2)//如果第一行的风扇关着,这里就调节转速则无反应{Oled_clear();Oledshow12();//风扇关转速0Motor_SetSpeed(0);fstuichudata = 4;//从一级界面点进去二级界面之后再一次退出出来,然后第二次点进去的二级界面保留之前二级页面的状态}KeyFlag = 0;//注意按键标志清零,防止程序跑飞		}break;case KEY2_PRES://3,按键2风扇:开  转速减少,每次减少20{if(fsclose ==1)//如果第一行的风扇开着,这里就可以不断调节转速{Oled_clear();Oledshow11();//风扇开转速fsflag =1;//让点按键一的时候增加风扇转速,如果点按键零可以直接关掉风扇Speed -=20;if(Speed < 20){Speed = 100;}Motor_SetSpeed(Speed);Oled_8_16A(48,2,Speed/100%10);Oled_8_16A(56,2,Speed/10%10);Oled_8_16A(64,2,Speed/1%10);fstuichudata =5;//从一级界面点进去二级界面之后再一次退出出来,然后第二次点进去的二级界面保留之前二级页面的状态}else if(fsclose ==2)//如果第一行的风扇关着,这里就调节转速则无反应{Oled_clear();Oledshow12();//风扇关转速0Motor_SetSpeed(0);fstuichudata =6;//从一级界面点进去二级界面之后再一次退出出来,然后第二次点进去的二级界面保留之前二级页面的状态}KeyFlag = 0;//注意按键标志清零,防止程序跑飞		}break;case KEY3_PRES://4,按键3,退出{Oled_clear();Oledshow3();//一级界面flag = 3;uuflag =0;KeyFlag = 0;//注意按键标志清零,防止程序跑飞		}break;}}
}int main(void)
{Timer_Init();//1msLED_Init();OLED_Init();Motor_Init();Key_Init();Oled_clear();Oledshow1();while(1){Key_Show1();//一级界面Key_show2();//二级界面if(T_flag == 1){if(Temp_time >= 2000)//2s检测一次,温湿度{if(DHT_Read()== 1){//湿度数据整数部分Oled_8_16(48,0,datas[0]/10);//十位Oled_8_16(56,0,datas[0]%10);//个位//湿度符号.Oled_8_16(64,0,13);//湿度数据小数部分Oled_8_16(72,0,datas[1]/10);Oled_8_16(80,0,datas[1]%10);//温度数据整数部分Oled_8_16(48,2,datas[2]/10);Oled_8_16(56,2,datas[2]%10);//温度符号.Oled_8_16(64,2,13);//温度数据小数部分Oled_8_16(72,2,datas[3]/10);Oled_8_16(80,2,datas[3]%10);}}}if(BEEP_TIME>=500)//500ms响一次蜂鸣器,不受按键影响,这里必须写大于,因为OLED按的某个时刻有可能计数值大于500{Beep =!Beep;BEEP_TIME =0;}}
}

OLED.c

#include "stm32f10x.h"
#include "Dht11.h"
#include "OLED_Font.h"/*引脚配置*/
#define OLED_W_SCL(x)		GPIO_WriteBit(GPIOB, GPIO_Pin_12, (BitAction)(x))
#define OLED_W_SDA(x)		GPIO_WriteBit(GPIOB, GPIO_Pin_13, (BitAction)(x))/*引脚初始化*/
void OLED_I2C_Init(void)
{RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);GPIO_InitTypeDef GPIO_InitStructure;GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_OD;GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12;GPIO_Init(GPIOB, &GPIO_InitStructure);GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13;GPIO_Init(GPIOB, &GPIO_InitStructure);OLED_W_SCL(1);OLED_W_SDA(1);
}/*** @brief  I2C开始* @param  无* @retval 无*/
void OLED_I2C_Start(void)
{OLED_W_SDA(1);OLED_W_SCL(1);OLED_W_SDA(0);OLED_W_SCL(0);
}/*** @brief  I2C停止* @param  无* @retval 无*/
void OLED_I2C_Stop(void)
{OLED_W_SDA(0);OLED_W_SCL(1);OLED_W_SDA(1);
}/*** @brief  I2C发送一个字节* @param  Byte 要发送的一个字节* @retval 无*/
void OLED_I2C_SendByte(uint8_t Byte)
{uint8_t i;for (i = 0; i < 8; i++){OLED_W_SDA(Byte & (0x80 >> i));OLED_W_SCL(1);OLED_W_SCL(0);}OLED_W_SCL(1);	//额外的一个时钟,不处理应答信号OLED_W_SCL(0);
}/*** @brief  OLED写命令* @param  Command 要写入的命令* @retval 无*/
void OLED_WriteCommand(uint8_t Command)
{OLED_I2C_Start();OLED_I2C_SendByte(0x78);		//从机地址OLED_I2C_SendByte(0x00);		//写命令OLED_I2C_SendByte(Command); OLED_I2C_Stop();
}/*** @brief  OLED写数据* @param  Data 要写入的数据* @retval 无*/
void OLED_WriteData(uint8_t Data)
{OLED_I2C_Start();OLED_I2C_SendByte(0x78);		//从机地址OLED_I2C_SendByte(0x40);		//写数据OLED_I2C_SendByte(Data);OLED_I2C_Stop();
}//坐标函数
void Oled_setpos(unsigned char x,unsigned char y)//OLED设置坐标(列,行)
{OLED_WriteCommand(0xB0 + y);//"页地址"从0xB0开始(一共8页)OLED_WriteCommand(((x & 0xF0) >> 4) | 0x10);//高四位OLED_WriteCommand((x & 0x0f) );//低四位
}/*** @brief  OLED清屏* @param  无* @retval 无*/
void Oled_clear()// 清屏函数
{int i,j;for(i=0;i<8;i++)//PAGE0-PAGE7都给0{OLED_WriteCommand(0xB0+i);//PAGE0-PAGE7OLED_WriteCommand(0x00);OLED_WriteCommand(0x10);for(j=0;j<128;j++){OLED_WriteData(0);}}
}/*** @brief  OLED初始化* @param  无* @retval 无*/
void OLED_Init(void)
{uint32_t i, j;for (i = 0; i < 1000; i++)			//上电延时{for (j = 0; j < 1000; j++);}OLED_I2C_Init();			//端口初始化OLED_WriteCommand(0xAE);	//关闭显示OLED_WriteCommand(0xD5);	//设置显示时钟分频比/振荡器频率OLED_WriteCommand(0x80);OLED_WriteCommand(0xA8);	//设置多路复用率OLED_WriteCommand(0x3F);OLED_WriteCommand(0xD3);	//设置显示偏移OLED_WriteCommand(0x00);OLED_WriteCommand(0x40);	//设置显示开始行OLED_WriteCommand(0xA1);	//设置左右方向,0xA1正常 0xA0左右反置OLED_WriteCommand(0xC8);	//设置上下方向,0xC8正常 0xC0上下反置OLED_WriteCommand(0xDA);	//设置COM引脚硬件配置OLED_WriteCommand(0x12);OLED_WriteCommand(0x81);	//设置对比度控制OLED_WriteCommand(0xCF);OLED_WriteCommand(0xD9);	//设置预充电周期OLED_WriteCommand(0xF1);OLED_WriteCommand(0xDB);	//设置VCOMH取消选择级别OLED_WriteCommand(0x30);OLED_WriteCommand(0xA4);	//设置整个显示打开/关闭OLED_WriteCommand(0xA6);	//设置正常/倒转显示OLED_WriteCommand(0x8D);	//设置充电泵OLED_WriteCommand(0x14);OLED_WriteCommand(0xAF);	//开启显示Oled_clear();				//OLED清屏
}/*
功能:显示中文OLED一共可以显示8列中文,4行中文
每个中文每列隔开数值+8,从0开始
每个中文每行隔开数值+2,,从0开始例子1:第一行显示两个中文
//选
Oled_8_16_L(8,0,0);
Oled_8_16_R(16,0,0);
//择
Oled_8_16_L(24,0,1);
Oled_8_16_R(32,0,1);例子2:第二行显示两个中文
//选
Oled_8_16_L(8,2,0);
Oled_8_16_R(16,2,0);
//择
Oled_8_16_L(24,2,1);
Oled_8_16_R(32,2,1);*/void Oled_8_16_L(unsigned char x,unsigned char y,unsigned char N)//需要16*16点阵的左边
{unsigned char i;unsigned int adder=32*N;    //16*16=256位,8位为一个字节,所以256/8=32个字节,一个汉字就是32字节,所以这里adder=32*N的意思就是N代表第几个汉字,比如第0个就是小,然后一开始就是数组从0开始Oled_setpos(x,y);          //(列,行) for(i=0;i<8;i++)						//汉字的左上部分{OLED_WriteData(F16_16[adder]); //当第一个汉字的时候,32*0=0,所以F16*16[adder]的adder从0开始,然后从0开始到7就是左上半部分adder++;}Oled_setpos(x,y+1);          //(列,行+1) for(i=0;i<8;i++)						//汉字的左下部分{OLED_WriteData(F16_16[adder+8]);//之后adder的8-15是右上部分,所以想取左下部分就+8adder++;}
}void Oled_8_16_R(unsigned char x,unsigned char y,unsigned char N)//需要16*16点阵的右边
{unsigned char i;unsigned int adder=32*N+8;    //16*16=256位,8位为一个字节,所以256/8=32个字节,一个汉字就是32字节,所以这里adder=32*N的意思就是N代表第几个汉字,比如第0个就是小,然后一开始就是数组从8开始Oled_setpos(x,y);          //(列,行) for(i=0;i<8;i++)						//汉字的右上部分{OLED_WriteData(F16_16[adder]); //当第一个汉字的时候,32*0=0,所以F16*16[adder]的adder从8开始,然后从8开始到15就是右上半部分adder++;}Oled_setpos(x,y+1);          //(列,行+1) for(i=0;i<8;i++)						//汉字的右下部分{OLED_WriteData(F16_16[adder+8]);//之后adder的16-23是左下部分,所以想取右下部分就+8adder++;}
}/*
功能:显示数字,英文,字符OLED一共可以显示16列数字英文字符,4行数字英文字符
每个数字英文字符每列隔开数值+8,从0开始
每个数字英文字符每行隔开数值+2,,从0开始例子1:第一行显示一个字符Oled_8_16(0,0,11);例子2:第二行显示一个字符Oled_8_16(0,2,11);*/
void Oled_8_16(unsigned char x,unsigned char y,unsigned char N)
{unsigned char i;unsigned int adder=16*N;Oled_setpos(x,y);          //(列,行) for(i=0;i<8;i++)						{OLED_WriteData(F8_16[adder]); adder++;}Oled_setpos(x,y+1);for(i=0;i<8;i++)						{OLED_WriteData(F8_16[adder]); adder++;}
}/*
功能://显示数字,英文,字符,颜色反转OLED一共可以显示16列数字英文字符,4行数字英文字符
每个数字英文字符每列隔开数值+8,从0开始
每个数字英文字符每行隔开数值+2,,从0开始例子1:第一行显示一个字符Oled_8_16A(0,0,11);例子2:第二行显示一个字符Oled_8_16A(0,2,11);*/
void Oled_8_16A(unsigned char x,unsigned char y,unsigned char N)
{unsigned char i;unsigned int adder=16*N;Oled_setpos(x,y);          //(列,行) for(i=0;i<8;i++)						{OLED_WriteData(F8_16A[adder]); adder++;}Oled_setpos(x,y+1);for(i=0;i<8;i++)						{OLED_WriteData(F8_16A[adder]); adder++;}
}

OLED.h

#ifndef __OLED_H
#define __OLED_H
#include "stm32f10x.h"                  // Device headervoid OLED_Init(void);
void Oled_clear(void);// 清屏函数
void OLED_WriteCommand(uint8_t Command);
void OLED_WriteData(uint8_t Data);
void Oled_8_16_L(unsigned char x,unsigned char y,unsigned char N);//需要16*16点阵的左边
void Oled_8_16_R(unsigned char x,unsigned char y,unsigned char N);//需要16*16点阵的右边,显示中文
void Oled_8_16(unsigned char x,unsigned char y,unsigned char N);//显示数字
void Oled_8_16A(unsigned char x,unsigned char y,unsigned char N);//显示数字,颜色反转#endif

OLED_Font.c

#include "stm32f10x.h"                  // Device header/*-------------------------此处添加所要加入的中文字库--------------------------*/
const unsigned char F16_16[]=
{
//字模提取app—参数设置:其他选项,纵向取模,字节倒序,保留,任何时候都加0
//文字输入区输入字,任何ctrl+回车生成
//修改图像:黑白反显图像
/*--  文字:  选  --*/
/*--  Fixedsys12;  此字体下对应的点阵为:宽x高=16x16   --*/
0xBF,0xBF,0xBD,0x33,0xFF,0xAF,0xB1,0x37,0xB7,0x80,0x37,0xB7,0xB7,0xBF,0xFF,0xFF,//0
0xFF,0xBF,0xDF,0xE0,0xDF,0xAF,0xB3,0xBC,0xBF,0xBF,0xB0,0xAF,0xAF,0xA3,0xBF,0xFF,/*--  文字:  择  --*/
/*--  Fixedsys12;  此字体下对应的点阵为:宽x高=16x16   --*/
0xEF,0xEF,0x00,0xEF,0xFF,0x7D,0x79,0xB5,0xAD,0x5D,0xAD,0xB5,0x79,0x7F,0x7F,0xFF,//1
0xBD,0x7D,0x80,0xFE,0xFF,0xEF,0xED,0xED,0xED,0x00,0xED,0xED,0xED,0xEF,0xFF,0xFF,/*--  文字:  灯  --*/
/*--  Fixedsys12;  此字体下对应的点阵为:宽x高=16x16   --*/
0x7F,0x8F,0xFF,0x00,0xDF,0xEF,0xFB,0xFB,0xFB,0xFB,0x03,0xFB,0xFB,0xFB,0xFB,0xFF,//2
0x7F,0x9F,0xE7,0xF8,0xF7,0xCF,0xFF,0xFF,0xBF,0x7F,0x80,0xFF,0xFF,0xFF,0xFF,0xFF,/*--  文字:  颜  --*/
/*--  Fixedsys12;  此字体下对应的点阵为:宽x高=16x16   --*/
0xFF,0x1B,0xD3,0xCA,0x59,0x8B,0xD3,0xDB,0xFD,0x0D,0xE5,0x29,0xED,0x0D,0xFD,0xFF,//3
0xBF,0xC0,0x7F,0x76,0xBB,0xDD,0xEE,0xF7,0x7F,0xB0,0xCF,0xF0,0xEF,0xD0,0x3F,0xFF,/*--  文字:  色  --*/
/*--  Fixedsys12;  此字体下对应的点阵为:宽x高=16x16   --*/
0xDF,0xEF,0x17,0xDB,0xD8,0xDB,0xDB,0x1B,0xDB,0xCB,0xD3,0xDF,0x1F,0xFF,0xFF,0xFF,//4
0xFF,0xFF,0xC0,0xBD,0xBD,0xBD,0xBD,0xBC,0xBD,0xBD,0xBD,0xBD,0xBC,0xBF,0x87,0xFF,/*--  文字:  查  --*/
/*--  Fixedsys12;  此字体下对应的点阵为:宽x高=16x16   --*/
0xBF,0xBB,0xDB,0x5B,0x6B,0x73,0x7B,0x00,0x7B,0x73,0x6B,0x5B,0xDB,0xBB,0xBF,0xFF,//5
0xBF,0xBF,0xBF,0xA0,0xB5,0xB5,0xB5,0xB5,0xB5,0xB5,0xB5,0xA0,0xBF,0xBF,0xBF,0xFF,/*--  文字:  看  --*/
/*--  Fixedsys12;  此字体下对应的点阵为:宽x高=16x16   --*/
0xDF,0xDD,0xD5,0xD5,0x55,0x95,0xC5,0xD1,0xD6,0xD6,0xD6,0xD6,0xD6,0xDF,0xDF,0xFF,//6
0xF7,0xFB,0xFD,0xFE,0x00,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0x00,0xFF,0xFF,0xFF,0xFF,/*--  文字:  温  --*/
/*--  Fixedsys12;  此字体下对应的点阵为:宽x高=16x16   --*/
0xEF,0x9F,0xFD,0x73,0xFF,0xFF,0x01,0x6D,0x6D,0x6D,0x6D,0x6D,0x01,0xFF,0xFF,0xFF,//7
0xFB,0xFB,0x81,0xFE,0xBF,0x81,0xBD,0xBD,0x81,0xBD,0x81,0xBD,0xBD,0x81,0xBF,0xFF,/*--  文字:  度  --*/
/*--  Fixedsys12;  此字体下对应的点阵为:宽x高=16x16   --*/
0xFF,0xFF,0x03,0xDB,0xDB,0xDB,0x03,0xDA,0xD9,0xDB,0x03,0xDB,0xDB,0xDB,0xFB,0xFF,//8
0xBF,0xCF,0x70,0x7F,0x7B,0xB3,0xAA,0xDA,0xDA,0xDA,0xAA,0xB3,0x7F,0x7F,0x7F,0xFF,/*--  文字:  风  --*/
/*--  Fixedsys12;  此字体下对应的点阵为:宽x高=16x16   --*/
0xFF,0xFF,0x01,0xFD,0xED,0xDD,0x3D,0xFD,0x3D,0xCD,0xFD,0x01,0xFF,0xFF,0xFF,0xFF,//9
0x7F,0x9F,0xE0,0xFF,0xDF,0xEF,0xF3,0xFC,0xF3,0xCF,0xFF,0xF0,0xCF,0xBF,0x07,0xFF,/*--  文字:  扇  --*/
/*--  Fixedsys12;  此字体下对应的点阵为:宽x高=16x16   --*/
0xFF,0xFF,0x03,0xDB,0xDB,0xDB,0xDA,0xD9,0xDB,0xDB,0xDB,0xDB,0xDB,0xC3,0xFF,0xFF,//10
0xBF,0xCF,0xF0,0xDE,0xEA,0xB6,0x7E,0x80,0xFF,0xDE,0xEA,0xB6,0x7E,0x80,0xFF,0xFF,/*--  文字:  开  --*/
/*--  Fixedsys12;  此字体下对应的点阵为:宽x高=16x16   --*/
0x7F,0x7D,0x7D,0x7D,0x01,0x7D,0x7D,0x7D,0x7D,0x7D,0x01,0x7D,0x7D,0x7D,0x7F,0xFF,//11
0xFF,0x7F,0xBF,0xCF,0xF0,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,/*--  文字:  关  --*/
/*--  Fixedsys12;  此字体下对应的点阵为:宽x高=16x16   --*/
0xFF,0xFF,0xEF,0xEE,0xE9,0xEF,0xEF,0x0F,0xEF,0xEF,0xEB,0xEC,0xEF,0xFF,0xFF,0xFF,//12
0x7E,0x7E,0xBE,0xBE,0xDE,0xEE,0xF2,0xFC,0xF2,0xEE,0xDE,0xBE,0xBE,0x7E,0x7E,0xFF,/*--  文字:  选  --*/
/*--  Fixedsys12;  此字体下对应的点阵为:宽x高=16x16   --*/
0xBF,0xBF,0xBD,0x33,0xFF,0xAF,0xB1,0x37,0xB7,0x80,0x37,0xB7,0xB7,0xBF,0xFF,0xFF,//13
0xFF,0xBF,0xDF,0xE0,0xDF,0xAF,0xB3,0xBC,0xBF,0xBF,0xB0,0xAF,0xAF,0xA3,0xBF,0xFF,/*--  文字:  择  --*/
/*--  Fixedsys12;  此字体下对应的点阵为:宽x高=16x16   --*/
0xEF,0xEF,0x00,0xEF,0xFF,0x7D,0x79,0xB5,0xAD,0x5D,0xAD,0xB5,0x79,0x7F,0x7F,0xFF,//14
0xBD,0x7D,0x80,0xFE,0xFF,0xEF,0xED,0xED,0xED,0x00,0xED,0xED,0xED,0xEF,0xFF,0xFF,/*--  文字:  红  --*/
/*--  Fixedsys12;  此字体下对应的点阵为:宽x高=16x16   --*/
0xDF,0xCF,0x53,0x9C,0xDF,0xE7,0xFF,0xFB,0xFB,0xFB,0x03,0xFB,0xFB,0xFB,0xFF,0xFF,//15
0xDD,0x98,0xDD,0xED,0xED,0xED,0xBF,0xBF,0xBF,0xBF,0x80,0xBF,0xBF,0xBF,0xBF,0xFF,/*--  文字:  灯  --*/
/*--  Fixedsys12;  此字体下对应的点阵为:宽x高=16x16   --*/
0x7F,0x8F,0xFF,0x00,0xDF,0xEF,0xFB,0xFB,0xFB,0xFB,0x03,0xFB,0xFB,0xFB,0xFB,0xFF,//16
0x7F,0x9F,0xE7,0xF8,0xF7,0xCF,0xFF,0xFF,0xBF,0x7F,0x80,0xFF,0xFF,0xFF,0xFF,0xFF,/*--  文字:  关  --*/
/*--  Fixedsys12;  此字体下对应的点阵为:宽x高=16x16   --*/
0xFF,0xFF,0xEF,0xEE,0xE9,0xEF,0xEF,0x0F,0xEF,0xEF,0xEB,0xEC,0xEF,0xFF,0xFF,0xFF,//17
0x7E,0x7E,0xBE,0xBE,0xDE,0xEE,0xF2,0xFC,0xF2,0xEE,0xDE,0xBE,0xBE,0x7E,0x7E,0xFF,/*--  文字:  开  --*/
/*--  Fixedsys12;  此字体下对应的点阵为:宽x高=16x16   --*/
0x7F,0x7D,0x7D,0x7D,0x01,0x7D,0x7D,0x7D,0x7D,0x7D,0x01,0x7D,0x7D,0x7D,0x7F,0xFF,//18
0xFF,0x7F,0xBF,0xCF,0xF0,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,/*--  文字:  绿  --*/
/*--  Fixedsys12;  此字体下对应的点阵为:宽x高=16x16   --*/
0xDF,0xCF,0x53,0x9C,0xCF,0xFF,0x7F,0x6D,0x6D,0x6D,0x6D,0x6D,0x01,0x7F,0x7F,0xFF,//19
0xDD,0x98,0xDD,0xED,0xED,0xFF,0xDD,0xEB,0xB7,0x7B,0x80,0xFB,0xF7,0xEB,0xDD,0xFF,/*--  文字:  灯  --*/
/*--  Fixedsys12;  此字体下对应的点阵为:宽x高=16x16   --*/
0x7F,0x8F,0xFF,0x00,0xDF,0xEF,0xFB,0xFB,0xFB,0xFB,0x03,0xFB,0xFB,0xFB,0xFB,0xFF,//20
0x7F,0x9F,0xE7,0xF8,0xF7,0xCF,0xFF,0xFF,0xBF,0x7F,0x80,0xFF,0xFF,0xFF,0xFF,0xFF,//字模提取app—参数设置:其他选项,纵向取模,字节倒序,保留,任何时候都加0
//文字输入区输入字,任何ctrl+回车生成
/*--  文字:  选  --*/
/*--  Fixedsys12;  此字体下对应的点阵为:宽x高=16x16   --*/
0x40,0x40,0x42,0xCC,0x00,0x50,0x4E,0xC8,0x48,0x7F,0xC8,0x48,0x48,0x40,0x00,0x00,//21
0x00,0x40,0x20,0x1F,0x20,0x50,0x4C,0x43,0x40,0x40,0x4F,0x50,0x50,0x5C,0x40,0x00,/*--  文字:  择  --*/
/*--  Fixedsys12;  此字体下对应的点阵为:宽x高=16x16   --*/
0x10,0x10,0xFF,0x10,0x00,0x82,0x86,0x4A,0x52,0xA2,0x52,0x4A,0x86,0x80,0x80,0x00,//22
0x42,0x82,0x7F,0x01,0x00,0x10,0x12,0x12,0x12,0xFF,0x12,0x12,0x12,0x10,0x00,0x00,/*--  文字:  灯  --*/
/*--  Fixedsys12;  此字体下对应的点阵为:宽x高=16x16   --*/
0x80,0x70,0x00,0xFF,0x20,0x10,0x04,0x04,0x04,0x04,0xFC,0x04,0x04,0x04,0x04,0x00,//23
0x80,0x60,0x18,0x07,0x08,0x30,0x00,0x00,0x40,0x80,0x7F,0x00,0x00,0x00,0x00,0x00,/*--  文字:  颜  --*/
/*--  Fixedsys12;  此字体下对应的点阵为:宽x高=16x16   --*/
0x00,0xE4,0x2C,0x35,0xA6,0x74,0x2C,0x24,0x02,0xF2,0x1A,0xD6,0x12,0xF2,0x02,0x00,//24
0x40,0x3F,0x80,0x89,0x44,0x22,0x11,0x08,0x80,0x4F,0x30,0x0F,0x10,0x2F,0xC0,0x00,/*--  文字:  色  --*/
/*--  Fixedsys12;  此字体下对应的点阵为:宽x高=16x16   --*/
0x20,0x10,0xE8,0x24,0x27,0x24,0x24,0xE4,0x24,0x34,0x2C,0x20,0xE0,0x00,0x00,0x00,//25
0x00,0x00,0x3F,0x42,0x42,0x42,0x42,0x43,0x42,0x42,0x42,0x42,0x43,0x40,0x78,0x00,/*--  文字:  查  --*/
/*--  Fixedsys12;  此字体下对应的点阵为:宽x高=16x16   --*/
0x40,0x44,0x24,0xA4,0x94,0x8C,0x84,0xFF,0x84,0x8C,0x94,0xA4,0x24,0x44,0x40,0x00,//26
0x40,0x40,0x40,0x5F,0x4A,0x4A,0x4A,0x4A,0x4A,0x4A,0x4A,0x5F,0x40,0x40,0x40,0x00,/*--  文字:  看  --*/
/*--  Fixedsys12;  此字体下对应的点阵为:宽x高=16x16   --*/
0x20,0x22,0x2A,0x2A,0xAA,0x6A,0x3A,0x2E,0x29,0x29,0x29,0x29,0x29,0x20,0x20,0x00,//27
0x08,0x04,0x02,0x01,0xFF,0x55,0x55,0x55,0x55,0x55,0x55,0xFF,0x00,0x00,0x00,0x00,/*--  文字:  温  --*/
/*--  Fixedsys12;  此字体下对应的点阵为:宽x高=16x16   --*/
0x10,0x60,0x02,0x8C,0x00,0x00,0xFE,0x92,0x92,0x92,0x92,0x92,0xFE,0x00,0x00,0x00,//28
0x04,0x04,0x7E,0x01,0x40,0x7E,0x42,0x42,0x7E,0x42,0x7E,0x42,0x42,0x7E,0x40,0x00,/*--  文字:  度  --*/
/*--  Fixedsys12;  此字体下对应的点阵为:宽x高=16x16   --*/
0x00,0x00,0xFC,0x24,0x24,0x24,0xFC,0x25,0x26,0x24,0xFC,0x24,0x24,0x24,0x04,0x00,//29
0x40,0x30,0x8F,0x80,0x84,0x4C,0x55,0x25,0x25,0x25,0x55,0x4C,0x80,0x80,0x80,0x00,/*--  文字:  风  --*/
/*--  Fixedsys12;  此字体下对应的点阵为:宽x高=16x16   --*/
0x00,0x00,0xFE,0x02,0x12,0x22,0xC2,0x02,0xC2,0x32,0x02,0xFE,0x00,0x00,0x00,0x00,//30
0x80,0x60,0x1F,0x00,0x20,0x10,0x0C,0x03,0x0C,0x30,0x00,0x0F,0x30,0x40,0xF8,0x00,/*--  文字:  扇  --*/
/*--  Fixedsys12;  此字体下对应的点阵为:宽x高=16x16   --*/
0x00,0x00,0xFC,0x24,0x24,0x24,0x25,0x26,0x24,0x24,0x24,0x24,0x24,0x3C,0x00,0x00,//31
0x40,0x30,0x0F,0x21,0x15,0x49,0x81,0x7F,0x00,0x21,0x15,0x49,0x81,0x7F,0x00,0x00,/*--  文字:  开  --*/
/*--  Fixedsys12;  此字体下对应的点阵为:宽x高=16x16   --*/
0x80,0x82,0x82,0x82,0xFE,0x82,0x82,0x82,0x82,0x82,0xFE,0x82,0x82,0x82,0x80,0x00,//32
0x00,0x80,0x40,0x30,0x0F,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,/*--  文字:  关  --*/
/*--  Fixedsys12;  此字体下对应的点阵为:宽x高=16x16   --*/
0x00,0x00,0x10,0x11,0x16,0x10,0x10,0xF0,0x10,0x10,0x14,0x13,0x10,0x00,0x00,0x00,//33
0x81,0x81,0x41,0x41,0x21,0x11,0x0D,0x03,0x0D,0x11,0x21,0x41,0x41,0x81,0x81,0x00,/*--  文字:  选  --*/
/*--  Fixedsys12;  此字体下对应的点阵为:宽x高=16x16   --*/
0x40,0x40,0x42,0xCC,0x00,0x50,0x4E,0xC8,0x48,0x7F,0xC8,0x48,0x48,0x40,0x00,0x00,//34
0x00,0x40,0x20,0x1F,0x20,0x50,0x4C,0x43,0x40,0x40,0x4F,0x50,0x50,0x5C,0x40,0x00,/*--  文字:  择  --*/
/*--  Fixedsys12;  此字体下对应的点阵为:宽x高=16x16   --*/
0x10,0x10,0xFF,0x10,0x00,0x82,0x86,0x4A,0x52,0xA2,0x52,0x4A,0x86,0x80,0x80,0x00,//35
0x42,0x82,0x7F,0x01,0x00,0x10,0x12,0x12,0x12,0xFF,0x12,0x12,0x12,0x10,0x00,0x00,/*--  文字:  红  --*/
/*--  Fixedsys12;  此字体下对应的点阵为:宽x高=16x16   --*/
0x20,0x30,0xAC,0x63,0x20,0x18,0x00,0x04,0x04,0x04,0xFC,0x04,0x04,0x04,0x00,0x00,//36
0x22,0x67,0x22,0x12,0x12,0x12,0x40,0x40,0x40,0x40,0x7F,0x40,0x40,0x40,0x40,0x00,/*--  文字:  灯  --*/
/*--  Fixedsys12;  此字体下对应的点阵为:宽x高=16x16   --*/
0x80,0x70,0x00,0xFF,0x20,0x10,0x04,0x04,0x04,0x04,0xFC,0x04,0x04,0x04,0x04,0x00,//37
0x80,0x60,0x18,0x07,0x08,0x30,0x00,0x00,0x40,0x80,0x7F,0x00,0x00,0x00,0x00,0x00,/*--  文字:  关  --*/
/*--  Fixedsys12;  此字体下对应的点阵为:宽x高=16x16   --*/
0x00,0x00,0x10,0x11,0x16,0x10,0x10,0xF0,0x10,0x10,0x14,0x13,0x10,0x00,0x00,0x00,//38
0x81,0x81,0x41,0x41,0x21,0x11,0x0D,0x03,0x0D,0x11,0x21,0x41,0x41,0x81,0x81,0x00,/*--  文字:  开  --*/
/*--  Fixedsys12;  此字体下对应的点阵为:宽x高=16x16   --*/
0x80,0x82,0x82,0x82,0xFE,0x82,0x82,0x82,0x82,0x82,0xFE,0x82,0x82,0x82,0x80,0x00,//39
0x00,0x80,0x40,0x30,0x0F,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,/*--  文字:  绿  --*/
/*--  Fixedsys12;  此字体下对应的点阵为:宽x高=16x16   --*/
0x20,0x30,0xAC,0x63,0x30,0x00,0x80,0x92,0x92,0x92,0x92,0x92,0xFE,0x80,0x80,0x00,//40
0x22,0x67,0x22,0x12,0x12,0x00,0x22,0x14,0x48,0x84,0x7F,0x04,0x08,0x14,0x22,0x00,/*--  文字:  灯  --*/
/*--  Fixedsys12;  此字体下对应的点阵为:宽x高=16x16   --*/
0x80,0x70,0x00,0xFF,0x20,0x10,0x04,0x04,0x04,0x04,0xFC,0x04,0x04,0x04,0x04,0x00,//41
0x80,0x60,0x18,0x07,0x08,0x30,0x00,0x00,0x40,0x80,0x7F,0x00,0x00,0x00,0x00,0x00,//字模提取app—参数设置:其他选项,纵向取模,字节倒序,保留,任何时候都加0
//文字输入区输入字,任何ctrl+回车生成
//修改图像:黑白反显图像
/*--  文字:  风  --*/
/*--  Fixedsys12;  此字体下对应的点阵为:宽x高=16x16   --*/
0xFF,0xFF,0x01,0xFD,0xED,0xDD,0x3D,0xFD,0x3D,0xCD,0xFD,0x01,0xFF,0xFF,0xFF,0xFF,//42
0x7F,0x9F,0xE0,0xFF,0xDF,0xEF,0xF3,0xFC,0xF3,0xCF,0xFF,0xF0,0xCF,0xBF,0x07,0xFF,/*--  文字:  扇  --*/
/*--  Fixedsys12;  此字体下对应的点阵为:宽x高=16x16   --*/
0xFF,0xFF,0x03,0xDB,0xDB,0xDB,0xDA,0xD9,0xDB,0xDB,0xDB,0xDB,0xDB,0xC3,0xFF,0xFF,//43
0xBF,0xCF,0xF0,0xDE,0xEA,0xB6,0x7E,0x80,0xFF,0xDE,0xEA,0xB6,0x7E,0x80,0xFF,0xFF,/*--  文字:  转  --*/
/*--  Fixedsys12;  此字体下对应的点阵为:宽x高=16x16   --*/
0x37,0x47,0x70,0x17,0x77,0x77,0xBF,0xB7,0xB7,0x17,0xA0,0xB7,0xB7,0xB7,0xBF,0xFF,//44
0xF7,0xE7,0xF7,0x00,0xFB,0xFB,0xFF,0xFD,0xF4,0xED,0xDD,0x2D,0xF5,0xF9,0xFF,0xFF,/*--  文字:  速  --*/
/*--  Fixedsys12;  此字体下对应的点阵为:宽x高=16x16   --*/
0xBF,0xBF,0xBD,0x33,0xFF,0xFB,0x0B,0x6B,0x6B,0x00,0x6B,0x6B,0x0B,0xFB,0xFF,0xFF,//45
0xFF,0xBF,0xDF,0xE0,0xDF,0xB7,0xBB,0xBD,0xBE,0xA0,0xBE,0xBD,0xBB,0xB7,0xBF,0xFF,//字模提取app—参数设置:其他选项,纵向取模,字节倒序,保留,任何时候都加0
//文字输入区输入字,任何ctrl+回车生成
/*--  文字:  风  --*/
/*--  Fixedsys12;  此字体下对应的点阵为:宽x高=16x16   --*/
0x00,0x00,0xFE,0x02,0x12,0x22,0xC2,0x02,0xC2,0x32,0x02,0xFE,0x00,0x00,0x00,0x00,//46
0x80,0x60,0x1F,0x00,0x20,0x10,0x0C,0x03,0x0C,0x30,0x00,0x0F,0x30,0x40,0xF8,0x00,/*--  文字:  扇  --*/
/*--  Fixedsys12;  此字体下对应的点阵为:宽x高=16x16   --*/
0x00,0x00,0xFC,0x24,0x24,0x24,0x25,0x26,0x24,0x24,0x24,0x24,0x24,0x3C,0x00,0x00,//47
0x40,0x30,0x0F,0x21,0x15,0x49,0x81,0x7F,0x00,0x21,0x15,0x49,0x81,0x7F,0x00,0x00,/*--  文字:  转  --*/
/*--  Fixedsys12;  此字体下对应的点阵为:宽x高=16x16   --*/
0xC8,0xB8,0x8F,0xE8,0x88,0x88,0x40,0x48,0x48,0xE8,0x5F,0x48,0x48,0x48,0x40,0x00,//48
0x08,0x18,0x08,0xFF,0x04,0x04,0x00,0x02,0x0B,0x12,0x22,0xD2,0x0A,0x06,0x00,0x00,/*--  文字:  速  --*/
/*--  Fixedsys12;  此字体下对应的点阵为:宽x高=16x16   --*/
0x40,0x40,0x42,0xCC,0x00,0x04,0xF4,0x94,0x94,0xFF,0x94,0x94,0xF4,0x04,0x00,0x00,//49
0x00,0x40,0x20,0x1F,0x20,0x48,0x44,0x42,0x41,0x5F,0x41,0x42,0x44,0x48,0x40,0x00,/*--  文字:  湿  --*/
/*--  Fixedsys12;  此字体下对应的点阵为:宽x高=16x16   --*/
0x10,0x60,0x02,0x8C,0x00,0xFE,0x92,0x92,0x92,0x92,0x92,0x92,0xFE,0x00,0x00,0x00,//50
0x04,0x04,0x7E,0x01,0x44,0x48,0x50,0x7F,0x40,0x40,0x7F,0x50,0x48,0x44,0x40,0x00,/*--  文字:  度  --*/
/*--  Fixedsys12;  此字体下对应的点阵为:宽x高=16x16   --*/
0x00,0x00,0xFC,0x24,0x24,0x24,0xFC,0x25,0x26,0x24,0xFC,0x24,0x24,0x24,0x04,0x00,//51
0x40,0x30,0x8F,0x80,0x84,0x4C,0x55,0x25,0x25,0x25,0x55,0x4C,0x80,0x80,0x80,0x00,/*--  文字:  温  --*/
/*--  Fixedsys12;  此字体下对应的点阵为:宽x高=16x16   --*/
0x10,0x60,0x02,0x8C,0x00,0x00,0xFE,0x92,0x92,0x92,0x92,0x92,0xFE,0x00,0x00,0x00,//52
0x04,0x04,0x7E,0x01,0x40,0x7E,0x42,0x42,0x7E,0x42,0x7E,0x42,0x42,0x7E,0x40,0x00,/*--  文字:  度  --*/
/*--  Fixedsys12;  此字体下对应的点阵为:宽x高=16x16   --*/
0x00,0x00,0xFC,0x24,0x24,0x24,0xFC,0x25,0x26,0x24,0xFC,0x24,0x24,0x24,0x04,0x00,//53
0x40,0x30,0x8F,0x80,0x84,0x4C,0x55,0x25,0x25,0x25,0x55,0x4C,0x80,0x80,0x80,0x00,};
/*-------------------------此处添加所要加入的英文符号数字字库--------------------------*/
const unsigned char  F8_16[]=
{
//字模提取app—参数设置:其他选项,纵向取模,字节倒序,保留,任何时候都加0
//文字输入区输入字,任何ctrl+回车生成
0x00,0x00,0xF0,0xF8,0x08,0x68,0xF8,0xF0,0x00,0x00,0x07,0x0F,0x0B,0x08,0x0F,0x07,//数字0,00x00,0x20,0x20,0x30,0xF8,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x0F,0x00,0x00,//数字1,10x00,0x30,0x38,0x08,0x88,0xF8,0x70,0x00,0x00,0x0C,0x0E,0x0B,0x09,0x08,0x08,0x00,0x00,0x30,0x38,0x88,0x88,0xF8,0x70,0x00,0x00,0x06,0x0E,0x08,0x08,0x0F,0x07,0x00,0x00,0x00,0xF8,0xF8,0x00,0xE0,0xE0,0x00,0x00,0x03,0x03,0x02,0x02,0x0F,0x0F,0x02,0x00,0xF8,0xF8,0x88,0x88,0x88,0x08,0x00,0x00,0x08,0x08,0x08,0x0C,0x07,0x03,0x00,0x00,0xC0,0xE0,0x78,0x58,0xC8,0x80,0x00,0x00,0x07,0x0F,0x08,0x08,0x0F,0x07,0x00,0x00,0x08,0x08,0x88,0xE8,0x78,0x18,0x00,0x00,0x00,0x0E,0x0F,0x01,0x00,0x00,0x00,0x00,0x70,0xF8,0xC8,0x88,0xF8,0x70,0x00,0x00,0x07,0x0F,0x08,0x09,0x0F,0x07,0x00,0x00,0xF0,0xF8,0x08,0x08,0xF8,0xF0,0x00,0x00,0x00,0x09,0x0D,0x0F,0x03,0x01,0x00,//数字9,9/*--  文字:  *  --*/
/*--  Fixedsys12;  此字体下对应的点阵为:宽x高=8x16   --*/
0x00,0x80,0xA0,0xE0,0xC0,0xE0,0xA0,0x80,0x00,0x00,0x02,0x03,0x01,0x03,0x02,0x00,//10/*--  文字:  :  --*/
/*--  Fixedsys12;  此字体下对应的点阵为:宽x高=8x16   --*/
0x00,0x00,0x00,0x60,0x60,0x60,0x00,0x00,0x00,0x00,0x00,0x0C,0x0C,0x0C,0x00,0x00,//11/*--  调入了一幅图像:这是您新建的图像,全黑  --*/
/*--  宽度x高度=8x16  --*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//12/*--  文字:  .  --*/
/*--  Fixedsys12;  此字体下对应的点阵为:宽x高=8x16   --*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x0C,0x0C,0x00,0x00,//13};/*-------------------------此处添加所要加入的英文符号数字字库,颜色反转--------------------------*/
const unsigned char  F8_16A[]=
{
//字模提取app—参数设置:其他选项,纵向取模,字节倒序,保留,任何时候都加0
//文字输入区输入字,任何ctrl+回车生成
//修改图像:黑白反显图像
/*--  文字:  0  --*/
/*--  Fixedsys12;  此字体下对应的点阵为:宽x高=8x16   --*/
0xFF,0xFF,0x0F,0x07,0xF7,0x97,0x07,0x0F,0xFF,0xFF,0xF8,0xF0,0xF4,0xF7,0xF0,0xF8,/*--  文字:  1  --*/
/*--  Fixedsys12;  此字体下对应的点阵为:宽x高=8x16   --*/
0xFF,0xDF,0xDF,0xCF,0x07,0x07,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xF0,0xF0,0xFF,0xFF,/*--  文字:  2  --*/
/*--  Fixedsys12;  此字体下对应的点阵为:宽x高=8x16   --*/
0xFF,0xCF,0xC7,0xF7,0x77,0x07,0x8F,0xFF,0xFF,0xF3,0xF1,0xF4,0xF6,0xF7,0xF7,0xFF,/*--  文字:  3  --*/
/*--  Fixedsys12;  此字体下对应的点阵为:宽x高=8x16   --*/
0xFF,0xCF,0xC7,0x77,0x77,0x07,0x8F,0xFF,0xFF,0xF9,0xF1,0xF7,0xF7,0xF0,0xF8,0xFF,/*--  文字:  4  --*/
/*--  Fixedsys12;  此字体下对应的点阵为:宽x高=8x16   --*/
0xFF,0xFF,0x07,0x07,0xFF,0x1F,0x1F,0xFF,0xFF,0xFC,0xFC,0xFD,0xFD,0xF0,0xF0,0xFD,/*--  文字:  5  --*/
/*--  Fixedsys12;  此字体下对应的点阵为:宽x高=8x16   --*/
0xFF,0x07,0x07,0x77,0x77,0x77,0xF7,0xFF,0xFF,0xF7,0xF7,0xF7,0xF3,0xF8,0xFC,0xFF,/*--  文字:  6  --*/
/*--  Fixedsys12;  此字体下对应的点阵为:宽x高=8x16   --*/
0xFF,0x3F,0x1F,0x87,0xA7,0x37,0x7F,0xFF,0xFF,0xF8,0xF0,0xF7,0xF7,0xF0,0xF8,0xFF,/*--  文字:  7  --*/
/*--  Fixedsys12;  此字体下对应的点阵为:宽x高=8x16   --*/
0xFF,0xF7,0xF7,0x77,0x17,0x87,0xE7,0xFF,0xFF,0xFF,0xF1,0xF0,0xFE,0xFF,0xFF,0xFF,/*--  文字:  8  --*/
/*--  Fixedsys12;  此字体下对应的点阵为:宽x高=8x16   --*/
0xFF,0x8F,0x07,0x37,0x77,0x07,0x8F,0xFF,0xFF,0xF8,0xF0,0xF7,0xF6,0xF0,0xF8,0xFF,/*--  文字:  9  --*/
/*--  Fixedsys12;  此字体下对应的点阵为:宽x高=8x16   --*/
0xFF,0x0F,0x07,0xF7,0xF7,0x07,0x0F,0xFF,0xFF,0xFF,0xF6,0xF2,0xF0,0xFC,0xFE,0xFF,/*--  文字:  :  --*/
/*--  Fixedsys12;  此字体下对应的点阵为:宽x高=8x16   --*/
0xFF,0xFF,0xFF,0x9F,0x9F,0x9F,0xFF,0xFF,0xFF,0xFF,0xFF,0xF3,0xF3,0xF3,0xFF,0xFF,//10};

OLED_Font.h

#ifndef __OLED_FONT_H
#define __OLED_FONT_H
#include "stm32f10x.h"                  // Device headerextern const unsigned char F16_16[];
extern const unsigned char  F8_16[];
extern const unsigned char  F8_16A[];#endif

OLEDShow.c

#include "stm32f10x.h"                  // Device header
#include "OLED.h"//初始一级界面
//*选择颜色灯(颜色反转)
// 查看温度
// 风扇开关选择
void Oledshow1()//展示需要的效果
{OLED_WriteCommand(0x2E);//关闭滚动OLED_WriteCommand(0x26);//向右滚动OLED_WriteCommand(0x00);//A:固定指令0OLED_WriteCommand(0x00);//B:起始页0OLED_WriteCommand(0x07);//C:刷新帧OLED_WriteCommand(0x07);//D:结束页OLED_WriteCommand(0x00);//虚拟字节OLED_WriteCommand(0xFF);//虚拟字节Oled_8_16(0,0,10);//字符*//选Oled_8_16_L(8,0,0);Oled_8_16_R(16,0,0);//择Oled_8_16_L(24,0,1);Oled_8_16_R(32,0,1);//灯Oled_8_16_L(40,0,2);Oled_8_16_R(48,0,2);//颜	Oled_8_16_L(56,0,3);Oled_8_16_R(64,0,3);//色Oled_8_16_L(72,0,4);Oled_8_16_R(80,0,4);//查Oled_8_16_L(8,2,26);Oled_8_16_R(16,2,26);//看Oled_8_16_L(24,2,27);Oled_8_16_R(32,2,27);//温Oled_8_16_L(40,2,28);Oled_8_16_R(48,2,28);//度Oled_8_16_L(56,2,29);Oled_8_16_R(64,2,29);//风Oled_8_16_L(8,4,30);Oled_8_16_R(16,4,30);//扇Oled_8_16_L(24,4,31);Oled_8_16_R(32,4,31);//开Oled_8_16_L(40,4,32);Oled_8_16_R(48,4,32);//关Oled_8_16_L(56,4,33);Oled_8_16_R(64,4,33);//选Oled_8_16_L(72,4,34);Oled_8_16_R(80,4,34);//择Oled_8_16_L(88,4,35);Oled_8_16_R(96,4,35);}//初始一级界面
// 选择颜色灯
//*查看温度(颜色反转)
// 风扇开关选择
void Oledshow2()//展示需要的效果
{OLED_WriteCommand(0x2E);//关闭滚动OLED_WriteCommand(0x26);//向右滚动OLED_WriteCommand(0x00);//A:固定指令0OLED_WriteCommand(0x00);//B:起始页0OLED_WriteCommand(0x07);//C:刷新帧OLED_WriteCommand(0x07);//D:结束页OLED_WriteCommand(0x00);//虚拟字节OLED_WriteCommand(0xFF);//虚拟字节Oled_8_16(0,2,10);//字符*//选Oled_8_16_L(8,0,21);Oled_8_16_R(16,0,21);//择Oled_8_16_L(24,0,22);Oled_8_16_R(32,0,22);//灯Oled_8_16_L(40,0,23);Oled_8_16_R(48,0,23);//颜	Oled_8_16_L(56,0,24);Oled_8_16_R(64,0,24);//色Oled_8_16_L(72,0,25);Oled_8_16_R(80,0,25);//查Oled_8_16_L(8,2,5);Oled_8_16_R(16,2,5);//看Oled_8_16_L(24,2,6);Oled_8_16_R(32,2,6);//温Oled_8_16_L(40,2,7);Oled_8_16_R(48,2,7);//度Oled_8_16_L(56,2,8);Oled_8_16_R(64,2,8);//风Oled_8_16_L(8,4,30);Oled_8_16_R(16,4,30);//扇Oled_8_16_L(24,4,31);Oled_8_16_R(32,4,31);//开Oled_8_16_L(40,4,32);Oled_8_16_R(48,4,32);//关Oled_8_16_L(56,4,33);Oled_8_16_R(64,4,33);//选Oled_8_16_L(72,4,34);Oled_8_16_R(80,4,34);//择Oled_8_16_L(88,4,35);Oled_8_16_R(96,4,35);}//初始一级界面
// 选择颜色灯
// 查看温度
//*风扇开关选择(颜色反转)
void Oledshow3()//展示需要的效果
{OLED_WriteCommand(0x2E);//关闭滚动OLED_WriteCommand(0x26);//向右滚动OLED_WriteCommand(0x00);//A:固定指令0OLED_WriteCommand(0x00);//B:起始页0OLED_WriteCommand(0x07);//C:刷新帧OLED_WriteCommand(0x07);//D:结束页OLED_WriteCommand(0x00);//虚拟字节OLED_WriteCommand(0xFF);//虚拟字节Oled_8_16(0,4,10);//字符*//选Oled_8_16_L(8,0,21);Oled_8_16_R(16,0,21);//择Oled_8_16_L(24,0,22);Oled_8_16_R(32,0,22);//灯Oled_8_16_L(40,0,23);Oled_8_16_R(48,0,23);//颜	Oled_8_16_L(56,0,24);Oled_8_16_R(64,0,24);//色Oled_8_16_L(72,0,25);Oled_8_16_R(80,0,25);//查Oled_8_16_L(8,2,26);Oled_8_16_R(16,2,26);//看Oled_8_16_L(24,2,27);Oled_8_16_R(32,2,27);//温Oled_8_16_L(40,2,28);Oled_8_16_R(48,2,28);//度Oled_8_16_L(56,2,29);Oled_8_16_R(64,2,29);//风Oled_8_16_L(8,4,9);Oled_8_16_R(16,4,9);//扇Oled_8_16_L(24,4,10);Oled_8_16_R(32,4,10);//开Oled_8_16_L(40,4,11);Oled_8_16_R(48,4,11);//关Oled_8_16_L(56,4,12);Oled_8_16_R(64,4,12);//选Oled_8_16_L(72,4,13);Oled_8_16_R(80,4,13);//择Oled_8_16_L(88,4,14);Oled_8_16_R(96,4,14);//OLED_WriteCommand(0x2F);//开启滚动}//选择灯颜色二级界面
//*红灯:关(颜色反转)
// 绿灯:关
void Oledshow4()//展示需要的效果
{OLED_WriteCommand(0x2E);//关闭滚动OLED_WriteCommand(0x26);//向右滚动OLED_WriteCommand(0x00);//A:固定指令0OLED_WriteCommand(0x00);//B:起始页0OLED_WriteCommand(0x07);//C:刷新帧OLED_WriteCommand(0x07);//D:结束页OLED_WriteCommand(0x00);//虚拟字节OLED_WriteCommand(0xFF);//虚拟字节Oled_8_16(0,0,10);//字符*//红Oled_8_16_L(8,0,15);Oled_8_16_R(16,0,15);//灯Oled_8_16_L(24,0,16);Oled_8_16_R(32,0,16);//字符:Oled_8_16A(40,0,10);//关Oled_8_16_L(48,0,17);Oled_8_16_R(56,0,17);//绿Oled_8_16_L(8,2,40);Oled_8_16_R(16,2,40);//灯Oled_8_16_L(24,2,41);Oled_8_16_R(32,2,41);//字符:Oled_8_16(40,2,11);//关Oled_8_16_L(48,2,38);Oled_8_16_R(56,2,38);
}//选择灯颜色二级界面
//*红灯:开(颜色反转)
// 绿灯:关
void Oledshow5()//展示需要的效果
{OLED_WriteCommand(0x2E);//关闭滚动OLED_WriteCommand(0x26);//向右滚动OLED_WriteCommand(0x00);//A:固定指令0OLED_WriteCommand(0x00);//B:起始页0OLED_WriteCommand(0x07);//C:刷新帧OLED_WriteCommand(0x07);//D:结束页OLED_WriteCommand(0x00);//虚拟字节OLED_WriteCommand(0xFF);//虚拟字节Oled_8_16(0,2,12);//全黑,把原来的第二行的*覆盖掉Oled_8_16(0,0,10);//字符*//红Oled_8_16_L(8,0,15);Oled_8_16_R(16,0,15);//灯Oled_8_16_L(24,0,16);Oled_8_16_R(32,0,16);//字符:Oled_8_16A(40,0,10);//开Oled_8_16_L(48,0,18);Oled_8_16_R(56,0,18);//绿Oled_8_16_L(8,2,40);Oled_8_16_R(16,2,40);//灯Oled_8_16_L(24,2,41);Oled_8_16_R(32,2,41);//字符:Oled_8_16(40,2,11);//关Oled_8_16_L(48,2,38);Oled_8_16_R(56,2,38);}//选择灯颜色二级界面
// 红灯:关
//*绿灯:开(颜色反转)
void Oledshow6()//展示需要的效果
{OLED_WriteCommand(0x2E);//关闭滚动OLED_WriteCommand(0x26);//向右滚动OLED_WriteCommand(0x00);//A:固定指令0OLED_WriteCommand(0x00);//B:起始页0OLED_WriteCommand(0x07);//C:刷新帧OLED_WriteCommand(0x07);//D:结束页OLED_WriteCommand(0x00);//虚拟字节OLED_WriteCommand(0xFF);//虚拟字节Oled_8_16(0,0,12);//全黑,把原来的第一行的*覆盖掉Oled_8_16(0,2,10);//字符*//红Oled_8_16_L(8,0,36);Oled_8_16_R(16,0,36);//灯Oled_8_16_L(24,0,37);Oled_8_16_R(32,0,37);//字符:Oled_8_16(40,0,11);//关Oled_8_16_L(48,0,38);Oled_8_16_R(56,0,38);//绿Oled_8_16_L(8,2,19);Oled_8_16_R(16,2,19);//灯Oled_8_16_L(24,2,20);Oled_8_16_R(32,2,20);//字符:Oled_8_16A(40,2,10);//开Oled_8_16_L(48,2,18);Oled_8_16_R(56,2,18);
}//选择灯颜色二级界面
//*红灯:关(颜色反转)
// 绿灯:关
void Oledshow7()//展示需要的效果
{OLED_WriteCommand(0x2E);//关闭滚动OLED_WriteCommand(0x26);//向右滚动OLED_WriteCommand(0x00);//A:固定指令0OLED_WriteCommand(0x00);//B:起始页0OLED_WriteCommand(0x07);//C:刷新帧OLED_WriteCommand(0x07);//D:结束页OLED_WriteCommand(0x00);//虚拟字节OLED_WriteCommand(0xFF);//虚拟字节Oled_8_16(0,2,12);//全黑,把原来的第一行的*覆盖掉Oled_8_16(0,0,10);//字符*//红Oled_8_16_L(8,0,15);Oled_8_16_R(16,0,15);//灯Oled_8_16_L(24,0,16);Oled_8_16_R(32,0,16);//字符:Oled_8_16A(40,0,10);//关Oled_8_16_L(48,0,17);Oled_8_16_R(56,0,17);//绿Oled_8_16_L(8,2,40);Oled_8_16_R(16,2,40);//灯Oled_8_16_L(24,2,41);Oled_8_16_R(32,2,41);//字符:Oled_8_16(40,2,11);//关Oled_8_16_L(48,2,38);Oled_8_16_R(56,2,38);
}//选择灯颜色二级界面
// 红灯:关
//*绿灯:关(颜色反转)
void Oledshow8()//展示需要的效果
{OLED_WriteCommand(0x2E);//关闭滚动OLED_WriteCommand(0x26);//向右滚动OLED_WriteCommand(0x00);//A:固定指令0OLED_WriteCommand(0x00);//B:起始页0OLED_WriteCommand(0x07);//C:刷新帧OLED_WriteCommand(0x07);//D:结束页OLED_WriteCommand(0x00);//虚拟字节OLED_WriteCommand(0xFF);//虚拟字节Oled_8_16(0,0,12);//全黑,把原来的第一行的*覆盖掉Oled_8_16(0,2,10);//字符*//红Oled_8_16_L(8,0,36);Oled_8_16_R(16,0,36);//灯Oled_8_16_L(24,0,37);Oled_8_16_R(32,0,37);//字符:Oled_8_16(40,0,11);//关Oled_8_16_L(48,0,38);Oled_8_16_R(56,0,38);//绿Oled_8_16_L(8,2,19);Oled_8_16_R(16,2,19);//灯Oled_8_16_L(24,2,20);Oled_8_16_R(32,2,20);//字符:Oled_8_16A(40,2,10);//关Oled_8_16_L(48,2,17);Oled_8_16_R(56,2,17);
}//风扇开关选择二级界面
//*风扇:关(颜色反转)
// 转速:0
void Oledshow9()//展示需要的效果
{OLED_WriteCommand(0x2E);//关闭滚动OLED_WriteCommand(0x26);//向右滚动OLED_WriteCommand(0x00);//A:固定指令0OLED_WriteCommand(0x00);//B:起始页0OLED_WriteCommand(0x07);//C:刷新帧OLED_WriteCommand(0x07);//D:结束页OLED_WriteCommand(0x00);//虚拟字节OLED_WriteCommand(0xFF);//虚拟字节Oled_8_16(0,0,10);//字符*//风Oled_8_16_L(8,0,42);Oled_8_16_R(16,0,42);//扇Oled_8_16_L(24,0,43);Oled_8_16_R(32,0,43);//字符:Oled_8_16A(40,0,10);//关Oled_8_16_L(48,0,17);Oled_8_16_R(56,0,17);//转Oled_8_16_L(8,2,48);Oled_8_16_R(16,2,48);//速Oled_8_16_L(24,2,49);Oled_8_16_R(32,2,49);//字符:Oled_8_16(40,2,11);//速度数字0Oled_8_16(48,2,0);}//风扇开关选择二级界面
//*风扇:开(颜色反转)
// 转速:100
void Oledshow10()//展示需要的效果
{OLED_WriteCommand(0x2E);//关闭滚动OLED_WriteCommand(0x26);//向右滚动OLED_WriteCommand(0x00);//A:固定指令0OLED_WriteCommand(0x00);//B:起始页0OLED_WriteCommand(0x07);//C:刷新帧OLED_WriteCommand(0x07);//D:结束页OLED_WriteCommand(0x00);//虚拟字节OLED_WriteCommand(0xFF);//虚拟字节Oled_8_16(0,0,10);//字符*//风Oled_8_16_L(8,0,42);Oled_8_16_R(16,0,42);//扇Oled_8_16_L(24,0,43);Oled_8_16_R(32,0,43);//字符:Oled_8_16A(40,0,10);//开Oled_8_16_L(48,0,18);Oled_8_16_R(56,0,18);//转Oled_8_16_L(8,2,48);Oled_8_16_R(16,2,48);//速Oled_8_16_L(24,2,49);Oled_8_16_R(32,2,49);//字符:Oled_8_16(40,2,11);//速度数字100Oled_8_16(48,2,1);Oled_8_16(56,2,0);Oled_8_16(64,2,0);}//风扇开关选择二级界面
// 风扇:开
//*转速:0-100(颜色反转)
void Oledshow11()//展示需要的效果
{OLED_WriteCommand(0x2E);//关闭滚动OLED_WriteCommand(0x26);//向右滚动OLED_WriteCommand(0x00);//A:固定指令0OLED_WriteCommand(0x00);//B:起始页0OLED_WriteCommand(0x07);//C:刷新帧OLED_WriteCommand(0x07);//D:结束页OLED_WriteCommand(0x00);//虚拟字节OLED_WriteCommand(0xFF);//虚拟字节Oled_8_16(0,2,10);//字符*//风Oled_8_16_L(8,0,46);Oled_8_16_R(16,0,46);//扇Oled_8_16_L(24,0,47);Oled_8_16_R(32,0,47);//字符:Oled_8_16(40,0,11);//开Oled_8_16_L(48,0,32);Oled_8_16_R(56,0,32);//转Oled_8_16_L(8,2,44);Oled_8_16_R(16,2,44);//速Oled_8_16_L(24,2,45);Oled_8_16_R(32,2,45);//字符:Oled_8_16A(40,2,10);}//风扇开关选择二级界面
// 风扇:开
//*转速:0(颜色反转)
void Oledshow12()//展示需要的效果
{OLED_WriteCommand(0x2E);//关闭滚动OLED_WriteCommand(0x26);//向右滚动OLED_WriteCommand(0x00);//A:固定指令0OLED_WriteCommand(0x00);//B:起始页0OLED_WriteCommand(0x07);//C:刷新帧OLED_WriteCommand(0x07);//D:结束页OLED_WriteCommand(0x00);//虚拟字节OLED_WriteCommand(0xFF);//虚拟字节Oled_8_16(0,2,10);//字符*//风Oled_8_16_L(8,0,46);Oled_8_16_R(16,0,46);//扇Oled_8_16_L(24,0,47);Oled_8_16_R(32,0,47);//字符:Oled_8_16(40,0,11);//开Oled_8_16_L(48,0,33);Oled_8_16_R(56,0,33);//转Oled_8_16_L(8,2,44);Oled_8_16_R(16,2,44);//速Oled_8_16_L(24,2,45);Oled_8_16_R(32,2,45);//字符:Oled_8_16A(40,2,10);Oled_8_16A(48,2,0);
}void Oledshow13()//展示需要的效果
{OLED_WriteCommand(0x2E);//关闭滚动OLED_WriteCommand(0x26);//向右滚动OLED_WriteCommand(0x00);//A:固定指令0OLED_WriteCommand(0x00);//B:起始页0OLED_WriteCommand(0x07);//C:刷新帧OLED_WriteCommand(0x07);//D:结束页OLED_WriteCommand(0x00);//虚拟字节OLED_WriteCommand(0xFF);//虚拟字节//湿Oled_8_16_L(8,0,50);Oled_8_16_R(16,0,50);//度Oled_8_16_L(24,0,51);Oled_8_16_R(32,0,51);//字符:Oled_8_16(40,0,11);//温Oled_8_16_L(8,2,52);Oled_8_16_R(16,2,52);//度Oled_8_16_L(24,2,53);Oled_8_16_R(32,2,53);//字符:Oled_8_16(40,2,11);}//选择灯颜色二级界面
//*红灯:开(颜色反转)
// 绿灯:开
void Oledshow14()//展示需要的效果
{OLED_WriteCommand(0x2E);//关闭滚动OLED_WriteCommand(0x26);//向右滚动OLED_WriteCommand(0x00);//A:固定指令0OLED_WriteCommand(0x00);//B:起始页0OLED_WriteCommand(0x07);//C:刷新帧OLED_WriteCommand(0x07);//D:结束页OLED_WriteCommand(0x00);//虚拟字节OLED_WriteCommand(0xFF);//虚拟字节Oled_8_16(0,2,12);//全黑,把原来的第二行的*覆盖掉Oled_8_16(0,0,10);//字符*//红Oled_8_16_L(8,0,15);Oled_8_16_R(16,0,15);//灯Oled_8_16_L(24,0,16);Oled_8_16_R(32,0,16);//字符:Oled_8_16A(40,0,10);//开Oled_8_16_L(48,0,18);Oled_8_16_R(56,0,18);//绿Oled_8_16_L(8,2,40);Oled_8_16_R(16,2,40);//灯Oled_8_16_L(24,2,41);Oled_8_16_R(32,2,41);//字符:Oled_8_16(40,2,11);//开Oled_8_16_L(48,2,39);Oled_8_16_R(56,2,39);
}//选择灯颜色二级界面
// 红灯:开
//*绿灯:开(颜色反转)
void Oledshow15()//展示需要的效果
{OLED_WriteCommand(0x2E);//关闭滚动OLED_WriteCommand(0x26);//向右滚动OLED_WriteCommand(0x00);//A:固定指令0OLED_WriteCommand(0x00);//B:起始页0OLED_WriteCommand(0x07);//C:刷新帧OLED_WriteCommand(0x07);//D:结束页OLED_WriteCommand(0x00);//虚拟字节OLED_WriteCommand(0xFF);//虚拟字节Oled_8_16(0,0,12);//全黑,把原来的第一行的*覆盖掉Oled_8_16(0,2,10);//字符*//红Oled_8_16_L(8,0,36);Oled_8_16_R(16,0,36);//灯Oled_8_16_L(24,0,37);Oled_8_16_R(32,0,37);//字符:Oled_8_16(40,0,11);//开Oled_8_16_L(48,0,39);Oled_8_16_R(56,0,39);//绿Oled_8_16_L(8,2,19);Oled_8_16_R(16,2,19);//灯Oled_8_16_L(24,2,20);Oled_8_16_R(32,2,20);//字符:Oled_8_16A(40,2,10);//开Oled_8_16_L(48,2,18);Oled_8_16_R(56,2,18);
}//选择灯颜色二级界面
//*红灯:关(颜色反转)
// 绿灯:开
void Oledshow16()//展示需要的效果
{OLED_WriteCommand(0x2E);//关闭滚动OLED_WriteCommand(0x26);//向右滚动OLED_WriteCommand(0x00);//A:固定指令0OLED_WriteCommand(0x00);//B:起始页0OLED_WriteCommand(0x07);//C:刷新帧OLED_WriteCommand(0x07);//D:结束页OLED_WriteCommand(0x00);//虚拟字节OLED_WriteCommand(0xFF);//虚拟字节Oled_8_16(0,2,12);//全黑,把原来的第二行的*覆盖掉Oled_8_16(0,0,10);//字符*//红Oled_8_16_L(8,0,15);Oled_8_16_R(16,0,15);//灯Oled_8_16_L(24,0,16);Oled_8_16_R(32,0,16);//字符:Oled_8_16A(40,0,10);//关Oled_8_16_L(48,0,17);Oled_8_16_R(56,0,17);//绿Oled_8_16_L(8,2,40);Oled_8_16_R(16,2,40);//灯Oled_8_16_L(24,2,41);Oled_8_16_R(32,2,41);//字符:Oled_8_16(40,2,11);//开Oled_8_16_L(48,2,39);Oled_8_16_R(56,2,39);
}//选择灯颜色二级界面
// 红灯:开
//*绿灯:关(颜色反转)
void Oledshow17()//展示需要的效果
{OLED_WriteCommand(0x2E);//关闭滚动OLED_WriteCommand(0x26);//向右滚动OLED_WriteCommand(0x00);//A:固定指令0OLED_WriteCommand(0x00);//B:起始页0OLED_WriteCommand(0x07);//C:刷新帧OLED_WriteCommand(0x07);//D:结束页OLED_WriteCommand(0x00);//虚拟字节OLED_WriteCommand(0xFF);//虚拟字节Oled_8_16(0,0,12);//全黑,把原来的第一行的*覆盖掉Oled_8_16(0,2,10);//字符*//红Oled_8_16_L(8,0,36);Oled_8_16_R(16,0,36);//灯Oled_8_16_L(24,0,37);Oled_8_16_R(32,0,37);//字符:Oled_8_16(40,0,11);//开Oled_8_16_L(48,0,39);Oled_8_16_R(56,0,39);//绿Oled_8_16_L(8,2,19);Oled_8_16_R(16,2,19);//灯Oled_8_16_L(24,2,20);Oled_8_16_R(32,2,20);//字符:Oled_8_16A(40,2,10);//关Oled_8_16_L(48,2,17);Oled_8_16_R(56,2,17);
}//初始一级界面
// 选择颜色灯
//*查看温度(颜色反转)
// 风扇开关选择
void Oledshow18()//展示需要的效果
{OLED_WriteCommand(0x2E);//关闭滚动OLED_WriteCommand(0x26);//向右滚动OLED_WriteCommand(0x00);//A:固定指令0OLED_WriteCommand(0x00);//B:起始页0OLED_WriteCommand(0x07);//C:刷新帧OLED_WriteCommand(0x07);//D:结束页OLED_WriteCommand(0x00);//虚拟字节OLED_WriteCommand(0xFF);//虚拟字节Oled_8_16(0,2,10);//字符*//选Oled_8_16_L(8,0,21);Oled_8_16_R(16,0,21);//择Oled_8_16_L(24,0,22);Oled_8_16_R(32,0,22);//灯Oled_8_16_L(40,0,23);Oled_8_16_R(48,0,23);//颜	Oled_8_16_L(56,0,24);Oled_8_16_R(64,0,24);//色Oled_8_16_L(72,0,25);Oled_8_16_R(80,0,25);//查Oled_8_16_L(8,2,5);Oled_8_16_R(16,2,5);//看Oled_8_16_L(24,2,6);Oled_8_16_R(32,2,6);//温Oled_8_16_L(40,2,7);Oled_8_16_R(48,2,7);//度Oled_8_16_L(56,2,8);Oled_8_16_R(64,2,8);//风Oled_8_16_L(8,4,30);Oled_8_16_R(16,4,30);//扇Oled_8_16_L(24,4,31);Oled_8_16_R(32,4,31);//开Oled_8_16_L(40,4,32);Oled_8_16_R(48,4,32);//关Oled_8_16_L(56,4,33);Oled_8_16_R(64,4,33);//选Oled_8_16_L(72,4,34);Oled_8_16_R(80,4,34);//择Oled_8_16_L(88,4,35);Oled_8_16_R(96,4,35);}

OLEDShow.h

#ifndef __OLEDSHOW_H
#define __OLEDSHOW_Hvoid Oledshow1(void);
void Oledshow2(void);
void Oledshow3(void);
void Oledshow4(void);
void Oledshow5(void);
void Oledshow6(void);
void Oledshow7(void);
void Oledshow8(void);
void Oledshow9(void);
void Oledshow10(void);
void Oledshow11(void);
void Oledshow12(void);
void Oledshow13(void);
void Oledshow14(void);
void Oledshow15(void);
void Oledshow16(void);
void Oledshow17(void);
void Oledshow18(void);#endif

Delay.c

#include "stm32f10x.h"/*** @brief  微秒级延时* @param  xus 延时时长,范围:0~233015* @retval 无*/
void Delay_us(uint32_t xus)
{SysTick->LOAD = 72 * xus;				//设置定时器重装值SysTick->VAL = 0x00;					//清空当前计数值SysTick->CTRL = 0x00000005;				//设置时钟源为HCLK,启动定时器while(!(SysTick->CTRL & 0x00010000));	//等待计数到0SysTick->CTRL = 0x00000004;				//关闭定时器
}/*** @brief  毫秒级延时* @param  xms 延时时长,范围:0~4294967295* @retval 无*/
void Delay_ms(uint32_t xms)
{while(xms--){Delay_us(1000);}
}/*** @brief  秒级延时* @param  xs 延时时长,范围:0~4294967295* @retval 无*/
void Delay_s(uint32_t xs)
{while(xs--){Delay_ms(1000);}
} 

Delay.h

#ifndef __DELAY_H
#define __DELAY_H#include "stm32f10x.h"                  // Device headervoid Delay_us(uint32_t us);
void Delay_ms(uint32_t ms);
void Delay_s(uint32_t s);#endif

Key.c

#include "stm32f10x.h"                  // Device header
#include "Key.h"
uint8_t KeyFlag = 0;    //按键标志typedef enum//按键状态
{KEY_CHECK =0,//检测KEY_CONFIRM = 1,//确认KEY_RELEASE = 2//释放
}KEY_STATE;KEY_STATE KeyState = KEY_CHECK;     //初始化按键状态为检测状态,KeyState是变量,KEY_CHECK是数值,初始化为0void Key_Init()
{RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOE,ENABLE);GPIO_InitTypeDef GPIO_InitStruct;GPIO_InitStruct.GPIO_Mode=GPIO_Mode_IPU;GPIO_InitStruct.GPIO_Pin=GPIO_Pin_2 | GPIO_Pin_3 | GPIO_Pin_4 | GPIO_Pin_6;GPIO_InitStruct.GPIO_Speed=GPIO_Speed_50MHz;GPIO_Init(GPIOE,&GPIO_InitStruct);
}uint8_t Key_Scan(void)
{static uint8_t KeyFlag = 0;    //按键标志switch(KeyState)//按键状态KeyState为0,1,2其中一个{case KEY_CHECK://按键状态:0if(!KEY)//如果按键值为0,说明按键被按下,切换状态,if是为1才能进入,按键按下了变为0,反转为1才进入{KeyState = KEY_CONFIRM;//按键状态从0切换为1}break;case KEY_CONFIRM://按键状态:1if(!KEY)//判断当前按键值是否为0,确认是否按下{KeyState = KEY_RELEASE;//按键状态从1切换为2if(0 == Key0)//KEY0被按下{KeyFlag = KEY0_PRES;//KEY0_PRES=1,KeyFlag=1}if(0 == Key1)//KEY1被按下{KeyFlag = KEY1_PRES;//KEY1_PRES=2,KeyFlag=2}if(0 == Key2)//KEY2被按下{KeyFlag = KEY2_PRES;//KEY2_PRES=3,KeyFlag=3}if(0 == Key3)//KEY3被按下{KeyFlag = KEY3_PRES;//KEY3_PRES=3,KeyFlag=4}}else//按键没有被按下,返回上一状态{KeyState = KEY_CHECK;}break;case KEY_RELEASE://按键状态:2if(KEY)//当前按键值为1,说明按键已经释放,切换到开始状态{KeyState = KEY_CHECK;//按键状态从2切换为0,以便下一次使用return KeyFlag;//释放以后才把按键数值返回}break;}return 0;
}

Key.h

#ifndef __KEY_H
#define __KEY_H
#include "stm32f10x.h"                  // Device header
#include "sys.h"#define Key0 PEin(4)
#define Key1 PEin(3)
#define Key2 PEin(2)
#define Key3 PEin(6)#define KEY    ((Key0) && (Key1) && (Key2)&& (Key3))//两个条件都为真时结果才为真,否则为假,我们按键只能按一个,无法同时按,人手速度没有这么快,所以始终无论哪个按键按下KEY都是0
#define KEY0_PRES 1
#define KEY1_PRES 2
#define KEY2_PRES 3
#define KEY3_PRES 4extern uint8_t KeyFlag;    //按键标志
void Key_Init(void);
uint8_t Key_Scan(void);    /*按键扫描函数*/#endif

sys.c


sys.h

#ifndef __SYS_H
#define __SYS_H	
#include "stm32f10x.h"//位带操作,实现51类似的GPIO控制功能
//具体实现思想,参考<<CM3权威指南>>第五章(87页~92页).
//IO口操作宏定义
#define BITBAND(addr, bitnum) ((addr & 0xF0000000)+0x2000000+((addr &0xFFFFF)<<5)+(bitnum<<2)) 
#define MEM_ADDR(addr)  *((volatile unsigned long  *)(addr)) 
#define BIT_ADDR(addr, bitnum)   MEM_ADDR(BITBAND(addr, bitnum)) 
//IO口地址映射
#define GPIOA_ODR_Addr    (GPIOA_BASE+12) //0x4001080C 
#define GPIOB_ODR_Addr    (GPIOB_BASE+12) //0x40010C0C 
#define GPIOC_ODR_Addr    (GPIOC_BASE+12) //0x4001100C 
#define GPIOD_ODR_Addr    (GPIOD_BASE+12) //0x4001140C 
#define GPIOE_ODR_Addr    (GPIOE_BASE+12) //0x4001180C 
#define GPIOF_ODR_Addr    (GPIOF_BASE+12) //0x40011A0C    
#define GPIOG_ODR_Addr    (GPIOG_BASE+12) //0x40011E0C    #define GPIOA_IDR_Addr    (GPIOA_BASE+8) //0x40010808 
#define GPIOB_IDR_Addr    (GPIOB_BASE+8) //0x40010C08 
#define GPIOC_IDR_Addr    (GPIOC_BASE+8) //0x40011008 
#define GPIOD_IDR_Addr    (GPIOD_BASE+8) //0x40011408 
#define GPIOE_IDR_Addr    (GPIOE_BASE+8) //0x40011808 
#define GPIOF_IDR_Addr    (GPIOF_BASE+8) //0x40011A08 
#define GPIOG_IDR_Addr    (GPIOG_BASE+8) //0x40011E08 //IO口操作,只对单一的IO口!
//确保n的值小于16!
#define PAout(n)   BIT_ADDR(GPIOA_ODR_Addr,n)  //输出 
#define PAin(n)    BIT_ADDR(GPIOA_IDR_Addr,n)  //输入 #define PBout(n)   BIT_ADDR(GPIOB_ODR_Addr,n)  //输出 
#define PBin(n)    BIT_ADDR(GPIOB_IDR_Addr,n)  //输入 #define PCout(n)   BIT_ADDR(GPIOC_ODR_Addr,n)  //输出 
#define PCin(n)    BIT_ADDR(GPIOC_IDR_Addr,n)  //输入 #define PDout(n)   BIT_ADDR(GPIOD_ODR_Addr,n)  //输出 
#define PDin(n)    BIT_ADDR(GPIOD_IDR_Addr,n)  //输入 #define PEout(n)   BIT_ADDR(GPIOE_ODR_Addr,n)  //输出 
#define PEin(n)    BIT_ADDR(GPIOE_IDR_Addr,n)  //输入#define PFout(n)   BIT_ADDR(GPIOF_ODR_Addr,n)  //输出 
#define PFin(n)    BIT_ADDR(GPIOF_IDR_Addr,n)  //输入#define PGout(n)   BIT_ADDR(GPIOG_ODR_Addr,n)  //输出 
#define PGin(n)    BIT_ADDR(GPIOG_IDR_Addr,n)  //输入#endif

LED.c

#include "stm32f10x.h"                  // Device header
#include "LED.h"void LED_Init(void)
{RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB,ENABLE);RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOE,ENABLE);RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC,ENABLE);GPIO_InitTypeDef GPIO_InitStruct;GPIO_InitStruct.GPIO_Mode=GPIO_Mode_Out_PP;GPIO_InitStruct.GPIO_Pin=GPIO_Pin_5;GPIO_InitStruct.GPIO_Speed=GPIO_Speed_50MHz;	GPIO_Init(GPIOB,&GPIO_InitStruct);GPIO_SetBits(GPIOB,GPIO_Pin_5);GPIO_InitStruct.GPIO_Mode=GPIO_Mode_Out_PP;GPIO_InitStruct.GPIO_Pin=GPIO_Pin_12;GPIO_InitStruct.GPIO_Speed=GPIO_Speed_50MHz;	GPIO_Init(GPIOC,&GPIO_InitStruct);GPIO_SetBits(GPIOC,GPIO_Pin_12);GPIO_InitStruct.GPIO_Mode=GPIO_Mode_Out_PP;GPIO_InitStruct.GPIO_Pin=GPIO_Pin_5;GPIO_InitStruct.GPIO_Speed=GPIO_Speed_50MHz;	GPIO_Init(GPIOE,&GPIO_InitStruct);GPIO_SetBits(GPIOE,GPIO_Pin_5);
}

LED.h

#ifndef __LED_H
#define __LED_H
#include "sys.h"
void LED_Init(void);
#define LED_Red   PBout(5)
#define LED_Green PEout(5)
#define Beep   PCout(12)#endif

Motor.c

#include "stm32f10x.h"                  // Device header
#include "PWM.h"
//IN1和IN2分别接PA4和PA5,然后P4和P5就是用作普通引脚输出高低电平。
void Motor_Init(void)
{RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);GPIO_InitTypeDef GPIO_InitStructure;GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4 | GPIO_Pin_5;GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;GPIO_Init(GPIOA, &GPIO_InitStructure);PWM_Init();
}void Motor_SetSpeed(int8_t Speed)
{if (Speed >= 0){GPIO_SetBits(GPIOA, GPIO_Pin_4);GPIO_ResetBits(GPIOA, GPIO_Pin_5);PWM_SetCompare3(Speed);}else{GPIO_ResetBits(GPIOA, GPIO_Pin_4);GPIO_SetBits(GPIOA, GPIO_Pin_5);PWM_SetCompare3(-Speed);}
}

Motor.h

#ifndef __MOTOR_H
#define __MOTOR_H
#include "stm32f10x.h"                  // Device headervoid Motor_Init(void);
void Motor_SetSpeed(int8_t Speed);#endif

PWM.c

#include "stm32f10x.h"                  // Device header
//ENA接PA2,因为PA2是TIM2_CH3,用于输出PWM,
void PWM_Init(void)
{RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE);RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);GPIO_InitTypeDef GPIO_InitStructure;GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2;GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;GPIO_Init(GPIOA, &GPIO_InitStructure);TIM_InternalClockConfig(TIM2);TIM_TimeBaseInitTypeDef TIM_TimeBaseInitStructure;TIM_TimeBaseInitStructure.TIM_ClockDivision = TIM_CKD_DIV1;TIM_TimeBaseInitStructure.TIM_CounterMode = TIM_CounterMode_Up;TIM_TimeBaseInitStructure.TIM_Period = 100 - 1;		//ARRTIM_TimeBaseInitStructure.TIM_Prescaler = 36 - 1;		//PSCTIM_TimeBaseInitStructure.TIM_RepetitionCounter = 0;TIM_TimeBaseInit(TIM2, &TIM_TimeBaseInitStructure);TIM_OCInitTypeDef TIM_OCInitStructure;TIM_OCStructInit(&TIM_OCInitStructure);TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1;TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High;TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;TIM_OCInitStructure.TIM_Pulse = 0;		//CCRTIM_OC3Init(TIM2, &TIM_OCInitStructure);TIM_Cmd(TIM2, ENABLE);
}void PWM_SetCompare3(uint16_t Compare)
{TIM_SetCompare3(TIM2, Compare);
}

PWM.h

#ifndef __PWM_H
#define __PWM_H
#include "stm32f10x.h"                  // Device headervoid PWM_Init(void);
void PWM_SetCompare3(uint16_t Compare);#endif

Dht11.c

#include "stm32f10x.h"                  // Device header
#include "Dht11.h"
#include "Delay.h"char datas[5]; 		//数组分别代表,湿度,湿度小数,温度,温度小数,校验和void DHT11_Init_Out(void)
{RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA,ENABLE);GPIO_InitTypeDef GPIO_InitStruct;GPIO_InitStruct.GPIO_Mode=GPIO_Mode_Out_PP;GPIO_InitStruct.GPIO_Pin=GPIO_Pin_7;GPIO_InitStruct.GPIO_Speed=GPIO_Speed_50MHz;GPIO_Init(GPIOA,&GPIO_InitStruct);
}void DHT11_Init_In(void)
{RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA,ENABLE);GPIO_InitTypeDef GPIO_InitStruct;GPIO_InitStruct.GPIO_Mode=GPIO_Mode_IPU;GPIO_InitStruct.GPIO_Pin=GPIO_Pin_7;GPIO_InitStruct.GPIO_Speed=GPIO_Speed_50MHz;GPIO_Init(GPIOA,&GPIO_InitStruct);
}//初始化模块(检测模块是否存在)每次传输数据都要初始化
uint8_t DHT_Start()
{DHT11_Init_Out();//输出模式//根据时序进行高低电平变化dhtout = 0;Delay_ms(20);dhtout=1;Delay_us(20);//主机拉高20usDHT11_Init_In();//输入状态if(!dhtin) //判断DHT有没有响应信号,dhtin =0的话则代表DHT发送了响应信号{while(!dhtin);//DHT正在发送响应信号,dhtin =0,等待变为高电平(dhtin =1)则退出循环while(dhtin);//dhtin =1,DHT处于高电平状态,等待变为低电平则退出循环,则代表开始传送数据return 1;//代表开始传送数据}return 0;//代表没有开始传送数据
}char DHT_Get_Data()
{uint8_t buffer=0;for(int i=0;i<8;i++){buffer<<=1;//一共八次,每次向左移1位while(!dhtin);//主机信号,等待低电平结束,无论是数据0还是1都是54us,不需要管,等待结束即可Delay_us(30);//30us后如果是高电平就是数字1,低电平就是数字0dhtin ? (buffer|=0x01) : (buffer&= ~0x01);//三目运算符,如果dhtin为1,则执行buffer|=0x01,否则buffer&= ~0x01while(dhtin);//30us后,因为高电平是68us-74us,高电平还有多的时间,需要等待高电平结束,如果是低电平,直接就跳过去了}return buffer;
}uint8_t DHT_Read(void)
{if(DHT_Start())//如果开始传输数据则,进入条件{datas[0]=DHT_Get_Data();datas[1]=DHT_Get_Data();datas[2]=DHT_Get_Data();datas[3]=DHT_Get_Data();datas[4]=DHT_Get_Data();Delay_us(60);//传感器释放总线时间	}if(datas[4]==(datas[0]+datas[1]+datas[2]+datas[3]))//校验和{return 1;}else{return 0;}}

Dht11.h

#ifndef __DHT11_H
#define __DHT11_H
#include "sys.h"
#define dhtout PAout(7)
#define dhtin PAin(7)extern char datas[5];
void DHT11_Init_In(void);
void DHT11_Init_Out(void);
uint8_t DHT_Read(void);#endif

Timer.c

#include "stm32f10x.h"                  // Device header
#include "LED.h"
#include "Key.h"volatile uint32_t global_times = 0;
volatile uint32_t BEEP_TIME = 0;
volatile uint32_t Temp_time=0;void Timer_Init(void)
{RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM4, ENABLE);TIM_TimeBaseInitTypeDef TIM_TimeBaseInitStructure;TIM_TimeBaseInitStructure.TIM_ClockDivision = TIM_CKD_DIV1;TIM_TimeBaseInitStructure.TIM_CounterMode = TIM_CounterMode_Up;TIM_TimeBaseInitStructure.TIM_Period = 1000 - 1;TIM_TimeBaseInitStructure.TIM_Prescaler = 72 - 1;TIM_TimeBaseInitStructure.TIM_RepetitionCounter = 0;TIM_TimeBaseInit(TIM4, &TIM_TimeBaseInitStructure);TIM_ClearFlag(TIM4, TIM_FLAG_Update);TIM_ITConfig(TIM4, TIM_IT_Update, ENABLE);NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);NVIC_InitTypeDef NVIC_InitStructure;NVIC_InitStructure.NVIC_IRQChannel = TIM4_IRQn;NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 2;NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;NVIC_Init(&NVIC_InitStructure);TIM_Cmd(TIM4, ENABLE);
}void TIM4_IRQHandler(void)
{if (TIM_GetITStatus(TIM4, TIM_IT_Update) == SET)//1ms{global_times++;BEEP_TIME ++;Temp_time ++;if(global_times ==20)//20ms进入检测按键一次{KeyFlag =Key_Scan();global_times=0;}TIM_ClearITPendingBit(TIM4, TIM_IT_Update);}
}

Timer.h

#ifndef __TIMER_H
#define __TIMER_H
#include "stm32f10x.h"                  // Device headerextern volatile uint32_t global_times;
extern volatile uint32_t BEEP_TIME;
extern volatile uint32_t Temp_time;
void Timer_Init(void);#endif

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/686921.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

MIPS指令集处理器设计(支持64条汇编指令)

一、题目背景和意义 二、国内外研究现状 (略) 三、MIPS指令集处理器设计与实现 (一).MIPS指令集功能性梳理 1.MIPS指令集架构 (1).mips基础指令集格式总结 MIPS是&#xff08;Microcomputer without interlocked pipeline stages&#xff09;[10]的缩写&#xff0c;含义是…

C++友元->全局函数做友元、类做友元、成员函数做友元

全局函数做友元代码&#xff1a; #include<iostream> using namespace std; #include<string> //建筑物类 class Building { //告诉编译器 goodGay全局函数 是 Building类的好朋友&#xff0c;可以访问类中的私有内容 friend void goodGay(Building * bu…

第14讲投票帖子详情实现

投票帖子详情实现 后端,根据id查询投票帖子信息&#xff1a; /*** 根据id查询* param id* return*/ GetMapping("/{id}") public R findById(PathVariable(value "id")Integer id){Vote vote voteService.getById(id);WxUserInfo wxUserInfo wxUserInf…

电商+支付双系统项目------设计数据库

这篇文章将详细介绍电商支付双系统项目的数据库设计。数据库在该项目中扮演着至关重要的角色&#xff0c;它负责存储和管理用户信息、商品数据、订单记录以及支付交易等关键数据。通过精心设计和优化数据库结构&#xff0c;可以实现高效的数据存储和检索&#xff0c;确保系统的…

JavaScript中的常见算法

一.排序算法 1.冒泡排序 冒泡排序比较所有相邻的两个项&#xff0c;如果第一个比第二个大&#xff0c;则交换它们。元素项向上移动至 正确的顺序&#xff0c;就好像气泡升至表面一样。 function bubbleSort(arr) {const { length } arrfor (let i 0; i < length - 1; i)…

详解自定义类型:枚举与联合体!

目录 ​编辑 一、枚举类型 1.枚举类型的声明 2.枚举类型的优点 3.枚举类型的使用 二、联合体类型(共用体&#xff09; 1.联合体类型的声明 2.联合体的特点 3.相同成员的结构体和联合体的对比 4.联合体大小的计算 5.用联合体判断大小端 三.完结散花 悟已往之不谏&…

深入浅出了解谷歌「Gemini大模型」发展历程

Google在2023年12月官宣了Gemini模型&#xff0c;随后2024年2月9日才宣布Gemini 1.0 Ultra正式对公众服务&#xff0c;并且开始收费。现在2024年2月14日就宣布了Gemini 1.5 Pro&#xff0c;史诗级多模态最强MoE首破100万极限上下文纪录&#xff01;&#xff01;&#xff01;Gem…

数据分析 — Pandas 数据加载、存储和清洗

目录 一、文件读取1、常见文件读取函数2、read_csv()3、read_table()4、read_excel()5、read_json()6、read_html()7、大文件读取 二、数据保存1、csv2、excel3、json4、html5、MySQL1、连接数据库2、MySQL 存储到本地3、本地存储到 MySQL 三、数据清洗1、处理缺失值1、判断数据…

Aster实现一台电脑当两台使——副屏使用独立win账号

前言&#xff1a;笔者每年回家&#xff0c;都面临着想要和小伙伴一起玩游戏&#xff0c;但小伙伴没有电脑/只有低配电脑的问题。与此同时&#xff0c;笔者自身的电脑是高配置的电脑&#xff0c;因此笔者想到&#xff0c;能否在自己的电脑上运行游戏&#xff0c;在小伙伴的电脑上…

LaTeX中的documentclass命令:指定文档的类型和整体布局

诸神缄默不语-个人CSDN博文目录 documentclass 是 LaTeX 中一个基础且重要的命令&#xff0c;用于定义文档的整体布局和样式。这个命令告诉 LaTeX 编译器文档是属于哪一类的&#xff0c;比如是文章、报告、书籍等&#xff0c;每一类都有其预定义的格式和结构。 文章目录 基本语…

怎么恢复电脑重装前的数据?介绍几种有效的方法

在日常生活和工作中&#xff0c;电脑已成为我们不可或缺的工具。然而&#xff0c;有时候我们会遇到一些突发情况&#xff0c;比如电脑系统崩溃需要重新安装系统。在这个过程中&#xff0c;我们可能会失去一些重要的数据&#xff0c;比如照片、文档、视频等。这些数据可能包含着…

基于springboot车辆充电桩管理系统源码和论文

随着信息化时代的到来&#xff0c;管理系统都趋向于智能化、系统化&#xff0c;车辆充电桩管理系统也不例外&#xff0c;但目前国内仍都使用人工管理&#xff0c;市场规模越来越大&#xff0c;同时信息量也越来越庞大&#xff0c;人工管理显然已无法应对时代的变化&#xff0c;…

马斯克评 OpenAI 视频模型,接地气又一针见血

马斯克评 OpenAI Sora 昨天&#xff0c;OpenAI 发布了首个视频生成模型 Sora。 一位 X&#xff08;前推特&#xff09;用户分享了 Sora 官网所展示的生成视频&#xff1a;一名女子在东京街头漫步。 该用户评论称&#xff1a;"OpenAI 今天宣布了 Sora&#xff0c;它使用混合…

为什么MySQL不建议使用TEXT字段?

当我们深入探讨“为什么MySQL不建议使用TEXT字段&#xff1f;”这一问题时&#xff0c;可以从一下多个方面来详细理解这个问题&#xff1a; 1. 性能问题 性能问题是MySQL不建议使用TEXT字段的一个重要原因。TEXT字段通常以外部存储方式保存&#xff0c;而不是像固定长度或可变…

C# winfrom实例:四路激光测距雷达数据采集和波形图绘制

1.所述产品 产品型号&#xff1a;TFmini Plus 相关资料下载地址&#xff1a;http://www.benewake.com/download 产品名称&#xff1a;TFmini Plus激光雷达模组制造商公司&#xff1a;北醒&#xff08;北京&#xff09;光子科技有限公司 2.产品功能&#xff1a;TFmini Plus是基…

实现低功耗设计的嵌入式系统技术

&#xff08;本文为简单介绍&#xff0c;观点来源网络&#xff09; 在嵌入式系统设计中&#xff0c;追求低功耗已成为一个核心指标&#xff0c;旨在延长设备的运行时间并提升能效。实现这一目标的途径是多元的&#xff0c;涉及从硬件选型到软件算法的各个层面。 首先&#xf…

【Py/Java/C++三种语言详解】LeetCode每日一题240217【二叉树BFS】LeetCode429、N叉树的层序遍历

有LeetCode交流群/华为OD考试扣扣交流群可加 948025485 可上全网独家的 欧弟OJ系统 练习华子OD、大厂真题 绿色聊天软件戳 od1336了解算法冲刺训练 文章目录 题目链接题目链接题目描述解题思路DFS和BFS异同用队列维护的BFS 代码PythonJavaC时空复杂度 相关习题华为OD算法/大厂面…

基于MapVGL的地理信息三维度数据增长可视化

写在前面 工作中接触&#xff0c;简单整理博文内容为 基于MapVGL的地理信息维度数据增长可视化 Demo理解不足小伙伴帮忙指正 对每个人而言&#xff0c;真正的职责只有一个&#xff1a;找到自我。然后在心中坚守其一生&#xff0c;全心全意&#xff0c;永不停息。所有其它的路都…

市场复盘总结 20240208

仅用于记录当天的市场情况&#xff0c;用于统计交易策略的适用情况&#xff0c;以便程序回测 短线核心&#xff1a;不参与任何级别的调整&#xff0c;采用龙空龙模式 一支股票 10%的时候可以操作&#xff0c; 90%的时间适合空仓等待 二进三&#xff1a; 进级率中 25% 最常用的…

LGAMEFI基于BPL公链开发的第一生态:开启RWA游戏娱乐与DeFi融合的新纪元

在去中心化金融&#xff08;DeFi&#xff09;与游戏娱乐的结合趋势中&#xff0c;BPL公链上的LGAMEFI项目代表了前沿的技术革新和市场领导。这种将web2上成熟页游进行RWA链改&#xff0c;不仅仅是将游戏热门领域融合&#xff0c;更是在寻找一种全新的参与者经验&#xff0c;将玩…