Browse Source

Split features into feature.c (#572)

master
Martin Budden 8 years ago
committed by Konstantin Sharlaimov
parent
commit
dafa38c61a
  1. 1
      Makefile
  2. 1
      src/main/blackbox/blackbox.c
  3. 38
      src/main/config/config.c
  4. 7
      src/main/config/config.h
  5. 110
      src/main/config/feature.c
  6. 26
      src/main/config/feature.h
  7. 1
      src/main/fc/mw.c
  8. 1
      src/main/fc/rc_controls.c
  9. 1
      src/main/flight/mixer.c
  10. 1
      src/main/io/beeper.c
  11. 1
      src/main/io/display.c
  12. 2
      src/main/io/gps.c
  13. 1
      src/main/io/ledstrip.c
  14. 7
      src/main/io/ledstrip.h
  15. 1
      src/main/io/serial_cli.c
  16. 1
      src/main/io/serial_msp.c
  17. 1
      src/main/main.c
  18. 1
      src/main/rx/pwm.c
  19. 1
      src/main/rx/rx.c
  20. 1
      src/main/sensors/battery.c
  21. 1
      src/main/sensors/initialisation.c
  22. 1
      src/main/telemetry/frsky.c
  23. 1
      src/main/telemetry/mavlink.c
  24. 1
      src/main/telemetry/smartport.c

1
Makefile

@ -371,6 +371,7 @@ COMMON_SRC = \
common/typeconversion.c \
common/streambuf.c \
config/config.c \
config/feature.c \
fc/runtime_config.c \
drivers/logging.c \
drivers/adc.c \

1
src/main/blackbox/blackbox.c

@ -77,6 +77,7 @@
#include "config/config.h"
#include "config/config_profile.h"
#include "config/config_master.h"
#include "config/feature.h"
#include "blackbox.h"
#include "blackbox_io.h"

38
src/main/config/config.c

@ -72,9 +72,9 @@
#include "fc/runtime_config.h"
#include "config/config.h"
#include "config/config_profile.h"
#include "config/config_master.h"
#include "config/feature.h"
#ifndef DEFAULT_RX_FEATURE
#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
profile_t *currentProfile;
static uint32_t activeFeaturesLatch = 0;
static uint8_t currentControlRateProfileIndex = 0;
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()
{
masterConfig.persistentFlags = 0;

7
src/main/config/config.h

@ -57,13 +57,6 @@ typedef enum {
} persistent_flags_e;
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 beeperOffSetAll(uint8_t beeperCount);
void beeperOffClear(uint32_t mask);

110
src/main/config/feature.c

@ -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

@ -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);

1
src/main/fc/mw.c

@ -86,6 +86,7 @@
#include "config/config.h"
#include "config/config_profile.h"
#include "config/config_master.h"
#include "config/feature.h"
// June 2013 V2.2-dev

1
src/main/fc/rc_controls.c

@ -55,6 +55,7 @@
#include "flight/failsafe.h"
#include "config/config.h"
#include "config/feature.h"
#include "blackbox/blackbox.h"

1
src/main/flight/mixer.c

@ -59,6 +59,7 @@
#include "config/config.h"
#include "config/config_profile.h"
#include "config/feature.h"
//#define MIXER_DEBUG

1
src/main/io/beeper.c

@ -41,6 +41,7 @@
#include "fc/runtime_config.h"
#include "config/config.h"
#include "config/feature.h"
#include "io/beeper.h"

1
src/main/io/display.c

@ -64,6 +64,7 @@
#include "config/config.h"
#include "config/feature.h"
#include "display.h"

2
src/main/io/gps.c

@ -52,6 +52,8 @@
#include "flight/navigation_rewrite.h"
#include "config/config.h"
#include "config/feature.h"
#include "fc/runtime_config.h"
// GPS timeout for wrong baud rate/disconnection/etc in milliseconds (default 2000 ms)

1
src/main/io/ledstrip.c

@ -75,6 +75,7 @@
#include "config/config.h"
#include "config/config_profile.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);

7
src/main/io/ledstrip.h

@ -134,7 +134,8 @@ typedef struct ledCounts_s {
ledConfig_t *ledConfigs;
hsvColor_t *colors;
struct hsvColor_s;
struct hsvColor_s *colors;
modeColorIndexes_t *modeColors;
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 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 updateLedStrip(void);
@ -173,7 +174,7 @@ extern uint16_t rssi; // FIXME dependency on mw.c
void applyDefaultLedStripConfig(ledConfig_t *ledConfig);
void applyDefaultColors(hsvColor_t *colors);
void applyDefaultColors(struct hsvColor_s *colors);
void applyDefaultModeColors(modeColorIndexes_t *modeColors);
void applyDefaultSpecialColors(specialColorIndexes_t *specialColors);

1
src/main/io/serial_cli.c

@ -91,6 +91,7 @@
#include "config/config.h"
#include "config/config_profile.h"
#include "config/config_master.h"
#include "config/feature.h"
#include "common/printf.h"

1
src/main/io/serial_msp.c

@ -88,6 +88,7 @@
#include "config/config.h"
#include "config/config_profile.h"
#include "config/config_master.h"
#include "config/feature.h"
#include "blackbox/blackbox.h"

1
src/main/main.c

@ -106,6 +106,7 @@
#include "config/config.h"
#include "config/config_profile.h"
#include "config/config_master.h"
#include "config/feature.h"
#ifdef USE_HARDWARE_REVISION_DETECTION
#include "hardware_revision.h"

1
src/main/rx/pwm.c

@ -33,6 +33,7 @@
#include "drivers/pwm_rx.h"
#include "config/config.h"
#include "config/feature.h"
#include "rx/rx.h"
#include "rx/pwm.h"

1
src/main/rx/rx.c

@ -31,6 +31,7 @@
#include "common/maths.h"
#include "config/config.h"
#include "config/feature.h"
#include "drivers/serial.h"
#include "drivers/adc.h"

1
src/main/sensors/battery.c

@ -29,6 +29,7 @@
#include "fc/runtime_config.h"
#include "config/config.h"
#include "config/feature.h"
#include "sensors/battery.h"

1
src/main/sensors/initialisation.c

@ -67,6 +67,7 @@
#include "fc/runtime_config.h"
#include "config/config.h"
#include "config/feature.h"
#include "io/gps.h"

1
src/main/telemetry/frsky.c

@ -59,6 +59,7 @@
#include "flight/navigation_rewrite.h"
#include "config/config.h"
#include "config/feature.h"
#include "telemetry/telemetry.h"
#include "telemetry/frsky.h"

1
src/main/telemetry/mavlink.c

@ -74,6 +74,7 @@
#include "config/config_profile.h"
#include "config/config_master.h"
#include "config/feature.h"
#include "fc/mw.h"

1
src/main/telemetry/smartport.c

@ -57,6 +57,7 @@
#include "telemetry/smartport.h"
#include "config/config.h"
#include "config/feature.h"
enum
{

Loading…
Cancel
Save