diff --git a/main.c b/main.c --- a/main.c +++ b/main.c @@ -49,7 +49,7 @@ int main(void) // Init USB (TODO: Handle plugged/unplugged with external power) MX_USB_DEVICE_Init(); -// set.usb_plugged = +// set.val.usb_plugged = // USB startup delay HAL_Delay(1000); @@ -67,15 +67,15 @@ int main(void) ssd1306_clearscreen(); // Default settings - set.boottobrew = 0; - set.temp_units = TEMP_UNITS_CELSIUS; - set.windup_guard = 1; - set.k_p = 1; - set.k_i = 1; - set.k_d = 1; - set.ignore_tc_error = 0; - set.setpoint_brew = 0; - set.setpoint_steam = 0; + set.val.boottobrew = 0; + set.val.temp_units = TEMP_UNITS_CELSIUS; + set.val.windup_guard = 1; + set.val.k_p = 1; + set.val.k_i = 1; + set.val.k_d = 1; + set.val.ignore_tc_error = 0; + set.val.setpoint_brew = 0; + set.val.setpoint_steam = 0; // Default status status.temp = 0; @@ -89,7 +89,7 @@ int main(void) restore_settings(&set); // Go to brew instead of idle if configured thusly - if(set.boottobrew) + if(set.val.boottobrew) status.state = STATE_PREHEAT_BREW; // Startup screen @@ -98,7 +98,7 @@ int main(void) HAL_Delay(1500); - flash_init(&set); + flash_restore(&set); HAL_Delay(1500); ssd1306_clearscreen(); @@ -138,7 +138,7 @@ int16_t update_pid(uint16_t k_p, uint16_ // it cant help be cold despite its best efforts) // not necessary, but this makes windup guard values // relative to the current iGain - int32_t windup_guard_res = set.windup_guard / k_i; + int32_t windup_guard_res = set.val.windup_guard / k_i; // Calculate integral term with windup guard if (i_state > windup_guard_res) @@ -201,7 +201,7 @@ void process() if(status.pid_enabled) { // Get ssr output for next time - int16_t power_percent = update_pid(set.k_p, set.k_i, set.k_d, status.temp, status.temp_frac, status.setpoint); + int16_t power_percent = update_pid(set.val.k_p, set.val.k_i, set.val.k_d, status.temp, status.temp_frac, status.setpoint); //power-percent is 0-1000 ssr_output = power_percent; //(((uint32_t)SSR_PERIOD * (uint32_t)10 * (uint32_t)100) * power_percent) / (uint32_t)1000000; } @@ -244,7 +244,7 @@ void process() tempstr[numlen] = '\r'; tempstr[numlen+1] = '\n'; -// if(set.usb_plugged) +// if(set.val.usb_plugged) // CDC_Transmit_FS(tempstr, numlen+2); // while(CDC_Transmit_FS("\r\n", 2) == USBD_BUSY);