mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-26 01:35:41 +03:00
Initial commit for implementation of autotune.
This commit is contained in:
parent
49c283fe59
commit
f7c38af7fc
10 changed files with 184 additions and 3 deletions
27
src/mw.c
27
src/mw.c
|
@ -22,6 +22,7 @@
|
|||
#include "failsafe.h"
|
||||
#include "flight_imu.h"
|
||||
#include "flight_common.h"
|
||||
#include "flight_autotune.h"
|
||||
#include "flight_mixer.h"
|
||||
#include "gimbal.h"
|
||||
#include "gps_common.h"
|
||||
|
@ -78,6 +79,30 @@ bool AccInflightCalibrationSavetoEEProm = false;
|
|||
bool AccInflightCalibrationActive = false;
|
||||
uint16_t InflightcalibratingA = 0;
|
||||
|
||||
void updateAutotuneState(void)
|
||||
{
|
||||
if (rcOptions[BOXAUTOTUNE]) {
|
||||
if (!f.AUTOTUNE_MODE) {
|
||||
if (f.ARMED) {
|
||||
autotuneBegin(¤tProfile.pidProfile, currentProfile.pidController);
|
||||
f.AUTOTUNE_MODE = 1;
|
||||
} else {
|
||||
if (havePidsBeenUpdatedByAutotune()) {
|
||||
//writeEEPROM();
|
||||
blinkLedAndSoundBeeper(5, 50, 1);
|
||||
autotuneReset();
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (f.AUTOTUNE_MODE) {
|
||||
autotuneEnd();
|
||||
f.AUTOTUNE_MODE = 0;
|
||||
}
|
||||
}
|
||||
|
||||
bool isCalibrating()
|
||||
{
|
||||
#ifdef BARO
|
||||
|
@ -603,6 +628,8 @@ void loop(void)
|
|||
cycleTime = (int32_t)(currentTime - previousTime);
|
||||
previousTime = currentTime;
|
||||
|
||||
updateAutotuneState();
|
||||
|
||||
#ifdef MAG
|
||||
if (sensors(SENSOR_MAG)) {
|
||||
if (abs(rcCommand[YAW]) < 70 && f.MAG_MODE) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue