//特为无线多点温度与湿度数据采集的系统设计
#include /* Define the register command code */ #define Disp_On 0x3f #define Disp_Off 0x3e #define Col_Add 0x40 #define Page_Add 0xb8 #define Start_Line 0xc0 #define Lcd_Bus P2 //MCU P0 LCM sbit cs1=P3^0; //Master chip enable sbit cs2=P3^1; //Slave chip enable sbit Enable=P3^4; //6800 mode Enable single sbit Di=P3^6; //Data or Instrument Select sbit RW=P3^5; //Write or Read sbit REST=P3^3;//rest unsigned char code table[][32]={ 0x10,0x50,0x92,0x1C,0x10,0xF0,0x10,0x00,0x00,0x00,0xFF,0x10,0x10,0x10,0x10,0x00, 0x10,0x10,0x0B,0x0C,0x0B,0x08,0x00,0x7F,0x21,0x21,0x21,0x21,0x21,0x7F,0x00,0x00,/*"站",0*/ 0x00,0x00,0x00,0xE0,0x20,0x20,0x20,0x3F,0x24,0x24,0x24,0xF4,0x24,0x00,0x00,0x00, 0x00,0x40,0x30,0x07,0x12,0x62,0x02,0x0A,0x12,0x62,0x02,0x0F,0x10,0x60,0x00,0x00,/*"点",1*/ 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,/*"—",2*/ 0x10,0x21,0x86,0x70,0x00,0x7E,0x4A,0x4A,0x4A,0x4A,0x4A,0x7E,0x00,0x00,0x00,0x00, 0x02,0xFE,0x01,0x40,0x7F,0x41,0x41,0x7F,0x41,0x41,0x7F,0x41,0x41,0x7F,0x40,0x00,/*"温",3*/ 0x00,0x00,0xFC,0x04,0x24,0x24,0xFC,0xA5,0xA6,0xA4,0xFC,0x24,0x24,0x24,0x04,0x00, 0x80,0x60,0x1F,0x80,0x80,0x42,0x46,0x2A,0x12,0x12,0x2A,0x26,0x42,0xC0,0x40,0x00,/*"度",4*/ 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,/*"—",5*/ 0x10,0x60,0x02,0xCC,0x00,0x00,0x3E,0x2A,0xAA,0x2A,0xAA,0x2A,0x3E,0x00,0x00,0x00, 0x08,0x08,0xFE,0x01,0x40,0x42,0x4C,0x40,0x7F,0x40,0x7F,0x48,0x44,0x42,0x40,0x00,/*"湿",6*/ 0x00,0x00,0xFC,0x04,0x24,0x24,0xFC,0xA5,0xA6,0xA4,0xFC,0x24,0x24,0x24,0x04,0x00, 0x80,0x60,0x1F,0x80,0x80,0x42,0x46,0x2A,0x12,0x12,0x2A,0x26,0x42,0xC0,0x40,0x00,/*"度",7*/ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*" ",8*/ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*" ",9*/ };//站点—温度—湿度— unsigned char code zzhan[][32]={ 0x00,0x00,0x00,0xF8,0x89,0x8E,0x88,0x88,0x88,0x8C,0x8B,0xF8,0x00,0x00,0x00,0x00, 0x00,0x20,0x38,0x00,0x3C,0x40,0x40,0x42,0x4C,0x40,0x40,0x70,0x04,0x18,0x30,0x00,/*"总",0*/ 0x10,0x50,0x92,0x1C,0x10,0xF0,0x10,0x00,0x00,0x00,0xFF,0x10,0x10,0x10,0x10,0x00, 0x10,0x10,0x0B,0x0C,0x0B,0x08,0x00,0x7F,0x21,0x21,0x21,0x21,0x21,0x7F,0x00,0x00,/*"站",1*/ 0x00,0x02,0x05,0xE2,0x18,0x04,0x02,0x02,0x02,0x02,0x02,0x02,0x04,0x1E,0x00,0x00, 0x00,0x00,0x00,0x07,0x18,0x20,0x40,0x40,0x40,0x40,0x40,0x40,0x20,0x18,0x00,0x00,/*"℃",0*/ }; unsigned char code yizhan[][32]={ 0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0xC0,0x80,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"一",0*/ 0x10,0x50,0x92,0x1C,0x10,0xF0,0x10,0x00,0x00,0x00,0xFF,0x10,0x10,0x10,0x10,0x00, 0x10,0x10,0x0B,0x0C,0x0B,0x08,0x00,0x7F,0x21,0x21,0x21,0x21,0x21,0x7F,0x00,0x00,/*"站",1*/ }; unsigned char code erzhan[][32]={ 0x00,0x00,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x06,0x04,0x00,0x00,0x00, 0x00,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x18,0x10,0x00,/*"二",0*/ 0x10,0x50,0x92,0x1C,0x10,0xF0,0x10,0x00,0x00,0x00,0xFF,0x10,0x10,0x10,0x10,0x00, 0x10,0x10,0x0B,0x0C,0x0B,0x08,0x00,0x7F,0x21,0x21,0x21,0x21,0x21,0x7F,0x00,0x00,/*"站",1*/ }; unsigned char code shu[][16]={ 0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00,/*"0",0*/ 0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,/*"1",1*/ 0x00,0x70,0x08,0x08,0x08,0x88,0x70,0x00,0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00,/*"2",2*/ 0x00,0x30,0x08,0x88,0x88,0x48,0x30,0x00,0x00,0x18,0x20,0x20,0x20,0x11,0x0E,0x00,/*"3",3*/ 0x00,0x00,0xC0,0x20,0x10,0xF8,0x00,0x00,0x00,0x07,0x04,0x24,0x24,0x3F,0x24,0x00,/*"4",4*/ 0x00,0xF8,0x08,0x88,0x88,0x08,0x08,0x00,0x00,0x19,0x21,0x20,0x20,0x11,0x0E,0x00,/*"5",5*/ 0x00,0xE0,0x10,0x88,0x88,0x18,0x00,0x00,0x00,0x0F,0x11,0x20,0x20,0x11,0x0E,0x00,/*"6",6*/ 0x00,0x38,0x08,0x08,0xC8,0x38,0x08,0x00,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x00,/*"7",7*/ 0x00,0x70,0x88,0x08,0x08,0x88,0x70,0x00,0x00,0x1C,0x22,0x21,0x21,0x22,0x1C,0x00,/*"8",8*/ 0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x00,0x31,0x22,0x22,0x11,0x0F,0x00,/*"9",9*/ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,0x00,0x00,/*".",10*/ 0xF0,0x08,0xF0,0x00,0xE0,0x18,0x00,0x00,0x00,0x21,0x1C,0x03,0x1E,0x21,0x1E,0x00,/*"%",0*/ }; unsigned char code sp[16]={ // 显示无 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, } ; /*------------------延时子程序-----------------------------*/ void delay123(unsigned int t) { unsigned int i,j; for(i=0;i } /*------------------写命令到LCD------------------------------*/ void write_com(unsigned char cmdcode) { Di=0;RW=0; Lcd_Bus=cmdcode;delay123(0); Enable=1;delay123(0); Enable=0; } /*-------------------写数据到LCD----------------------------*/ void write_data(unsigned char Dispdata) { Di=1;RW=0; Lcd_Bus=Dispdata;delay123(0); Enable=1;delay123(0); Enable=0; } /*--------------------------清除内存------------------------------*/ void Clr_Scr(void) { unsigned char j,k; cs1=1;cs2=1; write_com(Page_Add+0); write_com(Col_Add+0); for(k=0;k<8;k++) { write_com(Page_Add+k); for(j=0;j<64;j++) write_data(0x00); } } /*--------------------------指定位置显示汉字16*16-----------------------*/ void hz_disp16(unsigned char pag,unsigned char col, unsigned char code *hzk) { unsigned char j=0,i=0; if(col<64) { cs1=1;cs2=0; } else { col=col-64; cs1=0;cs2=1; } for(j=0;j<2;j++) { write_com(Page_Add+pag+j); write_com(Col_Add+col); for(i=0;i<16;i++) write_data(hzk[16*j+i]); } } /*----------------------指定位置显示字母或数字8*16-----------------------*/ void e_disp16(unsigned char pag,unsigned char col, unsigned char code *hzk) { unsigned char j=0,i=0; if(col<64) { cs1=1;cs2=0; } else { col=col-64; cs1=0;cs2=1; } for(j=0;j<2;j++) { write_com(Page_Add+pag+j); write_com(Col_Add+col); for(i=0;i<8;i++) write_data(hzk[8*j+i]); } } //************初始化********* void init_lcd(void) { delay123(100); cs1=1;cs2=1;delay123(100); write_com(Disp_Off); write_com(Page_Add+0); write_com(Start_Line+0); write_com(Col_Add+0); write_com(Disp_On); } /*------------------------------信息显示-------------------------------*/ void Msg(void) { unsigned char i; for(i=0;i<8;i++) { hz_disp16(0,i*16,table[i]); //站点—温度—湿度— // delay(200); } for(i=0;i<2;i++) //总站 { hz_disp16(2,i*16,zzhan[i]); // delay(200); } for(i=0;i<2;i++) //一站 { hz_disp16(4,i*16,yizhan[i]); // delay(200);//延时,显示时有跳动感 } for(i=0;i<2;i++) //二站 { hz_disp16(6,i*16,erzhan[i]); // delay(200); } } void WenMsg(unsigned char k, unsigned int w) { unsigned int t1=0,t2=0,t3=0; t1=w/100; t2=w%100/10; t3=w%10; //e_disp16(k,48-8,sp); //e_disp16(k,48-8,shu[t1]); e_disp16(k,40,sp); e_disp16(k,40,shu[t1]); // e_disp16(k,56-8,sp); // e_disp16(k,56-8,shu[t2]); e_disp16(k,48,sp); e_disp16(k,48,shu[t2]); e_disp16(k,64-8,shu[10]); //e_disp16(k,72-8,sp); //e_disp16(k,72-8,shu[t3]); e_disp16(k,64,sp); e_disp16(k,64,shu[t3]); hz_disp16(k,72,zzhan[2]); } void shiMsg(unsigned int k, unsigned shi) { unsigned int t1,t2; t1=shi/10; t2=shi%10; e_disp16(k,80+16,shu[t1]); e_disp16(k,80+24,shu[t2]); e_disp16(k,80+32,shu[11]); } void lcddisplay( unsigned int T,unsigned int T1,unsigned int T2,unsigned char shi,unsigned char shi1,unsigned char shi2 ) { WenMsg( 2,T); WenMsg( 4,T1); WenMsg( 6,T2); shiMsg( 2,shi); shiMsg( 4,shi1); shiMsg( 6,shi2); delay123(600); } /*---------------------------主程序---------------------------------*/ void main(void) { init_lcd(); Clr_Scr(); //清除内存 //delay123(150); Msg(); while(1) { lcddisplay(256,312,180,60,70,90); } }
相关文章