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"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_Show(void)//一级界面
{if(uuflag ==0)//主函数循环里面不断循环,如果为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_gongneng(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_Show();//一级界面Key_gongneng();//二级界面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);}}}//这里加这个蜂鸣器纯属想让你们知道按键按下按次数多了某个时刻定时器不一定会==500,必须>=500,按键不按下的时候又恢复成==500if(BEEP_TIME>=500)//500ms响一次蜂鸣器,不受按键影响,这里必须写大于,因为OLED按的某个时刻有可能计数值大于500{Beep =!Beep;BEEP_TIME =0;}}
}

OLED.c

#include "stm32f10x.h"
#include "Dht11.h"/*-------------------------此处添加所要加入的中文字库--------------------------*/
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,};
/*-------------------------此处添加所要加入的英文符号数字字库--------------------------*/
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};/*-------------------------此处添加所要加入的英文符号数字字库,颜色反转--------------------------*/
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};/*引脚配置*/
#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++;}
}//初始一级界面
//*选择颜色灯(颜色反转)
// 查看温度
// 风扇开关选择
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);}

OLED.h

#ifndef __OLED_H
#define __OLED_H
#include "stm32f10x.h"                  // Device headervoid OLED_Init(void);
void Oled_clear(void);// 清屏函数
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);//显示数字,颜色反转
void 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/258147.html

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

相关文章

Vulnhub靶机:DC6

一、介绍 运行环境&#xff1a;Virtualbox 攻击机&#xff1a;kali&#xff08;10.0.2.15&#xff09; 靶机&#xff1a;DC6&#xff08;10.0.2.59&#xff09; 目标&#xff1a;获取靶机root权限和flag 靶机下载地址&#xff1a;https://www.vulnhub.com/entry/dc-6,315/…

《MySQL 简易速速上手小册》第9章:高级 MySQL 特性和技巧(2024 最新版)

文章目录 9.1 使用存储过程和触发器9.1.1 基础知识9.1.2 重点案例&#xff1a;使用 Python 调用存储过程实现用户注册9.1.3 拓展案例 1&#xff1a;利用触发器自动记录数据更改历史9.1.4 拓展案例 2&#xff1a;使用 Python 和触发器实现数据完整性检查 9.2 管理和查询 JSON 数…

[网鼎杯 2020 朱雀组]phpweb

抓包发现两个参数&#xff0c;结合报文返回的warning猜测两个参数一个传函数名&#xff0c;另一个传函数参数 尝试直接system(ls /)&#xff0c;发现被过滤了 file_get_contents获取index.php的源码&#xff0c;发现可以反序列化实现RCE 这里复现的时候不知道为什么显示不全…

力扣例题----二叉树

文章目录 1. 100.相同的树2. 572. 另一颗树的子树3. 266.翻转二叉树4. LCR 175.计算二叉树的深度5. 110.平衡二叉树6. 101. 对称二叉树7. 牛客题目&#xff1a;KY11 二叉树遍历8. 102.二叉树的层序遍历9. 236.二叉树的最近公共祖先10. 105.根据前序和中序构造一棵二叉树11. 106…

python 人脸检测器

import cv2# 加载人脸检测器 关键文件 haarcascade_frontalface_default.xml face_cascade cv2.CascadeClassifier(haarcascade_frontalface_default.xml)# 读取图像 分析图片 ren4.png image cv2.imread(ren4.png) gray cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)# 进行人脸…

COM初体验——新建文档并写入内容。

我想在程序里和Word交互。老师跟我说不要学COM&#xff0c;因为它已经过时了。但是我不想再把代码移植到C#上面&#xff0c;然后用VSTO——已经用了std::unordered_set&#xff01;因为我使用了Copilot&#xff0c;结合我的思考&#xff0c;写了下面的代码&#xff1a; #impor…

17.JS中的object、map和weakMap

1.object和map的区别 2.weakMap和map的区别 &#xff08;1&#xff09;Map本质上就是键值对的集合&#xff0c;但是普通的Object中的键值对中的键只能是字符串。而ES6提供的Map数据结构类似于对象&#xff0c;但是它的键不限制范围&#xff0c;可以是任意类型&#xff0c;是一…

【C++】友元、内部类和匿名对象

&#x1f497;个人主页&#x1f497; ⭐个人专栏——C学习⭐ &#x1f4ab;点击关注&#x1f929;一起学习C语言&#x1f4af;&#x1f4ab; 目录 1. 友元 1.1 友元函数 1.2 友元类 2. 内部类 2.1 成员内部类 2.2 局部内部类 3. 匿名对象 3.1 基本概念 3.1 隐式转换 1…

【Spring原理进阶】SpringMVC调用链+JSP模板应用讲解

&#x1f389;&#x1f389;欢迎光临&#x1f389;&#x1f389; &#x1f3c5;我是苏泽&#xff0c;一位对技术充满热情的探索者和分享者。&#x1f680;&#x1f680; &#x1f31f;特别推荐给大家我的最新专栏《Spring 狂野之旅&#xff1a;底层原理高级进阶》 &#x1f680…

机器学习入门--循环神经网络原理与实践

循环神经网络 循环神经网络&#xff08;RNN&#xff09;是一种在序列数据上表现出色的人工神经网络。相比于传统前馈神经网络&#xff0c;RNN更加适合处理时间序列数据&#xff0c;如音频信号、自然语言和股票价格等。本文将介绍RNN的基本数学原理、使用PyTorch和Scikit-Learn…

PLC_博图系列☞FBD

PLC_博图系列☞FBD 文章目录 PLC_博图系列☞FBD背景介绍FBD优势局限性 FBD 元素 关键字&#xff1a; PLC、 西门子、 博图、 Siemens 、 FBD 背景介绍 这是一篇关于PLC编程的文章&#xff0c;特别是关于西门子的博图软件。我并不是专业的PLC编程人员&#xff0c;也不懂电路…

深度学习之梯度下降算法

梯度下降算法 梯度下降算法数学公式结果 梯度下降算法存在的问题随机梯度下降算法 梯度下降算法 数学公式 这里案例是用梯度下降算法&#xff0c;来计算 y w * x 先计算出梯度&#xff0c;再进行梯度的更新 import numpy as np import matplotlib.pyplot as pltx_data [1.0,…

心理辅导|高校心理教育辅导系统|基于Springboot的高校心理教育辅导系统设计与实现(源码+数据库+文档)

高校心理教育辅导系统目录 目录 基于Springboot的高校心理教育辅导系统设计与实现 一、前言 二、系统功能设计 三、系统实现 1、学生功能模块的实现 &#xff08;1&#xff09;学生登录界面 &#xff08;2&#xff09;留言反馈界面 &#xff08;3&#xff09;试卷列表界…

2.7日学习打卡----初学RabbitMQ(二)

2.7日学习打卡 目录&#xff1a; 2.7日学习打卡一. RabbitMQ 简单模式![在这里插入图片描述](https://img-blog.csdnimg.cn/direct/42009c68e078440797c3183ffda6955d.png)生产者代码实现消费者代码实现 二. RabbitMQ 工作队列模式生产者代码实现消费者代码实现 三. RabbitMQ 发…

【天衍系列 04】深入理解Flink的ElasticsearchSink组件:实时数据流如何无缝地流向Elasticsearch

文章目录 01 Elasticsearch Sink 基础概念02 Elasticsearch Sink 工作原理03 Elasticsearch Sink 核心组件04 Elasticsearch Sink 配置参数05 Elasticsearch Sink 依赖管理06 Elasticsearch Sink 初阶实战07 Elasticsearch Sink 进阶实战7.1 包结构 & 项目配置项目配置appl…

《杨绛传:生活不易,保持优雅》读书摘录

目录 书简介 作者成就 书中内容摘录 良好的家世背景&#xff0c;书香门第为求学打基础 求学相关 念大学 清华研究生 自费英国留学 法国留学自学文学 战乱时期回国 当校长 当小学老师 创造话剧 支持钱锺书写《围城》 出任震旦女子文理学院的教授 接受清华大学的…

【AIGC】Stable Diffusion的ControlNet参数入门

Stable Diffusion 中的 ControlNet 是一种用于控制图像生成过程的技术&#xff0c;它可以指导模型生成特定风格、内容或属性的图像。下面是关于 ControlNet 的界面参数的详细解释&#xff1a; 低显存模式 是一种在深度学习任务中用于处理显存受限设备的技术。在这种模式下&am…

【AIGC】Stable Diffusion的模型入门

下载好相关模型文件后&#xff0c;直接放入Stable Diffusion相关目录即可使用&#xff0c;Stable Diffusion 模型就是我们日常所说的大模型&#xff0c;下载后放入**\webui\models\Stable-diffusion**目录&#xff0c;界面上就会展示相应的模型选项&#xff0c;如下图所示。作者…

【C++】 为什么多继承子类重写的父类的虚函数地址不同?『 多态调用汇编剖析』

&#x1f440;樊梓慕&#xff1a;个人主页 &#x1f3a5;个人专栏&#xff1a;《C语言》《数据结构》《蓝桥杯试题》《LeetCode刷题笔记》《实训项目》《C》《Linux》《算法》 &#x1f31d;每一个不曾起舞的日子&#xff0c;都是对生命的辜负 前言 本篇文章主要是为了解答有…

Pytest测试技巧之Fixture:模块化管理测试数据

在 Pytest 测试中&#xff0c;有效管理测试数据是提高测试质量和可维护性的关键。本文将深入探讨 Pytest 中的 Fixture&#xff0c;特别是如何利用 Fixture 实现测试数据的模块化管理&#xff0c;以提高测试用例的清晰度和可复用性。 什么是Fixture&#xff1f; 在 Pytest 中&a…