Merge pull request #11198 from SteveCEvans/sce_rc2
[betaflight.git] / src / main / target / MULTIFLITEPICO / config.c
blob320275e3c16db587d57943b151489d85d12e407c
1 /*
2 * This file is part of Cleanflight and Betaflight.
4 * Cleanflight and Betaflight are free software. You can redistribute
5 * this software and/or modify this software under the terms of the
6 * GNU General Public License as published by the Free Software
7 * Foundation, either version 3 of the License, or (at your option)
8 * any later version.
10 * Cleanflight and Betaflight are distributed in the hope that they
11 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
12 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 * See the GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this software.
18 * If not, see <http://www.gnu.org/licenses/>.
21 #include <stdbool.h>
22 #include <stdint.h>
24 #include "platform.h"
26 #ifdef USE_TARGET_CONFIG
28 #include "common/axis.h"
29 #include "common/maths.h"
31 #include "config/config.h"
32 #include "fc/controlrate_profile.h"
33 #include "fc/rc_modes.h"
34 #include "fc/rc_controls.h"
36 #include "flight/failsafe.h"
37 #include "flight/pid.h"
39 #include "pg/rx.h"
40 #include "pg/motor.h"
42 #include "rx/rx.h"
44 #include "sensors/battery.h"
45 #include "sensors/compass.h"
46 #include "sensors/gyro.h"
48 #define VBAT_SCALE 100
50 // alternative defaults settings for MULTIFLITEPICO targets
51 void targetConfiguration(void)
53 compassConfigMutable()->mag_hardware = MAG_NONE; // disabled by default
55 voltageSensorADCConfigMutable(VOLTAGE_SENSOR_ADC_VBAT)->vbatscale = VBAT_SCALE;
56 voltageSensorADCConfigMutable(VOLTAGE_SENSOR_ADC_VBAT)->vbatresdivval = 15;
57 voltageSensorADCConfigMutable(VOLTAGE_SENSOR_ADC_VBAT)->vbatresdivmultiplier = 4;
58 batteryConfigMutable()->vbatmaxcellvoltage = 440;
59 batteryConfigMutable()->vbatmincellvoltage = 320;
60 batteryConfigMutable()->vbatwarningcellvoltage = 330;
62 rxConfigMutable()->spektrum_sat_bind = 5;
63 rxConfigMutable()->spektrum_sat_bind_autoreset = 1;
65 rcControlsConfigMutable()->yaw_deadband = 2;
66 rcControlsConfigMutable()->deadband = 2;
68 modeActivationConditionsMutable(0)->modeId = BOXANGLE;
69 modeActivationConditionsMutable(0)->auxChannelIndex = AUX1 - NON_AUX_CHANNEL_COUNT;
70 modeActivationConditionsMutable(0)->range.startStep = CHANNEL_VALUE_TO_STEP(900);
71 modeActivationConditionsMutable(0)->range.endStep = CHANNEL_VALUE_TO_STEP(1400);
72 modeActivationConditionsMutable(1)->modeId = BOXHORIZON;
73 modeActivationConditionsMutable(1)->auxChannelIndex = AUX1 - NON_AUX_CHANNEL_COUNT;
74 modeActivationConditionsMutable(1)->range.startStep = CHANNEL_VALUE_TO_STEP(1425);
75 modeActivationConditionsMutable(1)->range.endStep = CHANNEL_VALUE_TO_STEP(1575);
77 analyzeModeActivationConditions();
79 failsafeConfigMutable()->failsafe_delay = 2;
80 failsafeConfigMutable()->failsafe_off_delay = 0;
82 motorConfigMutable()->dev.motorPwmRate = 17000;
84 pidConfigMutable()->pid_process_denom = 4;
86 for (uint8_t pidProfileIndex = 0; pidProfileIndex < PID_PROFILE_COUNT; pidProfileIndex++) {
87 pidProfile_t *pidProfile = pidProfilesMutable(pidProfileIndex);
89 pidProfile->pid[PID_ROLL].P = 70;
90 pidProfile->pid[PID_ROLL].I = 62;
91 pidProfile->pid[PID_ROLL].D = 19;
92 pidProfile->pid[PID_PITCH].P = 70;
93 pidProfile->pid[PID_PITCH].I = 62;
94 pidProfile->pid[PID_PITCH].D = 19;
95 pidProfile->pid[PID_LEVEL].I = 40;
98 for (uint8_t rateProfileIndex = 0; rateProfileIndex < CONTROL_RATE_PROFILE_COUNT; rateProfileIndex++) {
99 controlRateConfig_t *controlRateConfig = controlRateProfilesMutable(rateProfileIndex);
101 controlRateConfig->rcRates[FD_ROLL] = 70;
102 controlRateConfig->rcRates[FD_PITCH] = 70;
105 #endif