diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2024-09-03 22:11:03 -0400 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2024-09-12 13:15:01 -0400 |
commit | 293858c51fc51c998a046ba12c00da0418fb8403 (patch) | |
tree | 54c0b2acd27f7a899abee7325068b7acecc57202 /klippy | |
parent | 14a83103c32fe1590b5b0416f71d1445648c58ed (diff) | |
download | kutter-293858c51fc51c998a046ba12c00da0418fb8403.tar.gz kutter-293858c51fc51c998a046ba12c00da0418fb8403.tar.xz kutter-293858c51fc51c998a046ba12c00da0418fb8403.zip |
hx71x: Avoid base classes to improve python2 compatibility
Also, add a load_cell regression test case.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy')
-rw-r--r-- | klippy/extras/ads1220.py | 2 | ||||
-rw-r--r-- | klippy/extras/hx71x.py | 30 |
2 files changed, 15 insertions, 17 deletions
diff --git a/klippy/extras/ads1220.py b/klippy/extras/ads1220.py index 14d47581..396f6854 100644 --- a/klippy/extras/ads1220.py +++ b/klippy/extras/ads1220.py @@ -24,7 +24,7 @@ def hexify(byte_array): return "[%s]" % (", ".join([hex(b) for b in byte_array])) -class ADS1220(): +class ADS1220: def __init__(self, config): self.printer = printer = config.get_printer() self.name = config.get_name().split()[-1] diff --git a/klippy/extras/hx71x.py b/klippy/extras/hx71x.py index 85eff85f..5c59ed0b 100644 --- a/klippy/extras/hx71x.py +++ b/klippy/extras/hx71x.py @@ -14,7 +14,7 @@ SAMPLE_ERROR_DESYNC = -0x80000000 SAMPLE_ERROR_LONG_READ = 0x40000000 # Implementation of HX711 and HX717 -class HX71xBase(): +class HX71xBase: def __init__(self, config, sensor_type, sample_rate_options, default_sample_rate, gain_options, default_gain): @@ -145,23 +145,21 @@ class HX71xBase(): 'overflows': self.ffreader.get_last_overflows()} -class HX711(HX71xBase): - def __init__(self, config): - super(HX711, self).__init__(config, "hx711", - # HX711 sps options - {80: 80, 10: 10}, 80, - # HX711 gain/channel options - {'A-128': 1, 'B-32': 2, 'A-64': 3}, 'A-128') +def HX711(config): + return HX71xBase(config, "hx711", + # HX711 sps options + {80: 80, 10: 10}, 80, + # HX711 gain/channel options + {'A-128': 1, 'B-32': 2, 'A-64': 3}, 'A-128') -class HX717(HX71xBase): - def __init__(self, config): - super(HX717, self).__init__(config, "hx717", - # HX717 sps options - {320: 320, 80: 80, 20: 20, 10: 10}, 320, - # HX717 gain/channel options - {'A-128': 1, 'B-64': 2, 'A-64': 3, - 'B-8': 4}, 'A-128') +def HX717(config): + return HX71xBase(config, "hx717", + # HX717 sps options + {320: 320, 80: 80, 20: 20, 10: 10}, 320, + # HX717 gain/channel options + {'A-128': 1, 'B-64': 2, 'A-64': 3, + 'B-8': 4}, 'A-128') HX71X_SENSOR_TYPES = { |