unsigned
char
TEMP_CONV(unsigned
int
*temp, unsigned
char
*str)
{
unsigned
char
res;
float
temp_float;
res = Get18B20Temp(temp);
if
(res)
{
if
( (*temp>>11)==0 )
{
temp_float=( (
float
)(*temp) ) *0.0625*10.0;
*temp=(unsigned
int
)temp_float;
str[0]=
'0'
+( (*temp/1000)%10 );
str[1]=
'0'
+( (*temp/100)%10 );
str[2]=
'0'
+( (*temp/10)%10 );
str[3]=
'.'
;
str[4]=
'0'
+( (*temp)%10 );
if
(str[0]==
'0'
)temp_i++;
if
(str[1]==
'0'
)temp_i++;
return
1;
}
else
if
( (*temp>>11)>0 )
{
*temp=(*temp)&0x07FF;
*temp=2048-(*temp);
temp_float=( (
float
)(*temp) )*0.0625*10.0;
*temp=(unsigned
int
)temp_float;
str[0]=
'-'
;
str[1]=
'0'
+( (*temp/100)%10 );
str[2]=
'0'
+( (*temp/10)%10 );
str[3]=
'.'
;
str[4]=
'0'
+( (*temp)%10 );
if
(str[1]==
'0'
)
{
str[1]=
'-'
;
temp_i=1;
}
return
1;
}
}
return
0;
}