diff --git a/.settings/language.settings.xml b/.settings/language.settings.xml --- a/.settings/language.settings.xml +++ b/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -16,7 +16,7 @@ - + diff --git a/src/main.c b/src/main.c --- a/src/main.c +++ b/src/main.c @@ -1,6 +1,6 @@ // // Therm Firmware -// Copyright 2017 Ethan Zonca +// Copyright 2018 Ethan Zonca // Author(s): Ethan Zonca // diff --git a/src/pid.c b/src/pid.c --- a/src/pid.c +++ b/src/pid.c @@ -6,10 +6,10 @@ #include "flash.h" // PID implementation - static pid_state_t state; +// Initialize PID loop void pid_init() { state.i_state = 0; @@ -17,10 +17,10 @@ void pid_init() state.last_pid_temp_frac = 0; } + +// Apply PID output values float pid_process(void) { - - // #ifdef MAX31865_RTD_SENSOR // max31865_readtemp(spi_get(), &set, &status); // #else @@ -55,6 +55,8 @@ float pid_process(void) return ssr_output; //ssr_output; } + +// Calculate new PID values int16_t pid_update(void) { therm_status_t* status = runtime_status(); diff --git a/src/tempsense.c b/src/tempsense.c --- a/src/tempsense.c +++ b/src/tempsense.c @@ -8,6 +8,7 @@ #include "max31856/max31856.h" +// Initialize temperature sensor void tempsense_init(void) { // TODO: Rework SPI stuff... init the port in a sharedlib then pass ref to display and tempsense @@ -21,7 +22,8 @@ void tempsense_init(void) } -// Returns the latest reading from the configured temperature sensor + +// Request reading from configured temperature sensor void tempsense_readtemp(void) { @@ -50,8 +52,14 @@ void tempsense_readtemp(void) // Need to gracefully handle the timeout... } + +// Get latest temperature in requested units float tempsense_gettemp(void) { - return max31856_latest_temp(); + float temp_converted = max31856_latest_temp(); + + if(flash_getsettings()->val.temp_units == TEMP_UNITS_FAHRENHEIT) + temp_converted = temp_converted * 1.8f + 32.0f; + + return temp_converted; } -