@@ -73,14 +73,25 @@ int main(void)
ssd1306_DrawString("therm 0.1", 0, 40);
ssd1306_DrawString("Status: Idle", 2, 40);
// ssd1306_block_write();
ssd1306_test();
uint8_t toggle = 0;
int16_t temp = 0;
while(1)
{
temp = SPI_I2S_ReceiveData(SPI2);
ssd1306_DrawString("Temp: ", 1, 40);
char tempstr[5];
char test = temp + 0x30;
//sprintf(tempstr, "%d", test);
//ssd1306_DrawString(tempstr, 1, 70);
//ssd1306_block_write();
// Process sensor inputs [TODO: 5hz?]
process();
// Run state machine [TODO: 50hz?]
@@ -175,15 +186,16 @@ void machine()
// Idle state
case STATE_IDLE:
// Write text to OLED
// [ therm :: idle ]
ssd1306_DrawString("therm :: idle ", 0, 40);
// Button handler
if(GPIO_ReadInputDataBit(SW_BTN)) {
if(!GPIO_ReadInputDataBit(SW_BTN)) {
state = STATE_SETP;
}
// Event Handler
// N/A
@@ -191,47 +203,50 @@ void machine()
case STATE_SETP:
// [ therm :: set p ]
// [ p = 12 ]
ssd1306_DrawString("therm :: set p", 0, 40);
state = STATE_IDLE;
state = STATE_SETI;
} break;
case STATE_SETI:
// [ therm :: set i ]
// [ i = 12 ]
ssd1306_DrawString("therm :: set i", 0, 40);
state = STATE_SETD;
case STATE_SETD:
// [ therm :: set d ]
// [ d = 12 ]
ssd1306_DrawString("therm :: set d", 0, 40);
@@ -239,15 +254,16 @@ void machine()
case STATE_PREHEAT_BREW:
// [ therm : preheating brew ]
// [ 30 => 120 C ]
ssd1306_DrawString("therm :: Bpreheat", 0, 40);
if(temp >= setpoint) {
state = STATE_MAINTAIN_BREW;
@@ -257,16 +273,17 @@ void machine()
case STATE_MAINTAIN_BREW:
// [ therm : ready to brew ]
ssd1306_DrawString("therm :: Bready", 0, 40);
@@ -274,15 +291,16 @@ void machine()
case STATE_PREHEAT_STEAM:
// [ therm : preheating steam ]
ssd1306_DrawString("therm :: Spreheat", 0, 40);
state = STATE_MAINTAIN_STEAM;
@@ -292,27 +310,29 @@ void machine()
case STATE_MAINTAIN_STEAM:
// [ therm : ready to steam ]
ssd1306_DrawString("therm :: Sready", 0, 40);
// Something is terribly wrong
default:
ssd1306_DrawString("therm :: BAD BAD", 0, 40);
Status change: