diff --git a/Firmware/Configuration.h b/Firmware/Configuration.h index 391935f1..b8669c22 100644 --- a/Firmware/Configuration.h +++ b/Firmware/Configuration.h @@ -132,6 +132,9 @@ // Power loss errors (total) #define EEPROM_POWER_COUNT_TOT (EEPROM_FERROR_COUNT_TOT - 2) // uint16 +#define EEPROM_PRINTER_TYPE (EEPROM_POWER_COUNT_TOT - 2) // uint16 +#define EEPROM_BOARD_TYPE (EEPROM_PRINTER_TYPE - 2) // uint16 + //TMC2130 configuration #define EEPROM_TMC_AXIS_SIZE //axis configuration block size diff --git a/Firmware/Configuration_prusa.h b/Firmware/Configuration_prusa.h index 9244f825..5654506e 100644 --- a/Firmware/Configuration_prusa.h +++ b/Firmware/Configuration_prusa.h @@ -6,6 +6,7 @@ *------------------------------------*/ // Printer revision +#define PRINTER_TYPE PRINTER_MK25 #define FILAMENT_SIZE "1_75mm_MK25" #define NOZZLE_TYPE "E3Dv6full" @@ -157,7 +158,7 @@ const bool Z_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic o #endif // Extrude mintemp -#define EXTRUDE_MINTEMP 190 +#define EXTRUDE_MINTEMP 180 // Extruder cooling fans #define EXTRUDER_0_AUTO_FAN_PIN 8 diff --git a/Firmware/Marlin.h b/Firmware/Marlin.h index 9e686bcb..f3f13463 100644 --- a/Firmware/Marlin.h +++ b/Firmware/Marlin.h @@ -380,6 +380,7 @@ void temp_compensation_apply(); void temp_compensation_start(); void show_fw_version_warnings(); void erase_eeprom_section(uint16_t offset, uint16_t bytes); +uint8_t check_printer_version(); #ifdef PINDA_THERMISTOR float temp_compensation_pinda_thermistor_offset(float temperature_pinda); diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 61d80d57..88274e49 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -41,6 +41,7 @@ #include "mesh_bed_calibration.h" #endif +#include "printers.h" #include "ultralcd.h" #include "Configuration_prusa.h" #include "planner.h" @@ -935,7 +936,22 @@ void show_fw_version_warnings() { lcd_update_enable(true); } +uint8_t check_printer_version() +{ + uint8_t version_changed = 0; + uint16_t printer_type = eeprom_read_word((uint16_t*)EEPROM_PRINTER_TYPE); + uint16_t motherboard = eeprom_read_word((uint16_t*)EEPROM_BOARD_TYPE); + if (printer_type != PRINTER_TYPE) { + if (printer_type == 0xffff) eeprom_write_word((uint16_t*)EEPROM_PRINTER_TYPE, PRINTER_TYPE); + else version_changed |= 0b10; + } + if (motherboard != MOTHERBOARD) { + if(motherboard == 0xffff) eeprom_write_word((uint16_t*)EEPROM_BOARD_TYPE, MOTHERBOARD); + else version_changed |= 0b01; + } + return version_changed; +} void erase_eeprom_section(uint16_t offset, uint16_t bytes) { @@ -1022,7 +1038,15 @@ void setup() SERIAL_ECHOLN((int)sizeof(block_t)*BLOCK_BUFFER_SIZE); //lcd_update_enable(false); // why do we need this?? - andre // loads data from EEPROM if available else uses defaults (and resets step acceleration rate) - bool previous_settings_retrieved = Config_RetrieveSettings(EEPROM_OFFSET); + + bool previous_settings_retrieved = false; + uint8_t hw_changed = check_printer_version(); + if (!(hw_changed & 0b10)) { //if printer version wasn't changed, check for eeprom version and retrieve settings from eeprom in case that version wasn't changed + previous_settings_retrieved = Config_RetrieveSettings(EEPROM_OFFSET); + } + else { //printer version was changed so use default settings + Config_ResetDefault(); + } SdFatUtil::set_stack_guard(); //writes magic number at the end of static variables to protect against overwriting static memory by stack tp_init(); // Initialize temperature loop @@ -1195,8 +1219,27 @@ void setup() show_fw_version_warnings(); + switch (hw_changed) { + //if motherboard or printer type was changed inform user as it can indicate flashing wrong firmware version + //if user confirms with knob, new hw version (printer and/or motherboard) is written to eeprom and message will be not shown next time + case(0b01): + lcd_show_fullscreen_message_and_wait_P(MSG_CHANGED_MOTHERBOARD); + eeprom_write_word((uint16_t*)EEPROM_BOARD_TYPE, MOTHERBOARD); + break; + case(0b10): + lcd_show_fullscreen_message_and_wait_P(MSG_CHANGED_PRINTER); + eeprom_write_word((uint16_t*)EEPROM_PRINTER_TYPE, PRINTER_TYPE); + break; + case(0b11): + lcd_show_fullscreen_message_and_wait_P(MSG_CHANGED_BOTH); + eeprom_write_word((uint16_t*)EEPROM_PRINTER_TYPE, PRINTER_TYPE); + eeprom_write_word((uint16_t*)EEPROM_BOARD_TYPE, MOTHERBOARD); + break; + default: break; //no change, show no message + } + if (!previous_settings_retrieved) { - lcd_show_fullscreen_message_and_wait_P(MSG_DEFAULT_SETTINGS_LOADED); //if EEPROM version was changed, inform user that default setting were loaded + lcd_show_fullscreen_message_and_wait_P(MSG_DEFAULT_SETTINGS_LOADED); //if EEPROM version or printer type was changed, inform user that default setting were loaded erase_eeprom_section(EEPROM_OFFSET, 156); //erase M500 part of eeprom } if (eeprom_read_byte((uint8_t*)EEPROM_WIZARD_ACTIVE) == 1) { diff --git a/Firmware/language_all.cpp b/Firmware/language_all.cpp index ac9b84a5..6d72bb18 100644 --- a/Firmware/language_all.cpp +++ b/Firmware/language_all.cpp @@ -320,6 +320,27 @@ const char * const MSG_CARD_MENU_LANG_TABLE[LANG_NUM] PROGMEM = { MSG_CARD_MENU_CZ }; +const char MSG_CHANGED_BOTH_EN[] PROGMEM = "Warning: both printer type and motherboard type changed."; +const char MSG_CHANGED_BOTH_CZ[] PROGMEM = "Varovani: doslo ke zmene typu tiskarny a motherboardu."; +const char * const MSG_CHANGED_BOTH_LANG_TABLE[LANG_NUM] PROGMEM = { + MSG_CHANGED_BOTH_EN, + MSG_CHANGED_BOTH_CZ +}; + +const char MSG_CHANGED_MOTHERBOARD_EN[] PROGMEM = "Warning: motherboard type changed."; +const char MSG_CHANGED_MOTHERBOARD_CZ[] PROGMEM = "Varovani: doslo ke zmene typu motherboardu."; +const char * const MSG_CHANGED_MOTHERBOARD_LANG_TABLE[LANG_NUM] PROGMEM = { + MSG_CHANGED_MOTHERBOARD_EN, + MSG_CHANGED_MOTHERBOARD_CZ +}; + +const char MSG_CHANGED_PRINTER_EN[] PROGMEM = "Warning: printer type changed."; +const char MSG_CHANGED_PRINTER_CZ[] PROGMEM = "Varovani: doslo ke zmene typu tiskarny."; +const char * const MSG_CHANGED_PRINTER_LANG_TABLE[LANG_NUM] PROGMEM = { + MSG_CHANGED_PRINTER_EN, + MSG_CHANGED_PRINTER_CZ +}; + const char MSG_CHANGE_EXTR_EN[] PROGMEM = "Change extruder"; const char MSG_CHANGE_EXTR_CZ[] PROGMEM = "Zmenit extruder"; const char * const MSG_CHANGE_EXTR_LANG_TABLE[LANG_NUM] PROGMEM = { diff --git a/Firmware/language_all.h b/Firmware/language_all.h index 895b9fbe..a055e361 100644 --- a/Firmware/language_all.h +++ b/Firmware/language_all.h @@ -120,6 +120,12 @@ extern const char* const MSG_CALIBRATION_PINDA_MENU_LANG_TABLE[LANG_NUM]; #define MSG_CALIBRATION_PINDA_MENU LANG_TABLE_SELECT(MSG_CALIBRATION_PINDA_MENU_LANG_TABLE) extern const char* const MSG_CARD_MENU_LANG_TABLE[LANG_NUM]; #define MSG_CARD_MENU LANG_TABLE_SELECT(MSG_CARD_MENU_LANG_TABLE) +extern const char* const MSG_CHANGED_BOTH_LANG_TABLE[LANG_NUM]; +#define MSG_CHANGED_BOTH LANG_TABLE_SELECT(MSG_CHANGED_BOTH_LANG_TABLE) +extern const char* const MSG_CHANGED_MOTHERBOARD_LANG_TABLE[LANG_NUM]; +#define MSG_CHANGED_MOTHERBOARD LANG_TABLE_SELECT(MSG_CHANGED_MOTHERBOARD_LANG_TABLE) +extern const char* const MSG_CHANGED_PRINTER_LANG_TABLE[LANG_NUM]; +#define MSG_CHANGED_PRINTER LANG_TABLE_SELECT(MSG_CHANGED_PRINTER_LANG_TABLE) extern const char* const MSG_CHANGE_EXTR_LANG_TABLE[LANG_NUM]; #define MSG_CHANGE_EXTR LANG_TABLE_SELECT(MSG_CHANGE_EXTR_LANG_TABLE) extern const char* const MSG_CHANGE_SUCCESS_LANG_TABLE[LANG_NUM]; diff --git a/Firmware/language_cz.h b/Firmware/language_cz.h index a570b34e..355b786e 100644 --- a/Firmware/language_cz.h +++ b/Firmware/language_cz.h @@ -406,3 +406,7 @@ #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_CHANGED_MOTHERBOARD "Varovani: doslo ke zmene typu motherboardu." +#define MSG_CHANGED_PRINTER "Varovani: doslo ke zmene typu tiskarny." +#define MSG_CHANGED_BOTH "Varovani: doslo ke zmene typu tiskarny a motherboardu." diff --git a/Firmware/language_en.h b/Firmware/language_en.h index fd8c9310..c22d9fb4 100644 --- a/Firmware/language_en.h +++ b/Firmware/language_en.h @@ -412,3 +412,6 @@ #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=4) MSG_CHANGED_MOTHERBOARD "Warning: motherboard type changed." +#define(length=20, lines=4) MSG_CHANGED_PRINTER "Warning: printer type changed." +#define(length=20, lines=4) MSG_CHANGED_BOTH "Warning: both printer type and motherboard type changed." \ No newline at end of file diff --git a/Firmware/printers.h b/Firmware/printers.h new file mode 100644 index 00000000..b0b5e2ba --- /dev/null +++ b/Firmware/printers.h @@ -0,0 +1,14 @@ +#ifndef PRINTERS_H +#define PRINTERS_H + +#define PRINTER_UNKNOWN 0 + +#define PRINTER_MK1 100 +#define PRINTER_MK2 200 +#define PRINTER_MK2_SNMM 201 +#define PRINTER_MK25 250 +#define PRINTER_MK25_SNMM 251 +#define PRINTER_MK3 300 +#define PRINTER_MK3_SNMM 301 + +#endif //PRINTERS_H