@@ -141,12 +141,13 @@ int main(void)
}
// Read temperature and update global temp vars
int32_t temp = 0;
uint8_t temp_frac = 0;
uint8_t state_resume = 0;
void update_temp() {
// Assert CS
GPIO_ResetBits(MAX_CS);
delay(1);
@@ -157,20 +158,24 @@ void update_temp() {
if(temp_pre & 0b0000000000000010) {
ssd1306_DrawString("Fatal Error", 3, 35);
state = STATE_TC_ERROR;
else if(temp_pre & 0b0000000000000001 && !ignore_tc_error) {
state_resume = state;
temp = 0;
temp_frac = 0;
else
{
if(state == STATE_TC_ERROR)
state = STATE_IDLE;
state = state_resume;
ssd1306_clearscreen();
uint8_t sign = temp >> 15;// top bit is sign
temp_pre = temp_pre >> 2; // Drop 2 lowest bits
temp_frac = temp_pre & 0b11; // get fractional part
temp_frac *= 25; // each bit is .25 a degree, up to fixed point
Status change: