mirror of
https://github.com/iNavFlight/inav.git
synced 2025-07-15 12:25:17 +03:00
Split features into feature.c (#572)
This commit is contained in:
parent
7af0bfb47d
commit
dafa38c61a
24 changed files with 161 additions and 47 deletions
1
Makefile
1
Makefile
|
@ -371,6 +371,7 @@ COMMON_SRC = \
|
||||||
common/typeconversion.c \
|
common/typeconversion.c \
|
||||||
common/streambuf.c \
|
common/streambuf.c \
|
||||||
config/config.c \
|
config/config.c \
|
||||||
|
config/feature.c \
|
||||||
fc/runtime_config.c \
|
fc/runtime_config.c \
|
||||||
drivers/logging.c \
|
drivers/logging.c \
|
||||||
drivers/adc.c \
|
drivers/adc.c \
|
||||||
|
|
|
@ -77,6 +77,7 @@
|
||||||
#include "config/config.h"
|
#include "config/config.h"
|
||||||
#include "config/config_profile.h"
|
#include "config/config_profile.h"
|
||||||
#include "config/config_master.h"
|
#include "config/config_master.h"
|
||||||
|
#include "config/feature.h"
|
||||||
|
|
||||||
#include "blackbox.h"
|
#include "blackbox.h"
|
||||||
#include "blackbox_io.h"
|
#include "blackbox_io.h"
|
||||||
|
|
|
@ -72,9 +72,9 @@
|
||||||
#include "fc/runtime_config.h"
|
#include "fc/runtime_config.h"
|
||||||
|
|
||||||
#include "config/config.h"
|
#include "config/config.h"
|
||||||
|
|
||||||
#include "config/config_profile.h"
|
#include "config/config_profile.h"
|
||||||
#include "config/config_master.h"
|
#include "config/config_master.h"
|
||||||
|
#include "config/feature.h"
|
||||||
|
|
||||||
#ifndef DEFAULT_RX_FEATURE
|
#ifndef DEFAULT_RX_FEATURE
|
||||||
#define DEFAULT_RX_FEATURE FEATURE_RX_PARALLEL_PWM
|
#define DEFAULT_RX_FEATURE FEATURE_RX_PARALLEL_PWM
|
||||||
|
@ -167,7 +167,6 @@ size_t custom_flash_memory_address = 0;
|
||||||
|
|
||||||
master_t masterConfig; // master config struct with data independent from profiles
|
master_t masterConfig; // master config struct with data independent from profiles
|
||||||
profile_t *currentProfile;
|
profile_t *currentProfile;
|
||||||
static uint32_t activeFeaturesLatch = 0;
|
|
||||||
|
|
||||||
static uint8_t currentControlRateProfileIndex = 0;
|
static uint8_t currentControlRateProfileIndex = 0;
|
||||||
controlRateConfig_t *currentControlRateProfile;
|
controlRateConfig_t *currentControlRateProfile;
|
||||||
|
@ -1168,41 +1167,6 @@ void handleOneshotFeatureChangeOnRestart(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void latchActiveFeatures()
|
|
||||||
{
|
|
||||||
activeFeaturesLatch = masterConfig.enabledFeatures;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool featureConfigured(uint32_t mask)
|
|
||||||
{
|
|
||||||
return masterConfig.enabledFeatures & mask;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool feature(uint32_t mask)
|
|
||||||
{
|
|
||||||
return activeFeaturesLatch & mask;
|
|
||||||
}
|
|
||||||
|
|
||||||
void featureSet(uint32_t mask)
|
|
||||||
{
|
|
||||||
masterConfig.enabledFeatures |= mask;
|
|
||||||
}
|
|
||||||
|
|
||||||
void featureClear(uint32_t mask)
|
|
||||||
{
|
|
||||||
masterConfig.enabledFeatures &= ~(mask);
|
|
||||||
}
|
|
||||||
|
|
||||||
void featureClearAll()
|
|
||||||
{
|
|
||||||
masterConfig.enabledFeatures = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t featureMask(void)
|
|
||||||
{
|
|
||||||
return masterConfig.enabledFeatures;
|
|
||||||
}
|
|
||||||
|
|
||||||
void persistentFlagClearAll()
|
void persistentFlagClearAll()
|
||||||
{
|
{
|
||||||
masterConfig.persistentFlags = 0;
|
masterConfig.persistentFlags = 0;
|
||||||
|
|
|
@ -57,13 +57,6 @@ typedef enum {
|
||||||
} persistent_flags_e;
|
} persistent_flags_e;
|
||||||
|
|
||||||
void handleOneshotFeatureChangeOnRestart(void);
|
void handleOneshotFeatureChangeOnRestart(void);
|
||||||
void latchActiveFeatures(void);
|
|
||||||
bool featureConfigured(uint32_t mask);
|
|
||||||
bool feature(uint32_t mask);
|
|
||||||
void featureSet(uint32_t mask);
|
|
||||||
void featureClear(uint32_t mask);
|
|
||||||
void featureClearAll(void);
|
|
||||||
uint32_t featureMask(void);
|
|
||||||
void beeperOffSet(uint32_t mask);
|
void beeperOffSet(uint32_t mask);
|
||||||
void beeperOffSetAll(uint8_t beeperCount);
|
void beeperOffSetAll(uint8_t beeperCount);
|
||||||
void beeperOffClear(uint32_t mask);
|
void beeperOffClear(uint32_t mask);
|
||||||
|
|
110
src/main/config/feature.c
Executable file
110
src/main/config/feature.c
Executable file
|
@ -0,0 +1,110 @@
|
||||||
|
/*
|
||||||
|
* This file is part of Cleanflight.
|
||||||
|
*
|
||||||
|
* Cleanflight is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Cleanflight is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "platform.h"
|
||||||
|
|
||||||
|
#include "common/axis.h"
|
||||||
|
#include "common/color.h"
|
||||||
|
#include "common/maths.h"
|
||||||
|
|
||||||
|
#include "drivers/sensor.h"
|
||||||
|
#include "drivers/accgyro.h"
|
||||||
|
#include "drivers/compass.h"
|
||||||
|
#include "drivers/system.h"
|
||||||
|
#include "drivers/gpio.h"
|
||||||
|
#include "drivers/timer.h"
|
||||||
|
#include "drivers/pwm_rx.h"
|
||||||
|
#include "drivers/rx_nrf24l01.h"
|
||||||
|
#include "drivers/serial.h"
|
||||||
|
|
||||||
|
#include "sensors/sensors.h"
|
||||||
|
#include "sensors/gyro.h"
|
||||||
|
#include "sensors/compass.h"
|
||||||
|
#include "sensors/acceleration.h"
|
||||||
|
#include "sensors/barometer.h"
|
||||||
|
#include "sensors/boardalignment.h"
|
||||||
|
#include "sensors/battery.h"
|
||||||
|
|
||||||
|
#include "io/beeper.h"
|
||||||
|
#include "io/serial.h"
|
||||||
|
#include "io/gimbal.h"
|
||||||
|
#include "io/escservo.h"
|
||||||
|
#include "fc/rc_controls.h"
|
||||||
|
#include "fc/rc_curves.h"
|
||||||
|
#include "io/ledstrip.h"
|
||||||
|
#include "io/gps.h"
|
||||||
|
|
||||||
|
#include "rx/rx.h"
|
||||||
|
#include "rx/nrf24.h"
|
||||||
|
|
||||||
|
#include "blackbox/blackbox_io.h"
|
||||||
|
|
||||||
|
#include "telemetry/telemetry.h"
|
||||||
|
|
||||||
|
#include "flight/mixer.h"
|
||||||
|
#include "flight/pid.h"
|
||||||
|
#include "flight/imu.h"
|
||||||
|
#include "flight/failsafe.h"
|
||||||
|
#include "flight/navigation_rewrite.h"
|
||||||
|
|
||||||
|
#include "fc/runtime_config.h"
|
||||||
|
|
||||||
|
#include "config/config.h"
|
||||||
|
|
||||||
|
#include "config/config_profile.h"
|
||||||
|
#include "config/config_master.h"
|
||||||
|
|
||||||
|
static uint32_t activeFeaturesLatch = 0;
|
||||||
|
|
||||||
|
void latchActiveFeatures()
|
||||||
|
{
|
||||||
|
activeFeaturesLatch = masterConfig.enabledFeatures;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool featureConfigured(uint32_t mask)
|
||||||
|
{
|
||||||
|
return masterConfig.enabledFeatures & mask;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool feature(uint32_t mask)
|
||||||
|
{
|
||||||
|
return activeFeaturesLatch & mask;
|
||||||
|
}
|
||||||
|
|
||||||
|
void featureSet(uint32_t mask)
|
||||||
|
{
|
||||||
|
masterConfig.enabledFeatures |= mask;
|
||||||
|
}
|
||||||
|
|
||||||
|
void featureClear(uint32_t mask)
|
||||||
|
{
|
||||||
|
masterConfig.enabledFeatures &= ~(mask);
|
||||||
|
}
|
||||||
|
|
||||||
|
void featureClearAll()
|
||||||
|
{
|
||||||
|
masterConfig.enabledFeatures = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t featureMask(void)
|
||||||
|
{
|
||||||
|
return masterConfig.enabledFeatures;
|
||||||
|
}
|
26
src/main/config/feature.h
Normal file
26
src/main/config/feature.h
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
/*
|
||||||
|
* This file is part of Cleanflight.
|
||||||
|
*
|
||||||
|
* Cleanflight is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Cleanflight is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
void latchActiveFeatures(void);
|
||||||
|
bool featureConfigured(uint32_t mask);
|
||||||
|
bool feature(uint32_t mask);
|
||||||
|
void featureSet(uint32_t mask);
|
||||||
|
void featureClear(uint32_t mask);
|
||||||
|
void featureClearAll(void);
|
||||||
|
uint32_t featureMask(void);
|
|
@ -86,6 +86,7 @@
|
||||||
#include "config/config.h"
|
#include "config/config.h"
|
||||||
#include "config/config_profile.h"
|
#include "config/config_profile.h"
|
||||||
#include "config/config_master.h"
|
#include "config/config_master.h"
|
||||||
|
#include "config/feature.h"
|
||||||
|
|
||||||
// June 2013 V2.2-dev
|
// June 2013 V2.2-dev
|
||||||
|
|
||||||
|
|
|
@ -55,6 +55,7 @@
|
||||||
#include "flight/failsafe.h"
|
#include "flight/failsafe.h"
|
||||||
|
|
||||||
#include "config/config.h"
|
#include "config/config.h"
|
||||||
|
#include "config/feature.h"
|
||||||
|
|
||||||
#include "blackbox/blackbox.h"
|
#include "blackbox/blackbox.h"
|
||||||
|
|
||||||
|
|
|
@ -59,6 +59,7 @@
|
||||||
|
|
||||||
#include "config/config.h"
|
#include "config/config.h"
|
||||||
#include "config/config_profile.h"
|
#include "config/config_profile.h"
|
||||||
|
#include "config/feature.h"
|
||||||
|
|
||||||
//#define MIXER_DEBUG
|
//#define MIXER_DEBUG
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,7 @@
|
||||||
#include "fc/runtime_config.h"
|
#include "fc/runtime_config.h"
|
||||||
|
|
||||||
#include "config/config.h"
|
#include "config/config.h"
|
||||||
|
#include "config/feature.h"
|
||||||
|
|
||||||
#include "io/beeper.h"
|
#include "io/beeper.h"
|
||||||
|
|
||||||
|
|
|
@ -64,6 +64,7 @@
|
||||||
|
|
||||||
|
|
||||||
#include "config/config.h"
|
#include "config/config.h"
|
||||||
|
#include "config/feature.h"
|
||||||
|
|
||||||
#include "display.h"
|
#include "display.h"
|
||||||
|
|
||||||
|
|
|
@ -52,6 +52,8 @@
|
||||||
#include "flight/navigation_rewrite.h"
|
#include "flight/navigation_rewrite.h"
|
||||||
|
|
||||||
#include "config/config.h"
|
#include "config/config.h"
|
||||||
|
#include "config/feature.h"
|
||||||
|
|
||||||
#include "fc/runtime_config.h"
|
#include "fc/runtime_config.h"
|
||||||
|
|
||||||
// GPS timeout for wrong baud rate/disconnection/etc in milliseconds (default 2000 ms)
|
// GPS timeout for wrong baud rate/disconnection/etc in milliseconds (default 2000 ms)
|
||||||
|
|
|
@ -75,6 +75,7 @@
|
||||||
#include "config/config.h"
|
#include "config/config.h"
|
||||||
#include "config/config_profile.h"
|
#include "config/config_profile.h"
|
||||||
#include "config/config_master.h"
|
#include "config/config_master.h"
|
||||||
|
#include "config/feature.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
PG_REGISTER_ARR_WITH_RESET_FN(ledConfig_t, LED_MAX_STRIP_LENGTH, ledConfigs, PG_LED_STRIP_CONFIG, 0);
|
PG_REGISTER_ARR_WITH_RESET_FN(ledConfig_t, LED_MAX_STRIP_LENGTH, ledConfigs, PG_LED_STRIP_CONFIG, 0);
|
||||||
|
|
|
@ -134,7 +134,8 @@ typedef struct ledCounts_s {
|
||||||
|
|
||||||
|
|
||||||
ledConfig_t *ledConfigs;
|
ledConfig_t *ledConfigs;
|
||||||
hsvColor_t *colors;
|
struct hsvColor_s;
|
||||||
|
struct hsvColor_s *colors;
|
||||||
modeColorIndexes_t *modeColors;
|
modeColorIndexes_t *modeColors;
|
||||||
specialColorIndexes_t specialColors;
|
specialColorIndexes_t specialColors;
|
||||||
|
|
||||||
|
@ -163,7 +164,7 @@ bool parseLedStripConfig(int ledIndex, const char *config);
|
||||||
void generateLedConfig(ledConfig_t *ledConfig, char *ledConfigBuffer, size_t bufferSize);
|
void generateLedConfig(ledConfig_t *ledConfig, char *ledConfigBuffer, size_t bufferSize);
|
||||||
void reevaluateLedConfig(void);
|
void reevaluateLedConfig(void);
|
||||||
|
|
||||||
void ledStripInit(ledConfig_t *ledConfigsToUse, hsvColor_t *colorsToUse, modeColorIndexes_t *modeColorsToUse, specialColorIndexes_t *specialColorsToUse);
|
void ledStripInit(ledConfig_t *ledConfigsToUse, struct hsvColor_s *colorsToUse, modeColorIndexes_t *modeColorsToUse, specialColorIndexes_t *specialColorsToUse);
|
||||||
void ledStripEnable(void);
|
void ledStripEnable(void);
|
||||||
void updateLedStrip(void);
|
void updateLedStrip(void);
|
||||||
|
|
||||||
|
@ -173,7 +174,7 @@ extern uint16_t rssi; // FIXME dependency on mw.c
|
||||||
|
|
||||||
|
|
||||||
void applyDefaultLedStripConfig(ledConfig_t *ledConfig);
|
void applyDefaultLedStripConfig(ledConfig_t *ledConfig);
|
||||||
void applyDefaultColors(hsvColor_t *colors);
|
void applyDefaultColors(struct hsvColor_s *colors);
|
||||||
void applyDefaultModeColors(modeColorIndexes_t *modeColors);
|
void applyDefaultModeColors(modeColorIndexes_t *modeColors);
|
||||||
void applyDefaultSpecialColors(specialColorIndexes_t *specialColors);
|
void applyDefaultSpecialColors(specialColorIndexes_t *specialColors);
|
||||||
|
|
||||||
|
|
|
@ -91,6 +91,7 @@
|
||||||
#include "config/config.h"
|
#include "config/config.h"
|
||||||
#include "config/config_profile.h"
|
#include "config/config_profile.h"
|
||||||
#include "config/config_master.h"
|
#include "config/config_master.h"
|
||||||
|
#include "config/feature.h"
|
||||||
|
|
||||||
#include "common/printf.h"
|
#include "common/printf.h"
|
||||||
|
|
||||||
|
|
|
@ -88,6 +88,7 @@
|
||||||
#include "config/config.h"
|
#include "config/config.h"
|
||||||
#include "config/config_profile.h"
|
#include "config/config_profile.h"
|
||||||
#include "config/config_master.h"
|
#include "config/config_master.h"
|
||||||
|
#include "config/feature.h"
|
||||||
|
|
||||||
#include "blackbox/blackbox.h"
|
#include "blackbox/blackbox.h"
|
||||||
|
|
||||||
|
|
|
@ -106,6 +106,7 @@
|
||||||
#include "config/config.h"
|
#include "config/config.h"
|
||||||
#include "config/config_profile.h"
|
#include "config/config_profile.h"
|
||||||
#include "config/config_master.h"
|
#include "config/config_master.h"
|
||||||
|
#include "config/feature.h"
|
||||||
|
|
||||||
#ifdef USE_HARDWARE_REVISION_DETECTION
|
#ifdef USE_HARDWARE_REVISION_DETECTION
|
||||||
#include "hardware_revision.h"
|
#include "hardware_revision.h"
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
#include "drivers/pwm_rx.h"
|
#include "drivers/pwm_rx.h"
|
||||||
|
|
||||||
#include "config/config.h"
|
#include "config/config.h"
|
||||||
|
#include "config/feature.h"
|
||||||
|
|
||||||
#include "rx/rx.h"
|
#include "rx/rx.h"
|
||||||
#include "rx/pwm.h"
|
#include "rx/pwm.h"
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
#include "common/maths.h"
|
#include "common/maths.h"
|
||||||
|
|
||||||
#include "config/config.h"
|
#include "config/config.h"
|
||||||
|
#include "config/feature.h"
|
||||||
|
|
||||||
#include "drivers/serial.h"
|
#include "drivers/serial.h"
|
||||||
#include "drivers/adc.h"
|
#include "drivers/adc.h"
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include "fc/runtime_config.h"
|
#include "fc/runtime_config.h"
|
||||||
|
|
||||||
#include "config/config.h"
|
#include "config/config.h"
|
||||||
|
#include "config/feature.h"
|
||||||
|
|
||||||
#include "sensors/battery.h"
|
#include "sensors/battery.h"
|
||||||
|
|
||||||
|
|
|
@ -67,6 +67,7 @@
|
||||||
#include "fc/runtime_config.h"
|
#include "fc/runtime_config.h"
|
||||||
|
|
||||||
#include "config/config.h"
|
#include "config/config.h"
|
||||||
|
#include "config/feature.h"
|
||||||
|
|
||||||
#include "io/gps.h"
|
#include "io/gps.h"
|
||||||
|
|
||||||
|
|
|
@ -59,6 +59,7 @@
|
||||||
#include "flight/navigation_rewrite.h"
|
#include "flight/navigation_rewrite.h"
|
||||||
|
|
||||||
#include "config/config.h"
|
#include "config/config.h"
|
||||||
|
#include "config/feature.h"
|
||||||
|
|
||||||
#include "telemetry/telemetry.h"
|
#include "telemetry/telemetry.h"
|
||||||
#include "telemetry/frsky.h"
|
#include "telemetry/frsky.h"
|
||||||
|
|
|
@ -74,6 +74,7 @@
|
||||||
|
|
||||||
#include "config/config_profile.h"
|
#include "config/config_profile.h"
|
||||||
#include "config/config_master.h"
|
#include "config/config_master.h"
|
||||||
|
#include "config/feature.h"
|
||||||
|
|
||||||
#include "fc/mw.h"
|
#include "fc/mw.h"
|
||||||
|
|
||||||
|
|
|
@ -57,6 +57,7 @@
|
||||||
#include "telemetry/smartport.h"
|
#include "telemetry/smartport.h"
|
||||||
|
|
||||||
#include "config/config.h"
|
#include "config/config.h"
|
||||||
|
#include "config/feature.h"
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue