aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/mcu.py
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2016-12-22 23:58:51 -0500
committerKevin O'Connor <kevin@koconnor.net>2016-12-23 17:06:10 -0500
commit872b08601a6b749de2f83b3f270a2c311dd22bbc (patch)
treed0525ecde954a6e7548e617da143dbf2d54652b9 /klippy/mcu.py
parentfe95ea221b2b88e9cb52a6378ff2018ee752094b (diff)
downloadkutter-872b08601a6b749de2f83b3f270a2c311dd22bbc.tar.gz
kutter-872b08601a6b749de2f83b3f270a2c311dd22bbc.tar.xz
kutter-872b08601a6b749de2f83b3f270a2c311dd22bbc.zip
mcu: Obtain the maximum adc value from the firmware
Don't assume the hardware ADC has 10bit resultion - instead have the firmware define a constant and read that constant in the host. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy/mcu.py')
-rw-r--r--klippy/mcu.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/klippy/mcu.py b/klippy/mcu.py
index b49c29cc..e50a6cb3 100644
--- a/klippy/mcu.py
+++ b/klippy/mcu.py
@@ -256,7 +256,6 @@ class MCU_pwm:
self._last_clock = clock
class MCU_adc:
- ADC_MAX = 1024 # 10bit adc
def __init__(self, mcu, pin):
self._mcu = mcu
self._oid = mcu.create_oid()
@@ -283,7 +282,8 @@ class MCU_adc:
minval = 0
if maxval is None:
maxval = 0xffff
- max_adc = sample_count * self.ADC_MAX
+ mcu_adc_max = float(self._mcu.serial.msgparser.config["ADC_MAX"])
+ max_adc = sample_count * mcu_adc_max
self._min_sample = int(minval * max_adc)
self._max_sample = min(0xffff, int(math.ceil(maxval * max_adc)))
self._inv_max_adc = 1.0 / max_adc