Simplify firmware/gcode version comparisons

Fix cherry-pick issue
This commit is contained in:
Yuri D'Elia 2022-12-07 18:59:29 +01:00 committed by 3d-gussner
parent 49506b5348
commit a6eff8f8a5
1 changed files with 34 additions and 37 deletions

View File

@ -378,20 +378,19 @@ return((uint8_t)ClCompareValue::_Equal);
} }
void fw_version_check(const char *pVersion) { void fw_version_check(const char *pVersion) {
uint16_t aVersion[4];
uint8_t nCompareValueResult;
if (oCheckVersion == ClCheckVersion::_None) if (oCheckVersion == ClCheckVersion::_None)
return; return;
uint16_t aVersion[4];
uint8_t nCompareValueResult;
parse_version(pVersion, aVersion); parse_version(pVersion, aVersion);
nCompareValueResult = mCompareValue(aVersion[0], eeprom_read_word((uint16_t *)EEPROM_FIRMWARE_VERSION_MAJOR)) << 6; nCompareValueResult = mCompareValue(aVersion[0], eeprom_read_word((uint16_t *)EEPROM_FIRMWARE_VERSION_MAJOR)) << 6;
nCompareValueResult += mCompareValue(aVersion[1], eeprom_read_word((uint16_t *)EEPROM_FIRMWARE_VERSION_MINOR)) << 4; nCompareValueResult += mCompareValue(aVersion[1], eeprom_read_word((uint16_t *)EEPROM_FIRMWARE_VERSION_MINOR)) << 4;
nCompareValueResult += mCompareValue(aVersion[2], eeprom_read_word((uint16_t *)EEPROM_FIRMWARE_VERSION_REVISION)) << 2; nCompareValueResult += mCompareValue(aVersion[2], eeprom_read_word((uint16_t *)EEPROM_FIRMWARE_VERSION_REVISION)) << 2;
nCompareValueResult += mCompareValue(aVersion[3], eeprom_read_word((uint16_t *)EEPROM_FIRMWARE_VERSION_FLAVOR)); nCompareValueResult += mCompareValue(aVersion[3], eeprom_read_word((uint16_t *)EEPROM_FIRMWARE_VERSION_FLAVOR));
if (nCompareValueResult == COMPARE_VALUE_EQUAL) if (nCompareValueResult <= COMPARE_VALUE_EQUAL)
return;
if ((nCompareValueResult < COMPARE_VALUE_EQUAL) && (oCheckVersion == ClCheckVersion::_Warn || oCheckVersion == ClCheckVersion::_Strict))
return; return;
/* /*
SERIAL_ECHO_START; SERIAL_ECHO_START;
SERIAL_ECHOLNPGM("Printer FW version differs from the G-code ..."); SERIAL_ECHOLNPGM("Printer FW version differs from the G-code ...");
@ -431,31 +430,29 @@ void fw_version_check(const char *pVersion) {
} }
} }
void gcode_level_check(uint16_t nGcodeLevel) void gcode_level_check(uint16_t nGcodeLevel) {
{ if (oCheckGcode == ClCheckGcode::_None)
if(oCheckGcode==ClCheckGcode::_None)
return; return;
if(nGcodeLevel==(uint16_t)GCODE_LEVEL) if (nGcodeLevel <= (uint16_t)GCODE_LEVEL)
return; return;
if((nGcodeLevel<(uint16_t)GCODE_LEVEL)&&(oCheckGcode==ClCheckGcode::_Warn))
return; // SERIAL_ECHO_START;
//SERIAL_ECHO_START; // SERIAL_ECHOLNPGM("Printer G-code level differs from the G-code ...");
//SERIAL_ECHOLNPGM("Printer G-code level differs from the G-code ..."); // SERIAL_ECHOPGM("actual : ");
//SERIAL_ECHOPGM("actual : "); // SERIAL_ECHOLN(GCODE_LEVEL);
//SERIAL_ECHOLN(GCODE_LEVEL); // SERIAL_ECHOPGM("expected: ");
//SERIAL_ECHOPGM("expected: "); // SERIAL_ECHOLN(nGcodeLevel);
//SERIAL_ECHOLN(nGcodeLevel); switch (oCheckGcode) {
switch(oCheckGcode)
{
case ClCheckGcode::_Warn: case ClCheckGcode::_Warn:
// lcd_show_fullscreen_message_and_wait_P(_i("Printer G-code level differs from the G-code. Continue?")); // lcd_show_fullscreen_message_and_wait_P(_i("Printer G-code level differs from the G-code. Continue?"));
lcd_display_message_fullscreen_P(_i("G-code sliced for a different level. Continue?"));////MSG_GCODE_DIFF_CONTINUE c=20 r=4 lcd_display_message_fullscreen_P(_i("G-code sliced for a different level. Continue?")); ////MSG_GCODE_DIFF_CONTINUE c=20 r=4
lcd_wait_for_click_delay(MSG_PRINT_CHECKING_FAILED_TIMEOUT); lcd_wait_for_click_delay(MSG_PRINT_CHECKING_FAILED_TIMEOUT);
//???custom_message_type=CUSTOM_MSG_TYPE_STATUS; // display / status-line recovery //???custom_message_type=CUSTOM_MSG_TYPE_STATUS; // display / status-line recovery
lcd_update_enable(true); // display / status-line recovery lcd_update_enable(true); // display / status-line recovery
break; break;
case ClCheckGcode::_Strict: case ClCheckGcode::_Strict:
lcd_show_fullscreen_message_and_wait_P(_i("G-code sliced for a different level. Please re-slice the model again. Print cancelled."));////MSG_GCODE_DIFF_CANCELLED c=20 r=7 lcd_show_fullscreen_message_and_wait_P(
_i("G-code sliced for a different level. Please re-slice the model again. Print cancelled.")); ////MSG_GCODE_DIFF_CANCELLED c=20 r=7
lcd_print_stop(); lcd_print_stop();
break; break;
case ClCheckGcode::_None: case ClCheckGcode::_None: