Skip to content

Commit c7d65d2

Browse files
committed
Removed 12h initialization
As discussed in the issue #3944
1 parent df17f7e commit c7d65d2

File tree

6 files changed

+15
-30
lines changed

6 files changed

+15
-30
lines changed

Diff for: examples/SimpleRTC/SimpleRTC.ino

+4-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
1010
created by Arturo Guadalupi <[email protected]>
1111
15 Jun 2015
12+
13+
modified
14+
21 Oct 2015
1215
*/
1316

1417
#include <RTCZero.h>
@@ -30,7 +33,7 @@ void setup()
3033
{
3134
Serial.begin(9600);
3235

33-
rtc.begin(H24); // initialize RTC 24H format. The dual option is H12
36+
rtc.begin(); // initialize RTC
3437

3538
// Set the time
3639
rtc.setHours(hours);

Diff for: examples/SimpleRTCAlarm/SimpleRTCAlarm.ino

+5-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
1010
created by Arturo Guadalupi <[email protected]>
1111
25 Sept 2015
12+
13+
modified
14+
21 Oct 2015
1215
*/
1316

1417
#include <RTCZero.h>
@@ -19,7 +22,7 @@ RTCZero rtc;
1922
/* Change these values to set the current initial time */
2023
const uint8_t seconds = 0;
2124
const uint8_t minutes = 0;
22-
const uint8_t hours = 17;
25+
const uint8_t hours = 16;
2326

2427
/* Change these values to set the current initial date */
2528
const uint8_t day = 25;
@@ -30,7 +33,7 @@ void setup()
3033
{
3134
Serial.begin(9600);
3235

33-
rtc.begin(H24); // initialize RTC 24H format. The dual option is H12
36+
rtc.begin(); // initialize RTC 24H format
3437

3538
rtc.setTime(hours, minutes, seconds);
3639
rtc.setDate(day, month, year);

Diff for: keywords.txt

-2
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,3 @@ disableAlarm KEYWORD2
5050
#######################################
5151
# Constants (LITERAL1)
5252
#######################################
53-
H24 LITERAL1
54-
H12 LITERAL1

Diff for: library.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=RTCZero
2-
version=1.1.1
2+
version=1.2.0
33
author=Arduino
44
maintainer=Arduino <[email protected]>
55
sentence=Allows to use the RTC functionalities. For Arduino Zero only.

Diff for: src/RTCZero.cpp

+4-23
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,12 @@
1919

2020
#include "RTCZero.h"
2121

22-
static bool __time24 = false;
23-
2422
voidFuncPtr RTC_callBack = NULL;
2523

26-
void RTCZero::begin(bool timeRep)
24+
void RTCZero::begin()
2725
{
2826
uint16_t tmp_reg = 0;
2927

30-
if (timeRep)
31-
__time24 = true; // 24h representation chosen
32-
3328
PM->APBAMASK.reg |= PM_APBAMASK_RTC; // turn on digital interface clock
3429
config32kOSC();
3530

@@ -51,11 +46,7 @@ void RTCZero::begin(bool timeRep)
5146
tmp_reg |= RTC_MODE2_CTRL_MODE_CLOCK; // set clock operating mode
5247
tmp_reg |= RTC_MODE2_CTRL_PRESCALER_DIV1024; // set prescaler to 1024 for MODE2
5348
tmp_reg &= ~RTC_MODE2_CTRL_MATCHCLR; // disable clear on match
54-
55-
if (timeRep)
56-
tmp_reg |= RTC_MODE2_CTRL_CLKREP; // 24h time representation
57-
else
58-
tmp_reg &= ~RTC_MODE2_CTRL_CLKREP; // 12h time representation
49+
tmp_reg |= RTC_MODE2_CTRL_CLKREP; // 24h time representation
5950

6051
RTC->MODE2.READREQ.reg &= ~RTC_READREQ_RCONT; // disable continuously mode
6152

@@ -193,11 +184,7 @@ void RTCZero::setMinutes(uint8_t minutes)
193184

194185
void RTCZero::setHours(uint8_t hours)
195186
{
196-
if ((__time24) || (hours < 13)) {
197-
RTC->MODE2.CLOCK.bit.HOUR = hours;
198-
} else {
199-
RTC->MODE2.CLOCK.bit.HOUR = hours - 12;
200-
}
187+
RTC->MODE2.CLOCK.bit.HOUR = hours;
201188
while (RTCisSyncing())
202189
;
203190
}
@@ -253,12 +240,7 @@ void RTCZero::setAlarmMinutes(uint8_t minutes)
253240

254241
void RTCZero::setAlarmHours(uint8_t hours)
255242
{
256-
if ((__time24) || (hours < 13)) {
257-
RTC->MODE2.Mode2Alarm[0].ALARM.bit.HOUR = hours;
258-
}
259-
else {
260-
RTC->MODE2.Mode2Alarm[0].ALARM.bit.HOUR = hours - 12;
261-
}
243+
RTC->MODE2.Mode2Alarm[0].ALARM.bit.HOUR = hours;
262244
while (RTCisSyncing())
263245
;
264246
}
@@ -346,4 +328,3 @@ void RTCZero::RTCresetRemove()
346328
while (RTCisSyncing())
347329
;
348330
}
349-

Diff for: src/RTCZero.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class RTCZero {
4141
};
4242

4343
RTCZero() {};
44-
void begin(bool timeRep);
44+
void begin();
4545

4646
void enableAlarm(Alarm_Match match);
4747
void disableAlarm();

0 commit comments

Comments
 (0)