diff --git a/main.c b/main.c --- a/main.c +++ b/main.c @@ -76,8 +76,19 @@ int main(void) 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?] @@ -178,9 +189,10 @@ void machine() { // 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; } @@ -194,10 +206,11 @@ void machine() // Write text to OLED // [ therm :: set p ] // [ p = 12 ] + ssd1306_DrawString("therm :: set p", 0, 40); // Button handler - if(GPIO_ReadInputDataBit(SW_BTN)) { - state = STATE_IDLE; + if(!GPIO_ReadInputDataBit(SW_BTN)) { + state = STATE_SETI; } // Event Handler @@ -210,10 +223,11 @@ void machine() // Write text to OLED // [ therm :: set i ] // [ i = 12 ] + ssd1306_DrawString("therm :: set i", 0, 40); // Button handler - if(GPIO_ReadInputDataBit(SW_BTN)) { - state = STATE_IDLE; + if(!GPIO_ReadInputDataBit(SW_BTN)) { + state = STATE_SETD; } // Event Handler @@ -226,9 +240,10 @@ void machine() // Write text to OLED // [ therm :: set d ] // [ d = 12 ] + ssd1306_DrawString("therm :: set d", 0, 40); // Button handler - if(GPIO_ReadInputDataBit(SW_BTN)) { + if(!GPIO_ReadInputDataBit(SW_BTN)) { state = STATE_IDLE; } @@ -242,9 +257,10 @@ void machine() // Write text to OLED // [ therm : preheating brew ] // [ 30 => 120 C ] + ssd1306_DrawString("therm :: Bpreheat", 0, 40); // Button handler - if(GPIO_ReadInputDataBit(SW_BTN)) { + if(!GPIO_ReadInputDataBit(SW_BTN)) { state = STATE_IDLE; } @@ -260,10 +276,11 @@ void machine() // Write text to OLED // [ therm : ready to brew ] // [ 30 => 120 C ] + ssd1306_DrawString("therm :: Bready", 0, 40); // Button handler - if(GPIO_ReadInputDataBit(SW_BTN)) { + if(!GPIO_ReadInputDataBit(SW_BTN)) { state = STATE_IDLE; } @@ -277,9 +294,10 @@ void machine() // Write text to OLED // [ therm : preheating steam ] // [ 30 => 120 C ] + ssd1306_DrawString("therm :: Spreheat", 0, 40); // Button handler - if(GPIO_ReadInputDataBit(SW_BTN)) { + if(!GPIO_ReadInputDataBit(SW_BTN)) { state = STATE_IDLE; } @@ -295,9 +313,10 @@ void machine() // Write text to OLED // [ therm : ready to steam ] // [ 30 => 120 C ] + ssd1306_DrawString("therm :: Sready", 0, 40); // Button handler - if(GPIO_ReadInputDataBit(SW_BTN)) { + if(!GPIO_ReadInputDataBit(SW_BTN)) { state = STATE_IDLE; } @@ -310,6 +329,7 @@ void machine() // Something is terribly wrong default: { + ssd1306_DrawString("therm :: BAD BAD", 0, 40); state = STATE_IDLE; } break;