Added shadow copies for CLI and MSP.

This commit is contained in:
mikeller 2018-07-10 00:49:17 +12:00
parent 985a9208d5
commit 6de1c32d9d
56 changed files with 277 additions and 222 deletions

View File

@ -448,7 +448,7 @@ static bool testBlackboxConditionUncached(FlightLogFieldCondition condition)
#endif #endif
case FLIGHT_LOG_FIELD_CONDITION_RSSI: case FLIGHT_LOG_FIELD_CONDITION_RSSI:
return rxConfig()->rssi_channel > 0 || featureConfigured(FEATURE_RSSI_ADC); return rxConfig()->rssi_channel > 0 || featureIsEnabled(FEATURE_RSSI_ADC);
case FLIGHT_LOG_FIELD_CONDITION_NOT_LOGGING_EVERY_FRAME: case FLIGHT_LOG_FIELD_CONDITION_NOT_LOGGING_EVERY_FRAME:
return blackboxConfig()->p_ratio != 1; return blackboxConfig()->p_ratio != 1;
@ -1488,7 +1488,7 @@ STATIC_UNIT_TESTED void blackboxLogIteration(timeUs_t currentTimeUs)
writeInterframe(); writeInterframe();
} }
#ifdef USE_GPS #ifdef USE_GPS
if (featureConfigured(FEATURE_GPS)) { if (featureIsEnabled(FEATURE_GPS)) {
if (blackboxShouldLogGpsHomeFrame()) { if (blackboxShouldLogGpsHomeFrame()) {
writeGPSHomeFrame(); writeGPSHomeFrame();
writeGPSFrame(currentTimeUs); writeGPSFrame(currentTimeUs);
@ -1554,7 +1554,7 @@ void blackboxUpdate(timeUs_t currentTimeUs)
if (!sendFieldDefinition('I', 'P', blackboxMainFields, blackboxMainFields + 1, ARRAYLEN(blackboxMainFields), if (!sendFieldDefinition('I', 'P', blackboxMainFields, blackboxMainFields + 1, ARRAYLEN(blackboxMainFields),
&blackboxMainFields[0].condition, &blackboxMainFields[1].condition)) { &blackboxMainFields[0].condition, &blackboxMainFields[1].condition)) {
#ifdef USE_GPS #ifdef USE_GPS
if (featureConfigured(FEATURE_GPS)) { if (featureIsEnabled(FEATURE_GPS)) {
blackboxSetState(BLACKBOX_STATE_SEND_GPS_H_HEADER); blackboxSetState(BLACKBOX_STATE_SEND_GPS_H_HEADER);
} else } else
#endif #endif

View File

@ -48,7 +48,7 @@ static uint8_t cmsx_FeatureLedstrip;
static long cmsx_Ledstrip_FeatureRead(void) static long cmsx_Ledstrip_FeatureRead(void)
{ {
if (!featureRead) { if (!featureRead) {
cmsx_FeatureLedstrip = featureConfigured(FEATURE_LED_STRIP) ? 1 : 0; cmsx_FeatureLedstrip = featureIsEnabled(FEATURE_LED_STRIP) ? 1 : 0;
featureRead = true; featureRead = true;
} }
@ -60,9 +60,9 @@ static long cmsx_Ledstrip_FeatureWriteback(const OSD_Entry *self)
UNUSED(self); UNUSED(self);
if (featureRead) { if (featureRead) {
if (cmsx_FeatureLedstrip) if (cmsx_FeatureLedstrip)
featureSet(FEATURE_LED_STRIP); featureEnable(FEATURE_LED_STRIP);
else else
featureClear(FEATURE_LED_STRIP); featureDisable(FEATURE_LED_STRIP);
} }
return 0; return 0;

View File

@ -35,32 +35,32 @@ PG_RESET_TEMPLATE(featureConfig_t, featureConfig,
.enabledFeatures = DEFAULT_FEATURES | DEFAULT_RX_FEATURE | FEATURE_DYNAMIC_FILTER | FEATURE_ANTI_GRAVITY, .enabledFeatures = DEFAULT_FEATURES | DEFAULT_RX_FEATURE | FEATURE_DYNAMIC_FILTER | FEATURE_ANTI_GRAVITY,
); );
void featureSetLocal(const uint32_t mask, uint32_t *features) void featureSet(const uint32_t mask, uint32_t *features)
{ {
*features |= mask; *features |= mask;
} }
void featureClearLocal(const uint32_t mask, uint32_t *features) void featureClear(const uint32_t mask, uint32_t *features)
{ {
*features &= ~(mask); *features &= ~(mask);
} }
bool featureConfigured(const uint32_t mask) bool featureIsEnabled(const uint32_t mask)
{ {
return featureConfig()->enabledFeatures & mask; return featureConfig()->enabledFeatures & mask;
} }
void featureSet(const uint32_t mask) void featureEnable(const uint32_t mask)
{ {
featureSetLocal(mask, &featureConfigMutable()->enabledFeatures); featureSet(mask, &featureConfigMutable()->enabledFeatures);
} }
void featureClear(const uint32_t mask) void featureDisable(const uint32_t mask)
{ {
featureClearLocal(mask, &featureConfigMutable()->enabledFeatures); featureClear(mask, &featureConfigMutable()->enabledFeatures);
} }
void featureClearAll(void) void featureDisableAll(void)
{ {
featureConfigMutable()->enabledFeatures = 0; featureConfigMutable()->enabledFeatures = 0;
} }

View File

@ -62,11 +62,11 @@ typedef struct featureConfig_s {
PG_DECLARE(featureConfig_t, featureConfig); PG_DECLARE(featureConfig_t, featureConfig);
bool featureConfigured(const uint32_t mask); bool featureIsEnabled(const uint32_t mask);
void featureSet(const uint32_t mask); void featureEnable(const uint32_t mask);
void featureClear(const uint32_t mask); void featureDisable(const uint32_t mask);
void featureClearAll(void); void featureDisableAll(void);
uint32_t featureMask(void); uint32_t featureMask(void);
void featureSetLocal(const uint32_t mask, uint32_t *features); void featureSet(const uint32_t mask, uint32_t *features);
void featureClearLocal(const uint32_t mask, uint32_t *features); void featureClear(const uint32_t mask, uint32_t *features);

View File

@ -174,7 +174,7 @@ static void validateAndFixConfig(void)
!findSerialPortConfig(FUNCTION_GPS) && !findSerialPortConfig(FUNCTION_GPS) &&
#endif #endif
true) { true) {
featureClear(FEATURE_GPS); featureDisable(FEATURE_GPS);
} }
#ifndef USE_OSD_SLAVE #ifndef USE_OSD_SLAVE
@ -194,7 +194,7 @@ static void validateAndFixConfig(void)
} }
if (motorConfig()->dev.motorPwmProtocol == PWM_TYPE_BRUSHED) { if (motorConfig()->dev.motorPwmProtocol == PWM_TYPE_BRUSHED) {
featureClear(FEATURE_3D); featureDisable(FEATURE_3D);
if (motorConfig()->mincommand < 1000) { if (motorConfig()->mincommand < 1000) {
motorConfigMutable()->mincommand = 1000; motorConfigMutable()->mincommand = 1000;
@ -207,40 +207,40 @@ static void validateAndFixConfig(void)
validateAndFixGyroConfig(); validateAndFixGyroConfig();
if (!(featureConfigured(FEATURE_RX_PARALLEL_PWM) || featureConfigured(FEATURE_RX_PPM) || featureConfigured(FEATURE_RX_SERIAL) || featureConfigured(FEATURE_RX_MSP) || featureConfigured(FEATURE_RX_SPI))) { if (!(featureIsEnabled(FEATURE_RX_PARALLEL_PWM) || featureIsEnabled(FEATURE_RX_PPM) || featureIsEnabled(FEATURE_RX_SERIAL) || featureIsEnabled(FEATURE_RX_MSP) || featureIsEnabled(FEATURE_RX_SPI))) {
featureSet(DEFAULT_RX_FEATURE); featureEnable(DEFAULT_RX_FEATURE);
} }
if (featureConfigured(FEATURE_RX_PPM)) { if (featureIsEnabled(FEATURE_RX_PPM)) {
featureClear(FEATURE_RX_SERIAL | FEATURE_RX_PARALLEL_PWM | FEATURE_RX_MSP | FEATURE_RX_SPI); featureDisable(FEATURE_RX_SERIAL | FEATURE_RX_PARALLEL_PWM | FEATURE_RX_MSP | FEATURE_RX_SPI);
} }
if (featureConfigured(FEATURE_RX_MSP)) { if (featureIsEnabled(FEATURE_RX_MSP)) {
featureClear(FEATURE_RX_SERIAL | FEATURE_RX_PARALLEL_PWM | FEATURE_RX_PPM | FEATURE_RX_SPI); featureDisable(FEATURE_RX_SERIAL | FEATURE_RX_PARALLEL_PWM | FEATURE_RX_PPM | FEATURE_RX_SPI);
} }
if (featureConfigured(FEATURE_RX_SERIAL)) { if (featureIsEnabled(FEATURE_RX_SERIAL)) {
featureClear(FEATURE_RX_PARALLEL_PWM | FEATURE_RX_MSP | FEATURE_RX_PPM | FEATURE_RX_SPI); featureDisable(FEATURE_RX_PARALLEL_PWM | FEATURE_RX_MSP | FEATURE_RX_PPM | FEATURE_RX_SPI);
} }
#ifdef USE_RX_SPI #ifdef USE_RX_SPI
if (featureConfigured(FEATURE_RX_SPI)) { if (featureIsEnabled(FEATURE_RX_SPI)) {
featureClear(FEATURE_RX_SERIAL | FEATURE_RX_PARALLEL_PWM | FEATURE_RX_PPM | FEATURE_RX_MSP); featureDisable(FEATURE_RX_SERIAL | FEATURE_RX_PARALLEL_PWM | FEATURE_RX_PPM | FEATURE_RX_MSP);
} }
#endif // USE_RX_SPI #endif // USE_RX_SPI
if (featureConfigured(FEATURE_RX_PARALLEL_PWM)) { if (featureIsEnabled(FEATURE_RX_PARALLEL_PWM)) {
featureClear(FEATURE_RX_SERIAL | FEATURE_RX_MSP | FEATURE_RX_PPM | FEATURE_RX_SPI); featureDisable(FEATURE_RX_SERIAL | FEATURE_RX_MSP | FEATURE_RX_PPM | FEATURE_RX_SPI);
} }
#ifdef USE_SOFTSPI #ifdef USE_SOFTSPI
if (featureConfigured(FEATURE_SOFTSPI)) { if (featureIsEnabled(FEATURE_SOFTSPI)) {
featureClear(FEATURE_RX_PPM | FEATURE_RX_PARALLEL_PWM | FEATURE_SOFTSERIAL); featureDisable(FEATURE_RX_PPM | FEATURE_RX_PARALLEL_PWM | FEATURE_SOFTSERIAL);
batteryConfigMutable()->voltageMeterSource = VOLTAGE_METER_NONE; batteryConfigMutable()->voltageMeterSource = VOLTAGE_METER_NONE;
#if defined(STM32F10X) #if defined(STM32F10X)
featureClear(FEATURE_LED_STRIP); featureDisable(FEATURE_LED_STRIP);
// rssi adc needs the same ports // rssi adc needs the same ports
featureClear(FEATURE_RSSI_ADC); featureDisable(FEATURE_RSSI_ADC);
// current meter needs the same ports // current meter needs the same ports
if (batteryConfig()->currentMeterSource == CURRENT_METER_ADC) { if (batteryConfig()->currentMeterSource == CURRENT_METER_ADC) {
batteryConfigMutable()->currentMeterSource = CURRENT_METER_NONE; batteryConfigMutable()->currentMeterSource = CURRENT_METER_NONE;
@ -250,14 +250,14 @@ static void validateAndFixConfig(void)
#endif // USE_SOFTSPI #endif // USE_SOFTSPI
#if defined(USE_ADC) #if defined(USE_ADC)
if (featureConfigured(FEATURE_RSSI_ADC)) { if (featureIsEnabled(FEATURE_RSSI_ADC)) {
rxConfigMutable()->rssi_channel = 0; rxConfigMutable()->rssi_channel = 0;
rxConfigMutable()->rssi_src_frame_errors = false; rxConfigMutable()->rssi_src_frame_errors = false;
} else } else
#endif #endif
if (rxConfigMutable()->rssi_channel if (rxConfigMutable()->rssi_channel
#if defined(USE_PWM) || defined(USE_PPM) #if defined(USE_PWM) || defined(USE_PPM)
|| featureConfigured(FEATURE_RX_PPM) || featureConfigured(FEATURE_RX_PARALLEL_PWM) || featureIsEnabled(FEATURE_RX_PPM) || featureIsEnabled(FEATURE_RX_PARALLEL_PWM)
#endif #endif
) { ) {
rxConfigMutable()->rssi_src_frame_errors = false; rxConfigMutable()->rssi_src_frame_errors = false;
@ -291,7 +291,7 @@ static void validateAndFixConfig(void)
#endif #endif
if ( if (
featureConfigured(FEATURE_3D) || !featureConfigured(FEATURE_GPS) featureIsEnabled(FEATURE_3D) || !featureIsEnabled(FEATURE_GPS)
#if !defined(USE_GPS) || !defined(USE_GPS_RESCUE) #if !defined(USE_GPS) || !defined(USE_GPS_RESCUE)
|| true || true
#endif #endif
@ -308,7 +308,7 @@ static void validateAndFixConfig(void)
#if defined(USE_ESC_SENSOR) #if defined(USE_ESC_SENSOR)
if (!findSerialPortConfig(FUNCTION_ESC_SENSOR)) { if (!findSerialPortConfig(FUNCTION_ESC_SENSOR)) {
featureClear(FEATURE_ESC_SENSOR); featureDisable(FEATURE_ESC_SENSOR);
} }
#endif #endif
@ -316,71 +316,71 @@ static void validateAndFixConfig(void)
// I have kept them all here in one place, some could be moved to sections of code above. // I have kept them all here in one place, some could be moved to sections of code above.
#ifndef USE_PPM #ifndef USE_PPM
featureClear(FEATURE_RX_PPM); featureDisable(FEATURE_RX_PPM);
#endif #endif
#ifndef USE_SERIAL_RX #ifndef USE_SERIAL_RX
featureClear(FEATURE_RX_SERIAL); featureDisable(FEATURE_RX_SERIAL);
#endif #endif
#if !defined(USE_SOFTSERIAL1) && !defined(USE_SOFTSERIAL2) #if !defined(USE_SOFTSERIAL1) && !defined(USE_SOFTSERIAL2)
featureClear(FEATURE_SOFTSERIAL); featureDisable(FEATURE_SOFTSERIAL);
#endif #endif
#ifndef USE_RANGEFINDER #ifndef USE_RANGEFINDER
featureClear(FEATURE_RANGEFINDER); featureDisable(FEATURE_RANGEFINDER);
#endif #endif
#ifndef USE_TELEMETRY #ifndef USE_TELEMETRY
featureClear(FEATURE_TELEMETRY); featureDisable(FEATURE_TELEMETRY);
#endif #endif
#ifndef USE_PWM #ifndef USE_PWM
featureClear(FEATURE_RX_PARALLEL_PWM); featureDisable(FEATURE_RX_PARALLEL_PWM);
#endif #endif
#ifndef USE_RX_MSP #ifndef USE_RX_MSP
featureClear(FEATURE_RX_MSP); featureDisable(FEATURE_RX_MSP);
#endif #endif
#ifndef USE_LED_STRIP #ifndef USE_LED_STRIP
featureClear(FEATURE_LED_STRIP); featureDisable(FEATURE_LED_STRIP);
#endif #endif
#ifndef USE_DASHBOARD #ifndef USE_DASHBOARD
featureClear(FEATURE_DASHBOARD); featureDisable(FEATURE_DASHBOARD);
#endif #endif
#ifndef USE_OSD #ifndef USE_OSD
featureClear(FEATURE_OSD); featureDisable(FEATURE_OSD);
#endif #endif
#ifndef USE_SERVOS #ifndef USE_SERVOS
featureClear(FEATURE_SERVO_TILT | FEATURE_CHANNEL_FORWARDING); featureDisable(FEATURE_SERVO_TILT | FEATURE_CHANNEL_FORWARDING);
#endif #endif
#ifndef USE_TRANSPONDER #ifndef USE_TRANSPONDER
featureClear(FEATURE_TRANSPONDER); featureDisable(FEATURE_TRANSPONDER);
#endif #endif
#ifndef USE_RX_SPI #ifndef USE_RX_SPI
featureClear(FEATURE_RX_SPI); featureDisable(FEATURE_RX_SPI);
#endif #endif
#ifndef USE_SOFTSPI #ifndef USE_SOFTSPI
featureClear(FEATURE_SOFTSPI); featureDisable(FEATURE_SOFTSPI);
#endif #endif
#ifndef USE_ESC_SENSOR #ifndef USE_ESC_SENSOR
featureClear(FEATURE_ESC_SENSOR); featureDisable(FEATURE_ESC_SENSOR);
#endif #endif
#ifndef USE_GYRO_DATA_ANALYSE #ifndef USE_GYRO_DATA_ANALYSE
featureClear(FEATURE_DYNAMIC_FILTER); featureDisable(FEATURE_DYNAMIC_FILTER);
#endif #endif
#if !defined(USE_ADC) #if !defined(USE_ADC)
featureClear(FEATURE_RSSI_ADC); featureDisable(FEATURE_RSSI_ADC);
#endif #endif
#if defined(USE_BEEPER) #if defined(USE_BEEPER)
@ -548,6 +548,14 @@ void writeEEPROM(void)
#endif #endif
} }
void writeEEPROMWithFeatures(uint32_t features)
{
featureDisableAll();
featureEnable(features);
writeEEPROM();
}
void resetEEPROM(void) void resetEEPROM(void)
{ {
resetConfigs(); resetConfigs();

View File

@ -53,6 +53,7 @@ void initEEPROM(void);
void resetEEPROM(void); void resetEEPROM(void);
bool readEEPROM(void); bool readEEPROM(void);
void writeEEPROM(void); void writeEEPROM(void);
void writeEEPROMWithFeatures(uint32_t features);
void ensureEEPROMStructureIsValid(void); void ensureEEPROMStructureIsValid(void);
void saveConfigAndNotify(void); void saveConfigAndNotify(void);

View File

@ -268,7 +268,7 @@ void updateArmingStatus(void)
&& !(getArmingDisableFlags() & ~(ARMING_DISABLED_ARM_SWITCH | ARMING_DISABLED_CALIBRATING)); && !(getArmingDisableFlags() & ~(ARMING_DISABLED_ARM_SWITCH | ARMING_DISABLED_CALIBRATING));
/* Ignore ARMING_DISABLED_THROTTLE (once arm switch is on) if we are in 3D mode */ /* Ignore ARMING_DISABLED_THROTTLE (once arm switch is on) if we are in 3D mode */
bool ignoreThrottle = featureConfigured(FEATURE_3D) bool ignoreThrottle = featureIsEnabled(FEATURE_3D)
&& !IS_RC_MODE_ACTIVE(BOX3D) && !IS_RC_MODE_ACTIVE(BOX3D)
&& !flight3DConfig()->switched_mode3d && !flight3DConfig()->switched_mode3d
&& !(getArmingDisableFlags() & ~(ARMING_DISABLED_ARM_SWITCH | ARMING_DISABLED_THROTTLE)); && !(getArmingDisableFlags() & ~(ARMING_DISABLED_ARM_SWITCH | ARMING_DISABLED_THROTTLE));
@ -313,7 +313,7 @@ void disarm(void)
#endif #endif
BEEP_OFF; BEEP_OFF;
#ifdef USE_DSHOT #ifdef USE_DSHOT
if (isMotorProtocolDshot() && flipOverAfterCrashMode && !featureConfigured(FEATURE_3D)) { if (isMotorProtocolDshot() && flipOverAfterCrashMode && !featureIsEnabled(FEATURE_3D)) {
pwmWriteDshotCommand(ALL_MOTORS, getMotorCount(), DSHOT_CMD_SPIN_DIRECTION_NORMAL, false); pwmWriteDshotCommand(ALL_MOTORS, getMotorCount(), DSHOT_CMD_SPIN_DIRECTION_NORMAL, false);
} }
#endif #endif
@ -352,7 +352,7 @@ void tryArm(void)
if (isMotorProtocolDshot() && isModeActivationConditionPresent(BOXFLIPOVERAFTERCRASH)) { if (isMotorProtocolDshot() && isModeActivationConditionPresent(BOXFLIPOVERAFTERCRASH)) {
if (!(IS_RC_MODE_ACTIVE(BOXFLIPOVERAFTERCRASH) || (tryingToArm == ARMING_DELAYED_CRASHFLIP))) { if (!(IS_RC_MODE_ACTIVE(BOXFLIPOVERAFTERCRASH) || (tryingToArm == ARMING_DELAYED_CRASHFLIP))) {
flipOverAfterCrashMode = false; flipOverAfterCrashMode = false;
if (!featureConfigured(FEATURE_3D)) { if (!featureIsEnabled(FEATURE_3D)) {
pwmWriteDshotCommand(ALL_MOTORS, getMotorCount(), DSHOT_CMD_SPIN_DIRECTION_NORMAL, false); pwmWriteDshotCommand(ALL_MOTORS, getMotorCount(), DSHOT_CMD_SPIN_DIRECTION_NORMAL, false);
} }
} else { } else {
@ -360,7 +360,7 @@ void tryArm(void)
#ifdef USE_RUNAWAY_TAKEOFF #ifdef USE_RUNAWAY_TAKEOFF
runawayTakeoffCheckDisabled = false; runawayTakeoffCheckDisabled = false;
#endif #endif
if (!featureConfigured(FEATURE_3D)) { if (!featureIsEnabled(FEATURE_3D)) {
pwmWriteDshotCommand(ALL_MOTORS, getMotorCount(), DSHOT_CMD_SPIN_DIRECTION_REVERSED, false); pwmWriteDshotCommand(ALL_MOTORS, getMotorCount(), DSHOT_CMD_SPIN_DIRECTION_REVERSED, false);
} }
} }
@ -387,7 +387,7 @@ void tryArm(void)
//beep to indicate arming //beep to indicate arming
#ifdef USE_GPS #ifdef USE_GPS
if (featureConfigured(FEATURE_GPS) && STATE(GPS_FIX) && gpsSol.numSat >= 5) { if (featureIsEnabled(FEATURE_GPS) && STATE(GPS_FIX) && gpsSol.numSat >= 5) {
beeper(BEEPER_ARMING_GPS_FIX); beeper(BEEPER_ARMING_GPS_FIX);
} else { } else {
beeper(BEEPER_ARMING); beeper(BEEPER_ARMING);
@ -517,7 +517,7 @@ void runawayTakeoffTemporaryDisable(uint8_t disableFlag)
uint8_t calculateThrottlePercent(void) uint8_t calculateThrottlePercent(void)
{ {
uint8_t ret = 0; uint8_t ret = 0;
if (featureConfigured(FEATURE_3D) if (featureIsEnabled(FEATURE_3D)
&& !IS_RC_MODE_ACTIVE(BOX3D) && !IS_RC_MODE_ACTIVE(BOX3D)
&& !flight3DConfig()->switched_mode3d) { && !flight3DConfig()->switched_mode3d) {
@ -560,7 +560,7 @@ bool processRx(timeUs_t currentTimeUs)
} }
// in 3D mode, we need to be able to disarm by switch at any time // in 3D mode, we need to be able to disarm by switch at any time
if (featureConfigured(FEATURE_3D)) { if (featureIsEnabled(FEATURE_3D)) {
if (!IS_RC_MODE_ACTIVE(BOXARM)) if (!IS_RC_MODE_ACTIVE(BOXARM))
disarm(); disarm();
} }
@ -615,7 +615,7 @@ bool processRx(timeUs_t currentTimeUs)
// - sticks are active and have deflection greater than runaway_takeoff_deactivate_stick_percent // - sticks are active and have deflection greater than runaway_takeoff_deactivate_stick_percent
// - pidSum on all axis is less then runaway_takeoff_deactivate_pidlimit // - pidSum on all axis is less then runaway_takeoff_deactivate_pidlimit
bool inStableFlight = false; bool inStableFlight = false;
if (!featureConfigured(FEATURE_MOTOR_STOP) || isAirmodeActive() || (throttleStatus != THROTTLE_LOW)) { // are motors running? if (!featureIsEnabled(FEATURE_MOTOR_STOP) || isAirmodeActive() || (throttleStatus != THROTTLE_LOW)) { // are motors running?
const uint8_t lowThrottleLimit = pidConfig()->runaway_takeoff_deactivate_throttle; const uint8_t lowThrottleLimit = pidConfig()->runaway_takeoff_deactivate_throttle;
const uint8_t midThrottleLimit = constrain(lowThrottleLimit * 2, lowThrottleLimit * 2, RUNAWAY_TAKEOFF_HIGH_THROTTLE_PERCENT); const uint8_t midThrottleLimit = constrain(lowThrottleLimit * 2, lowThrottleLimit * 2, RUNAWAY_TAKEOFF_HIGH_THROTTLE_PERCENT);
if ((((throttlePercent >= lowThrottleLimit) && areSticksActive(RUNAWAY_TAKEOFF_DEACTIVATE_STICK_PERCENT)) || (throttlePercent >= midThrottleLimit)) if ((((throttlePercent >= lowThrottleLimit) && areSticksActive(RUNAWAY_TAKEOFF_DEACTIVATE_STICK_PERCENT)) || (throttlePercent >= midThrottleLimit))
@ -667,9 +667,9 @@ bool processRx(timeUs_t currentTimeUs)
// board after delay so users without buzzer won't lose fingers. // board after delay so users without buzzer won't lose fingers.
// mixTable constrains motor commands, so checking throttleStatus is enough // mixTable constrains motor commands, so checking throttleStatus is enough
if (ARMING_FLAG(ARMED) if (ARMING_FLAG(ARMED)
&& featureConfigured(FEATURE_MOTOR_STOP) && featureIsEnabled(FEATURE_MOTOR_STOP)
&& !STATE(FIXED_WING) && !STATE(FIXED_WING)
&& !featureConfigured(FEATURE_3D) && !featureIsEnabled(FEATURE_3D)
&& !isAirmodeActive() && !isAirmodeActive()
) { ) {
if (isUsingSticksForArming()) { if (isUsingSticksForArming()) {
@ -711,7 +711,7 @@ bool processRx(timeUs_t currentTimeUs)
processRcStickPositions(); processRcStickPositions();
if (featureConfigured(FEATURE_INFLIGHT_ACC_CAL)) { if (featureIsEnabled(FEATURE_INFLIGHT_ACC_CAL)) {
updateInflightCalibrationState(); updateInflightCalibrationState();
} }
@ -814,7 +814,7 @@ bool processRx(timeUs_t currentTimeUs)
} }
#ifdef USE_TELEMETRY #ifdef USE_TELEMETRY
if (featureConfigured(FEATURE_TELEMETRY)) { if (featureIsEnabled(FEATURE_TELEMETRY)) {
bool enableSharedPortTelemetry = (!isModeActivationConditionPresent(BOXTELEMETRY) && ARMING_FLAG(ARMED)) || (isModeActivationConditionPresent(BOXTELEMETRY) && IS_RC_MODE_ACTIVE(BOXTELEMETRY)); bool enableSharedPortTelemetry = (!isModeActivationConditionPresent(BOXTELEMETRY) && ARMING_FLAG(ARMED)) || (isModeActivationConditionPresent(BOXTELEMETRY) && IS_RC_MODE_ACTIVE(BOXTELEMETRY));
if (enableSharedPortTelemetry && !sharedPortTelemetryEnabled) { if (enableSharedPortTelemetry && !sharedPortTelemetryEnabled) {
mspSerialReleaseSharedTelemetryPorts(); mspSerialReleaseSharedTelemetryPorts();
@ -872,7 +872,7 @@ static FAST_CODE void subTaskPidController(timeUs_t currentTimeUs)
&& !runawayTakeoffCheckDisabled && !runawayTakeoffCheckDisabled
&& !flipOverAfterCrashMode && !flipOverAfterCrashMode
&& !runawayTakeoffTemporarilyDisabled && !runawayTakeoffTemporarilyDisabled
&& (!featureConfigured(FEATURE_MOTOR_STOP) || isAirmodeActive() || (calculateThrottleStatus() != THROTTLE_LOW))) { && (!featureIsEnabled(FEATURE_MOTOR_STOP) || isAirmodeActive() || (calculateThrottleStatus() != THROTTLE_LOW))) {
if (((fabsf(pidData[FD_PITCH].Sum) >= RUNAWAY_TAKEOFF_PIDSUM_THRESHOLD) if (((fabsf(pidData[FD_PITCH].Sum) >= RUNAWAY_TAKEOFF_PIDSUM_THRESHOLD)
|| (fabsf(pidData[FD_ROLL].Sum) >= RUNAWAY_TAKEOFF_PIDSUM_THRESHOLD) || (fabsf(pidData[FD_ROLL].Sum) >= RUNAWAY_TAKEOFF_PIDSUM_THRESHOLD)

View File

@ -296,7 +296,7 @@ void init(void)
#endif #endif
#if defined(USE_SPEKTRUM_BIND) #if defined(USE_SPEKTRUM_BIND)
if (featureConfigured(FEATURE_RX_SERIAL)) { if (featureIsEnabled(FEATURE_RX_SERIAL)) {
switch (rxConfig()->serialrx_provider) { switch (rxConfig()->serialrx_provider) {
case SERIALRX_SPEKTRUM1024: case SERIALRX_SPEKTRUM1024:
case SERIALRX_SPEKTRUM2048: case SERIALRX_SPEKTRUM2048:
@ -327,23 +327,23 @@ void init(void)
#endif #endif
#if defined(AVOID_UART1_FOR_PWM_PPM) #if defined(AVOID_UART1_FOR_PWM_PPM)
serialInit(featureConfigured(FEATURE_SOFTSERIAL), serialInit(featureIsEnabled(FEATURE_SOFTSERIAL),
featureConfigured(FEATURE_RX_PPM) || featureConfigured(FEATURE_RX_PARALLEL_PWM) ? SERIAL_PORT_USART1 : SERIAL_PORT_NONE); featureIsEnabled(FEATURE_RX_PPM) || featureIsEnabled(FEATURE_RX_PARALLEL_PWM) ? SERIAL_PORT_USART1 : SERIAL_PORT_NONE);
#elif defined(AVOID_UART2_FOR_PWM_PPM) #elif defined(AVOID_UART2_FOR_PWM_PPM)
serialInit(featureConfigured(FEATURE_SOFTSERIAL), serialInit(featureIsEnabled(FEATURE_SOFTSERIAL),
featureConfigured(FEATURE_RX_PPM) || featureConfigured(FEATURE_RX_PARALLEL_PWM) ? SERIAL_PORT_USART2 : SERIAL_PORT_NONE); featureIsEnabled(FEATURE_RX_PPM) || featureIsEnabled(FEATURE_RX_PARALLEL_PWM) ? SERIAL_PORT_USART2 : SERIAL_PORT_NONE);
#elif defined(AVOID_UART3_FOR_PWM_PPM) #elif defined(AVOID_UART3_FOR_PWM_PPM)
serialInit(featureConfigured(FEATURE_SOFTSERIAL), serialInit(featureIsEnabled(FEATURE_SOFTSERIAL),
featureConfigured(FEATURE_RX_PPM) || featureConfigured(FEATURE_RX_PARALLEL_PWM) ? SERIAL_PORT_USART3 : SERIAL_PORT_NONE); featureIsEnabled(FEATURE_RX_PPM) || featureIsEnabled(FEATURE_RX_PARALLEL_PWM) ? SERIAL_PORT_USART3 : SERIAL_PORT_NONE);
#else #else
serialInit(featureConfigured(FEATURE_SOFTSERIAL), SERIAL_PORT_NONE); serialInit(featureIsEnabled(FEATURE_SOFTSERIAL), SERIAL_PORT_NONE);
#endif #endif
mixerInit(mixerConfig()->mixerMode); mixerInit(mixerConfig()->mixerMode);
mixerConfigureOutput(); mixerConfigureOutput();
uint16_t idlePulse = motorConfig()->mincommand; uint16_t idlePulse = motorConfig()->mincommand;
if (featureConfigured(FEATURE_3D)) { if (featureIsEnabled(FEATURE_3D)) {
idlePulse = flight3DConfig()->neutral3d; idlePulse = flight3DConfig()->neutral3d;
} }
if (motorConfig()->dev.motorPwmProtocol == PWM_TYPE_BRUSHED) { if (motorConfig()->dev.motorPwmProtocol == PWM_TYPE_BRUSHED) {
@ -357,12 +357,12 @@ void init(void)
if (0) {} if (0) {}
#if defined(USE_PPM) #if defined(USE_PPM)
else if (featureConfigured(FEATURE_RX_PPM)) { else if (featureIsEnabled(FEATURE_RX_PPM)) {
ppmRxInit(ppmConfig()); ppmRxInit(ppmConfig());
} }
#endif #endif
#if defined(USE_PWM) #if defined(USE_PWM)
else if (featureConfigured(FEATURE_RX_PARALLEL_PWM)) { else if (featureIsEnabled(FEATURE_RX_PARALLEL_PWM)) {
pwmRxInit(pwmConfig()); pwmRxInit(pwmConfig());
} }
#endif #endif
@ -449,13 +449,13 @@ void init(void)
// XXX These kind of code should goto target/config.c? // XXX These kind of code should goto target/config.c?
// XXX And these no longer work properly as FEATURE_RANGEFINDER does control HCSR04 runtime configuration. // XXX And these no longer work properly as FEATURE_RANGEFINDER does control HCSR04 runtime configuration.
#if defined(RANGEFINDER_HCSR04_SOFTSERIAL2_EXCLUSIVE) && defined(USE_RANGEFINDER_HCSR04) && defined(USE_SOFTSERIAL2) #if defined(RANGEFINDER_HCSR04_SOFTSERIAL2_EXCLUSIVE) && defined(USE_RANGEFINDER_HCSR04) && defined(USE_SOFTSERIAL2)
if (featureConfigured(FEATURE_RANGEFINDER) && featureConfigured(FEATURE_SOFTSERIAL)) { if (featureIsEnabled(FEATURE_RANGEFINDER) && featureIsEnabled(FEATURE_SOFTSERIAL)) {
serialRemovePort(SERIAL_PORT_SOFTSERIAL2); serialRemovePort(SERIAL_PORT_SOFTSERIAL2);
} }
#endif #endif
#if defined(RANGEFINDER_HCSR04_SOFTSERIAL1_EXCLUSIVE) && defined(USE_RANGEFINDER_HCSR04) && defined(USE_SOFTSERIAL1) #if defined(RANGEFINDER_HCSR04_SOFTSERIAL1_EXCLUSIVE) && defined(USE_RANGEFINDER_HCSR04) && defined(USE_SOFTSERIAL1)
if (featureConfigured(FEATURE_RANGEFINDER) && featureConfigured(FEATURE_SOFTSERIAL)) { if (featureIsEnabled(FEATURE_RANGEFINDER) && featureIsEnabled(FEATURE_SOFTSERIAL)) {
serialRemovePort(SERIAL_PORT_SOFTSERIAL1); serialRemovePort(SERIAL_PORT_SOFTSERIAL1);
} }
#endif #endif
@ -465,9 +465,9 @@ void init(void)
adcConfigMutable()->current.enabled = (batteryConfig()->currentMeterSource == CURRENT_METER_ADC); adcConfigMutable()->current.enabled = (batteryConfig()->currentMeterSource == CURRENT_METER_ADC);
// The FrSky D SPI RX sends RSSI_ADC_PIN (if configured) as A2 // The FrSky D SPI RX sends RSSI_ADC_PIN (if configured) as A2
adcConfigMutable()->rssi.enabled = featureConfigured(FEATURE_RSSI_ADC); adcConfigMutable()->rssi.enabled = featureIsEnabled(FEATURE_RSSI_ADC);
#ifdef USE_RX_SPI #ifdef USE_RX_SPI
adcConfigMutable()->rssi.enabled |= (featureConfigured(FEATURE_RX_SPI) && rxSpiConfig()->rx_spi_protocol == RX_SPI_FRSKY_D); adcConfigMutable()->rssi.enabled |= (featureIsEnabled(FEATURE_RX_SPI) && rxSpiConfig()->rx_spi_protocol == RX_SPI_FRSKY_D);
#endif #endif
adcInit(adcConfig()); adcInit(adcConfig());
#endif #endif
@ -496,7 +496,7 @@ void init(void)
servosInit(); servosInit();
servoConfigureOutput(); servoConfigureOutput();
if (isMixerUsingServos()) { if (isMixerUsingServos()) {
//pwm_params.useChannelForwarding = featureConfigured(FEATURE_CHANNEL_FORWARDING); //pwm_params.useChannelForwarding = featureIsEnabled(FEATURE_CHANNEL_FORWARDING);
servoDevInit(&servoConfig()->dev); servoDevInit(&servoConfig()->dev);
} }
servosFilterInit(); servosFilterInit();
@ -558,7 +558,7 @@ void init(void)
#if defined(USE_OSD) && !defined(USE_OSD_SLAVE) #if defined(USE_OSD) && !defined(USE_OSD_SLAVE)
//The OSD need to be initialised after GYRO to avoid GYRO initialisation failure on some targets //The OSD need to be initialised after GYRO to avoid GYRO initialisation failure on some targets
if (featureConfigured(FEATURE_OSD)) { if (featureIsEnabled(FEATURE_OSD)) {
#if defined(USE_MAX7456) #if defined(USE_MAX7456)
// If there is a max7456 chip for the OSD then use it // If there is a max7456 chip for the OSD then use it
osdDisplayPort = max7456DisplayPortInit(vcdProfile()); osdDisplayPort = max7456DisplayPortInit(vcdProfile());
@ -587,7 +587,7 @@ void init(void)
#ifdef USE_DASHBOARD #ifdef USE_DASHBOARD
// Dashbord will register with CMS by itself. // Dashbord will register with CMS by itself.
if (featureConfigured(FEATURE_DASHBOARD)) { if (featureIsEnabled(FEATURE_DASHBOARD)) {
dashboardInit(); dashboardInit();
} }
#endif #endif
@ -598,7 +598,7 @@ void init(void)
#endif #endif
#ifdef USE_GPS #ifdef USE_GPS
if (featureConfigured(FEATURE_GPS)) { if (featureIsEnabled(FEATURE_GPS)) {
gpsInit(); gpsInit();
} }
#endif #endif
@ -606,19 +606,19 @@ void init(void)
#ifdef USE_LED_STRIP #ifdef USE_LED_STRIP
ledStripInit(); ledStripInit();
if (featureConfigured(FEATURE_LED_STRIP)) { if (featureIsEnabled(FEATURE_LED_STRIP)) {
ledStripEnable(); ledStripEnable();
} }
#endif #endif
#ifdef USE_TELEMETRY #ifdef USE_TELEMETRY
if (featureConfigured(FEATURE_TELEMETRY)) { if (featureIsEnabled(FEATURE_TELEMETRY)) {
telemetryInit(); telemetryInit();
} }
#endif #endif
#ifdef USE_ESC_SENSOR #ifdef USE_ESC_SENSOR
if (featureConfigured(FEATURE_ESC_SENSOR)) { if (featureIsEnabled(FEATURE_ESC_SENSOR)) {
escSensorInit(); escSensorInit();
} }
#endif #endif
@ -628,7 +628,7 @@ void init(void)
#endif #endif
#ifdef USE_TRANSPONDER #ifdef USE_TRANSPONDER
if (featureConfigured(FEATURE_TRANSPONDER)) { if (featureIsEnabled(FEATURE_TRANSPONDER)) {
transponderInit(); transponderInit();
transponderStartRepeating(); transponderStartRepeating();
systemState |= SYSTEM_STATE_TRANSPONDER_ENABLED; systemState |= SYSTEM_STATE_TRANSPONDER_ENABLED;
@ -711,7 +711,7 @@ void init(void)
batteryInit(); // always needs doing, regardless of features. batteryInit(); // always needs doing, regardless of features.
#ifdef USE_DASHBOARD #ifdef USE_DASHBOARD
if (featureConfigured(FEATURE_DASHBOARD)) { if (featureIsEnabled(FEATURE_DASHBOARD)) {
#ifdef USE_OLED_GPS_DEBUG_PAGE_ONLY #ifdef USE_OLED_GPS_DEBUG_PAGE_ONLY
dashboardShowFixedPage(PAGE_GPS); dashboardShowFixedPage(PAGE_GPS);
#else #else

View File

@ -203,7 +203,7 @@ static void checkForThrottleErrorResetState(uint16_t rxRefreshRate)
const int rxRefreshRateMs = rxRefreshRate / 1000; const int rxRefreshRateMs = rxRefreshRate / 1000;
const int indexMax = constrain(THROTTLE_DELTA_MS / rxRefreshRateMs, 1, THROTTLE_BUFFER_MAX); const int indexMax = constrain(THROTTLE_DELTA_MS / rxRefreshRateMs, 1, THROTTLE_BUFFER_MAX);
const int16_t throttleVelocityThreshold = (featureConfigured(FEATURE_3D)) ? currentPidProfile->itermThrottleThreshold / 2 : currentPidProfile->itermThrottleThreshold; const int16_t throttleVelocityThreshold = (featureIsEnabled(FEATURE_3D)) ? currentPidProfile->itermThrottleThreshold / 2 : currentPidProfile->itermThrottleThreshold;
rcCommandThrottlePrevious[index++] = rcCommand[THROTTLE]; rcCommandThrottlePrevious[index++] = rcCommand[THROTTLE];
if (index >= indexMax) { if (index >= indexMax) {
@ -621,7 +621,7 @@ FAST_CODE FAST_CODE_NOINLINE void updateRcCommands(void)
} }
int32_t tmp; int32_t tmp;
if (featureConfigured(FEATURE_3D)) { if (featureIsEnabled(FEATURE_3D)) {
tmp = constrain(rcData[THROTTLE], PWM_RANGE_MIN, PWM_RANGE_MAX); tmp = constrain(rcData[THROTTLE], PWM_RANGE_MIN, PWM_RANGE_MAX);
tmp = (uint32_t)(tmp - PWM_RANGE_MIN); tmp = (uint32_t)(tmp - PWM_RANGE_MIN);
} else { } else {
@ -635,7 +635,7 @@ FAST_CODE FAST_CODE_NOINLINE void updateRcCommands(void)
rcCommand[THROTTLE] = rcLookupThrottle(tmp); rcCommand[THROTTLE] = rcLookupThrottle(tmp);
if (featureConfigured(FEATURE_3D) && !failsafeIsActive()) { if (featureIsEnabled(FEATURE_3D) && !failsafeIsActive()) {
if (!flight3DConfig()->switched_mode3d) { if (!flight3DConfig()->switched_mode3d) {
if (IS_RC_MODE_ACTIVE(BOX3D)) { if (IS_RC_MODE_ACTIVE(BOX3D)) {
fix12_t throttleScaler = qConstruct(rcCommand[THROTTLE] - 1000, 1000); fix12_t throttleScaler = qConstruct(rcCommand[THROTTLE] - 1000, 1000);

View File

@ -216,7 +216,7 @@ static void taskCalculateAltitude(timeUs_t currentTimeUs)
#ifdef USE_TELEMETRY #ifdef USE_TELEMETRY
static void taskTelemetry(timeUs_t currentTimeUs) static void taskTelemetry(timeUs_t currentTimeUs)
{ {
if (!cliMode && featureConfigured(FEATURE_TELEMETRY)) { if (!cliMode && featureIsEnabled(FEATURE_TELEMETRY)) {
subTaskTelemetryPollSensors(currentTimeUs); subTaskTelemetryPollSensors(currentTimeUs);
telemetryProcess(currentTimeUs); telemetryProcess(currentTimeUs);
@ -251,12 +251,12 @@ void fcTasksInit(void)
#ifdef USE_OSD_SLAVE #ifdef USE_OSD_SLAVE
const bool useBatteryAlerts = batteryConfig()->useVBatAlerts || batteryConfig()->useConsumptionAlerts; const bool useBatteryAlerts = batteryConfig()->useVBatAlerts || batteryConfig()->useConsumptionAlerts;
#else #else
const bool useBatteryAlerts = batteryConfig()->useVBatAlerts || batteryConfig()->useConsumptionAlerts || featureConfigured(FEATURE_OSD); const bool useBatteryAlerts = batteryConfig()->useVBatAlerts || batteryConfig()->useConsumptionAlerts || featureIsEnabled(FEATURE_OSD);
#endif #endif
setTaskEnabled(TASK_BATTERY_ALERTS, (useBatteryVoltage || useBatteryCurrent) && useBatteryAlerts); setTaskEnabled(TASK_BATTERY_ALERTS, (useBatteryVoltage || useBatteryCurrent) && useBatteryAlerts);
#ifdef USE_TRANSPONDER #ifdef USE_TRANSPONDER
setTaskEnabled(TASK_TRANSPONDER, featureConfigured(FEATURE_TRANSPONDER)); setTaskEnabled(TASK_TRANSPONDER, featureIsEnabled(FEATURE_TRANSPONDER));
#endif #endif
#ifdef STACK_CHECK #ifdef STACK_CHECK
@ -285,7 +285,7 @@ void fcTasksInit(void)
setTaskEnabled(TASK_BEEPER, true); setTaskEnabled(TASK_BEEPER, true);
#endif #endif
#ifdef USE_GPS #ifdef USE_GPS
setTaskEnabled(TASK_GPS, featureConfigured(FEATURE_GPS)); setTaskEnabled(TASK_GPS, featureIsEnabled(FEATURE_GPS));
#endif #endif
#ifdef USE_MAG #ifdef USE_MAG
setTaskEnabled(TASK_COMPASS, sensors(SENSOR_MAG)); setTaskEnabled(TASK_COMPASS, sensors(SENSOR_MAG));
@ -294,13 +294,13 @@ void fcTasksInit(void)
setTaskEnabled(TASK_BARO, sensors(SENSOR_BARO)); setTaskEnabled(TASK_BARO, sensors(SENSOR_BARO));
#endif #endif
#if defined(USE_BARO) || defined(USE_GPS) #if defined(USE_BARO) || defined(USE_GPS)
setTaskEnabled(TASK_ALTITUDE, sensors(SENSOR_BARO) || featureConfigured(FEATURE_GPS)); setTaskEnabled(TASK_ALTITUDE, sensors(SENSOR_BARO) || featureIsEnabled(FEATURE_GPS));
#endif #endif
#ifdef USE_DASHBOARD #ifdef USE_DASHBOARD
setTaskEnabled(TASK_DASHBOARD, featureConfigured(FEATURE_DASHBOARD)); setTaskEnabled(TASK_DASHBOARD, featureIsEnabled(FEATURE_DASHBOARD));
#endif #endif
#ifdef USE_TELEMETRY #ifdef USE_TELEMETRY
if (featureConfigured(FEATURE_TELEMETRY)) { if (featureIsEnabled(FEATURE_TELEMETRY)) {
setTaskEnabled(TASK_TELEMETRY, true); setTaskEnabled(TASK_TELEMETRY, true);
if (rxConfig()->serialrx_provider == SERIALRX_JETIEXBUS) { if (rxConfig()->serialrx_provider == SERIALRX_JETIEXBUS) {
// Reschedule telemetry to 500hz for Jeti Exbus // Reschedule telemetry to 500hz for Jeti Exbus
@ -312,19 +312,19 @@ void fcTasksInit(void)
} }
#endif #endif
#ifdef USE_LED_STRIP #ifdef USE_LED_STRIP
setTaskEnabled(TASK_LEDSTRIP, featureConfigured(FEATURE_LED_STRIP)); setTaskEnabled(TASK_LEDSTRIP, featureIsEnabled(FEATURE_LED_STRIP));
#endif #endif
#ifdef USE_TRANSPONDER #ifdef USE_TRANSPONDER
setTaskEnabled(TASK_TRANSPONDER, featureConfigured(FEATURE_TRANSPONDER)); setTaskEnabled(TASK_TRANSPONDER, featureIsEnabled(FEATURE_TRANSPONDER));
#endif #endif
#ifdef USE_OSD #ifdef USE_OSD
setTaskEnabled(TASK_OSD, featureConfigured(FEATURE_OSD) && osdInitialized()); setTaskEnabled(TASK_OSD, featureIsEnabled(FEATURE_OSD) && osdInitialized()));
#endif #endif
#ifdef USE_BST #ifdef USE_BST
setTaskEnabled(TASK_BST_MASTER_PROCESS, true); setTaskEnabled(TASK_BST_MASTER_PROCESS, true);
#endif #endif
#ifdef USE_ESC_SENSOR #ifdef USE_ESC_SENSOR
setTaskEnabled(TASK_ESC_SENSOR, featureConfigured(FEATURE_ESC_SENSOR)); setTaskEnabled(TASK_ESC_SENSOR, featureIsEnabled(FEATURE_ESC_SENSOR));
#endif #endif
#ifdef USE_ADC_INTERNAL #ifdef USE_ADC_INTERNAL
setTaskEnabled(TASK_ADC_INTERNAL, true); setTaskEnabled(TASK_ADC_INTERNAL, true);
@ -336,7 +336,7 @@ void fcTasksInit(void)
#ifdef USE_MSP_DISPLAYPORT #ifdef USE_MSP_DISPLAYPORT
setTaskEnabled(TASK_CMS, true); setTaskEnabled(TASK_CMS, true);
#else #else
setTaskEnabled(TASK_CMS, featureConfigured(FEATURE_OSD) || featureConfigured(FEATURE_DASHBOARD)); setTaskEnabled(TASK_CMS, featureIsEnabled(FEATURE_OSD) || featureIsEnabled(FEATURE_DASHBOARD));
#endif #endif
#endif #endif
#ifdef USE_VTX_CONTROL #ifdef USE_VTX_CONTROL

View File

@ -113,7 +113,7 @@ bool areSticksInApModePosition(uint16_t ap_mode)
throttleStatus_e calculateThrottleStatus(void) throttleStatus_e calculateThrottleStatus(void)
{ {
if (featureConfigured(FEATURE_3D)) { if (featureIsEnabled(FEATURE_3D)) {
if (IS_RC_MODE_ACTIVE(BOX3D) || flight3DConfig()->switched_mode3d) { if (IS_RC_MODE_ACTIVE(BOX3D) || flight3DConfig()->switched_mode3d) {
if (rcData[THROTTLE] < rxConfig()->mincheck) { if (rcData[THROTTLE] < rxConfig()->mincheck) {
return THROTTLE_LOW; return THROTTLE_LOW;
@ -240,7 +240,7 @@ void processRcStickPositions()
gyroStartCalibration(false); gyroStartCalibration(false);
#ifdef USE_GPS #ifdef USE_GPS
if (featureConfigured(FEATURE_GPS)) { if (featureIsEnabled(FEATURE_GPS)) {
GPS_reset_home_position(); GPS_reset_home_position();
} }
#endif #endif
@ -253,7 +253,7 @@ void processRcStickPositions()
return; return;
} }
if (featureConfigured(FEATURE_INFLIGHT_ACC_CAL) && (rcSticks == THR_LO + YAW_LO + PIT_HI + ROL_HI)) { if (featureIsEnabled(FEATURE_INFLIGHT_ACC_CAL) && (rcSticks == THR_LO + YAW_LO + PIT_HI + ROL_HI)) {
// Inflight ACC Calibration // Inflight ACC Calibration
handleInflightCalibrationStickPosition(); handleInflightCalibrationStickPosition();
return; return;

View File

@ -59,7 +59,7 @@ void rcModeUpdate(boxBitmask_t *newState)
} }
bool isAirmodeActive(void) { bool isAirmodeActive(void) {
return (IS_RC_MODE_ACTIVE(BOXAIRMODE) || featureConfigured(FEATURE_AIRMODE)); return (IS_RC_MODE_ACTIVE(BOXAIRMODE) || featureIsEnabled(FEATURE_AIRMODE));
} }
bool isRangeActive(uint8_t auxChannelIndex, const channelRange_t *range) { bool isRangeActive(uint8_t auxChannelIndex, const channelRange_t *range) {

View File

@ -383,7 +383,7 @@ void initEscEndpoints(void)
case PWM_TYPE_DSHOT300: case PWM_TYPE_DSHOT300:
case PWM_TYPE_DSHOT150: case PWM_TYPE_DSHOT150:
disarmMotorOutput = DSHOT_DISARM_COMMAND; disarmMotorOutput = DSHOT_DISARM_COMMAND;
if (featureConfigured(FEATURE_3D)) { if (featureIsEnabled(FEATURE_3D)) {
motorOutputLow = DSHOT_MIN_THROTTLE + ((DSHOT_3D_DEADBAND_LOW - DSHOT_MIN_THROTTLE) / 100.0f) * CONVERT_PARAMETER_TO_PERCENT(motorConfig()->digitalIdleOffsetValue); motorOutputLow = DSHOT_MIN_THROTTLE + ((DSHOT_3D_DEADBAND_LOW - DSHOT_MIN_THROTTLE) / 100.0f) * CONVERT_PARAMETER_TO_PERCENT(motorConfig()->digitalIdleOffsetValue);
} else { } else {
motorOutputLow = DSHOT_MIN_THROTTLE + ((DSHOT_MAX_THROTTLE - DSHOT_MIN_THROTTLE) / 100.0f) * CONVERT_PARAMETER_TO_PERCENT(motorConfig()->digitalIdleOffsetValue); motorOutputLow = DSHOT_MIN_THROTTLE + ((DSHOT_MAX_THROTTLE - DSHOT_MIN_THROTTLE) / 100.0f) * CONVERT_PARAMETER_TO_PERCENT(motorConfig()->digitalIdleOffsetValue);
@ -395,7 +395,7 @@ void initEscEndpoints(void)
break; break;
#endif #endif
default: default:
if (featureConfigured(FEATURE_3D)) { if (featureIsEnabled(FEATURE_3D)) {
disarmMotorOutput = flight3DConfig()->neutral3d; disarmMotorOutput = flight3DConfig()->neutral3d;
motorOutputLow = flight3DConfig()->limit3d_low; motorOutputLow = flight3DConfig()->limit3d_low;
motorOutputHigh = flight3DConfig()->limit3d_high; motorOutputHigh = flight3DConfig()->limit3d_high;
@ -536,7 +536,7 @@ static void calculateThrottleAndCurrentMotorEndpoints(timeUs_t currentTimeUs)
static timeUs_t reversalTimeUs = 0; // time when motors last reversed in 3D mode static timeUs_t reversalTimeUs = 0; // time when motors last reversed in 3D mode
float currentThrottleInputRange = 0; float currentThrottleInputRange = 0;
if (featureConfigured(FEATURE_3D)) { if (featureIsEnabled(FEATURE_3D)) {
if (!ARMING_FLAG(ARMED)) { if (!ARMING_FLAG(ARMED)) {
rcThrottlePrevious = rxConfig()->midrc; // When disarmed set to mid_rc. It always results in positive direction after arming. rcThrottlePrevious = rxConfig()->midrc; // When disarmed set to mid_rc. It always results in positive direction after arming.
} }
@ -708,7 +708,7 @@ static void applyMixToMotors(float motorMix[MAX_SUPPORTED_MOTORS])
motorOutput = constrain(motorOutput, motorRangeMin, motorRangeMax); motorOutput = constrain(motorOutput, motorRangeMin, motorRangeMax);
} }
// Motor stop handling // Motor stop handling
if (featureConfigured(FEATURE_MOTOR_STOP) && ARMING_FLAG(ARMED) && !featureConfigured(FEATURE_3D) && !isAirmodeActive()) { if (featureIsEnabled(FEATURE_MOTOR_STOP) && ARMING_FLAG(ARMED) && !featureIsEnabled(FEATURE_3D) && !isAirmodeActive()) {
if (((rcData[THROTTLE]) < rxConfig()->mincheck)) { if (((rcData[THROTTLE]) < rxConfig()->mincheck)) {
motorOutput = disarmMotorOutput; motorOutput = disarmMotorOutput;
} }
@ -851,7 +851,7 @@ float convertExternalToMotor(uint16_t externalValue)
case true: case true:
externalValue = constrain(externalValue, PWM_RANGE_MIN, PWM_RANGE_MAX); externalValue = constrain(externalValue, PWM_RANGE_MIN, PWM_RANGE_MAX);
if (featureConfigured(FEATURE_3D)) { if (featureIsEnabled(FEATURE_3D)) {
if (externalValue == PWM_RANGE_MID) { if (externalValue == PWM_RANGE_MID) {
motorValue = DSHOT_DISARM_COMMAND; motorValue = DSHOT_DISARM_COMMAND;
} else if (externalValue < PWM_RANGE_MID) { } else if (externalValue < PWM_RANGE_MID) {
@ -880,7 +880,7 @@ uint16_t convertMotorToExternal(float motorValue)
switch ((int)isMotorProtocolDshot()) { switch ((int)isMotorProtocolDshot()) {
#ifdef USE_DSHOT #ifdef USE_DSHOT
case true: case true:
if (featureConfigured(FEATURE_3D)) { if (featureIsEnabled(FEATURE_3D)) {
if (motorValue == DSHOT_DISARM_COMMAND || motorValue < DSHOT_MIN_THROTTLE) { if (motorValue == DSHOT_DISARM_COMMAND || motorValue < DSHOT_MIN_THROTTLE) {
externalValue = PWM_RANGE_MID; externalValue = PWM_RANGE_MID;
} else if (motorValue <= DSHOT_3D_DEADBAND_LOW) { } else if (motorValue <= DSHOT_3D_DEADBAND_LOW) {

View File

@ -224,7 +224,7 @@ void servosInit(void)
// enable servos for mixes that require them. note, this shifts motor counts. // enable servos for mixes that require them. note, this shifts motor counts.
useServo = mixers[currentMixerMode].useServo; useServo = mixers[currentMixerMode].useServo;
// if we want camstab/trig, that also enables servos, even if mixer doesn't // if we want camstab/trig, that also enables servos, even if mixer doesn't
if (featureConfigured(FEATURE_SERVO_TILT) || featureConfigured(FEATURE_CHANNEL_FORWARDING)) { if (featureIsEnabled(FEATURE_SERVO_TILT) || featureIsEnabled(FEATURE_CHANNEL_FORWARDING)) {
useServo = 1; useServo = 1;
} }
@ -377,13 +377,13 @@ void writeServos(void)
} }
// Two servos for SERVO_TILT, if enabled // Two servos for SERVO_TILT, if enabled
if (featureConfigured(FEATURE_SERVO_TILT) || currentMixerMode == MIXER_GIMBAL) { if (featureIsEnabled(FEATURE_SERVO_TILT) || currentMixerMode == MIXER_GIMBAL) {
updateGimbalServos(servoIndex); updateGimbalServos(servoIndex);
servoIndex += 2; servoIndex += 2;
} }
// forward AUX to remaining servo outputs (not constrained) // forward AUX to remaining servo outputs (not constrained)
if (featureConfigured(FEATURE_CHANNEL_FORWARDING)) { if (featureIsEnabled(FEATURE_CHANNEL_FORWARDING)) {
forwardAuxChannelsToServos(servoIndex); forwardAuxChannelsToServos(servoIndex);
servoIndex += MAX_AUX_CHANNEL_COUNT; servoIndex += MAX_AUX_CHANNEL_COUNT;
} }
@ -406,7 +406,7 @@ void servoMixer(void)
input[INPUT_STABILIZED_YAW] = pidData[FD_YAW].Sum * PID_SERVO_MIXER_SCALING; input[INPUT_STABILIZED_YAW] = pidData[FD_YAW].Sum * PID_SERVO_MIXER_SCALING;
// Reverse yaw servo when inverted in 3D mode // Reverse yaw servo when inverted in 3D mode
if (featureConfigured(FEATURE_3D) && (rcData[THROTTLE] < rxConfig()->midrc)) { if (featureIsEnabled(FEATURE_3D) && (rcData[THROTTLE] < rxConfig()->midrc)) {
input[INPUT_STABILIZED_YAW] *= -1; input[INPUT_STABILIZED_YAW] *= -1;
} }
} }
@ -498,7 +498,7 @@ static void servoTable(void)
} }
// camera stabilization // camera stabilization
if (featureConfigured(FEATURE_SERVO_TILT)) { if (featureIsEnabled(FEATURE_SERVO_TILT)) {
// center at fixed position, or vary either pitch or roll by RC channel // center at fixed position, or vary either pitch or roll by RC channel
servo[SERVO_GIMBAL_PITCH] = determineServoMiddleOrForwardFromChannel(SERVO_GIMBAL_PITCH); servo[SERVO_GIMBAL_PITCH] = determineServoMiddleOrForwardFromChannel(SERVO_GIMBAL_PITCH);
servo[SERVO_GIMBAL_ROLL] = determineServoMiddleOrForwardFromChannel(SERVO_GIMBAL_ROLL); servo[SERVO_GIMBAL_ROLL] = determineServoMiddleOrForwardFromChannel(SERVO_GIMBAL_ROLL);

View File

@ -179,6 +179,9 @@ static bool configIsInCopy = false;
static int8_t pidProfileIndexToUse = CURRENT_PROFILE_INDEX; static int8_t pidProfileIndexToUse = CURRENT_PROFILE_INDEX;
static int8_t rateProfileIndexToUse = CURRENT_PROFILE_INDEX; static int8_t rateProfileIndexToUse = CURRENT_PROFILE_INDEX;
static bool featureMaskIsCopied = false;
static uint32_t featureMaskCopy;
#if defined(USE_BOARD_INFO) #if defined(USE_BOARD_INFO)
static bool boardInformationUpdated = false; static bool boardInformationUpdated = false;
#if defined(USE_SIGNATURE) #if defined(USE_SIGNATURE)
@ -2345,9 +2348,18 @@ static void cliMcuId(char *cmdline)
cliPrintLinef("mcu_id %08x%08x%08x", U_ID_0, U_ID_1, U_ID_2); cliPrintLinef("mcu_id %08x%08x%08x", U_ID_0, U_ID_1, U_ID_2);
} }
static uint32_t getFeatureMask(const uint32_t featureMask)
{
if (featureMaskIsCopied) {
return featureMaskCopy;
} else {
return featureMask;
}
}
static void printFeature(uint8_t dumpMask, const featureConfig_t *featureConfig, const featureConfig_t *featureConfigDefault) static void printFeature(uint8_t dumpMask, const featureConfig_t *featureConfig, const featureConfig_t *featureConfigDefault)
{ {
const uint32_t mask = featureConfig->enabledFeatures; const uint32_t mask = getFeatureMask(featureConfig->enabledFeatures);
const uint32_t defaultMask = featureConfigDefault->enabledFeatures; const uint32_t defaultMask = featureConfigDefault->enabledFeatures;
for (uint32_t i = 0; featureNames[i]; i++) { // disabled features first for (uint32_t i = 0; featureNames[i]; i++) { // disabled features first
if (strcmp(featureNames[i], emptyString) != 0) { //Skip unused if (strcmp(featureNames[i], emptyString) != 0) { //Skip unused
@ -2372,15 +2384,16 @@ static void printFeature(uint8_t dumpMask, const featureConfig_t *featureConfig,
static void cliFeature(char *cmdline) static void cliFeature(char *cmdline)
{ {
uint32_t len = strlen(cmdline); uint32_t len = strlen(cmdline);
uint32_t mask = featureMask(); const uint32_t mask = getFeatureMask(featureMask());
if (len == 0) { if (len == 0) {
cliPrint("Enabled: "); cliPrint("Enabled: ");
for (uint32_t i = 0; ; i++) { for (uint32_t i = 0; ; i++) {
if (featureNames[i] == NULL) if (featureNames[i] == NULL) {
break; break;
if (mask & (1 << i)) }
if (mask & (1 << i)) {
cliPrintf("%s ", featureNames[i]); cliPrintf("%s ", featureNames[i]);
}
} }
cliPrintLinefeed(); cliPrintLinefeed();
} else if (strncasecmp(cmdline, "list", len) == 0) { } else if (strncasecmp(cmdline, "list", len) == 0) {
@ -2394,6 +2407,12 @@ static void cliFeature(char *cmdline)
cliPrintLinefeed(); cliPrintLinefeed();
return; return;
} else { } else {
if (!featureMaskIsCopied) {
featureMaskCopy = featureMask();
featureMaskIsCopied = true;
}
uint32_t feature;
bool remove = false; bool remove = false;
if (cmdline[0] == '-') { if (cmdline[0] == '-') {
// remove feature // remove feature
@ -2409,25 +2428,24 @@ static void cliFeature(char *cmdline)
} }
if (strncasecmp(cmdline, featureNames[i], len) == 0) { if (strncasecmp(cmdline, featureNames[i], len) == 0) {
feature = 1 << i;
mask = 1 << i;
#ifndef USE_GPS #ifndef USE_GPS
if (mask & FEATURE_GPS) { if (feature & FEATURE_GPS) {
cliPrintLine("unavailable"); cliPrintLine("unavailable");
break; break;
} }
#endif #endif
#ifndef USE_RANGEFINDER #ifndef USE_RANGEFINDER
if (mask & FEATURE_RANGEFINDER) { if (feature & FEATURE_RANGEFINDER) {
cliPrintLine("unavailable"); cliPrintLine("unavailable");
break; break;
} }
#endif #endif
if (remove) { if (remove) {
featureClear(mask); featureClear(feature, &featureMaskCopy);
cliPrint("Disabled"); cliPrint("Disabled");
} else { } else {
featureSet(mask); featureSet(feature, &featureMaskCopy);
cliPrint("Enabled"); cliPrint("Enabled");
} }
cliPrintLinef(" %s", featureNames[i]); cliPrintLinef(" %s", featureNames[i]);
@ -2946,7 +2964,7 @@ static void cliDshotProg(char *cmdline)
pwmWriteDshotCommand(escIndex, getMotorCount(), command, true); pwmWriteDshotCommand(escIndex, getMotorCount(), command, true);
} else { } else {
#if defined(USE_ESC_SENSOR) && defined(USE_ESC_SENSOR_INFO) #if defined(USE_ESC_SENSOR) && defined(USE_ESC_SENSOR_INFO)
if (featureConfigured(FEATURE_ESC_SENSOR)) { if (featureIsEnabled(FEATURE_ESC_SENSOR)) {
if (escIndex != ALL_MOTORS) { if (escIndex != ALL_MOTORS) {
executeEscInfoCommand(escIndex); executeEscInfoCommand(escIndex);
} else { } else {
@ -3238,7 +3256,11 @@ static void cliSave(char *cmdline)
#endif #endif
#endif // USE_BOARD_INFO #endif // USE_BOARD_INFO
writeEEPROM(); if (featureMaskIsCopied) {
writeEEPROMWithFeatures(featureMaskCopy);
} else {
writeEEPROM();
}
cliReboot(); cliReboot();
} }
@ -4642,9 +4664,9 @@ void cliEnter(serialPort_t *serialPort)
#else #else
cliPrintLine("\r\nCLI"); cliPrintLine("\r\nCLI");
#endif #endif
cliPrompt();
setArmingDisabled(ARMING_DISABLED_CLI); setArmingDisabled(ARMING_DISABLED_CLI);
cliPrompt();
} }
void cliInit(const serialConfig_t *serialConfig) void cliInit(const serialConfig_t *serialConfig)

View File

@ -165,6 +165,18 @@ typedef enum {
#define RTC_NOT_SUPPORTED 0xff #define RTC_NOT_SUPPORTED 0xff
static bool featureMaskIsCopied = false;
static uint32_t featureMaskCopy;
static uint32_t getFeatureMask(void)
{
if (featureMaskIsCopied) {
return featureMaskCopy;
} else {
return featureMask();
}
}
#ifdef USE_SERIAL_4WAY_BLHELI_INTERFACE #ifdef USE_SERIAL_4WAY_BLHELI_INTERFACE
#define ESC_4WAY 0xff #define ESC_4WAY 0xff
@ -531,7 +543,7 @@ static bool mspCommonProcessOutCommand(uint8_t cmdMSP, sbuf_t *dst, mspPostProce
break; break;
case MSP_FEATURE_CONFIG: case MSP_FEATURE_CONFIG:
sbufWriteU32(dst, featureMask()); sbufWriteU32(dst, getFeatureMask());
break; break;
#ifdef USE_BEEPER #ifdef USE_BEEPER
@ -1018,7 +1030,7 @@ static bool mspProcessOutCommand(uint8_t cmdMSP, sbuf_t *dst)
#if defined(USE_ESC_SENSOR) #if defined(USE_ESC_SENSOR)
case MSP_ESC_SENSOR_DATA: case MSP_ESC_SENSOR_DATA:
if (featureConfigured(FEATURE_ESC_SENSOR)) { if (featureIsEnabled(FEATURE_ESC_SENSOR)) {
sbufWriteU8(dst, getMotorCount()); sbufWriteU8(dst, getMotorCount());
for (int i = 0; i < getMotorCount(); i++) { for (int i = 0; i < getMotorCount(); i++) {
const escSensorData_t *escData = getEscSensorData(i); const escSensorData_t *escData = getEscSensorData(i);
@ -1552,7 +1564,11 @@ static mspResult_e mspProcessInCommand(uint8_t cmdMSP, sbuf_t *src)
readEEPROM(); readEEPROM();
break; break;
case MSP_EEPROM_WRITE: case MSP_EEPROM_WRITE:
writeEEPROM(); if (featureMaskIsCopied) {
writeEEPROMWithFeatures(featureMaskCopy);
} else {
writeEEPROM();
}
readEEPROM(); readEEPROM();
break; break;
default: default:
@ -1999,7 +2015,12 @@ static mspResult_e mspProcessInCommand(uint8_t cmdMSP, sbuf_t *src)
if (ARMING_FLAG(ARMED)) { if (ARMING_FLAG(ARMED)) {
return MSP_RESULT_ERROR; return MSP_RESULT_ERROR;
} }
writeEEPROM();
if (featureMaskIsCopied) {
writeEEPROMWithFeatures(featureMaskCopy);
} else {
writeEEPROM();
}
readEEPROM(); readEEPROM();
break; break;
@ -2124,8 +2145,11 @@ static mspResult_e mspProcessInCommand(uint8_t cmdMSP, sbuf_t *src)
break; break;
#endif // USE_GPS #endif // USE_GPS
case MSP_SET_FEATURE_CONFIG: case MSP_SET_FEATURE_CONFIG:
featureClearAll(); featureMaskCopy = sbufReadU32(src);
featureSet(sbufReadU32(src)); // features bitmap if (!featureMaskIsCopied) {
featureMaskIsCopied = true;
}
break; break;
#ifdef USE_BEEPER #ifdef USE_BEEPER

View File

@ -166,11 +166,11 @@ void initActiveBoxIds(void)
#define BME(boxId) do { bitArraySet(&ena, boxId); } while (0) #define BME(boxId) do { bitArraySet(&ena, boxId); } while (0)
BME(BOXARM); BME(BOXARM);
BME(BOXPREARM); BME(BOXPREARM);
if (!featureConfigured(FEATURE_AIRMODE)) { if (!featureIsEnabled(FEATURE_AIRMODE)) {
BME(BOXAIRMODE); BME(BOXAIRMODE);
} }
if (!featureConfigured(FEATURE_ANTI_GRAVITY)) { if (!featureIsEnabled(FEATURE_ANTI_GRAVITY)) {
BME(BOXANTIGRAVITY); BME(BOXANTIGRAVITY);
} }
@ -188,9 +188,9 @@ void initActiveBoxIds(void)
#endif #endif
#ifdef USE_GPS #ifdef USE_GPS
if (featureConfigured(FEATURE_GPS)) { if (featureIsEnabled(FEATURE_GPS)) {
#ifdef USE_GPS_RESCUE #ifdef USE_GPS_RESCUE
if (!featureConfigured(FEATURE_3D)) { if (!featureIsEnabled(FEATURE_3D)) {
BME(BOXGPSRESCUE); BME(BOXGPSRESCUE);
} }
#endif #endif
@ -207,7 +207,7 @@ void initActiveBoxIds(void)
BME(BOXBEEPERON); BME(BOXBEEPERON);
#ifdef USE_LED_STRIP #ifdef USE_LED_STRIP
if (featureConfigured(FEATURE_LED_STRIP)) { if (featureIsEnabled(FEATURE_LED_STRIP)) {
BME(BOXLEDLOW); BME(BOXLEDLOW);
} }
#endif #endif
@ -221,7 +221,7 @@ void initActiveBoxIds(void)
BME(BOXFPVANGLEMIX); BME(BOXFPVANGLEMIX);
if (featureConfigured(FEATURE_3D)) { if (featureIsEnabled(FEATURE_3D)) {
BME(BOX3D); BME(BOX3D);
} }
@ -229,18 +229,18 @@ void initActiveBoxIds(void)
BME(BOXFLIPOVERAFTERCRASH); BME(BOXFLIPOVERAFTERCRASH);
} }
if (featureConfigured(FEATURE_SERVO_TILT)) { if (featureIsEnabled(FEATURE_SERVO_TILT)) {
BME(BOXCAMSTAB); BME(BOXCAMSTAB);
} }
if (featureConfigured(FEATURE_INFLIGHT_ACC_CAL)) { if (featureIsEnabled(FEATURE_INFLIGHT_ACC_CAL)) {
BME(BOXCALIB); BME(BOXCALIB);
} }
BME(BOXOSD); BME(BOXOSD);
#ifdef USE_TELEMETRY #ifdef USE_TELEMETRY
if (featureConfigured(FEATURE_TELEMETRY)) { if (featureIsEnabled(FEATURE_TELEMETRY)) {
BME(BOXTELEMETRY); BME(BOXTELEMETRY);
} }
#endif #endif

View File

@ -384,7 +384,7 @@ void beeperUpdate(timeUs_t currentTimeUs)
if (IS_RC_MODE_ACTIVE(BOXBEEPERON)) { if (IS_RC_MODE_ACTIVE(BOXBEEPERON)) {
beeper(BEEPER_RX_SET); beeper(BEEPER_RX_SET);
#ifdef USE_GPS #ifdef USE_GPS
} else if (featureConfigured(FEATURE_GPS) && IS_RC_MODE_ACTIVE(BOXBEEPGPSCOUNT)) { } else if (featureIsEnabled(FEATURE_GPS) && IS_RC_MODE_ACTIVE(BOXBEEPGPSCOUNT)) {
beeperGpsStatus(); beeperGpsStatus();
#endif #endif
} }

View File

@ -357,7 +357,7 @@ static void showProfilePage(void)
#ifdef USE_GPS #ifdef USE_GPS
static void showGpsPage(void) static void showGpsPage(void)
{ {
if (!featureConfigured(FEATURE_GPS)) { if (!featureIsEnabled(FEATURE_GPS)) {
pageState.pageFlags |= PAGE_STATE_FLAG_FORCE_PAGE_CHANGE; pageState.pageFlags |= PAGE_STATE_FLAG_FORCE_PAGE_CHANGE;
return; return;
} }

View File

@ -1214,7 +1214,7 @@ static void gpsHandlePassthrough(uint8_t data)
{ {
gpsNewData(data); gpsNewData(data);
#ifdef USE_DASHBOARD #ifdef USE_DASHBOARD
if (featureConfigured(FEATURE_DASHBOARD)) { if (featureIsEnabled(FEATURE_DASHBOARD)) {
dashboardUpdate(micros()); dashboardUpdate(micros());
} }
#endif #endif
@ -1230,7 +1230,7 @@ void gpsEnablePassthrough(serialPort_t *gpsPassthroughPort)
serialSetMode(gpsPort, gpsPort->mode | MODE_TX); serialSetMode(gpsPort, gpsPort->mode | MODE_TX);
#ifdef USE_DASHBOARD #ifdef USE_DASHBOARD
if (featureConfigured(FEATURE_DASHBOARD)) { if (featureIsEnabled(FEATURE_DASHBOARD)) {
dashboardShowFixedPage(PAGE_GPS); dashboardShowFixedPage(PAGE_GPS);
} }
#endif #endif

View File

@ -788,7 +788,7 @@ static bool osdDrawSingleElement(uint8_t item)
#ifdef USE_ESC_SENSOR #ifdef USE_ESC_SENSOR
// Show warning if we lose motor output, the ESC is overheating or excessive current draw // Show warning if we lose motor output, the ESC is overheating or excessive current draw
if (featureConfigured(FEATURE_ESC_SENSOR) && osdWarnGetState(OSD_WARNING_ESC_FAIL)) { if (featureIsEnabled(FEATURE_ESC_SENSOR) && osdWarnGetState(OSD_WARNING_ESC_FAIL)) {
char escWarningMsg[OSD_FORMAT_MESSAGE_BUFFER_SIZE]; char escWarningMsg[OSD_FORMAT_MESSAGE_BUFFER_SIZE];
unsigned pos = 0; unsigned pos = 0;
@ -956,13 +956,13 @@ static bool osdDrawSingleElement(uint8_t item)
#ifdef USE_ESC_SENSOR #ifdef USE_ESC_SENSOR
case OSD_ESC_TMP: case OSD_ESC_TMP:
if (featureConfigured(FEATURE_ESC_SENSOR)) { if (featureIsEnabled(FEATURE_ESC_SENSOR)) {
tfp_sprintf(buff, "%3d%c", osdConvertTemperatureToSelectedUnit(escDataCombined->temperature * 10) / 10, osdGetTemperatureSymbolForSelectedUnit()); tfp_sprintf(buff, "%3d%c", osdConvertTemperatureToSelectedUnit(escDataCombined->temperature * 10) / 10, osdGetTemperatureSymbolForSelectedUnit());
} }
break; break;
case OSD_ESC_RPM: case OSD_ESC_RPM:
if (featureConfigured(FEATURE_ESC_SENSOR)) { if (featureIsEnabled(FEATURE_ESC_SENSOR)) {
tfp_sprintf(buff, "%5d", escDataCombined == NULL ? 0 : calcEscRpm(escDataCombined->rpm)); tfp_sprintf(buff, "%5d", escDataCombined == NULL ? 0 : calcEscRpm(escDataCombined->rpm));
} }
break; break;
@ -1040,7 +1040,7 @@ static void osdDrawElements(void)
#endif // GPS #endif // GPS
#ifdef USE_ESC_SENSOR #ifdef USE_ESC_SENSOR
if (featureConfigured(FEATURE_ESC_SENSOR)) { if (featureIsEnabled(FEATURE_ESC_SENSOR)) {
osdDrawSingleElement(OSD_ESC_TMP); osdDrawSingleElement(OSD_ESC_TMP);
osdDrawSingleElement(OSD_ESC_RPM); osdDrawSingleElement(OSD_ESC_RPM);
} }
@ -1226,7 +1226,7 @@ void osdUpdateAlarms(void)
} }
#ifdef USE_ESC_SENSOR #ifdef USE_ESC_SENSOR
if (featureConfigured(FEATURE_ESC_SENSOR)) { if (featureIsEnabled(FEATURE_ESC_SENSOR)) {
// This works because the combined ESC data contains the maximum temperature seen amongst all ESCs // This works because the combined ESC data contains the maximum temperature seen amongst all ESCs
if (osdConfig()->esc_temp_alarm != ESC_TEMP_ALARM_OFF && escDataCombined->temperature >= osdConfig()->esc_temp_alarm) { if (osdConfig()->esc_temp_alarm != ESC_TEMP_ALARM_OFF && escDataCombined->temperature >= osdConfig()->esc_temp_alarm) {
SET_BLINK(OSD_ESC_TMP); SET_BLINK(OSD_ESC_TMP);
@ -1560,7 +1560,7 @@ STATIC_UNIT_TESTED void osdRefresh(timeUs_t currentTimeUs)
blinkState = (currentTimeUs / 200000) % 2; blinkState = (currentTimeUs / 200000) % 2;
#ifdef USE_ESC_SENSOR #ifdef USE_ESC_SENSOR
if (featureConfigured(FEATURE_ESC_SENSOR)) { if (featureIsEnabled(FEATURE_ESC_SENSOR)) {
escDataCombined = getEscSensorData(ESC_SENSOR_COMBINED); escDataCombined = getEscSensorData(ESC_SENSOR_COMBINED);
} }
#endif #endif

View File

@ -72,7 +72,7 @@ bool vtxRTC6705Init(void)
bool vtxRTC6705CanUpdate(void) bool vtxRTC6705CanUpdate(void)
{ {
#if defined(MAX7456_SPI_INSTANCE) && defined(RTC6705_SPI_INSTANCE) && defined(SPI_SHARED_MAX7456_AND_RTC6705) #if defined(MAX7456_SPI_INSTANCE) && defined(RTC6705_SPI_INSTANCE) && defined(SPI_SHARED_MAX7456_AND_RTC6705)
if (featureConfigured(FEATURE_OSD)) { if (featureIsEnabled(FEATURE_OSD)) {
return !max7456DmaInProgress(); return !max7456DmaInProgress();
} }
#endif #endif

View File

@ -233,7 +233,7 @@ void init(void)
adcConfigMutable()->vbat.enabled = (batteryConfig()->voltageMeterSource == VOLTAGE_METER_ADC); adcConfigMutable()->vbat.enabled = (batteryConfig()->voltageMeterSource == VOLTAGE_METER_ADC);
adcConfigMutable()->current.enabled = (batteryConfig()->currentMeterSource == CURRENT_METER_ADC); adcConfigMutable()->current.enabled = (batteryConfig()->currentMeterSource == CURRENT_METER_ADC);
adcConfigMutable()->rssi.enabled = featureConfigured(FEATURE_RSSI_ADC); adcConfigMutable()->rssi.enabled = featureIsEnabled(FEATURE_RSSI_ADC);
adcInit(adcConfig()); adcInit(adcConfig());
#endif #endif
@ -275,7 +275,7 @@ void init(void)
#ifdef USE_LED_STRIP #ifdef USE_LED_STRIP
ledStripInit(); ledStripInit();
if (featureConfigured(FEATURE_LED_STRIP)) { if (featureIsEnabled(FEATURE_LED_STRIP)) {
ledStripEnable(); ledStripEnable();
} }
#endif #endif
@ -285,7 +285,7 @@ void init(void)
#endif #endif
#ifdef USE_TRANSPONDER #ifdef USE_TRANSPONDER
if (featureConfigured(FEATURE_TRANSPONDER)) { if (featureIsEnabled(FEATURE_TRANSPONDER)) {
transponderInit(); transponderInit();
transponderStartRepeating(); transponderStartRepeating();
systemState |= SYSTEM_STATE_TRANSPONDER_ENABLED; systemState |= SYSTEM_STATE_TRANSPONDER_ENABLED;

View File

@ -305,7 +305,7 @@ rx_spi_received_e frSkyDHandlePacket(uint8_t * const packet, uint8_t * const pro
void frSkyDInit(void) void frSkyDInit(void)
{ {
#if defined(USE_RX_FRSKY_SPI_TELEMETRY) && defined(USE_TELEMETRY_FRSKY_HUB) #if defined(USE_RX_FRSKY_SPI_TELEMETRY) && defined(USE_TELEMETRY_FRSKY_HUB)
if (featureConfigured(FEATURE_TELEMETRY)) { if (featureIsEnabled(FEATURE_TELEMETRY)) {
telemetryEnabled = initFrSkyHubTelemetryExternal(frSkyDTelemetryWriteByte); telemetryEnabled = initFrSkyHubTelemetryExternal(frSkyDTelemetryWriteByte);
} }
#endif #endif

View File

@ -543,7 +543,7 @@ rx_spi_received_e frSkyXHandlePacket(uint8_t * const packet, uint8_t * const pro
void frSkyXInit(void) void frSkyXInit(void)
{ {
#if defined(USE_TELEMETRY_SMARTPORT) #if defined(USE_TELEMETRY_SMARTPORT)
if (featureConfigured(FEATURE_TELEMETRY)) { if (featureIsEnabled(FEATURE_TELEMETRY)) {
telemetryEnabled = initSmartPortTelemetryExternal(frSkyXTelemetryWriteFrame); telemetryEnabled = initSmartPortTelemetryExternal(frSkyXTelemetryWriteFrame);
} }
#endif #endif

View File

@ -60,10 +60,10 @@ void rxPwmInit(const rxConfig_t *rxConfig, rxRuntimeConfig_t *rxRuntimeConfig)
rxRuntimeConfig->rxRefreshRate = 20000; rxRuntimeConfig->rxRefreshRate = 20000;
// configure PWM/CPPM read function and max number of channels. serial rx below will override both of these, if enabled // configure PWM/CPPM read function and max number of channels. serial rx below will override both of these, if enabled
if (featureConfigured(FEATURE_RX_PARALLEL_PWM)) { if (featureIsEnabled(FEATURE_RX_PARALLEL_PWM)) {
rxRuntimeConfig->channelCount = MAX_SUPPORTED_RC_PARALLEL_PWM_CHANNEL_COUNT; rxRuntimeConfig->channelCount = MAX_SUPPORTED_RC_PARALLEL_PWM_CHANNEL_COUNT;
rxRuntimeConfig->rcReadRawFn = pwmReadRawRC; rxRuntimeConfig->rcReadRawFn = pwmReadRawRC;
} else if (featureConfigured(FEATURE_RX_PPM)) { } else if (featureIsEnabled(FEATURE_RX_PPM)) {
rxRuntimeConfig->channelCount = MAX_SUPPORTED_RC_PPM_CHANNEL_COUNT; rxRuntimeConfig->channelCount = MAX_SUPPORTED_RC_PPM_CHANNEL_COUNT;
rxRuntimeConfig->rcReadRawFn = ppmReadRawRC; rxRuntimeConfig->rcReadRawFn = ppmReadRawRC;
} }

View File

@ -248,7 +248,7 @@ void rxInit(void)
rcInvalidPulsPeriod[i] = millis() + MAX_INVALID_PULS_TIME; rcInvalidPulsPeriod[i] = millis() + MAX_INVALID_PULS_TIME;
} }
rcData[THROTTLE] = (featureConfigured(FEATURE_3D)) ? rxConfig()->midrc : rxConfig()->rx_min_usec; rcData[THROTTLE] = (featureIsEnabled(FEATURE_3D)) ? rxConfig()->midrc : rxConfig()->rx_min_usec;
// Initialize ARM switch to OFF position when arming via switch is defined // Initialize ARM switch to OFF position when arming via switch is defined
// TODO - move to rc_mode.c // TODO - move to rc_mode.c
@ -268,7 +268,7 @@ void rxInit(void)
} }
#ifdef USE_SERIAL_RX #ifdef USE_SERIAL_RX
if (featureConfigured(FEATURE_RX_SERIAL)) { if (featureIsEnabled(FEATURE_RX_SERIAL)) {
const bool enabled = serialRxInit(rxConfig(), &rxRuntimeConfig); const bool enabled = serialRxInit(rxConfig(), &rxRuntimeConfig);
if (!enabled) { if (!enabled) {
rxRuntimeConfig.rcReadRawFn = nullReadRawRC; rxRuntimeConfig.rcReadRawFn = nullReadRawRC;
@ -278,14 +278,14 @@ void rxInit(void)
#endif #endif
#ifdef USE_RX_MSP #ifdef USE_RX_MSP
if (featureConfigured(FEATURE_RX_MSP)) { if (featureIsEnabled(FEATURE_RX_MSP)) {
rxMspInit(rxConfig(), &rxRuntimeConfig); rxMspInit(rxConfig(), &rxRuntimeConfig);
needRxSignalMaxDelayUs = DELAY_5_HZ; needRxSignalMaxDelayUs = DELAY_5_HZ;
} }
#endif #endif
#ifdef USE_RX_SPI #ifdef USE_RX_SPI
if (featureConfigured(FEATURE_RX_SPI)) { if (featureIsEnabled(FEATURE_RX_SPI)) {
const bool enabled = rxSpiInit(rxSpiConfig(), &rxRuntimeConfig); const bool enabled = rxSpiInit(rxSpiConfig(), &rxRuntimeConfig);
if (!enabled) { if (!enabled) {
rxRuntimeConfig.rcReadRawFn = nullReadRawRC; rxRuntimeConfig.rcReadRawFn = nullReadRawRC;
@ -295,13 +295,13 @@ void rxInit(void)
#endif #endif
#if defined(USE_PWM) || defined(USE_PPM) #if defined(USE_PWM) || defined(USE_PPM)
if (featureConfigured(FEATURE_RX_PPM) || featureConfigured(FEATURE_RX_PARALLEL_PWM)) { if (featureIsEnabled(FEATURE_RX_PPM) || featureIsEnabled(FEATURE_RX_PARALLEL_PWM)) {
rxPwmInit(rxConfig(), &rxRuntimeConfig); rxPwmInit(rxConfig(), &rxRuntimeConfig);
} }
#endif #endif
#if defined(USE_ADC) #if defined(USE_ADC)
if (featureConfigured(FEATURE_RSSI_ADC)) { if (featureIsEnabled(FEATURE_RSSI_ADC)) {
rssiSource = RSSI_SOURCE_ADC; rssiSource = RSSI_SOURCE_ADC;
} else } else
#endif #endif
@ -344,14 +344,14 @@ bool rxUpdateCheck(timeUs_t currentTimeUs, timeDelta_t currentDeltaTime)
bool useDataDrivenProcessing = true; bool useDataDrivenProcessing = true;
#if defined(USE_PWM) || defined(USE_PPM) #if defined(USE_PWM) || defined(USE_PPM)
if (featureConfigured(FEATURE_RX_PPM)) { if (featureIsEnabled(FEATURE_RX_PPM)) {
if (isPPMDataBeingReceived()) { if (isPPMDataBeingReceived()) {
signalReceived = true; signalReceived = true;
rxIsInFailsafeMode = false; rxIsInFailsafeMode = false;
needRxSignalBefore = currentTimeUs + needRxSignalMaxDelayUs; needRxSignalBefore = currentTimeUs + needRxSignalMaxDelayUs;
resetPPMDataReceivedState(); resetPPMDataReceivedState();
} }
} else if (featureConfigured(FEATURE_RX_PARALLEL_PWM)) { } else if (featureIsEnabled(FEATURE_RX_PARALLEL_PWM)) {
if (isPWMDataBeingReceived()) { if (isPWMDataBeingReceived()) {
signalReceived = true; signalReceived = true;
rxIsInFailsafeMode = false; rxIsInFailsafeMode = false;
@ -435,7 +435,7 @@ static uint16_t getRxfailValue(uint8_t channel)
case YAW: case YAW:
return rxConfig()->midrc; return rxConfig()->midrc;
case THROTTLE: case THROTTLE:
if (featureConfigured(FEATURE_3D)) if (featureIsEnabled(FEATURE_3D))
return rxConfig()->midrc; return rxConfig()->midrc;
else else
return rxConfig()->rx_min_usec; return rxConfig()->rx_min_usec;
@ -510,7 +510,7 @@ static void detectAndApplySignalLossBehaviour(void)
} }
} }
} }
if (featureConfigured(FEATURE_RX_PARALLEL_PWM | FEATURE_RX_PPM)) { if (featureIsEnabled(FEATURE_RX_PARALLEL_PWM | FEATURE_RX_PPM)) {
// smooth output for PWM and PPM // smooth output for PWM and PPM
rcData[channel] = calculateChannelMovingAverage(channel, sample); rcData[channel] = calculateChannelMovingAverage(channel, sample);
} else { } else {

View File

@ -238,7 +238,7 @@ void spektrumBind(rxConfig_t *rxConfig)
switch (rxConfig->serialrx_provider) { switch (rxConfig->serialrx_provider) {
case SERIALRX_SRXL: case SERIALRX_SRXL:
#if defined(USE_TELEMETRY) && defined(USE_TELEMETRY_SRXL) #if defined(USE_TELEMETRY) && defined(USE_TELEMETRY_SRXL)
if (featureConfigured(FEATURE_TELEMETRY) && !telemetryCheckRxPortShared(portConfig)) { if (featureIsEnabled(FEATURE_TELEMETRY) && !telemetryCheckRxPortShared(portConfig)) {
bindPin = txPin; bindPin = txPin;
} }
break; break;
@ -322,7 +322,7 @@ bool spektrumInit(const rxConfig_t *rxConfig, rxRuntimeConfig_t *rxRuntimeConfig
switch (rxConfig->serialrx_provider) { switch (rxConfig->serialrx_provider) {
case SERIALRX_SRXL: case SERIALRX_SRXL:
#if defined(USE_TELEMETRY) && defined(USE_TELEMETRY_SRXL) #if defined(USE_TELEMETRY) && defined(USE_TELEMETRY_SRXL)
srxlEnabled = (featureConfigured(FEATURE_TELEMETRY) && !portShared); srxlEnabled = (featureIsEnabled(FEATURE_TELEMETRY) && !portShared);
FALLTHROUGH; FALLTHROUGH;
#endif #endif
case SERIALRX_SPEKTRUM2048: case SERIALRX_SPEKTRUM2048:

View File

@ -528,7 +528,7 @@ void accUpdate(timeUs_t currentTimeUs, rollAndPitchTrims_t *rollAndPitchTrims)
performAcclerationCalibration(rollAndPitchTrims); performAcclerationCalibration(rollAndPitchTrims);
} }
if (featureConfigured(FEATURE_INFLIGHT_ACC_CAL)) { if (featureIsEnabled(FEATURE_INFLIGHT_ACC_CAL)) {
performInflightAccelerationCalibration(rollAndPitchTrims); performInflightAccelerationCalibration(rollAndPitchTrims);
} }

View File

@ -121,7 +121,7 @@ void batteryUpdateVoltage(timeUs_t currentTimeUs)
switch (batteryConfig()->voltageMeterSource) { switch (batteryConfig()->voltageMeterSource) {
#ifdef USE_ESC_SENSOR #ifdef USE_ESC_SENSOR
case VOLTAGE_METER_ESC: case VOLTAGE_METER_ESC:
if (featureConfigured(FEATURE_ESC_SENSOR)) { if (featureIsEnabled(FEATURE_ESC_SENSOR)) {
voltageMeterESCRefresh(); voltageMeterESCRefresh();
voltageMeterESCReadCombined(&voltageMeter); voltageMeterESCReadCombined(&voltageMeter);
} }
@ -399,7 +399,7 @@ void batteryUpdateCurrentMeter(timeUs_t currentTimeUs)
case CURRENT_METER_VIRTUAL: { case CURRENT_METER_VIRTUAL: {
#ifdef USE_VIRTUAL_CURRENT_METER #ifdef USE_VIRTUAL_CURRENT_METER
throttleStatus_e throttleStatus = calculateThrottleStatus(); throttleStatus_e throttleStatus = calculateThrottleStatus();
bool throttleLowAndMotorStop = (throttleStatus == THROTTLE_LOW && featureConfigured(FEATURE_MOTOR_STOP)); bool throttleLowAndMotorStop = (throttleStatus == THROTTLE_LOW && featureIsEnabled(FEATURE_MOTOR_STOP));
int32_t throttleOffset = (int32_t)rcCommand[THROTTLE] - 1000; int32_t throttleOffset = (int32_t)rcCommand[THROTTLE] - 1000;
currentMeterVirtualRefresh(lastUpdateAt, ARMING_FLAG(ARMED), throttleLowAndMotorStop, throttleOffset); currentMeterVirtualRefresh(lastUpdateAt, ARMING_FLAG(ARMED), throttleLowAndMotorStop, throttleOffset);
@ -410,7 +410,7 @@ void batteryUpdateCurrentMeter(timeUs_t currentTimeUs)
case CURRENT_METER_ESC: case CURRENT_METER_ESC:
#ifdef USE_ESC_SENSOR #ifdef USE_ESC_SENSOR
if (featureConfigured(FEATURE_ESC_SENSOR)) { if (featureIsEnabled(FEATURE_ESC_SENSOR)) {
currentMeterESCRefresh(lastUpdateAt); currentMeterESCRefresh(lastUpdateAt);
currentMeterESCReadCombined(&currentMeter); currentMeterESCReadCombined(&currentMeter);
} }

View File

@ -148,7 +148,7 @@ bool isEscSensorActive(void)
escSensorData_t *getEscSensorData(uint8_t motorNumber) escSensorData_t *getEscSensorData(uint8_t motorNumber)
{ {
if (!featureConfigured(FEATURE_ESC_SENSOR)) { if (!featureIsEnabled(FEATURE_ESC_SENSOR)) {
return NULL; return NULL;
} }

View File

@ -744,7 +744,7 @@ static void gyroInitFilterNotch2(gyroSensor_t *gyroSensor, uint16_t notchHz, uin
#ifdef USE_GYRO_DATA_ANALYSE #ifdef USE_GYRO_DATA_ANALYSE
static bool isDynamicFilterActive(void) static bool isDynamicFilterActive(void)
{ {
return featureConfigured(FEATURE_DYNAMIC_FILTER); return featureIsEnabled(FEATURE_DYNAMIC_FILTER);
} }
static void gyroInitFilterDynamicNotch(gyroSensor_t *gyroSensor) static void gyroInitFilterDynamicNotch(gyroSensor_t *gyroSensor)

View File

@ -101,7 +101,7 @@ void targetConfiguration(void)
rxConfigMutable()->serialrx_inverted = true; rxConfigMutable()->serialrx_inverted = true;
serialConfigMutable()->portConfigs[findSerialPortIndexByIdentifier(SERIALRX_UART)].functionMask = FUNCTION_TELEMETRY_FRSKY_HUB | FUNCTION_RX_SERIAL; serialConfigMutable()->portConfigs[findSerialPortIndexByIdentifier(SERIALRX_UART)].functionMask = FUNCTION_TELEMETRY_FRSKY_HUB | FUNCTION_RX_SERIAL;
telemetryConfigMutable()->telemetry_inverted = false; telemetryConfigMutable()->telemetry_inverted = false;
featureSet(FEATURE_TELEMETRY); featureEnable(FEATURE_TELEMETRY);
beeperDevConfigMutable()->isOpenDrain = false; beeperDevConfigMutable()->isOpenDrain = false;
beeperDevConfigMutable()->isInverted = true; beeperDevConfigMutable()->isInverted = true;
parseRcChannels("AETR1234", rxConfigMutable()); parseRcChannels("AETR1234", rxConfigMutable());

View File

@ -73,7 +73,7 @@ void targetConfiguration(void)
telemetryConfigMutable()->telemetry_inverted = false; telemetryConfigMutable()->telemetry_inverted = false;
batteryConfigMutable()->voltageMeterSource = VOLTAGE_METER_ADC; batteryConfigMutable()->voltageMeterSource = VOLTAGE_METER_ADC;
batteryConfigMutable()->currentMeterSource = CURRENT_METER_ADC; batteryConfigMutable()->currentMeterSource = CURRENT_METER_ADC;
featureSet(FEATURE_TELEMETRY); featureEnable(FEATURE_TELEMETRY);
} }
for (uint8_t pidProfileIndex = 0; pidProfileIndex < MAX_PROFILE_COUNT; pidProfileIndex++) { for (uint8_t pidProfileIndex = 0; pidProfileIndex < MAX_PROFILE_COUNT; pidProfileIndex++) {

View File

@ -72,7 +72,7 @@ void targetConfiguration(void)
telemetryConfigMutable()->telemetry_inverted = false; telemetryConfigMutable()->telemetry_inverted = false;
batteryConfigMutable()->voltageMeterSource = VOLTAGE_METER_ADC; batteryConfigMutable()->voltageMeterSource = VOLTAGE_METER_ADC;
batteryConfigMutable()->currentMeterSource = CURRENT_METER_ADC; batteryConfigMutable()->currentMeterSource = CURRENT_METER_ADC;
featureSet(FEATURE_TELEMETRY); featureEnable(FEATURE_TELEMETRY);
} }
for (uint8_t pidProfileIndex = 0; pidProfileIndex < MAX_PROFILE_COUNT; pidProfileIndex++) { for (uint8_t pidProfileIndex = 0; pidProfileIndex < MAX_PROFILE_COUNT; pidProfileIndex++) {

View File

@ -113,7 +113,7 @@ void targetConfiguration(void)
pidConfigMutable()->runaway_takeoff_prevention = false; pidConfigMutable()->runaway_takeoff_prevention = false;
featureSet((FEATURE_DYNAMIC_FILTER | FEATURE_AIRMODE | FEATURE_ANTI_GRAVITY) ^ FEATURE_RX_PARALLEL_PWM); featureEnable((FEATURE_DYNAMIC_FILTER | FEATURE_AIRMODE | FEATURE_ANTI_GRAVITY) ^ FEATURE_RX_PARALLEL_PWM);
/* AlienWhoop PIDs tested with 6mm and 7mm motors on most frames */ /* AlienWhoop PIDs tested with 6mm and 7mm motors on most frames */
for (uint8_t pidProfileIndex = 0; pidProfileIndex < MAX_PROFILE_COUNT; pidProfileIndex++) { for (uint8_t pidProfileIndex = 0; pidProfileIndex < MAX_PROFILE_COUNT; pidProfileIndex++) {

View File

@ -56,7 +56,7 @@ void targetPreInit(void)
serialPortConfig_t *portConfig = serialFindPortConfiguration(SERIAL_PORT_USART1); serialPortConfig_t *portConfig = serialFindPortConfiguration(SERIAL_PORT_USART1);
if (portConfig) { if (portConfig) {
bool smartportEnabled = (portConfig->functionMask & FUNCTION_TELEMETRY_SMARTPORT); bool smartportEnabled = (portConfig->functionMask & FUNCTION_TELEMETRY_SMARTPORT);
if (smartportEnabled && (!telemetryConfig()->telemetry_inverted) && (featureConfigured(FEATURE_TELEMETRY))) { if (smartportEnabled && (!telemetryConfig()->telemetry_inverted) && (featureIsEnabled(FEATURE_TELEMETRY))) {
high = true; high = true;
} }
} }

View File

@ -558,10 +558,10 @@ static bool bstSlaveProcessWriteCommand(uint8_t bstWriteCommand)
readEEPROM(); readEEPROM();
break; break;
case BST_SET_FEATURE: case BST_SET_FEATURE:
featureClearAll(); featureDisableAll();
featureSet(bstRead32()); // features bitmap featureEnable(bstRead32()); // features bitmap
#ifdef SERIALRX_UART #ifdef SERIALRX_UART
if (featureConfigured(FEATURE_RX_SERIAL)) { if (featureIsEnabled(FEATURE_RX_SERIAL)) {
serialConfigMutable()->portConfigs[SERIALRX_UART].functionMask = FUNCTION_RX_SERIAL; serialConfigMutable()->portConfigs[SERIALRX_UART].functionMask = FUNCTION_RX_SERIAL;
} else { } else {
serialConfigMutable()->portConfigs[SERIALRX_UART].functionMask = FUNCTION_NONE; serialConfigMutable()->portConfigs[SERIALRX_UART].functionMask = FUNCTION_NONE;

View File

@ -35,7 +35,7 @@
void targetConfiguration(void) void targetConfiguration(void)
{ {
if (hardwareRevision >= FORTINIF4_REV_2) { if (hardwareRevision >= FORTINIF4_REV_2) {
featureSet(FEATURE_OSD); featureEnable(FEATURE_OSD);
} }
telemetryConfigMutable()->halfDuplex = false; telemetryConfigMutable()->halfDuplex = false;

View File

@ -65,7 +65,7 @@ void targetConfiguration(void)
#else #else
serialConfigMutable()->portConfigs[findSerialPortIndexByIdentifier(SERIAL_PORT_USART2)].functionMask = FUNCTION_TELEMETRY_FRSKY_HUB; serialConfigMutable()->portConfigs[findSerialPortIndexByIdentifier(SERIAL_PORT_USART2)].functionMask = FUNCTION_TELEMETRY_FRSKY_HUB;
rxConfigMutable()->serialrx_inverted = true; rxConfigMutable()->serialrx_inverted = true;
featureSet(FEATURE_TELEMETRY); featureEnable(FEATURE_TELEMETRY);
#endif #endif
parseRcChannels("TAER1234", rxConfigMutable()); parseRcChannels("TAER1234", rxConfigMutable());

View File

@ -436,7 +436,7 @@ void pwmCompleteMotorUpdate(uint8_t motorCount) {
// for gazebo8 ArduCopterPlugin remap, normal range = [0.0, 1.0], 3D rang = [-1.0, 1.0] // for gazebo8 ArduCopterPlugin remap, normal range = [0.0, 1.0], 3D rang = [-1.0, 1.0]
double outScale = 1000.0; double outScale = 1000.0;
if (featureConfigured(FEATURE_3D)) { if (featureIsEnabled(FEATURE_3D)) {
outScale = 500.0; outScale = 500.0;
} }

View File

@ -445,7 +445,7 @@ void initCrsfTelemetry(void)
crsfSchedule[index++] = BV(CRSF_FRAME_BATTERY_SENSOR_INDEX); crsfSchedule[index++] = BV(CRSF_FRAME_BATTERY_SENSOR_INDEX);
} }
crsfSchedule[index++] = BV(CRSF_FRAME_FLIGHT_MODE_INDEX); crsfSchedule[index++] = BV(CRSF_FRAME_FLIGHT_MODE_INDEX);
if (featureConfigured(FEATURE_GPS)) { if (featureIsEnabled(FEATURE_GPS)) {
crsfSchedule[index++] = BV(CRSF_FRAME_GPS_INDEX); crsfSchedule[index++] = BV(CRSF_FRAME_GPS_INDEX);
} }
crsfScheduleCount = (uint8_t)index; crsfScheduleCount = (uint8_t)index;

View File

@ -193,7 +193,7 @@ static void sendThrottleOrBatterySizeAsRpm(void)
if (ARMING_FLAG(ARMED)) { if (ARMING_FLAG(ARMED)) {
const throttleStatus_e throttleStatus = calculateThrottleStatus(); const throttleStatus_e throttleStatus = calculateThrottleStatus();
uint16_t throttleForRPM = rcCommand[THROTTLE] / BLADE_NUMBER_DIVIDER; uint16_t throttleForRPM = rcCommand[THROTTLE] / BLADE_NUMBER_DIVIDER;
if (throttleStatus == THROTTLE_LOW && featureConfigured(FEATURE_MOTOR_STOP)) { if (throttleStatus == THROTTLE_LOW && featureIsEnabled(FEATURE_MOTOR_STOP)) {
throttleForRPM = 0; throttleForRPM = 0;
} }
data = throttleForRPM; data = throttleForRPM;

View File

@ -228,7 +228,7 @@ static uint16_t getRPM()
if (ARMING_FLAG(ARMED)) { if (ARMING_FLAG(ARMED)) {
const throttleStatus_e throttleStatus = calculateThrottleStatus(); const throttleStatus_e throttleStatus = calculateThrottleStatus();
rpm = rcCommand[THROTTLE]; // / BLADE_NUMBER_DIVIDER; rpm = rcCommand[THROTTLE]; // / BLADE_NUMBER_DIVIDER;
if (throttleStatus == THROTTLE_LOW && featureConfigured(FEATURE_MOTOR_STOP)) rpm = 0; if (throttleStatus == THROTTLE_LOW && featureIsEnabled(FEATURE_MOTOR_STOP)) rpm = 0;
} else { } else {
rpm = (uint16_t)(batteryConfig()->batteryCapacity); // / BLADE_NUMBER_DIVIDER rpm = (uint16_t)(batteryConfig()->batteryCapacity); // / BLADE_NUMBER_DIVIDER
} }

View File

@ -318,7 +318,7 @@ static void smartPortSendPackage(uint16_t id, uint32_t val)
} }
static bool reportExtendedEscSensors(void) { static bool reportExtendedEscSensors(void) {
return featureConfigured(FEATURE_ESC_SENSOR) && telemetryConfig()->smartport_use_extra_sensors; return featureIsEnabled(FEATURE_ESC_SENSOR) && telemetryConfig()->smartport_use_extra_sensors;
} }
#define ADD_SENSOR(dataId) frSkyDataIdTableInfo.table[frSkyDataIdTableInfo.index++] = dataId #define ADD_SENSOR(dataId) frSkyDataIdTableInfo.table[frSkyDataIdTableInfo.index++] = dataId
@ -332,7 +332,7 @@ static void initSmartPortSensors(void)
if (isBatteryVoltageConfigured()) { if (isBatteryVoltageConfigured()) {
#ifdef USE_ESC_SENSOR #ifdef USE_ESC_SENSOR
if (!featureConfigured(FEATURE_ESC_SENSOR)) { if (!featureIsEnabled(FEATURE_ESC_SENSOR)) {
#endif #endif
{ {
ADD_SENSOR(FSSP_DATAID_VFAS); ADD_SENSOR(FSSP_DATAID_VFAS);
@ -365,7 +365,7 @@ static void initSmartPortSensors(void)
} }
#ifdef USE_GPS #ifdef USE_GPS
if (featureConfigured(FEATURE_GPS)) { if (featureIsEnabled(FEATURE_GPS)) {
ADD_SENSOR(FSSP_DATAID_SPEED); ADD_SENSOR(FSSP_DATAID_SPEED);
ADD_SENSOR(FSSP_DATAID_LATLONG); ADD_SENSOR(FSSP_DATAID_LATLONG);
ADD_SENSOR(FSSP_DATAID_LATLONG); // twice (one for lat, one for long) ADD_SENSOR(FSSP_DATAID_LATLONG); // twice (one for lat, one for long)
@ -719,7 +719,7 @@ void processSmartPortTelemetry(smartPortPayload_t *payload, volatile bool *clear
// provide GPS lock status // provide GPS lock status
smartPortSendPackage(id, (STATE(GPS_FIX) ? 1000 : 0) + (STATE(GPS_FIX_HOME) ? 2000 : 0) + gpsSol.numSat); smartPortSendPackage(id, (STATE(GPS_FIX) ? 1000 : 0) + (STATE(GPS_FIX_HOME) ? 2000 : 0) + gpsSol.numSat);
*clearToSend = false; *clearToSend = false;
} else if (featureConfigured(FEATURE_GPS)) { } else if (featureIsEnabled(FEATURE_GPS)) {
smartPortSendPackage(id, 0); smartPortSendPackage(id, 0);
*clearToSend = false; *clearToSend = false;
} else } else

View File

@ -793,7 +793,7 @@ extern "C" {
uint32_t millis(void) { return micros() / 1000; } uint32_t millis(void) { return micros() / 1000; }
bool rxIsReceivingSignal(void) { return simulationHaveRx; } bool rxIsReceivingSignal(void) { return simulationHaveRx; }
bool featureConfigured(uint32_t f) { return simulationFeatureFlags & f; } bool featureIsEnabled(uint32_t f) { return simulationFeatureFlags & f; }
void warningLedFlash(void) {} void warningLedFlash(void) {}
void warningLedDisable(void) {} void warningLedDisable(void) {}
void warningLedUpdate(void) {} void warningLedUpdate(void) {}

View File

@ -273,7 +273,7 @@ uint8_t armingFlags = 0;
float rcCommand[4] = {0,0,0,0}; float rcCommand[4] = {0,0,0,0};
bool featureConfigured(uint32_t mask) bool featureIsEnabled(uint32_t mask)
{ {
UNUSED(mask); UNUSED(mask);
return false; return false;

View File

@ -388,7 +388,7 @@ bool sensors(uint32_t) {return false;}
void serialWrite(serialPort_t *, uint8_t) {} void serialWrite(serialPort_t *, uint8_t) {}
uint32_t serialTxBytesFree(const serialPort_t *) {return 0;} uint32_t serialTxBytesFree(const serialPort_t *) {return 0;}
bool isSerialTransmitBufferEmpty(const serialPort_t *) {return false;} bool isSerialTransmitBufferEmpty(const serialPort_t *) {return false;}
bool featureConfigured(uint32_t) {return false;} bool featureIsEnabled(uint32_t) {return false;}
void mspSerialReleasePortIfAllocated(serialPort_t *) {} void mspSerialReleasePortIfAllocated(serialPort_t *) {}
serialPortConfig_t *findSerialPortConfig(serialPortFunction_e ) {return NULL;} serialPortConfig_t *findSerialPortConfig(serialPortFunction_e ) {return NULL;}
serialPort_t *findSharedSerialPort(uint16_t , serialPortFunction_e ) {return NULL;} serialPort_t *findSharedSerialPort(uint16_t , serialPortFunction_e ) {return NULL;}

View File

@ -567,7 +567,7 @@ throttleStatus_e calculateThrottleStatus()
void delay(uint32_t) {} void delay(uint32_t) {}
bool featureConfigured(uint32_t mask) { bool featureIsEnabled(uint32_t mask) {
return (mask & testFeatureMask); return (mask & testFeatureMask);
} }

View File

@ -392,7 +392,7 @@ uint8_t armingFlags;
void delay(uint32_t) {} void delay(uint32_t) {}
bool featureConfigured(uint32_t mask) { bool featureIsEnabled(uint32_t mask) {
return (mask & testFeatureMask); return (mask & testFeatureMask);
} }

View File

@ -352,7 +352,7 @@ void delay(uint32_t ms)
uint32_t micros(void) { return 0; } uint32_t micros(void) { return 0; }
bool shouldSoundBatteryAlarm(void) { return false; } bool shouldSoundBatteryAlarm(void) { return false; }
bool featureConfigured(uint32_t mask) { bool featureIsEnabled(uint32_t mask) {
UNUSED(mask); UNUSED(mask);
return false; return false;
} }

View File

@ -709,7 +709,7 @@ void gyroStartCalibration(bool isFirstArmingCalibration)
} }
void applyAndSaveAccelerometerTrimsDelta(rollAndPitchTrims_t*) {} void applyAndSaveAccelerometerTrimsDelta(rollAndPitchTrims_t*) {}
void handleInflightCalibrationStickPosition(void) {} void handleInflightCalibrationStickPosition(void) {}
bool featureConfigured(uint32_t) { return false;} bool featureIsEnabled(uint32_t) { return false;}
bool sensors(uint32_t) { return false;} bool sensors(uint32_t) { return false;}
void tryArm(void) {} void tryArm(void) {}
void disarm(void) {} void disarm(void) {}

View File

@ -845,7 +845,7 @@ extern "C" {
sbufWriteU8(dst, (uint8_t)val); sbufWriteU8(dst, (uint8_t)val);
} }
bool featureConfigured(uint32_t) { return false; } bool featureIsEnabled(uint32_t) { return false; }
void serialWriteBuf(serialPort_t *instance, const uint8_t *data, int count) void serialWriteBuf(serialPort_t *instance, const uint8_t *data, int count)
{ {

View File

@ -186,11 +186,11 @@ bool rxMspInit(rxConfig_t *rxConfig, rxRuntimeConfig_t *rxRuntimeConfig, rcReadR
return true; return true;
} }
bool featureConfigured(uint32_t) { bool featureIsEnabled(uint32_t) {
return false; return false;
} }
void featureClear(uint32_t) { void featureDisable(uint32_t) {
} }
bool rxMspFrameComplete(void) bool rxMspFrameComplete(void)

View File

@ -293,7 +293,7 @@ void beeperConfirmationBeeps(uint8_t beepCount) {UNUSED(beepCount);}
uint32_t micros(void) {return 0;} uint32_t micros(void) {return 0;}
bool featureConfigured(uint32_t) {return true;} bool featureIsEnabled(uint32_t) {return true;}
uint32_t serialRxBytesWaiting(const serialPort_t *) {return 0;} uint32_t serialRxBytesWaiting(const serialPort_t *) {return 0;}
uint32_t serialTxBytesFree(const serialPort_t *) {return 0;} uint32_t serialTxBytesFree(const serialPort_t *) {return 0;}

View File

@ -108,7 +108,7 @@ throttleStatus_e calculateThrottleStatus(void)
return throttleStatus; return throttleStatus;
} }
bool featureConfigured(uint32_t mask) bool featureIsEnabled(uint32_t mask)
{ {
return (definedFeatures & mask) != 0; return (definedFeatures & mask) != 0;
} }