|
@@ -36,6 +36,7 @@
|
36
|
36
|
#endif
|
37
|
37
|
#endif // ENABLE_AUTO_BED_LEVELING
|
38
|
38
|
|
|
39
|
+#define HAS_LCD_BUZZ (defined(ULTRALCD) || (defined(BEEPER) && BEEPER >= 0) || defined(LCD_USE_I2C_BUZZER))
|
39
|
40
|
#define SERVO_LEVELING (defined(ENABLE_AUTO_BED_LEVELING) && PROBE_SERVO_DEACTIVATION_DELAY > 0)
|
40
|
41
|
|
41
|
42
|
#ifdef MESH_BED_LEVELING
|
|
@@ -4091,7 +4092,7 @@ inline void gcode_M226() {
|
4091
|
4092
|
|
4092
|
4093
|
#endif // NUM_SERVOS > 0
|
4093
|
4094
|
|
4094
|
|
-#if BEEPER > 0 || defined(ULTRALCD) || defined(LCD_USE_I2C_BUZZER)
|
|
4095
|
+#if HAS_LCD_BUZZ
|
4095
|
4096
|
|
4096
|
4097
|
/**
|
4097
|
4098
|
* M300: Play beep sound S<frequency Hz> P<duration ms>
|
|
@@ -4103,7 +4104,7 @@ inline void gcode_M226() {
|
4103
|
4104
|
lcd_buzz(beepP, beepS);
|
4104
|
4105
|
}
|
4105
|
4106
|
|
4106
|
|
-#endif // BEEPER>0 || ULTRALCD || LCD_USE_I2C_BUZZER
|
|
4107
|
+#endif // HAS_LCD_BUZZ
|
4107
|
4108
|
|
4108
|
4109
|
#ifdef PIDTEMP
|
4109
|
4110
|
|
|
@@ -4507,27 +4508,50 @@ inline void gcode_M410() { quickStop(); }
|
4507
|
4508
|
|
4508
|
4509
|
/**
|
4509
|
4510
|
* 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
|
|
4511
|
+ * current_position and the nearest "reference point."
|
|
4512
|
+ * If an axis is past center its endstop position
|
4512
|
4513
|
* is the reference-point. Otherwise it uses 0. This allows
|
4513
|
4514
|
* the Z offset to be set near the bed when using a max endstop.
|
4514
|
4515
|
*
|
|
4516
|
+ * M428 can't be used more than 2cm away from 0 or an endstop.
|
|
4517
|
+ *
|
4515
|
4518
|
* Use M206 to set these values directly.
|
4516
|
4519
|
*/
|
4517
|
4520
|
inline void gcode_M428() {
|
|
4521
|
+ bool err = false;
|
|
4522
|
+ float new_offs[3], new_pos[3];
|
|
4523
|
+ memcpy(new_pos, current_position, sizeof(new_pos));
|
|
4524
|
+ memcpy(new_offs, home_offset, sizeof(new_offs));
|
4518
|
4525
|
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);
|
|
4526
|
+ if (axis_known_position[i]) {
|
|
4527
|
+ float base = (new_pos[i] > (min_pos[i] + max_pos[i]) / 2) ? base_home_pos(i) : 0,
|
|
4528
|
+ diff = new_pos[i] - base;
|
|
4529
|
+ if (diff > -20 && diff < 20) {
|
|
4530
|
+ new_offs[i] -= diff;
|
|
4531
|
+ new_pos[i] = base;
|
|
4532
|
+ }
|
|
4533
|
+ else {
|
|
4534
|
+ SERIAL_ERROR_START;
|
|
4535
|
+ SERIAL_ERRORLNPGM(MSG_ERR_M428_TOO_FAR);
|
|
4536
|
+ LCD_ALERTMESSAGEPGM("Err: Too far!");
|
|
4537
|
+ #if HAS_LCD_BUZZ
|
|
4538
|
+ enqueuecommands_P(PSTR("M300 S40 P200"));
|
|
4539
|
+ #endif
|
|
4540
|
+ err = true;
|
|
4541
|
+ break;
|
|
4542
|
+ }
|
4528
|
4543
|
}
|
4529
|
4544
|
}
|
4530
|
|
- sync_plan_position();
|
|
4545
|
+
|
|
4546
|
+ if (!err) {
|
|
4547
|
+ memcpy(current_position, new_pos, sizeof(new_pos));
|
|
4548
|
+ memcpy(home_offset, new_offs, sizeof(new_offs));
|
|
4549
|
+ sync_plan_position();
|
|
4550
|
+ LCD_ALERTMESSAGEPGM("Offset applied.");
|
|
4551
|
+ #if HAS_LCD_BUZZ
|
|
4552
|
+ enqueuecommands_P(PSTR("M300 S659 P200\nM300 S698 P200"));
|
|
4553
|
+ #endif
|
|
4554
|
+ }
|
4531
|
4555
|
}
|
4532
|
4556
|
|
4533
|
4557
|
/**
|
|
@@ -5277,11 +5301,11 @@ void process_commands() {
|
5277
|
5301
|
break;
|
5278
|
5302
|
#endif // NUM_SERVOS > 0
|
5279
|
5303
|
|
5280
|
|
- #if BEEPER > 0 || defined(ULTRALCD) || defined(LCD_USE_I2C_BUZZER)
|
|
5304
|
+ #if HAS_LCD_BUZZ
|
5281
|
5305
|
case 300: // M300 - Play beep tone
|
5282
|
5306
|
gcode_M300();
|
5283
|
5307
|
break;
|
5284
|
|
- #endif // BEEPER > 0 || ULTRALCD || LCD_USE_I2C_BUZZER
|
|
5308
|
+ #endif // HAS_LCD_BUZZ
|
5285
|
5309
|
|
5286
|
5310
|
#ifdef PIDTEMP
|
5287
|
5311
|
case 301: // M301
|