自己根据基本例程修改实现 基本的 选定、翻页、显示字库, 内含取模软件及教程。
单片机源程序如下:
- #include "stm32f10x.h"
- #include "OLED_I2C.h"
- #include "delay.h"
- #include "key.h"
- u8 key=0;
- u8 test=0;
- int main(void)
- {
- unsigned char i=0;
- unsigned char JI;
- unsigned char ASD=2;
- extern const unsigned char BMP1[];
- extern unsigned char F16x16[];
- extern unsigned char shiduF16x16[];
- extern unsigned char xuankuangF16x16[];
- extern unsigned char mochu[];
- DelayInit();
- I2C_Configuration();
- OLED_Init();
- KEY_Init();
- OLED_Fill(0x00);//全屏灭
- test=0;
- while(1)
- {
- key=KEY_Scan(0);
- if(key)
- {
-
- switch(key)
- {
-
- case 1:
- OLED_CLS();//清屏
-
- //DelayS(1);
- if(test==0){
- for(JI=0,i=2;i<4;i++)
- {
- OLED_ShowCN(70+JI*16,1,i,F16x16);//菜单
- JI++;
- }
- for(JI=0,i=7;i<9;i++)
- {
- OLED_ShowCN(10+JI*16,1,i,F16x16);//状态
- JI++;
- }
- //`````DelayMs(500);
- for(i=0;i<2;i++)
- {
- OLED_ShowCN(22+i*16,6,i,shiduF16x16);//湿度
- }
-
- for(i=0;i<2;i++)
- {
- OLED_ShowCN(22+i*16,4,i,F16x16);//温度
- }
- OLED_ShowStr(56,4,":",2);//测试6*8字符
- OLED_ShowStr(56,6,":",2);//测试6*8字符
-
-
- DelayS(1);
- OLED_ShowStr(64,4,"26 C",2);//测试6*8字符
-
- DelayS(1);
- OLED_ShowStr(64,6,"23 C",2);//测试8*16字符
-
- OLED_ShowCN(45,1,0,xuankuangF16x16);//箭头
-
- break;
- };
- if(test==1)
- {
- OLED_CLS();//清屏
- // //OLED_CLS();//清屏
- // //OLED_OFF();//测试OLED休眠
- // //DelayS(2);
- // //OLED_ON();//测试OLED休眠后唤醒
- // OLED_DrawBMP(0,0,128,8,(unsigned char *)BMP1);//测试BMP位图显示
- // //DelayS(2);
-
-
- for(i=0;i<ASD*2;i+=2)
- {
- for(JI=0;JI<i/2;JI++)
- {
- OLED_ShowStr(10+i*7,7-JI,"@",1);//测试6*8字符
- OLED_ShowStr(10+(i+1)*7,7-JI,"@",1);//测试6*8字符
- }
- }
-
-
- break;
- // //OLED_Fill(0xFF);//全屏点亮
- // //DelayS(2);
- }
- break;
-
-
- case 2:
- ASD++;
- if(ASD>=8){ASD=0;}
-
-
- if(test==0)
- {
- OLED_ShowCN(45,1,0,mochu);//测试显示中文
- OLED_ShowCN(105,1,0,xuankuangF16x16);//测试显示中文
- test++;
- break;
- }
-
- if(test==1)
- {
-
- OLED_ShowCN(105,1,0,mochu);//测试显示中文
-
- OLED_ShowCN(45,1,0,xuankuangF16x16);//测试显示中文
- test=0;
- break;
- }
-
-
-
- }
- }
- }
- }
复制代码
所有资料51hei提供下载:
IIC-OLED显示屏资料(SSD1306).7z
(4.19 MB, 下载次数: 190)
|