27 lines
740 B
C
27 lines
740 B
C
#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);
|
|
|