Browse Source

Save hotend_offset array (M218) in EEPROM

Scott Lahteine 8 years ago
parent
commit
67ab54185b
3 changed files with 97 additions and 53 deletions
  1. 4
    0
      Marlin/Marlin.h
  2. 2
    8
      Marlin/Marlin_main.cpp
  3. 91
    45
      Marlin/configuration_store.cpp

+ 4
- 0
Marlin/Marlin.h View File

@@ -278,6 +278,10 @@ extern float current_position[NUM_AXIS];
278 278
 extern float position_shift[XYZ];
279 279
 extern float home_offset[XYZ];
280 280
 
281
+#if HOTENDS > 1
282
+  extern float hotend_offset[XYZ][HOTENDS];
283
+#endif
284
+
281 285
 // Software Endstops
282 286
 void update_software_endstops(AxisEnum axis);
283 287
 #if ENABLED(min_software_endstops) || ENABLED(max_software_endstops)

+ 2
- 8
Marlin/Marlin_main.cpp View File

@@ -481,13 +481,7 @@ static uint8_t target_extruder;
481 481
 
482 482
 // Extruder offsets
483 483
 #if HOTENDS > 1
484
-  float hotend_offset[][HOTENDS] = {
485
-    HOTEND_OFFSET_X,
486
-    HOTEND_OFFSET_Y
487
-    #ifdef HOTEND_OFFSET_Z
488
-      , HOTEND_OFFSET_Z
489
-    #endif
490
-  };
484
+  float hotend_offset[XYZ][HOTENDS];
491 485
 #endif
492 486
 
493 487
 #if HAS_Z_SERVO_ENDSTOP
@@ -6129,7 +6123,7 @@ inline void gcode_M211() {
6129 6123
    *   Z<zoffset> - Available with DUAL_X_CARRIAGE and SWITCHING_EXTRUDER
6130 6124
    */
6131 6125
   inline void gcode_M218() {
6132
-    if (get_target_extruder_from_command(218)) return;
6126
+    if (get_target_extruder_from_command(218) || target_extruder == 0) return;
6133 6127
 
6134 6128
     if (code_seen('X')) hotend_offset[X_AXIS][target_extruder] = code_value_axis_units(X_AXIS);
6135 6129
     if (code_seen('Y')) hotend_offset[Y_AXIS][target_extruder] = code_value_axis_units(Y_AXIS);

+ 91
- 45
Marlin/configuration_store.cpp View File

@@ -36,13 +36,13 @@
36 36
  *
37 37
  */
38 38
 
39
-#define EEPROM_VERSION "V26"
39
+#define EEPROM_VERSION "V27"
40 40
 
41 41
 // Change EEPROM version if these are changed:
42 42
 #define EEPROM_OFFSET 100
43 43
 
44 44
 /**
45
- * V24 EEPROM Layout:
45
+ * V27 EEPROM Layout:
46 46
  *
47 47
  *  100  Version (char x4)
48 48
  *  104  EEPROM Checksum (uint16_t)
@@ -61,65 +61,66 @@
61 61
  *  186  M205 Z    planner.max_jerk[Z_AXIS] (float)
62 62
  *  190  M205 E    planner.max_jerk[E_AXIS] (float)
63 63
  *  194  M206 XYZ  home_offset (float x3)
64
+ *  206  M218 XYZ  hotend_offset (float x3 per additional hotend)
64 65
  *
65 66
  * Mesh bed leveling:
66
- *  206  M420 S    status (uint8)
67
- *  207            z_offset (float)
68
- *  211            mesh_num_x (uint8 as set in firmware)
69
- *  212            mesh_num_y (uint8 as set in firmware)
70
- *  213 G29 S3 XYZ z_values[][] (float x9, by default, up to float x 81)
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)
71 72
  *
72 73
  * AUTO BED LEVELING
73
- *  249  M851      zprobe_zoffset (float)
74
+ *  261  M851      zprobe_zoffset (float)
74 75
  *
75 76
  * DELTA:
76
- *  253  M666 XYZ  endstop_adj (float x3)
77
- *  265  M665 R    delta_radius (float)
78
- *  269  M665 L    delta_diagonal_rod (float)
79
- *  273  M665 S    delta_segments_per_second (float)
80
- *  277  M665 A    delta_diagonal_rod_trim_tower_1 (float)
81
- *  281  M665 B    delta_diagonal_rod_trim_tower_2 (float)
82
- *  285  M665 C    delta_diagonal_rod_trim_tower_3 (float)
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)
83 84
  *
84 85
  * Z_DUAL_ENDSTOPS:
85
- *  289  M666 Z    z_endstop_adj (float)
86
+ *  301  M666 Z    z_endstop_adj (float)
86 87
  *
87 88
  * ULTIPANEL:
88
- *  293  M145 S0 H preheatHotendTemp1 (int)
89
- *  295  M145 S0 B preheatBedTemp1 (int)
90
- *  297  M145 S0 F preheatFanSpeed1 (int)
91
- *  299  M145 S1 H preheatHotendTemp2 (int)
92
- *  301  M145 S1 B preheatBedTemp2 (int)
93
- *  303  M145 S1 F preheatFanSpeed2 (int)
89
+ *  305  M145 S0 H preheatHotendTemp1 (int)
90
+ *  307  M145 S0 B preheatBedTemp1 (int)
91
+ *  309  M145 S0 F preheatFanSpeed1 (int)
92
+ *  311  M145 S1 H preheatHotendTemp2 (int)
93
+ *  313  M145 S1 B preheatBedTemp2 (int)
94
+ *  315  M145 S1 F preheatFanSpeed2 (int)
94 95
  *
95 96
  * PIDTEMP:
96
- *  305  M301 E0 PIDC  Kp[0], Ki[0], Kd[0], Kc[0] (float x4)
97
- *  321  M301 E1 PIDC  Kp[1], Ki[1], Kd[1], Kc[1] (float x4)
98
- *  337  M301 E2 PIDC  Kp[2], Ki[2], Kd[2], Kc[2] (float x4)
99
- *  353  M301 E3 PIDC  Kp[3], Ki[3], Kd[3], Kc[3] (float x4)
100
- *  369  M301 L        lpq_len (int)
97
+ *  317  M301 E0 PIDC  Kp[0], Ki[0], Kd[0], Kc[0] (float x4)
98
+ *  333  M301 E1 PIDC  Kp[1], Ki[1], Kd[1], Kc[1] (float x4)
99
+ *  349  M301 E2 PIDC  Kp[2], Ki[2], Kd[2], Kc[2] (float x4)
100
+ *  365  M301 E3 PIDC  Kp[3], Ki[3], Kd[3], Kc[3] (float x4)
101
+ *  381  M301 L        lpq_len (int)
101 102
  *
102 103
  * PIDTEMPBED:
103
- *  371  M304 PID  thermalManager.bedKp, thermalManager.bedKi, thermalManager.bedKd (float x3)
104
+ *  383  M304 PID  thermalManager.bedKp, thermalManager.bedKi, thermalManager.bedKd (float x3)
104 105
  *
105 106
  * DOGLCD:
106
- *  383  M250 C    lcd_contrast (int)
107
+ *  395  M250 C    lcd_contrast (int)
107 108
  *
108 109
  * FWRETRACT:
109
- *  385  M209 S    autoretract_enabled (bool)
110
- *  386  M207 S    retract_length (float)
111
- *  390  M207 W    retract_length_swap (float)
112
- *  394  M207 F    retract_feedrate_mm_s (float)
113
- *  399  M207 Z    retract_zlift (float)
114
- *  402  M208 S    retract_recover_length (float)
115
- *  406  M208 W    retract_recover_length_swap (float)
116
- *  410  M208 F    retract_recover_feedrate_mm_s (float)
110
+ *  397  M209 S    autoretract_enabled (bool)
111
+ *  398  M207 S    retract_length (float)
112
+ *  402  M207 W    retract_length_swap (float)
113
+ *  406  M207 F    retract_feedrate_mm_s (float)
114
+ *  410  M207 Z    retract_zlift (float)
115
+ *  414  M208 S    retract_recover_length (float)
116
+ *  418  M208 W    retract_recover_length_swap (float)
117
+ *  422  M208 F    retract_recover_feedrate_mm_s (float)
117 118
  *
118 119
  * Volumetric Extrusion:
119
- *  414  M200 D    volumetric_enabled (bool)
120
- *  415  M200 T D  filament_size (float x4) (T0..3)
120
+ *  426  M200 D    volumetric_enabled (bool)
121
+ *  427  M200 T D  filament_size (float x4) (T0..3)
121 122
  *
122
- *  431  This Slot is Available!
123
+ *  443  This Slot is Available!
123 124
  *
124 125
  */
125 126
 #include "Marlin.h"
@@ -222,6 +223,12 @@ void Config_StoreSettings()  {
222 223
   EEPROM_WRITE(planner.max_jerk);
223 224
   EEPROM_WRITE(home_offset);
224 225
 
226
+  #if HOTENDS > 1
227
+    // Skip hotend 0 which must be 0
228
+    for (uint8_t e = 1; e < HOTENDS; e++)
229
+      LOOP_XYZ(i) EEPROM_WRITE(hotend_offset[i][e]);
230
+  #endif
231
+
225 232
   #if ENABLED(MESH_BED_LEVELING)
226 233
     // Compile time test that sizeof(mbl.z_values) is as expected
227 234
     typedef char c_assert[(sizeof(mbl.z_values) == (MESH_NUM_X_POINTS) * (MESH_NUM_Y_POINTS) * sizeof(dummy)) ? 1 : -1];
@@ -407,6 +414,12 @@ void Config_RetrieveSettings() {
407 414
     EEPROM_READ(planner.max_jerk);
408 415
     EEPROM_READ(home_offset);
409 416
 
417
+    #if HOTENDS > 1
418
+      // Skip hotend 0 which must be 0
419
+      for (uint8_t e = 1; e < HOTENDS; e++)
420
+        LOOP_XYZ(i) EEPROM_READ(hotend_offset[i][e]);
421
+    #endif
422
+
410 423
     uint8_t dummy_uint8 = 0, mesh_num_x = 0, mesh_num_y = 0;
411 424
     EEPROM_READ(dummy_uint8);
412 425
     EEPROM_READ(dummy);
@@ -558,9 +571,8 @@ void Config_RetrieveSettings() {
558 571
  * M502 - Reset Configuration
559 572
  */
560 573
 void Config_ResetDefault() {
561
-  float tmp1[] = DEFAULT_AXIS_STEPS_PER_UNIT;
562
-  float tmp2[] = DEFAULT_MAX_FEEDRATE;
563
-  long tmp3[] = DEFAULT_MAX_ACCELERATION;
574
+  const float tmp1[] = DEFAULT_AXIS_STEPS_PER_UNIT, tmp2[] = DEFAULT_MAX_FEEDRATE;
575
+  const long tmp3[] = DEFAULT_MAX_ACCELERATION;
564 576
   LOOP_XYZE(i) {
565 577
     planner.axis_steps_per_mm[i] = tmp1[i];
566 578
     planner.max_feedrate_mm_s[i] = tmp2[i];
@@ -579,6 +591,23 @@ void Config_ResetDefault() {
579 591
   planner.max_jerk[E_AXIS] = DEFAULT_EJERK;
580 592
   home_offset[X_AXIS] = home_offset[Y_AXIS] = home_offset[Z_AXIS] = 0;
581 593
 
594
+  #if HOTENDS > 1
595
+    constexpr float tmp4[XYZ][HOTENDS] = {
596
+      HOTEND_OFFSET_X,
597
+      HOTEND_OFFSET_Y
598
+      #ifdef HOTEND_OFFSET_Z
599
+        , HOTEND_OFFSET_Z
600
+      #else
601
+        , { 0 }
602
+      #endif
603
+    };
604
+    static_assert(
605
+      tmp4[X_AXIS][0] == 0 && tmp4[Y_AXIS][0] == 0 && tmp4[Z_AXIS][0] == 0,
606
+      "Offsets for the first hotend must be 0.0."
607
+    );
608
+    LOOP_XYZ(i) HOTEND_LOOP() hotend_offset[i][e] = tmp4[i][e];
609
+  #endif
610
+
582 611
   #if ENABLED(MESH_BED_LEVELING)
583 612
     mbl.reset();
584 613
   #endif
@@ -751,6 +780,23 @@ void Config_PrintSettings(bool forReplay) {
751 780
   SERIAL_ECHOPAIR(" Z", home_offset[Z_AXIS]);
752 781
   SERIAL_EOL;
753 782
 
783
+  #if HOTENDS > 1
784
+    CONFIG_ECHO_START;
785
+    if (!forReplay) {
786
+      SERIAL_ECHOLNPGM("Hotend offsets (mm)");
787
+      CONFIG_ECHO_START;
788
+    }
789
+    for (uint8_t e = 1; e < HOTENDS; e++) {
790
+      SERIAL_ECHOPAIR("  M218 T", (int)e);
791
+      SERIAL_ECHOPAIR(" X", hotend_offset[X_AXIS]);
792
+      SERIAL_ECHOPAIR(" Y", hotend_offset[Y_AXIS]);
793
+      #if ENABLED(DUAL_X_CARRIAGE) || ENABLED(SWITCHING_EXTRUDER)
794
+        SERIAL_ECHOPAIR(" Z", hotend_offset[Z_AXIS]);
795
+      #endif
796
+      SERIAL_EOL;
797
+    }
798
+  #endif
799
+
754 800
   #if ENABLED(MESH_BED_LEVELING)
755 801
     if (!forReplay) {
756 802
       SERIAL_ECHOLNPGM("Mesh bed leveling:");
@@ -763,8 +809,8 @@ void Config_PrintSettings(bool forReplay) {
763 809
     for (uint8_t py = 1; py <= MESH_NUM_Y_POINTS; py++) {
764 810
       for (uint8_t px = 1; px <= MESH_NUM_X_POINTS; px++) {
765 811
         CONFIG_ECHO_START;
766
-        SERIAL_ECHOPAIR("  G29 S3 X", px);
767
-        SERIAL_ECHOPAIR(" Y", py);
812
+        SERIAL_ECHOPAIR("  G29 S3 X", (int)px);
813
+        SERIAL_ECHOPAIR(" Y", (int)py);
768 814
         SERIAL_ECHOPGM(" Z");
769 815
         SERIAL_PROTOCOL_F(mbl.z_values[py-1][px-1], 5);
770 816
         SERIAL_EOL;

Loading…
Cancel
Save