aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorConfuSomu2021-03-01 22:31:20 -0500
committerConfuSomu2021-03-01 22:31:20 -0500
commit09f67190a934230853e1dddaf65a14c4e9a50999 (patch)
tree2cab7827bcc7b9167fec42d5230bb0bd1bd5206b
parente63fcd31861aecfd0760d77b8ab0eea0c528ea8c (diff)
downloadpico-watch-09f67190a934230853e1dddaf65a14c4e9a50999.tar
pico-watch-09f67190a934230853e1dddaf65a14c4e9a50999.tar.gz
pico-watch-09f67190a934230853e1dddaf65a14c4e9a50999.zip
Implement API to set/get render interval
-rw-r--r--api.cpp10
-rw-r--r--api.hpp8
-rw-r--r--pico-watch.cpp2
3 files changed, 19 insertions, 1 deletions
diff --git a/api.cpp b/api.cpp
index 1200f16..2d63506 100644
--- a/api.cpp
+++ b/api.cpp
@@ -134,6 +134,16 @@ bool Api::datetime_get(datetime_t *t) {
return rtc_get_datetime(t);
}
+int Api::performance_render_interval_get() {
+ return m_app_render_interval;
+}
+
+void Api::performance_render_interval_set(int interval) {
+ if (interval < 10)
+ interval = 10;
+ m_app_render_interval = interval;
+}
+
uint Api::button_last_get() {
return m_button_last_pressed;
}
diff --git a/api.hpp b/api.hpp
index f5de57e..20f5c34 100644
--- a/api.hpp
+++ b/api.hpp
@@ -13,6 +13,7 @@ class Api {
u_char m_init_done = 0;
uint8_t m_ucBuffer[1024] = {0};
uint m_button_last_pressed = 0;
+ int m_app_render_interval = 500;
void init_display();
public:
bool m_send_button_press_to_app = true;
@@ -55,7 +56,14 @@ class Api {
// \param perf See Api::perf_modes enum for possible values
bool performance_set(int perf);
bool datetime_get(datetime_t *t);
+ // Get app's current render interval
+ // \return Value in millisec
+ int performance_render_interval_get();
+ // Same spirit as performance_set, the app should use the smallest value possible that does not cause a lack of responsiveness in the app's UI.
+ // \param interval Time to wait in millisec between calls of the app's render function.
+ void performance_render_interval_set(int interval);
// Get last button pressed, see buttons.hpp for values
+ // \return Last button pressed
uint button_last_get();
// Set last button pressed, should only be called by button gpio interrupt.
void button_last_set(uint gpio);
diff --git a/pico-watch.cpp b/pico-watch.cpp
index 7c59d98..adfe2fd 100644
--- a/pico-watch.cpp
+++ b/pico-watch.cpp
@@ -80,7 +80,7 @@ int main() {
while (1) {
app_render(current_app);
- sleep_ms(500);
+ sleep_ms(app_api.performance_render_interval_get());
}
return 0;
}