mirror of
https://github.com/okalachev/flix.git
synced 2026-06-28 05:56:44 +00:00
Add Rate class for running the code at fixed rate
This commit is contained in:
+3
-4
@@ -4,10 +4,10 @@
|
||||
// In-RAM logging
|
||||
|
||||
#include "vector.h"
|
||||
#include "util.h"
|
||||
|
||||
#define LOG_RATE 100
|
||||
#define LOG_DURATION 10
|
||||
#define LOG_PERIOD 1.0 / LOG_RATE
|
||||
#define LOG_SIZE LOG_DURATION * LOG_RATE
|
||||
|
||||
Vector attitudeEuler;
|
||||
@@ -46,9 +46,8 @@ void prepareLogData() {
|
||||
void logData() {
|
||||
if (!armed) return;
|
||||
static int logPointer = 0;
|
||||
static float logTime = 0;
|
||||
if (t - logTime < LOG_PERIOD) return;
|
||||
logTime = t;
|
||||
static Rate period(LOG_RATE);
|
||||
if (!period) return;
|
||||
|
||||
prepareLogData();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user