From b611e72a19d499208e09e426a7e8358a78a62b55 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Thu, 29 Apr 2021 20:46:57 -0400 Subject: [PATCH] pulse_counter: Use "clock" suffix instead of "time" in commands The debugging code knows how to handle fields that end in "clock". Signed-off-by: Kevin O'Connor --- klippy/extras/pulse_counter.py | 11 ++++++----- src/pulse_counter.c | 6 +++--- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/klippy/extras/pulse_counter.py b/klippy/extras/pulse_counter.py index a952b7f8..a7587187 100644 --- a/klippy/extras/pulse_counter.py +++ b/klippy/extras/pulse_counter.py @@ -13,6 +13,7 @@ class MCU_counter: self._pin = pin_params['pin'] self._pullup = pin_params['pullup'] self._poll_time = poll_time + self._poll_ticks = 0 self._sample_time = sample_time self._callback = None self._last_count = 0 @@ -22,11 +23,11 @@ class MCU_counter: self._mcu.add_config_cmd("config_counter oid=%d pin=%s pull_up=%d" % (self._oid, self._pin, self._pullup)) clock = self._mcu.get_query_slot(self._oid) - poll_ticks = self._mcu.seconds_to_clock(self._poll_time) + self._poll_ticks = self._mcu.seconds_to_clock(self._poll_time) sample_ticks = self._mcu.seconds_to_clock(self._sample_time) self._mcu.add_config_cmd( "query_counter oid=%d clock=%d poll_ticks=%d sample_ticks=%d" - % (self._oid, clock, poll_ticks, sample_ticks), is_init=True) + % (self._oid, clock, self._poll_ticks, sample_ticks), is_init=True) self._mcu.register_response(self._handle_counter_state, "counter_state", self._oid) @@ -35,10 +36,10 @@ class MCU_counter: self._callback = cb def _handle_counter_state(self, params): - clock = self._mcu.clock32_to_clock64(params['time']) - time = self._mcu.clock_to_print_time(clock) + next_clock = self._mcu.clock32_to_clock64(params['next_clock']) + time = self._mcu.clock_to_print_time(next_clock - self._poll_ticks) - count_clock = self._mcu.clock32_to_clock64(params['count_time']) + count_clock = self._mcu.clock32_to_clock64(params['count_clock']) count_time = self._mcu.clock_to_print_time(count_clock) # handle 32-bit counter overflow diff --git a/src/pulse_counter.c b/src/pulse_counter.c index c2cf4ea3..7837a3c8 100644 --- a/src/pulse_counter.c +++ b/src/pulse_counter.c @@ -87,13 +87,13 @@ counter_task(void) if (!(c->flags & CF_PENDING)) continue; irq_disable(); - uint32_t time = c->timer.waketime - c->poll_ticks; + uint32_t waketime = c->timer.waketime; uint32_t count = c->count; uint32_t count_time = c->last_count_time; c->flags &= ~CF_PENDING; irq_enable(); - sendf("counter_state oid=%c time=%u count=%u count_time=%u", - oid, time, count, count_time); + sendf("counter_state oid=%c next_clock=%u count=%u count_clock=%u", + oid, waketime, count, count_time); } } DECL_TASK(counter_task);