Added PG config definitions 6

This commit is contained in:
Martin Budden 2017-02-26 08:48:16 +00:00
parent 8a8aae49b9
commit 6b27f10c94
10 changed files with 137 additions and 52 deletions

View File

@ -596,6 +596,7 @@ COMMON_SRC = \
drivers/system.c \
drivers/timer.c \
fc/config.c \
fc/controlrate_profile.c \
fc/fc_init.c \
fc/fc_dispatch.c \
fc/fc_hardfaults.c \

View File

@ -38,6 +38,7 @@
#include "drivers/serial.h"
#include "fc/config.h"
#include "fc/controlrate_profile.h"
#include "fc/rc_adjustments.h"
#include "fc/rc_controls.h"
#include "fc/fc_core.h"

View File

@ -944,7 +944,7 @@ static systemConfig_t systemConfigCopy;
#ifdef BEEPER
static beeperDevConfig_t beeperDevConfigCopy;
#endif
static controlRateConfig_t controlRateProfilesCopy[MAX_CONTROL_RATE_PROFILE_COUNT];
static controlRateConfig_t controlRateProfilesCopy[CONTROL_RATE_PROFILE_COUNT];
static pidProfile_t pidProfileCopy[MAX_PROFILE_COUNT];
#endif // USE_PARAMETER_GROUPS

View File

@ -127,8 +127,6 @@ PG_REGISTER_WITH_RESET_FN(statusLedConfig_t, statusLedConfig, PG_STATUS_LED_CONF
master_t masterConfig; // master config struct with data independent from profiles
profile_t *currentProfile;
controlRateConfig_t *currentControlRateProfile;
#ifndef USE_PARAMETER_GROUPS
static void resetAccelerometerTrims(flightDynamicsTrims_t *accelerometerTrims)
{
@ -148,7 +146,6 @@ static void resetCompassConfig(compassConfig_t* compassConfig)
compassConfig->interruptTag = IO_TAG_NONE;
#endif
}
#endif
static void resetControlRateProfile(controlRateConfig_t *controlRateConfig)
{
@ -165,6 +162,7 @@ static void resetControlRateProfile(controlRateConfig_t *controlRateConfig)
controlRateConfig->rates[axis] = 70;
}
}
#endif
static void resetPidProfile(pidProfile_t *pidProfile)
{
@ -768,14 +766,6 @@ uint8_t getCurrentControlRateProfileIndex(void)
return systemConfigMutable()->activeRateProfile;
}
static void setControlRateProfile(uint8_t controlRateProfileIndex)
{
if (controlRateProfileIndex < MAX_CONTROL_RATE_PROFILE_COUNT) {
systemConfigMutable()->activeRateProfile = controlRateProfileIndex;
currentControlRateProfile = controlRateProfilesMutable(controlRateProfileIndex);
}
}
uint16_t getCurrentMinthrottle(void)
{
return motorConfig()->minthrottle;
@ -993,9 +983,11 @@ void createDefaultConfig(master_t *config)
for (int ii = 0; ii < MAX_PROFILE_COUNT; ++ii) {
resetProfile(&config->profile[ii]);
}
for (int ii = 0; ii < MAX_CONTROL_RATE_PROFILE_COUNT; ++ii) {
#ifndef USE_PARAMETER_GROUPS
for (int ii = 0; ii < CONTROL_RATE_PROFILE_COUNT; ++ii) {
resetControlRateProfile(&config->controlRateProfile[ii]);
}
#endif
config->compassConfig.mag_declination = 0;
@ -1363,15 +1355,6 @@ void changeProfile(uint8_t profileIndex)
beeperConfirmationBeeps(profileIndex + 1);
}
void changeControlRateProfile(uint8_t profileIndex)
{
if (profileIndex >= MAX_RATEPROFILES) {
profileIndex = MAX_RATEPROFILES - 1;
}
setControlRateProfile(profileIndex);
generateThrottleCurve();
}
void beeperOffSet(uint32_t mask)
{
beeperConfigMutable()->beeper_off_flags |= mask;

View File

@ -89,8 +89,6 @@ PG_DECLARE(serialPinConfig_t, serialPinConfig);
struct profile_s;
extern struct profile_s *currentProfile;
struct controlRateConfig_s;
extern struct controlRateConfig_s *currentControlRateProfile;
void beeperOffSet(uint32_t mask);
void beeperOffSetAll(uint8_t beeperCount);

View File

@ -0,0 +1,73 @@
/*
* 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 "config/config_reset.h"
#include "config/parameter_group.h"
#include "config/parameter_group_ids.h"
#include "fc/config.h"
#include "fc/controlrate_profile.h"
#include "fc/fc_rc.h"
controlRateConfig_t *currentControlRateProfile;
PG_REGISTER_ARRAY_WITH_RESET_FN(controlRateConfig_t, CONTROL_RATE_PROFILE_COUNT, controlRateProfiles, PG_CONTROL_RATE_PROFILES, 0);
void pgResetFn_controlRateProfiles(controlRateConfig_t *controlRateConfig)
{
for (int i = 0; i < CONTROL_RATE_PROFILE_COUNT; i++) {
RESET_CONFIG(const controlRateConfig_t, &controlRateConfig[i],
.rcRate8 = 100,
.rcYawRate8 = 100,
.rcExpo8 = 0,
.thrMid8 = 50,
.thrExpo8 = 0,
.dynThrPID = 10,
.rcYawExpo8 = 0,
.tpa_breakpoint = 1650,
.rates[FD_ROLL] = 70,
.rates[FD_PITCH] = 70,
.rates[FD_YAW] = 70
);
}
}
void setControlRateProfile(uint8_t controlRateProfileIndex)
{
if (controlRateProfileIndex < CONTROL_RATE_PROFILE_COUNT) {
systemConfigMutable()->activeRateProfile = controlRateProfileIndex;
currentControlRateProfile = controlRateProfilesMutable(controlRateProfileIndex);
}
}
void changeControlRateProfile(uint8_t controlRateProfileIndex)
{
if (controlRateProfileIndex >= CONTROL_RATE_PROFILE_COUNT) {
controlRateProfileIndex = CONTROL_RATE_PROFILE_COUNT - 1;
}
setControlRateProfile(controlRateProfileIndex);
generateThrottleCurve();
}

View File

@ -0,0 +1,43 @@
/*
* 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
#include <stdint.h>
#include "config/parameter_group.h"
typedef struct controlRateConfig_s {
uint8_t rcRate8;
uint8_t rcYawRate8;
uint8_t rcExpo8;
uint8_t thrMid8;
uint8_t thrExpo8;
uint8_t rates[3];
uint8_t dynThrPID;
uint8_t rcYawExpo8;
uint16_t tpa_breakpoint; // Breakpoint where TPA is activated
} controlRateConfig_t;
#define CONTROL_RATE_PROFILE_COUNT 3
PG_DECLARE_ARRAY(controlRateConfig_t, CONTROL_RATE_PROFILE_COUNT, controlRateProfiles);
extern controlRateConfig_t *currentControlRateProfile;
void setControlRateProfile(uint8_t controlRateProfileIndex);
void changeControlRateProfile(uint8_t controlRateProfileIndex);

View File

@ -47,6 +47,7 @@
#include "fc/cli.h"
#include "fc/config.h"
#include "fc/controlrate_profile.h"
#include "fc/fc_core.h"
#include "fc/fc_rc.h"
#include "fc/rc_adjustments.h"

View File

@ -151,21 +151,6 @@ typedef struct modeActivationProfile_s {
#define IS_RANGE_USABLE(range) ((range)->startStep < (range)->endStep)
typedef struct controlRateConfig_s {
uint8_t rcRate8;
uint8_t rcYawRate8;
uint8_t rcExpo8;
uint8_t thrMid8;
uint8_t thrExpo8;
uint8_t rates[3];
uint8_t dynThrPID;
uint8_t rcYawExpo8;
uint16_t tpa_breakpoint; // Breakpoint where TPA is activated
} controlRateConfig_t;
#define MAX_CONTROL_RATE_PROFILE_COUNT 3
PG_DECLARE_ARRAY(controlRateConfig_t, MAX_CONTROL_RATE_PROFILE_COUNT, controlRateProfiles);
extern int16_t rcCommand[4];
typedef struct rcControlsConfig_s {

View File

@ -21,21 +21,31 @@
#include "config/parameter_group.h"
#include "config/parameter_group_ids.h"
#include "drivers/system.h"
#include "drivers/sensor.h"
#include "drivers/accgyro.h"
#include "drivers/compass.h"
#include "drivers/sensor.h"
#include "drivers/system.h"
#include "fc/config.h"
#include "fc/controlrate_profile.h"
#include "fc/fc_msp.h"
#include "fc/rc_controls.h"
#include "fc/runtime_config.h"
#include "fc/fc_msp.h"
#include "flight/altitudehold.h"
#include "flight/failsafe.h"
#include "flight/imu.h"
#include "flight/mixer.h"
#include "flight/pid.h"
#include "flight/navigation.h"
#include "io/beeper.h"
#include "io/motors.h"
#include "io/gps.h"
#include "io/serial.h"
#include "msp/msp.h"
#include "sensors/boardalignment.h"
#include "sensors/sensors.h"
#include "sensors/battery.h"
@ -44,23 +54,13 @@
#include "sensors/compass.h"
#include "sensors/gyro.h"
#include "flight/pid.h"
#include "flight/imu.h"
#include "flight/mixer.h"
#include "flight/failsafe.h"
#include "flight/navigation.h"
#include "flight/altitudehold.h"
#include "rx/rx.h"
#include "rx/msp.h"
#include "telemetry/telemetry.h"
#include "telemetry/smartport.h"
#include "msp/msp.h"
extern profile_t *currentProfile;
extern controlRateConfig_t *currentControlRateProfile;
enum
{