Changeset - f4ef22eb5176
[Not reviewed]
cortex-f0
0 3 0
Ethan Zonca - 9 years ago 2015-06-01 17:18:30
ez@ethanzonca.com
Added support for detecting which thermocouple error occurred
3 files changed with 13 insertions and 3 deletions:
0 comments (0 inline, 0 general)
display.c
Show inline comments
 
@@ -489,25 +489,32 @@ void display_process(therm_settings_t* s
 

	
 
            // Event Handler
 
            // N/A
 
 
 
        } break;
 

	
 
        case STATE_TC_ERROR:
 
        {
 
            // Write text to OLED
 
            // [ therm : ready to steam ]
 
            // [ 30 => 120 C            ]
 
            ssd1306_DrawString("Error:", 0, 0);
 
            ssd1306_DrawString("Connect thermocouple", 1, 0);
 

	
 
            if(status->tc_errno == 1)
 
                ssd1306_DrawString("#1, Check Sensor", 1, 0);
 
            else if(status->tc_errno == 4)
 
                ssd1306_DrawString("#4, Check Sensor", 1, 0);
 
            else
 
                ssd1306_DrawString("#?, Unknown Error", 1, 0);
 

	
 
            ssd1306_DrawString("Press -> to ignore", 3, 0);
 

	
 
            // Button handler
 
            if(SW_BTN_PRESSED) {
 
                status->state = STATE_IDLE;
 
            }
 
            else if(SW_RIGHT_PRESSED) {
 
                set->ignore_tc_error = 1;
 
                status->state = STATE_IDLE;
 
            }
 
            // Event Handler
 
            // Maybe handle if TC is plugged in
main.c
Show inline comments
 
@@ -153,31 +153,33 @@ void update_temp() {
 
 
    HAL_SPI_Receive(&hspi1, rxdatah, 1, 100);
 
    HAL_SPI_Receive(&hspi1, rxdatal, 1, 100);
 
 
    // Release CS
 
    HAL_GPIO_WritePin(MAX_CS, 1);
 
 
    // Assemble data array into one var
 
    uint16_t temp_pre = rxdatal[0] | (rxdatah[0]<<8);
 
 
    if(temp_pre & 0b0000000000000010) {
 
        ssd1306_clearscreen();
 
        //ssd1306_DrawString("Fatal Error", 3, 35);
 
        HAL_Delay(100);
 
        HAL_Delay(100); // FIXME: remove?
 
        status.tc_errno = 4;
 
        status.state = STATE_TC_ERROR;
 
        status.temp = 0;
 
        status.temp_frac = 0;
 
    }
 
    else if(temp_pre & 0b0000000000000001 && !set.ignore_tc_error) {
 
        status.tc_errno = 1;
 
        HAL_Delay(100); // FIXME: remove?
 
        status.state_resume = status.state;
 
        status.state = STATE_TC_ERROR;
 
        status.temp = 0;
 
        status.temp_frac = 0;
 
    }
 
    else 
 
    {
 
        if(status.state == STATE_TC_ERROR)
 
        {
 
            status.state = status.state_resume;
 
            ssd1306_clearscreen();
 
        }
states.h
Show inline comments
 
#ifndef STATES_H
 
#define STATES_H
 

	
 
typedef struct {
 
    int32_t temp;
 
    uint8_t temp_frac;
 
    uint8_t state_resume;
 
    uint8_t state;
 
    int32_t setpoint;
 
    uint8_t pid_enabled;
 
    uint8_t tc_errno;
 
} therm_status_t;
 

	
 
typedef struct {
 
    uint8_t boottobrew;
 
    uint8_t temp_units;
 
    uint16_t windup_guard;
 
    uint16_t k_p;
 
    uint16_t k_i;
 
    uint16_t k_d;
 
    int16_t temp_offset;
 
    uint8_t ignore_tc_error;
 
    int16_t setpoint_brew;
0 comments (0 inline, 0 general)