@@ -328,193 +328,197 @@ void display_process(therm_settings_t* s
ssd1306_drawstring("Start on Boot", 0, 40);
ssd1306_drawlogo();
ssd1306_drawstring("sob=", 1, 45);
if(set->val.boottobrew)
ssd1306_drawstring("Enabled ", 1, 70);
else
ssd1306_drawstring("Disabled", 1, 70);
ssd1306_drawstring("Press to accept", 3, 40);
// Button handler
if(SW_BTN_PRESSED) {
status->state = STATE_SETUNITS;
}
else if(!HAL_GPIO_ReadPin(SW_UP)) {
set->val.boottobrew = 1;
else if(!HAL_GPIO_ReadPin(SW_DOWN)) {
set->val.boottobrew = 0;
// Event Handler
// N/A
} break;
case STATE_SETUNITS:
{
// Write text to OLED
// [ therm :: set windup ]
// [ g = 12 ]
ssd1306_drawstring("Units: ", 0, 40);
if(set->val.temp_units == TEMP_UNITS_FAHRENHEIT)
ssd1306_drawstring("Fahrenheit", 1, 60);
ssd1306_drawstring("Celsius ", 1, 60);
status->state = STATE_SETTEMPOFFSET;
set->val.temp_units = TEMP_UNITS_FAHRENHEIT;
set->val.temp_units = TEMP_UNITS_CELSIUS;
case STATE_SETTEMPOFFSET:
// [ therm :: set temp offset ]
ssd1306_drawstring("Temp Cal Offset", 0, 40);
char tempstr[6];
itoa(set->val.temp_offset, tempstr, 10);
ssd1306_drawstring("O=", 1, 45);
ssd1306_drawstring(" ", 1, 57);
ssd1306_drawstring(tempstr, 1, 57);
flash_save(set);
status->state = STATE_IDLE;
else {
user_input_signed(&set->val.temp_offset);
case STATE_PREHEAT:
// [ therm : preheating brew ]
// [ 30 => 120 C ]
ssd1306_drawstring("Preheating...", 0, 0);
if(set->val.plant_type == PLANT_HEATER)
ssd1306_drawstring("Precooling...", 0, 0);
//ssd1306_drawlogo();
draw_setpoint(status);
status->pid_enabled = 1;
status->setpoint = set->val.setpoint_brew;
user_input((uint16_t*)&set->val.setpoint_brew);
if(status->temp >= status->setpoint) {
status->state = STATE_MAINTAIN;
case STATE_MAINTAIN:
// [ therm : ready to brew ]
ssd1306_drawstring("Preheated!", 0, 0);
ssd1306_drawstring("Precooled!", 0, 0);
// Thermocouple error
case STATE_TC_ERROR:
// [ therm : ready to steam ]
ssd1306_drawstring("Error: ", 0, 0);
itoa(status->error_code, tempstr, 10);
ssd1306_drawstring(tempstr, 0, 57);
//TODO: add RTD error codes
if(status->error_code == 1)
ssd1306_drawstring(" TC Open Circuit", 1, 0);
else if(status->error_code == 4)
ssd1306_drawstring(" TC Short to GND", 1, 0);
else if(status->error_code == 8)
ssd1306_drawstring(" TC Short to VCC", 1, 0);
ssd1306_drawstring("#?, Unknown Error", 1, 0);
ssd1306_drawstring(" ", 2, 0);
ssd1306_drawstring("-> to ignore all or", 2, 0);
ssd1306_drawstring("press to continue", 3, 0);
#ifdef MAX31865_RTD_SENSOR
max31865_clear_errors(spi_get());
#endif
else if(SW_RIGHT_PRESSED) {
set->val.ignore_error = 1;
// Maybe handle if TC is plugged in
// Reset state
case STATE_RESET:
Status change: