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
   // HAS_TRINAMIC
220
   // HAS_TRINAMIC
221
   //
221
   //
222
   uint16_t tmc_stepper_current[11];                     // M906 X Y Z X2 Y2 Z2 E0 E1 E2 E3 E4
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
   // LIN_ADVANCE
226
   // LIN_ADVANCE
721
     //
721
     //
722
     // TMC2130 Sensorless homing threshold
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
       #else
741
       #else
741
-        thrs = 0;
742
+        0
742
       #endif
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
     // Linear Advance
748
     // Linear Advance
762
     _FIELD_TEST(motor_current_setting);
760
     _FIELD_TEST(motor_current_setting);
763
 
761
 
764
     #if HAS_MOTOR_CURRENT_PWM
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
     #else
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
     #endif
767
     #endif
770
 
768
 
771
     //
769
     //
793
       EEPROM_WRITE(planner.yz_skew_factor);
791
       EEPROM_WRITE(planner.yz_skew_factor);
794
     #else
792
     #else
795
       dummy = 0.0f;
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
     #endif
795
     #endif
798
 
796
 
799
     //
797
     //
1254
        * TMC2130 Sensorless homing threshold.
1252
        * TMC2130 Sensorless homing threshold.
1255
        * X and X2 use the same value
1253
        * X and X2 use the same value
1256
        * Y and Y2 use the same value
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
       #if ENABLED(SENSORLESS_HOMING)
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
             #if ENABLED(X_IS_TMC2130)
1262
             #if ENABLED(X_IS_TMC2130)
1264
-              stepperX.sgt(thrs);
1263
+              stepperX.sgt(thrs[0]);
1265
             #endif
1264
             #endif
1266
             #if ENABLED(X2_IS_TMC2130)
1265
             #if ENABLED(X2_IS_TMC2130)
1267
-              stepperX2.sgt(thrs);
1266
+              stepperX2.sgt(thrs[0]);
1268
             #endif
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
             #if ENABLED(Y_IS_TMC2130)
1270
             #if ENABLED(Y_IS_TMC2130)
1275
-              stepperY.sgt(thrs);
1271
+              stepperY.sgt(thrs[1]);
1276
             #endif
1272
             #endif
1277
             #if ENABLED(Y2_IS_TMC2130)
1273
             #if ENABLED(Y2_IS_TMC2130)
1278
-              stepperY2.sgt(thrs);
1274
+              stepperY2.sgt(thrs[1]);
1279
             #endif
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
             #if ENABLED(Z_IS_TMC2130)
1278
             #if ENABLED(Z_IS_TMC2130)
1286
-              stepperZ.sgt(thrs);
1279
+              stepperZ.sgt(thrs[2]);
1287
             #endif
1280
             #endif
1288
             #if ENABLED(Z2_IS_TMC2130)
1281
             #if ENABLED(Z2_IS_TMC2130)
1289
-              stepperZ2.sgt(thrs);
1282
+              stepperZ2.sgt(thrs[2]);
1290
             #endif
1283
             #endif
1291
-          }
1292
-        #endif
1293
-      #else
1294
-        for (uint8_t q = 0; q < 3; q++) EEPROM_READ(thrs);
1284
+          #endif
1285
+        }
1295
       #endif
1286
       #endif
1296
 
1287
 
1297
       //
1288
       //
1313
       _FIELD_TEST(motor_current_setting);
1304
       _FIELD_TEST(motor_current_setting);
1314
 
1305
 
1315
       #if HAS_MOTOR_CURRENT_PWM
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
       #else
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
       #endif
1311
       #endif
1321
 
1312
 
1322
       //
1313
       //
1348
           EEPROM_READ(dummy);
1339
           EEPROM_READ(dummy);
1349
         #endif
1340
         #endif
1350
       #else
1341
       #else
1351
-        for (uint8_t q = 3; q--;) EEPROM_READ(dummy);
1342
+        for (uint8_t q = XYZ; q--;) EEPROM_READ(dummy);
1352
       #endif
1343
       #endif
1353
 
1344
 
1354
       //
1345
       //
1831
   #endif
1822
   #endif
1832
 
1823
 
1833
   #if HAS_MOTOR_CURRENT_PWM
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
       stepper.digipot_current(q, (stepper.motor_current_setting[q] = tmp_motor_current_setting[q]));
1827
       stepper.digipot_current(q, (stepper.motor_current_setting[q] = tmp_motor_current_setting[q]));
1837
   #endif
1828
   #endif
1838
 
1829
 

Loading…
Cancel
Save