# HG changeset patch # User Ethan Zonca # Date 2015-01-25 16:19:38 # Node ID cfa4fd71c861a0c5b5bc7560d49f8d42f1896e33 # Parent facb8c86942c4b8ed1b82a7b84b44e0fbef167a4 Fixed rendering issues when drawing setpoints, other various fixes diff --git a/main.c b/main.c --- a/main.c +++ b/main.c @@ -179,9 +179,11 @@ void update_temp() { if(temp_pre & 0b0000000000000010) { ssd1306_clearscreen(); - ssd1306_DrawString("Fatal Error", 3, 35); + //ssd1306_DrawString("Fatal Error", 3, 35); HAL_Delay(100); state = STATE_TC_ERROR; + temp = 0; + temp_frac = 0; } else if(temp_pre & 0b0000000000000001 && !ignore_tc_error) { state_resume = state; @@ -231,6 +233,7 @@ void update_temp() { } // Print temp to cdc +/* CDC_Transmit_FS("Temp: ", 6); char tempstr[6]; zitoa(temp, tempstr); @@ -241,7 +244,7 @@ void update_temp() { CDC_Transmit_FS("\r\n", 2); CDC_Transmit_FS("\r\n", 2); CDC_Transmit_FS("\r\n", 2); - +*/ } @@ -351,16 +354,6 @@ void process() } } -void draw_setpoint() { - char tempstr[3]; - itoa_fp(temp, temp_frac, tempstr); - ssd1306_DrawStringBig(" ", 3, 0); - ssd1306_DrawStringBig(tempstr, 3, 0); - ssd1306_DrawStringBig(">", 3, 74); - itoa(setpoint, tempstr, 10); - ssd1306_DrawStringBig(" ", 3, 90); - ssd1306_DrawStringBig(tempstr, 3, 90); -} uint8_t goto_mode = 2; @@ -450,6 +443,35 @@ uint8_t final_setpoint = 0; //////////////////////////////////////////////////////////////////////////////////////////////// +uint8_t trigger_drawsetpoint = 1; +int32_t temp_last = 43002; +int32_t setpoint_last = 10023; +void draw_setpoint() { + // FIXME: need to do this when switching modes too + if(temp != temp_last || trigger_drawsetpoint) { + char tempstr[3]; + itoa_fp(temp, temp_frac, tempstr); + ssd1306_DrawStringBig(" ", 3, 0); + ssd1306_DrawStringBig(tempstr, 3, 0); + } + + if(trigger_drawsetpoint) + ssd1306_DrawStringBig(">", 3, 74); + + if(setpoint != setpoint_last || trigger_drawsetpoint) { + char tempstr[3]; + itoa(setpoint, tempstr, 10); + ssd1306_DrawStringBig(" ", 3, 90); + ssd1306_DrawStringBig(tempstr, 3, 90); + } + + trigger_drawsetpoint = 0; + setpoint_last = setpoint; + temp_last = temp; +} + + + void machine() { uint8_t last_state = state; @@ -767,6 +789,7 @@ void machine() ssd1306_DrawString("Preheating...", 0, 0); //ssd1306_drawlogo(); draw_setpoint(); + pid_enabled = 1; setpoint = setpoint_brew; @@ -899,6 +922,7 @@ void machine() if(last_state != state) { // Clear screen on state change goto_mode = 2; + trigger_drawsetpoint = 1; ssd1306_clearscreen(); }