diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 0f562e18..198a28be 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -1273,6 +1273,12 @@ void setup() lcd_show_fullscreen_message_and_wait_P(MSG_FOLLOW_CALIBRATION_FLOW); } } + + if (force_selftest_if_fw_version() && calibration_status() < CALIBRATION_STATUS_ASSEMBLED ) { + lcd_show_fullscreen_message_and_wait_P(MSG_FORCE_SELFTEST); + update_current_firmware_version_to_eeprom(); + lcd_selftest(); + } KEEPALIVE_STATE(IN_PROCESS); #endif //DEBUG_DISABLE_STARTMSGS lcd_update_enable(true); diff --git a/Firmware/language_all.cpp b/Firmware/language_all.cpp index ac9b84a5..7f5e4eb7 100644 --- a/Firmware/language_all.cpp +++ b/Firmware/language_all.cpp @@ -779,6 +779,13 @@ const char * const MSG_FOLLOW_CALIBRATION_FLOW_LANG_TABLE[LANG_NUM] PROGMEM = { MSG_FOLLOW_CALIBRATION_FLOW_CZ }; +const char MSG_FORCE_SELFTEST_EN[] PROGMEM = "Selftest will be run to calibrate accurate sensorless rehoming."; +const char MSG_FORCE_SELFTEST_CZ[] PROGMEM = "Pro kalibraci presneho rehomovani bude nyni spusten selftest."; +const char * const MSG_FORCE_SELFTEST_LANG_TABLE[LANG_NUM] PROGMEM = { + MSG_FORCE_SELFTEST_EN, + MSG_FORCE_SELFTEST_CZ +}; + const char MSG_FREE_MEMORY_EN[] PROGMEM = " Free Memory: "; const char * const MSG_FREE_MEMORY_LANG_TABLE[1] PROGMEM = { MSG_FREE_MEMORY_EN diff --git a/Firmware/language_all.h b/Firmware/language_all.h index 895b9fbe..b8da5464 100644 --- a/Firmware/language_all.h +++ b/Firmware/language_all.h @@ -270,6 +270,8 @@ extern const char* const MSG_FLOW2_LANG_TABLE[1]; #define MSG_FLOW2 LANG_TABLE_SELECT_EXPLICIT(MSG_FLOW2_LANG_TABLE, 0) extern const char* const MSG_FOLLOW_CALIBRATION_FLOW_LANG_TABLE[LANG_NUM]; #define MSG_FOLLOW_CALIBRATION_FLOW LANG_TABLE_SELECT(MSG_FOLLOW_CALIBRATION_FLOW_LANG_TABLE) +extern const char* const MSG_FORCE_SELFTEST_LANG_TABLE[LANG_NUM]; +#define MSG_FORCE_SELFTEST LANG_TABLE_SELECT(MSG_FORCE_SELFTEST_LANG_TABLE) extern const char* const MSG_FREE_MEMORY_LANG_TABLE[1]; #define MSG_FREE_MEMORY LANG_TABLE_SELECT_EXPLICIT(MSG_FREE_MEMORY_LANG_TABLE, 0) extern const char* const MSG_FSENSOR_NA_LANG_TABLE[LANG_NUM]; diff --git a/Firmware/language_cz.h b/Firmware/language_cz.h index a570b34e..aaf9e160 100644 --- a/Firmware/language_cz.h +++ b/Firmware/language_cz.h @@ -406,3 +406,4 @@ #define MSG_FW_VERSION_ALPHA "Pouzivate alpha verzi firmwaru. Jedna se o vyvojovou verzi. Pouzivani teto verze firmware neni doporuceno a muze zpusobit poskozeni tiskarny." #define MSG_FW_VERSION_BETA "Pouzivate beta verzi firmwaru. Jedna se o vyvojovou verzi. Pouzivani teto verze firmware neni doporuceno a muze zpusobit poskozeni tiskarny." #define MSG_FW_VERSION_RC "Tato verze firmware je release candidate. Nektere z funkci nemusi pracovat spolehlive." +#define MSG_FORCE_SELFTEST "Pro kalibraci presneho rehomovani bude nyni spusten selftest." diff --git a/Firmware/language_en.h b/Firmware/language_en.h index fd8c9310..a3ab5fb3 100644 --- a/Firmware/language_en.h +++ b/Firmware/language_en.h @@ -412,3 +412,4 @@ #define(length=20, lines=8) MSG_FW_VERSION_ALPHA "You are using firmware alpha version. This is development version. Using this version is not recommended and may cause printer damage." #define(length=20, lines=8) MSG_FW_VERSION_BETA "You are using firmware beta version. This is development version. Using this version is not recommended and may cause printer damage." #define(length=20, lines=8) MSG_FW_VERSION_RC "This firmware version is release candidate. Some of the features may not work properly." +#define(length=20, lines=8) MSG_FORCE_SELFTEST "Selftest will be run to calibrate accurate sensorless rehoming." diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 8de9e2eb..9cd4a932 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -5842,7 +5842,7 @@ static void lcd_selftest_v() (void)lcd_selftest(); } -static bool lcd_selftest() +bool lcd_selftest() { int _progress = 0; bool _result = true; diff --git a/Firmware/ultralcd.h b/Firmware/ultralcd.h index 0940a9d8..53ced8a1 100644 --- a/Firmware/ultralcd.h +++ b/Firmware/ultralcd.h @@ -35,7 +35,7 @@ void lcd_mylang(); bool lcd_detected(void); static void lcd_selftest_v(); - static bool lcd_selftest(); + extern bool lcd_selftest(); static bool lcd_selfcheck_endstops(); #ifdef TMC2130 diff --git a/Firmware/util.cpp b/Firmware/util.cpp index 23acbee3..8aea54ab 100644 --- a/Firmware/util.cpp +++ b/Firmware/util.cpp @@ -239,6 +239,30 @@ inline int8_t is_provided_version_newer(const char *version_string) return 0; } +bool force_selftest_if_fw_version() +{ + //if fw version used before flashing new firmware (fw version currently stored in eeprom) is lower then 3.1.2-RC2, function returns true to force selftest + + uint16_t ver_eeprom[4]; + uint16_t ver_with_calibration[4] = {3, 1, 2, 4}; //hardcoded 3.1.2-RC2 version + bool force_selftest = false; + + ver_eeprom[0] = eeprom_read_word((uint16_t*)EEPROM_FIRMWARE_VERSION_MAJOR); + ver_eeprom[1] = eeprom_read_word((uint16_t*)EEPROM_FIRMWARE_VERSION_MINOR); + ver_eeprom[2] = eeprom_read_word((uint16_t*)EEPROM_FIRMWARE_VERSION_REVISION); + ver_eeprom[3] = eeprom_read_word((uint16_t*)EEPROM_FIRMWARE_VERSION_FLAVOR); + + for (uint8_t i = 0; i < 4; ++i) { + if (ver_with_calibration[i] > ver_eeprom[i]) { + force_selftest = true; + break; + } + else if (ver_with_calibration[i] < ver_eeprom[i]) + break; + } + return force_selftest; +} + bool show_upgrade_dialog_if_version_newer(const char *version_string) { uint16_t ver_gcode[4], ver_current[4]; diff --git a/Firmware/util.h b/Firmware/util.h index 52e4b6bc..7cbcb027 100644 --- a/Firmware/util.h +++ b/Firmware/util.h @@ -18,6 +18,7 @@ enum FirmwareRevisionFlavorType }; extern bool show_upgrade_dialog_if_version_newer(const char *version_string); +extern bool force_selftest_if_fw_version(); extern void update_current_firmware_version_to_eeprom();