aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2021-04-29 20:46:57 -0400
committerKevin O'Connor <kevin@koconnor.net>2021-04-30 11:40:37 -0400
commitb611e72a19d499208e09e426a7e8358a78a62b55 (patch)
treef5bf71be278b1f9047353d5f531e04a07fac5c35
parent8f76e53c0eef351576be7fa2acbb964af031d7b3 (diff)
downloadkutter-b611e72a19d499208e09e426a7e8358a78a62b55.tar.gz
kutter-b611e72a19d499208e09e426a7e8358a78a62b55.tar.xz
kutter-b611e72a19d499208e09e426a7e8358a78a62b55.zip
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 <kevin@koconnor.net>
-rw-r--r--klippy/extras/pulse_counter.py11
-rw-r--r--src/pulse_counter.c6
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);