diff options
author | ConfuSomu | 2021-03-01 22:31:20 -0500 |
---|---|---|
committer | ConfuSomu | 2021-03-01 22:31:20 -0500 |
commit | 09f67190a934230853e1dddaf65a14c4e9a50999 (patch) | |
tree | 2cab7827bcc7b9167fec42d5230bb0bd1bd5206b | |
parent | e63fcd31861aecfd0760d77b8ab0eea0c528ea8c (diff) | |
download | pico-watch-09f67190a934230853e1dddaf65a14c4e9a50999.tar pico-watch-09f67190a934230853e1dddaf65a14c4e9a50999.tar.gz pico-watch-09f67190a934230853e1dddaf65a14c4e9a50999.zip |
Implement API to set/get render interval
-rw-r--r-- | api.cpp | 10 | ||||
-rw-r--r-- | api.hpp | 8 | ||||
-rw-r--r-- | pico-watch.cpp | 2 |
3 files changed, 19 insertions, 1 deletions
@@ -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; } @@ -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; } |