Browse Source

Merge pull request #1700 from thinkyhead/fixup_leveling

Fixup leveling and other issues
Scott Lahteine 10 years ago
parent
commit
1aec2f437c

+ 5
- 3
Marlin/Configuration.h View File

532
 // Custom M code points
532
 // Custom M code points
533
 #define CUSTOM_M_CODES
533
 #define CUSTOM_M_CODES
534
 #ifdef CUSTOM_M_CODES
534
 #ifdef CUSTOM_M_CODES
535
-  #define CUSTOM_M_CODE_SET_Z_PROBE_OFFSET 851
536
-  #define Z_PROBE_OFFSET_RANGE_MIN -15
537
-  #define Z_PROBE_OFFSET_RANGE_MAX -5
535
+  #ifdef ENABLE_AUTO_BED_LEVELING
536
+    #define CUSTOM_M_CODE_SET_Z_PROBE_OFFSET 851
537
+    #define Z_PROBE_OFFSET_RANGE_MIN -20
538
+    #define Z_PROBE_OFFSET_RANGE_MAX 20
539
+  #endif
538
 #endif
540
 #endif
539
 
541
 
540
 
542
 

+ 35
- 21
Marlin/ConfigurationStore.cpp View File

11
  *  max_acceleration_units_per_sq_second (x4)
11
  *  max_acceleration_units_per_sq_second (x4)
12
  *  acceleration
12
  *  acceleration
13
  *  retract_acceleration
13
  *  retract_acceleration
14
- *  travel_aceeleration
14
+ *  travel_acceleration
15
  *  minimumfeedrate
15
  *  minimumfeedrate
16
  *  mintravelfeedrate
16
  *  mintravelfeedrate
17
  *  minsegmenttime
17
  *  minsegmenttime
25
  *  mesh_num_x
25
  *  mesh_num_x
26
  *  mesh_num_y
26
  *  mesh_num_y
27
  *  z_values[][]
27
  *  z_values[][]
28
+ *  zprobe_zoffset
28
  *
29
  *
29
  * DELTA:
30
  * DELTA:
30
  *  endstop_adj (x3)
31
  *  endstop_adj (x3)
39
  *  absPreheatHotendTemp
40
  *  absPreheatHotendTemp
40
  *  absPreheatHPBTemp
41
  *  absPreheatHPBTemp
41
  *  absPreheatFanSpeed
42
  *  absPreheatFanSpeed
42
- *  zprobe_zoffset
43
  *
43
  *
44
  * PIDTEMP:
44
  * PIDTEMP:
45
  *  Kp[0], Ki[0], Kd[0], Kc[0]
45
  *  Kp[0], Ki[0], Kd[0], Kc[0]
118
 // wrong data being written to the variables.
118
 // wrong data being written to the variables.
119
 // ALSO:  always make sure the variables in the Store and retrieve sections are in the same order.
119
 // ALSO:  always make sure the variables in the Store and retrieve sections are in the same order.
120
 
120
 
121
-#define EEPROM_VERSION "V17"
121
+#define EEPROM_VERSION "V18"
122
 
122
 
123
 #ifdef EEPROM_SETTINGS
123
 #ifdef EEPROM_SETTINGS
124
 
124
 
143
 
143
 
144
   uint8_t mesh_num_x = 3;
144
   uint8_t mesh_num_x = 3;
145
   uint8_t mesh_num_y = 3;
145
   uint8_t mesh_num_y = 3;
146
-  #if defined(MESH_BED_LEVELING)
146
+  #ifdef MESH_BED_LEVELING
147
     // Compile time test that sizeof(mbl.z_values) is as expected
147
     // Compile time test that sizeof(mbl.z_values) is as expected
148
     typedef char c_assert[(sizeof(mbl.z_values) == MESH_NUM_X_POINTS*MESH_NUM_Y_POINTS*sizeof(dummy)) ? 1 : -1];
148
     typedef char c_assert[(sizeof(mbl.z_values) == MESH_NUM_X_POINTS*MESH_NUM_Y_POINTS*sizeof(dummy)) ? 1 : -1];
149
     mesh_num_x = MESH_NUM_X_POINTS;
149
     mesh_num_x = MESH_NUM_X_POINTS;
161
     for (int q=0; q<mesh_num_x*mesh_num_y; q++) {
161
     for (int q=0; q<mesh_num_x*mesh_num_y; q++) {
162
       EEPROM_WRITE_VAR(i, dummy);
162
       EEPROM_WRITE_VAR(i, dummy);
163
     }
163
     }
164
-  #endif  // MESH_BED_LEVELING
164
+  #endif // MESH_BED_LEVELING
165
+
166
+  #ifndef ENABLE_AUTO_BED_LEVELING
167
+    float zprobe_zoffset = 0;
168
+  #endif
169
+  EEPROM_WRITE_VAR(i, zprobe_zoffset);
165
 
170
 
166
   #ifdef DELTA
171
   #ifdef DELTA
167
     EEPROM_WRITE_VAR(i, endstop_adj);               // 3 floats
172
     EEPROM_WRITE_VAR(i, endstop_adj);               // 3 floats
188
   EEPROM_WRITE_VAR(i, absPreheatHotendTemp);
193
   EEPROM_WRITE_VAR(i, absPreheatHotendTemp);
189
   EEPROM_WRITE_VAR(i, absPreheatHPBTemp);
194
   EEPROM_WRITE_VAR(i, absPreheatHPBTemp);
190
   EEPROM_WRITE_VAR(i, absPreheatFanSpeed);
195
   EEPROM_WRITE_VAR(i, absPreheatFanSpeed);
191
-  EEPROM_WRITE_VAR(i, zprobe_zoffset);
196
+
192
 
197
 
193
   for (int e = 0; e < 4; e++) {
198
   for (int e = 0; e < 4; e++) {
194
 
199
 
328
       }
333
       }
329
     #endif  // MESH_BED_LEVELING
334
     #endif  // MESH_BED_LEVELING
330
 
335
 
336
+    #ifndef ENABLE_AUTO_BED_LEVELING
337
+      float zprobe_zoffset = 0;
338
+    #endif
339
+    EEPROM_READ_VAR(i, zprobe_zoffset);
340
+
331
     #ifdef DELTA
341
     #ifdef DELTA
332
       EEPROM_READ_VAR(i, endstop_adj);                // 3 floats
342
       EEPROM_READ_VAR(i, endstop_adj);                // 3 floats
333
       EEPROM_READ_VAR(i, delta_radius);               // 1 float
343
       EEPROM_READ_VAR(i, delta_radius);               // 1 float
353
     EEPROM_READ_VAR(i, absPreheatHotendTemp);
363
     EEPROM_READ_VAR(i, absPreheatHotendTemp);
354
     EEPROM_READ_VAR(i, absPreheatHPBTemp);
364
     EEPROM_READ_VAR(i, absPreheatHPBTemp);
355
     EEPROM_READ_VAR(i, absPreheatFanSpeed);
365
     EEPROM_READ_VAR(i, absPreheatFanSpeed);
356
-    EEPROM_READ_VAR(i, zprobe_zoffset);
357
 
366
 
358
     #ifdef PIDTEMP
367
     #ifdef PIDTEMP
359
       for (int e = 0; e < 4; e++) { // 4 = max extruders currently supported by Marlin
368
       for (int e = 0; e < 4; e++) { // 4 = max extruders currently supported by Marlin
461
   max_e_jerk = DEFAULT_EJERK;
470
   max_e_jerk = DEFAULT_EJERK;
462
   home_offset[X_AXIS] = home_offset[Y_AXIS] = home_offset[Z_AXIS] = 0;
471
   home_offset[X_AXIS] = home_offset[Y_AXIS] = home_offset[Z_AXIS] = 0;
463
 
472
 
464
-  #if defined(MESH_BED_LEVELING)
473
+  #ifdef MESH_BED_LEVELING
465
     mbl.active = 0;
474
     mbl.active = 0;
466
-  #endif  // MESH_BED_LEVELING
475
+  #endif
476
+
477
+  #ifdef ENABLE_AUTO_BED_LEVELING
478
+    zprobe_zoffset = -Z_PROBE_OFFSET_FROM_EXTRUDER;
479
+  #endif
467
 
480
 
468
   #ifdef DELTA
481
   #ifdef DELTA
469
     endstop_adj[X_AXIS] = endstop_adj[Y_AXIS] = endstop_adj[Z_AXIS] = 0;
482
     endstop_adj[X_AXIS] = endstop_adj[Y_AXIS] = endstop_adj[Z_AXIS] = 0;
484
     absPreheatFanSpeed = ABS_PREHEAT_FAN_SPEED;
497
     absPreheatFanSpeed = ABS_PREHEAT_FAN_SPEED;
485
   #endif
498
   #endif
486
 
499
 
487
-  #ifdef ENABLE_AUTO_BED_LEVELING
488
-    zprobe_zoffset = -Z_PROBE_OFFSET_FROM_EXTRUDER;
489
-  #endif
490
-
491
   #ifdef DOGLCD
500
   #ifdef DOGLCD
492
     lcd_contrast = DEFAULT_LCD_CONTRAST;
501
     lcd_contrast = DEFAULT_LCD_CONTRAST;
493
   #endif
502
   #endif
738
     }
747
     }
739
   }
748
   }
740
 
749
 
741
-  #ifdef CUSTOM_M_CODES
750
+  #ifdef ENABLE_AUTO_BED_LEVELING
742
     SERIAL_ECHO_START;
751
     SERIAL_ECHO_START;
743
-    if (!forReplay) {
744
-      SERIAL_ECHOLNPGM("Z-Probe Offset (mm):");
745
-      SERIAL_ECHO_START;
746
-    }
747
-    SERIAL_ECHO("   M");
748
-    SERIAL_ECHO(CUSTOM_M_CODE_SET_Z_PROBE_OFFSET);
749
-    SERIAL_ECHOPAIR(" Z", -zprobe_zoffset);
752
+    #ifdef CUSTOM_M_CODES
753
+      if (!forReplay) {
754
+        SERIAL_ECHOLNPGM("Z-Probe Offset (mm):");
755
+        SERIAL_ECHO_START;
756
+      }
757
+      SERIAL_ECHOPAIR("   M", (unsigned long)CUSTOM_M_CODE_SET_Z_PROBE_OFFSET);
758
+      SERIAL_ECHOPAIR(" Z", -zprobe_zoffset);
759
+    #else
760
+      if (!forReplay) {
761
+        SERIAL_ECHOPAIR("Z-Probe Offset (mm):", -zprobe_zoffset);
762
+      }
763
+    #endif
750
     SERIAL_EOL;
764
     SERIAL_EOL;
751
   #endif
765
   #endif
752
 }
766
 }

+ 3
- 1
Marlin/Marlin.h View File

251
 extern float min_pos[3];
251
 extern float min_pos[3];
252
 extern float max_pos[3];
252
 extern float max_pos[3];
253
 extern bool axis_known_position[3];
253
 extern bool axis_known_position[3];
254
-extern float zprobe_zoffset;
254
+#ifdef ENABLE_AUTO_BED_LEVELING
255
+  extern float zprobe_zoffset;
256
+#endif
255
 extern int fanSpeed;
257
 extern int fanSpeed;
256
 #ifdef BARICUDA
258
 #ifdef BARICUDA
257
   extern int ValvePressure;
259
   extern int ValvePressure;

+ 178
- 169
Marlin/Marlin_main.cpp View File

203
 
203
 
204
 float homing_feedrate[] = HOMING_FEEDRATE;
204
 float homing_feedrate[] = HOMING_FEEDRATE;
205
 #ifdef ENABLE_AUTO_BED_LEVELING
205
 #ifdef ENABLE_AUTO_BED_LEVELING
206
-int xy_travel_speed = XY_TRAVEL_SPEED;
206
+  int xy_travel_speed = XY_TRAVEL_SPEED;
207
+  float zprobe_zoffset = -Z_PROBE_OFFSET_FROM_EXTRUDER;
207
 #endif
208
 #endif
208
 int homing_bump_divisor[] = HOMING_BUMP_DIVISOR;
209
 int homing_bump_divisor[] = HOMING_BUMP_DIVISOR;
209
 bool axis_relative_modes[] = AXIS_RELATIVE_MODES;
210
 bool axis_relative_modes[] = AXIS_RELATIVE_MODES;
255
 float min_pos[3] = { X_MIN_POS, Y_MIN_POS, Z_MIN_POS };
256
 float min_pos[3] = { X_MIN_POS, Y_MIN_POS, Z_MIN_POS };
256
 float max_pos[3] = { X_MAX_POS, Y_MAX_POS, Z_MAX_POS };
257
 float max_pos[3] = { X_MAX_POS, Y_MAX_POS, Z_MAX_POS };
257
 bool axis_known_position[3] = { false, false, false };
258
 bool axis_known_position[3] = { false, false, false };
258
-float zprobe_zoffset;
259
 
259
 
260
 // Extruder offset
260
 // Extruder offset
261
 #if EXTRUDERS > 1
261
 #if EXTRUDERS > 1
1097
     current_position[Y_AXIS] = corrected_position.y;
1097
     current_position[Y_AXIS] = corrected_position.y;
1098
     current_position[Z_AXIS] = corrected_position.z;
1098
     current_position[Z_AXIS] = corrected_position.z;
1099
 
1099
 
1100
-    // put the bed at 0 so we don't go below it.
1101
-    current_position[Z_AXIS] = zprobe_zoffset; // in the lsq we reach here after raising the extruder due to the loop structure
1102
-
1103
     plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
1100
     plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
1104
 }
1101
 }
1105
 #endif
1102
 #endif
1113
     vector_3 pt1 = vector_3(ABL_PROBE_PT_1_X, ABL_PROBE_PT_1_Y, z_at_pt_1);
1110
     vector_3 pt1 = vector_3(ABL_PROBE_PT_1_X, ABL_PROBE_PT_1_Y, z_at_pt_1);
1114
     vector_3 pt2 = vector_3(ABL_PROBE_PT_2_X, ABL_PROBE_PT_2_Y, z_at_pt_2);
1111
     vector_3 pt2 = vector_3(ABL_PROBE_PT_2_X, ABL_PROBE_PT_2_Y, z_at_pt_2);
1115
     vector_3 pt3 = vector_3(ABL_PROBE_PT_3_X, ABL_PROBE_PT_3_Y, z_at_pt_3);
1112
     vector_3 pt3 = vector_3(ABL_PROBE_PT_3_X, ABL_PROBE_PT_3_Y, z_at_pt_3);
1113
+    vector_3 planeNormal = vector_3::cross(pt1 - pt2, pt3 - pt2).get_normal();
1116
 
1114
 
1117
-    vector_3 from_2_to_1 = (pt1 - pt2).get_normal();
1118
-    vector_3 from_2_to_3 = (pt3 - pt2).get_normal();
1119
-    vector_3 planeNormal = vector_3::cross(from_2_to_1, from_2_to_3).get_normal();
1120
-    planeNormal = vector_3(planeNormal.x, planeNormal.y, abs(planeNormal.z));
1115
+    if (planeNormal.z < 0) {
1116
+      planeNormal.x = -planeNormal.x;
1117
+      planeNormal.y = -planeNormal.y;
1118
+      planeNormal.z = -planeNormal.z;
1119
+    }
1121
 
1120
 
1122
     plan_bed_level_matrix = matrix_3x3::create_look_at(planeNormal);
1121
     plan_bed_level_matrix = matrix_3x3::create_look_at(planeNormal);
1123
 
1122
 
1126
     current_position[Y_AXIS] = corrected_position.y;
1125
     current_position[Y_AXIS] = corrected_position.y;
1127
     current_position[Z_AXIS] = corrected_position.z;
1126
     current_position[Z_AXIS] = corrected_position.z;
1128
 
1127
 
1129
-    // put the bed at 0 so we don't go below it.
1130
-    current_position[Z_AXIS] = zprobe_zoffset;
1131
-
1132
     plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
1128
     plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
1133
-
1134
 }
1129
 }
1135
 
1130
 
1136
 #endif // AUTO_BED_LEVELING_GRID
1131
 #endif // AUTO_BED_LEVELING_GRID
2017
   endstops_hit_on_purpose();
2012
   endstops_hit_on_purpose();
2018
 }
2013
 }
2019
 
2014
 
2020
-#if defined(MESH_BED_LEVELING)
2015
+#ifdef MESH_BED_LEVELING
2021
 
2016
 
2017
+  /**
2018
+   * G29: Mesh-based Z-Probe, probes a grid and produces a
2019
+   *      mesh to compensate for variable bed height
2020
+   *
2021
+   * Parameters With MESH_BED_LEVELING:
2022
+   *
2023
+   *  S0 Produce a mesh report
2024
+   *  S1 Start probing mesh points
2025
+   *  S2 Probe the next mesh point
2026
+   *
2027
+   */
2022
   inline void gcode_G29() {
2028
   inline void gcode_G29() {
2023
     static int probe_point = -1;
2029
     static int probe_point = -1;
2024
     int state = 0;
2030
     int state = 0;
2060
     } else if (state == 2) { // Goto next point
2066
     } else if (state == 2) { // Goto next point
2061
 
2067
 
2062
       if (probe_point < 0) {
2068
       if (probe_point < 0) {
2063
-        SERIAL_PROTOCOLPGM("Mesh probing not started.\n");
2069
+        SERIAL_PROTOCOLPGM("Start mesh probing with \"G29 S1\" first.\n");
2064
         return;
2070
         return;
2065
       }
2071
       }
2066
       int ix, iy;
2072
       int ix, iy;
2070
       } else {
2076
       } else {
2071
         ix = (probe_point-1) % MESH_NUM_X_POINTS;
2077
         ix = (probe_point-1) % MESH_NUM_X_POINTS;
2072
         iy = (probe_point-1) / MESH_NUM_X_POINTS;
2078
         iy = (probe_point-1) / MESH_NUM_X_POINTS;
2073
-        if (iy&1) { // Zig zag
2074
-          ix = (MESH_NUM_X_POINTS - 1) - ix;
2075
-        }
2079
+        if (iy & 1) ix = (MESH_NUM_X_POINTS - 1) - ix; // zig-zag
2076
         mbl.set_z(ix, iy, current_position[Z_AXIS]);
2080
         mbl.set_z(ix, iy, current_position[Z_AXIS]);
2077
         current_position[Z_AXIS] = MESH_HOME_SEARCH_Z;
2081
         current_position[Z_AXIS] = MESH_HOME_SEARCH_Z;
2078
         plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], homing_feedrate[X_AXIS]/60, active_extruder);
2082
         plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], homing_feedrate[X_AXIS]/60, active_extruder);
2079
         st_synchronize();
2083
         st_synchronize();
2080
       }
2084
       }
2081
-      if (probe_point == MESH_NUM_X_POINTS*MESH_NUM_Y_POINTS) {
2082
-        SERIAL_PROTOCOLPGM("Mesh done.\n");
2085
+      if (probe_point == MESH_NUM_X_POINTS * MESH_NUM_Y_POINTS) {
2086
+        SERIAL_PROTOCOLPGM("Mesh probing done.\n");
2083
         probe_point = -1;
2087
         probe_point = -1;
2084
         mbl.active = 1;
2088
         mbl.active = 1;
2085
         enquecommands_P(PSTR("G28"));
2089
         enquecommands_P(PSTR("G28"));
2087
       }
2091
       }
2088
       ix = probe_point % MESH_NUM_X_POINTS;
2092
       ix = probe_point % MESH_NUM_X_POINTS;
2089
       iy = probe_point / MESH_NUM_X_POINTS;
2093
       iy = probe_point / MESH_NUM_X_POINTS;
2090
-      if (iy&1) { // Zig zag
2091
-        ix = (MESH_NUM_X_POINTS - 1) - ix;
2092
-      }
2094
+      if (iy & 1) ix = (MESH_NUM_X_POINTS - 1) - ix; // zig-zag
2093
       current_position[X_AXIS] = mbl.get_x(ix);
2095
       current_position[X_AXIS] = mbl.get_x(ix);
2094
       current_position[Y_AXIS] = mbl.get_y(iy);
2096
       current_position[Y_AXIS] = mbl.get_y(iy);
2095
       plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], homing_feedrate[X_AXIS]/60, active_extruder);
2097
       plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], homing_feedrate[X_AXIS]/60, active_extruder);
2098
     }
2100
     }
2099
   }
2101
   }
2100
 
2102
 
2101
-#endif
2102
-
2103
-#ifdef ENABLE_AUTO_BED_LEVELING
2103
+#elif defined(ENABLE_AUTO_BED_LEVELING)
2104
 
2104
 
2105
   /**
2105
   /**
2106
    * G29: Detailed Z-Probe, probes the bed at 3 or more points.
2106
    * G29: Detailed Z-Probe, probes the bed at 3 or more points.
2116
    *
2116
    *
2117
    *  S  Set the XY travel speed between probe points (in mm/min)
2117
    *  S  Set the XY travel speed between probe points (in mm/min)
2118
    *
2118
    *
2119
-   *  D  Dry-Run mode. Just evaluate the bed Topology - It does not apply or clean the rotation Matrix
2120
-   *     Useful to check the topology after a first run of G29.
2119
+   *  D  Dry-Run mode. Just evaluate the bed Topology - Don't apply
2120
+   *     or clean the rotation Matrix. Useful to check the topology
2121
+   *     after a first run of G29.
2121
    *
2122
    *
2122
    *  V  Set the verbose level (0-4). Example: "G29 V3"
2123
    *  V  Set the verbose level (0-4). Example: "G29 V3"
2123
    *
2124
    *
2165
 
2166
 
2166
     #ifdef AUTO_BED_LEVELING_GRID
2167
     #ifdef AUTO_BED_LEVELING_GRID
2167
 
2168
 
2168
-    #ifndef DELTA
2169
-      bool do_topography_map = verbose_level > 2 || code_seen('T') || code_seen('t');
2170
-    #endif
2169
+      #ifndef DELTA
2170
+        bool do_topography_map = verbose_level > 2 || code_seen('T') || code_seen('t');
2171
+      #endif
2171
 
2172
 
2172
       if (verbose_level > 0)
2173
       if (verbose_level > 0)
2173
       {
2174
       {
2224
 
2225
 
2225
     #ifdef Z_PROBE_SLED
2226
     #ifdef Z_PROBE_SLED
2226
       dock_sled(false); // engage (un-dock) the probe
2227
       dock_sled(false); // engage (un-dock) the probe
2227
-    #elif defined(Z_PROBE_ALLEN_KEY)
2228
+    #elif defined(Z_PROBE_ALLEN_KEY) //|| defined(SERVO_LEVELING)
2228
       engage_z_probe();
2229
       engage_z_probe();
2229
     #endif
2230
     #endif
2230
 
2231
 
2234
     {
2235
     {
2235
       #ifdef DELTA
2236
       #ifdef DELTA
2236
         reset_bed_level();
2237
         reset_bed_level();
2237
-      #else
2238
-
2239
-      // make sure the bed_level_rotation_matrix is identity or the planner will get it incorectly
2240
-      //vector_3 corrected_position = plan_get_position_mm();
2241
-      //corrected_position.debug("position before G29");
2242
-      plan_bed_level_matrix.set_to_identity();
2243
-      vector_3 uncorrected_position = plan_get_position();
2244
-//    uncorrected_position.debug("position during G29");
2245
-
2246
-      current_position[X_AXIS] = uncorrected_position.x;
2247
-      current_position[Y_AXIS] = uncorrected_position.y;
2248
-      current_position[Z_AXIS] = uncorrected_position.z;
2249
-      plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
2238
+      #else //!DELTA
2239
+
2240
+        // make sure the bed_level_rotation_matrix is identity or the planner will get it incorectly
2241
+        //vector_3 corrected_position = plan_get_position_mm();
2242
+        //corrected_position.debug("position before G29");
2243
+        plan_bed_level_matrix.set_to_identity();
2244
+        vector_3 uncorrected_position = plan_get_position();
2245
+        //uncorrected_position.debug("position during G29");
2246
+        current_position[X_AXIS] = uncorrected_position.x;
2247
+        current_position[Y_AXIS] = uncorrected_position.y;
2248
+        current_position[Z_AXIS] = uncorrected_position.z;
2249
+        plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
2250
 
2250
 
2251
       #endif
2251
       #endif
2252
     }
2252
     }
2261
       const int xGridSpacing = (right_probe_bed_position - left_probe_bed_position) / (auto_bed_leveling_grid_points-1);
2261
       const int xGridSpacing = (right_probe_bed_position - left_probe_bed_position) / (auto_bed_leveling_grid_points-1);
2262
       const int yGridSpacing = (back_probe_bed_position - front_probe_bed_position) / (auto_bed_leveling_grid_points-1);
2262
       const int yGridSpacing = (back_probe_bed_position - front_probe_bed_position) / (auto_bed_leveling_grid_points-1);
2263
 
2263
 
2264
-    #ifndef DELTA
2265
-      // solve the plane equation ax + by + d = z
2266
-      // A is the matrix with rows [x y 1] for all the probed points
2267
-      // B is the vector of the Z positions
2268
-      // the normal vector to the plane is formed by the coefficients of the plane equation in the standard form, which is Vx*x+Vy*y+Vz*z+d = 0
2269
-      // so Vx = -a Vy = -b Vz = 1 (we want the vector facing towards positive Z
2270
-
2271
-      int abl2 = auto_bed_leveling_grid_points * auto_bed_leveling_grid_points;
2272
-
2273
-      double eqnAMatrix[abl2 * 3], // "A" matrix of the linear system of equations
2274
-             eqnBVector[abl2],     // "B" vector of Z points
2275
-             mean = 0.0;
2276
-
2277
-    #else
2278
-      delta_grid_spacing[0] = xGridSpacing;
2279
-      delta_grid_spacing[1] = yGridSpacing;
2280
-
2281
-      float z_offset = Z_PROBE_OFFSET_FROM_EXTRUDER;
2282
-      if (code_seen(axis_codes[Z_AXIS])) z_offset += code_value();
2283
-    #endif
2264
+      #ifdef DELTA
2265
+        delta_grid_spacing[0] = xGridSpacing;
2266
+        delta_grid_spacing[1] = yGridSpacing;
2267
+        float z_offset = Z_PROBE_OFFSET_FROM_EXTRUDER;
2268
+        if (code_seen(axis_codes[Z_AXIS])) z_offset += code_value();
2269
+      #else // !DELTA
2270
+        // solve the plane equation ax + by + d = z
2271
+        // A is the matrix with rows [x y 1] for all the probed points
2272
+        // B is the vector of the Z positions
2273
+        // the normal vector to the plane is formed by the coefficients of the plane equation in the standard form, which is Vx*x+Vy*y+Vz*z+d = 0
2274
+        // so Vx = -a Vy = -b Vz = 1 (we want the vector facing towards positive Z
2275
+
2276
+        int abl2 = auto_bed_leveling_grid_points * auto_bed_leveling_grid_points;
2277
+
2278
+        double eqnAMatrix[abl2 * 3], // "A" matrix of the linear system of equations
2279
+               eqnBVector[abl2],     // "B" vector of Z points
2280
+               mean = 0.0;
2281
+      #endif // !DELTA
2284
 
2282
 
2285
       int probePointCounter = 0;
2283
       int probePointCounter = 0;
2286
       bool zig = true;
2284
       bool zig = true;
2313
           float measured_z,
2311
           float measured_z,
2314
                 z_before = probePointCounter == 0 ? Z_RAISE_BEFORE_PROBING : current_position[Z_AXIS] + Z_RAISE_BETWEEN_PROBINGS;
2312
                 z_before = probePointCounter == 0 ? Z_RAISE_BEFORE_PROBING : current_position[Z_AXIS] + Z_RAISE_BETWEEN_PROBINGS;
2315
 
2313
 
2316
-        #ifdef DELTA
2317
-          // Avoid probing the corners (outside the round or hexagon print surface) on a delta printer.
2318
-          float distance_from_center = sqrt(xProbe*xProbe + yProbe*yProbe);
2319
-          if (distance_from_center > DELTA_PROBABLE_RADIUS)
2320
-            continue;
2321
-        #endif //DELTA
2314
+          #ifdef DELTA
2315
+            // Avoid probing the corners (outside the round or hexagon print surface) on a delta printer.
2316
+            float distance_from_center = sqrt(xProbe*xProbe + yProbe*yProbe);
2317
+            if (distance_from_center > DELTA_PROBABLE_RADIUS)
2318
+              continue;
2319
+          #endif //DELTA
2322
 
2320
 
2323
           // Enhanced G29 - Do not retract servo between probes
2321
           // Enhanced G29 - Do not retract servo between probes
2324
           ProbeAction act;
2322
           ProbeAction act;
2335
 
2333
 
2336
           measured_z = probe_pt(xProbe, yProbe, z_before, act, verbose_level);
2334
           measured_z = probe_pt(xProbe, yProbe, z_before, act, verbose_level);
2337
 
2335
 
2338
-        #ifndef DELTA
2339
-          mean += measured_z;
2336
+          #ifndef DELTA
2337
+            mean += measured_z;
2340
 
2338
 
2341
-          eqnBVector[probePointCounter] = measured_z;
2342
-          eqnAMatrix[probePointCounter + 0 * abl2] = xProbe;
2343
-          eqnAMatrix[probePointCounter + 1 * abl2] = yProbe;
2344
-          eqnAMatrix[probePointCounter + 2 * abl2] = 1;
2345
-        #else
2346
-          bed_level[xCount][yCount] = measured_z + z_offset;
2347
-        #endif
2339
+            eqnBVector[probePointCounter] = measured_z;
2340
+            eqnAMatrix[probePointCounter + 0 * abl2] = xProbe;
2341
+            eqnAMatrix[probePointCounter + 1 * abl2] = yProbe;
2342
+            eqnAMatrix[probePointCounter + 2 * abl2] = 1;
2343
+          #else
2344
+            bed_level[xCount][yCount] = measured_z + z_offset;
2345
+          #endif
2348
 
2346
 
2349
           probePointCounter++;
2347
           probePointCounter++;
2350
         } //xProbe
2348
         } //xProbe
2352
 
2350
 
2353
       clean_up_after_endstop_move();
2351
       clean_up_after_endstop_move();
2354
 
2352
 
2355
-    #ifndef DELTA
2356
-      // solve lsq problem
2357
-      double *plane_equation_coefficients = qr_solve(abl2, 3, eqnAMatrix, eqnBVector);
2358
-
2359
-      mean /= abl2;
2360
-
2361
-      if (verbose_level) {
2362
-        SERIAL_PROTOCOLPGM("Eqn coefficients: a: ");
2363
-        SERIAL_PROTOCOL_F(plane_equation_coefficients[0], 8);
2364
-        SERIAL_PROTOCOLPGM(" b: ");
2365
-        SERIAL_PROTOCOL_F(plane_equation_coefficients[1], 8);
2366
-        SERIAL_PROTOCOLPGM(" d: ");
2367
-        SERIAL_PROTOCOL_F(plane_equation_coefficients[2], 8);
2368
-        SERIAL_EOL;
2369
-        if (verbose_level > 2) {
2370
-          SERIAL_PROTOCOLPGM("Mean of sampled points: ");
2371
-          SERIAL_PROTOCOL_F(mean, 8);
2353
+      #ifdef DELTA
2354
+
2355
+        if (!dryrun) extrapolate_unprobed_bed_level();
2356
+        print_bed_level();
2357
+
2358
+      #else // !DELTA
2359
+
2360
+        // solve lsq problem
2361
+        double *plane_equation_coefficients = qr_solve(abl2, 3, eqnAMatrix, eqnBVector);
2362
+
2363
+        mean /= abl2;
2364
+
2365
+        if (verbose_level) {
2366
+          SERIAL_PROTOCOLPGM("Eqn coefficients: a: ");
2367
+          SERIAL_PROTOCOL_F(plane_equation_coefficients[0], 8);
2368
+          SERIAL_PROTOCOLPGM(" b: ");
2369
+          SERIAL_PROTOCOL_F(plane_equation_coefficients[1], 8);
2370
+          SERIAL_PROTOCOLPGM(" d: ");
2371
+          SERIAL_PROTOCOL_F(plane_equation_coefficients[2], 8);
2372
           SERIAL_EOL;
2372
           SERIAL_EOL;
2373
+          if (verbose_level > 2) {
2374
+            SERIAL_PROTOCOLPGM("Mean of sampled points: ");
2375
+            SERIAL_PROTOCOL_F(mean, 8);
2376
+            SERIAL_EOL;
2377
+          }
2373
         }
2378
         }
2374
-      }
2375
 
2379
 
2376
-      // Show the Topography map if enabled
2377
-      if (do_topography_map) {
2378
-
2379
-        SERIAL_PROTOCOLPGM(" \nBed Height Topography: \n");
2380
-        SERIAL_PROTOCOLPGM("+-----------+\n");
2381
-        SERIAL_PROTOCOLPGM("|...Back....|\n");
2382
-        SERIAL_PROTOCOLPGM("|Left..Right|\n");
2383
-        SERIAL_PROTOCOLPGM("|...Front...|\n");
2384
-        SERIAL_PROTOCOLPGM("+-----------+\n");
2385
-
2386
-        for (int yy = auto_bed_leveling_grid_points - 1; yy >= 0; yy--) {
2387
-          for (int xx = 0; xx < auto_bed_leveling_grid_points; xx++) {
2388
-            int ind = yy * auto_bed_leveling_grid_points + xx;
2389
-            float diff = eqnBVector[ind] - mean;
2390
-            if (diff >= 0.0)
2391
-              SERIAL_PROTOCOLPGM(" +");   // Include + for column alignment
2392
-            else
2393
-              SERIAL_PROTOCOLPGM(" ");
2394
-            SERIAL_PROTOCOL_F(diff, 5);
2395
-          } // xx
2380
+        // Show the Topography map if enabled
2381
+        if (do_topography_map) {
2382
+
2383
+          SERIAL_PROTOCOLPGM(" \nBed Height Topography: \n");
2384
+          SERIAL_PROTOCOLPGM("+-----------+\n");
2385
+          SERIAL_PROTOCOLPGM("|...Back....|\n");
2386
+          SERIAL_PROTOCOLPGM("|Left..Right|\n");
2387
+          SERIAL_PROTOCOLPGM("|...Front...|\n");
2388
+          SERIAL_PROTOCOLPGM("+-----------+\n");
2389
+
2390
+          for (int yy = auto_bed_leveling_grid_points - 1; yy >= 0; yy--) {
2391
+            for (int xx = 0; xx < auto_bed_leveling_grid_points; xx++) {
2392
+              int ind = yy * auto_bed_leveling_grid_points + xx;
2393
+              float diff = eqnBVector[ind] - mean;
2394
+              if (diff >= 0.0)
2395
+                SERIAL_PROTOCOLPGM(" +");   // Include + for column alignment
2396
+              else
2397
+                SERIAL_PROTOCOLPGM(" ");
2398
+              SERIAL_PROTOCOL_F(diff, 5);
2399
+            } // xx
2400
+            SERIAL_EOL;
2401
+          } // yy
2396
           SERIAL_EOL;
2402
           SERIAL_EOL;
2397
-        } // yy
2398
-        SERIAL_EOL;
2399
 
2403
 
2400
-      } //do_topography_map
2404
+        } //do_topography_map
2405
+
2401
 
2406
 
2407
+        if (!dryrun) set_bed_level_equation_lsq(plane_equation_coefficients);
2408
+        free(plane_equation_coefficients);
2402
 
2409
 
2403
-      if (!dryrun) set_bed_level_equation_lsq(plane_equation_coefficients);
2404
-      free(plane_equation_coefficients);
2405
-    #else //Delta
2406
-      if (!dryrun) extrapolate_unprobed_bed_level();
2407
-      print_bed_level();
2408
-    #endif //Delta
2410
+      #endif //!DELTA
2409
 
2411
 
2410
     #else // !AUTO_BED_LEVELING_GRID
2412
     #else // !AUTO_BED_LEVELING_GRID
2411
 
2413
 
2428
 
2430
 
2429
     #endif // !AUTO_BED_LEVELING_GRID
2431
     #endif // !AUTO_BED_LEVELING_GRID
2430
 
2432
 
2431
-  #ifndef DELTA
2432
-    if (verbose_level > 0) plan_bed_level_matrix.debug(" \n\nBed Level Correction Matrix:");
2433
+    #ifndef DELTA
2434
+      if (verbose_level > 0)
2435
+        plan_bed_level_matrix.debug(" \n\nBed Level Correction Matrix:");
2433
 
2436
 
2434
-    // Correct the Z height difference from z-probe position and hotend tip position.
2435
-    // The Z height on homing is measured by Z-Probe, but the probe is quite far from the hotend.
2436
-    // When the bed is uneven, this height must be corrected.
2437
-    if (!dryrun)
2438
-    {
2439
-      real_z = float(st_get_position(Z_AXIS)) / axis_steps_per_unit[Z_AXIS];  //get the real Z (since the auto bed leveling is already correcting the plane)
2440
-      x_tmp = current_position[X_AXIS] + X_PROBE_OFFSET_FROM_EXTRUDER;
2441
-      y_tmp = current_position[Y_AXIS] + Y_PROBE_OFFSET_FROM_EXTRUDER;
2442
-      z_tmp = current_position[Z_AXIS];
2437
+      // Correct the Z height difference from z-probe position and hotend tip position.
2438
+      // The Z height on homing is measured by Z-Probe, but the probe is quite far from the hotend.
2439
+      // When the bed is uneven, this height must be corrected.
2440
+      if (!dryrun)
2441
+      {
2442
+        real_z = float(st_get_position(Z_AXIS)) / axis_steps_per_unit[Z_AXIS];  //get the real Z (since the auto bed leveling is already correcting the plane)
2443
+        x_tmp = current_position[X_AXIS] + X_PROBE_OFFSET_FROM_EXTRUDER;
2444
+        y_tmp = current_position[Y_AXIS] + Y_PROBE_OFFSET_FROM_EXTRUDER;
2445
+        z_tmp = current_position[Z_AXIS];
2443
 
2446
 
2444
-      apply_rotation_xyz(plan_bed_level_matrix, x_tmp, y_tmp, z_tmp);         //Apply the correction sending the probe offset
2445
-      current_position[Z_AXIS] = z_tmp - real_z + current_position[Z_AXIS];   //The difference is added to current position and sent to planner.
2446
-      plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
2447
-    }
2448
-  #endif
2447
+        apply_rotation_xyz(plan_bed_level_matrix, x_tmp, y_tmp, z_tmp);         //Apply the correction sending the probe offset
2448
+        current_position[Z_AXIS] = z_tmp - real_z + current_position[Z_AXIS];   //The difference is added to current position and sent to planner.
2449
+        plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
2450
+      }
2451
+    #endif // !DELTA
2449
 
2452
 
2450
-  #ifdef Z_PROBE_SLED
2451
-    dock_sled(true, -SLED_DOCKING_OFFSET); // dock the probe, correcting for over-travel
2452
-  #elif defined(Z_PROBE_ALLEN_KEY)
2453
-    retract_z_probe();
2454
-  #endif
2455
-    
2456
-  #ifdef Z_PROBE_END_SCRIPT
2457
-    enquecommands_P(PSTR(Z_PROBE_END_SCRIPT));
2458
-    st_synchronize();
2459
-  #endif
2453
+    #ifdef Z_PROBE_SLED
2454
+      dock_sled(true, -SLED_DOCKING_OFFSET); // dock the probe, correcting for over-travel
2455
+    #elif defined(Z_PROBE_ALLEN_KEY) //|| defined(SERVO_LEVELING)
2456
+      retract_z_probe();
2457
+    #endif
2458
+
2459
+    #ifdef Z_PROBE_END_SCRIPT
2460
+      enquecommands_P(PSTR(Z_PROBE_END_SCRIPT));
2461
+      st_synchronize();
2462
+    #endif
2460
   }
2463
   }
2461
 
2464
 
2462
   #ifndef Z_PROBE_SLED
2465
   #ifndef Z_PROBE_SLED
2919
       do_blocking_move_to( X_probe_location, Y_probe_location, Z_start_location); // Make sure we are at the probe location
2922
       do_blocking_move_to( X_probe_location, Y_probe_location, Z_start_location); // Make sure we are at the probe location
2920
 
2923
 
2921
       if (n_legs) {
2924
       if (n_legs) {
2922
-        double radius=0.0, theta=0.0, x_sweep, y_sweep;
2925
+        double radius=0.0, theta=0.0;
2923
         int l;
2926
         int l;
2924
         int rotational_direction = (unsigned long) millis() & 0x0001;     // clockwise or counter clockwise
2927
         int rotational_direction = (unsigned long) millis() & 0x0001;     // clockwise or counter clockwise
2925
         radius = (unsigned long)millis() % (long)(X_MAX_LENGTH / 4);      // limit how far out to go
2928
         radius = (unsigned long)millis() % (long)(X_MAX_LENGTH / 4);      // limit how far out to go
3545
     }
3548
     }
3546
   }
3549
   }
3547
 
3550
 
3548
-  float area = .0;
3549
   if (code_seen('D')) {
3551
   if (code_seen('D')) {
3550
     float diameter = code_value();
3552
     float diameter = code_value();
3551
     // setting any extruder filament size disables volumetric on the assumption that
3553
     // setting any extruder filament size disables volumetric on the assumption that
4283
  * M503: print settings currently in memory
4285
  * M503: print settings currently in memory
4284
  */
4286
  */
4285
 inline void gcode_M503() {
4287
 inline void gcode_M503() {
4286
-  Config_PrintSettings(code_seen('S') && code_value == 0);
4288
+  Config_PrintSettings(code_seen('S') && code_value() == 0);
4287
 }
4289
 }
4288
 
4290
 
4289
 #ifdef ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED
4291
 #ifdef ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED
4580
     SERIAL_ECHOLN(MSG_INVALID_EXTRUDER);
4582
     SERIAL_ECHOLN(MSG_INVALID_EXTRUDER);
4581
   }
4583
   }
4582
   else {
4584
   else {
4583
-    boolean make_move = false;
4585
+    #if EXTRUDERS > 1
4586
+      bool make_move = false;
4587
+    #endif
4588
+
4584
     if (code_seen('F')) {
4589
     if (code_seen('F')) {
4585
-      make_move = true;
4590
+      #if EXTRUDERS > 1
4591
+        make_move = true;
4592
+      #endif
4586
       next_feedrate = code_value();
4593
       next_feedrate = code_value();
4587
       if (next_feedrate > 0.0) feedrate = next_feedrate;
4594
       if (next_feedrate > 0.0) feedrate = next_feedrate;
4588
     }
4595
     }
5179
   SERIAL_PROTOCOLLNPGM(MSG_OK);
5186
   SERIAL_PROTOCOLLNPGM(MSG_OK);
5180
 }
5187
 }
5181
 
5188
 
5182
-void get_coordinates()
5183
-{
5184
-  bool seen[4]={false,false,false,false};
5185
-  for(int8_t i=0; i < NUM_AXIS; i++) {
5186
-    if(code_seen(axis_codes[i]))
5187
-    {
5188
-      destination[i] = (float)code_value() + (axis_relative_modes[i] || relative_mode)*current_position[i];
5189
-      seen[i]=true;
5189
+void get_coordinates() {
5190
+  for (int i = 0; i < NUM_AXIS; i++) {
5191
+    float dest;
5192
+    if (code_seen(axis_codes[i])) {
5193
+      dest = code_value();
5194
+      if (axis_relative_modes[i] || relative_mode)
5195
+        dest += current_position[i];
5190
     }
5196
     }
5191
-    else destination[i] = current_position[i]; //Are these else lines really needed?
5197
+    else
5198
+      dest = current_position[i];
5199
+
5200
+    destination[i] = dest;
5192
   }
5201
   }
5193
-  if(code_seen('F')) {
5202
+  if (code_seen('F')) {
5194
     next_feedrate = code_value();
5203
     next_feedrate = code_value();
5195
-    if(next_feedrate > 0.0) feedrate = next_feedrate;
5204
+    if (next_feedrate > 0.0) feedrate = next_feedrate;
5196
   }
5205
   }
5197
 }
5206
 }
5198
 
5207
 

+ 4
- 4
Marlin/SanityCheck.h View File

104
 
104
 
105
       // Make sure probing points are reachable
105
       // Make sure probing points are reachable
106
       #if LEFT_PROBE_BED_POSITION < MIN_PROBE_X
106
       #if LEFT_PROBE_BED_POSITION < MIN_PROBE_X
107
-        #error The given LEFT_PROBE_BED_POSITION can not be reached by the probe.
107
+        #error "The given LEFT_PROBE_BED_POSITION can't be reached by the probe."
108
       #elif RIGHT_PROBE_BED_POSITION > MAX_PROBE_X
108
       #elif RIGHT_PROBE_BED_POSITION > MAX_PROBE_X
109
-        #error The given RIGHT_PROBE_BED_POSITION can not be reached by the probe.
109
+        #error "The given RIGHT_PROBE_BED_POSITION can't be reached by the probe."
110
       #elif FRONT_PROBE_BED_POSITION < MIN_PROBE_Y
110
       #elif FRONT_PROBE_BED_POSITION < MIN_PROBE_Y
111
-        #error The given FRONT_PROBE_BED_POSITION can not be reached by the probe.
111
+        #error "The given FRONT_PROBE_BED_POSITION can't be reached by the probe."
112
       #elif BACK_PROBE_BED_POSITION > MAX_PROBE_Y
112
       #elif BACK_PROBE_BED_POSITION > MAX_PROBE_Y
113
-        #error The given BACK_PROBE_BED_POSITION can not be reached by the probe.
113
+        #error "The given BACK_PROBE_BED_POSITION can't be reached by the probe."
114
       #endif
114
       #endif
115
 
115
 
116
       #define PROBE_SIZE_X (X_PROBE_OFFSET_FROM_EXTRUDER * (AUTO_BED_LEVELING_GRID_POINTS-1))
116
       #define PROBE_SIZE_X (X_PROBE_OFFSET_FROM_EXTRUDER * (AUTO_BED_LEVELING_GRID_POINTS-1))

+ 5
- 3
Marlin/configurator/config/Configuration.h View File

569
 // Custom M code points
569
 // Custom M code points
570
 #define CUSTOM_M_CODES
570
 #define CUSTOM_M_CODES
571
 #ifdef CUSTOM_M_CODES
571
 #ifdef CUSTOM_M_CODES
572
-  #define CUSTOM_M_CODE_SET_Z_PROBE_OFFSET 851
573
-  #define Z_PROBE_OFFSET_RANGE_MIN -15
574
-  #define Z_PROBE_OFFSET_RANGE_MAX -5
572
+  #ifdef ENABLE_AUTO_BED_LEVELING
573
+    #define CUSTOM_M_CODE_SET_Z_PROBE_OFFSET 851
574
+    #define Z_PROBE_OFFSET_RANGE_MIN -15
575
+    #define Z_PROBE_OFFSET_RANGE_MAX -5
576
+  #endif
575
 #endif
577
 #endif
576
 
578
 
577
 // @section extras
579
 // @section extras

+ 5
- 3
Marlin/example_configurations/Felix/Configuration.h View File

511
 // Custom M code points
511
 // Custom M code points
512
 #define CUSTOM_M_CODES
512
 #define CUSTOM_M_CODES
513
 #ifdef CUSTOM_M_CODES
513
 #ifdef CUSTOM_M_CODES
514
-  #define CUSTOM_M_CODE_SET_Z_PROBE_OFFSET 851
515
-  #define Z_PROBE_OFFSET_RANGE_MIN -15
516
-  #define Z_PROBE_OFFSET_RANGE_MAX -5
514
+  #ifdef ENABLE_AUTO_BED_LEVELING
515
+    #define CUSTOM_M_CODE_SET_Z_PROBE_OFFSET 851
516
+    #define Z_PROBE_OFFSET_RANGE_MIN -15
517
+    #define Z_PROBE_OFFSET_RANGE_MAX -5
518
+  #endif
517
 #endif
519
 #endif
518
 
520
 
519
 
521
 

+ 5
- 3
Marlin/example_configurations/Felix/Configuration_DUAL.h View File

511
 // Custom M code points
511
 // Custom M code points
512
 #define CUSTOM_M_CODES
512
 #define CUSTOM_M_CODES
513
 #ifdef CUSTOM_M_CODES
513
 #ifdef CUSTOM_M_CODES
514
-  #define CUSTOM_M_CODE_SET_Z_PROBE_OFFSET 851
515
-  #define Z_PROBE_OFFSET_RANGE_MIN -15
516
-  #define Z_PROBE_OFFSET_RANGE_MAX -5
514
+  #ifdef ENABLE_AUTO_BED_LEVELING
515
+    #define CUSTOM_M_CODE_SET_Z_PROBE_OFFSET 851
516
+    #define Z_PROBE_OFFSET_RANGE_MIN -15
517
+    #define Z_PROBE_OFFSET_RANGE_MAX -5
518
+  #endif
517
 #endif
519
 #endif
518
 
520
 
519
 
521
 

+ 5
- 3
Marlin/example_configurations/Hephestos/Configuration.h View File

539
 // Custom M code points
539
 // Custom M code points
540
 #define CUSTOM_M_CODES
540
 #define CUSTOM_M_CODES
541
 #ifdef CUSTOM_M_CODES
541
 #ifdef CUSTOM_M_CODES
542
-  #define CUSTOM_M_CODE_SET_Z_PROBE_OFFSET 851
543
-  #define Z_PROBE_OFFSET_RANGE_MIN -15
544
-  #define Z_PROBE_OFFSET_RANGE_MAX -5
542
+  #ifdef ENABLE_AUTO_BED_LEVELING
543
+    #define CUSTOM_M_CODE_SET_Z_PROBE_OFFSET 851
544
+    #define Z_PROBE_OFFSET_RANGE_MIN -15
545
+    #define Z_PROBE_OFFSET_RANGE_MAX -5
546
+  #endif
545
 #endif
547
 #endif
546
 
548
 
547
 
549
 

+ 5
- 3
Marlin/example_configurations/K8200/Configuration.h View File

543
 // Custom M code points
543
 // Custom M code points
544
 #define CUSTOM_M_CODES
544
 #define CUSTOM_M_CODES
545
 #ifdef CUSTOM_M_CODES
545
 #ifdef CUSTOM_M_CODES
546
-  #define CUSTOM_M_CODE_SET_Z_PROBE_OFFSET 851
547
-  #define Z_PROBE_OFFSET_RANGE_MIN -15
548
-  #define Z_PROBE_OFFSET_RANGE_MAX -5
546
+  #ifdef ENABLE_AUTO_BED_LEVELING
547
+    #define CUSTOM_M_CODE_SET_Z_PROBE_OFFSET 851
548
+    #define Z_PROBE_OFFSET_RANGE_MIN -15
549
+    #define Z_PROBE_OFFSET_RANGE_MAX -5
550
+  #endif
549
 #endif
551
 #endif
550
 
552
 
551
 
553
 

+ 5
- 3
Marlin/example_configurations/SCARA/Configuration.h View File

569
 // Custom M code points
569
 // Custom M code points
570
 //#define CUSTOM_M_CODES
570
 //#define CUSTOM_M_CODES
571
 #ifdef CUSTOM_M_CODES
571
 #ifdef CUSTOM_M_CODES
572
-  #define CUSTOM_M_CODE_SET_Z_PROBE_OFFSET 851
573
-  #define Z_PROBE_OFFSET_RANGE_MIN -15
574
-  #define Z_PROBE_OFFSET_RANGE_MAX -5
572
+  #ifdef ENABLE_AUTO_BED_LEVELING
573
+    #define CUSTOM_M_CODE_SET_Z_PROBE_OFFSET 851
574
+    #define Z_PROBE_OFFSET_RANGE_MIN -15
575
+    #define Z_PROBE_OFFSET_RANGE_MAX -5
576
+  #endif
575
 #endif
577
 #endif
576
 
578
 
577
 
579
 

+ 5
- 3
Marlin/example_configurations/WITBOX/Configuration.h View File

536
 // Custom M code points
536
 // Custom M code points
537
 #define CUSTOM_M_CODES
537
 #define CUSTOM_M_CODES
538
 #ifdef CUSTOM_M_CODES
538
 #ifdef CUSTOM_M_CODES
539
-  #define CUSTOM_M_CODE_SET_Z_PROBE_OFFSET 851
540
-  #define Z_PROBE_OFFSET_RANGE_MIN -15
541
-  #define Z_PROBE_OFFSET_RANGE_MAX -5
539
+  #ifdef ENABLE_AUTO_BED_LEVELING
540
+    #define CUSTOM_M_CODE_SET_Z_PROBE_OFFSET 851
541
+    #define Z_PROBE_OFFSET_RANGE_MIN -15
542
+    #define Z_PROBE_OFFSET_RANGE_MAX -5
543
+  #endif
542
 #endif
544
 #endif
543
 
545
 
544
 
546
 

+ 5
- 3
Marlin/example_configurations/delta/generic/Configuration.h View File

552
 // Custom M code points
552
 // Custom M code points
553
 #define CUSTOM_M_CODES
553
 #define CUSTOM_M_CODES
554
 #ifdef CUSTOM_M_CODES
554
 #ifdef CUSTOM_M_CODES
555
-  #define CUSTOM_M_CODE_SET_Z_PROBE_OFFSET 851
556
-  #define Z_PROBE_OFFSET_RANGE_MIN -15
557
-  #define Z_PROBE_OFFSET_RANGE_MAX -5
555
+  #ifdef ENABLE_AUTO_BED_LEVELING
556
+    #define CUSTOM_M_CODE_SET_Z_PROBE_OFFSET 851
557
+    #define Z_PROBE_OFFSET_RANGE_MIN -15
558
+    #define Z_PROBE_OFFSET_RANGE_MAX -5
559
+  #endif
558
 #endif
560
 #endif
559
 
561
 
560
 
562
 

+ 5
- 3
Marlin/example_configurations/delta/kossel_mini/Configuration.h View File

554
 // Custom M code points
554
 // Custom M code points
555
 #define CUSTOM_M_CODES
555
 #define CUSTOM_M_CODES
556
 #ifdef CUSTOM_M_CODES
556
 #ifdef CUSTOM_M_CODES
557
-  #define CUSTOM_M_CODE_SET_Z_PROBE_OFFSET 851
558
-  #define Z_PROBE_OFFSET_RANGE_MIN -15
559
-  #define Z_PROBE_OFFSET_RANGE_MAX -5
557
+  #ifdef ENABLE_AUTO_BED_LEVELING
558
+    #define CUSTOM_M_CODE_SET_Z_PROBE_OFFSET 851
559
+    #define Z_PROBE_OFFSET_RANGE_MIN -15
560
+    #define Z_PROBE_OFFSET_RANGE_MAX -5
561
+  #endif
560
 #endif
562
 #endif
561
 
563
 
562
 
564
 

+ 5
- 3
Marlin/example_configurations/makibox/Configuration.h View File

534
 // Custom M code points
534
 // Custom M code points
535
 #define CUSTOM_M_CODES
535
 #define CUSTOM_M_CODES
536
 #ifdef CUSTOM_M_CODES
536
 #ifdef CUSTOM_M_CODES
537
-  #define CUSTOM_M_CODE_SET_Z_PROBE_OFFSET 851
538
-  #define Z_PROBE_OFFSET_RANGE_MIN -15
539
-  #define Z_PROBE_OFFSET_RANGE_MAX -5
537
+  #ifdef ENABLE_AUTO_BED_LEVELING
538
+    #define CUSTOM_M_CODE_SET_Z_PROBE_OFFSET 851
539
+    #define Z_PROBE_OFFSET_RANGE_MIN -15
540
+    #define Z_PROBE_OFFSET_RANGE_MAX -5
541
+  #endif
540
 #endif
542
 #endif
541
 
543
 
542
 
544
 

+ 5
- 3
Marlin/example_configurations/tvrrug/Round2/Configuration.h View File

541
 // Custom M code points
541
 // Custom M code points
542
 #define CUSTOM_M_CODES
542
 #define CUSTOM_M_CODES
543
 #ifdef CUSTOM_M_CODES
543
 #ifdef CUSTOM_M_CODES
544
-  #define CUSTOM_M_CODE_SET_Z_PROBE_OFFSET 851
545
-  #define Z_PROBE_OFFSET_RANGE_MIN -15
546
-  #define Z_PROBE_OFFSET_RANGE_MAX -5
544
+  #ifdef ENABLE_AUTO_BED_LEVELING
545
+    #define CUSTOM_M_CODE_SET_Z_PROBE_OFFSET 851
546
+    #define Z_PROBE_OFFSET_RANGE_MIN -15
547
+    #define Z_PROBE_OFFSET_RANGE_MAX -5
548
+  #endif
547
 #endif
549
 #endif
548
 
550
 
549
 
551
 

+ 9
- 13
Marlin/mesh_bed_leveling.cpp View File

1
 #include "mesh_bed_leveling.h"
1
 #include "mesh_bed_leveling.h"
2
 
2
 
3
-#if defined(MESH_BED_LEVELING)
3
+#ifdef MESH_BED_LEVELING
4
 
4
 
5
-mesh_bed_leveling mbl;
5
+  mesh_bed_leveling mbl;
6
 
6
 
7
-mesh_bed_leveling::mesh_bed_leveling() {
8
-    reset();
9
-}
10
-    
11
-void mesh_bed_leveling::reset() {
12
-    for (int y=0; y<MESH_NUM_Y_POINTS; y++) {
13
-        for (int x=0; x<MESH_NUM_X_POINTS; x++) {
14
-            z_values[y][x] = 0;
15
-        }
16
-    }
7
+  mesh_bed_leveling::mesh_bed_leveling() { reset(); }
8
+      
9
+  void mesh_bed_leveling::reset() {
17
     active = 0;
10
     active = 0;
18
-}
11
+    for (int y = 0; y < MESH_NUM_Y_POINTS; y++)
12
+      for (int x = 0; x < MESH_NUM_X_POINTS; x++)
13
+        z_values[y][x] = 0;
14
+  }
19
 
15
 
20
 #endif  // MESH_BED_LEVELING
16
 #endif  // MESH_BED_LEVELING

+ 29
- 33
Marlin/mesh_bed_leveling.h View File

2
 
2
 
3
 #if defined(MESH_BED_LEVELING)
3
 #if defined(MESH_BED_LEVELING)
4
 
4
 
5
-#define MESH_X_DIST ((MESH_MAX_X - MESH_MIN_X)/(MESH_NUM_X_POINTS - 1))
6
-#define MESH_Y_DIST ((MESH_MAX_Y - MESH_MIN_Y)/(MESH_NUM_Y_POINTS - 1))
5
+  #define MESH_X_DIST ((MESH_MAX_X - MESH_MIN_X)/(MESH_NUM_X_POINTS - 1))
6
+  #define MESH_Y_DIST ((MESH_MAX_Y - MESH_MIN_Y)/(MESH_NUM_Y_POINTS - 1))
7
 
7
 
8
-class mesh_bed_leveling {
9
-public:
8
+  class mesh_bed_leveling {
9
+  public:
10
     uint8_t active;
10
     uint8_t active;
11
     float z_values[MESH_NUM_Y_POINTS][MESH_NUM_X_POINTS];
11
     float z_values[MESH_NUM_Y_POINTS][MESH_NUM_X_POINTS];
12
     
12
     
14
     
14
     
15
     void reset();
15
     void reset();
16
     
16
     
17
-    float get_x(int i) { return MESH_MIN_X + MESH_X_DIST*i; }
18
-    float get_y(int i) { return MESH_MIN_Y + MESH_Y_DIST*i; }
17
+    float get_x(int i) { return MESH_MIN_X + MESH_X_DIST * i; }
18
+    float get_y(int i) { return MESH_MIN_Y + MESH_Y_DIST * i; }
19
     void set_z(int ix, int iy, float z) { z_values[iy][ix] = z; }
19
     void set_z(int ix, int iy, float z) { z_values[iy][ix] = z; }
20
     
20
     
21
     int select_x_index(float x) {
21
     int select_x_index(float x) {
22
-        int i = 1;
23
-        while (x > get_x(i) && i < MESH_NUM_X_POINTS-1) {
24
-            i++;
25
-        }
26
-        return i-1;
22
+      int i = 1;
23
+      while (x > get_x(i) && i < MESH_NUM_X_POINTS-1) i++;
24
+      return i - 1;
27
     }
25
     }
28
     
26
     
29
     int select_y_index(float y) {
27
     int select_y_index(float y) {
30
-        int i = 1;
31
-        while (y > get_y(i) && i < MESH_NUM_Y_POINTS-1) {
32
-            i++;
33
-        }
34
-        return i-1;
28
+      int i = 1;
29
+      while (y > get_y(i) && i < MESH_NUM_Y_POINTS - 1) i++;
30
+      return i - 1;
35
     }
31
     }
36
     
32
     
37
     float calc_z0(float a0, float a1, float z1, float a2, float z2) {
33
     float calc_z0(float a0, float a1, float z1, float a2, float z2) {
38
-        float delta_z = (z2 - z1)/(a2 - a1);
39
-        float delta_a = a0 - a1;
40
-        return z1 + delta_a * delta_z;
34
+      float delta_z = (z2 - z1)/(a2 - a1);
35
+      float delta_a = a0 - a1;
36
+      return z1 + delta_a * delta_z;
41
     }
37
     }
42
     
38
     
43
     float get_z(float x0, float y0) {
39
     float get_z(float x0, float y0) {
44
-        int x_index = select_x_index(x0);
45
-        int y_index = select_y_index(y0);
46
-        float z1 = calc_z0(x0,
47
-                           get_x(x_index), z_values[y_index][x_index],
48
-                           get_x(x_index+1), z_values[y_index][x_index+1]);
49
-        float z2 = calc_z0(x0,
50
-                           get_x(x_index), z_values[y_index+1][x_index],
51
-                           get_x(x_index+1), z_values[y_index+1][x_index+1]);
52
-        float z0 = calc_z0(y0,
53
-                           get_y(y_index), z1,
54
-                           get_y(y_index+1), z2);
55
-        return z0;
40
+      int x_index = select_x_index(x0);
41
+      int y_index = select_y_index(y0);
42
+      float z1 = calc_z0(x0,
43
+                         get_x(x_index), z_values[y_index][x_index],
44
+                         get_x(x_index+1), z_values[y_index][x_index+1]);
45
+      float z2 = calc_z0(x0,
46
+                         get_x(x_index), z_values[y_index+1][x_index],
47
+                         get_x(x_index+1), z_values[y_index+1][x_index+1]);
48
+      float z0 = calc_z0(y0,
49
+                         get_y(y_index), z1,
50
+                         get_y(y_index+1), z2);
51
+      return z0;
56
     }
52
     }
57
-};
53
+  };
58
 
54
 
59
-extern mesh_bed_leveling mbl;
55
+  extern mesh_bed_leveling mbl;
60
 
56
 
61
 #endif  // MESH_BED_LEVELING
57
 #endif  // MESH_BED_LEVELING

+ 3
- 3
Marlin/stepper.cpp View File

1176
 }
1176
 }
1177
 
1177
 
1178
 void microstep_init() {
1178
 void microstep_init() {
1179
-  const uint8_t microstep_modes[] = MICROSTEP_MODES;
1180
-
1181
   #if defined(E1_MS1_PIN) && E1_MS1_PIN >= 0
1179
   #if defined(E1_MS1_PIN) && E1_MS1_PIN >= 0
1182
     pinMode(E1_MS1_PIN,OUTPUT);
1180
     pinMode(E1_MS1_PIN,OUTPUT);
1183
     pinMode(E1_MS2_PIN,OUTPUT); 
1181
     pinMode(E1_MS2_PIN,OUTPUT); 
1192
     pinMode(Z_MS2_PIN,OUTPUT);
1190
     pinMode(Z_MS2_PIN,OUTPUT);
1193
     pinMode(E0_MS1_PIN,OUTPUT);
1191
     pinMode(E0_MS1_PIN,OUTPUT);
1194
     pinMode(E0_MS2_PIN,OUTPUT);
1192
     pinMode(E0_MS2_PIN,OUTPUT);
1195
-    for (int i = 0; i <= 4; i++) microstep_mode(i, microstep_modes[i]);
1193
+    const uint8_t microstep_modes[] = MICROSTEP_MODES;
1194
+    for (int i = 0; i < sizeof(microstep_modes) / sizeof(microstep_modes[0]); i++)
1195
+        microstep_mode(i, microstep_modes[i]);
1196
   #endif
1196
   #endif
1197
 }
1197
 }
1198
 
1198
 

+ 3
- 2
Marlin/temperature.cpp View File

1181
   #endif
1181
   #endif
1182
   #if HAS_TEMP_1
1182
   #if HAS_TEMP_1
1183
     #ifdef TEMP_SENSOR_1_AS_REDUNDANT
1183
     #ifdef TEMP_SENSOR_1_AS_REDUNDANT
1184
-      redundant_temperature_raw =
1184
+      redundant_temperature_raw = raw_temp_value[1];
1185
+    #else
1186
+      current_temperature_raw[1] = raw_temp_value[1];
1185
     #endif
1187
     #endif
1186
-    current_temperature_raw[1] = raw_temp_value[1];
1187
     #if HAS_TEMP_2
1188
     #if HAS_TEMP_2
1188
       current_temperature_raw[2] = raw_temp_value[2];
1189
       current_temperature_raw[2] = raw_temp_value[2];
1189
       #if HAS_TEMP_3
1190
       #if HAS_TEMP_3

+ 3
- 3
Marlin/temperature.h View File

41
 
41
 
42
 // low level conversion routines
42
 // low level conversion routines
43
 // do not use these routines and variables outside of temperature.cpp
43
 // do not use these routines and variables outside of temperature.cpp
44
-extern int target_temperature[EXTRUDERS];  
45
-extern float current_temperature[EXTRUDERS];
44
+extern int target_temperature[4];  
45
+extern float current_temperature[4];
46
 #ifdef SHOW_TEMP_ADC_VALUES
46
 #ifdef SHOW_TEMP_ADC_VALUES
47
-  extern int current_temperature_raw[EXTRUDERS];
47
+  extern int current_temperature_raw[4];
48
   extern int current_temperature_bed_raw;
48
   extern int current_temperature_bed_raw;
49
 #endif
49
 #endif
50
 extern int target_temperature_bed;
50
 extern int target_temperature_bed;

+ 1
- 1
Marlin/ultralcd.cpp View File

911
   START_MENU();
911
   START_MENU();
912
   MENU_ITEM(back, MSG_CONTROL, lcd_control_menu);
912
   MENU_ITEM(back, MSG_CONTROL, lcd_control_menu);
913
   #ifdef ENABLE_AUTO_BED_LEVELING
913
   #ifdef ENABLE_AUTO_BED_LEVELING
914
-    MENU_ITEM_EDIT(float32, MSG_ZPROBE_ZOFFSET, &zprobe_zoffset, 0.0, 50);
914
+    MENU_ITEM_EDIT(float32, MSG_ZPROBE_ZOFFSET, &zprobe_zoffset, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX);
915
   #endif
915
   #endif
916
   MENU_ITEM_EDIT(float5, MSG_ACC, &acceleration, 10, 99000);
916
   MENU_ITEM_EDIT(float5, MSG_ACC, &acceleration, 10, 99000);
917
   MENU_ITEM_EDIT(float3, MSG_VXY_JERK, &max_xy_jerk, 1, 990);
917
   MENU_ITEM_EDIT(float3, MSG_VXY_JERK, &max_xy_jerk, 1, 990);

+ 31
- 55
Marlin/vector_3.cpp View File

26
 
26
 
27
 vector_3::vector_3(float x_, float y_, float z_) : x(x_), y(y_), z(z_) { }
27
 vector_3::vector_3(float x_, float y_, float z_) : x(x_), y(y_), z(z_) { }
28
 
28
 
29
-vector_3 vector_3::cross(vector_3 left, vector_3 right)
30
-{
29
+vector_3 vector_3::cross(vector_3 left, vector_3 right) {
31
 	return vector_3(left.y * right.z - left.z * right.y,
30
 	return vector_3(left.y * right.z - left.z * right.y,
32
 		left.z * right.x - left.x * right.z,
31
 		left.z * right.x - left.x * right.z,
33
 		left.x * right.y - left.y * right.x);
32
 		left.x * right.y - left.y * right.x);
34
 }
33
 }
35
 
34
 
36
-vector_3 vector_3::operator+(vector_3 v) 
37
-{
38
-	return vector_3((x + v.x), (y + v.y), (z + v.z));
39
-}
40
-
41
-vector_3 vector_3::operator-(vector_3 v) 
42
-{
43
-	return vector_3((x - v.x), (y - v.y), (z - v.z));
44
-}
35
+vector_3 vector_3::operator+(vector_3 v) { return vector_3((x + v.x), (y + v.y), (z + v.z)); }
36
+vector_3 vector_3::operator-(vector_3 v) { return vector_3((x - v.x), (y - v.y), (z - v.z)); }
45
 
37
 
46
-vector_3 vector_3::get_normal() 
47
-{
38
+vector_3 vector_3::get_normal() {
48
 	vector_3 normalized = vector_3(x, y, z);
39
 	vector_3 normalized = vector_3(x, y, z);
49
 	normalized.normalize();
40
 	normalized.normalize();
50
 	return normalized;
41
 	return normalized;
51
 }
42
 }
52
 
43
 
53
-float vector_3::get_length() 
54
-{
55
-	float length = sqrt((x * x) + (y * y) + (z * z));
56
-	return length;
57
-}
58
- 
59
-void vector_3::normalize()
60
-{
44
+float vector_3::get_length() { return sqrt((x * x) + (y * y) + (z * z)); }
45
+
46
+void vector_3::normalize() {
61
 	float length = get_length();
47
 	float length = get_length();
62
 	x /= length;
48
 	x /= length;
63
 	y /= length;
49
 	y /= length;
64
 	z /= length;
50
 	z /= length;
65
 }
51
 }
66
 
52
 
67
-void vector_3::apply_rotation(matrix_3x3 matrix)
68
-{
53
+void vector_3::apply_rotation(matrix_3x3 matrix) {
69
 	float resultX = x * matrix.matrix[3*0+0] + y * matrix.matrix[3*1+0] + z * matrix.matrix[3*2+0];
54
 	float resultX = x * matrix.matrix[3*0+0] + y * matrix.matrix[3*1+0] + z * matrix.matrix[3*2+0];
70
 	float resultY = x * matrix.matrix[3*0+1] + y * matrix.matrix[3*1+1] + z * matrix.matrix[3*2+1];
55
 	float resultY = x * matrix.matrix[3*0+1] + y * matrix.matrix[3*1+1] + z * matrix.matrix[3*2+1];
71
 	float resultZ = x * matrix.matrix[3*0+2] + y * matrix.matrix[3*1+2] + z * matrix.matrix[3*2+2];
56
 	float resultZ = x * matrix.matrix[3*0+2] + y * matrix.matrix[3*1+2] + z * matrix.matrix[3*2+2];
72
-
73
 	x = resultX;
57
 	x = resultX;
74
 	y = resultY;
58
 	y = resultY;
75
 	z = resultZ;
59
 	z = resultZ;
76
 }
60
 }
77
 
61
 
78
-void vector_3::debug(char* title)
79
-{
62
+void vector_3::debug(const char title[]) {
80
 	SERIAL_PROTOCOL(title);
63
 	SERIAL_PROTOCOL(title);
81
 	SERIAL_PROTOCOLPGM(" x: ");
64
 	SERIAL_PROTOCOLPGM(" x: ");
82
 	SERIAL_PROTOCOL_F(x, 6);
65
 	SERIAL_PROTOCOL_F(x, 6);
87
 	SERIAL_EOL;
70
 	SERIAL_EOL;
88
 }
71
 }
89
 
72
 
90
-void apply_rotation_xyz(matrix_3x3 matrix, float &x, float& y, float& z)
91
-{
73
+void apply_rotation_xyz(matrix_3x3 matrix, float &x, float& y, float& z) {
92
 	vector_3 vector = vector_3(x, y, z);
74
 	vector_3 vector = vector_3(x, y, z);
93
 	vector.apply_rotation(matrix);
75
 	vector.apply_rotation(matrix);
94
 	x = vector.x;
76
 	x = vector.x;
96
 	z = vector.z;
78
 	z = vector.z;
97
 }
79
 }
98
 
80
 
99
-matrix_3x3 matrix_3x3::create_from_rows(vector_3 row_0, vector_3 row_1, vector_3 row_2)
100
-{
101
-        //row_0.debug("row_0");
102
-        //row_1.debug("row_1");
103
-        //row_2.debug("row_2");
81
+matrix_3x3 matrix_3x3::create_from_rows(vector_3 row_0, vector_3 row_1, vector_3 row_2) {
82
+  //row_0.debug("row_0");
83
+  //row_1.debug("row_1");
84
+  //row_2.debug("row_2");
104
 	matrix_3x3 new_matrix;
85
 	matrix_3x3 new_matrix;
105
 	new_matrix.matrix[0] = row_0.x; new_matrix.matrix[1] = row_0.y; new_matrix.matrix[2] = row_0.z; 
86
 	new_matrix.matrix[0] = row_0.x; new_matrix.matrix[1] = row_0.y; new_matrix.matrix[2] = row_0.z; 
106
 	new_matrix.matrix[3] = row_1.x; new_matrix.matrix[4] = row_1.y; new_matrix.matrix[5] = row_1.z; 
87
 	new_matrix.matrix[3] = row_1.x; new_matrix.matrix[4] = row_1.y; new_matrix.matrix[5] = row_1.z; 
107
 	new_matrix.matrix[6] = row_2.x; new_matrix.matrix[7] = row_2.y; new_matrix.matrix[8] = row_2.z; 
88
 	new_matrix.matrix[6] = row_2.x; new_matrix.matrix[7] = row_2.y; new_matrix.matrix[8] = row_2.z; 
108
-        //new_matrix.debug("new_matrix");
109
-        
89
+  //new_matrix.debug("new_matrix");
110
 	return new_matrix;
90
 	return new_matrix;
111
 }
91
 }
112
 
92
 
113
-void matrix_3x3::set_to_identity()
114
-{
93
+void matrix_3x3::set_to_identity() {
115
 	matrix[0] = 1; matrix[1] = 0; matrix[2] = 0;
94
 	matrix[0] = 1; matrix[1] = 0; matrix[2] = 0;
116
 	matrix[3] = 0; matrix[4] = 1; matrix[5] = 0;
95
 	matrix[3] = 0; matrix[4] = 1; matrix[5] = 0;
117
 	matrix[6] = 0; matrix[7] = 0; matrix[8] = 1;
96
 	matrix[6] = 0; matrix[7] = 0; matrix[8] = 1;
118
 }
97
 }
119
 
98
 
120
-matrix_3x3 matrix_3x3::create_look_at(vector_3 target)
121
-{
122
-    vector_3 z_row = target.get_normal();
123
-    vector_3 x_row = vector_3(1, 0, -target.x/target.z).get_normal();
124
-    vector_3 y_row = vector_3::cross(z_row, x_row).get_normal();
99
+matrix_3x3 matrix_3x3::create_look_at(vector_3 target) {
100
+  vector_3 z_row = target.get_normal();
101
+  vector_3 x_row = vector_3(1, 0, -target.x/target.z).get_normal();
102
+  vector_3 y_row = vector_3::cross(z_row, x_row).get_normal();
125
 
103
 
126
-   // x_row.debug("x_row");
127
-   // y_row.debug("y_row");
128
-   // z_row.debug("z_row");
104
+  // x_row.debug("x_row");
105
+  // y_row.debug("y_row");
106
+  // z_row.debug("z_row");
129
 
107
 
130
- 
131
-     // create the matrix already correctly transposed
132
-    matrix_3x3 rot = matrix_3x3::create_from_rows(x_row, y_row, z_row);
108
+  // create the matrix already correctly transposed
109
+  matrix_3x3 rot = matrix_3x3::create_from_rows(x_row, y_row, z_row);
133
 
110
 
134
- //   rot.debug("rot");
135
-    return rot;
111
+  // rot.debug("rot");
112
+  return rot;
136
 }
113
 }
137
 
114
 
138
-
139
-matrix_3x3 matrix_3x3::transpose(matrix_3x3 original)
140
-{
115
+matrix_3x3 matrix_3x3::transpose(matrix_3x3 original) {
141
   matrix_3x3 new_matrix;
116
   matrix_3x3 new_matrix;
142
   new_matrix.matrix[0] = original.matrix[0]; new_matrix.matrix[1] = original.matrix[3]; new_matrix.matrix[2] = original.matrix[6]; 
117
   new_matrix.matrix[0] = original.matrix[0]; new_matrix.matrix[1] = original.matrix[3]; new_matrix.matrix[2] = original.matrix[6]; 
143
   new_matrix.matrix[3] = original.matrix[1]; new_matrix.matrix[4] = original.matrix[4]; new_matrix.matrix[5] = original.matrix[7]; 
118
   new_matrix.matrix[3] = original.matrix[1]; new_matrix.matrix[4] = original.matrix[4]; new_matrix.matrix[5] = original.matrix[7]; 
145
   return new_matrix;
120
   return new_matrix;
146
 }
121
 }
147
 
122
 
148
-void matrix_3x3::debug(char* title) {
123
+void matrix_3x3::debug(const char title[]) {
149
   SERIAL_PROTOCOLLN(title);
124
   SERIAL_PROTOCOLLN(title);
150
   int count = 0;
125
   int count = 0;
151
   for(int i=0; i<3; i++) {
126
   for(int i=0; i<3; i++) {
152
     for(int j=0; j<3; j++) {
127
     for(int j=0; j<3; j++) {
128
+      if (matrix[count] >= 0.0) SERIAL_PROTOCOLPGM("+");
153
       SERIAL_PROTOCOL_F(matrix[count], 6);
129
       SERIAL_PROTOCOL_F(matrix[count], 6);
154
       SERIAL_PROTOCOLPGM(" ");
130
       SERIAL_PROTOCOLPGM(" ");
155
       count++;
131
       count++;
158
   }
134
   }
159
 }
135
 }
160
 
136
 
161
-#endif // #ifdef ENABLE_AUTO_BED_LEVELING
137
+#endif // ENABLE_AUTO_BED_LEVELING
162
 
138
 

+ 2
- 2
Marlin/vector_3.h View File

37
 	float get_length();
37
 	float get_length();
38
 	vector_3 get_normal();
38
 	vector_3 get_normal();
39
 
39
 
40
-	void debug(char* title);
40
+	void debug(const char title[]);
41
 	
41
 	
42
 	void apply_rotation(matrix_3x3 matrix);
42
 	void apply_rotation(matrix_3x3 matrix);
43
 };
43
 };
52
 
52
 
53
 	void set_to_identity();
53
 	void set_to_identity();
54
 
54
 
55
-	void debug(char* title);
55
+	void debug(const char title[]);
56
 };
56
 };
57
 
57
 
58
 
58
 

Loading…
Cancel
Save