From 1fe9fb3ad414ddcf7ecc1dacd310bf8967b61e2c Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Thu, 29 Jan 2026 14:53:11 -0500 Subject: [PATCH] trigger_analog: Don't report trigger time as the peak time There are some rare corner cases where reporting the peak time could cause hard to debug issues (for example, the peak time could theoretically be a significant time prior to the actual trigger time, which could possibly cause unexpected clock rollover issues). Now that the host code does not utilize the peak time for "tap" detection, it can be removed from the mcu code. Signed-off-by: Kevin O'Connor --- klippy/extras/trigger_analog.py | 4 ++-- src/trigger_analog.c | 9 +++------ 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/klippy/extras/trigger_analog.py b/klippy/extras/trigger_analog.py index 6f79c0486..d38bcd777 100644 --- a/klippy/extras/trigger_analog.py +++ b/klippy/extras/trigger_analog.py @@ -277,7 +277,7 @@ class MCU_trigger_analog: # Lookup commands self._query_state_cmd = self._mcu.lookup_query_command( "trigger_analog_query_state oid=%c", - "trigger_analog_state oid=%c homing=%c trigger_clock=%u", + "trigger_analog_state oid=%c homing=%c homing_clock=%u", oid=self._oid, cq=cmd_queue) self._set_raw_range_cmd = self._mcu.lookup_command( "trigger_analog_set_raw_range oid=%c raw_min=%i raw_max=%i", @@ -334,7 +334,7 @@ class MCU_trigger_analog: def _clear_home(self): self._home_cmd.send([self._oid, 0, 0, 0, 0, 0, 0, 0]) params = self._query_state_cmd.send([self._oid]) - trigger_ticks = self._mcu.clock32_to_clock64(params['trigger_clock']) + trigger_ticks = self._mcu.clock32_to_clock64(params['homing_clock']) return self._mcu.clock_to_print_time(trigger_ticks) def get_steppers(self): diff --git a/src/trigger_analog.c b/src/trigger_analog.c index a77af68d7..ce9b998bf 100644 --- a/src/trigger_analog.c +++ b/src/trigger_analog.c @@ -23,7 +23,6 @@ struct trigger_analog { struct sos_filter *sf; // Trigger value checking int32_t trigger_value, trigger_peak; - uint32_t trigger_clock; uint8_t trigger_type; // Trsync triggering uint8_t flags, trigger_reason, error_reason; @@ -91,14 +90,11 @@ check_trigger(struct trigger_analog *ta, uint32_t time, int32_t value) { switch (ta->trigger_type) { case TT_ABS_GE: - ta->trigger_clock = time; return abs(value) >= ta->trigger_value; case TT_GT: - ta->trigger_clock = time; return value > ta->trigger_value; case TT_DIFF_PEAK_GT: if (value > ta->trigger_peak) { - ta->trigger_clock = time; ta->trigger_peak = value; return 0; } @@ -173,6 +169,7 @@ trigger_analog_update(struct trigger_analog *ta, int32_t sample) if (ret) { trsync_do_trigger(ta->ts, ta->trigger_reason); flags = 0; + ta->homing_clock = time; } ta->flags = flags; @@ -250,8 +247,8 @@ command_trigger_analog_query_state(uint32_t *args) { uint8_t oid = args[0]; struct trigger_analog *ta = trigger_analog_oid_lookup(args[0]); - sendf("trigger_analog_state oid=%c homing=%c trigger_clock=%u" - , oid, !!(ta->flags & TA_CAN_TRIGGER), ta->trigger_clock); + sendf("trigger_analog_state oid=%c homing=%c homing_clock=%u" + , oid, !!(ta->flags & TA_CAN_TRIGGER), ta->homing_clock); } DECL_COMMAND(command_trigger_analog_query_state , "trigger_analog_query_state oid=%c");