|
@@ -189,6 +189,7 @@
|
189
|
189
|
* M410 - Quickstop. Abort all the planned moves
|
190
|
190
|
* M420 - Enable/Disable Mesh Leveling (with current values) S1=enable S0=disable
|
191
|
191
|
* M421 - Set a single Z coordinate in the Mesh Leveling grid. X<mm> Y<mm> Z<mm>
|
|
192
|
+ * M428 - Set the home_offset logically based on the current_position
|
192
|
193
|
* M500 - Store parameters in EEPROM
|
193
|
194
|
* M501 - Read parameters from EEPROM (if you need reset them after you changed them temporarily).
|
194
|
195
|
* M502 - Revert to the default "factory settings". You still need to store them in EEPROM afterwards if you want to.
|
|
@@ -4505,6 +4506,31 @@ inline void gcode_M410() { quickStop(); }
|
4505
|
4506
|
#endif
|
4506
|
4507
|
|
4507
|
4508
|
/**
|
|
4509
|
+ * M428: Set home_offset based on the distance between the
|
|
4510
|
+ * current_position and the nearest "reference position."
|
|
4511
|
+ * If an axis is past center the endstop position
|
|
4512
|
+ * is the reference-point. Otherwise it uses 0. This allows
|
|
4513
|
+ * the Z offset to be set near the bed when using a max endstop.
|
|
4514
|
+ *
|
|
4515
|
+ * Use M206 to set these values directly.
|
|
4516
|
+ */
|
|
4517
|
+inline void gcode_M428() {
|
|
4518
|
+ for (int8_t i = X_AXIS; i <= Z_AXIS; i++) {
|
|
4519
|
+ float base = (current_position[i] > (min_pos[i] + max_pos[i]) / 2) ? base_home_pos(i) : 0,
|
|
4520
|
+ diff = current_position[i] - base;
|
|
4521
|
+ if (diff > -20 && diff < 20) {
|
|
4522
|
+ home_offset[i] -= diff;
|
|
4523
|
+ current_position[i] = base;
|
|
4524
|
+ }
|
|
4525
|
+ else {
|
|
4526
|
+ SERIAL_ERROR_START;
|
|
4527
|
+ SERIAL_ERRORLNPGM(MSG_ERR_M428_TOO_FAR);
|
|
4528
|
+ }
|
|
4529
|
+ }
|
|
4530
|
+ sync_plan_position();
|
|
4531
|
+}
|
|
4532
|
+
|
|
4533
|
+/**
|
4508
|
4534
|
* M500: Store settings in EEPROM
|
4509
|
4535
|
*/
|
4510
|
4536
|
inline void gcode_M500() {
|
|
@@ -5353,6 +5379,10 @@ void process_commands() {
|
5353
|
5379
|
break;
|
5354
|
5380
|
#endif
|
5355
|
5381
|
|
|
5382
|
+ case 428: // M428 Apply current_position to home_offset
|
|
5383
|
+ gcode_M428();
|
|
5384
|
+ break;
|
|
5385
|
+
|
5356
|
5386
|
case 500: // M500 Store settings in EEPROM
|
5357
|
5387
|
gcode_M500();
|
5358
|
5388
|
break;
|