From 561d1d43a66de8f732f543b56e5ac4bcb8fca84e Mon Sep 17 00:00:00 2001 From: EduardoGMohedano Date: Fri, 11 Sep 2020 09:53:17 -0500 Subject: [PATCH 1/2] Added 12 Hrs format Adding 12 Hrs format for Alarms. Implementaion is in the begin function, default state is 24 Hrs, if a True parameter is passed to the begin function, the 12 Hrs format is used --- src/RTCZero.cpp | 13 ++++++++++++- src/RTCZero.h | 3 ++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/RTCZero.cpp b/src/RTCZero.cpp index 71bfd8d..715afcd 100644 --- a/src/RTCZero.cpp +++ b/src/RTCZero.cpp @@ -39,7 +39,7 @@ RTCZero::RTCZero() _configured = false; } -void RTCZero::begin(bool resetTime) +void RTCZero::begin(bool twelveHrsformat,bool resetTime) { uint16_t tmp_reg = 0; @@ -72,6 +72,10 @@ void RTCZero::begin(bool resetTime) //According to the datasheet RTC_MODE2_CTRL_CLKREP = 0 for 24h tmp_reg &= ~RTC_MODE2_CTRL_CLKREP; // 24h time representation + if(twelveHrsformat) + { + tmp_reg |= RTC_MODE2_CTRL_CLKREP; // 12h time representation + } RTC->MODE2.READREQ.reg &= ~RTC_READREQ_RCONT; // disable continuously mode @@ -152,6 +156,13 @@ void RTCZero::standbyMode() __WFI(); } +void RTCZero::enable12Hrsformat() +{ + RTCdisable(); + RTC->MODE2.CTRL.reg = RTC_MODE2_CTRL_CLKREP; + RTCenable(); +} + /* * Get Functions */ diff --git a/src/RTCZero.h b/src/RTCZero.h index f74f091..ae4cb10 100644 --- a/src/RTCZero.h +++ b/src/RTCZero.h @@ -39,7 +39,7 @@ class RTCZero { }; RTCZero(); - void begin(bool resetTime = false); + void begin(bool twelveHrsformat = false,bool resetTime = false); void enableAlarm(Alarm_Match match); void disableAlarm(); @@ -48,6 +48,7 @@ class RTCZero { void detachInterrupt(); void standbyMode(); + void enable12Hrsformat(); /* Get Functions */ From 207962abb32f0c2c18c5683f5d2fe3c2454ff5f9 Mon Sep 17 00:00:00 2001 From: EduardoGMohedano Date: Fri, 11 Sep 2020 15:41:59 -0500 Subject: [PATCH 2/2] Added 12 Hrs Format for Alarm --- src/RTCZero.cpp | 7 ------- src/RTCZero.h | 1 - 2 files changed, 8 deletions(-) diff --git a/src/RTCZero.cpp b/src/RTCZero.cpp index 715afcd..7a97dd1 100644 --- a/src/RTCZero.cpp +++ b/src/RTCZero.cpp @@ -156,13 +156,6 @@ void RTCZero::standbyMode() __WFI(); } -void RTCZero::enable12Hrsformat() -{ - RTCdisable(); - RTC->MODE2.CTRL.reg = RTC_MODE2_CTRL_CLKREP; - RTCenable(); -} - /* * Get Functions */ diff --git a/src/RTCZero.h b/src/RTCZero.h index ae4cb10..73fa796 100644 --- a/src/RTCZero.h +++ b/src/RTCZero.h @@ -48,7 +48,6 @@ class RTCZero { void detachInterrupt(); void standbyMode(); - void enable12Hrsformat(); /* Get Functions */