Browse Source

Prettify some EEPROM code

Scott Lahteine 7 years ago
parent
commit
c07bbd4154
1 changed files with 61 additions and 6 deletions
  1. 61
    6
      Marlin/src/module/configuration_store.cpp

+ 61
- 6
Marlin/src/module/configuration_store.cpp View File

@@ -292,7 +292,7 @@ void MarlinSettings::postprocess() {
292 292
     EEPROM_WRITE(ver);     // invalidate data first
293 293
     EEPROM_SKIP(working_crc); // Skip the checksum slot
294 294
 
295
-    working_crc = 0; // clear before first "real data"
295
+    working_crc = 0;  // Init to 0. Accumulated by EEPROM_READ
296 296
 
297 297
     const uint8_t esteppers = COUNT(planner.axis_steps_per_mm) - XYZ;
298 298
     EEPROM_WRITE(esteppers);
@@ -699,6 +699,10 @@ void MarlinSettings::postprocess() {
699 699
       uint8_t esteppers;
700 700
       EEPROM_READ(esteppers);
701 701
 
702
+      //
703
+      // Planner Motion
704
+      //
705
+
702 706
       // Get only the number of E stepper parameters previously stored
703 707
       // Any steppers added later are set to their defaults
704 708
       const float def1[] = DEFAULT_AXIS_STEPS_PER_UNIT, def2[] = DEFAULT_MAX_FEEDRATE;
@@ -722,6 +726,10 @@ void MarlinSettings::postprocess() {
722 726
       EEPROM_READ(planner.min_segment_time_us);
723 727
       EEPROM_READ(planner.max_jerk);
724 728
 
729
+      //
730
+      // Home Offset (M206)
731
+      //
732
+
725 733
       #if !HAS_HOME_OFFSET
726 734
         float home_offset[XYZ];
727 735
       #endif
@@ -733,6 +741,10 @@ void MarlinSettings::postprocess() {
733 741
         home_offset[Z_AXIS] -= DELTA_HEIGHT;
734 742
       #endif
735 743
 
744
+      //
745
+      // Hotend Offsets, if any
746
+      //
747
+
736 748
       #if HOTENDS > 1
737 749
         // Skip hotend 0 which must be 0
738 750
         for (uint8_t e = 1; e < HOTENDS; e++)
@@ -816,6 +828,10 @@ void MarlinSettings::postprocess() {
816 828
           for (uint16_t q = grid_max_x * grid_max_y; q--;) EEPROM_READ(dummy);
817 829
         }
818 830
 
831
+      //
832
+      // Unified Bed Leveling active state
833
+      //
834
+
819 835
       #if ENABLED(AUTO_BED_LEVELING_UBL)
820 836
         EEPROM_READ(planner.leveling_active);
821 837
         EEPROM_READ(ubl.storage_slot);
@@ -825,6 +841,10 @@ void MarlinSettings::postprocess() {
825 841
         EEPROM_READ(dummyui8);
826 842
       #endif // AUTO_BED_LEVELING_UBL
827 843
 
844
+      //
845
+      // DELTA Geometry or Dual Endstops offsets
846
+      //
847
+
828 848
       #if ENABLED(DELTA)
829 849
         EEPROM_READ(delta_endstop_adj);         // 3 floats
830 850
         EEPROM_READ(delta_radius);              // 1 float
@@ -861,19 +881,27 @@ void MarlinSettings::postprocess() {
861 881
 
862 882
       #endif
863 883
 
884
+      //
885
+      // LCD Preheat settings
886
+      //
887
+
864 888
       #if DISABLED(ULTIPANEL)
865 889
         int lcd_preheat_hotend_temp[2], lcd_preheat_bed_temp[2], lcd_preheat_fan_speed[2];
866 890
       #endif
867 891
 
868
-      EEPROM_READ(lcd_preheat_hotend_temp);
869
-      EEPROM_READ(lcd_preheat_bed_temp);
870
-      EEPROM_READ(lcd_preheat_fan_speed);
892
+      EEPROM_READ(lcd_preheat_hotend_temp); // 2 floats
893
+      EEPROM_READ(lcd_preheat_bed_temp);    // 2 floats
894
+      EEPROM_READ(lcd_preheat_fan_speed);   // 2 floats
871 895
 
872 896
       //EEPROM_ASSERT(
873 897
       //  WITHIN(lcd_preheat_fan_speed, 0, 255),
874 898
       //  "lcd_preheat_fan_speed out of range"
875 899
       //);
876 900
 
901
+      //
902
+      // Hotend PID
903
+      //
904
+
877 905
       #if ENABLED(PIDTEMP)
878 906
         for (uint8_t e = 0; e < MAX_EXTRUDERS; e++) {
879 907
           EEPROM_READ(dummy); // Kp
@@ -897,11 +925,19 @@ void MarlinSettings::postprocess() {
897 925
         for (uint8_t q = MAX_EXTRUDERS * 4; q--;) EEPROM_READ(dummy);  // Kp, Ki, Kd, Kc
898 926
       #endif // !PIDTEMP
899 927
 
928
+      //
929
+      // PID Extrusion Scaling
930
+      //
931
+
900 932
       #if DISABLED(PID_EXTRUSION_SCALING)
901 933
         int lpq_len;
902 934
       #endif
903 935
       EEPROM_READ(lpq_len);
904 936
 
937
+      //
938
+      // Heated Bed PID
939
+      //
940
+
905 941
       #if ENABLED(PIDTEMPBED)
906 942
         EEPROM_READ(dummy); // bedKp
907 943
         if (dummy != DUMMY_PID_VALUE) {
@@ -913,11 +949,19 @@ void MarlinSettings::postprocess() {
913 949
         for (uint8_t q=3; q--;) EEPROM_READ(dummy); // bedKp, bedKi, bedKd
914 950
       #endif
915 951
 
952
+      //
953
+      // LCD Contrast
954
+      //
955
+
916 956
       #if !HAS_LCD_CONTRAST
917 957
         uint16_t lcd_contrast;
918 958
       #endif
919 959
       EEPROM_READ(lcd_contrast);
920 960
 
961
+      //
962
+      // Firmware Retraction
963
+      //
964
+
921 965
       #if ENABLED(FWRETRACT)
922 966
         EEPROM_READ(fwretract.autoretract_enabled);
923 967
         EEPROM_READ(fwretract.retract_length);
@@ -933,13 +977,20 @@ void MarlinSettings::postprocess() {
933 977
         for (uint8_t q=8; q--;) EEPROM_READ(dummy);
934 978
       #endif
935 979
 
936
-      EEPROM_READ(parser.volumetric_enabled);
980
+      //
981
+      // Volumetric & Filament Size
982
+      //
937 983
 
984
+      EEPROM_READ(parser.volumetric_enabled);
938 985
       for (uint8_t q = 0; q < MAX_EXTRUDERS; q++) {
939 986
         EEPROM_READ(dummy);
940 987
         if (q < COUNT(planner.filament_size)) planner.filament_size[q] = dummy;
941 988
       }
942 989
 
990
+      //
991
+      // TMC2130 Stepper Current
992
+      //
993
+
943 994
       uint16_t val;
944 995
       #if ENABLED(HAVE_TMC2130)
945 996
         EEPROM_READ(val);
@@ -987,7 +1038,7 @@ void MarlinSettings::postprocess() {
987 1038
           stepperE4.setCurrent(val, R_SENSE, HOLD_MULTIPLIER);
988 1039
         #endif
989 1040
       #else
990
-        for (uint8_t q = 0; q < 11; q++) EEPROM_READ(val);
1041
+        for (uint8_t q = 11; q--;) EEPROM_READ(val);
991 1042
       #endif
992 1043
 
993 1044
       //
@@ -1002,6 +1053,10 @@ void MarlinSettings::postprocess() {
1002 1053
         EEPROM_READ(dummy);
1003 1054
       #endif
1004 1055
 
1056
+      //
1057
+      // Motor Current PWM
1058
+      //
1059
+
1005 1060
       #if HAS_MOTOR_CURRENT_PWM
1006 1061
         for (uint8_t q = 3; q--;) EEPROM_READ(stepper.motor_current_setting[q]);
1007 1062
       #else

Loading…
Cancel
Save