From bb3887fe1baa4d8e2a3a60e662b0106509227dd0 Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Fri, 12 May 2017 11:18:01 +0200 Subject: [PATCH] calibration status and pinda probe calibration status were split --- Firmware/Configuration.h | 4 +--- Firmware/ConfigurationStore.h | 1 + Firmware/Marlin_main.cpp | 18 +++++++++++------- Firmware/mesh_bed_calibration.cpp | 2 +- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/Firmware/Configuration.h b/Firmware/Configuration.h index 483273a0f..7d932b0b1 100644 --- a/Firmware/Configuration.h +++ b/Firmware/Configuration.h @@ -47,6 +47,7 @@ #define EEPROM_PROBE_TEMP_SHIFT (EEPROM_PRINT_FLAG - 2*5) //5 x int for storing pinda probe temp shift relative to 50 C; unit: motor steps #define EEPROM_TEMP_CAL_ACTIVE (EEPROM_PROBE_TEMP_SHIFT - 1) #define EEPROM_BOWDEN_LENGTH (EEPROM_TEMP_CAL_ACTIVE - 2*4) //4 x int for bowden lengths for multimaterial +#define EEPROM_CALIBRATION_STATUS_PINDA (EEPROM_BOWDEN_LENGTH - 1) //0 - not calibrated; 1 - calibrated // Currently running firmware, each digit stored as uint16_t. // The flavor differentiates a dev, alpha, beta, release candidate or a release version. @@ -714,9 +715,6 @@ enum CalibrationStatus // The XYZ calibration has been performed, now it remains to run the V2Calibration.gcode. CALIBRATION_STATUS_LIVE_ADJUST = 230, - //V2 calibration has been run, now run PINDA probe temperature calibration - CALIBRATION_STATUS_PINDA = 220, - // Calibrated, ready to print. CALIBRATION_STATUS_CALIBRATED = 1, diff --git a/Firmware/ConfigurationStore.h b/Firmware/ConfigurationStore.h index c73b29bcb..164aed681 100644 --- a/Firmware/ConfigurationStore.h +++ b/Firmware/ConfigurationStore.h @@ -22,5 +22,6 @@ FORCE_INLINE void Config_RetrieveSettings() { Config_ResetDefault(); Config_Prin inline uint8_t calibration_status() { return eeprom_read_byte((uint8_t*)EEPROM_CALIBRATION_STATUS); } inline uint8_t calibration_status_store(uint8_t status) { eeprom_update_byte((uint8_t*)EEPROM_CALIBRATION_STATUS, status); } +inline bool calibration_status_pinda() { return eeprom_read_byte((uint8_t*)EEPROM_CALIBRATION_STATUS_PINDA); } #endif//CONFIG_STORE_H diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 7cd1aafeb..ee98afa0b 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -1181,6 +1181,10 @@ void setup() temp_cal_active = false; } else temp_cal_active = eeprom_read_byte((uint8_t*)EEPROM_TEMP_CAL_ACTIVE); + if (eeprom_read_byte((uint8_t*)EEPROM_CALIBRATION_STATUS_PINDA) == 255) { + eeprom_write_byte((uint8_t*)EEPROM_CALIBRATION_STATUS_PINDA, 0); + } + check_babystep(); //checking if Z babystep is in allowed range if (calibration_status() == CALIBRATION_STATUS_ASSEMBLED || @@ -1193,7 +1197,7 @@ void setup() // Show the message. lcd_show_fullscreen_message_and_wait_P(MSG_BABYSTEP_Z_NOT_SET); lcd_update_enable(true); - } else if (calibration_status() == CALIBRATION_STATUS_PINDA && temp_cal_active == true) { + } else if (calibration_status() == CALIBRATION_STATUS_CALIBRATED && temp_cal_active == true && calibration_status_pinda() == false) { lcd_show_fullscreen_message_and_wait_P(MSG_PINDA_NOT_CALIBRATED); lcd_update_enable(true); } else if (calibration_status() == CALIBRATION_STATUS_Z_CALIBRATION) { @@ -2786,7 +2790,7 @@ void process_commands() //enquecommand_P(PSTR("M190 S50")); for (int i = 0; i < PINDA_HEAT_T; i++) delay_keep_alive(1000); - calibration_status_store(CALIBRATION_STATUS_PINDA); //invalidate temp. calibration in case that in will be aborted during the calibration process + eeprom_update_byte((uint8_t*)EEPROM_CALIBRATION_STATUS_PINDA, 0); //invalidate temp. calibration in case that in will be aborted during the calibration process current_position[Z_AXIS] = 5; plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 3000 / 60, active_extruder); @@ -2840,7 +2844,7 @@ void process_commands() custom_message_type = 0; custom_message = false; - calibration_status_store(CALIBRATION_STATUS_CALIBRATED); + eeprom_update_byte((uint8_t*)EEPROM_CALIBRATION_STATUS_PINDA, 1); lcd_show_fullscreen_message_and_wait_P(MSG_TEMP_CALIBRATION_DONE); lcd_update_enable(true); lcd_update(2); @@ -2915,7 +2919,7 @@ void process_commands() break; } - if (run == false && card.sdprinting == true && temp_cal_active == true && calibration_status() < CALIBRATION_STATUS_PINDA) { + if (run == false && card.sdprinting == true && temp_cal_active == true && calibration_status_pinda() == true) { temp_compensation_start(); run = true; repeatcommand_front(); // repeat G80 with all its parameters @@ -3062,7 +3066,7 @@ void process_commands() } clean_up_after_endstop_move(); SERIAL_ECHOLNPGM("clean up finished "); - if(temp_cal_active == true && calibration_status() < CALIBRATION_STATUS_PINDA) temp_compensation_apply(); //apply PINDA temperature compensation + if(temp_cal_active == true && calibration_status_pinda() == true) temp_compensation_apply(); //apply PINDA temperature compensation babystep_apply(); // Apply Z height correction aka baby stepping before mesh bed leveing gets activated. SERIAL_ECHOLNPGM("babystep applied"); bool eeprom_bed_correction_valid = eeprom_read_byte((unsigned char*)EEPROM_BED_CORRECTION_VALID) == 1; @@ -3128,7 +3132,7 @@ void process_commands() go_home_with_z_lift(); SERIAL_ECHOLNPGM("Go home finished"); //unretract (after PINDA preheat retraction) - if (card.sdprinting == true && degHotend(active_extruder) > EXTRUDE_MINTEMP && temp_cal_active == true) { + if (card.sdprinting == true && degHotend(active_extruder) > EXTRUDE_MINTEMP && temp_cal_active == true && calibration_status_pinda() == true) { current_position[E_AXIS] += DEFAULT_RETRACTION; plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 400, active_extruder); } @@ -3236,7 +3240,7 @@ void process_commands() * This G-code will be performed at the end of a calibration script. */ case 87: - calibration_status_store(CALIBRATION_STATUS_PINDA); + calibration_status_store(CALIBRATION_STATUS_CALIBRATED); break; /** diff --git a/Firmware/mesh_bed_calibration.cpp b/Firmware/mesh_bed_calibration.cpp index 1ebc12658..14e80652c 100644 --- a/Firmware/mesh_bed_calibration.cpp +++ b/Firmware/mesh_bed_calibration.cpp @@ -2309,7 +2309,7 @@ static int babystepLoadZ = 0; void babystep_apply() { // Apply Z height correction aka baby stepping before mesh bed leveling gets activated. - if(calibration_status() <= CALIBRATION_STATUS_PINDA) + if(calibration_status() == CALIBRATION_STATUS_CALIBRATED) { check_babystep(); //checking if babystep is in allowed range, otherwise setting babystep to 0