diff --git a/Firmware/Configuration.h b/Firmware/Configuration.h index 92de22bcb..bc274d676 100644 --- a/Firmware/Configuration.h +++ b/Firmware/Configuration.h @@ -524,36 +524,6 @@ your extruder heater takes 2 minutes to hit the target on heating. #define DEFAULT_NOMINAL_FILAMENT_DIA 1.75 //Enter the diameter (in mm) of the filament generally used (3.0 mm or 1.75 mm). Used by the volumetric extrusion. -// Calibration status of the machine, to be stored into the EEPROM, -// (unsigned char*)EEPROM_CALIBRATION_STATUS -enum CalibrationStatus -{ - // Freshly assembled, needs to peform a self-test and the XYZ calibration. - CALIBRATION_STATUS_ASSEMBLED = 255, - - // For the wizard: self test has been performed, now the XYZ calibration is needed. - CALIBRATION_STATUS_XYZ_CALIBRATION = 250, - - // For the wizard: factory assembled, needs to run Z calibration. - CALIBRATION_STATUS_Z_CALIBRATION = 240, - -#ifdef TEMP_MODEL - // The XYZ calibration has been performed, needs to run Temp model calibration. - CALIBRATION_STATUS_TEMP_MODEL_CALIBRATION = 235, -#endif //TEMP_MODEL - -// The XYZ calibration AND OR Temp model calibration has been performed, now it remains to run the V2Calibration.gcode. - CALIBRATION_STATUS_LIVE_ADJUST = 230, - - // Calibrated, ready to print. - CALIBRATION_STATUS_CALIBRATED = 1, - - // Legacy: resetted by issuing a G86 G-code. - // This value can only be expected after an upgrade from the initial MK2 firmware releases. - // Currently the G86 sets the calibration status to - CALIBRATION_STATUS_UNKNOWN = 0, -}; - // Try to maintain a minimum distance from the bed even when Z is // unknown when doing the following operations #define MIN_Z_FOR_LOAD 50 // lcd filament loading or autoload diff --git a/Firmware/ConfigurationStore.h b/Firmware/ConfigurationStore.h index 892bbb938..f3c61ce8c 100644 --- a/Firmware/ConfigurationStore.h +++ b/Firmware/ConfigurationStore.h @@ -65,7 +65,4 @@ FORCE_INLINE void Config_StoreSettings() {} FORCE_INLINE void Config_RetrieveSettings() { Config_ResetDefault(); Config_PrintSettings(); } #endif -inline uint8_t calibration_status() { return eeprom_read_byte((uint8_t*)EEPROM_CALIBRATION_STATUS); } -inline void 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/eeprom.h b/Firmware/eeprom.h index 95f03083b..7dc2bc7c1 100644 --- a/Firmware/eeprom.h +++ b/Firmware/eeprom.h @@ -89,13 +89,13 @@ static_assert(sizeof(Sheets) == EEPROM_SHEETS_SIZEOF, "Sizeof(Sheets) is not EEP | 0x0FFA 4090 | uint16 | EEPROM_BABYSTEP_Y | ??? | ff ffh 65535 | Babystep for Y axis _unsued_ | ^ | D3 Ax0ffa C2 | 0x0FF8 4088 | uint16 | EEPROM_BABYSTEP_Z | ??? | ff ffh 65535 | Babystep for Z axis _lagacy_ | ^ | D3 Ax0ff8 C2 | ^ | ^ | ^ | ^ | ^ | multiple values stored now in EEPROM_Sheets_base | ^ | ^ -| 0x0FF7 4087 | uint8 | EEPROM_CALIBRATION_STATUS | ffh 255 | ffh 255 | Assembled _default_ | ??? | D3 Ax0ff7 C1 +| 0x0FF7 4087 | uint8 | EEPROM_CALIBRATION_STATUS_V1 | ffh 255 | ffh 255 | Calibration status (=v3.12) | ??? | D3 Ax0ca6 C1 |Address begin|Bit/Type | Name | Valid values | Default/FactoryReset | Description |Gcode/Function| Debug code | :--: | :--: | :--: | :--: | :--: | :--: | :--: | :--: @@ -370,7 +371,7 @@ static_assert(sizeof(Sheets) == EEPROM_SHEETS_SIZEOF, "Sizeof(Sheets) is not EEP #define EEPROM_BABYSTEP_X 4092 //unused #define EEPROM_BABYSTEP_Y 4090 //unused #define EEPROM_BABYSTEP_Z 4088 //legacy, multiple values stored now in EEPROM_Sheets_base -#define EEPROM_CALIBRATION_STATUS 4087 +#define EEPROM_CALIBRATION_STATUS_V1 4087 // legacy, used up to v3.11 #define EEPROM_BABYSTEP_Z0 4085 #define EEPROM_FILAMENTUSED 4081 // uint32_t @@ -575,9 +576,10 @@ static Sheets * const EEPROM_Sheets_base = (Sheets*)(EEPROM_SHEETS_BASE); #define EEPROM_MMU_ENABLED (EEPROM_FSENSOR_JAM_DETECTION-1) // uint8_t #define EEPROM_TOTAL_TOOLCHANGE_COUNT (EEPROM_MMU_ENABLED-4) #define EEPROM_HEAT_BED_ON_LOAD_FILAMENT (EEPROM_TOTAL_TOOLCHANGE_COUNT-1) //uint8 +#define EEPROM_CALIBRATION_STATUS_V2 (EEPROM_HEAT_BED_ON_LOAD_FILAMENT-1) //uint8 //This is supposed to point to last item to allow EEPROM overrun check. Please update when adding new items. -#define EEPROM_LAST_ITEM EEPROM_HEAT_BED_ON_LOAD_FILAMENT +#define EEPROM_LAST_ITEM EEPROM_CALIBRATION_STATUS_V2 // !!!!! // !!!!! this is end of EEPROM section ... all updates MUST BE inserted before this mark !!!!! // !!!!! diff --git a/Firmware/util.cpp b/Firmware/util.cpp index 58800ae76..942088b3c 100644 --- a/Firmware/util.cpp +++ b/Firmware/util.cpp @@ -464,3 +464,24 @@ void ip4_to_str(char* dest, uint8_t* IP) { sprintf_P(dest, PSTR("%u.%u.%u.%u"), IP[0], IP[1], IP[2], IP[3]); } + + +bool calibration_status_get(CalibrationStatus components) +{ + CalibrationStatus status = eeprom_read_byte((uint8_t*)EEPROM_CALIBRATION_STATUS_V2); + return ((status & components) == components); +} + +void calibration_status_set(CalibrationStatus components) +{ + CalibrationStatus status = eeprom_read_byte((uint8_t*)EEPROM_CALIBRATION_STATUS_V2); + status |= components; + eeprom_update_byte((uint8_t*)EEPROM_CALIBRATION_STATUS_V2, status); +} + +void calibration_status_clear(CalibrationStatus components) +{ + CalibrationStatus status = eeprom_read_byte((uint8_t*)EEPROM_CALIBRATION_STATUS_V2); + status &= ~components; + eeprom_update_byte((uint8_t*)EEPROM_CALIBRATION_STATUS_V2, status); +} diff --git a/Firmware/util.h b/Firmware/util.h index bdfc21da3..d81c8f894 100644 --- a/Firmware/util.h +++ b/Firmware/util.h @@ -100,3 +100,35 @@ const char *sPrinterType(bool bMMu); #define IP4_STR_SIZE 16 extern void ip4_to_str(char* dest, uint8_t* IP); + +// Calibration status of the machine +// (unsigned char*)EEPROM_CALIBRATION_STATUS_V2 +typedef uint8_t CalibrationStatus; +const CalibrationStatus CALIBRATION_STATUS_SELFTEST = 0b00000001; // Selftest +const CalibrationStatus CALIBRATION_STATUS_XYZ = 0b00000010; // XYZ calibration +const CalibrationStatus CALIBRATION_STATUS_Z = 0b00000100; // Z calibration +#ifdef TEMP_MODEL +const CalibrationStatus CALIBRATION_STATUS_TEMP_MODEL = 0b00001000; // Temperature model calibration +#endif +const CalibrationStatus CALIBRATION_STATUS_LIVE_ADJUST = 0b00010000; // 1st layer calibration +const CalibrationStatus CALIBRATION_STATUS_UNKNOWN = 0b10000000; // Freshly assembled or unknown status + +// Calibration steps performed by the wizard +const CalibrationStatus CALIBRATION_WIZARD_STEPS = + CALIBRATION_STATUS_SELFTEST | + CALIBRATION_STATUS_XYZ | + CALIBRATION_STATUS_Z | +#ifdef TEMP_MODEL + CALIBRATION_STATUS_TEMP_MODEL | +#endif + CALIBRATION_STATUS_LIVE_ADJUST; + +// Calibration steps enforced after service prep +const CalibrationStatus CALIBRATION_FORCE_PREP = CALIBRATION_STATUS_Z; + +bool calibration_status_get(CalibrationStatus components); +void calibration_status_set(CalibrationStatus components); +void calibration_status_clear(CalibrationStatus components); + +// PINDA has an independent calibration flag +inline bool calibration_status_pinda() { return eeprom_read_byte((uint8_t*)EEPROM_CALIBRATION_STATUS_PINDA); }