Browse Source

Add e-stepper count to EEPROM (for planner vars)

Scott Lahteine 8 years ago
parent
commit
f2301a2a04
1 changed files with 75 additions and 56 deletions
  1. 75
    56
      Marlin/configuration_store.cpp

+ 75
- 56
Marlin/configuration_store.cpp View File

@@ -36,88 +36,89 @@
36 36
  *
37 37
  */
38 38
 
39
-#define EEPROM_VERSION "V27"
39
+#define EEPROM_VERSION "V28"
40 40
 
41 41
 // Change EEPROM version if these are changed:
42 42
 #define EEPROM_OFFSET 100
43 43
 
44 44
 /**
45
- * V27 EEPROM Layout:
45
+ * V28 EEPROM Layout:
46 46
  *
47 47
  *  100  Version (char x4)
48 48
  *  104  EEPROM Checksum (uint16_t)
49 49
  *
50
- *  106  M92 XYZE  planner.axis_steps_per_mm (float x4 ... x7)
51
- *  122  M203 XYZE planner.max_feedrate_mm_s (float x4 ... x7)
52
- *  138  M201 XYZE planner.max_acceleration_mm_per_s2 (uint32_t x4 ... x7)
53
- *  154  M204 P    planner.acceleration (float)
54
- *  158  M204 R    planner.retract_acceleration (float)
55
- *  162  M204 T    planner.travel_acceleration (float)
56
- *  166  M205 S    planner.min_feedrate_mm_s (float)
57
- *  170  M205 T    planner.min_travel_feedrate_mm_s (float)
58
- *  174  M205 B    planner.min_segment_time (ulong)
59
- *  178  M205 X    planner.max_jerk[X_AXIS] (float)
60
- *  182  M205 Y    planner.max_jerk[Y_AXIS] (float)
61
- *  186  M205 Z    planner.max_jerk[Z_AXIS] (float)
62
- *  190  M205 E    planner.max_jerk[E_AXIS] (float)
63
- *  194  M206 XYZ  home_offset (float x3)
64
- *  206  M218 XYZ  hotend_offset (float x3 per additional hotend)
50
+ *  106  E_STEPPERS (uint8_t)
51
+ *  107  M92 XYZE  planner.axis_steps_per_mm (float x4 ... x7)
52
+ *  123  M203 XYZE planner.max_feedrate_mm_s (float x4 ... x7)
53
+ *  139  M201 XYZE planner.max_acceleration_mm_per_s2 (uint32_t x4 ... x7)
54
+ *  155  M204 P    planner.acceleration (float)
55
+ *  159  M204 R    planner.retract_acceleration (float)
56
+ *  163  M204 T    planner.travel_acceleration (float)
57
+ *  167  M205 S    planner.min_feedrate_mm_s (float)
58
+ *  171  M205 T    planner.min_travel_feedrate_mm_s (float)
59
+ *  175  M205 B    planner.min_segment_time (ulong)
60
+ *  179  M205 X    planner.max_jerk[X_AXIS] (float)
61
+ *  183  M205 Y    planner.max_jerk[Y_AXIS] (float)
62
+ *  187  M205 Z    planner.max_jerk[Z_AXIS] (float)
63
+ *  191  M205 E    planner.max_jerk[E_AXIS] (float)
64
+ *  195  M206 XYZ  home_offset (float x3)
65
+ *  207  M218 XYZ  hotend_offset (float x3 per additional hotend)
65 66
  *
66 67
  * Mesh bed leveling:
67
- *  218  M420 S    status (uint8)
68
- *  219            z_offset (float)
69
- *  223            mesh_num_x (uint8 as set in firmware)
70
- *  224            mesh_num_y (uint8 as set in firmware)
71
- *  225 G29 S3 XYZ z_values[][] (float x9, by default, up to float x 81)
68
+ *  219  M420 S    status (uint8)
69
+ *  220            z_offset (float)
70
+ *  224            mesh_num_x (uint8 as set in firmware)
71
+ *  225            mesh_num_y (uint8 as set in firmware)
72
+ *  226 G29 S3 XYZ z_values[][] (float x9, by default, up to float x 81)
72 73
  *
73 74
  * AUTO BED LEVELING
74
- *  261  M851      zprobe_zoffset (float)
75
+ *  262  M851      zprobe_zoffset (float)
75 76
  *
76 77
  * DELTA:
77
- *  265  M666 XYZ  endstop_adj (float x3)
78
- *  277  M665 R    delta_radius (float)
79
- *  281  M665 L    delta_diagonal_rod (float)
80
- *  285  M665 S    delta_segments_per_second (float)
81
- *  289  M665 A    delta_diagonal_rod_trim_tower_1 (float)
82
- *  293  M665 B    delta_diagonal_rod_trim_tower_2 (float)
83
- *  297  M665 C    delta_diagonal_rod_trim_tower_3 (float)
78
+ *  266  M666 XYZ  endstop_adj (float x3)
79
+ *  278  M665 R    delta_radius (float)
80
+ *  282  M665 L    delta_diagonal_rod (float)
81
+ *  286  M665 S    delta_segments_per_second (float)
82
+ *  290  M665 A    delta_diagonal_rod_trim_tower_1 (float)
83
+ *  294  M665 B    delta_diagonal_rod_trim_tower_2 (float)
84
+ *  298  M665 C    delta_diagonal_rod_trim_tower_3 (float)
84 85
  *
85 86
  * Z_DUAL_ENDSTOPS:
86
- *  301  M666 Z    z_endstop_adj (float)
87
+ *  302  M666 Z    z_endstop_adj (float)
87 88
  *
88 89
  * ULTIPANEL:
89
- *  305  M145 S0 H lcd_preheat_hotend_temp (int x2)
90
- *  309  M145 S0 B lcd_preheat_bed_temp (int x2)
91
- *  313  M145 S0 F lcd_preheat_fan_speed (int x2)
90
+ *  306  M145 S0 H lcd_preheat_hotend_temp (int x2)
91
+ *  310  M145 S0 B lcd_preheat_bed_temp (int x2)
92
+ *  314  M145 S0 F lcd_preheat_fan_speed (int x2)
92 93
  *
93 94
  * PIDTEMP:
94
- *  317  M301 E0 PIDC  Kp[0], Ki[0], Kd[0], Kc[0] (float x4)
95
- *  333  M301 E1 PIDC  Kp[1], Ki[1], Kd[1], Kc[1] (float x4)
96
- *  349  M301 E2 PIDC  Kp[2], Ki[2], Kd[2], Kc[2] (float x4)
97
- *  365  M301 E3 PIDC  Kp[3], Ki[3], Kd[3], Kc[3] (float x4)
98
- *  381  M301 L        lpq_len (int)
95
+ *  318  M301 E0 PIDC  Kp[0], Ki[0], Kd[0], Kc[0] (float x4)
96
+ *  334  M301 E1 PIDC  Kp[1], Ki[1], Kd[1], Kc[1] (float x4)
97
+ *  350  M301 E2 PIDC  Kp[2], Ki[2], Kd[2], Kc[2] (float x4)
98
+ *  366  M301 E3 PIDC  Kp[3], Ki[3], Kd[3], Kc[3] (float x4)
99
+ *  382  M301 L        lpq_len (int)
99 100
  *
100 101
  * PIDTEMPBED:
101
- *  383  M304 PID  thermalManager.bedKp, thermalManager.bedKi, thermalManager.bedKd (float x3)
102
+ *  384  M304 PID  thermalManager.bedKp, thermalManager.bedKi, thermalManager.bedKd (float x3)
102 103
  *
103 104
  * DOGLCD:
104
- *  395  M250 C    lcd_contrast (int)
105
+ *  396  M250 C    lcd_contrast (int)
105 106
  *
106 107
  * FWRETRACT:
107
- *  397  M209 S    autoretract_enabled (bool)
108
- *  398  M207 S    retract_length (float)
109
- *  402  M207 W    retract_length_swap (float)
110
- *  406  M207 F    retract_feedrate_mm_s (float)
111
- *  410  M207 Z    retract_zlift (float)
112
- *  414  M208 S    retract_recover_length (float)
113
- *  418  M208 W    retract_recover_length_swap (float)
114
- *  422  M208 F    retract_recover_feedrate_mm_s (float)
108
+ *  398  M209 S    autoretract_enabled (bool)
109
+ *  399  M207 S    retract_length (float)
110
+ *  403  M207 W    retract_length_swap (float)
111
+ *  407  M207 F    retract_feedrate_mm_s (float)
112
+ *  411  M207 Z    retract_zlift (float)
113
+ *  415  M208 S    retract_recover_length (float)
114
+ *  419  M208 W    retract_recover_length_swap (float)
115
+ *  423  M208 F    retract_recover_feedrate_mm_s (float)
115 116
  *
116 117
  * Volumetric Extrusion:
117
- *  426  M200 D    volumetric_enabled (bool)
118
- *  427  M200 T D  filament_size (float x4) (T0..3)
118
+ *  427  M200 D    volumetric_enabled (bool)
119
+ *  428  M200 T D  filament_size (float x4) (T0..3)
119 120
  *
120
- *  443  This Slot is Available!
121
+ *  444  This Slot is Available!
121 122
  *
122 123
  */
123 124
 #include "Marlin.h"
@@ -219,9 +220,12 @@ void Config_Postprocess() {
219 220
 
220 221
     eeprom_checksum = 0; // clear before first "real data"
221 222
 
223
+    const uint8_t esteppers = E_STEPPERS;
224
+    EEPROM_WRITE(esteppers);
222 225
     EEPROM_WRITE(planner.axis_steps_per_mm);
223 226
     EEPROM_WRITE(planner.max_feedrate_mm_s);
224 227
     EEPROM_WRITE(planner.max_acceleration_mm_per_s2);
228
+
225 229
     EEPROM_WRITE(planner.acceleration);
226 230
     EEPROM_WRITE(planner.retract_acceleration);
227 231
     EEPROM_WRITE(planner.travel_acceleration);
@@ -398,6 +402,7 @@ void Config_Postprocess() {
398 402
     //  SERIAL_CHAR(']');
399 403
     //  SERIAL_EOL;
400 404
 
405
+    // Version has to match or defaults are used
401 406
     if (strncmp(version, stored_ver, 3) != 0) {
402 407
       Config_ResetDefault();
403 408
     }
@@ -406,10 +411,24 @@ void Config_Postprocess() {
406 411
 
407 412
       eeprom_checksum = 0; // clear before reading first "real data"
408 413
 
409
-      // version number match
410
-      EEPROM_READ(planner.axis_steps_per_mm);
411
-      EEPROM_READ(planner.max_feedrate_mm_s);
412
-      EEPROM_READ(planner.max_acceleration_mm_per_s2);
414
+      // Number of esteppers may change
415
+      uint8_t esteppers;
416
+      EEPROM_READ(esteppers);
417
+
418
+      // Get only the number of E stepper parameters previously stored
419
+      // Any steppers added later are set to their defaults
420
+      const float def1[] = DEFAULT_AXIS_STEPS_PER_UNIT, def2[] = DEFAULT_MAX_FEEDRATE;
421
+      const long def3[] = DEFAULT_MAX_ACCELERATION;
422
+      float tmp1[XYZ + esteppers], tmp2[XYZ + esteppers];
423
+      long tmp3[XYZ + esteppers];
424
+      EEPROM_READ(tmp1);
425
+      EEPROM_READ(tmp2);
426
+      EEPROM_READ(tmp3);
427
+      LOOP_XYZE_N(i) {
428
+        planner.axis_steps_per_mm[i]          = i < XYZ + esteppers ? tmp1[i] : def1[i < COUNT(def1) ? i : COUNT(def1) - 1];
429
+        planner.max_feedrate_mm_s[i]          = i < XYZ + esteppers ? tmp2[i] : def2[i < COUNT(def2) ? i : COUNT(def2) - 1];
430
+        planner.max_acceleration_mm_per_s2[i] = i < XYZ + esteppers ? tmp3[i] : def3[i < COUNT(def3) ? i : COUNT(def3) - 1];
431
+      }
413 432
 
414 433
       EEPROM_READ(planner.acceleration);
415 434
       EEPROM_READ(planner.retract_acceleration);

Loading…
Cancel
Save