Skip to content

Commit 9c84895

Browse files
authored
ads1x1x: Interface for "QUERY_ADC" (#7132)
"QUERY_ADC" command will fail without "get_last_value" function. Signed-off-by: Timo Hilbig <[email protected]>
1 parent 9ac90f8 commit 9c84895

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

klippy/extras/ads1x1x.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ def __init__(self, chip, pcfg):
322322
self.mcu = chip.mcu
323323
self.chip = chip
324324
self.pcfg = pcfg
325-
325+
self._last_state = (0., 0.)
326326
self.invalid_count = 0
327327

328328
self.chip._printer.register_event_handler("klippy:connect", \
@@ -362,6 +362,7 @@ def _process_sample(self, eventtime):
362362

363363
# Publish result
364364
measured_time = self._reactor.monotonic()
365+
self._last_state = (target_value, measured_time)
365366
self.callback(self.chip.mcu.estimated_print_time(measured_time),
366367
target_value)
367368
else:
@@ -389,5 +390,8 @@ def setup_adc_sample(self, sample_time, sample_count,
389390
self.maxval = maxval
390391
self.range_check_count = range_check_count
391392

393+
def get_last_value(self):
394+
return self._last_state
395+
392396
def load_config_prefix(config):
393397
return ADS1X1X_chip(config)

0 commit comments

Comments
 (0)