OLED有多个控制显示界面,四按键控制
支持单数据线连接多个DS18b20,自动搜索显示
控制界面设定温度阈值,控制电机1,2,3档调速
部分 STM32代码:
- #include "display.h"
- #include "delay.h"
- extern u8 display;//页面函数
- void OLED_on1() //主页显示程序
- {
- OLED_Clear();
- OLED_ShowCHinese(16,0,0);//数
- OLED_ShowCHinese(32,0,1);//子
- OLED_ShowCHinese(48,0,2);//散
- OLED_ShowCHinese(64,0,3);//热
- OLED_ShowCHinese(80,0,4);//系
- OLED_ShowCHinese(96,0,5);//统
-
- OLED_ShowCHinese(0,2,6);//温
- OLED_ShowCHinese(16,2,7);//度
- OLED_ShowChar(32,2,':',16);//:
- OLED_ShowChar(64,2,'.',16);//.
- OLED_ShowCHinese(80,2,14);//℃
-
- OLED_ShowCHinese(0,4,6);//温
- OLED_ShowCHinese(16,4,7);//度
- OLED_ShowChar(32,4,':',16);//:
- OLED_ShowChar(64,4,'.',16);//.
- OLED_ShowCHinese(80,4,14);//℃
- OLED_ShowCHinese(64,6,8);//风
- OLED_ShowCHinese(80,6,9);//速
- OLED_ShowChar(96,6,':',16);//:
- OLED_ShowCHinese(104,6,18);//关
-
- while(DS18B20_Init())//初始化DS18B20,18B20
- {
- delay_ms(400);
- OLED_ShowCHinese(0,6,11); //未
- OLED_ShowCHinese(16,6,12);//连
- OLED_ShowCHinese(32,6,13);//接
- OLED_ShowChar(48,6,'!',16);
- }
- if(DS18B20_Init()==0)
- {
- OLED_ShowCHinese(0,6,10); //已
- OLED_ShowCHinese(16,6,12);//连
- OLED_ShowCHinese(32,6,13);//接
- OLED_ShowChar(48,6,':',16);
- }
- }
- void OLED_on2()
- {
- OLED_Clear();
- OLED_ShowCHinese(48,0,22);//设
- OLED_ShowCHinese(64,0,23);//置
-
- OLED_ShowString(8,2,"WiFi" ,16);
- OLED_ShowChar(40,2,':',16);//:
-
- OLED_ShowCHinese(8,4,19); //散
- OLED_ShowCHinese(24,4,20); //热
- OLED_ShowCHinese(40,4,37);//方
- OLED_ShowCHinese(56,4,38);//式
- OLED_ShowChar(72,4,':',16);//:
-
- OLED_ShowCHinese(8,6,18); //关
- OLED_ShowCHinese(24,6,41);//闭
- OLED_ShowCHinese(40,6,42);//显
- OLED_ShowCHinese(56,6,43);//示
- OLED_ShowChar(72,6,':',16);//:
- OLED_ShowString(80,6,"K1||K2" ,16);
- }
- void OLED_on3()
- {
- OLED_Clear();
- OLED_ShowCHinese(32,0,24);//参
- OLED_ShowCHinese(48,0,25);//数
- OLED_ShowCHinese(64,0,26);//调
- OLED_ShowCHinese(80,0,27);//节
-
- OLED_ShowCHinese(8,2,6);//温
- OLED_ShowCHinese(24,2,7);//度
- OLED_ShowCHinese(40,2,28);//阈
- OLED_ShowCHinese(56,2,29);//值
- OLED_ShowChar(72,2,':',16);//:
- OLED_ShowChar(96,2,'.',16);//.
- OLED_ShowCHinese(110,2,14);//℃
-
- OLED_ShowCHinese(8,4,6);//温
- OLED_ShowCHinese(24,4,7);//度
- OLED_ShowCHinese(40,4,28);//阈
- OLED_ShowCHinese(56,4,29);//值
- OLED_ShowChar(72,4,':',16);//:
- OLED_ShowChar(96,4,'.',16);//.
- OLED_ShowCHinese(110,4,14);//℃
-
- OLED_ShowCHinese(8,6,8); //风
- OLED_ShowCHinese(24,6,9); //速
- OLED_ShowCHinese(40,6,29);//值
- OLED_ShowChar(56,6,':',16);//:64
- OLED_ShowChar(88,6,'%',16);//%
- }
- void OLED_on4()
- {
- OLED_Clear();
- OLED_ShowCHinese(48,0,22);//设
- OLED_ShowCHinese(64,0,23);//置
-
- OLED_ShowCHinese(8,2,6);//温
- OLED_ShowCHinese(24,2,7);//度
- OLED_ShowCHinese(40,2,28);//阈
- OLED_ShowCHinese(56,2,29);//值
- OLED_ShowChar(72,2,':',16);//:
- OLED_ShowChar(96,2,'.',16);//.
- OLED_ShowCHinese(110,2,14);//℃
- }
- void OLED_on5()
- {
- OLED_Clear();
- OLED_ShowCHinese(32,0,24);//参
- OLED_ShowCHinese(48,0,25);//数
- OLED_ShowCHinese(64,0,26);//调
- OLED_ShowCHinese(80,0,27);//节
- }
- void OLED_on6()
- {
- OLED_Clear();
- OLED_ShowCHinese(48,6,22);//设
- OLED_ShowCHinese(64,6,23);//置
-
- OLED_ShowCHinese(8,2,6);//温
- OLED_ShowCHinese(24,2,7);//度
- OLED_ShowCHinese(40,2,28);//阈
- OLED_ShowCHinese(56,2,29);//值
- OLED_ShowChar(72,2,':',16);//:
- OLED_ShowChar(96,2,'.',16);//.
- OLED_ShowCHinese(110,2,14);//℃
- }
- void OLED_on(u8 mode)
- {
- if(mode>3)
- mode = 1;
- if(mode==0)
- mode = 3;
- switch (mode)
- {
- case 1:OLED_on1();display=1;
- break;
- case 2:OLED_on2();display=2;
- break;
- case 3:OLED_on3();display=3;
- break;
- case 4:OLED_on4();display=4;
- break;
- // case 5:OLED_on5();display=5;
- // break;
- // case 6:OLED_on6();display=6;
- // break;
- }
- delay_ms(100);
- }
复制代码
4
|
|
|
|