aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/mcu.py
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2019-11-07 19:23:20 -0500
committerKevin O'Connor <kevin@koconnor.net>2019-11-07 19:28:27 -0500
commit0bfb655f665c2f29efa14c28d4dc5c47f151d09a (patch)
treea0b3b006ef33c1db0d65c3459ce10c7a2d757585 /klippy/mcu.py
parent124ba12485c7f4720959270b3151a5ebbcb7cf6b (diff)
downloadkutter-0bfb655f665c2f29efa14c28d4dc5c47f151d09a.tar.gz
kutter-0bfb655f665c2f29efa14c28d4dc5c47f151d09a.tar.xz
kutter-0bfb655f665c2f29efa14c28d4dc5c47f151d09a.zip
query_adc: Add a new module to help query and debug analog pins
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy/mcu.py')
-rw-r--r--klippy/mcu.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/klippy/mcu.py b/klippy/mcu.py
index dda02598..0a283452 100644
--- a/klippy/mcu.py
+++ b/klippy/mcu.py
@@ -392,6 +392,7 @@ class MCU_adc:
self._sample_time = self._report_time = 0.
self._sample_count = self._range_check_count = 0
self._report_clock = 0
+ self._last_state = (0., 0.)
self._oid = self._callback = None
self._mcu.register_config_callback(self._build_config)
self._inv_max_adc = 0.
@@ -407,6 +408,8 @@ class MCU_adc:
def setup_adc_callback(self, report_time, callback):
self._report_time = report_time
self._callback = callback
+ def get_last_value(self):
+ return self._last_state
def _build_config(self):
if not self._sample_count:
return
@@ -435,6 +438,7 @@ class MCU_adc:
next_clock = self._mcu.clock32_to_clock64(params['next_clock'])
last_read_clock = next_clock - self._report_clock
last_read_time = self._mcu.clock_to_print_time(last_read_clock)
+ self._last_state = (last_value, last_read_time)
if self._callback is not None:
self._callback(last_read_time, last_value)