Changeset - 255811a3e69c
[Not reviewed]
default
0 1 0
Ethan Zonca - 10 years ago 2014-08-23 22:28:17
ez@ethanzonca.com
Get fractional part
1 file changed with 6 insertions and 0 deletions:
main.c
6
0 comments (0 inline, 0 general)
main.c
Show inline comments
 
@@ -171,12 +171,15 @@ void process()
 
    }
 
 
    uint8_t sign = temp >> 15;// top bit is sign
 
 
 
    temp_pre = temp_pre >> 2; // Drop 2 lowest bits
 
    uint8_t frac = temp_pre & 0b11; // get fractional part
 
    frac *= 25; // each bit is .25 a degree, up to fixed point
 
    temp_pre = temp_pre >> 2; // Drop 2 fractional bits 
 
 
    int16_t temp = 0;
 
    if(sign) {
 
        temp = -temp_pre;
 
    }
 
    else {
 
@@ -213,12 +216,15 @@ void process()
 
    }
 
    char tempstr[9];
 
    itoa(temp_pre, tempstr);
 
    ssd1306_DrawString("Temp: ", 1, 40);
 
    ssd1306_DrawString("    ", 1, 70);
 
    ssd1306_DrawString(tempstr, 1, 70);
 
    itoa(frac, tempstr);
 
    ssd1306_DrawString("  ", 1, 90);
 
    ssd1306_DrawString(tempstr, 1, 90);
 
 
/*
 
    if((!retval || (temp & 0x2) != 0))
 
    {
 
        ssd1306_DrawString("!TempCOMMS", 3, 35);
 
        //return; // Comms error - this is happening right now
0 comments (0 inline, 0 general)