Skip to content

Commit 2e20a70

Browse files
committed
Re-added "string" class attribute and usage
1 parent 3a71fb0 commit 2e20a70

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

adafruit_hts221.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
from adafruit_register.i2c_bit import RWBit, ROBit
3636

3737
try:
38-
from typing import Sequence, Tuple
38+
from typing import Union, Sequence, Tuple
3939
from busio import I2C
4040
except ImportError:
4141
pass
@@ -71,13 +71,17 @@ class CV:
7171
"""struct helper"""
7272

7373
@classmethod
74-
def add_values(cls, value_tuples: Sequence[Tuple[str, int]]) -> None:
74+
def add_values(
75+
cls, value_tuples: Sequence[Tuple[str, int, Union[int, str]]]
76+
) -> None:
7577
"""creates CV entries"""
7678
cls.contents = {}
79+
cls.string = {}
7780

7881
for value_tuple in value_tuples:
79-
name, value = value_tuple
82+
name, value, string = value_tuple
8083
setattr(cls, name, value)
84+
cls.string[value] = string
8185

8286
@classmethod
8387
def is_valid(cls, value: int) -> bool:
@@ -108,10 +112,13 @@ class Rate(CV):
108112

109113
Rate.add_values(
110114
(
111-
("ONE_SHOT", 0),
112-
("RATE_1_HZ", 1),
113-
("RATE_7_HZ", 2),
114-
("RATE_12_5_HZ", 3),
115+
("ONE_SHOT", 0, 0),
116+
(
117+
"RATE_1_HZ",
118+
1,
119+
),
120+
("RATE_7_HZ", 2, 7),
121+
("RATE_12_5_HZ", 3, 12.5),
115122
)
116123
)
117124

0 commit comments

Comments
 (0)