diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2018-07-02 13:47:22 -0400 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2018-07-02 13:56:34 -0400 |
commit | 0dbfa915de5495662102d17c7a11cea219354b91 (patch) | |
tree | 902109825fd2653ca7bd98a259e421522a69280c /klippy/mcu.py | |
parent | 5b3444c060a51b27fc19ec6386029f00385ba42a (diff) | |
download | kutter-0dbfa915de5495662102d17c7a11cea219354b91.tar.gz kutter-0dbfa915de5495662102d17c7a11cea219354b91.tar.xz kutter-0dbfa915de5495662102d17c7a11cea219354b91.zip |
adccmds: Add support for min/max temperature check filtering
Extend the ADC out of range check so that it is possible to sample
multiple times before going into a shutdown state. This reduces the
chance that measurement noise will cause an error. In an actual over
temperature (or under temperature event) it is expected that the
sensor will consistently report the problem, so extra checks for an
additional second or two should not substantially increase risk.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy/mcu.py')
-rw-r--r-- | klippy/mcu.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/klippy/mcu.py b/klippy/mcu.py index 8d7e86cb..56c28b4b 100644 --- a/klippy/mcu.py +++ b/klippy/mcu.py @@ -350,17 +350,19 @@ class MCU_adc: self._pin = pin_params['pin'] self._min_sample = self._max_sample = 0. self._sample_time = self._report_time = 0. - self._sample_count = 0 + self._sample_count = self._range_check_count = 0 self._report_clock = 0 self._oid = self._callback = None self._inv_max_adc = 0. def get_mcu(self): return self._mcu - def setup_minmax(self, sample_time, sample_count, minval=0., maxval=1.): + def setup_minmax(self, sample_time, sample_count, + minval=0., maxval=1., range_check_count=0): self._sample_time = sample_time self._sample_count = sample_count self._min_sample = minval self._max_sample = maxval + self._range_check_count = range_check_count def setup_adc_callback(self, report_time, callback): self._report_time = report_time self._callback = callback @@ -381,9 +383,10 @@ class MCU_adc: math.ceil(self._max_sample * max_adc)))) self._mcu.add_config_cmd( "query_analog_in oid=%d clock=%d sample_ticks=%d sample_count=%d" - " rest_ticks=%d min_value=%d max_value=%d" % ( + " rest_ticks=%d min_value=%d max_value=%d range_check_count=%d" % ( self._oid, clock, sample_ticks, self._sample_count, - self._report_clock, min_sample, max_sample), is_init=True) + self._report_clock, min_sample, max_sample, + self._range_check_count), is_init=True) self._mcu.register_msg(self._handle_analog_in_state, "analog_in_state" , self._oid) def _handle_analog_in_state(self, params): |