This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

can anyone explain this function?

Hi i have to read some data from a temperature sensor.

twi_temp_read((int8_t *)&temperature);

this below what do?

temperature = ((temperature >> 12) & 0x000F) | (temperature << 4);

if((temperature & 0x0800) != 0){
// minus
temperature--;
temperature ^= 0x0FFF;
sprintf(str, "-%03.4f", (float)temperature*0.0625);
}else{
    sprintf(str, " %03.4f", (float)temperature*0.0625);
}

Can anyone explain this function? thanks

Parents Reply Children
Related