Skip to content

Commit a925301

Browse files
committed
Rename members to avoid any confusion
_day -> _wday is a week day (1 to 7) _date -> _day is the day (1 to 31) _alarmDate -> _alarmDay is the alarm day (1 to 31) Signed-off-by: Frederic.Pillon <[email protected]>
1 parent b74ba71 commit a925301

File tree

2 files changed

+35
-35
lines changed

2 files changed

+35
-35
lines changed

src/STM32RTC.cpp

+33-33
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ void STM32RTC::begin(RTC_Hour_Format format)
8181
syncTime();
8282
syncDate();
8383
// Use current time to init alarm members
84-
_alarmDate = _date;
84+
_alarmDay = _day;
8585
_alarmHours = _hours;
8686
_alarmMinutes = _minutes;
8787
_alarmSeconds = _seconds;
@@ -128,28 +128,28 @@ void STM32RTC::setClockSource(RTC_Source_Clock source)
128128
void STM32RTC::enableAlarm(Alarm_Match match)
129129
{
130130
hourAM_PM_t period;
131-
uint8_t date, hours, minutes, seconds;
131+
uint8_t day, hours, minutes, seconds;
132132
uint32_t subSeconds;
133133

134134
if(_configured) {
135135
RTC_GetTime(&hours, &minutes, &seconds, &subSeconds, &period);
136-
date = getDay();
136+
day = getDay();
137137
switch (match) {
138138
case MATCH_OFF:
139139
RTC_StopAlarm();
140140
break;
141141
case MATCH_YYMMDDHHMMSS://kept for compatibility
142142
case MATCH_MMDDHHMMSS: //kept for compatibility
143143
case MATCH_DHHMMSS:
144-
date = _alarmDate;
144+
day = _alarmDay;
145145
case MATCH_HHMMSS:
146146
hours = _alarmHours;
147147
period = (_alarmPeriod == RTC_AM)? AM: PM;
148148
case MATCH_MMSS:
149149
minutes = _alarmMinutes;
150150
case MATCH_SS:
151151
seconds = _alarmSeconds;
152-
RTC_StartAlarm(date, hours, minutes, seconds, subSeconds, period);
152+
RTC_StartAlarm(day, hours, minutes, seconds, subSeconds, period);
153153
break;
154154
default:
155155
break;
@@ -249,17 +249,17 @@ uint8_t STM32RTC::getHours(RTC_AM_PM *period)
249249
uint8_t STM32RTC::getWeekDay(void)
250250
{
251251
syncDate();
252-
return _day;
252+
return _wday;
253253
}
254254

255255
/**
256-
* @brief get RTC date.
257-
* @retval return the current date from the RTC.
256+
* @brief get RTC day.
257+
* @retval return the current day from the RTC.
258258
*/
259259
uint8_t STM32RTC::getDay(void)
260260
{
261261
syncDate();
262-
return _date;
262+
return _day;
263263
}
264264

265265
/**
@@ -328,13 +328,13 @@ uint8_t STM32RTC::getAlarmHours(RTC_AM_PM *period)
328328
}
329329

330330
/**
331-
* @brief get RTC alarm date.
332-
* @retval return the current alarm date.
331+
* @brief get RTC alarm day.
332+
* @retval return the current alarm day.
333333
*/
334334
uint8_t STM32RTC::getAlarmDay(void)
335335
{
336336
syncAlarmTime();
337-
return _alarmDate;
337+
return _alarmDay;
338338
}
339339

340340
/**
@@ -487,27 +487,27 @@ void STM32RTC::setTime(uint8_t hours, uint8_t minutes, uint8_t seconds, uint32_t
487487
void STM32RTC::setWeekDay(uint8_t weekDay)
488488
{
489489
if (_configured) {
490-
RTC_GetDate(&_year, &_month, &_date, &_day);
490+
RTC_GetDate(&_year, &_month, &_day, &_wday);
491491
if((weekDay >= 1) && (weekDay <= 7)) {
492-
_day = weekDay;
492+
_wday = weekDay;
493493
}
494-
RTC_SetDate(_year, _month, _date, _day);
494+
RTC_SetDate(_year, _month, _day, _wday);
495495
}
496496
}
497497

498498
/**
499-
* @brief set RTC date.
500-
* @param date: 1-31
499+
* @brief set RTC day.
500+
* @param day: 1-31
501501
* @retval none
502502
*/
503503
void STM32RTC::setDay(uint8_t day)
504504
{
505505
if (_configured) {
506-
RTC_GetDate(&_year, &_month, &_date, &_day);
506+
RTC_GetDate(&_year, &_month, &_day, &_wday);
507507
if((day >= 1) && (day <= 31)) {
508-
_date = day;
508+
_day = day;
509509
}
510-
RTC_SetDate(_year, _month, _date, _day);
510+
RTC_SetDate(_year, _month, _day, _wday);
511511
}
512512
}
513513

@@ -519,11 +519,11 @@ void STM32RTC::setDay(uint8_t day)
519519
void STM32RTC::setMonth(uint8_t month)
520520
{
521521
if (_configured) {
522-
RTC_GetDate(&_year, &_month, &_date, &_day);
522+
RTC_GetDate(&_year, &_month, &_day, &_wday);
523523
if((month >= 1) && (month <= 12)) {
524524
_month = month;
525525
}
526-
RTC_SetDate(_year, _month, _date, _day);
526+
RTC_SetDate(_year, _month, _day, _wday);
527527
}
528528
}
529529

@@ -535,11 +535,11 @@ void STM32RTC::setMonth(uint8_t month)
535535
void STM32RTC::setYear(uint8_t year)
536536
{
537537
if (_configured) {
538-
RTC_GetDate(&_year, &_month, &_date, &_day);
538+
RTC_GetDate(&_year, &_month, &_day, &_wday);
539539
if(year < 100) {
540540
_year = year;
541541
}
542-
RTC_SetDate(_year, _month, _date, _day);
542+
RTC_SetDate(_year, _month, _day, _wday);
543543
}
544544
}
545545

@@ -669,15 +669,15 @@ void STM32RTC::setAlarmTime(uint8_t hours, uint8_t minutes, uint8_t seconds, RTC
669669
}
670670

671671
/**
672-
* @brief set RTC alarm date.
672+
* @brief set RTC alarm day.
673673
* @param day: 1-31
674674
* @retval none
675675
*/
676676
void STM32RTC::setAlarmDay(uint8_t day)
677677
{
678678
if (_configured) {
679679
if((day >= 1) && (day <= 31)) {
680-
_alarmDate = day;
680+
_alarmDay = day;
681681
}
682682
}
683683
}
@@ -733,10 +733,10 @@ uint32_t STM32RTC::getEpoch(void)
733733

734734
tm.tm_isdst = -1;
735735
tm.tm_yday = 0;
736-
tm.tm_wday = _day - 1;
736+
tm.tm_wday = _wday - 1;
737737
tm.tm_year = _year + EPOCH_TIME_YEAR_OFF;
738738
tm.tm_mon = _month - 1;
739-
tm.tm_mday = _date;
739+
tm.tm_mday = _day;
740740
tm.tm_hour = _hours;
741741
tm.tm_min = _minutes;
742742
tm.tm_sec = _seconds;
@@ -791,13 +791,13 @@ void STM32RTC::setEpoch(uint32_t ts)
791791

792792
_year = tmp->tm_year - EPOCH_TIME_YEAR_OFF;
793793
_month = tmp->tm_mon + 1;
794-
_date = tmp->tm_mday;
795-
_day = tmp->tm_wday + 1;
794+
_day = tmp->tm_mday;
795+
_wday = tmp->tm_wday + 1;
796796
_hours = tmp->tm_hour;
797797
_minutes = tmp->tm_min;
798798
_seconds = tmp->tm_sec;
799799

800-
RTC_SetDate(_year, _month, _date, _day);
800+
RTC_SetDate(_year, _month, _day, _wday);
801801
RTC_SetTime(_hours, _minutes, _seconds, _subSeconds, (_hoursPeriod == RTC_AM)? AM : PM);
802802
}
803803
}
@@ -833,7 +833,7 @@ void STM32RTC::syncTime(void)
833833
void STM32RTC::syncDate(void)
834834
{
835835
if(_configured) {
836-
RTC_GetDate(&_year, &_month, &_date, &_day);
836+
RTC_GetDate(&_year, &_month, &_day, &_wday);
837837
}
838838
}
839839

@@ -845,7 +845,7 @@ void STM32RTC::syncAlarmTime(void)
845845
{
846846
if(_configured) {
847847
hourAM_PM_t p = AM;
848-
RTC_GetAlarm(&_alarmDate, &_alarmHours, &_alarmMinutes, &_alarmSeconds, &_alarmSubSeconds, &p);
848+
RTC_GetAlarm(&_alarmDay, &_alarmHours, &_alarmMinutes, &_alarmSeconds, &_alarmSubSeconds, &p);
849849
_alarmPeriod = (p == AM)? RTC_AM : RTC_PM;
850850
}
851851
}

src/STM32RTC.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,10 @@ class STM32RTC {
182182
uint32_t _subSeconds;
183183
uint8_t _year;
184184
uint8_t _month;
185-
uint8_t _date;
186185
uint8_t _day;
186+
uint8_t _wday;
187187

188-
uint8_t _alarmDate;
188+
uint8_t _alarmDay;
189189
uint8_t _alarmHours;
190190
uint8_t _alarmMinutes;
191191
uint8_t _alarmSeconds;

0 commit comments

Comments
 (0)