Handle CALIBRATION_STATUS_LIVE_ADJUST

This commit is contained in:
Yuri D'Elia 2022-12-24 19:33:07 +01:00 committed by DRracer
parent 5ec627c12c
commit b41ece175b
3 changed files with 15 additions and 15 deletions

View File

@ -3362,8 +3362,9 @@ bool gcode_M45(bool onlyZ, int8_t verbosity_level)
else
{
// Reset the baby step value and the baby step applied flag.
calibration_status_store(CALIBRATION_STATUS_XYZ_CALIBRATION);
eeprom_update_word(reinterpret_cast<uint16_t *>(&(EEPROM_Sheets_base->s[(eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet)))].z_offset)),0);
calibration_status_clear(CALIBRATION_STATUS_LIVE_ADJUST);
eeprom_update_word(reinterpret_cast<uint16_t *>(&(EEPROM_Sheets_base->s[(eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet)))].z_offset)),0);
// Complete XYZ calibration.
uint8_t point_too_far_mask = 0;
BedSkewOffsetDetectionResultType result = find_bed_offset_and_skew(verbosity_level, point_too_far_mask);
@ -5142,7 +5143,7 @@ void process_commands()
(Prusa3D specific)
*/
case 86:
calibration_status_store(CALIBRATION_STATUS_LIVE_ADJUST);
calibration_status_clear(CALIBRATION_STATUS_LIVE_ADJUST);
break;
@ -5153,7 +5154,7 @@ void process_commands()
(Prusa3D specific)
*/
case 87:
calibration_status_store(CALIBRATION_STATUS_CALIBRATED);
calibration_status_set(CALIBRATION_STATUS_LIVE_ADJUST);
break;
/*!
@ -5605,9 +5606,9 @@ void process_commands()
*/
case 44: // M44: Prusa3D: Reset the bed skew and offset calibration.
// Reset the baby step value and the baby step applied flag.
calibration_status_store(CALIBRATION_STATUS_ASSEMBLED);
eeprom_update_word(reinterpret_cast<uint16_t *>(&(EEPROM_Sheets_base->s[(eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet)))].z_offset)),0);
// Reset the baby step value and the baby step applied flag.
calibration_status_clear(CALIBRATION_STATUS_LIVE_ADJUST);
eeprom_update_word(reinterpret_cast<uint16_t *>(&(EEPROM_Sheets_base->s[(eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet)))].z_offset)),0);
// Reset the skew and offset in both RAM and EEPROM.
reset_bed_offset_and_skew();

View File

@ -1,5 +1,6 @@
#include "Configuration.h"
#include "ConfigurationStore.h"
#include "util.h"
#include "language.h"
#include "mesh_bed_calibration.h"
#include "mesh_bed_leveling.h"
@ -3040,7 +3041,7 @@ void babystep_load()
{
babystepLoadZ = 0;
// Apply Z height correction aka baby stepping before mesh bed leveling gets activated.
if (calibration_status() < CALIBRATION_STATUS_LIVE_ADJUST)
if (calibration_status_get(CALIBRATION_STATUS_LIVE_ADJUST))
{
check_babystep(); //checking if babystep is in allowed range, otherwise setting babystep to 0

View File

@ -2702,7 +2702,7 @@ static void lcd_babystep_z()
}
// same logic as in babystep_load
if (calibration_status() >= CALIBRATION_STATUS_LIVE_ADJUST)
if (!calibration_status_get(CALIBRATION_STATUS_LIVE_ADJUST))
_md->babystepMemZ = 0;
_md->babystepMemMMZ = _md->babystepMemZ/cs.axis_steps_per_unit[Z_AXIS];
@ -2744,7 +2744,7 @@ static void lcd_babystep_z()
#ifdef PINDA_THERMISTOR
eeprom_update_byte(&(EEPROM_Sheets_base->s[active_sheet].pinda_temp),current_temperature_pinda);
#endif //PINDA_THERMISTOR
calibration_status_store(CALIBRATION_STATUS_CALIBRATED);
calibration_status_set(CALIBRATION_STATUS_LIVE_ADJUST);
}
if (LCD_CLICKED) menu_back();
}
@ -3740,7 +3740,7 @@ void lcd_first_layer_calibration_reset()
MenuData* menuData = (MenuData*)&(menu_data[0]);
if(LCD_CLICKED || !eeprom_is_sheet_initialized(eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet))) ||
(calibration_status() >= CALIBRATION_STATUS_LIVE_ADJUST) ||
(!calibration_status_get(CALIBRATION_STATUS_LIVE_ADJUST)) ||
(0 == static_cast<int16_t>(eeprom_read_word(reinterpret_cast<uint16_t*>
(&EEPROM_Sheets_base->s[(eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet)))].z_offset)))))
{
@ -5344,10 +5344,8 @@ static void lcd_reset_sheet()
if (selected_sheet == eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet)))
{
eeprom_switch_to_next_sheet();
if((-1 == eeprom_next_initialized_sheet(0)) && (CALIBRATION_STATUS_CALIBRATED == calibration_status()))
{
calibration_status_store(CALIBRATION_STATUS_LIVE_ADJUST);
}
if (-1 == eeprom_next_initialized_sheet(0))
calibration_status_clear(CALIBRATION_STATUS_LIVE_ADJUST);
}
menu_back();