aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorConfuSomu2021-08-12 21:03:38 -0400
committerConfuSomu2021-08-12 21:03:38 -0400
commit822e2bc38be3ea056fb976e5850c9df1e0c24fd3 (patch)
treed613854919203a21e8098388c91a8e797cf29dba
parent52fdf6f19ad1d529d7f802ac9a26d259234068ad (diff)
downloadpico-watch-822e2bc38be3ea056fb976e5850c9df1e0c24fd3.tar
pico-watch-822e2bc38be3ea056fb976e5850c9df1e0c24fd3.tar.gz
pico-watch-822e2bc38be3ea056fb976e5850c9df1e0c24fd3.zip
Have the render interval be an app attribute
This simplifies managing the change of foreground app. Use the performance_render_interval_{set,get} functions would be too cumbersome to implement. Unfortunately, this might give too much freedom to running apps, as they can decide to use a very small render interval which can use more battery as the system cannot sleep while waiting for the next render cycle.
-rw-r--r--base_app.hpp1
-rw-r--r--pico-watch.cpp4
2 files changed, 3 insertions, 2 deletions
diff --git a/base_app.hpp b/base_app.hpp
index 06f608a..3615df3 100644
--- a/base_app.hpp
+++ b/base_app.hpp
@@ -7,6 +7,7 @@ class BaseApp {
struct AppAttributes {
uint id = 0;
bool destroy_on_exit = true;
+ uint render_interval = 500; // Interval in ms at which the render method is called.
};
enum AppReturnValues {
OK = 0,
diff --git a/pico-watch.cpp b/pico-watch.cpp
index abfcdf6..9bf45e0 100644
--- a/pico-watch.cpp
+++ b/pico-watch.cpp
@@ -56,7 +56,7 @@ int main() {
}
if (g_s.is_sleeping) __wfi();
- else sleep_ms(app_api.performance_render_interval_get());
- }
+ else sleep_ms(g_s.foreground_app->app_get_attributes().render_interval);
+ }
return 0;
}