mirror of
https://github.com/Klipper3d/klipper.git
synced 2025-08-09 14:55:09 -06:00
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>
This commit is contained in:
parent
14a83103c3
commit
293858c51f
4 changed files with 43 additions and 17 deletions
|
@ -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]
|
||||
|
|
|
@ -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 = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue