@@ -244,12 +244,26 @@ enum state {
STATE_MAINTAIN_BREW,
STATE_PREHEAT_STEAM,
STATE_MAINTAIN_STEAM,
};
void draw_setpoint() {
char tempstr[3];
itoa_fp(temp, temp_frac, tempstr);
ssd1306_DrawString(" ", 3, 40);
ssd1306_DrawString(tempstr, 3, 40);
ssd1306_DrawString("-> ", 3, 40);
itoa(setpoint, tempstr);
ssd1306_DrawString(" ", 3, 70);
ssd1306_DrawString(tempstr, 3, 70);
}
uint8_t state = STATE_IDLE;
uint8_t goto_mode = 2;
// State machine
void machine()
{
@@ -261,13 +275,13 @@ void machine()
case STATE_IDLE:
// Write text to OLED
// [ therm :: idle ]
ssd1306_DrawString("therm :: idle ", 0, 40);
char tempstr[5];
char tempstr[6];
ssd1306_DrawString("Temp: ", 3, 40);
ssd1306_DrawString(tempstr, 3, 72);
ssd1306_drawlogo();
@@ -415,12 +429,13 @@ void machine()
case STATE_PREHEAT_BREW:
// [ therm : preheating brew ]
// [ 30 => 120 C ]
ssd1306_DrawString("Preheating...", 0, 40);
draw_setpoint();
// Button handler
if(!GPIO_ReadInputDataBit(SW_BTN)) {
state = STATE_IDLE;
@@ -434,13 +449,13 @@ void machine()
case STATE_MAINTAIN_BREW:
// [ therm : ready to brew ]
ssd1306_DrawString("Ready to Brew!", 0, 40);
@@ -452,12 +467,13 @@ void machine()
case STATE_PREHEAT_STEAM:
// [ therm : preheating steam ]
@@ -471,12 +487,13 @@ void machine()
case STATE_MAINTAIN_STEAM:
// [ therm : ready to steam ]
ssd1306_DrawString("Ready to Steam!", 0, 40);
Status change: