Subversion Repositories HomeAutomation

Rev

Rev 862 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed

Rev 862 Rev 866
Line 31... Line 31...
31
 
31
 
32
    txMsg.Data[0] = SensorIds[CurrentSensor];
32
    txMsg.Data[0] = SensorIds[CurrentSensor];
33
 
33
 
34
    if (DS18X20_read_meas(&gSensorIDs[CurrentSensor][0], &subzero, &cel, &cel_frac_bits) == DS18X20_OK)
34
    if (DS18X20_read_meas(&gSensorIDs[CurrentSensor][0], &subzero, &cel, &cel_frac_bits) == DS18X20_OK)
35
    {
35
    {
-
 
36
        int16_t temp = cel;
-
 
37
 
-
 
38
        temp = temp << 6;
-
 
39
 
-
 
40
        temp += (cel_frac_bits << 2);
-
 
41
 
36
        if (subzero)
42
        if (subzero)
37
        {
43
        {
38
            txMsg.Data[1] = -cel-1;
44
            temp = -temp;
39
            txMsg.Data[2] = ~(cel_frac_bits<<4);
-
 
40
        }
-
 
41
        else
-
 
42
        {
-
 
43
            txMsg.Data[1] = cel;
-
 
44
            txMsg.Data[2] = (cel_frac_bits<<4);
-
 
45
        }
45
        }
-
 
46
 
-
 
47
        txMsg.Data[1] = (uint8_t)(temp >> 8);
-
 
48
        txMsg.Data[2] = (uint8_t)(temp & 0xff);
46
    }
49
    }
47
   
50
   
48
    StdCan_Put(&txMsg);
51
    StdCan_Put(&txMsg);
49
 
52
 
50
    CurrentSensor++;
53
    CurrentSensor++;