Skip to content

Commit 63e9e5e

Browse files
dfriesTracy Spiva
authored and
Tracy Spiva
committed
⚡️ Skip a redundant BLTouch::command (MarlinFirmware#25656)
1 parent 61da404 commit 63e9e5e

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

Marlin/src/feature/bltouch.cpp

+8-3
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,14 @@ bool BLTouch::od_5v_mode; // Initialized by settings.load, 0 = Open Drai
4242
#include "../core/debug_out.h"
4343

4444
bool BLTouch::command(const BLTCommand cmd, const millis_t &ms) {
45-
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("BLTouch Command :", cmd);
46-
servo[Z_PROBE_SERVO_NR].move(cmd);
47-
safe_delay(_MAX(ms, (uint32_t)BLTOUCH_DELAY)); // BLTOUCH_DELAY is also the *minimum* delay
45+
const BLTCommand current = servo[Z_PROBE_SERVO_NR].read();
46+
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("BLTouch from ", current, " to ", cmd);
47+
// If the new command is the same, skip it (and the delay).
48+
// The previous write should've already delayed to detect the alarm.
49+
if (cmd != current) {
50+
servo[Z_PROBE_SERVO_NR].move(cmd);
51+
safe_delay(_MAX(ms, (uint32_t)BLTOUCH_DELAY)); // BLTOUCH_DELAY is also the *minimum* delay
52+
}
4853
return triggered();
4954
}
5055

0 commit comments

Comments
 (0)