44
44
__version__ = "0.0.0-auto.0"
45
45
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_CCS811.git"
46
46
47
- _BASELINE_PACKING_FORMAT = "<H"
48
47
49
48
_ALG_RESULT_DATA = const (0x02 )
50
49
_RAW_DATA = const (0x03 )
@@ -161,7 +160,7 @@ def _update_data(self):
161
160
@property
162
161
def baseline (self ):
163
162
"""
164
- The function read and return the current baseline value.
163
+ The propery reads and returns the current baseline value.
165
164
The returned value is packed into an integer.
166
165
Later the same integer can be passed `set_baseline` function
167
166
in order to set a new baseline.
@@ -170,16 +169,17 @@ def baseline(self):
170
169
buf [0 ] = _BASELINE
171
170
with self .i2c_device as i2c :
172
171
i2c .write_then_readinto (buf , buf , out_end = 1 , in_start = 1 )
173
- return struct .unpack (_BASELINE_PACKING_FORMAT , buf [1 :])[0 ]
172
+ return struct .unpack ("<H" , buf [1 :])[0 ]
174
173
175
- def set_baseline (self , baseline_int ):
174
+ @baseline .setter
175
+ def baseline (self , baseline_int ):
176
176
"""
177
- The function lets you set a new baseline. As an argument accepts
177
+ The property lets you set a new baseline. As a value accepts
178
178
integer which represents packed baseline 2 bytes value.
179
179
"""
180
180
buf = bytearray (3 )
181
181
buf [0 ] = _BASELINE
182
- struct .pack_into (_BASELINE_PACKING_FORMAT , buf , 1 , baseline_int )
182
+ struct .pack_into ("<H" , buf , 1 , baseline_int )
183
183
with self .i2c_device as i2c :
184
184
i2c .write (buf )
185
185
0 commit comments