Simplify firmware/gcode version comparisons

This commit is contained in:
Yuri D'Elia 2022-12-07 18:59:29 +01:00
parent 6f5a67491c
commit 0cedb92ac6
1 changed files with 7 additions and 9 deletions

View File

@ -366,20 +366,19 @@ uint8_t mCompareValue(uint16_t nX, uint16_t nY) {
}
void fw_version_check(const char *pVersion) {
uint16_t aVersion[4];
uint8_t nCompareValueResult;
if (oCheckVersion == ClCheckVersion::_None)
return;
uint16_t aVersion[4];
uint8_t nCompareValueResult;
parse_version(pVersion, aVersion);
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[2], eeprom_read_word((uint16_t *)EEPROM_FIRMWARE_VERSION_REVISION)) << 2;
nCompareValueResult += mCompareValue(aVersion[3], eeprom_read_word((uint16_t *)EEPROM_FIRMWARE_VERSION_FLAVOR));
if (nCompareValueResult == COMPARE_VALUE_EQUAL)
return;
if ((nCompareValueResult < COMPARE_VALUE_EQUAL) && (oCheckVersion == ClCheckVersion::_Warn || oCheckVersion == ClCheckVersion::_Strict))
if (nCompareValueResult <= COMPARE_VALUE_EQUAL)
return;
/*
SERIAL_ECHO_START;
SERIAL_ECHOLNPGM("Printer FW version differs from the G-code ...");
@ -422,10 +421,9 @@ void fw_version_check(const char *pVersion) {
void gcode_level_check(uint16_t nGcodeLevel) {
if (oCheckGcode == ClCheckGcode::_None)
return;
if (nGcodeLevel == (uint16_t)GCODE_LEVEL)
return;
if ((nGcodeLevel < (uint16_t)GCODE_LEVEL) && (oCheckGcode == ClCheckGcode::_Warn))
if (nGcodeLevel <= (uint16_t)GCODE_LEVEL)
return;
// SERIAL_ECHO_START;
// SERIAL_ECHOLNPGM("Printer G-code level differs from the G-code ...");
// SERIAL_ECHOPGM("actual : ");