mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-23 08:15:30 +03:00
CF/BF - First cut of allow building of the OSD SLAVE board without all
the flight controller code. Likely the dependencies can be further improved. This is a minimal-impact solution while there are a lot of other Betaflight PR's still pending.
This commit is contained in:
parent
2ec39de031
commit
2b1dac4c6d
38 changed files with 923 additions and 409 deletions
|
@ -35,7 +35,6 @@
|
|||
#include "common/maths.h"
|
||||
|
||||
#include "config/config_eeprom.h"
|
||||
#include "config/config_profile.h"
|
||||
#include "config/feature.h"
|
||||
#include "config/parameter_group.h"
|
||||
#include "config/parameter_group_ids.h"
|
||||
|
@ -67,6 +66,7 @@
|
|||
#include "fc/rc_controls.h"
|
||||
#include "fc/runtime_config.h"
|
||||
|
||||
#ifdef USE_FC
|
||||
#include "flight/altitude.h"
|
||||
#include "flight/failsafe.h"
|
||||
#include "flight/imu.h"
|
||||
|
@ -74,6 +74,7 @@
|
|||
#include "flight/navigation.h"
|
||||
#include "flight/pid.h"
|
||||
#include "flight/servos.h"
|
||||
#endif
|
||||
|
||||
#include "io/beeper.h"
|
||||
#include "io/gimbal.h"
|
||||
|
@ -98,7 +99,9 @@
|
|||
|
||||
#include "telemetry/telemetry.h"
|
||||
|
||||
#ifdef USE_FC
|
||||
pidProfile_t *currentPidProfile;
|
||||
#endif
|
||||
|
||||
#ifndef DEFAULT_FEATURES
|
||||
#define DEFAULT_FEATURES 0
|
||||
|
@ -118,13 +121,22 @@ PG_RESET_TEMPLATE(featureConfig_t, featureConfig,
|
|||
|
||||
PG_REGISTER_WITH_RESET_TEMPLATE(systemConfig_t, systemConfig, PG_SYSTEM_CONFIG, 0);
|
||||
|
||||
#ifdef USE_FC
|
||||
PG_RESET_TEMPLATE(systemConfig_t, systemConfig,
|
||||
.pidProfileIndex = 0,
|
||||
.activeRateProfile = 0,
|
||||
.debug_mode = DEBUG_MODE,
|
||||
.task_statistics = true,
|
||||
.name = { 0 }
|
||||
.name = { 0 } // FIXME misplaced, see PG_PILOT_CONFIG in CF v1.x
|
||||
);
|
||||
#endif
|
||||
|
||||
#ifdef USE_OSD_SLAVE
|
||||
PG_RESET_TEMPLATE(systemConfig_t, systemConfig,
|
||||
.debug_mode = DEBUG_MODE,
|
||||
.task_statistics = true
|
||||
);
|
||||
#endif
|
||||
|
||||
#ifdef BEEPER
|
||||
PG_REGISTER(beeperConfig_t, beeperConfig, PG_BEEPER_CONFIG, 0);
|
||||
|
@ -447,6 +459,7 @@ void pgResetFn_statusLedConfig(statusLedConfig_t *statusLedConfig)
|
|||
;
|
||||
}
|
||||
|
||||
#ifdef USE_FC
|
||||
uint8_t getCurrentPidProfileIndex(void)
|
||||
{
|
||||
return systemConfig()->pidProfileIndex;
|
||||
|
@ -470,6 +483,7 @@ uint16_t getCurrentMinthrottle(void)
|
|||
{
|
||||
return motorConfig()->minthrottle;
|
||||
}
|
||||
#endif
|
||||
|
||||
void resetConfigs(void)
|
||||
{
|
||||
|
@ -481,8 +495,10 @@ void resetConfigs(void)
|
|||
|
||||
pgActivateProfile(0);
|
||||
|
||||
#ifdef USE_FC
|
||||
setPidProfile(0);
|
||||
setControlRateProfile(0);
|
||||
#endif
|
||||
|
||||
#ifdef LED_STRIP
|
||||
reevaluateLedConfig();
|
||||
|
@ -491,6 +507,7 @@ void resetConfigs(void)
|
|||
|
||||
void activateConfig(void)
|
||||
{
|
||||
#ifdef USE_FC
|
||||
generateThrottleCurve();
|
||||
|
||||
resetAdjustmentStates();
|
||||
|
@ -509,10 +526,12 @@ void activateConfig(void)
|
|||
imuConfigure(throttleCorrectionConfig()->throttle_correction_angle);
|
||||
|
||||
configureAltitudeHold(currentPidProfile);
|
||||
#endif
|
||||
}
|
||||
|
||||
void validateAndFixConfig(void)
|
||||
{
|
||||
#ifdef USE_FC
|
||||
if((motorConfig()->dev.motorPwmProtocol == PWM_TYPE_BRUSHED) && (motorConfig()->mincommand < 1000)){
|
||||
motorConfigMutable()->mincommand = 1000;
|
||||
}
|
||||
|
@ -571,22 +590,24 @@ void validateAndFixConfig(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
if (!isSerialConfigValid(serialConfig())) {
|
||||
pgResetFn_serialConfig(serialConfigMutable());
|
||||
}
|
||||
|
||||
// Prevent invalid notch cutoff
|
||||
if (currentPidProfile->dterm_notch_cutoff >= currentPidProfile->dterm_notch_hz) {
|
||||
currentPidProfile->dterm_notch_hz = 0;
|
||||
}
|
||||
|
||||
validateAndFixGyroConfig();
|
||||
#endif
|
||||
|
||||
if (!isSerialConfigValid(serialConfig())) {
|
||||
pgResetFn_serialConfig(serialConfigMutable());
|
||||
}
|
||||
|
||||
#if defined(TARGET_VALIDATECONFIG)
|
||||
targetValidateConfiguration();
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef USE_FC
|
||||
void validateAndFixGyroConfig(void)
|
||||
{
|
||||
// Prevent invalid notch cutoff
|
||||
|
@ -662,16 +683,19 @@ void validateAndFixGyroConfig(void)
|
|||
motorConfigMutable()->dev.motorPwmRate = maxEscRate;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void readEEPROM(void)
|
||||
{
|
||||
#ifdef USE_FC
|
||||
suspendRxSignal();
|
||||
#endif
|
||||
|
||||
// Sanity check, read flash
|
||||
if (!loadEEPROM()) {
|
||||
failureMode(FAILURE_INVALID_EEPROM_CONTENTS);
|
||||
}
|
||||
|
||||
#ifdef USE_FC
|
||||
if (systemConfig()->activeRateProfile >= CONTROL_RATE_PROFILE_COUNT) {// sanity check
|
||||
systemConfigMutable()->activeRateProfile = 0;
|
||||
}
|
||||
|
@ -681,20 +705,27 @@ void readEEPROM(void)
|
|||
systemConfigMutable()->pidProfileIndex = 0;
|
||||
}
|
||||
setPidProfile(systemConfig()->pidProfileIndex);
|
||||
#endif
|
||||
|
||||
validateAndFixConfig();
|
||||
activateConfig();
|
||||
|
||||
#ifdef USE_FC
|
||||
resumeRxSignal();
|
||||
#endif
|
||||
}
|
||||
|
||||
void writeEEPROM(void)
|
||||
{
|
||||
#ifdef USE_FC
|
||||
suspendRxSignal();
|
||||
#endif
|
||||
|
||||
writeConfigToEEPROM();
|
||||
|
||||
#ifdef USE_FC
|
||||
resumeRxSignal();
|
||||
#endif
|
||||
}
|
||||
|
||||
void resetEEPROM(void)
|
||||
|
@ -718,6 +749,7 @@ void saveConfigAndNotify(void)
|
|||
beeperConfirmationBeeps(1);
|
||||
}
|
||||
|
||||
#ifdef USE_FC
|
||||
void changePidProfile(uint8_t pidProfileIndex)
|
||||
{
|
||||
if (pidProfileIndex >= MAX_PROFILE_COUNT) {
|
||||
|
@ -727,6 +759,7 @@ void changePidProfile(uint8_t pidProfileIndex)
|
|||
currentPidProfile = pidProfilesMutable(pidProfileIndex);
|
||||
beeperConfirmationBeeps(pidProfileIndex + 1);
|
||||
}
|
||||
#endif
|
||||
|
||||
void beeperOffSet(uint32_t mask)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue