diff --git a/Firmware/Configuration.cpp b/Firmware/Configuration.cpp index 082ac0706..343ae419a 100644 --- a/Firmware/Configuration.cpp +++ b/Firmware/Configuration.cpp @@ -5,6 +5,3 @@ const uint16_t _nPrinterType PROGMEM=PRINTER_TYPE; const char _sPrinterName[] PROGMEM=PRINTER_NAME; const uint16_t _nPrinterMmuType PROGMEM=PRINTER_MMU_TYPE; const char _sPrinterMmuName[] PROGMEM=PRINTER_MMU_NAME; - -uint16_t nPrinterType; -PGM_P sPrinterName; \ No newline at end of file diff --git a/Firmware/Configuration.h b/Firmware/Configuration.h index 065366641..aa40af0e2 100644 --- a/Firmware/Configuration.h +++ b/Firmware/Configuration.h @@ -12,8 +12,6 @@ extern const uint16_t _nPrinterType; extern const char _sPrinterName[] PROGMEM; extern const uint16_t _nPrinterMmuType; extern const char _sPrinterMmuName[] PROGMEM; -extern uint16_t nPrinterType; -extern PGM_P sPrinterName; // Firmware version #define FW_MAJOR 3 diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 70128536d..bbf5a89d6 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -8049,27 +8049,27 @@ Sigma_Exit: else if(code_seen('Q')) SERIAL_PROTOCOLLN((float)eeprom_read_word((uint16_t*)EEPROM_NOZZLE_DIAMETER_uM)/1000.0); break; - case ClPrintChecking::_Model: // ~ .2 + case ClPrintChecking::_Model: { // ~ .2 + uint16_t type = nPrinterType(MMU2::mmu2.Enabled()); if(code_seen('P')) { uint16_t nPrinterModel; nPrinterModel=(uint16_t)code_value_long(); // based on current state of MMU (active/stopped/connecting) perform a runtime update of the printer type - fSetMmuMode(MMU2::mmu2.Enabled()); - printer_model_check(nPrinterModel); + printer_model_check(nPrinterModel, type); } else if(code_seen('Q')) - SERIAL_PROTOCOLLN(nPrinterType); - break; - case ClPrintChecking::_Smodel: // ~ .3 + SERIAL_PROTOCOLLN(type); + } break; + case ClPrintChecking::_Smodel: { // ~ .3 + const char *type = sPrinterType(MMU2::mmu2.Enabled()); if(code_seen('P')) { - fSetMmuMode(MMU2::mmu2.Enabled()); - printer_smodel_check(strchr_pointer); + printer_smodel_check(strchr_pointer, type); } else if(code_seen('Q')) - SERIAL_PROTOCOLLNRPGM(sPrinterName); - break; + SERIAL_PROTOCOLLNRPGM(type); + } break; case ClPrintChecking::_Version: // ~ .4 if(code_seen('P')) fw_version_check(++strchr_pointer); diff --git a/Firmware/util.cpp b/Firmware/util.cpp index 6c4187d61..1ff2a2ed7 100644 --- a/Firmware/util.cpp +++ b/Firmware/util.cpp @@ -328,15 +328,15 @@ void nozzle_diameter_check(uint16_t nDiameter) { } } -void printer_model_check(uint16_t nPrinterModel) { +void printer_model_check(uint16_t nPrinterModel, uint16_t actualPrinterModel) { if (oCheckModel == ClCheckModel::_None) return; - if (nPrinterModel == nPrinterType) + if (nPrinterModel == actualPrinterModel) return; // SERIAL_ECHO_START; // SERIAL_ECHOLNPGM("Printer model differs from the G-code ..."); // SERIAL_ECHOPGM("actual : "); - // SERIAL_ECHOLN(nPrinterType); + // SERIAL_ECHOLN(actualPrinterModel); // SERIAL_ECHOPGM("expected: "); // SERIAL_ECHOLN(nPrinterModel); switch (oCheckModel) { @@ -470,16 +470,16 @@ if(!pStrEnd) return pStrBegin; } -void printer_smodel_check(const char *pStrPos) { +void printer_smodel_check(const char *pStrPos, const char *actualPrinterSModel) { char* pResult; size_t nLength,nPrinterNameLength; -nPrinterNameLength = strlen_P(sPrinterName); +nPrinterNameLength = strlen_P(actualPrinterSModel); pResult=code_string(pStrPos,&nLength); if(pResult != NULL && nLength == nPrinterNameLength) { // Only compare them if the lengths match - if (strncmp_P(pResult, sPrinterName, nLength) == 0) return; + if (strncmp_P(pResult, actualPrinterSModel, nLength) == 0) return; } switch(oCheckModel) @@ -501,13 +501,21 @@ lcd_update_enable(true); // display / status-line recovery } } -void fSetMmuMode(bool bMMu) { +uint16_t nPrinterType(bool bMMu) { if (bMMu) { - nPrinterType = pgm_read_word(&_nPrinterMmuType); - sPrinterName = _sPrinterMmuName; - } else { - nPrinterType = pgm_read_word(&_nPrinterType); - sPrinterName = _sPrinterName; + return pgm_read_word(&_nPrinterMmuType); + } + else { + return pgm_read_word(&_nPrinterType); + } +} + +const char *sPrinterType(bool bMMu) { + if (bMMu) { + return _sPrinterMmuName; + } + else { + return _sPrinterName; } } diff --git a/Firmware/util.h b/Firmware/util.h index fade140fb..a630203e1 100644 --- a/Firmware/util.h +++ b/Firmware/util.h @@ -87,12 +87,13 @@ extern ClCheckGcode oCheckGcode; void fCheckModeInit(); void nozzle_diameter_check(uint16_t nDiameter); -void printer_model_check(uint16_t nPrinterModel); -void printer_smodel_check(const char* pStrPos); +void printer_model_check(uint16_t nPrinterModel, uint16_t actualPrinterModel); +void printer_smodel_check(const char *pStrPos, const char *actualPrinterSModel); void fw_version_check(const char *pVersion); void gcode_level_check(uint16_t nGcodeLevel); -void fSetMmuMode(bool bMMu); +uint16_t nPrinterType(bool bMMu); +const char *sPrinterType(bool bMMu); #define IP4_STR_SIZE 16 extern void ip4_to_str(char* dest, uint8_t* IP);