无线多点温度与湿度数据采集的系统

发布时间:2023-01-04  

//特为无线多点温度与湿度数据采集的系统设计

#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;ifor(j=0;j<6;j++);

}

/*------------------写命令到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);

}

}


文章来源于:电子工程世界    原文链接
本站所有转载文章系出于传递更多信息之目的,且明确注明来源,不希望被转载的媒体或个人可与我们联系,我们将立即进行删除处理。

我们与500+贴片厂合作,完美满足客户的定制需求。为品牌提供定制化的推广方案、专属产品特色页,多渠道推广,SEM/SEO精准营销以及与公众号的联合推广...详细>>

利用葫芦芯平台的卓越技术服务和新产品推广能力,原厂代理能轻松打入消费物联网(IOT)、信息与通信(ICT)、汽车及新能源汽车、工业自动化及工业物联网、装备及功率电子...详细>>

充分利用其强大的电子元器件采购流量,创新性地为这些物料提供了一个全新的窗口。我们的高效数字营销技术,不仅可以助你轻松识别与连接到需求方,更能够极大地提高“闲置物料”的处理能力,通过葫芦芯平台...详细>>

我们的目标很明确:构建一个全方位的半导体产业生态系统。成为一家全球领先的半导体互联网生态公司。目前,我们已成功打造了智能汽车、智能家居、大健康医疗、机器人和材料等五大生态领域。更为重要的是...详细>>

我们深知加工与定制类服务商的价值和重要性,因此,我们倾力为您提供最顶尖的营销资源。在我们的平台上,您可以直接接触到100万的研发工程师和采购工程师,以及10万的活跃客户群体...详细>>

凭借我们强大的专业流量和尖端的互联网数字营销技术,我们承诺为原厂提供免费的产品资料推广服务。无论是最新的资讯、技术动态还是创新产品,都可以通过我们的平台迅速传达给目标客户...详细>>

我们不止于将线索转化为潜在客户。葫芦芯平台致力于形成业务闭环,从引流、宣传到最终销售,全程跟进,确保每一个potential lead都得到妥善处理,从而大幅提高转化率。不仅如此...详细>>