@@ -205,102 +205,102 @@ void update_temp() {
else {
temp = temp_pre;
}
// Deassert CS
Delay(1);
GPIO_SetBits(MAX_CS);
int32_t setpoint = 0;
uint16_t k_p = 1;
uint16_t k_i = 1;
uint16_t k_d = 1;
// Process things
void process()
{
update_temp(); // Read MAX31855
// TODO: Add calibration offset (linear)
// Perform PID calculations
//if(
GPIO_SetBits(LED_STAT);
// Write output to SSR
enum state {
STATE_IDLE = 0,
STATE_SETP,
STATE_SETI,
STATE_SETD,
STATE_PREHEAT_BREW,
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(" ", 3, 40);
ssd1306_DrawString(tempstr, 3, 40);
ssd1306_DrawString("-> ", 3, 40);
ssd1306_DrawString("-> ", 3, 80);
itoa(setpoint, tempstr);
ssd1306_DrawString(" ", 3, 70);
ssd1306_DrawString(tempstr, 3, 70);
ssd1306_DrawString(" ", 3, 95);
ssd1306_DrawString(tempstr, 3, 95);
uint8_t state = STATE_IDLE;
uint8_t goto_mode = 2;
// State machine
void machine()
uint8_t last_state = state;
switch(state)
// Idle state
case STATE_IDLE:
// Write text to OLED
// [ therm :: idle ]
ssd1306_DrawString("therm :: idle ", 0, 40);
char tempstr[6];
ssd1306_DrawString("Temp: ", 3, 40);
ssd1306_DrawString(tempstr, 3, 72);
ssd1306_drawlogo();
switch(goto_mode) {
case 2:
ssd1306_DrawString("-> brew ", 1, 40);
} break;
case 1:
ssd1306_DrawString("-> set P/I/D", 1, 40);
case 0:
ssd1306_DrawString("-> setup ", 1, 40);
// Button handler
Status change: