Changeset - f228963e487a
[Not reviewed]
default
0 1 0
Ethan Zonca - 10 years ago 2014-08-23 22:29:44
ez@ethanzonca.com
Get fractional part
1 file changed with 1 insertions and 46 deletions:
main.c
1
46
0 comments (0 inline, 0 general)
main.c
Show inline comments
 
@@ -49,13 +49,6 @@ char* itoa(int16_t i, char b[]){
 
    return b;
 
}
 
 
 
int32_t round(double x) {
 
    if (x >= 0)
 
        return (long) (x+0.5);
 
    return (long) (x-0.5);
 
}
 
 
static __IO uint32_t TimingDelay;
 
 
// Move to header file
 
@@ -186,31 +179,10 @@ void process()
 
        temp = temp_pre;
 
    }
 
 
 
    // Deassert CS
 
    Delay(1);
 
    GPIO_SetBits(MAX_CS);
 
 
 
    //////////////////////////
 
    // Calc internal temp   //
 
    //////////////////////////
 
/*    temp = temp >> 4; // Drop last 4 bits, no need for them
 
    float internal_temp = temp & 0x7FF // Lower 11bits are internal temp
 
    
 
    // Check internal temp sign
 
    if(temp & 0x800) {
 
        // Convert to negative value by extending sign and casting to signed type.
 
        int16_t tmp = 0xF800 | (temp & 0x7FF);
 
        internal_temp = tmp;
 
    }
 
    internal_temp *= 0.0625; // LSB = 0.0625 degrees
 
    // Now we have a good internal temp!
 
*/
 
    //////////////////////////
 
    // Calc external temp   //
 
    //////////////////////////
 
 
    if(temp > 0) {
 
        GPIO_SetBits(LED_STAT);
 
    }
 
@@ -223,25 +195,8 @@ void process()
 
    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
 
    }
 
 
    else if((temp & 0x4)!= 0)
 
    {
 
        ssd1306_DrawString("!OpenThermocouple", 3, 40);
 
        //return; // Open thermocouple
 
    }
 
 
    temp = (temp & 0x7FF8) >> 5;
 
*/
 
 
    // TODO: Add calibration offset (linear)
 
 
 
    // Perform PID calculations
 
 
    // Write output to SSR
 
@@ -477,7 +432,7 @@ void init_spi(void)
 
    SPI_InitStructure.SPI_CPOL = SPI_CPOL_Low; // From andysworkshop
 
    SPI_InitStructure.SPI_CPHA = SPI_CPHA_1Edge; // same
 
    SPI_InitStructure.SPI_NSS = SPI_NSS_Soft;
 
    SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_256;
 
    SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_8;
 
    SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB;
 
    SPI_InitStructure.SPI_CRCPolynomial = 7;
 
    SPI_Init(SPI2, &SPI_InitStructure);
0 comments (0 inline, 0 general)