@@ -52,6 +52,13 @@ class is inherited by the chip-specific subclasses.
52
52
from adafruit_register import i2c_bcd_alarm
53
53
from adafruit_register import i2c_bcd_datetime
54
54
55
+ try :
56
+ import typing # pylint: disable=unused-import
57
+ from busio import I2C
58
+ from time import struct_time
59
+ except ImportError :
60
+ pass
61
+
55
62
STANDARD_BATTERY_SWITCHOVER_AND_DETECTION = 0b000
56
63
BATTERY_SWITCHOVER_OFF = 0b111
57
64
@@ -136,7 +143,7 @@ class PCF8523:
136
143
"""Calibration offset to apply, from -64 to +63. See the PCF8523 datasheet
137
144
figure 18 for the offset calibration calculation workflow."""
138
145
139
- def __init__ (self , i2c_bus ):
146
+ def __init__ (self , i2c_bus : I2C ):
140
147
self .i2c_device = I2CDevice (i2c_bus , 0x68 )
141
148
142
149
# Try and verify this is the RTC we expect by checking the timer B
@@ -151,13 +158,13 @@ def __init__(self, i2c_bus):
151
158
raise ValueError ("Unable to find PCF8523 at i2c address 0x68." )
152
159
153
160
@property
154
- def datetime (self ):
161
+ def datetime (self ) -> struct_time :
155
162
"""Gets the current date and time or sets the current date and time then starts the
156
163
clock."""
157
164
return self .datetime_register
158
165
159
166
@datetime .setter
160
- def datetime (self , value ):
167
+ def datetime (self , value : struct_time ):
161
168
# Automatically sets lost_power to false.
162
169
self .power_management = STANDARD_BATTERY_SWITCHOVER_AND_DETECTION
163
170
self .datetime_register = value
0 commit comments