summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/home_menu/main.cpp14
-rw-r--r--apps/home_menu/main.hpp6
-rw-r--r--apps/main_clock/main.cpp22
-rw-r--r--apps/main_clock/main.hpp8
-rw-r--r--apps/settings/main.cpp12
-rw-r--r--apps/settings/main.hpp6
6 files changed, 39 insertions, 29 deletions
diff --git a/apps/home_menu/main.cpp b/apps/home_menu/main.cpp
index ff8ae4d..4508e38 100644
--- a/apps/home_menu/main.cpp
+++ b/apps/home_menu/main.cpp
@@ -28,19 +28,19 @@ void app_home_menu::show_title(Api *app_api) {
}
// Rendering of app
-int app_home_menu::render(Api *app_api) {
+BaseApp::AppReturnValues app_home_menu::render(Api *app_api) {
show_title(app_api);
app_api->display_write_string(0,5,3, display_app_name, FONT_12x16, 0, 1);
- return 0;
+ return AppReturnValues::OK;
}
// Example of how button inputs could be interpreted.
// Drawing on screen should be done in the render function.
-int app_home_menu::btnpressed(Api *app_api, uint gpio, unsigned long delta) {
+BaseApp::AppReturnValues app_home_menu::btnpressed(Api *app_api, uint gpio, unsigned long delta) {
switch (gpio) {
case BUTTON_SELECT:
app_mgr::app_switch_request(selected_app);
- return 0;
+ return AppReturnValues::OK;
case BUTTON_DOWN:
selected_app--;
break;
@@ -55,7 +55,7 @@ int app_home_menu::btnpressed(Api *app_api, uint gpio, unsigned long delta) {
}
// Add spaces to avoid "ghost" characters from app names displayed before
snprintf(display_app_name, SIZE_APP_NAME, "%s ", APPS_NAME[selected_app]);
- return 0;
+ return AppReturnValues::OK;
}
// Initlisation of the app.
@@ -66,6 +66,6 @@ app_home_menu::app_home_menu(Api *app_api) {
}
// 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 app_home_menu::bgrefresh(Api *app_api, bool in_foreground) {
- return 1;
+BaseApp::AppReturnValues app_home_menu::bgrefresh(Api *app_api, bool in_foreground) {
+ return AppReturnValues::OK;
}
diff --git a/apps/home_menu/main.hpp b/apps/home_menu/main.hpp
index 155009b..d82e2a0 100644
--- a/apps/home_menu/main.hpp
+++ b/apps/home_menu/main.hpp
@@ -24,8 +24,8 @@ class app_home_menu : public BaseApp {
}
app_home_menu(Api *app_api);
- int render(Api *app_api);
- int btnpressed(Api *app_api, uint gpio, unsigned long delta);
- int bgrefresh(Api *app_api, bool in_foreground);
+ AppReturnValues render(Api *app_api);
+ AppReturnValues btnpressed(Api *app_api, uint gpio, unsigned long delta);
+ AppReturnValues bgrefresh(Api *app_api, bool in_foreground);
~app_home_menu();
};
diff --git a/apps/main_clock/main.cpp b/apps/main_clock/main.cpp
index 78be6fd..73a3103 100644
--- a/apps/main_clock/main.cpp
+++ b/apps/main_clock/main.cpp
@@ -52,7 +52,7 @@ void app_main_clock::show_datetime(Api *app_api) {
}
// Rendering of the app
-int app_main_clock::render(Api *app_api) {
+BaseApp::AppReturnValues app_main_clock::render(Api *app_api) {
app_api->gui_header_text("Test clock", 17);
show_datetime(app_api);
if (*ask_user_choice) {
@@ -60,14 +60,20 @@ int app_main_clock::render(Api *app_api) {
*ask_user_choice = false;
}
app_api->gui_footer_text(choices[*user_choice],0,1);
- return 0;
+
+ if (*user_choice == 1)
+ return AppReturnValues::CLOSE;
+ else if (*user_choice == 2)
+ return AppReturnValues::QUIT;
+
+ return AppReturnValues::OK;
}
// Interpretation of button inputs
-int app_main_clock::btnpressed(Api *app_api, uint gpio, unsigned long delta) {
+BaseApp::AppReturnValues app_main_clock::btnpressed(Api *app_api, uint gpio, unsigned long delta) {
if (gpio == BUTTON_MODE)
*ask_user_choice = true;
- return 0;
+ return AppReturnValues::OK;
}
// Initlisation of the app.
@@ -82,8 +88,12 @@ app_main_clock::app_main_clock(Api *app_api) {
}
// 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 app_main_clock::bgrefresh(Api *app_api, bool in_foreground) {
- return 1;
+BaseApp::AppReturnValues app_main_clock::bgrefresh(Api *app_api, bool in_foreground) {
+ if (*user_choice == 3)
+ return AppReturnValues::CLOSE;
+ else if (*user_choice == 4)
+ return AppReturnValues::QUIT;
+ return AppReturnValues::OK;
}
// 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.
diff --git a/apps/main_clock/main.hpp b/apps/main_clock/main.hpp
index f00958e..7c07cb3 100644
--- a/apps/main_clock/main.hpp
+++ b/apps/main_clock/main.hpp
@@ -9,7 +9,7 @@ class app_main_clock : public BaseApp {
private:
bool *ask_user_choice;
int *user_choice;
- const char *choices[26] = {"One", "Two", "Three!", "This is looong!", "make sure to choose me!:p"};
+ const char *choices[10] = {"One", "Close (fg)", "Quit (fg)", "Close (bg)", "Quit (bg)"};
void time_as_str(char *buf, uint buf_size, const datetime_t *t);
void date_as_str(char *buf, uint buf_size, const datetime_t *t);
@@ -22,8 +22,8 @@ class app_main_clock : public BaseApp {
}
app_main_clock(Api *app_api);
- int render(Api *app_api);
- int btnpressed(Api *app_api, uint gpio, unsigned long delta);
- int bgrefresh(Api *app_api, bool in_foreground);
+ AppReturnValues render(Api *app_api);
+ AppReturnValues btnpressed(Api *app_api, uint gpio, unsigned long delta);
+ AppReturnValues bgrefresh(Api *app_api, bool in_foreground);
~app_main_clock();
};
diff --git a/apps/settings/main.cpp b/apps/settings/main.cpp
index 555c2c1..d4c910a 100644
--- a/apps/settings/main.cpp
+++ b/apps/settings/main.cpp
@@ -119,7 +119,7 @@ void app_settings::set1_menu(Api *app_api) {
}
// Rendering of app
-int app_settings::render(Api *app_api) {
+BaseApp::AppReturnValues app_settings::render(Api *app_api) {
show_title(app_api);
app_api->display_write_string(0,0,3, display_setting_name, FONT_12x16, 0, 1);
@@ -135,10 +135,10 @@ int app_settings::render(Api *app_api) {
}
}
- return 0;
+ return AppReturnValues::OK;
}
-int app_settings::btnpressed(Api *app_api, uint gpio, unsigned long delta) {
+BaseApp::AppReturnValues app_settings::btnpressed(Api *app_api, uint gpio, unsigned long delta) {
switch (gpio) {
case BUTTON_SELECT:
selected = true;
@@ -157,7 +157,7 @@ int app_settings::btnpressed(Api *app_api, uint gpio, unsigned long delta) {
}
// Add spaces to avoid "ghost" characters from app names displayed before
snprintf(display_setting_name, SIZE_SETTING_NAME, "%s ", MAIN_SET_NAMES[selected_setting]);
- return 0;
+ return AppReturnValues::OK;
}
app_settings::app_settings(Api *app_api) {
@@ -168,8 +168,8 @@ app_settings::app_settings(Api *app_api) {
snprintf(display_setting_name, SIZE_SETTING_NAME, "%s", MAIN_SET_NAMES[0]);
}
-int app_settings::bgrefresh(Api *app_api, bool in_foreground) {
- return 1;
+BaseApp::AppReturnValues app_settings::bgrefresh(Api *app_api, bool in_foreground) {
+ return AppReturnValues::OK;
}
app_settings::~app_settings() {
diff --git a/apps/settings/main.hpp b/apps/settings/main.hpp
index 589be70..d53b8a9 100644
--- a/apps/settings/main.hpp
+++ b/apps/settings/main.hpp
@@ -20,9 +20,9 @@ class app_settings : public BaseApp {
}
app_settings(Api *app_api);
- int render(Api *app_api);
- int btnpressed(Api *app_api, uint gpio, unsigned long delta);
- int bgrefresh(Api *app_api, bool in_foreground);
+ AppReturnValues render(Api *app_api);
+ AppReturnValues btnpressed(Api *app_api, uint gpio, unsigned long delta);
+ AppReturnValues bgrefresh(Api *app_api, bool in_foreground);
~app_settings();
};
#include "strings-undef.hpp"