Browse Source

EEPROM parity with 1.1.x

Scott Lahteine 7 years ago
parent
commit
8d5a77001e
1 changed files with 48 additions and 57 deletions
  1. 48
    57
      Marlin/src/module/configuration_store.cpp

+ 48
- 57
Marlin/src/module/configuration_store.cpp View File

@@ -220,7 +220,7 @@ typedef struct SettingsDataStruct {
220 220
   // HAS_TRINAMIC
221 221
   //
222 222
   uint16_t tmc_stepper_current[11];                     // M906 X Y Z X2 Y2 Z2 E0 E1 E2 E3 E4
223
-  int16_t tmc_sgt[3];                                   // M914 X Y Z
223
+  int16_t tmc_sgt[XYZ];                                 // M914 X Y Z
224 224
 
225 225
   //
226 226
   // LIN_ADVANCE
@@ -721,30 +721,28 @@ void MarlinSettings::postprocess() {
721 721
     //
722 722
     // TMC2130 Sensorless homing threshold
723 723
     //
724
-    int16_t thrs;
725
-    #if ENABLED(SENSORLESS_HOMING)
726
-      #if ENABLED(X_IS_TMC2130) && defined(X_HOMING_SENSITIVITY)
727
-        thrs = stepperX.sgt();
728
-      #else
729
-        thrs = 0;
730
-      #endif
731
-      EEPROM_WRITE(thrs);
732
-      #if ENABLED(Y_IS_TMC2130) && defined(Y_HOMING_SENSITIVITY)
733
-        thrs = stepperY.sgt();
734
-      #else
735
-        thrs = 0;
736
-      #endif
737
-      EEPROM_WRITE(thrs);
738
-      #if ENABLED(Z_IS_TMC2130) && defined(Z_HOMING_SENSITIVITY)
739
-        thrs = stepperZ.sgt();
724
+    int16_t thrs[XYZ] = {
725
+      #if ENABLED(SENSORLESS_HOMING)
726
+        #if ENABLED(X_IS_TMC2130) && defined(X_HOMING_SENSITIVITY)
727
+          stepperX.sgt(),
728
+        #else
729
+          0,
730
+        #endif
731
+        #if ENABLED(Y_IS_TMC2130) && defined(Y_HOMING_SENSITIVITY)
732
+          stepperY.sgt(),
733
+        #else
734
+          0
735
+        #endif
736
+        #if ENABLED(Z_IS_TMC2130) && defined(Z_HOMING_SENSITIVITY)
737
+          stepperZ.sgt()
738
+        #else
739
+          0
740
+        #endif
740 741
       #else
741
-        thrs = 0;
742
+        0
742 743
       #endif
743
-      EEPROM_WRITE(thrs);
744
-    #else
745
-      thrs = 0;
746
-      for (uint8_t q = 3; q--;) EEPROM_WRITE(thrs);
747
-    #endif
744
+    };
745
+    EEPROM_WRITE(thrs);
748 746
 
749 747
     //
750 748
     // Linear Advance
@@ -762,10 +760,10 @@ void MarlinSettings::postprocess() {
762 760
     _FIELD_TEST(motor_current_setting);
763 761
 
764 762
     #if HAS_MOTOR_CURRENT_PWM
765
-      for (uint8_t q = 3; q--;) EEPROM_WRITE(stepper.motor_current_setting[q]);
763
+      for (uint8_t q = XYZ; q--;) EEPROM_WRITE(stepper.motor_current_setting[q]);
766 764
     #else
767
-      const uint32_t dummyui32 = 0;
768
-      for (uint8_t q = 3; q--;) EEPROM_WRITE(dummyui32);
765
+      const uint32_t dummyui32[XYZ] = { 0 };
766
+      EEPROM_WRITE(dummyui32);
769 767
     #endif
770 768
 
771 769
     //
@@ -793,7 +791,7 @@ void MarlinSettings::postprocess() {
793 791
       EEPROM_WRITE(planner.yz_skew_factor);
794 792
     #else
795 793
       dummy = 0.0f;
796
-      for (uint8_t q = 3; q--;) EEPROM_WRITE(dummy);
794
+      for (uint8_t q = XYZ; q--;) EEPROM_WRITE(dummy);
797 795
     #endif
798 796
 
799 797
     //
@@ -1254,44 +1252,37 @@ void MarlinSettings::postprocess() {
1254 1252
        * TMC2130 Sensorless homing threshold.
1255 1253
        * X and X2 use the same value
1256 1254
        * Y and Y2 use the same value
1255
+       * Z and Z2 use the same value
1257 1256
        */
1258
-      int16_t thrs;
1257
+      int16_t thrs[XYZ];
1258
+      EEPROM_READ(thrs);
1259 1259
       #if ENABLED(SENSORLESS_HOMING)
1260
-        EEPROM_READ(thrs);
1261
-        #ifdef X_HOMING_SENSITIVITY
1262
-          if (!validating) {
1260
+        if (!validating) {
1261
+          #ifdef X_HOMING_SENSITIVITY
1263 1262
             #if ENABLED(X_IS_TMC2130)
1264
-              stepperX.sgt(thrs);
1263
+              stepperX.sgt(thrs[0]);
1265 1264
             #endif
1266 1265
             #if ENABLED(X2_IS_TMC2130)
1267
-              stepperX2.sgt(thrs);
1266
+              stepperX2.sgt(thrs[0]);
1268 1267
             #endif
1269
-          }
1270
-        #endif
1271
-        EEPROM_READ(thrs);
1272
-        #ifdef Y_HOMING_SENSITIVITY
1273
-          if (!validating) {
1268
+          #endif
1269
+          #ifdef Y_HOMING_SENSITIVITY
1274 1270
             #if ENABLED(Y_IS_TMC2130)
1275
-              stepperY.sgt(thrs);
1271
+              stepperY.sgt(thrs[1]);
1276 1272
             #endif
1277 1273
             #if ENABLED(Y2_IS_TMC2130)
1278
-              stepperY2.sgt(thrs);
1274
+              stepperY2.sgt(thrs[1]);
1279 1275
             #endif
1280
-          }
1281
-        #endif
1282
-        EEPROM_READ(thrs);
1283
-        #ifdef Z_HOMING_SENSITIVITY
1284
-          if (!validating) {
1276
+          #endif
1277
+          #ifdef Z_HOMING_SENSITIVITY
1285 1278
             #if ENABLED(Z_IS_TMC2130)
1286
-              stepperZ.sgt(thrs);
1279
+              stepperZ.sgt(thrs[2]);
1287 1280
             #endif
1288 1281
             #if ENABLED(Z2_IS_TMC2130)
1289
-              stepperZ2.sgt(thrs);
1282
+              stepperZ2.sgt(thrs[2]);
1290 1283
             #endif
1291
-          }
1292
-        #endif
1293
-      #else
1294
-        for (uint8_t q = 0; q < 3; q++) EEPROM_READ(thrs);
1284
+          #endif
1285
+        }
1295 1286
       #endif
1296 1287
 
1297 1288
       //
@@ -1313,10 +1304,10 @@ void MarlinSettings::postprocess() {
1313 1304
       _FIELD_TEST(motor_current_setting);
1314 1305
 
1315 1306
       #if HAS_MOTOR_CURRENT_PWM
1316
-        for (uint8_t q = 3; q--;) EEPROM_READ(stepper.motor_current_setting[q]);
1307
+        for (uint8_t q = XYZ; q--;) EEPROM_READ(stepper.motor_current_setting[q]);
1317 1308
       #else
1318
-        uint32_t dummyui32;
1319
-        for (uint8_t q = 3; q--;) EEPROM_READ(dummyui32);
1309
+        uint32_t dummyui32[XYZ];
1310
+        EEPROM_READ(dummyui32);
1320 1311
       #endif
1321 1312
 
1322 1313
       //
@@ -1348,7 +1339,7 @@ void MarlinSettings::postprocess() {
1348 1339
           EEPROM_READ(dummy);
1349 1340
         #endif
1350 1341
       #else
1351
-        for (uint8_t q = 3; q--;) EEPROM_READ(dummy);
1342
+        for (uint8_t q = XYZ; q--;) EEPROM_READ(dummy);
1352 1343
       #endif
1353 1344
 
1354 1345
       //
@@ -1831,8 +1822,8 @@ void MarlinSettings::reset(
1831 1822
   #endif
1832 1823
 
1833 1824
   #if HAS_MOTOR_CURRENT_PWM
1834
-    uint32_t tmp_motor_current_setting[3] = PWM_MOTOR_CURRENT;
1835
-    for (uint8_t q = 3; q--;)
1825
+    uint32_t tmp_motor_current_setting[XYZ] = PWM_MOTOR_CURRENT;
1826
+    for (uint8_t q = XYZ; q--;)
1836 1827
       stepper.digipot_current(q, (stepper.motor_current_setting[q] = tmp_motor_current_setting[q]));
1837 1828
   #endif
1838 1829
 

Loading…
Cancel
Save