firmware: add persistent level calibration
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
#pragma once
|
||||
#include "sensor_state.h"
|
||||
|
||||
struct LevelCalibrationState {
|
||||
bool valid = false;
|
||||
bool active = false;
|
||||
float pitchOffsetDegrees = 0;
|
||||
float rollOffsetDegrees = 0;
|
||||
unsigned long startedMs = 0;
|
||||
unsigned long lastSampleMs = 0;
|
||||
uint32_t sampleCount = 0;
|
||||
float pitchSum = 0;
|
||||
float rollSinSum = 0;
|
||||
float rollCosSum = 0;
|
||||
float firstPitch = 0;
|
||||
float firstRoll = 0;
|
||||
};
|
||||
|
||||
extern LevelCalibrationState levelCalibration;
|
||||
void initLevelCalibration();
|
||||
bool startLevelCalibration(const ImuState& imu);
|
||||
bool updateLevelCalibration(const ImuState& imu, String& result);
|
||||
void clearLevelCalibration();
|
||||
float calibratedPitchDegrees(const ImuState& imu);
|
||||
float calibratedRollDegrees(const ImuState& imu);
|
||||
|
||||
Reference in New Issue
Block a user