30
30
DO NOT ACCESS REGISTERS WITH ADDRESSES HIGHER THAN 0x08 AS THEY CONTAIN CALIBRATION CODES.
31
31
DOING SO MAY IRREPARABLY DAMAGE THE SENSOR.
32
32
33
- This driver is a comprehensive implementation of the MCP9808 sensor's features. It is designed
33
+ This driver is a comprehensive implementation of the MCP9808 sensor's features. It is designed
34
34
to be easy to use and offers a high level of abstraction from the sensor's registers.
35
- The driver includes built-in error checking (such as type validation and bounds checking
35
+ The driver includes built-in error checking (such as type validation and bounds checking
36
36
for register access) and a debug mode to assist with development.
37
37
38
38
61
61
62
62
63
63
# For more information, see the README file at
64
- https://github.com/MarcoMiano/mip-mcp9808
64
+ https://github.com/MarcoMiano/mip-mcp9808
65
65
"""
66
66
67
67
from machine import SoftI2C , I2C
@@ -156,7 +156,7 @@ def _check_device(self) -> None:
156
156
self ._dev_id : bytes = self ._i2c .readfrom_mem (self ._addr , self .REG_DEV , 2 )
157
157
if self ._dev_id [0 ] != 4 :
158
158
raise Exception (f"Invalid device ID { self ._dev_id [0 ]} " )
159
- if self ._dev_id [1 ] != 0 and self ._debug == True :
159
+ if self ._dev_id [1 ] != 0 and self ._debug :
160
160
print (
161
161
f"[WARN] Module written for HW revision 0 but got { self ._dev_id [1 ]} ." ,
162
162
)
@@ -307,7 +307,7 @@ def _set_config(
307
307
print (
308
308
f"[WARN] Failed to set crit_lock. Set { crit_lock } got { self ._crit_lock } " ,
309
309
)
310
- if self .irq_clear_bit == True :
310
+ if self .irq_clear_bit :
311
311
print (
312
312
"[WARN] Something wrong with irq_clear_bit. Should always read False"
313
313
)
@@ -332,7 +332,7 @@ def _set_config(
332
332
f"[WARN] Failed to set alert_mode. Set { alert_mode } got { self ._alert_mode } ." ,
333
333
)
334
334
335
- def _set_alert_limit (self , limit : float | int , register : int ) -> None :
335
+ def _set_alert_limit (self , limit : float , register : int ) -> None :
336
336
"""Private method to set the alert limit register.
337
337
338
338
Inteded to be used by the set_alert_XXXXX_limit wrapper methods.
@@ -350,13 +350,13 @@ def _set_alert_limit(self, limit: float | int, register: int) -> None:
350
350
``None``
351
351
"""
352
352
353
- if not limit .__class__ in [float , int ]:
353
+ if limit .__class__ not in [float ]:
354
354
raise TypeError (
355
355
f"limit: { limit } { limit .__class__ } . Expecting float|int." ,
356
356
)
357
357
if limit < - 128 or limit > 127 :
358
358
raise ValueError ("Temperature out of range [-128, 127]" )
359
- if (limit < - 40 or limit > 125 ) and self ._debug == True :
359
+ if (limit < - 40 or limit > 125 ) and self ._debug :
360
360
print (
361
361
"[WARN] Temperature outside of operational range, limit won't be ever reached." ,
362
362
)
@@ -505,7 +505,7 @@ def set_alert_mode(self, irq=False) -> None:
505
505
"""
506
506
self ._set_config (alert_mode = irq )
507
507
508
- def set_alert_upper_limit (self , upper_limit : float | int ) -> None :
508
+ def set_alert_upper_limit (self , upper_limit : float ) -> None :
509
509
"""Set the alert upper limit.
510
510
511
511
Args:
@@ -522,7 +522,7 @@ def set_alert_upper_limit(self, upper_limit: float | int) -> None:
522
522
"""
523
523
self ._set_alert_limit (upper_limit , self .REG_ATU )
524
524
525
- def set_alert_lower_limit (self , lower_limit : float | int ) -> None :
525
+ def set_alert_lower_limit (self , lower_limit : float ) -> None :
526
526
"""Set the alert lower limit.
527
527
528
528
Args:
@@ -538,7 +538,7 @@ def set_alert_lower_limit(self, lower_limit: float | int) -> None:
538
538
"""
539
539
self ._set_alert_limit (lower_limit , self .REG_ATL )
540
540
541
- def set_alert_crit_limit (self , crit_limit : float | int ) -> None :
541
+ def set_alert_crit_limit (self , crit_limit : float ) -> None :
542
542
"""Set the alert critical limit.
543
543
544
544
Args:
0 commit comments