Skip to content
This repository was archived by the owner on Feb 28, 2024. It is now read-only.

Commit fad152c

Browse files
committed
RTC: Added javadoc comments
1 parent c460fe1 commit fad152c

File tree

1 file changed

+63
-56
lines changed

1 file changed

+63
-56
lines changed

src/utility/RTC/PCF8563T.cpp

Lines changed: 63 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ PCF8563TClass::PCF8563TClass()
5959

6060
/**
6161
* Start the communication with the RTC
62-
*
63-
* @return true if the RTC Controller is on the I2C bus, false in case it is not in the bus.
62+
* Initialize I2C (Wire1) bus and check if the chip is connected trhoug sending an ACK on the I2C bus.
63+
* @return true if the RTC Controller is on the I2C bus, false if it is not.
6464
*
6565
*/
6666
bool PCF8563TClass::begin()
@@ -75,9 +75,9 @@ bool PCF8563TClass::begin()
7575
}
7676

7777
/**
78-
* Set Year number
79-
*
80-
* @param years Year's number
78+
* Set Year number's value
79+
* Save an unsigned byte with the Year's value
80+
* @param years Year's unsigned byte
8181
*/
8282
void PCF8563TClass::setYears(uint8_t years) {
8383
uint8_t dec = years / 10;
@@ -86,9 +86,9 @@ void PCF8563TClass::setYears(uint8_t years) {
8686
}
8787

8888
/**
89-
* Set Month number
90-
*
91-
* @param months Month's number (0 to 12)
89+
* Set Month number's value
90+
* Save an unsigned byte with the Month's value
91+
* @param months Month's unsigned byte (0 to 12)
9292
*/
9393
void PCF8563TClass::setMonths(uint8_t months) {
9494
uint8_t offset = 0;
@@ -99,9 +99,9 @@ void PCF8563TClass::setMonths(uint8_t months) {
9999
}
100100

101101
/**
102-
* Set Day number
103-
*
104-
* @param days day's number
102+
* Set Day number's value
103+
* Save an unsigned byte with the Day's value
104+
* @param days day's unsigned byte
105105
*/
106106
void PCF8563TClass::setDays(uint8_t days) {
107107
uint8_t dec = days / 10;
@@ -110,9 +110,9 @@ void PCF8563TClass::setDays(uint8_t days) {
110110
}
111111

112112
/**
113-
* Set Hour
114-
*
115-
* @param hours hour number
113+
* Set Hour(s) number's value
114+
* Save an unsigned byte with the Hour(s) value
115+
* @param hours hour unsigned byte (0 - 23)
116116
*/
117117
void PCF8563TClass::setHours(uint8_t hours) {
118118
uint8_t dec = hours / 10;
@@ -121,9 +121,9 @@ void PCF8563TClass::setHours(uint8_t hours) {
121121
}
122122

123123
/**
124-
* Set Minute
125-
*
126-
* @param minutes minute number
124+
* Set Minute(s) number's value
125+
* Save an unsigned byte with the Minute(s) value
126+
* @param minutes minute unsigned byte (0-60)
127127
*/
128128
void PCF8563TClass::setMinutes(uint8_t minutes) {
129129
uint8_t dec = minutes / 10;
@@ -132,9 +132,9 @@ void PCF8563TClass::setMinutes(uint8_t minutes) {
132132
}
133133

134134
/**
135-
* Set Second number
136-
*
137-
* @param seconds Second number
135+
* Set Second(s) number's value
136+
* Save an unsigned byte with the Second(s) value
137+
* @param seconds Second(s) unsigned byte (0-60)
138138
*/
139139
void PCF8563TClass::setSeconds(uint8_t seconds) {
140140
uint8_t dec = seconds / 10;
@@ -143,20 +143,20 @@ void PCF8563TClass::setSeconds(uint8_t seconds) {
143143
}
144144

145145
/**
146-
* Get Year number
147-
*
148-
* @return number of years
146+
* Get Year(s) number's value
147+
* Get unsigned byte with the Year(s) value
148+
* @return byte with Year(s) value
149149
*/
150150
uint8_t PCF8563TClass::getYears() {
151151
uint8_t years = readByte(PCF8563T_YEARS_REG);
152152
return (years & 0x0F) + ((years >> 4)*10);
153153
}
154154

155155
/**
156-
* Get Month number
157-
*
158-
* @return number of month
159-
*/
156+
* Get Month(s) month's value
157+
* Get unsigned byte with the month(s) value
158+
* @return byte with Month(s) value
159+
*/
160160
uint8_t PCF8563TClass::getMonths() {
161161
uint8_t months = readByte(PCF8563T_MONTHS_REG) & 0x1F;
162162
if(months > 9) {
@@ -167,47 +167,47 @@ uint8_t PCF8563TClass::getMonths() {
167167
}
168168

169169
/**
170-
* Get Day number
171-
*
172-
* @return number of days
173-
*/
170+
* Get Day(s) number's value
171+
* Get unsigned byte with the Day(s) value
172+
* @return byte with Day(s) value
173+
*/
174174
uint8_t PCF8563TClass::getDays() {
175175
uint8_t days = readByte(PCF8563T_DAYS_REG);
176176
return (days & 0x0F) + ((days >> 4)*10);
177177
}
178178

179179
/**
180-
* Get Hour number
181-
*
182-
* @return number of hours
183-
*/
180+
* Get Hour(s) number's value
181+
* Get unsigned byte with the Hour(s) value
182+
* @return byte with Hour(s) value
183+
*/
184184
uint8_t PCF8563TClass::getHours() {
185185
uint8_t hours = readByte(PCF8563T_HOURS_REG) & 0x3F;
186186
return (hours & 0x0F) + ((hours >> 4)*10);
187187
}
188188

189189
/**
190-
* Get Minute number
191-
*
192-
* @return number of minutes
193-
*/
190+
* Get Minute(s) number's value
191+
* Get unsigned byte with the Minute(s) value
192+
* @return byte with Minute(s) value
193+
*/
194194
uint8_t PCF8563TClass::getMinutes() {
195195
uint8_t minutes = (readByte(PCF8563T_MINUTES_REG)) & 0x7F ;
196196
return (minutes & 0x0F) + ((minutes >> 4)*10);
197197
}
198198

199199
/**
200-
* Get Second number
201-
*
202-
* @return number of seconds
203-
*/
200+
* Get Second(s) number's value
201+
* Get unsigned byte with the Second(s) value
202+
* @return byte with Second(s) value
203+
*/
204204
uint8_t PCF8563TClass::getSeconds() {
205205
uint8_t seconds = readByte(PCF8563T_VL_SECONDS_REG) & 0x7F;
206206
return (seconds & 0x0F) + ((seconds >> 4)*10);
207207
}
208208

209209
/**
210-
* Set time by epoch
210+
* Set time Epoch format
211211
*
212212
*/
213213
void PCF8563TClass::setEpoch() {
@@ -224,9 +224,10 @@ void PCF8563TClass::setEpoch() {
224224
}
225225

226226
/**
227-
* Set time by epoch
227+
* Set time with Epoch format
228+
*
228229
*
229-
* @param seconds number of seconds
230+
* @param seconds number of seconds (time_t type)
230231
*/
231232
void PCF8563TClass::setEpoch(time_t seconds) {
232233
struct tm time;
@@ -242,8 +243,11 @@ void PCF8563TClass::setEpoch(time_t seconds) {
242243
}
243244

244245
/**
245-
* Set time by epoch
246+
* Set time with Epoch format
246247
*
248+
* Convert the input values to Epoch format
249+
* example: Tue, 06 Jul 2021 11:55:27 GMT -> 1625572527
250+
*
247251
* @param years number of years
248252
* @param mohths number of months
249253
* @param days number of days
@@ -267,9 +271,13 @@ void PCF8563TClass::setEpoch(uint8_t years, uint8_t months, uint8_t days, uint8_
267271
}
268272

269273
/**
270-
* Get epoch number, convert real time to difference between actual time and epoch(Unix time)
271-
*
272-
* @return number of seconds after Unix time
274+
* Get epoch number
275+
* Convert real time to difference between actual time and Epoch(Unix time)
276+
* Saved into time_t type
277+
*
278+
* example: 1625572527 -> Tue, 06 Jul 2021 11:55:27 GMT
279+
*
280+
* @return number of seconds after Unix time (time_t type)
273281
*/
274282
time_t PCF8563TClass::getEpoch() {
275283
struct tm time;
@@ -287,15 +295,15 @@ time_t PCF8563TClass::getEpoch() {
287295
}
288296

289297
/**
290-
* Enable alarm mode
298+
* Enable alarm
291299
*
292300
*/
293301
void PCF8563TClass::enableAlarm() {
294302
writeByte(PCF8563T_STATUS_2_REG, (readByte(PCF8563T_STATUS_2_REG) & PCF8563T_STATUS_2_CLEAR_INT) | PCF8563T_STATUS_2_AIE_MASK);
295303
}
296304

297305
/**
298-
* Disable alarm mode
306+
* Disable alarm
299307
*
300308
*/
301309
void PCF8563TClass::disableAlarm() {
@@ -313,8 +321,7 @@ void PCF8563TClass::clearAlarm() {
313321
/**
314322
* Set alarm's minute
315323
*
316-
* @param minutes minute number for the Aarm
317-
* @return none
324+
* @param minutes minute(s) value for the Alarm (byte type)
318325
*/
319326
void PCF8563TClass::setMinuteAlarm(uint8_t minutes) {
320327
uint8_t dec = minutes / 10;
@@ -334,7 +341,7 @@ void PCF8563TClass::disableMinuteAlarm() {
334341
/**
335342
* Set Alarm's hour
336343
*
337-
* @param hours hour number for the Alarm
344+
* @param hours hour(s) value for the Alarm (byte type)
338345
*/
339346
void PCF8563TClass::setHourAlarm(uint8_t hours) {
340347
uint8_t dec = hours / 10;
@@ -354,7 +361,7 @@ void PCF8563TClass::disableHourAlarm() {
354361
/**
355362
* Set Alarm's day
356363
*
357-
* @param days day number for the Alarm
364+
* @param days day value for the Alarm (byte type)
358365
*/
359366
void PCF8563TClass::setDayAlarm(uint8_t days) {
360367
uint8_t dec = days / 10;

0 commit comments

Comments
 (0)