@@ -300,268 +300,268 @@ void display_process(therm_settings_t* s
// Button handler
if(SW_BTN_PRESSED) {
status->state = STATE_SETUNITS;
}
else if(!HAL_GPIO_ReadPin(SW_UP)) {
set->boottobrew = 1;
else if(!HAL_GPIO_ReadPin(SW_DOWN)) {
set->boottobrew = 0;
// Event Handler
// N/A
} break;
case STATE_SETUNITS:
{
// Write text to OLED
// [ therm :: set windup ]
// [ g = 12 ]
ssd1306_DrawString("Units: ", 0, 40);
ssd1306_drawlogo();
if(set->temp_units == TEMP_UNITS_FAHRENHEIT)
ssd1306_DrawString("Fahrenheit", 1, 60);
else
ssd1306_DrawString("Celsius ", 1, 60);
ssd1306_DrawString("Press to accept", 3, 40);
status->state = STATE_SETTEMPOFFSET;
set->temp_units = TEMP_UNITS_FAHRENHEIT;
set->temp_units = TEMP_UNITS_CELSIUS;
case STATE_SETTEMPOFFSET:
// [ therm :: set temp offset ]
ssd1306_DrawString("Temp Cal Offset", 0, 40);
char tempstr[6];
itoa(set->temp_offset, tempstr, 10);
ssd1306_DrawString("O=", 1, 45);
ssd1306_DrawString(" ", 1, 57);
ssd1306_DrawString(tempstr, 1, 57);
save_settings(&set);
status->state = STATE_IDLE;
else {
user_input_signed(&set->temp_offset);
case STATE_PREHEAT_BREW:
// [ therm : preheating brew ]
// [ 30 => 120 C ]
ssd1306_DrawString("Preheating...", 0, 0);
//ssd1306_drawlogo();
draw_setpoint(status);
status->pid_enabled = 1;
status->setpoint = set->setpoint_brew;
save_setpoints(&set); // TODO: Check for mod
user_input(&set->setpoint_brew);
if(status->temp >= status->setpoint) {
status->state = STATE_MAINTAIN_BREW;
case STATE_MAINTAIN_BREW:
// [ therm : ready to brew ]
ssd1306_DrawString("Preheated!", 0, 0);
case STATE_PREHEAT_STEAM:
// [ therm : preheating steam ]
status->setpoint = set->setpoint_steam;
user_input(&set->setpoint_steam);
status->state = STATE_MAINTAIN_STEAM;
case STATE_MAINTAIN_STEAM:
// [ therm : ready to steam ]
ssd1306_DrawString("Ready to Steam!", 0, 0);
case STATE_TC_ERROR:
ssd1306_DrawString("Error:", 0, 0);
if(status->tc_errno == 1)
ssd1306_DrawString("#1, Check Sensor", 1, 0);
ssd1306_DrawString(" Check Sensor (1)", 1, 0);
else if(status->tc_errno == 4)
ssd1306_DrawString("#4, Check Sensor", 1, 0);
ssd1306_DrawString(" Check Sensor (2)", 1, 0);
ssd1306_DrawString("#?, Unknown Error", 1, 0);
ssd1306_DrawString(" ", 2, 0);
ssd1306_DrawString("Press -> to ignore", 3, 0);
else if(SW_RIGHT_PRESSED) {
set->ignore_tc_error = 1;
// Maybe handle if TC is plugged in
// Something is terribly wrong
default:
status->pid_enabled = 0;
if(last_state != status->state) {
// Clear screen on state change
goto_mode = 2;
trigger_drawsetpoint = 1;
ssd1306_clearscreen();
// Last buttonpress
sw_btn_last = sw_btn;
sw_up_last = sw_up;
sw_down_last = sw_down;
sw_left_last = sw_left;
sw_right_last = sw_right;
int32_t temp_last = 43002;
int32_t setpoint_last = 10023;
void draw_setpoint(therm_status_t* status) {
// FIXME: need to do this when switching modes too
if(status->temp != temp_last || trigger_drawsetpoint) {
char tempstr[3];
itoa_fp(status->temp, status->temp_frac, tempstr);
ssd1306_DrawStringBig(" ", 3, 0);
ssd1306_DrawStringBig(tempstr, 3, 0);
if(trigger_drawsetpoint)
ssd1306_DrawStringBig(">", 3, 74);
if(status->setpoint != setpoint_last || trigger_drawsetpoint) {
itoa(status->setpoint, tempstr, 10);
ssd1306_DrawStringBig(" ", 3, 90);
ssd1306_DrawStringBig(tempstr, 3, 90);
trigger_drawsetpoint = 0;
setpoint_last = status->setpoint;
temp_last = status->temp;
// vim:softtabstop=4 shiftwidth=4 expandtab
Status change: