aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--api.cpp8
-rw-r--r--api.hpp2
-rw-r--r--apps/home_menu.cpp6
-rw-r--r--apps/main_clock.cpp6
4 files changed, 12 insertions, 10 deletions
diff --git a/api.cpp b/api.cpp
index 60c0bcd..98b10f1 100644
--- a/api.cpp
+++ b/api.cpp
@@ -1,5 +1,9 @@
#include <stdio.h>
#include "pico/stdlib.h"
+extern "C" {
+#include "hardware/rtc.h"
+}
+#include "pico/util/datetime.h"
#include "oled/ss_oled.h"
#include "api.hpp"
@@ -26,3 +30,7 @@ int Api::dispWriteString(int iScrollX, int x, int y, char *szMsg, int iSize, int
void Api::dispFill(unsigned char ucData, int bRender) {
oledFill(&m_oled, ucData, bRender);
}
+
+bool Api::getDatetime(datetime_t *t) {
+ return rtc_get_datetime(t);
+}
diff --git a/api.hpp b/api.hpp
index 735d55b..3863388 100644
--- a/api.hpp
+++ b/api.hpp
@@ -1,6 +1,7 @@
#ifndef __API_H__
#define __API_H__
+#include "pico/util/datetime.h"
#include "oled/ss_oled.h"
class Api {
@@ -12,6 +13,7 @@ class Api {
void init();
int dispWriteString(int iScrollX, int x, int y, char *szMsg, int iSize, int bInvert, int bRender);
void dispFill(unsigned char ucData, int bRender);
+ bool getDatetime(datetime_t *t);
};
#endif \ No newline at end of file
diff --git a/apps/home_menu.cpp b/apps/home_menu.cpp
index 8f0ee8b..97d4423 100644
--- a/apps/home_menu.cpp
+++ b/apps/home_menu.cpp
@@ -1,9 +1,5 @@
#include <stdio.h>
#include "pico/stdlib.h"
-extern "C" {
-#include "hardware/rtc.h"
-}
-#include "pico/util/datetime.h"
#include "home_menu.hpp"
#include "../api.hpp"
@@ -32,7 +28,7 @@ namespace app_home_menu {
char datetime_buf[256];
char *datetime_str = &datetime_buf[0];
datetime_t t;
- rtc_get_datetime(&t);
+ app_api->getDatetime(&t);
// title with time
title_str(datetime_str, sizeof(datetime_buf), &t);
diff --git a/apps/main_clock.cpp b/apps/main_clock.cpp
index 9939e4e..298fed0 100644
--- a/apps/main_clock.cpp
+++ b/apps/main_clock.cpp
@@ -1,9 +1,5 @@
#include <stdio.h>
#include "pico/stdlib.h"
-extern "C" {
-#include "hardware/rtc.h"
-}
-#include "pico/util/datetime.h"
#include "main_clock.hpp"
#include "../api.hpp"
@@ -43,7 +39,7 @@ namespace app_main_clock {
char datetime_buf[256];
char *datetime_str = &datetime_buf[0];
datetime_t t;
- rtc_get_datetime(&t);
+ app_api->getDatetime(&t);
// time
time_as_str(datetime_str, sizeof(datetime_buf), &t);