@@ -49,9 +49,18 @@ class is inherited by the chip-specific subclasses.
49
49
from adafruit_register import i2c_bcd_alarm
50
50
from adafruit_register import i2c_bcd_datetime
51
51
52
+ try :
53
+ import typing # pylint: disable=unused-import
54
+ from busio import I2C
55
+ except ImportError :
56
+ pass
57
+
52
58
53
59
class PCF8563 :
54
- """Interface to the PCF8563 RTC."""
60
+ """Interface to the PCF8563 RTC.
61
+
62
+ :param I2C i2c_bus: The I2C bus object
63
+ """
55
64
56
65
datetime_compromised = i2c_bit .RWBit (0x2 , 7 )
57
66
"""True if the clock integrity is compromised."""
@@ -74,7 +83,7 @@ class PCF8563:
74
83
alarm_status = i2c_bit .RWBit (0x01 , 3 )
75
84
"""True if alarm is alarming. Set to False to reset."""
76
85
77
- def __init__ (self , i2c_bus ) :
86
+ def __init__ (self , i2c_bus : I2C ) -> None :
78
87
time .sleep (0.05 )
79
88
self .i2c_device = I2CDevice (i2c_bus , 0x51 )
80
89
@@ -87,13 +96,13 @@ def __init__(self, i2c_bus):
87
96
i2c .write_then_readinto (buf , buf , out_end = 1 , in_start = 1 )
88
97
89
98
@property
90
- def datetime (self ):
99
+ def datetime (self ) -> time . struct_time :
91
100
"""Gets the current date and time or sets the current date and time then starts the
92
101
clock."""
93
102
return self .datetime_register
94
103
95
104
@datetime .setter
96
- def datetime (self , value ) :
105
+ def datetime (self , value : time . struct_time ) -> None :
97
106
# Automatically sets lost_power to false.
98
107
self .datetime_register = value
99
108
self .datetime_compromised = False
0 commit comments