1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-18 05:45:31 +03:00

allow user to fly without mag only if they reverse the default

This commit is contained in:
ctzsnooze 2024-10-14 12:12:06 +11:00
parent 5fecff404f
commit f09a71a76d
8 changed files with 19 additions and 5 deletions

View file

@ -70,6 +70,7 @@
#include "flight/mixer.h" #include "flight/mixer.h"
#include "flight/pid.h" #include "flight/pid.h"
#include "flight/position.h" #include "flight/position.h"
#include "flight/pos_hold.h"
#include "flight/rpm_filter.h" #include "flight/rpm_filter.h"
#include "flight/servos.h" #include "flight/servos.h"
#include "flight/imu.h" #include "flight/imu.h"
@ -1818,7 +1819,7 @@ static bool blackboxWriteSysinfo(void)
#endif #endif
#ifdef USE_POS_HOLD_MODE #ifdef USE_POS_HOLD_MODE
// nothing at present BLACKBOX_PRINT_HEADER_LINE(PARAM_NAME_POS_HOLD_WITHOUT_MAG, "%d", posHoldConfig()->pos_hold_without_mag);
#endif #endif
#ifdef USE_WING #ifdef USE_WING

View file

@ -64,6 +64,7 @@
#include "flight/mixer.h" #include "flight/mixer.h"
#include "flight/pid.h" #include "flight/pid.h"
#include "flight/position.h" #include "flight/position.h"
#include "flight/pos_hold.h"
#include "flight/rpm_filter.h" #include "flight/rpm_filter.h"
#include "flight/servos.h" #include "flight/servos.h"
@ -1113,7 +1114,7 @@ const clivalue_t valueTable[] = {
#endif #endif
#ifdef USE_POS_HOLD_MODE #ifdef USE_POS_HOLD_MODE
// nothing at present { PARAM_NAME_POS_HOLD_WITHOUT_MAG, VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OFF_ON }, PG_POSHOLD_CONFIG, offsetof(posHoldConfig_t, pos_hold_without_mag) },
#endif #endif
// PG_PID_CONFIG // PG_PID_CONFIG

View file

@ -1064,7 +1064,8 @@ void processRxModes(timeUs_t currentTimeUs)
// and we have Acc for self-levelling // and we have Acc for self-levelling
&& sensors(SENSOR_ACC) && sensors(SENSOR_ACC)
// and we have altitude data // and we have altitude data
// TO DO: handle No Mag data depending on user choice to proceed with or without mag && sensors(SENSOR_MAG || allowPosHoldWithoutMag())
// Need Mag unless a BRAVE user tries it without
&& isAltitudeAvailable() && isAltitudeAvailable()
// prevent activation until after takeoff // prevent activation until after takeoff
&& wasThrottleRaised()) { && wasThrottleRaised()) {

View file

@ -251,6 +251,10 @@
#define PARAM_NAME_ALT_HOLD_ADJUST_RATE "alt_hold_adjust_rate" #define PARAM_NAME_ALT_HOLD_ADJUST_RATE "alt_hold_adjust_rate"
#endif // USE_ALT_HOLD_MODE #endif // USE_ALT_HOLD_MODE
#ifdef USE_POS_HOLD_MODE
#define PARAM_NAME_POS_HOLD_WITHOUT_MAG "position_hold_without_mag"
#endif // USE_POS_HOLD_MODE
#define PARAM_NAME_IMU_DCM_KP "imu_dcm_kp" #define PARAM_NAME_IMU_DCM_KP "imu_dcm_kp"
#define PARAM_NAME_IMU_DCM_KI "imu_dcm_ki" #define PARAM_NAME_IMU_DCM_KI "imu_dcm_ki"
#define PARAM_NAME_IMU_SMALL_ANGLE "small_angle" #define PARAM_NAME_IMU_SMALL_ANGLE "small_angle"

View file

@ -104,4 +104,10 @@ bool showPosHoldWarning(void) {
return (posHold.isPosHoldRequested && !posHold.posHoldIsOK); return (posHold.isPosHoldRequested && !posHold.posHoldIsOK);
} }
bool allowPosHoldWithoutMag(void) {
return (posHoldConfig()->pos_hold_without_mag);
}
#endif // USE_POS_HOLD #endif // USE_POS_HOLD

View file

@ -36,5 +36,6 @@ void posHoldInit(void);
void updatePosHoldState(timeUs_t currentTimeUs); void updatePosHoldState(timeUs_t currentTimeUs);
bool showPosHoldWarning(void); bool showPosHoldWarning(void);
bool allowPosHoldWithoutMag(void);
#endif #endif

View file

@ -32,6 +32,6 @@
PG_REGISTER_WITH_RESET_TEMPLATE(posHoldConfig_t, posHoldConfig, PG_POSHOLD_CONFIG, 1); PG_REGISTER_WITH_RESET_TEMPLATE(posHoldConfig_t, posHoldConfig, PG_POSHOLD_CONFIG, 1);
PG_RESET_TEMPLATE(posHoldConfig_t, posHoldConfig, PG_RESET_TEMPLATE(posHoldConfig_t, posHoldConfig,
.unused = 33, // position hold within this percentage stick deflection .pos_hold_without_mag = false, // position hold within this percentage stick deflection
); );
#endif #endif

View file

@ -25,7 +25,7 @@
#include "pg/pg.h" #include "pg/pg.h"
typedef struct posHoldConfig_s { typedef struct posHoldConfig_s {
uint8_t unused; bool pos_hold_without_mag;
} posHoldConfig_t; } posHoldConfig_t;
PG_DECLARE(posHoldConfig_t, posHoldConfig); PG_DECLARE(posHoldConfig_t, posHoldConfig);