From be1f3d3631d5403bb8391182258118098816d113 Mon Sep 17 00:00:00 2001 From: James Haggerty Date: Wed, 12 Oct 2022 11:59:43 +1100 Subject: [PATCH 1/3] Make starter project work in simulator Use the higher abstraction level sleeping. --- apps/starter-project/app.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/starter-project/app.c b/apps/starter-project/app.c index 9a4ef4fe..5dfde68d 100644 --- a/apps/starter-project/app.c +++ b/apps/starter-project/app.c @@ -1,6 +1,7 @@ #include #include #include "watch.h" +#include "watch_main_loop.h" ////////////////////////////////////////////////////////////////////////////////////////// // This section sets up types and storage for our application state. @@ -156,13 +157,13 @@ bool app_loop(void) { if (application_state.enter_sleep_mode) { // wait a moment for the user's finger to be off the button - delay_ms(250); + main_loop_sleep(250); // nap time :) watch_enter_deep_sleep_mode(); // we just woke up; wait a moment again for the user's finger to be off the button... - delay_ms(250); + main_loop_sleep(250); // and prevent ourselves from going right back to sleep. application_state.enter_sleep_mode = false; From b399f4ca459d0487139f642c7b526fb4144cac8b Mon Sep 17 00:00:00 2001 From: joeycastillo Date: Tue, 11 Oct 2022 22:06:02 -0500 Subject: [PATCH 2/3] only include watch_main_loop.h in simulator builds --- apps/starter-project/app.c | 1 - watch-library/shared/watch/watch.h | 4 ++++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/starter-project/app.c b/apps/starter-project/app.c index 5dfde68d..2efa6e72 100644 --- a/apps/starter-project/app.c +++ b/apps/starter-project/app.c @@ -1,7 +1,6 @@ #include #include #include "watch.h" -#include "watch_main_loop.h" ////////////////////////////////////////////////////////////////////////////////////////// // This section sets up types and storage for our application state. diff --git a/watch-library/shared/watch/watch.h b/watch-library/shared/watch/watch.h index 7526d03a..790f9a16 100644 --- a/watch-library/shared/watch/watch.h +++ b/watch-library/shared/watch/watch.h @@ -30,6 +30,10 @@ #include "driver_init.h" #include "pins.h" +#ifdef __EMSCRIPTEN__ +#include "watch_main_loop.h" +#endif // __EMSCRIPTEN__ + /** @mainpage Sensor Watch Documentation * @brief This documentation covers most of the functions you will use to interact with the Sensor Watch hardware. It is divided into the following sections: From f79741a85fa08dff34a41ae7c804d80dc800343c Mon Sep 17 00:00:00 2001 From: joeycastillo Date: Tue, 11 Oct 2022 22:11:58 -0500 Subject: [PATCH 3/3] add delay_ms function for simulator --- apps/starter-project/app.c | 4 ++-- watch-library/simulator/main.c | 4 ++++ watch-library/simulator/watch/watch_main_loop.h | 2 ++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/apps/starter-project/app.c b/apps/starter-project/app.c index 2efa6e72..9a4ef4fe 100644 --- a/apps/starter-project/app.c +++ b/apps/starter-project/app.c @@ -156,13 +156,13 @@ bool app_loop(void) { if (application_state.enter_sleep_mode) { // wait a moment for the user's finger to be off the button - main_loop_sleep(250); + delay_ms(250); // nap time :) watch_enter_deep_sleep_mode(); // we just woke up; wait a moment again for the user's finger to be off the button... - main_loop_sleep(250); + delay_ms(250); // and prevent ourselves from going right back to sleep. application_state.enter_sleep_mode = false; diff --git a/watch-library/simulator/main.c b/watch-library/simulator/main.c index ac9db6ac..6898fd06 100644 --- a/watch-library/simulator/main.c +++ b/watch-library/simulator/main.c @@ -101,6 +101,10 @@ static void main_loop_set_sleeping(bool sleeping) { }, sleeping); } +void delay_ms(const uint16_t ms) { + main_loop_sleep(ms); +} + int main(void) { app_init(); _watch_init(); diff --git a/watch-library/simulator/watch/watch_main_loop.h b/watch-library/simulator/watch/watch_main_loop.h index 82351919..7599f727 100644 --- a/watch-library/simulator/watch/watch_main_loop.h +++ b/watch-library/simulator/watch/watch_main_loop.h @@ -31,3 +31,5 @@ void resume_main_loop(void); void main_loop_sleep(uint32_t ms); bool main_loop_is_sleeping(void); + +void delay_ms(const uint16_t ms);