利用绘晶cog12864屏幕。显示万年历,温度,湿度,空气质量
单片机源程序如下:
- #include "stm32f10x.h"
- #include "delay.h"
- #include "lcd.h"
- #include "ds1302.h"
- #include "dht11.h"
- #include "key.h"
- unsigned char shi[]={
- /*-- 文字: 室 --*/
- /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x10,0x0C,0x24,0x24,0xA4,0x64,0x25,0x26,0x24,0x24,0xA4,0x24,0x24,0x14,0x0C,0x00,
- 0x40,0x40,0x48,0x49,0x49,0x49,0x49,0x7F,0x49,0x49,0x49,0x4B,0x48,0x40,0x40,0x00,};
- unsigned char nei[]={
- /*-- 文字: 内 --*/
- /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x00,0xF8,0x08,0x08,0x08,0x08,0x88,0x7F,0x88,0x08,0x08,0x08,0x08,0xF8,0x00,0x00,
- 0x00,0xFF,0x00,0x08,0x04,0x02,0x01,0x00,0x00,0x01,0x02,0x4C,0x80,0x7F,0x00,0x00,};
- unsigned char jian[]={
- /*-- 文字: 检 --*/
- /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x10,0x10,0xD0,0xFF,0x90,0x50,0x20,0x50,0x4C,0x43,0x4C,0x50,0x20,0x40,0x40,0x00,
- 0x04,0x03,0x00,0xFF,0x00,0x41,0x44,0x58,0x41,0x4E,0x60,0x58,0x47,0x40,0x40,0x00,};
- unsigned char ce[]={
- /*-- 文字: 测 --*/
- /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x10,0x60,0x02,0x8C,0x00,0xFE,0x02,0xF2,0x02,0xFE,0x00,0xF8,0x00,0xFF,0x00,0x00,
- 0x04,0x04,0x7E,0x01,0x80,0x47,0x30,0x0F,0x10,0x27,0x00,0x47,0x80,0x7F,0x00,0x00,};
- unsigned char xi[]={
- /*-- 文字: 系 --*/
- /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x00,0x00,0x22,0x32,0x2A,0xA6,0xA2,0x62,0x21,0x11,0x09,0x81,0x01,0x00,0x00,0x00,
- 0x00,0x42,0x22,0x13,0x0B,0x42,0x82,0x7E,0x02,0x02,0x0A,0x12,0x23,0x46,0x00,0x00,};
- unsigned char tong[]={
- /*-- 文字: 统 --*/
- /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x20,0x30,0xAC,0x63,0x30,0x00,0x88,0xC8,0xA8,0x99,0x8E,0x88,0xA8,0xC8,0x88,0x00,
- 0x22,0x67,0x22,0x12,0x12,0x80,0x40,0x30,0x0F,0x00,0x00,0x3F,0x40,0x40,0x71,0x00,};
- unsigned char kong[]={
- /*-- 文字: 空 --*/
- /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x10,0x0C,0x44,0x24,0x14,0x04,0x05,0x06,0x04,0x04,0x14,0x24,0x44,0x14,0x0C,0x00,
- 0x00,0x40,0x40,0x41,0x41,0x41,0x41,0x7F,0x41,0x41,0x41,0x41,0x40,0x40,0x00,0x00,};
- unsigned char qi[]={
- /*-- 文字: 气 --*/
- /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x20,0x10,0x4C,0x47,0x54,0x54,0x54,0x54,0x54,0x54,0x54,0xD4,0x04,0x04,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x30,0x40,0xF0,0x00,};
- unsigned char zhi[]={
- /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x00,0x00,0xFE,0x12,0x12,0x92,0x92,0x92,0x92,0xFF,0x91,0x91,0x91,0x91,0x10,0x00,
- 0x80,0x60,0x1F,0x80,0x80,0x5F,0x40,0x20,0x10,0x0E,0x10,0x10,0x20,0x5F,0x80,0x00,};
- unsigned char liang[]={
- /*-- 文字: 量 --*/
- /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x20,0x20,0x20,0xBE,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xBE,0x20,0x20,0x20,0x00,
- 0x00,0x80,0x80,0xAF,0xAA,0xAA,0xAA,0xFF,0xAA,0xAA,0xAA,0xAF,0x80,0x80,0x00,0x00,
- };
- unsigned char y[]={
- /*-- 文字: 优 --*/
- /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x00,0x80,0x60,0xF8,0x07,0x10,0x10,0x10,0xFF,0x10,0xF0,0x11,0x16,0x10,0x10,0x00,
- 0x01,0x00,0x00,0xFF,0x00,0x80,0x60,0x1C,0x03,0x00,0x3F,0x40,0x40,0x40,0x78,0x00,};
- unsigned char l[]={
- /*-- 文字: 良 --*/
- /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x00,0x00,0xFC,0x24,0x24,0x24,0x25,0x26,0x24,0x24,0x24,0xFC,0x00,0x00,0x00,0x00,
- 0x00,0x00,0xFF,0x81,0x41,0x21,0x03,0x05,0x09,0x11,0x29,0x45,0x42,0x80,0x80,0x00,};
- unsigned char z[]={
- /*-- 文字: 中 --*/
- /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x00,0x00,0xF0,0x10,0x10,0x10,0x10,0xFF,0x10,0x10,0x10,0x10,0xF0,0x00,0x00,0x00,
- 0x00,0x00,0x0F,0x04,0x04,0x04,0x04,0xFF,0x04,0x04,0x04,0x04,0x0F,0x00,0x00,0x00,};
- unsigned char c[]={
- /*-- 文字: 差 --*/
- /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x00,0x04,0x24,0x24,0x25,0x26,0xE4,0x3C,0x24,0x26,0x25,0x24,0x24,0x04,0x00,0x00,
- 0x41,0x21,0x11,0x89,0x85,0x8B,0x89,0x89,0xF9,0x89,0x89,0x89,0x89,0x81,0x01,0x00,};
- unsigned char zhou[]={
- /*-- 文字: 周 --*/
- /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x00,0x00,0xFE,0x82,0x92,0x92,0x92,0xFE,0x92,0x92,0x92,0x82,0xFE,0x00,0x00,0x00,
- 0x80,0x60,0x1F,0x00,0x00,0x1E,0x12,0x12,0x12,0x1E,0x40,0x80,0x7F,0x00,0x00,0x00,
- };
- unsigned char yi[]={
- /*-- 文字: 一 --*/
- /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- };
- unsigned char er[]={
- /*-- 文字: 二 --*/
- /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x00,0x00,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x00,0x00,0x00,
- 0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x00,
- };
- unsigned char san[]={
- /*-- 文字: 三 --*/
- /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x00,0x04,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x04,0x00,0x00,
- 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x00,
- };
- unsigned char si[]={
- /*-- 文字: 四 --*/
- /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x00,0xFC,0x04,0x04,0x04,0xFC,0x04,0x04,0x04,0xFC,0x04,0x04,0x04,0xFC,0x00,0x00,
- 0x00,0x7F,0x28,0x24,0x23,0x20,0x20,0x20,0x20,0x21,0x22,0x22,0x22,0x7F,0x00,0x00,
- };
- unsigned char wu[]={
- /*-- 文字: 五 --*/
- /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x00,0x02,0x42,0x42,0x42,0xC2,0x7E,0x42,0x42,0x42,0x42,0xC2,0x02,0x02,0x00,0x00,
- 0x40,0x40,0x40,0x40,0x78,0x47,0x40,0x40,0x40,0x40,0x40,0x7F,0x40,0x40,0x40,0x00,
- };
- unsigned char lu[]={
- /*-- 文字: 六 --*/
- /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x20,0x20,0x20,0x20,0x20,0x20,0x21,0x22,0x2C,0x20,0x20,0x20,0x20,0x20,0x20,0x00,
- 0x00,0x40,0x20,0x10,0x0C,0x03,0x00,0x00,0x00,0x01,0x02,0x04,0x18,0x60,0x00,0x00,
- };
- unsigned char muo[]={
- /*-- 文字: 末 --*/
- /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x08,0x88,0x88,0x88,0x88,0x88,0x88,0xFF,0x88,0x88,0x88,0x88,0x88,0x88,0x08,0x00,
- 0x20,0x20,0x10,0x08,0x04,0x02,0x01,0xFF,0x01,0x02,0x04,0x08,0x10,0x20,0x20,0x00,
- };
- unsigned char zi[]={
- /*-- 文字: 制 --*/
- /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x40,0x50,0x4E,0x48,0x48,0xFF,0x48,0x48,0x48,0x40,0xF8,0x00,0x00,0xFF,0x00,0x00,
- 0x00,0x00,0x3E,0x02,0x02,0xFF,0x12,0x22,0x1E,0x00,0x0F,0x40,0x80,0x7F,0x00,0x00,
- };
- unsigned char zhuo[]={
- /*-- 文字: 作 --*/
- /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x00,0x80,0x60,0xF8,0x07,0x40,0x30,0x0F,0xF8,0x88,0x88,0x88,0x88,0x08,0x08,0x00,
- 0x01,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0xFF,0x08,0x08,0x08,0x08,0x08,0x00,0x00,
- };
- unsigned char ren[]={
- /*-- 文字: 人 --*/
- /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x3F,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x80,0x40,0x20,0x10,0x0C,0x03,0x00,0x00,0x00,0x03,0x0C,0x10,0x20,0x40,0x80,0x00,
- };
- unsigned char zhang[]={
- /*-- 文字: 张 --*/
- /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x02,0xE2,0x22,0x22,0x3E,0x80,0x80,0xFF,0x80,0xA0,0x90,0x88,0x86,0x80,0x80,0x00,
- 0x00,0x43,0x82,0x42,0x3E,0x00,0x00,0xFF,0x40,0x21,0x06,0x08,0x10,0x20,0x40,0x00,
- };
- unsigned char yu[]={
- /*-- 文字: 宇 --*/
- /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x10,0x0C,0x24,0x24,0x24,0x24,0x25,0xE6,0x24,0x24,0x24,0x24,0x24,0x14,0x0C,0x00,
- 0x02,0x02,0x02,0x02,0x02,0x42,0x82,0x7F,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x00,
- };
- unsigned char lon[]={
- /*-- 文字: 龙 --*/
- /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x10,0x10,0x10,0x10,0x10,0xFF,0x10,0x10,0xF0,0x10,0x11,0x16,0xD0,0x10,0x10,0x00,
- 0x80,0x40,0x20,0x18,0x06,0x41,0x20,0x10,0x3F,0x44,0x42,0x41,0x40,0x40,0x78,0x00,
- };
- int main(void)
- {
- int i;
- u8 time[15];
- u8 temperature;
- u8 humidity;
-
- delay_init(); //初始化延时函数
- lcd_gpio_init();
- lcd_init();
-
- DS1302_Init();
- // delay_ms(10);
- // DS1302_Write_Time();
- DHT11_Init();
-
- key_init();
-
- clear_screen();
- delay_ms(150);
- display_bk();
- delay_ms(150);
- dispaly_16x16(1,3,16,shi);
- delay_ms(50);
- dispaly_16x16(1,3,32,nei);
- delay_ms(50);
- dispaly_16x16(1,3,48,jian);
- delay_ms(50);
- dispaly_16x16(1,3,64,ce);
- delay_ms(50);
- dispaly_16x16(1,3,80,xi);
- delay_ms(50);
- dispaly_16x16(1,3,96,tong);
- delay_ms(50);
- dispaly_16x16(1,5,10,zi);
- delay_ms(50);
- dispaly_16x16(1,5,26,zhuo);
- delay_ms(50);
- dispaly_16x16(1,5,42,ren);
- delay_ms(50);
- dispaly_8x16(1,5,58,":");
- delay_ms(50);
- dispaly_16x16(1,5,66,zhang);
- delay_ms(50);
- dispaly_16x16(1,5,82,yu);
- delay_ms(50);
- dispaly_16x16(1,5,98,lon);
- delay_ms(500);
- clear_screen();
- dispaly_8x16(1,4,30,"WHITE");
- delay_ms(50);
- for(i=0;i<5;i++)
- {
- white(170);
- }
-
- clear_screen();
- while(1)
- {
- int m,r;
- DS1302_Get_Time(time);
- DHT11_Read_Data(&temperature,&humidity); //读取温湿度值
-
- m=temperature;
- r=humidity;
-
- dispaly_8x16_t(1,1,0,time[0]);
- dispaly_8x16_t(1,1,8,time[1]);
- dispaly_8x16_t(1,1,16,time[2]);
- dispaly_8x16_t(1,1,24,time[3]);
- dispaly_8x16(1,1,32,"-");
- dispaly_8x16_t(1,1,40,time[4]);
- dispaly_8x16_t(1,1,48,time[5]);
- dispaly_8x16(1,1,56,"-");
- dispaly_8x16_t(1,1,64,time[6]);
- dispaly_8x16_t(1,1,72,time[7]);
-
- dispaly_8x16_t(0,3,0,time[9]);
- dispaly_8x16_t(0,3,8,time[10]);
- dispaly_8x16(0,3,16,":");
- dispaly_8x16_t(0,3,24,time[11]);
- dispaly_8x16_t(0,3,32,time[12]);
- dispaly_8x16(0,3,40,":");
- dispaly_8x16_t(0,3,48,time[13]);
- dispaly_8x16_t(0,3,56,time[14]);
- dispaly_8x16(1,5,5,"T");
- dispaly_8x16(1,5,13,":");
- dispaly_8x16_t(1,5,21,m/10%10);
- dispaly_8x16_t(1,5,29,m/1%10);
- dispaly_8x16(1,5,37,"C.");
-
- dispaly_8x16(1,5,60,"H");
- dispaly_8x16(1,5,68,":");
- dispaly_8x16_t(1,5,76,r/10%10);
- dispaly_8x16_t(1,5,84,r/1%10);
- dispaly_8x16(1,5,92,"%RH");
- dispaly_16x16(1,7,0,kong);
- dispaly_16x16(1,7,16,qi);
- dispaly_16x16(1,7,32,zhi);
- dispaly_16x16(1,7,48,liang);
- dispaly_8x16(1,7,64,":");
- if(A==0&&B==0)
- {
- dispaly_16x16(1,7,80,y);
- dispaly_8x16(1,7,96," ");
- }
-
- if(A==0&&B==1)
- {
- dispaly_16x16(1,7,80,l);
- dispaly_8x16(1,7,96," ");
- }
- if(A==1&&B==0)
- {
- dispaly_16x16(1,7,80,z);
- dispaly_8x16(1,7,96," ");
- }
- if(A==1&&B==1)
- {
- dispaly_16x16(1,7,80,c);
- dispaly_8x16(1,7,96,"!");
- }
-
-
- switch(time[8])
- {
- case 1: dispaly_16x16(1,3,90,zhou);
- dispaly_16x16(1,3,106,yi);
- break;
- case 2: dispaly_16x16(1,3,90,zhou);
- dispaly_16x16(1,3,106,er);
- break;
- case 3: dispaly_16x16(1,3,90,zhou);
- dispaly_16x16(1,3,106,san);
- break;
- case 4: dispaly_16x16(1,3,90,zhou);
- dispaly_16x16(1,3,106,si);
- break;
- case 5: dispaly_16x16(1,3,90,zhou);
- dispaly_16x16(1,3,106,wu);
- break;
- case 6: dispaly_16x16(1,3,90,zhou);
- dispaly_16x16(1,3,106,lu);
- break;
- case 7: dispaly_16x16(1,3,90,zhou);
- dispaly_16x16(1,3,106,muo);
- break;
-
-
-
- }
-
-
-
- }
- }
- // dispaly_8x16(1,5,38,"C.");
- //
- // dispaly_8x16(1,5,91,"%RH");
- // if( Read_DHT11(&DHT11_Data)==SUCCESS)
- // {
- //
- ////DHT11_Data.humi_int,DHT11_Data.humi_deci,DHT11_Data.temp_int,DHT11_Data.temp_deci;
- //
- // dispaly_8x16_t(1,5,10,temp_int);
-
- // dispaly_8x16(1,5,38,"C.");
- // dispaly_8x16_t(1,5,50,humi_int);
- // dispaly_8x16_t(1,5,60,humi_deci);
- // dispaly_8x16(1,5,91,"%RH");
- //
- //
- //
- // }
复制代码
所有程序51hei提供下载:
室内检测系统.7z
(189.54 KB, 下载次数: 32)
|