Browse Source

Minor EEPROM cleanup

Scott Lahteine 4 years ago
parent
commit
5e28b0f471
1 changed files with 49 additions and 52 deletions
  1. 49
    52
      Marlin/src/module/configuration_store.cpp

+ 49
- 52
Marlin/src/module/configuration_store.cpp View File

@@ -525,7 +525,7 @@ void MarlinSettings::postprocess() {
525 525
    * M500 - Store Configuration
526 526
    */
527 527
   bool MarlinSettings::save() {
528
-    float dummy = 0;
528
+    float dummyf = 0;
529 529
     char ver[4] = "ERR";
530 530
 
531 531
     uint16_t working_crc = 0;
@@ -556,8 +556,8 @@ void MarlinSettings::postprocess() {
556 556
       #if HAS_CLASSIC_JERK
557 557
         EEPROM_WRITE(planner.max_jerk);
558 558
         #if HAS_LINEAR_E_JERK
559
-          dummy = float(DEFAULT_EJERK);
560
-          EEPROM_WRITE(dummy);
559
+          dummyf = float(DEFAULT_EJERK);
560
+          EEPROM_WRITE(dummyf);
561 561
         #endif
562 562
       #else
563 563
         const xyze_pos_t planner_max_jerk = { 10, 10, 0.4, float(DEFAULT_EJERK) };
@@ -567,8 +567,8 @@ void MarlinSettings::postprocess() {
567 567
       #if DISABLED(CLASSIC_JERK)
568 568
         EEPROM_WRITE(planner.junction_deviation_mm);
569 569
       #else
570
-        dummy = 0.02f;
571
-        EEPROM_WRITE(dummy);
570
+        dummyf = 0.02f;
571
+        EEPROM_WRITE(dummyf);
572 572
       #endif
573 573
     }
574 574
 
@@ -643,12 +643,12 @@ void MarlinSettings::postprocess() {
643 643
         EEPROM_WRITE(mesh_num_y);
644 644
         EEPROM_WRITE(mbl.z_values);
645 645
       #else // For disabled MBL write a default mesh
646
-        dummy = 0;
646
+        dummyf = 0;
647 647
         const uint8_t mesh_num_x = 3, mesh_num_y = 3;
648
-        EEPROM_WRITE(dummy); // z_offset
648
+        EEPROM_WRITE(dummyf); // z_offset
649 649
         EEPROM_WRITE(mesh_num_x);
650 650
         EEPROM_WRITE(mesh_num_y);
651
-        for (uint8_t q = mesh_num_x * mesh_num_y; q--;) EEPROM_WRITE(dummy);
651
+        for (uint8_t q = mesh_num_x * mesh_num_y; q--;) EEPROM_WRITE(dummyf);
652 652
       #endif
653 653
     }
654 654
 
@@ -672,8 +672,8 @@ void MarlinSettings::postprocess() {
672 672
       #if ABL_PLANAR
673 673
         EEPROM_WRITE(planner.bed_level_matrix);
674 674
       #else
675
-        dummy = 0;
676
-        for (uint8_t q = 9; q--;) EEPROM_WRITE(dummy);
675
+        dummyf = 0;
676
+        for (uint8_t q = 9; q--;) EEPROM_WRITE(dummyf);
677 677
       #endif
678 678
     }
679 679
 
@@ -697,12 +697,12 @@ void MarlinSettings::postprocess() {
697 697
         // For disabled Bilinear Grid write an empty 3x3 grid
698 698
         const uint8_t grid_max_x = 3, grid_max_y = 3;
699 699
         const xy_pos_t bilinear_start{0}, bilinear_grid_spacing{0};
700
-        dummy = 0;
700
+        dummyf = 0;
701 701
         EEPROM_WRITE(grid_max_x);
702 702
         EEPROM_WRITE(grid_max_y);
703 703
         EEPROM_WRITE(bilinear_grid_spacing);
704 704
         EEPROM_WRITE(bilinear_start);
705
-        for (uint16_t q = grid_max_x * grid_max_y; q--;) EEPROM_WRITE(dummy);
705
+        for (uint16_t q = grid_max_x * grid_max_y; q--;) EEPROM_WRITE(dummyf);
706 706
       #endif
707 707
     }
708 708
 
@@ -781,35 +781,35 @@ void MarlinSettings::postprocess() {
781 781
         _FIELD_TEST(x2_endstop_adj);
782 782
 
783 783
         // Write dual endstops in X, Y, Z order. Unused = 0.0
784
-        dummy = 0;
784
+        dummyf = 0;
785 785
         #if ENABLED(X_DUAL_ENDSTOPS)
786 786
           EEPROM_WRITE(endstops.x2_endstop_adj);   // 1 float
787 787
         #else
788
-          EEPROM_WRITE(dummy);
788
+          EEPROM_WRITE(dummyf);
789 789
         #endif
790 790
 
791 791
         #if ENABLED(Y_DUAL_ENDSTOPS)
792 792
           EEPROM_WRITE(endstops.y2_endstop_adj);   // 1 float
793 793
         #else
794
-          EEPROM_WRITE(dummy);
794
+          EEPROM_WRITE(dummyf);
795 795
         #endif
796 796
 
797 797
         #if ENABLED(Z_MULTI_ENDSTOPS)
798 798
           EEPROM_WRITE(endstops.z2_endstop_adj);   // 1 float
799 799
         #else
800
-          EEPROM_WRITE(dummy);
800
+          EEPROM_WRITE(dummyf);
801 801
         #endif
802 802
 
803 803
         #if ENABLED(Z_MULTI_ENDSTOPS) && NUM_Z_STEPPER_DRIVERS >= 3
804 804
           EEPROM_WRITE(endstops.z3_endstop_adj);   // 1 float
805 805
         #else
806
-          EEPROM_WRITE(dummy);
806
+          EEPROM_WRITE(dummyf);
807 807
         #endif
808 808
 
809 809
         #if ENABLED(Z_MULTI_ENDSTOPS) && NUM_Z_STEPPER_DRIVERS >= 4
810 810
           EEPROM_WRITE(endstops.z4_endstop_adj);   // 1 float
811 811
         #else
812
-          EEPROM_WRITE(dummy);
812
+          EEPROM_WRITE(dummyf);
813 813
         #endif
814 814
 
815 815
       #endif
@@ -970,9 +970,9 @@ void MarlinSettings::postprocess() {
970 970
       #else
971 971
 
972 972
         const bool volumetric_enabled = false;
973
-        dummy = DEFAULT_NOMINAL_FILAMENT_DIA;
973
+        dummyf = DEFAULT_NOMINAL_FILAMENT_DIA;
974 974
         EEPROM_WRITE(volumetric_enabled);
975
-        for (uint8_t q = EXTRUDERS; q--;) EEPROM_WRITE(dummy);
975
+        for (uint8_t q = EXTRUDERS; q--;) EEPROM_WRITE(dummyf);
976 976
 
977 977
       #endif
978 978
     }
@@ -1245,8 +1245,8 @@ void MarlinSettings::postprocess() {
1245 1245
       #if ENABLED(LIN_ADVANCE)
1246 1246
         EEPROM_WRITE(planner.extruder_advance_K);
1247 1247
       #else
1248
-        dummy = 0;
1249
-        for (uint8_t q = _MAX(EXTRUDERS, 1); q--;) EEPROM_WRITE(dummy);
1248
+        dummyf = 0;
1249
+        for (uint8_t q = _MAX(EXTRUDERS, 1); q--;) EEPROM_WRITE(dummyf);
1250 1250
       #endif
1251 1251
     }
1252 1252
 
@@ -1403,7 +1403,7 @@ void MarlinSettings::postprocess() {
1403 1403
       eeprom_error = true;
1404 1404
     }
1405 1405
     else {
1406
-      float dummy = 0;
1406
+      float dummyf = 0;
1407 1407
       working_crc = 0;  // Init to 0. Accumulated by EEPROM_READ
1408 1408
 
1409 1409
       _FIELD_TEST(esteppers);
@@ -1442,16 +1442,16 @@ void MarlinSettings::postprocess() {
1442 1442
         #if HAS_CLASSIC_JERK
1443 1443
           EEPROM_READ(planner.max_jerk);
1444 1444
           #if HAS_LINEAR_E_JERK
1445
-            EEPROM_READ(dummy);
1445
+            EEPROM_READ(dummyf);
1446 1446
           #endif
1447 1447
         #else
1448
-          for (uint8_t q = 4; q--;) EEPROM_READ(dummy);
1448
+          for (uint8_t q = 4; q--;) EEPROM_READ(dummyf);
1449 1449
         #endif
1450 1450
 
1451 1451
         #if DISABLED(CLASSIC_JERK)
1452 1452
           EEPROM_READ(planner.junction_deviation_mm);
1453 1453
         #else
1454
-          EEPROM_READ(dummy);
1454
+          EEPROM_READ(dummyf);
1455 1455
         #endif
1456 1456
       }
1457 1457
 
@@ -1508,7 +1508,7 @@ void MarlinSettings::postprocess() {
1508 1508
         #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
1509 1509
           EEPROM_READ(new_z_fade_height);
1510 1510
         #else
1511
-          EEPROM_READ(dummy);
1511
+          EEPROM_READ(dummyf);
1512 1512
         #endif
1513 1513
       }
1514 1514
 
@@ -1517,12 +1517,12 @@ void MarlinSettings::postprocess() {
1517 1517
       //
1518 1518
       {
1519 1519
         uint8_t mesh_num_x, mesh_num_y;
1520
-        EEPROM_READ(dummy);
1520
+        EEPROM_READ(dummyf);
1521 1521
         EEPROM_READ_ALWAYS(mesh_num_x);
1522 1522
         EEPROM_READ_ALWAYS(mesh_num_y);
1523 1523
 
1524 1524
         #if ENABLED(MESH_BED_LEVELING)
1525
-          if (!validating) mbl.z_offset = dummy;
1525
+          if (!validating) mbl.z_offset = dummyf;
1526 1526
           if (mesh_num_x == GRID_MAX_POINTS_X && mesh_num_y == GRID_MAX_POINTS_Y) {
1527 1527
             // EEPROM data fits the current mesh
1528 1528
             EEPROM_READ(mbl.z_values);
@@ -1530,11 +1530,11 @@ void MarlinSettings::postprocess() {
1530 1530
           else {
1531 1531
             // EEPROM data is stale
1532 1532
             if (!validating) mbl.reset();
1533
-            for (uint16_t q = mesh_num_x * mesh_num_y; q--;) EEPROM_READ(dummy);
1533
+            for (uint16_t q = mesh_num_x * mesh_num_y; q--;) EEPROM_READ(dummyf);
1534 1534
           }
1535 1535
         #else
1536 1536
           // MBL is disabled - skip the stored data
1537
-          for (uint16_t q = mesh_num_x * mesh_num_y; q--;) EEPROM_READ(dummy);
1537
+          for (uint16_t q = mesh_num_x * mesh_num_y; q--;) EEPROM_READ(dummyf);
1538 1538
         #endif // MESH_BED_LEVELING
1539 1539
       }
1540 1540
 
@@ -1558,7 +1558,7 @@ void MarlinSettings::postprocess() {
1558 1558
         #if ABL_PLANAR
1559 1559
           EEPROM_READ(planner.bed_level_matrix);
1560 1560
         #else
1561
-          for (uint8_t q = 9; q--;) EEPROM_READ(dummy);
1561
+          for (uint8_t q = 9; q--;) EEPROM_READ(dummyf);
1562 1562
         #endif
1563 1563
       }
1564 1564
 
@@ -1567,8 +1567,8 @@ void MarlinSettings::postprocess() {
1567 1567
       //
1568 1568
       {
1569 1569
         uint8_t grid_max_x, grid_max_y;
1570
-        EEPROM_READ_ALWAYS(grid_max_x);                       // 1 byte
1571
-        EEPROM_READ_ALWAYS(grid_max_y);                       // 1 byte
1570
+        EEPROM_READ_ALWAYS(grid_max_x);                // 1 byte
1571
+        EEPROM_READ_ALWAYS(grid_max_y);                // 1 byte
1572 1572
         #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
1573 1573
           if (grid_max_x == GRID_MAX_POINTS_X && grid_max_y == GRID_MAX_POINTS_Y) {
1574 1574
             if (!validating) set_bed_leveling_enabled(false);
@@ -1583,7 +1583,7 @@ void MarlinSettings::postprocess() {
1583 1583
             xy_pos_t bgs, bs;
1584 1584
             EEPROM_READ(bgs);
1585 1585
             EEPROM_READ(bs);
1586
-            for (uint16_t q = grid_max_x * grid_max_y; q--;) EEPROM_READ(dummy);
1586
+            for (uint16_t q = grid_max_x * grid_max_y; q--;) EEPROM_READ(dummyf);
1587 1587
           }
1588 1588
       }
1589 1589
 
@@ -1592,16 +1592,15 @@ void MarlinSettings::postprocess() {
1592 1592
       //
1593 1593
       {
1594 1594
         _FIELD_TEST(planner_leveling_active);
1595
-
1596 1595
         #if ENABLED(AUTO_BED_LEVELING_UBL)
1597
-          EEPROM_READ(planner.leveling_active);
1598
-          EEPROM_READ(ubl.storage_slot);
1596
+          bool &planner_leveling_active = planner.leveling_active;
1597
+          uint8_t &ubl_storage_slot = ubl.storage_slot;
1599 1598
         #else
1600 1599
           bool planner_leveling_active;
1601 1600
           uint8_t ubl_storage_slot;
1602
-          EEPROM_READ(planner_leveling_active);
1603
-          EEPROM_READ(ubl_storage_slot);
1604 1601
         #endif
1602
+        EEPROM_READ(planner_leveling_active);
1603
+        EEPROM_READ(ubl_storage_slot);
1605 1604
       }
1606 1605
 
1607 1606
       //
@@ -1609,7 +1608,6 @@ void MarlinSettings::postprocess() {
1609 1608
       //
1610 1609
       {
1611 1610
         _FIELD_TEST(servo_angles);
1612
-
1613 1611
         #if ENABLED(EDITABLE_SERVO_ANGLES)
1614 1612
           uint16_t (&servo_angles_arr)[EEPROM_NUM_SERVOS][2] = servo_angles;
1615 1613
         #else
@@ -1638,7 +1636,7 @@ void MarlinSettings::postprocess() {
1638 1636
       {
1639 1637
         _FIELD_TEST(bltouch_last_written_mode);
1640 1638
         #if ENABLED(BLTOUCH)
1641
-          const bool &bltouch_last_written_mode = bltouch.last_written_mode;
1639
+          bool &bltouch_last_written_mode = bltouch.last_written_mode;
1642 1640
         #else
1643 1641
           bool bltouch_last_written_mode;
1644 1642
         #endif
@@ -1667,27 +1665,27 @@ void MarlinSettings::postprocess() {
1667 1665
           #if ENABLED(X_DUAL_ENDSTOPS)
1668 1666
             EEPROM_READ(endstops.x2_endstop_adj);  // 1 float
1669 1667
           #else
1670
-            EEPROM_READ(dummy);
1668
+            EEPROM_READ(dummyf);
1671 1669
           #endif
1672 1670
           #if ENABLED(Y_DUAL_ENDSTOPS)
1673 1671
             EEPROM_READ(endstops.y2_endstop_adj);  // 1 float
1674 1672
           #else
1675
-            EEPROM_READ(dummy);
1673
+            EEPROM_READ(dummyf);
1676 1674
           #endif
1677 1675
           #if ENABLED(Z_MULTI_ENDSTOPS)
1678 1676
             EEPROM_READ(endstops.z2_endstop_adj); // 1 float
1679 1677
           #else
1680
-            EEPROM_READ(dummy);
1678
+            EEPROM_READ(dummyf);
1681 1679
           #endif
1682 1680
           #if ENABLED(Z_MULTI_ENDSTOPS) && NUM_Z_STEPPER_DRIVERS >= 3
1683 1681
             EEPROM_READ(endstops.z3_endstop_adj); // 1 float
1684 1682
           #else
1685
-            EEPROM_READ(dummy);
1683
+            EEPROM_READ(dummyf);
1686 1684
           #endif
1687 1685
           #if ENABLED(Z_MULTI_ENDSTOPS) && NUM_Z_STEPPER_DRIVERS >= 4
1688 1686
             EEPROM_READ(endstops.z4_endstop_adj); // 1 float
1689 1687
           #else
1690
-            EEPROM_READ(dummy);
1688
+            EEPROM_READ(dummyf);
1691 1689
           #endif
1692 1690
 
1693 1691
         #endif
@@ -1749,11 +1747,11 @@ void MarlinSettings::postprocess() {
1749 1747
       {
1750 1748
         _FIELD_TEST(lpq_len);
1751 1749
         #if ENABLED(PID_EXTRUSION_SCALING)
1752
-          EEPROM_READ(thermalManager.lpq_len);
1750
+          int16_t &lpq_len = thermalManager.lpq_len;
1753 1751
         #else
1754 1752
           int16_t lpq_len;
1755
-          EEPROM_READ(lpq_len);
1756 1753
         #endif
1754
+        EEPROM_READ(lpq_len);
1757 1755
       }
1758 1756
 
1759 1757
       //
@@ -1800,13 +1798,12 @@ void MarlinSettings::postprocess() {
1800 1798
       //
1801 1799
       {
1802 1800
         _FIELD_TEST(recovery_enabled);
1803
-
1804 1801
         #if ENABLED(POWER_LOSS_RECOVERY)
1805
-          EEPROM_READ(recovery.enabled);
1802
+          bool &recovery_enabled = recovery.enabled;
1806 1803
         #else
1807 1804
           bool recovery_enabled;
1808
-          EEPROM_READ(recovery_enabled);
1809 1805
         #endif
1806
+        EEPROM_READ(recovery_enabled);
1810 1807
       }
1811 1808
 
1812 1809
       //

Loading…
Cancel
Save