Skip to content

Commit 119eeef

Browse files
committed
libs/unit: Delete illegal naming.
Signed-off-by: lbuque <[email protected]>
1 parent 4e08c8b commit 119eeef

File tree

14 files changed

+32
-226
lines changed

14 files changed

+32
-226
lines changed

m5stack/libs/unit/__init__.py

Lines changed: 13 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
# SPDX-License-Identifier: MIT
44

55
_attrs = {
6-
"ACMeasureUnit": "ac_measure", # 2.0.3 添加
7-
"AC_MEASUREUnit": "ac_measure", # TODO: 类名/型参不符合规范, 2.0.6 移除
6+
"ACMeasureUnit": "ac_measure",
87
"ADCV11Unit": "adc_v11",
98
"ADCUnit": "adc",
109
"AIN4_20MAUnit": "ain4_20ma",
@@ -31,8 +30,7 @@
3130
"DualButtonUnit": "dual_button",
3231
"EarthUnit": "earth",
3332
"EncoderUnit": "encoder",
34-
"Encoder8Unit": "encoder8", # 2.0.3 添加
35-
"ENCODER8Unit": "encoder8", # TODO: 类名/型参不符合规范, 2.0.6 移除
33+
"Encoder8Unit": "encoder8",
3634
"ENVUnit": "env",
3735
"ENVPROUnit": "envpro",
3836
"ExtEncoderUnit": "extencoder",
@@ -42,17 +40,14 @@
4240
"FanUnit": "fan",
4341
"FingerUnit": "finger",
4442
"FlashLightUnit": "flash_light",
45-
"GestureUnit": "gesture", # 2.0.3 添加
46-
"GESTUREUnit": "gesture", # TODO: 类名/型参不符合规范, 2.0.6 移除
43+
"GestureUnit": "gesture",
4744
"GPSUnit": "gps",
4845
"Grove2GroveUnit": "grove2grove",
4946
"HallEffectUnit": "hall_effect",
50-
"HbridgeUnit": "hbridge", # 2.0.3 添加
51-
"HBRIDGEUnit": "hbridge", # TODO: 类名/型参不符合规范, 2.0.6 移除
47+
"HbridgeUnit": "hbridge",
5248
"IRUnit": "ir",
5349
"KeyUnit": "key",
54-
"KMeterISOUnit": "kmeter_iso", # 2.0.3 添加
55-
"KMETER_ISOUnit": "kmeter_iso", # TODO: 类名/型参不符合规范, 2.0.6 移除
50+
"KMeterISOUnit": "kmeter_iso",
5651
"LaserRXUnit": "laser_rx",
5752
"LaserTXUnit": "laser_tx",
5853
"LightUnit": "light",
@@ -76,32 +71,22 @@
7671
"ISO485Unit": "rs485_iso",
7772
"RS485Unit": "rs485",
7873
"RTC8563Unit": "rtc8563",
79-
"ScalesUnit": "scales", # 2.0.3 添加
80-
"SCALESUnit": "scales", # TODO: 类名/型参不符合规范, 2.0.6 移除
74+
"ScalesUnit": "scales",
8175
"Servos8Unit": "servos8",
82-
"SERVOS8Unit": "servos8",
8376
"SSRUnit": "ssr",
84-
"SynthUnit": "synth", # 2.0.3 添加
85-
"SYNTHUnit": "synth", # TODO: 类名/型参不符合规范, 2.0.6 移除
86-
"ThermalUnit": "thermal", # 2.0.3 添加
87-
"THERMALUnit": "thermal", # TODO: 类名/型参不符合规范, 2.0.6 移除
77+
"SynthUnit": "synth",
78+
"ThermalUnit": "thermal",
8879
"Thermal2Unit": "thermal2",
8980
"ToFUnit": "tof",
9081
"TOF4MUnit": "tof4m",
9182
"TubePressureUnit": "tube_pressure",
92-
"UltrasoundI2CUnit": "ultrasonic_i2c", # 2.0.3 添加
93-
"ULTRASONIC_I2CUnit": "ultrasonic_i2c", # TODO: 类名/型参不符合规范, 2.0.6 移除
94-
"UltrasoundIOUnit": "ultrasonic_io", # 2.0.3 添加
95-
"ULTRASONIC_IOUnit": "ultrasonic_io", # TODO: 类名不符合规范, 2.0.6 移除
83+
"UltrasoundI2CUnit": "ultrasonic_i2c",
84+
"UltrasoundIOUnit": "ultrasonic_io",
9685
"UWBUnit": "uwb",
97-
"VoltmeterUnit": "vmeter", # 2.0.3 添加
98-
"VMeterUnit": "vmeter", # TODO: 类名/型参不符合规范, 2.0.6 移除
86+
"VoltmeterUnit": "vmeter",
9987
"WateringUnit": "watering",
100-
"WeightI2CUnit": "weight_i2c", # 2.0.3 添加
101-
"WEIGHT_I2CUnit": "weight_i2c", # TODO: 类名/型参不符合规范, 2.0.6 移除
102-
"WeightUnit": "weight", # 2.0.3 添加
103-
"WEIGHTUnit": "weight", # TODO: 类名不符合规范, 2.0.6 移除
104-
"CatchUnit": "catch",
88+
"WeightI2CUnit": "weight_i2c",
89+
"WeightUnit": "weight",
10590
}
10691

10792

m5stack/libs/unit/ac_measure.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,12 @@ class AC_MEASUREUnit:
3636
def __init__(
3737
self,
3838
i2c: I2C | PAHUBUnit,
39-
slave_addr: int = AC_MEASURE_ADDR,
4039
address: int | list | tuple = AC_MEASURE_ADDR,
4140
) -> None:
42-
# TODO: 2.0.6 移除 addr 参数
4341
"""
4442
AC Measure Initialize Function
4543
Set I2C port, AC Measure Slave Address
4644
"""
47-
address = slave_addr
4845
self.ac_measure_i2c = i2c
4946
self.init_i2c_address(address)
5047

m5stack/libs/unit/ameter.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,8 @@ class AMeterUnit:
8686
def __init__(
8787
self,
8888
i2c: I2C | PAHUBUnit,
89-
ads_addr=ADS1115_ADDR,
9089
address: int | list | tuple = ADS1115_ADDR,
9190
):
92-
# TODO: 2.0.6 移除 ads_addr 参数
93-
address = ads_addr
9491
self.ads_i2c = i2c
9592
self.ads_i2c_addr = address
9693
if self.ads_i2c_addr not in self.ads_i2c.scan():

m5stack/libs/unit/dac2.py

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,17 @@ class DAC2Unit:
2828
CHANNEL_1 = (1,)
2929
CHANNEL_BOTH = (2,)
3030

31-
def __init__(self, i2c: I2C | PAHUBUnit, addr=0x59, address: int | list | tuple = 0x59):
32-
# TODO: 2.0.6 移除 addr 参数
31+
def __init__(self, i2c: I2C | PAHUBUnit, address: int | list | tuple = 0x59):
3332
"""! Initialize the DAC.
3433
3534
@param port I2C port to use.
3635
@param addr I2C address of the sensor.
3736
"""
38-
address = addr
3937
self.i2c = i2c
4038
self.addr = address
4139
self._available()
4240
self._range = self.RANGE_5V
43-
self.setDACOutputVoltageRange(self._range)
41+
self.set_dacoutput_voltage_range(self._range)
4442

4543
def _available(self):
4644
"""! Check if sensor is available on the I2C bus.
@@ -52,11 +50,6 @@ def _available(self):
5250
raise UnitError("DAC2 Unit/Hat not found.")
5351

5452
def set_dacoutput_voltage_range(self, _range: int = 0):
55-
# 2.0.3 添加
56-
self.setDACOutputVoltageRange(_range)
57-
58-
def setDACOutputVoltageRange(self, _range: int = 0): # noqa: N802
59-
# TODO: 2.0.6 移除
6053
"""!
6154
6255
@en Set the DAC %1 output voltage range to %2.
@@ -73,11 +66,6 @@ def setDACOutputVoltageRange(self, _range: int = 0): # noqa: N802
7366
self.i2c.writeto_mem(self.addr, 0x01, struct.pack("b", data))
7467

7568
def set_voltage(self, voltage: float, channel: int = 2):
76-
# 2.0.3 添加
77-
self.setVoltage(voltage, channel)
78-
79-
def setVoltage(self, voltage: float, channel: int = 2): # noqa: N802
80-
# TODO: 2.0.6 移除
8169
"""!
8270
@en Set %1 channel %3 to %2 V.
8371
@cn 设置DAC %1 通道 %3 的输出电压为 %1 V。
@@ -107,11 +95,6 @@ def setVoltage(self, voltage: float, channel: int = 2): # noqa: N802
10795
self.i2c.writeto_mem(self.addr, 0x04, struct.pack("<H", data))
10896

10997
def set_voltage_both(self, voltage0: float, voltage1: float):
110-
# 2.0.3 添加
111-
self.setVoltageBoth(voltage0, voltage1)
112-
113-
def setVoltageBoth(self, voltage0: float, voltage1: float): # noqa: N802
114-
# TODO: 2.0.6 移除
11598
"""!
11699
@en Set the DAC %1 channel 0 %2 V, channel 1 %3 V.
117100
@cn 设置 %1 通道0的电压为 %2 V,通道1的电压为 %3 V。

m5stack/libs/unit/hbridge.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,16 @@
2020
FW_VER_REG = 0xFE
2121

2222

23-
class HBRIDGEUnit:
23+
class HbridgeUnit:
2424
def __init__(
2525
self,
2626
i2c: I2C | PAHUBUnit,
27-
slave_addr=HBRIDGE_ADDR,
2827
address: int | list | tuple = HBRIDGE_ADDR,
2928
):
3029
"""
3130
Hbridge Initialize Function
3231
Set I2C port, Hbridge Slave Address
3332
"""
34-
# TODO: 2.0.6 移除 slave_addr 参数
35-
address = slave_addr
3633
self.hbridge_i2c = i2c
3734
self.init_i2c_address(address)
3835

@@ -149,8 +146,3 @@ def map(self, x, in_min, in_max, out_min, out_max):
149146

150147
def deinit(self):
151148
pass
152-
153-
154-
class HbridgeUnit(HBRIDGEUnit):
155-
def __init__(self, i2c: I2C | PAHUBUnit, address: int | list | tuple = HBRIDGE_ADDR):
156-
super().__init__(i2c, slave_addr=address)

m5stack/libs/unit/kmeter_iso.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,11 @@
2222
I2C_ADDR_REG = 0xFF
2323

2424

25-
class KMETER_ISOUnit:
26-
def __init__(
27-
self, i2c: I2C | PAHUBUnit, addr=KMETER_ADDR, address: int | list | tuple = KMETER_ADDR
28-
):
29-
# TODO: 2.0.6 移除 addr 参数
25+
class KMeterISOUnit:
26+
def __init__(self, i2c: I2C | PAHUBUnit, address: int | list | tuple = KMETER_ADDR):
3027
"""! Kmeter Initialize Function
3128
addr: 1 ~ 127
3229
"""
33-
address = addr
3430
self.kmeter_i2c = i2c
3531
if address >= 0x01 and address <= 0x7F:
3632
self.unit_addr = address
@@ -96,8 +92,3 @@ def set_i2c_address(self, addr) -> None:
9692

9793
def int_convert(self, value):
9894
return struct.unpack("<i", value)[0]
99-
100-
101-
class KMeterISOUnit(KMETER_ISOUnit):
102-
def __init__(self, i2c: I2C | PAHUBUnit, address: int | list | tuple = KMETER_ADDR) -> None:
103-
super().__init__(i2c, addr=address)

m5stack/libs/unit/miniscale.py

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@
1212
class MiniScaleUnit:
1313
"""! MiniScale is a weight sensor, includes a hx711 22bit ADC."""
1414

15-
def __init__(self, i2c: I2C | PAHUBUnit, addr=0x26, address: int | list | tuple = 0x26):
16-
# TODO: 2.0.6 移除 addr 参数
17-
address = addr
15+
def __init__(self, i2c: I2C | PAHUBUnit, address: int | list | tuple = 0x26):
1816
self.i2c = i2c
1917
self.addr = address
2018
self._available()
@@ -47,11 +45,6 @@ def button(self) -> bool:
4745
return struct.unpack("b", data)[0] == 0
4846

4947
def set_led(self, r: int, g: int, b: int):
50-
# 2.0.3 添加
51-
self.setLed(r, g, b)
52-
53-
def setLed(self, r: int, g: int, b: int): # noqa: N802
54-
# TODO: 2.0.6移除
5548
"""! Set the RGB LED color.
5649
5750
@param r Red value. 0 - 255
@@ -83,11 +76,6 @@ def calibration(self, weight1_g: float, weight1_adc: int, weight2_g: float, weig
8376
self.i2c.writeto_mem(self.addr, 0x40, struct.pack("<f", gap))
8477

8578
def set_low_pass_filter(self, enabled: bool):
86-
# 2.0.3 添加
87-
self.setLowPassFilter(enabled)
88-
89-
def setLowPassFilter(self, enabled: bool): # noqa: N802
90-
# TODO: 2.0.6 移除
9179
"""! Set low pass filter enabled or not
9280
9381
@param enabled Enable filter or not
@@ -98,21 +86,11 @@ def setLowPassFilter(self, enabled: bool): # noqa: N802
9886
self.i2c.writeto_mem(self.addr, 0x80, b"\x00")
9987

10088
def get_low_pass_filter(self) -> bool:
101-
# 2.0.3 添加
102-
return self.getLowPassFilter()
103-
104-
def getLowPassFilter(self) -> bool: # noqa: N802
105-
# TODO: 2.0.6 移除
10689
"""! Get low pass filter enabled or not"""
10790
data = self.i2c.readfrom_mem(self.addr, 0x80, 1)
10891
return data == b"\x01"
10992

11093
def set_average_filter_level(self, level: int):
111-
# 2.0.3 添加
112-
self.setAverageFilterLevel(level)
113-
114-
def setAverageFilterLevel(self, level: int): # noqa: N802
115-
# TODO: 2.0.6 移除
11694
"""! Set average filter level
11795
11896
@param level level of average filter, larger value for smoother result but more latency
@@ -123,21 +101,11 @@ def setAverageFilterLevel(self, level: int): # noqa: N802
123101
self.i2c.writeto_mem(self.addr, 0x81, struct.pack("b", level))
124102

125103
def get_average_filter_level(self) -> int:
126-
# 2.0.3 添加
127-
return self.getAverageFilterLevel()
128-
129-
def getAverageFilterLevel(self) -> int: # noqa: N802
130-
# TODO: 2.0.6 移除
131104
"""! Get average filter level"""
132105
data = self.i2c.readfrom_mem(self.addr, 0x81, 1)
133106
return struct.unpack("b", data)[0]
134107

135108
def set_ema_filter_alpha(self, alpha: int):
136-
# 2.0.3 添加
137-
self.setEMAFilterAlpha(alpha)
138-
139-
def setEMAFilterAlpha(self, alpha: int): # noqa: N802
140-
# TODO: 2.0.6 移除
141109
"""! Set ema filter alpha
142110
143111
@param alpha alpha of ema filter, smaller value for smoother result but more latency
@@ -148,10 +116,6 @@ def setEMAFilterAlpha(self, alpha: int): # noqa: N802
148116
self.i2c.writeto_mem(self.addr, 0x82, struct.pack("b", alpha))
149117

150118
def get_ema_filter_alpha(self) -> int:
151-
return self.getEMAFilterAlpha()
152-
153-
def getEMAFilterAlpha(self) -> int: # noqa: N802
154-
# TODO: 2.0.6 移除
155119
"""! Get ema filter alpha"""
156120
data = self.i2c.readfrom_mem(self.addr, 0x82, 1)
157121
return struct.unpack("b", data)[0]

0 commit comments

Comments
 (0)