Changeset - 3d43c0d055a8
[Not reviewed]
default
0 1 0
Ethan Zonca - 10 years ago 2014-08-19 22:00:18
ez@ethanzonca.com
Add some more text and stuff
1 file changed with 30 insertions and 10 deletions:
main.c
30
10
0 comments (0 inline, 0 general)
main.c
Show inline comments
 
@@ -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:
 
        {
 
            // 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
 
            // N/A
 
 
 
        } break;
 
 
        case STATE_SETI:
 
        {
 
            // 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
 
            // N/A
 
 
 
        } break;
 
 
        case STATE_SETD:
 
        {
 
            // 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;
 
            }
 
 
            // Event Handler
 
            // N/A
 
 
 
@@ -239,15 +254,16 @@ void machine()
 
 
        case STATE_PREHEAT_BREW:
 
        {
 
            // 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;
 
            }
 
 
            // Event Handler
 
            if(temp >= setpoint) {
 
                state = STATE_MAINTAIN_BREW;
 
@@ -257,16 +273,17 @@ void machine()
 
 
        case STATE_MAINTAIN_BREW:
 
        {
 
            // 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;
 
            }
 
 
            // Event Handler
 
            // N/A
 
 
 
@@ -274,15 +291,16 @@ void machine()
 
 
        case STATE_PREHEAT_STEAM:
 
        {
 
            // 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;
 
            }
 
 
            // Event Handler
 
            if(temp >= setpoint) {
 
                state = STATE_MAINTAIN_STEAM;
 
@@ -292,27 +310,29 @@ void machine()
 
 
        case STATE_MAINTAIN_STEAM:
 
        {
 
            // 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;
 
            }
 
 
            // Event Handler
 
            // N/A
 
 
 
        } break;
 
 
 
        // Something is terribly wrong
 
        default:
 
        {
 
            ssd1306_DrawString("therm :: BAD BAD", 0, 40);
 
            state = STATE_IDLE;
 
 
        } break;
 
            
 
    }
 
}
0 comments (0 inline, 0 general)