mirror of
https://github.com/Klipper3d/klipper.git
synced 2026-03-06 18:14:41 -07:00
mcu: Change MCU_adc.get_last_value() to return (time, value)
Change the get_last_value() method to return time first then value (instead of value, then time). This makes get_last_value() match the order of parameters that is used in the adc update callback. This also fixes ads1x1x to return the "print_time" instead of a system time. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
9e962ee3f4
commit
5a2fd1009d
5 changed files with 9 additions and 9 deletions
|
|
@ -23,7 +23,7 @@ class MCU_scaled_adc:
|
|||
max_adc = self._main.last_vref[1]
|
||||
min_adc = self._main.last_vssa[1]
|
||||
scaled_val = (read_value - min_adc) / (max_adc - min_adc)
|
||||
self._last_state = (scaled_val, read_time)
|
||||
self._last_state = (read_time, scaled_val)
|
||||
self._callback(read_time, scaled_val)
|
||||
def setup_adc_callback(self, report_time, callback):
|
||||
self._callback = callback
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ class HelperTemperatureDiagnostics:
|
|||
def _clarify_adc_range(self, msg, details):
|
||||
if self.min_temp is None:
|
||||
return None
|
||||
last_value, last_read_time = self.mcu_adc.get_last_value()
|
||||
last_read_time, last_value = self.mcu_adc.get_last_value()
|
||||
if not last_read_time:
|
||||
return None
|
||||
if last_value >= self.min_adc and last_value <= self.max_adc:
|
||||
|
|
|
|||
|
|
@ -361,10 +361,10 @@ class ADS1X1X_pin:
|
|||
self.invalid_count = 0
|
||||
|
||||
# Publish result
|
||||
measured_time = self._reactor.monotonic()
|
||||
self._last_state = (target_value, measured_time)
|
||||
self.callback(self.chip.mcu.estimated_print_time(measured_time),
|
||||
target_value)
|
||||
systime = self._reactor.monotonic()
|
||||
measured_time = self.chip.mcu.estimated_print_time(systime)
|
||||
self._last_state = (measured_time, target_value)
|
||||
self.callback(measured_time, target_value)
|
||||
else:
|
||||
self.invalid_count = self.invalid_count + 1
|
||||
self.check_invalid()
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ class QueryADC:
|
|||
msg = "Available ADC objects: %s" % (', '.join(objs),)
|
||||
gcmd.respond_info(msg)
|
||||
return
|
||||
value, timestamp = self.adc[name].get_last_value()
|
||||
timestamp, value = self.adc[name].get_last_value()
|
||||
msg = 'ADC object "%s" has value %.6f (timestamp %.3f)' % (
|
||||
name, value, timestamp)
|
||||
pullup = gcmd.get_float('PULLUP', None, above=0.)
|
||||
|
|
|
|||
|
|
@ -601,7 +601,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)
|
||||
self._last_state = (last_read_time, last_value)
|
||||
if self._callback is not None:
|
||||
self._callback(last_read_time, last_value)
|
||||
def _handle_analog_in_state(self, params):
|
||||
|
|
@ -610,7 +610,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)
|
||||
self._last_state = (last_read_time, last_value)
|
||||
if self._callback is not None:
|
||||
self._callback(last_read_time, last_value)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue