aboutsummaryrefslogtreecommitdiffstats
path: root/source/rtc.cpp
diff options
context:
space:
mode:
authorClyne Sullivan <tullivan99@gmail.com>2019-03-14 14:44:18 -0400
committerClyne Sullivan <tullivan99@gmail.com>2019-03-14 14:44:18 -0400
commit352e0df7d800b033ce24ad1022461f5d1908da93 (patch)
tree3cf6adf03311668fe3ecbbb21c070668624fa10a /source/rtc.cpp
parent31e115f7e72532fbfd456709e95d440e3be46fa1 (diff)
cleanup, display screen abstraction
Diffstat (limited to 'source/rtc.cpp')
-rw-r--r--source/rtc.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/source/rtc.cpp b/source/rtc.cpp
index c355c90..ddb68c0 100644
--- a/source/rtc.cpp
+++ b/source/rtc.cpp
@@ -4,6 +4,8 @@
nrf_drv_rtc_t RTC::rtc = NRF_DRV_RTC_INSTANCE(2);
unsigned int RTC::rtcCount = 0;
+char RTC::message[16] = "";
+
void RTC::begin(void)
{
//Initialize RTC instance
@@ -19,6 +21,22 @@ void RTC::begin(void)
nrf_drv_rtc_enable(&rtc);
}
+void RTC::showTime(Display& display)
+{
+ static unsigned int oldTicks = 0;
+ if (auto t = rtcCount; t != oldTicks) {
+ oldTicks = t;
+
+ display.setCursor(0, 10);
+ display.printf("%2d:%02d:%02d", t / 3600, (t % 3600) / 60,
+ t % 60);
+ if (*message != '\0') {
+ display.setCursor(0, 100);
+ display.printf("%-16s", message);
+ }
+ }
+}
+
void RTC::handler([[maybe_unused]] nrf_drv_rtc_int_type_t int_type)
{
static unsigned char counter = 0;