Forráskód Böngészése

Read version data from progmem in eeprom_fw_version_older_than

Yuri D'Elia 1 éve
szülő
commit
2a1511f7b1
3 módosított fájl, 7 hozzáadás és 6 törlés
  1. 2 1
      Firmware/Marlin_main.cpp
  2. 4 4
      Firmware/util.cpp
  3. 1 1
      Firmware/util.h

+ 2 - 1
Firmware/Marlin_main.cpp

@@ -1529,7 +1529,8 @@ void setup()
           // calibrated printer upgraded from FW<3.12
           calibration_status |= (CALIBRATION_STATUS_SELFTEST | CALIBRATION_STATUS_XYZ | CALIBRATION_STATUS_Z | CALIBRATION_STATUS_LIVE_ADJUST);
 
-          if (eeprom_fw_version_older_than({3, 2, 0, 4})) {
+          static const uint16_t v3_2_0_4[] PROGMEM = {3, 2, 0, 4};
+          if (eeprom_fw_version_older_than_p(v3_2_0_4)) {
               // printer upgraded from FW<3.2.0.4 and requires re-running selftest
               lcd_show_fullscreen_message_and_wait_P(_i("Selftest will be run to calibrate accurate sensorless rehoming."));////MSG_FORCE_SELFTEST c=20 r=8
               calibration_status &= ~CALIBRATION_STATUS_SELFTEST;

+ 4 - 4
Firmware/util.cpp

@@ -181,19 +181,19 @@ inline int8_t is_provided_version_newer(const char *version_string)
     return 0;
 }
 
-bool eeprom_fw_version_older_than(const uint16_t (&ver_req)[4])
+bool eeprom_fw_version_older_than_p(const uint16_t (&ver_req)[4])
 {
     uint16_t ver_eeprom[4];
-
     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_req[i] > ver_eeprom[i])
+        uint16_t v = pgm_read_word(&ver_req[i]);
+        if (v > ver_eeprom[i])
             return true;
-        else if (ver_req[i] < ver_eeprom[i])
+        else if (v < ver_eeprom[i])
             break;
     }
 

+ 1 - 1
Firmware/util.h

@@ -17,7 +17,7 @@ enum FirmwareRevisionFlavorType : uint16_t {
 };
 
 bool show_upgrade_dialog_if_version_newer(const char *version_string);
-bool eeprom_fw_version_older_than(const uint16_t (&req_ver)[4]);
+bool eeprom_fw_version_older_than_p(const uint16_t (&req_ver)[4]);
 void update_current_firmware_version_to_eeprom();