mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-19 22:35:23 +03:00
Cleanup baro/mag/gyro/acc method names from old sensors.c
This commit is contained in:
parent
7e76fd6995
commit
9f26018abd
12 changed files with 38 additions and 43 deletions
|
@ -83,7 +83,7 @@ void imuInit(void)
|
||||||
#ifdef MAG
|
#ifdef MAG
|
||||||
// if mag sensor is enabled, use it
|
// if mag sensor is enabled, use it
|
||||||
if (sensors(SENSOR_MAG))
|
if (sensors(SENSOR_MAG))
|
||||||
Mag_init();
|
compassInit();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,9 +92,9 @@ void computeIMU(void)
|
||||||
uint32_t axis;
|
uint32_t axis;
|
||||||
static int16_t gyroYawSmooth = 0;
|
static int16_t gyroYawSmooth = 0;
|
||||||
|
|
||||||
Gyro_getADC();
|
gyroGetADC();
|
||||||
if (sensors(SENSOR_ACC)) {
|
if (sensors(SENSOR_ACC)) {
|
||||||
ACC_getADC();
|
accGetADC();
|
||||||
getEstimatedAttitude();
|
getEstimatedAttitude();
|
||||||
} else {
|
} else {
|
||||||
accADC[X] = 0;
|
accADC[X] = 0;
|
||||||
|
@ -406,7 +406,7 @@ int getEstimatedAltitude(void)
|
||||||
vel = 0;
|
vel = 0;
|
||||||
accAlt = 0;
|
accAlt = 0;
|
||||||
}
|
}
|
||||||
BaroAlt = Baro_calculateAltitude();
|
BaroAlt = baroCalculateAltitude();
|
||||||
|
|
||||||
dt = accTimeSum * 1e-6f; // delta acc reading time in seconds
|
dt = accTimeSum * 1e-6f; // delta acc reading time in seconds
|
||||||
|
|
||||||
|
|
|
@ -193,11 +193,11 @@ int main(void)
|
||||||
previousTime = micros();
|
previousTime = micros();
|
||||||
|
|
||||||
if (masterConfig.mixerConfiguration == MULTITYPE_GIMBAL) {
|
if (masterConfig.mixerConfiguration == MULTITYPE_GIMBAL) {
|
||||||
ACC_SetCalibrationCycles(CALIBRATING_ACC_CYCLES);
|
accSetCalibrationCycles(CALIBRATING_ACC_CYCLES);
|
||||||
}
|
}
|
||||||
GYRO_SetCalibrationCycles(CALIBRATING_GYRO_CYCLES);
|
gyroSetCalibrationCycles(CALIBRATING_GYRO_CYCLES);
|
||||||
#ifdef BARO
|
#ifdef BARO
|
||||||
Baro_SetCalibrationCycles(CALIBRATING_BARO_CYCLES);
|
baroSetCalibrationCycles(CALIBRATING_BARO_CYCLES);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
f.SMALL_ANGLE = 1;
|
f.SMALL_ANGLE = 1;
|
||||||
|
|
6
src/mw.c
6
src/mw.c
|
@ -6,6 +6,8 @@
|
||||||
|
|
||||||
#include "sensors_sonar.h"
|
#include "sensors_sonar.h"
|
||||||
#include "sensors_gyro.h"
|
#include "sensors_gyro.h"
|
||||||
|
#include "sensors_compass.h"
|
||||||
|
#include "sensors_barometer.h"
|
||||||
#include "flight_common.h"
|
#include "flight_common.h"
|
||||||
#include "serial_cli.h"
|
#include "serial_cli.h"
|
||||||
#include "telemetry_common.h"
|
#include "telemetry_common.h"
|
||||||
|
@ -479,13 +481,13 @@ void loop(void)
|
||||||
case 0:
|
case 0:
|
||||||
taskOrder++;
|
taskOrder++;
|
||||||
#ifdef MAG
|
#ifdef MAG
|
||||||
if (sensors(SENSOR_MAG) && Mag_getADC())
|
if (sensors(SENSOR_MAG) && compassGetADC())
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
case 1:
|
case 1:
|
||||||
taskOrder++;
|
taskOrder++;
|
||||||
#ifdef BARO
|
#ifdef BARO
|
||||||
if (sensors(SENSOR_BARO) && Baro_update())
|
if (sensors(SENSOR_BARO) && baroUpdate())
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
case 2:
|
case 2:
|
||||||
|
|
7
src/mw.h
7
src/mw.h
|
@ -64,13 +64,6 @@ void annexCode(void);
|
||||||
void computeIMU(void);
|
void computeIMU(void);
|
||||||
int getEstimatedAltitude(void);
|
int getEstimatedAltitude(void);
|
||||||
|
|
||||||
// Sensors
|
|
||||||
void ACC_getADC(void);
|
|
||||||
int Baro_update(void);
|
|
||||||
void Gyro_getADC(void);
|
|
||||||
void Mag_init(void);
|
|
||||||
int Mag_getADC(void);
|
|
||||||
|
|
||||||
// Output
|
// Output
|
||||||
void mixerResetMotors(void);
|
void mixerResetMotors(void);
|
||||||
void mixerLoadMix(int index);
|
void mixerLoadMix(int index);
|
||||||
|
|
|
@ -18,12 +18,12 @@ extern bool AccInflightCalibrationMeasurementDone;
|
||||||
extern bool AccInflightCalibrationSavetoEEProm;
|
extern bool AccInflightCalibrationSavetoEEProm;
|
||||||
extern bool AccInflightCalibrationActive;
|
extern bool AccInflightCalibrationActive;
|
||||||
|
|
||||||
void ACC_SetCalibrationCycles(uint16_t calibrationCyclesRequired)
|
void accSetCalibrationCycles(uint16_t calibrationCyclesRequired)
|
||||||
{
|
{
|
||||||
calibratingA = calibrationCyclesRequired;
|
calibratingA = calibrationCyclesRequired;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ACC_Common(void)
|
void accCommon(void)
|
||||||
{
|
{
|
||||||
static int32_t a[3];
|
static int32_t a[3];
|
||||||
int axis;
|
int axis;
|
||||||
|
@ -109,11 +109,11 @@ void ACC_Common(void)
|
||||||
accADC[GI_YAW] -= masterConfig.accZero[GI_YAW];
|
accADC[GI_YAW] -= masterConfig.accZero[GI_YAW];
|
||||||
}
|
}
|
||||||
|
|
||||||
void ACC_getADC(void)
|
void accGetADC(void)
|
||||||
{
|
{
|
||||||
acc.read(accADC);
|
acc.read(accADC);
|
||||||
alignSensors(accADC, accADC, accAlign);
|
alignSensors(accADC, accADC, accAlign);
|
||||||
|
|
||||||
ACC_Common();
|
accCommon();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ extern sensor_align_e accAlign;
|
||||||
extern acc_t acc;
|
extern acc_t acc;
|
||||||
extern uint16_t calibratingA;
|
extern uint16_t calibratingA;
|
||||||
|
|
||||||
void ACC_SetCalibrationCycles(uint16_t calibrationCyclesRequired);
|
void accSetCalibrationCycles(uint16_t calibrationCyclesRequired);
|
||||||
void ACC_Common(void);
|
void accCommon(void);
|
||||||
void ACC_getADC(void);
|
void accGetADC(void);
|
||||||
|
|
||||||
|
|
|
@ -11,12 +11,12 @@ uint16_t calibratingB = 0; // baro calibration = get new ground pressure va
|
||||||
static int32_t baroGroundAltitude = 0;
|
static int32_t baroGroundAltitude = 0;
|
||||||
static int32_t baroGroundPressure = 0;
|
static int32_t baroGroundPressure = 0;
|
||||||
|
|
||||||
void Baro_SetCalibrationCycles(uint16_t calibrationCyclesRequired)
|
void baroSetCalibrationCycles(uint16_t calibrationCyclesRequired)
|
||||||
{
|
{
|
||||||
calibratingB = calibrationCyclesRequired;
|
calibratingB = calibrationCyclesRequired;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Baro_Common(void)
|
void baroCommon(void)
|
||||||
{
|
{
|
||||||
static int32_t baroHistTab[BARO_TAB_SIZE_MAX];
|
static int32_t baroHistTab[BARO_TAB_SIZE_MAX];
|
||||||
static int baroHistIdx;
|
static int baroHistIdx;
|
||||||
|
@ -32,7 +32,7 @@ void Baro_Common(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int Baro_update(void)
|
int baroUpdate(void)
|
||||||
{
|
{
|
||||||
static uint32_t baroDeadline = 0;
|
static uint32_t baroDeadline = 0;
|
||||||
static int state = 0;
|
static int state = 0;
|
||||||
|
@ -52,14 +52,14 @@ int Baro_update(void)
|
||||||
} else {
|
} else {
|
||||||
baro.get_ut();
|
baro.get_ut();
|
||||||
baro.start_up();
|
baro.start_up();
|
||||||
Baro_Common();
|
baroCommon();
|
||||||
state = 1;
|
state = 1;
|
||||||
baroDeadline += baro.up_delay;
|
baroDeadline += baro.up_delay;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t Baro_calculateAltitude(void)
|
int32_t baroCalculateAltitude(void)
|
||||||
{
|
{
|
||||||
int32_t BaroAlt_tmp;
|
int32_t BaroAlt_tmp;
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#ifdef BARO
|
#ifdef BARO
|
||||||
void Baro_SetCalibrationCycles(uint16_t calibrationCyclesRequired);
|
void baroSetCalibrationCycles(uint16_t calibrationCyclesRequired);
|
||||||
void Baro_Common(void);
|
void baroCommon(void);
|
||||||
int Baro_update(void);
|
int baroUpdate(void);
|
||||||
int32_t Baro_calculateAltitude(void);
|
int32_t baroCalculateAltitude(void);
|
||||||
bool isBaroCalibrationComplete(void);
|
bool isBaroCalibrationComplete(void);
|
||||||
void performBaroCalibrationCycle(void);
|
void performBaroCalibrationCycle(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -8,7 +8,7 @@ sensor_align_e magAlign = 0;
|
||||||
#ifdef MAG
|
#ifdef MAG
|
||||||
static uint8_t magInit = 0;
|
static uint8_t magInit = 0;
|
||||||
|
|
||||||
void Mag_init(void)
|
void compassInit(void)
|
||||||
{
|
{
|
||||||
// initialize and calibration. turn on led during mag calibration (calibration routine blinks it)
|
// initialize and calibration. turn on led during mag calibration (calibration routine blinks it)
|
||||||
LED1_ON;
|
LED1_ON;
|
||||||
|
@ -17,7 +17,7 @@ void Mag_init(void)
|
||||||
magInit = 1;
|
magInit = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Mag_getADC(void)
|
int compassGetADC(void)
|
||||||
{
|
{
|
||||||
static uint32_t t, tCal = 0;
|
static uint32_t t, tCal = 0;
|
||||||
static int16_t magZeroTempMin[3];
|
static int16_t magZeroTempMin[3];
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#ifdef MAG
|
#ifdef MAG
|
||||||
void Mag_init(void);
|
void compassInit(void);
|
||||||
int Mag_getADC(void);
|
int compassGetADC(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern int16_t magADC[XYZ_AXIS_COUNT];
|
extern int16_t magADC[XYZ_AXIS_COUNT];
|
||||||
|
|
|
@ -11,12 +11,12 @@ uint16_t acc_1G = 256; // this is the 1G measured acceleration.
|
||||||
gyro_t gyro; // gyro access functions
|
gyro_t gyro; // gyro access functions
|
||||||
sensor_align_e gyroAlign = 0;
|
sensor_align_e gyroAlign = 0;
|
||||||
|
|
||||||
void GYRO_SetCalibrationCycles(uint16_t calibrationCyclesRequired)
|
void gyroSetCalibrationCycles(uint16_t calibrationCyclesRequired)
|
||||||
{
|
{
|
||||||
calibratingG = calibrationCyclesRequired;
|
calibratingG = calibrationCyclesRequired;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GYRO_Common(void)
|
void gyroCommon(void)
|
||||||
{
|
{
|
||||||
int axis;
|
int axis;
|
||||||
static int32_t g[3];
|
static int32_t g[3];
|
||||||
|
@ -56,10 +56,10 @@ void GYRO_Common(void)
|
||||||
gyroADC[axis] -= gyroZero[axis];
|
gyroADC[axis] -= gyroZero[axis];
|
||||||
}
|
}
|
||||||
|
|
||||||
void Gyro_getADC(void)
|
void gyroGetADC(void)
|
||||||
{
|
{
|
||||||
// range: +/- 8192; +/- 2000 deg/sec
|
// range: +/- 8192; +/- 2000 deg/sec
|
||||||
gyro.read(gyroADC);
|
gyro.read(gyroADC);
|
||||||
alignSensors(gyroADC, gyroADC, gyroAlign);
|
alignSensors(gyroADC, gyroADC, gyroAlign);
|
||||||
GYRO_Common();
|
gyroCommon();
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ extern uint16_t acc_1G;
|
||||||
extern gyro_t gyro;
|
extern gyro_t gyro;
|
||||||
extern sensor_align_e gyroAlign;
|
extern sensor_align_e gyroAlign;
|
||||||
|
|
||||||
void GYRO_SetCalibrationCycles(uint16_t calibrationCyclesRequired);
|
void gyroSetCalibrationCycles(uint16_t calibrationCyclesRequired);
|
||||||
void GYRO_Common(void);
|
void gyroCommon(void);
|
||||||
void Gyro_getADC(void);
|
void gyroGetADC(void);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue