diff --git a/Firmware/temp_model.h b/Firmware/temp_model.h index 93f40088..492781fd 100644 --- a/Firmware/temp_model.h +++ b/Firmware/temp_model.h @@ -60,7 +60,6 @@ struct model_data }; static bool enabled; // model check enabled -static bool valid = false; // model is valid static bool warn_beep = true; // beep on warning threshold static model_data data; // default heater data diff --git a/Firmware/temperature.cpp b/Firmware/temperature.cpp index 5911a0c1..8fe14ea2 100755 --- a/Firmware/temperature.cpp +++ b/Firmware/temperature.cpp @@ -2506,7 +2506,6 @@ static void temp_model_reset_enabled(bool enabled) { TempMgrGuard temp_mgr_guard; temp_model::enabled = enabled; - temp_model::valid = enabled; temp_model::data.flag_bits.uninitialized = true; } @@ -2517,19 +2516,11 @@ void temp_model_set_enabled(bool enabled) TempMgrGuard temp_mgr_guard; temp_model::enabled = enabled; temp_model::setup(); - temp_model::valid = true; } // verify that the model has been enabled - if(enabled && !temp_model::enabled) { + if(enabled && !temp_model::enabled) SERIAL_ECHOLNPGM("TM: invalid parameters, cannot enable"); - temp_model::valid = false; - } -} - -bool temp_model_valid() -{ - return temp_model::valid; } void temp_model_set_warn_beep(bool enabled) @@ -2590,7 +2581,6 @@ void temp_model_reset_settings() temp_model::data.err = TEMP_MODEL_E; temp_model::warn_beep = true; temp_model::enabled = true; - temp_model::valid = false; } void temp_model_load_settings() @@ -2888,8 +2878,12 @@ static bool autotune(int16_t cal_temp) } // namespace temp_model_cal +static bool temp_model_autotune_err = true; + void temp_model_autotune(int16_t temp, bool selftest) { + temp_model_autotune_err = true; + char tm_message[LCD_WIDTH+1]; if(moves_planned() || printer_active()) { sprintf_P(tm_message, PSTR("TM: Cal. NOT IDLE")); @@ -2907,12 +2901,12 @@ void temp_model_autotune(int16_t temp, bool selftest) temp_model_reset_enabled(selftest); SERIAL_ECHOLNPGM("TM: calibration start"); - bool err = temp_model_cal::autotune(temp > 0 ? temp : TEMP_MODEL_CAL_Th); + temp_model_autotune_err = temp_model_cal::autotune(temp > 0 ? temp : TEMP_MODEL_CAL_Th); // always reset temperature disable_heater(); - if(err) { + if(temp_model_autotune_err) { sprintf_P(tm_message, PSTR("TM: calibr. failed!")); lcd_setstatus_serial(tm_message); if(temp_error_state.v) @@ -2928,6 +2922,11 @@ void temp_model_autotune(int16_t temp, bool selftest) menu_unset_block(MENU_BLOCK_TEMP_MODEL_AUTOTUNE); } +bool temp_model_autotune_result() +{ + return !temp_model_autotune_err; +} + #ifdef TEMP_MODEL_DEBUG void temp_model_log_enable(bool enable) { diff --git a/Firmware/temperature.h b/Firmware/temperature.h index 2b66397d..c6c52227 100755 --- a/Firmware/temperature.h +++ b/Firmware/temperature.h @@ -218,7 +218,6 @@ void PID_autotune(float temp, int extruder, int ncycles); #ifdef TEMP_MODEL void temp_model_set_enabled(bool enabled); -bool temp_model_valid(); void temp_model_set_warn_beep(bool enabled); void temp_model_set_params(float C = NAN, float P = NAN, float Ta_corr = NAN, float warn = NAN, float err = NAN); void temp_model_set_resistance(uint8_t index, float R); @@ -229,6 +228,7 @@ void temp_model_load_settings(); void temp_model_save_settings(); void temp_model_autotune(int16_t temp = 0, bool selftest = false); +bool temp_model_autotune_result(); // return true if the last autotune was complete and successful #ifdef TEMP_MODEL_DEBUG void temp_model_log_enable(bool enable);