From e954f3fda2ef99a6805804e7485705c5a45b7841 Mon Sep 17 00:00:00 2001 From: Silvano Seva Date: Sun, 29 Aug 2021 16:57:54 +0200 Subject: [PATCH] Moved sleep regulating update rate of rtx task from rtx thread to OpMode implementations, as each operating mode may require a custom update rate --- openrtx/include/rtx/OpMode.h | 2 ++ openrtx/src/rtx/OpMode_FM.cpp | 3 +++ openrtx/src/rtx/OpMode_M17.cpp | 2 ++ openrtx/src/threads.c | 1 - 4 files changed, 7 insertions(+), 1 deletion(-) diff --git a/openrtx/include/rtx/OpMode.h b/openrtx/include/rtx/OpMode.h index 75bb58df..9565b766 100644 --- a/openrtx/include/rtx/OpMode.h +++ b/openrtx/include/rtx/OpMode.h @@ -21,6 +21,7 @@ #ifndef OPMODE_H #define OPMODE_H +#include #include "rtx.h" /** @@ -75,6 +76,7 @@ public: { (void) status; (void) newCfg; + sleepFor(0u, 30u); } /** diff --git a/openrtx/src/rtx/OpMode_FM.cpp b/openrtx/src/rtx/OpMode_FM.cpp index a97512a8..31d798c0 100644 --- a/openrtx/src/rtx/OpMode_FM.cpp +++ b/openrtx/src/rtx/OpMode_FM.cpp @@ -192,4 +192,7 @@ void OpMode_FM::update(rtxStatus_t *const status, const bool newCfg) platform_ledOff(RED); break; } + + // Sleep thread for 30ms for 33Hz update rate + sleepFor(0u, 30u); } diff --git a/openrtx/src/rtx/OpMode_M17.cpp b/openrtx/src/rtx/OpMode_M17.cpp index 5ee64777..587eb764 100644 --- a/openrtx/src/rtx/OpMode_M17.cpp +++ b/openrtx/src/rtx/OpMode_M17.cpp @@ -19,6 +19,7 @@ ***************************************************************************/ #include +#include #include #include #include @@ -53,6 +54,7 @@ void OpMode_M17::update(rtxStatus_t *const status, const bool newCfg) if(status->opStatus == RX) { // TODO: Implement M17 Rx + sleepFor(0u, 30u); } else if((status->opStatus == OFF) && enterRx) { diff --git a/openrtx/src/threads.c b/openrtx/src/threads.c index f88579cb..d926228c 100644 --- a/openrtx/src/threads.c +++ b/openrtx/src/threads.c @@ -262,7 +262,6 @@ void *rtx_task(void *arg) while(1) { rtx_taskFunc(); - sleepFor(0u, 30u); } }