Changeset - e28695e6887c
[Not reviewed]
cortex-f0
0 5 0
Ethan Zonca - 9 years ago 2015-06-01 17:09:22
ez@ethanzonca.com
Added temperature offset support
5 files changed with 52 insertions and 2 deletions:
0 comments (0 inline, 0 general)
display.c
Show inline comments
 
@@ -341,8 +341,7 @@ void display_process(therm_settings_t* s
 

	
 
            // Button handler
 
            if(SW_BTN_PRESSED) {
 
                save_settings();
 
                status->state = STATE_IDLE;
 
                status->state = STATE_SETTEMPOFFSET;
 
            }
 
            else if(!HAL_GPIO_ReadPin(SW_UP)) {
 
                set->temp_units = TEMP_UNITS_FAHRENHEIT;
 
@@ -357,6 +356,37 @@ void display_process(therm_settings_t* s
 
        } break;
 

	
 

	
 
        case STATE_SETTEMPOFFSET:
 
        {
 
            // Write text to OLED
 
            // [ therm :: set temp offset ]
 
            // [ g = 12         ]
 
            ssd1306_DrawString("Thermocouple Offset", 0, 40);
 
            ssd1306_drawlogo();
 

	
 
            char tempstr[6];
 
            itoa(set->temp_offset, tempstr, 10);
 
            ssd1306_DrawString("O=", 1, 45);
 
            ssd1306_DrawString("    ", 1, 57);
 
            ssd1306_DrawString(tempstr, 1, 57);
 

	
 
            ssd1306_DrawString("Press to accept", 3, 40);
 

	
 
            // Button handler
 
            if(SW_BTN_PRESSED) {
 
                save_settings();
 
                status->state = STATE_IDLE;
 
            }
 
            else {
 
                user_input_signed(&set->temp_offset);
 
            }
 

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

	
 

	
 
        case STATE_PREHEAT_BREW:
 
        {
 
            // Write text to OLED
gpio.c
Show inline comments
 
@@ -20,6 +20,21 @@ void user_input(uint16_t* to_modify)
 
    }
 
}
 

	
 
void user_input_signed(int16_t* to_modify)
 
{
 
    // TODO: Bounds check on int16_t
 
    if(CHANGE_ELAPSED) {
 
        if(!HAL_GPIO_ReadPin(SW_UP) ) {
 
            CHANGE_RESET;
 
            (*to_modify)++;
 
        }
 
        else if(!HAL_GPIO_ReadPin(SW_DOWN)) {
 
            CHANGE_RESET;
 
            (*to_modify)--;
 
        }
 
    }
 
}
 

	
 

	
 
void init_gpio(void) {
 

	
gpio.h
Show inline comments
 
@@ -9,6 +9,7 @@
 

	
 

	
 
void user_input(uint16_t* to_modify);
 
void user_input_signed(int16_t* to_modify);
 
void init_gpio(void);
 

	
 
#endif
main.c
Show inline comments
 
@@ -206,12 +206,14 @@ void update_temp() {
 
            status.temp += 3200;
 
            status.temp_frac = status.temp % 100;
 
            status.temp /= 100;
 
            status.temp += set.temp_offset;
 
        }
 
 
        // Use Celsius values
 
        else
 
        {
 
            status.temp = temp_pre * signint;
 
            status.temp += set.temp_offset;
 
        }
 
    }
 
}
states.h
Show inline comments
 
@@ -17,6 +17,7 @@ typedef struct {
 
    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;
 
    int16_t setpoint_steam;
 
@@ -39,6 +40,7 @@ enum state {
 
    STATE_SETWINDUP,
 
    STATE_SETBOOTTOBREW,
 
    STATE_SETUNITS,
 
    STATE_SETTEMPOFFSET,
 

	
 
    STATE_PREHEAT_BREW,
 
    STATE_MAINTAIN_BREW,
0 comments (0 inline, 0 general)