Closed tekktrik closed 2 years ago
looks ok to me @caternuson can also take a look
Oh yah, that issue. Thanks for picking this up and PRing a fix.
LGTM. Even tested. Did black change the long string message syntax to be multi-line? Looks like it's adding a bunch of white space.
BEFORE
Adafruit CircuitPython 7.1.1 on 2022-01-14; Adafruit ItsyBitsy M4 Express with samd51g19
>>> import board
>>> import adafruit_scd4x
>>> scd4x = adafruit_scd4x.SCD4X(board.I2C())
>>> scd4x.altitude
0
>>> scd4x.altitude = 42
>>> scd4x.altitude
42
>>> scd4x.start_periodic_measurement()
>>> scd4x.altitude
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/lib/adafruit_scd4x.py", line 284, in altitude
File "/lib/adafruit_scd4x.py", line 307, in _send_command
OSError: [Errno 5] Input/output error
>>>
AFTER
Adafruit CircuitPython 7.1.1 on 2022-01-14; Adafruit ItsyBitsy M4 Express with samd51g19
>>> import board
>>> import adafruit_scd4x
>>> scd4x = adafruit_scd4x.SCD4X(board.I2C())
>>> scd4x.altitude
42
>>> scd4x.start_periodic_measurement()
>>> scd4x.altitude
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/lib/adafruit_scd4x.py", line 302, in altitude
File "/lib/adafruit_scd4x.py", line 329, in _send_command
RuntimeError: Could not communicate via I2C, some commands/settings unavailable while in working mode
>>>
Thanks for testing! I think I botched how I accounted for breaking up the string, this new commit should fix that whitespace.
Yep. Looks good:
Adafruit CircuitPython 7.1.1 on 2022-01-14; Adafruit ItsyBitsy M4 Express with samd51g19
>>> import board
>>> import adafruit_scd4x
>>> scd4x = adafruit_scd4x.SCD4X(board.I2C())
>>> scd4x.altitude
42
>>> scd4x.start_periodic_measurement()
>>> scd4x.altitude
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/lib/adafruit_scd4x.py", line 302, in altitude
File "/lib/adafruit_scd4x.py", line 329, in _send_command
RuntimeError: Could not communicate via I2C, some commands/settings unavailable while in working mode
>>>
Resolves #10 by:
OSError
into aRuntimeError
that explains that some commands are unavailable in working mode. Still mentions it as an I2C communication just in case it really isstart_periodic_measurement()
(and a reference to that instart_low_periodic_measurement()
) to help clarify.Not tested yet, but wanted to know if this is the right solution