基于51单片机运用LCD12864液晶显示
case TEMP : error+=s_write_byte(MEASURE_TEMP); break;
}
for (i=0;i<65535;i++) if(DATA==0) break;
if(DATA) error+=1;
*(p_value) =s_read_byte(ACK);
*(p_value+1)=s_read_byte(ACK);
*p_checksum =s_read_byte(noACK); //read CRC校验码
return error; // error=1 通讯错误
}
//温湿度值标度变换及温度补偿
void calc_sth10(float *p_humidity ,float *p_temperature)
{
const float C1=-4.0;
const float C2=+0.0405;
const float C3=-0.0000028;
const float T1=+0.01;
const float T2=+0.00008;
float rh=*p_humidity;
float t=*p_temperature;
float rh_lin;
float rh_true;
float t_C;
t_C=t*0.01 - 40;
rh_lin=C3*rh*rh + C2*rh + C1;
rh_true=(t_C-25)*(T1+T2*rh)+rh_lin;
if(rh_true>100)rh_true=100;
if(rh_true<0.1)rh_true=0.1;
*p_temperature=t_C;
*p_humidity=rh_true;
}
void main(void)
{
unsigned int temp,humi;
value humi_val,temp_val; //定义两个共同体,一个用于湿度,一个用于温度
unsigned char error;
unsigned char checksum; //CRC
init12864lcd();
display1();
display2();
display3();
s_connectionreset();
while(1)
{
error=0;
error+=s_measure((unsigned char*)&temp_val.i,&checksum,TEMP); //温度测量
error+=s_measure((unsigned char*)&humi_val.i,&checksum,HUMI); //湿度测量
humi_val.f=(float)humi_val.i;
displaywendu();
shidu[0]=humi/1000+0;
displayshidu();
delay(800);
}
}
51单片机LCD12864液晶显 相关文章:
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)
- Linux嵌入式系统开发平台选型探讨(11-09)
- Windows CE 进程、线程和内存管理(二)(11-09)