dirtwillfly 发表于 2013-5-15 08:34 
这个0X用的好奇葩。把源程序都贴出来,大家欣赏下
void conversion(long temp_data)
{
/*
shiwan=temp_data/100000+0x30 ; //十万
temp_data=temp_data%100000; //取余运算
wan=temp_data/10000+0x30 ; //万
temp_data=temp_data%10000; //取余运算
qian=temp_data/1000+0x30 ; //千
temp_data=temp_data%1000; //取余运算
bai=temp_data/100+0x30 ; //百
temp_data=temp_data%100; //取余运算
shi=temp_data/10+0x30 ; //十
temp_data=temp_data%10; //取余运算
ge=temp_data+0x30; //个
*/
shiwan=temp_data/0x1000000 ; //0x100 00 00 得到八个字节中最高的字节 最高1 00
temp_data=temp_data%0x1000000; //取余运算
wan=temp_data/0x10000; //0x100 00 2 01
temp_data=temp_data%0x10000; //取余运算
qian=temp_data/0x100 ; //0x100 3 87
bai=temp_data%0x100; //取余运算 60
shi=temp_data/0x01 ;
ge=temp_data%0x01 ;
}
void bmp085Convert()
{
unsigned int ut;
long up;
long x1, x2, b5, b6, x3, b3, p;
unsigned long b4, b7;
long temperature;
long pressure;
// xdata float ui;
// uint left;
ut = bmp085ReadTemp();
ut = bmp085ReadTemp(); // 读取温度
up = bmp085ReadPressure();
up = bmp085ReadPressure(); // 读取压强
x1 = ((long)ut - ac6) * ac5 >> 15;
x2 = ((long) mc << 11) / (x1 + md);
b5 = x1 + x2;
temperature = (b5 + 8) >> 4;
conversion(temperature);
Send_Byte(qian);
Send_Byte(bai);
}
源程序相当长,就把相关的贴出来了
|