aboutsummaryrefslogtreecommitdiffstats
path: root/apps/main_clock.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'apps/main_clock.cpp')
-rw-r--r--apps/main_clock.cpp30
1 files changed, 13 insertions, 17 deletions
diff --git a/apps/main_clock.cpp b/apps/main_clock.cpp
index f9be3e5..895a7b9 100644
--- a/apps/main_clock.cpp
+++ b/apps/main_clock.cpp
@@ -1,12 +1,8 @@
#include <stdio.h>
#include "pico/stdlib.h"
-extern "C" {
-#include "hardware/rtc.h"
-}
-#include "pico/util/datetime.h"
-#include "../oled/ss_oled.h"
#include "main_clock.hpp"
+#include "../api.hpp"
#include "../buttons.hpp"
namespace app_main_clock {
@@ -39,46 +35,46 @@ namespace app_main_clock {
DATETIME_DOWS[t->dotw - 1]);
};
- void show_datetime(SSOLED *oled) {
+ void show_datetime(Api *app_api) {
char datetime_buf[256];
char *datetime_str = &datetime_buf[0];
datetime_t t;
- rtc_get_datetime(&t);
+ app_api->datetime_get(&t);
// time
time_as_str(datetime_str, sizeof(datetime_buf), &t);
- oledWriteString(oled, 0,10,3, datetime_str, FONT_12x16, 0, 1);
+ app_api->display_write_string(0,10,3, datetime_str, FONT_12x16, 0, 1);
// date
date_as_str(datetime_str, sizeof(datetime_buf), &t);
- oledWriteString(oled, 0,0,7, datetime_str, FONT_8x8, 0, 1);
+ app_api->gui_footer_text((std::string)datetime_str);
}
// Rendering of the app
- int render(SSOLED *oled) {
- oledWriteString(oled, 0,15,0, (char *)"Test clock", FONT_8x8, 0, 1);
- show_datetime(oled);
- //oledWriteString(oled, 0,0,0, &data[0], FONT_6x8, 0, 1);
+ int render(Api *app_api) {
+ app_api->gui_header_text("Test clock", 17);
+ show_datetime(app_api);
return 0;
}
// Interpretation of button inputs
- int btnpressed(SSOLED *oled, uint gpio) {
+ int btnpressed(Api *app_api, uint gpio) {
return 0;
}
// Initlisation of the app.
- int init(SSOLED *oled) {
+ int init(Api *app_api) {
+ app_api->performance_set(Api::perf_modes::LOW_POWER);
return 1; // return 1 when function not implemented
}
// Processor intensive operations and functions related to drawing to the screen should only be done when the app is in_foreground(=1). This function is only called when the app is init.
- int bgrefresh(SSOLED *oled, char in_foreground) {
+ int bgrefresh(Api *app_api, char in_foreground) {
return 1;
}
// Destruction of app, deinitlisation should be done here. This is only called if the app's APPS_DESTROY_ON_EXIT is set to 1. When it is not a "service" app.
- int destroy(SSOLED *oled) {
+ int destroy(Api *app_api) {
return 1;
}
} \ No newline at end of file