Browse Source

Prettify some EEPROM code

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

+ 61
- 7
Marlin/configuration_store.cpp View File

723
       float dummy = 0;
723
       float dummy = 0;
724
       bool dummyb;
724
       bool dummyb;
725
 
725
 
726
-      working_crc = 0; //clear before reading first "real data"
726
+      working_crc = 0;  // Init to 0. Accumulated by EEPROM_READ
727
 
727
 
728
       // Number of esteppers may change
728
       // Number of esteppers may change
729
       uint8_t esteppers;
729
       uint8_t esteppers;
730
       EEPROM_READ(esteppers);
730
       EEPROM_READ(esteppers);
731
 
731
 
732
+      //
733
+      // Planner Motion
734
+      //
735
+
732
       // Get only the number of E stepper parameters previously stored
736
       // Get only the number of E stepper parameters previously stored
733
       // Any steppers added later are set to their defaults
737
       // Any steppers added later are set to their defaults
734
       const float def1[] = DEFAULT_AXIS_STEPS_PER_UNIT, def2[] = DEFAULT_MAX_FEEDRATE;
738
       const float def1[] = DEFAULT_AXIS_STEPS_PER_UNIT, def2[] = DEFAULT_MAX_FEEDRATE;
752
       EEPROM_READ(planner.min_segment_time_us);
756
       EEPROM_READ(planner.min_segment_time_us);
753
       EEPROM_READ(planner.max_jerk);
757
       EEPROM_READ(planner.max_jerk);
754
 
758
 
759
+      //
760
+      // Home Offset (M206)
761
+      //
762
+
755
       #if !HAS_HOME_OFFSET
763
       #if !HAS_HOME_OFFSET
756
         float home_offset[XYZ];
764
         float home_offset[XYZ];
757
       #endif
765
       #endif
763
         home_offset[Z_AXIS] -= DELTA_HEIGHT;
771
         home_offset[Z_AXIS] -= DELTA_HEIGHT;
764
       #endif
772
       #endif
765
 
773
 
774
+      //
775
+      // Hotend Offsets, if any
776
+      //
777
+
766
       #if HOTENDS > 1
778
       #if HOTENDS > 1
767
         // Skip hotend 0 which must be 0
779
         // Skip hotend 0 which must be 0
768
         for (uint8_t e = 1; e < HOTENDS; e++)
780
         for (uint8_t e = 1; e < HOTENDS; e++)
846
           for (uint16_t q = grid_max_x * grid_max_y; q--;) EEPROM_READ(dummy);
858
           for (uint16_t q = grid_max_x * grid_max_y; q--;) EEPROM_READ(dummy);
847
         }
859
         }
848
 
860
 
861
+      //
862
+      // Unified Bed Leveling active state
863
+      //
864
+
849
       #if ENABLED(AUTO_BED_LEVELING_UBL)
865
       #if ENABLED(AUTO_BED_LEVELING_UBL)
850
         EEPROM_READ(planner.leveling_active);
866
         EEPROM_READ(planner.leveling_active);
851
         EEPROM_READ(ubl.storage_slot);
867
         EEPROM_READ(ubl.storage_slot);
855
         EEPROM_READ(dummyui8);
871
         EEPROM_READ(dummyui8);
856
       #endif // AUTO_BED_LEVELING_UBL
872
       #endif // AUTO_BED_LEVELING_UBL
857
 
873
 
874
+      //
875
+      // DELTA Geometry or Dual Endstops offsets
876
+      //
877
+
858
       #if ENABLED(DELTA)
878
       #if ENABLED(DELTA)
859
         EEPROM_READ(delta_endstop_adj);         // 3 floats
879
         EEPROM_READ(delta_endstop_adj);         // 3 floats
860
         EEPROM_READ(delta_radius);              // 1 float
880
         EEPROM_READ(delta_radius);              // 1 float
891
 
911
 
892
       #endif
912
       #endif
893
 
913
 
914
+      //
915
+      // LCD Preheat settings
916
+      //
917
+
894
       #if DISABLED(ULTIPANEL)
918
       #if DISABLED(ULTIPANEL)
895
         int lcd_preheat_hotend_temp[2], lcd_preheat_bed_temp[2], lcd_preheat_fan_speed[2];
919
         int lcd_preheat_hotend_temp[2], lcd_preheat_bed_temp[2], lcd_preheat_fan_speed[2];
896
       #endif
920
       #endif
897
-
898
-      EEPROM_READ(lcd_preheat_hotend_temp);
899
-      EEPROM_READ(lcd_preheat_bed_temp);
900
-      EEPROM_READ(lcd_preheat_fan_speed);
921
+      EEPROM_READ(lcd_preheat_hotend_temp); // 2 floats
922
+      EEPROM_READ(lcd_preheat_bed_temp);    // 2 floats
923
+      EEPROM_READ(lcd_preheat_fan_speed);   // 2 floats
901
 
924
 
902
       //EEPROM_ASSERT(
925
       //EEPROM_ASSERT(
903
       //  WITHIN(lcd_preheat_fan_speed, 0, 255),
926
       //  WITHIN(lcd_preheat_fan_speed, 0, 255),
904
       //  "lcd_preheat_fan_speed out of range"
927
       //  "lcd_preheat_fan_speed out of range"
905
       //);
928
       //);
906
 
929
 
930
+      //
931
+      // Hotend PID
932
+      //
933
+
907
       #if ENABLED(PIDTEMP)
934
       #if ENABLED(PIDTEMP)
908
         for (uint8_t e = 0; e < MAX_EXTRUDERS; e++) {
935
         for (uint8_t e = 0; e < MAX_EXTRUDERS; e++) {
909
           EEPROM_READ(dummy); // Kp
936
           EEPROM_READ(dummy); // Kp
927
         for (uint8_t q = MAX_EXTRUDERS * 4; q--;) EEPROM_READ(dummy);  // Kp, Ki, Kd, Kc
954
         for (uint8_t q = MAX_EXTRUDERS * 4; q--;) EEPROM_READ(dummy);  // Kp, Ki, Kd, Kc
928
       #endif // !PIDTEMP
955
       #endif // !PIDTEMP
929
 
956
 
957
+      //
958
+      // PID Extrusion Scaling
959
+      //
960
+
930
       #if DISABLED(PID_EXTRUSION_SCALING)
961
       #if DISABLED(PID_EXTRUSION_SCALING)
931
         int lpq_len;
962
         int lpq_len;
932
       #endif
963
       #endif
933
       EEPROM_READ(lpq_len);
964
       EEPROM_READ(lpq_len);
934
 
965
 
966
+      //
967
+      // Heated Bed PID
968
+      //
969
+
935
       #if ENABLED(PIDTEMPBED)
970
       #if ENABLED(PIDTEMPBED)
936
         EEPROM_READ(dummy); // bedKp
971
         EEPROM_READ(dummy); // bedKp
937
         if (dummy != DUMMY_PID_VALUE) {
972
         if (dummy != DUMMY_PID_VALUE) {
943
         for (uint8_t q=3; q--;) EEPROM_READ(dummy); // bedKp, bedKi, bedKd
978
         for (uint8_t q=3; q--;) EEPROM_READ(dummy); // bedKp, bedKi, bedKd
944
       #endif
979
       #endif
945
 
980
 
981
+      //
982
+      // LCD Contrast
983
+      //
984
+
946
       #if !HAS_LCD_CONTRAST
985
       #if !HAS_LCD_CONTRAST
947
         uint16_t lcd_contrast;
986
         uint16_t lcd_contrast;
948
       #endif
987
       #endif
949
       EEPROM_READ(lcd_contrast);
988
       EEPROM_READ(lcd_contrast);
950
 
989
 
990
+      //
991
+      // Firmware Retraction
992
+      //
993
+
951
       #if ENABLED(FWRETRACT)
994
       #if ENABLED(FWRETRACT)
952
         EEPROM_READ(autoretract_enabled);
995
         EEPROM_READ(autoretract_enabled);
953
         EEPROM_READ(retract_length);
996
         EEPROM_READ(retract_length);
963
         for (uint8_t q=8; q--;) EEPROM_READ(dummy);
1006
         for (uint8_t q=8; q--;) EEPROM_READ(dummy);
964
       #endif
1007
       #endif
965
 
1008
 
966
-      EEPROM_READ(volumetric_enabled);
1009
+      //
1010
+      // Volumetric & Filament Size
1011
+      //
967
 
1012
 
1013
+      EEPROM_READ(volumetric_enabled);
968
       for (uint8_t q = 0; q < MAX_EXTRUDERS; q++) {
1014
       for (uint8_t q = 0; q < MAX_EXTRUDERS; q++) {
969
         EEPROM_READ(dummy);
1015
         EEPROM_READ(dummy);
970
         if (q < COUNT(filament_size)) filament_size[q] = dummy;
1016
         if (q < COUNT(filament_size)) filament_size[q] = dummy;
971
       }
1017
       }
972
 
1018
 
1019
+      //
1020
+      // TMC2130 Stepper Current
1021
+      //
1022
+
973
       uint16_t val;
1023
       uint16_t val;
974
       #if ENABLED(HAVE_TMC2130)
1024
       #if ENABLED(HAVE_TMC2130)
975
         EEPROM_READ(val);
1025
         EEPROM_READ(val);
1017
           stepperE4.setCurrent(val, R_SENSE, HOLD_MULTIPLIER);
1067
           stepperE4.setCurrent(val, R_SENSE, HOLD_MULTIPLIER);
1018
         #endif
1068
         #endif
1019
       #else
1069
       #else
1020
-        for (uint8_t q = 0; q < 11; q++) EEPROM_READ(val);
1070
+        for (uint8_t q = 11; --q;) EEPROM_READ(val);
1021
       #endif
1071
       #endif
1022
 
1072
 
1023
       //
1073
       //
1032
         EEPROM_READ(dummy);
1082
         EEPROM_READ(dummy);
1033
       #endif
1083
       #endif
1034
 
1084
 
1085
+      //
1086
+      // Motor Current PWM
1087
+      //
1088
+
1035
       #if HAS_MOTOR_CURRENT_PWM
1089
       #if HAS_MOTOR_CURRENT_PWM
1036
         for (uint8_t q = 3; q--;) EEPROM_READ(stepper.motor_current_setting[q]);
1090
         for (uint8_t q = 3; q--;) EEPROM_READ(stepper.motor_current_setting[q]);
1037
       #else
1091
       #else

Loading…
Cancel
Save