3030DO NOT ACCESS REGISTERS WITH ADDRESSES HIGHER THAN 0x08 AS THEY CONTAIN CALIBRATION CODES.
3131DOING SO MAY IRREPARABLY DAMAGE THE SENSOR.
3232
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
3434to 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
3636for register access) and a debug mode to assist with development.
3737
3838
6161
6262
6363# For more information, see the README file at
64- https://github.com/MarcoMiano/mip-mcp9808
64+ https://github.com/MarcoMiano/mip-mcp9808
6565"""
6666
6767from machine import SoftI2C , I2C
@@ -156,7 +156,7 @@ def _check_device(self) -> None:
156156 self ._dev_id : bytes = self ._i2c .readfrom_mem (self ._addr , self .REG_DEV , 2 )
157157 if self ._dev_id [0 ] != 4 :
158158 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 :
160160 print (
161161 f"[WARN] Module written for HW revision 0 but got { self ._dev_id [1 ]} ." ,
162162 )
@@ -307,7 +307,7 @@ def _set_config(
307307 print (
308308 f"[WARN] Failed to set crit_lock. Set { crit_lock } got { self ._crit_lock } " ,
309309 )
310- if self .irq_clear_bit == True :
310+ if self .irq_clear_bit :
311311 print (
312312 "[WARN] Something wrong with irq_clear_bit. Should always read False"
313313 )
@@ -332,7 +332,7 @@ def _set_config(
332332 f"[WARN] Failed to set alert_mode. Set { alert_mode } got { self ._alert_mode } ." ,
333333 )
334334
335- def _set_alert_limit (self , limit : float | int , register : int ) -> None :
335+ def _set_alert_limit (self , limit : float , register : int ) -> None :
336336 """Private method to set the alert limit register.
337337
338338 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:
350350 ``None``
351351 """
352352
353- if not limit .__class__ in [float , int ]:
353+ if limit .__class__ not in [float ]:
354354 raise TypeError (
355355 f"limit: { limit } { limit .__class__ } . Expecting float|int." ,
356356 )
357357 if limit < - 128 or limit > 127 :
358358 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 :
360360 print (
361361 "[WARN] Temperature outside of operational range, limit won't be ever reached." ,
362362 )
@@ -505,7 +505,7 @@ def set_alert_mode(self, irq=False) -> None:
505505 """
506506 self ._set_config (alert_mode = irq )
507507
508- def set_alert_upper_limit (self , upper_limit : float | int ) -> None :
508+ def set_alert_upper_limit (self , upper_limit : float ) -> None :
509509 """Set the alert upper limit.
510510
511511 Args:
@@ -522,7 +522,7 @@ def set_alert_upper_limit(self, upper_limit: float | int) -> None:
522522 """
523523 self ._set_alert_limit (upper_limit , self .REG_ATU )
524524
525- def set_alert_lower_limit (self , lower_limit : float | int ) -> None :
525+ def set_alert_lower_limit (self , lower_limit : float ) -> None :
526526 """Set the alert lower limit.
527527
528528 Args:
@@ -538,7 +538,7 @@ def set_alert_lower_limit(self, lower_limit: float | int) -> None:
538538 """
539539 self ._set_alert_limit (lower_limit , self .REG_ATL )
540540
541- def set_alert_crit_limit (self , crit_limit : float | int ) -> None :
541+ def set_alert_crit_limit (self , crit_limit : float ) -> None :
542542 """Set the alert critical limit.
543543
544544 Args:
0 commit comments