diff --git a/display.c b/display.c --- a/display.c +++ b/display.c @@ -25,7 +25,7 @@ static uint8_t sw_right_last = 0; static uint8_t trigger_drawsetpoint = 1; static int16_t last_temp = 21245; static int16_t last_temp_frac = 21245; -static int16_t last_state = STATE_IDLE; +static int16_t last_state = 123; static uint8_t goto_mode = MODE_HEAT; static uint8_t reset_mode = RESET_REBOOT; @@ -190,7 +190,7 @@ void display_process(therm_settings_t* s if(set->val.control_mode == MODE_PID) status->state = STATE_SETP; else - status->state = STATE_SETBOOTTOBREW; + status->state = STATE_SETHYSTERESIS; } else if (!HAL_GPIO_ReadPin(SW_UP)) { set->val.plant_type = PLANT_COOLER; @@ -204,6 +204,35 @@ void display_process(therm_settings_t* s } break; + + case STATE_SETHYSTERESIS: + { + // Write text to OLED + ssd1306_drawstring("Hysteresis", 0, 40); + ssd1306_drawlogo(); + + char tempstr[6]; + itoa(set->val.hysteresis, tempstr, 10); + ssd1306_drawstring("H=", 1, 45); + ssd1306_drawstring(" ", 1, 57); + ssd1306_drawstring(tempstr, 1, 57); + + ssd1306_drawstring("Press to accept", 3, 40); + + // Button handler + if(SW_BTN_PRESSED) { + status->state = STATE_SETBOOTTOBREW; + } + else { + user_input((uint16_t*)&set->val.hysteresis); + } + + // Event Handler + // N/A + + } break; + + case STATE_SETP: { // Write text to OLED