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.rhkb.cn/news/258797.html

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

相关文章

免费chatgpt使用

基本功能如下&#xff1a; https://go.aigcplus.cc/auth/register?inviteCode3HCULH2UD

TensorRT转换onnx的Transpose算子遇到的奇怪问题

近来把一个模型导出为onnx并用onnx simplifier化简后转换为TensorRT engine遇到非常奇怪的问题&#xff0c;在我们的网络中有多个检测头时&#xff0c;转换出来的engine的推理效果是正常的&#xff0c;当网络中只有一个检测头时&#xff0c;转换出来的engine的推理效果奇差&…

OpenCV-42 直方图均匀化

目录 一、直方图均匀化原理 二、直方图均匀化在OpenCV中的运用 一、直方图均匀化原理 直方图均匀化是通过拉伸像素强度的分布范围&#xff0c;使得在0~255灰阶上的分布更加均匀&#xff0c;提高图像的对比度。达到改善图像主管视觉效果的目的。对比度较低的图像适合使用直方…

Flink理论—容错之状态

Flink理论—容错之状态 在 Flink 的框架中&#xff0c;进行有状态的计算是 Flink 最重要的特性之一。所谓的状态&#xff0c;其实指的是 Flink 程序的中间计算结果。Flink 支持了不同类型的状态&#xff0c;并且针对状态的持久化还提供了专门的机制和状态管理器。 Flink 使用…

HCIA-HarmonyOS设备开发认证V2.0-轻量系统内核基础-互斥锁mux

目录 一、互斥锁基本概念二、互斥锁运行机制三、互斥锁开发流程四、互斥锁使用说明五、互斥锁接口六、代码分析&#xff08;待续...&#xff09; 一、互斥锁基本概念 互斥锁又称互斥型信号量&#xff0c;是一种特殊的二值性信号量&#xff0c;用于实现对共享资源的独占式处理。…

Nginx (window)2024版 笔记 下载 安装 配置

前言 Nginx (engine x) 是一款轻量级的 Web 服务器 、反向代理&#xff08;Reverse Proxy&#xff09;服务器及电子邮件&#xff08;IMAP/POP3&#xff09;代理服务器。 反向代理方式是指以代理服务器来接受 internet 上的连接请求&#xff0c;然后将请求转发给内部网络上的服…

C++ //练习 6.3 编写你自己的fact函数,上机检查是否正确。

C Primer&#xff08;第5版&#xff09; 练习 6.3 练习 6.3 编写你自己的fact函数&#xff0c;上机检查是否正确。 环境&#xff1a;Linux Ubuntu&#xff08;云服务器&#xff09; 工具&#xff1a;vim 代码块 /********************************************************…

数据结构~二叉树(基础知识)

上一篇博客我们对树有了初步了解与学习&#xff0c;这篇我将初步学习二叉树&#xff01;&#xff01;&#xff08;新年快乐&#xff01;&#xff09; 目录 二叉树 1、定义&#xff1a; 2、特点&#xff1a; 3、基本形态&#xff1a; 4、二叉树的种类&#xff1a; &…

精工电联:定制精工线缆,赋能科技互联---致力于为客户提供卓越的连接线缆和连接器产品

精工电联 “定制精工线缆 &#xff0c;赋能科技互联”&#xff0c;精工电联致力于为高科技产业提供全方位、多维度的集成线缆解决方案。凭借深厚的研发实力和丰富的行业经验&#xff0c;精工电联已经成功地在工控设备、医疗设备、人工智能、新能源领域、轨道交通和超声波设备等…

数学建模【非线性规划】

一、非线性规划简介 通过分析问题判断是用线性规划还是非线性规划 线性规划&#xff1a;模型中所有的变量都是一次方非线性规划&#xff1a;模型中至少一个变量是非线性 非线性规划在形式上与线性规划非常类似&#xff0c;但在数学上求解却困难很多 线性规划有通用的求解准…

实战 | 使用CNN和OpenCV实现数字识别项目(步骤 + 源码)

导 读 本文主要介绍使用CNN和OpenCV实现数字识别项目,含详细步骤和源码。 前 言 在当今世界,深度学习和图像处理技术正在各个应用领域得到利用。在这篇博文中,我们将使用卷积神经网络 (CNN) 和 OpenCV 库完成数字识别项目。我们将逐步掌握该项目如何执行。 项目准…

Git 初学

目录 一、需求的产生 二、版本控制系统理解 1. 认识版本控制系统 2. 版本控制系统分类 &#xff08;1&#xff09;集中式版本控制系统 缺点&#xff1a; &#xff08;2&#xff09;分布式版本控制系统 三、初识 git 四、git 的使用 例&#xff1a;将 “ OLED文件夹 ”…

Nuxt3+Vue3(Composition API)+TS+Vite+Ant Design Vue 搭建

最近官网搭建选择了nuxtjs&#xff0c;由于框架更新了&#xff0c;其中语法也有很多变化&#xff0c;中间遇到了一些问题点做下总结。 nuxt3官方文档地址&#xff1a;https://nuxt.com/docs/getting-started/installation 安装 在安装Nuxt3之前&#xff0c;你需要保证你的nod…

如何使用iptables或者firewalld配置Linux系统的防火墙策略

在网络安全中&#xff0c;防火墙是一种关键的安全设备&#xff0c;用于保护计算机网络免受恶意攻击和未经授权的访问。在Linux系统中&#xff0c;我们可以使用iptables或者firewalld来配置防火墙策略。本文将介绍如何使用这两种工具来配置Linux系统的防火墙策略&#xff0c;包括…

java8-重构、测试、调试

8.1.1 改善代码的可读性 改善代码的可读性到底意味着什么?我们很难定义什么是好的可读性&#xff0c;因为这可能非常主观。通常的理解是&#xff0c;“别人理解这段代码的难易程度”。改善可读性意味着你要确保你的代码能非常容易地被包括自己在内的所有人理解和维护。为了确保…

php基础学习之函数

基本概念 是一种语法结构&#xff0c;将实现某一个功能的代码块封装到一个结构中&#xff0c;从而实现代码的重复利用 php函数的定义语法 &#xff08;与C/Java很类似&#xff0c;区别在于没有数据类型&#xff0c;因为php是弱类型语言&#xff09; function 函数名(参数){ //…

问题:内存时序参数 CASLatency 是() #学习方法#微信#微信

问题&#xff1a;内存时序参数 CASLatency 是&#xff08;&#xff09; A&#xff0e;行地址控制器延迟时间 B&#xff0e;列地址至行地址延迟时间 C&#xff0e;列地址控制器预充电时间 D&#xff0e;列动态时间 参考答案如图所示

HTML-多媒体嵌入-MDN文档学习笔记

HTML-多媒体与嵌入 查看更多学习笔记&#xff1a;GitHub&#xff1a;LoveEmiliaForever MDN中文官网 HTML-中的图片 将图片放入网页 可以使用<img/>来将图片嵌入网页&#xff0c;它是一个空元素&#xff0c;最少只需src属性即可工作 <img src"图片链接"…

图像卷积、步长、填充、特征图、多通道卷积、权重共享、感受野、池化

图像卷积、步长、填充、特征图、多通道卷积、权重共享、感受野、池化 卷积神经网络的一些基本概念&#xff1a;图像卷积、步长、填充、特征图、多通道卷积、权重共享、感受野、池化 1.图像卷积、步长、填充 图像卷积&#xff1a;卷积核矩阵在一个原始图像矩阵上 “从上往下、…

CF1845 D. Rating System [思维题+数形结合]

传送门:CF [前题提要]:自己在做这道题的时候思路完全想错方向,导致怎么做都做不出来,看了题解之后感觉数形结合的思考方式挺好的(或者这种做法挺典的),故写篇题解记录一下 题目很简单,不再解释.先不考虑 k k k,想想是一种什么情况?很显然应该是跟下图一样是一个折线图的变化.…