mirror of
https://github.com/okalachev/flix.git
synced 2026-01-11 21:46:55 +00:00
Add Rate class for running the code at fixed rate
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
// Parameters storage in flash memory
|
||||
|
||||
#include <Preferences.h>
|
||||
#include "util.h"
|
||||
|
||||
extern float channelZero[16];
|
||||
extern float channelMax[16];
|
||||
@@ -118,10 +119,9 @@ bool setParameter(const char *name, const float value) {
|
||||
}
|
||||
|
||||
void syncParameters() {
|
||||
static float lastSync = 0;
|
||||
if (t - lastSync < 1) return; // sync once per second
|
||||
static Rate rate(1);
|
||||
if (!rate) return; // sync once per second
|
||||
if (motorsActive()) return; // don't use flash while flying, it may cause a delay
|
||||
lastSync = t;
|
||||
|
||||
for (auto ¶meter : parameters) {
|
||||
if (parameter.value == *parameter.variable) continue;
|
||||
|
||||
Reference in New Issue
Block a user