@@ -98,13 +98,13 @@ def _value_is_in_range(value, *, lo_limit, hi_limit):
9898 assert lo_limit <= value <= hi_limit
9999 except AssertionError as error :
100100 raise ValueError (
101- "Value must be in the range %s to %s inclusive." % (lo_limit , hi_limit )
101+ "Value must be in the range %s to %s, inclusive." % (lo_limit , hi_limit )
102102 ) from error
103103 return value
104104
105105
106106class AS3935_Sensor :
107- """Driver for the Franklin AS3935 lightning detector chip ."""
107+ """Register handling for the Franklin AS3935 PSI and I2C drivers ."""
108108
109109 # Constants to make register values human readable in the code
110110 DATA_PURGE = _0X00 # 0x00 - Distance recalculated after purging old data
@@ -199,8 +199,8 @@ def indoor(self, value):
199199
200200 @property
201201 def watchdog (self ):
202- """int: Watchdog thresholdin the range 0 - 10 (default is 2). Higher thresholds reduce
203- triggers by disturbers but decrease sensitivity to lightning strikes.
202+ """int: Watchdog threshold in the range 0 - 10 (default is 2). Higher thresholds reduce
203+ triggers from disturbers but decrease sensitivity to lightning strikes.
204204 """
205205 return self ._get_register (self ._WDTH )
206206
@@ -265,7 +265,7 @@ def interrupt_status(self):
265265 """int: Status of the interrupt register. These constants are defined as helpers:
266266 LIGHTNING, DISTURBER. NOISE, DATA_PURGE.
267267
268- note: : This register is automatically cleared by the sensor after it is read.
268+ Note : This register is automatically cleared by the sensor after it is read.
269269 """
270270 # Wait a minimum of 2 ms between the interrupt pin going high and reading the register
271271 time .sleep (0.0002 )
@@ -330,7 +330,7 @@ def power_down(self, value):
330330 self ._set_register (self ._PWD , 0x00 )
331331 # RCO clocks need to be calibrated when powering back up from a power_down
332332 # Procedure as per AS3935 datasheet
333- self ._calibrate_clocks ()
333+ self .calibrate_clocks ()
334334 self ._check_clock_calibration ()
335335 self ._set_register (self ._DISP_FLAGS , 0x02 )
336336 time .sleep (0.002 )
@@ -399,9 +399,9 @@ def output_trco(self, value):
399399 @property
400400 def tuning_capacitance (self ):
401401 """int: The tuning capacitance for the RLC antenna in pF. This capacitance
402- is added to the antenna to tune it within 3.5 % of 500 kHz (483 - 517 kHz).
402+ is added to the antenna to tune it to within 3.5 % of 500 kHz (483 - 517 kHz).
403403
404- Capacitance must be in the range 0 - 120. Any of these values may be set ,
404+ Capacitance must be in the range 0 - 120. Any of these values may be used ,
405405 however, the capacitance is set in steps of 8 pF, so values less than 120
406406 will be rounded down to the nearest step. Default is 0.
407407 """
@@ -432,8 +432,9 @@ def _check_clock_calibration(self):
432432 if _0X01 in [trco_result , srco_result ]:
433433 raise RuntimeError ("AS3935 RCO clock calibration failed." )
434434
435- def _calibrate_clocks (self ):
436- """Recalibrate the internal clocks."""
435+ def calibrate_clocks (self ):
436+ """Recalibrate the internal clocks. The clocks rely on the tuning frequency of
437+ the antenna, so adjust that to 500 KHz +/- 3.5 % before calibrating."""
437438 # Send the direct command to the CALIB_RCO register to start automatic RCO calibration
438439 # then check that the calibration has succeeded
439440 self ._set_register (self ._CALIB_RCO , self .DIRECT_COMMAND )
@@ -466,7 +467,7 @@ def _startup_checks(self):
466467 # checking the clock calibration status tells the that the clocks are OK and if
467468 # the calibration times out, we know that there are no comms with the sensor
468469 self .reset ()
469- self ._calibrate_clocks ()
470+ self .calibrate_clocks ()
470471 self ._check_clock_calibration ()
471472
472473
0 commit comments