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)
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/>.
27 #ifdef USE_TARGET_CONFIG
29 #include "common/axis.h"
30 #include "common/maths.h"
32 #include "config/feature.h"
34 #include "drivers/light_led.h"
35 #include "drivers/pwm_esc_detect.h"
37 #include "config/config.h"
38 #include "fc/controlrate_profile.h"
39 #include "fc/rc_modes.h"
40 #include "fc/rc_controls.h"
42 #include "flight/pid.h"
50 #include "io/serial.h"
54 #include "sensors/battery.h"
55 #include "sensors/gyro.h"
57 #include "telemetry/telemetry.h"
59 #if !defined(BEEBRAIN_V2D)
60 #define BBV2_FRSKY_RSSI_CH_IDX 9
63 #ifdef BRUSHED_MOTORS_PWM_RATE
64 #undef BRUSHED_MOTORS_PWM_RATE
67 #define BRUSHED_MOTORS_PWM_RATE 32000 // 32kHz
69 void targetConfiguration(void)
71 if (getDetectedMotorType() == MOTOR_BRUSHED
) {
72 motorConfigMutable()->dev
.motorPwmRate
= BRUSHED_MOTORS_PWM_RATE
;
73 motorConfigMutable()->minthrottle
= 1030;
74 pidConfigMutable()->pid_process_denom
= 1;
77 for (uint8_t pidProfileIndex
= 0; pidProfileIndex
< PID_PROFILE_COUNT
; pidProfileIndex
++) {
78 pidProfile_t
*pidProfile
= pidProfilesMutable(pidProfileIndex
);
80 pidProfile
->pid
[PID_ROLL
].P
= 86;
81 pidProfile
->pid
[PID_ROLL
].I
= 50;
82 pidProfile
->pid
[PID_ROLL
].D
= 60;
83 pidProfile
->pid
[PID_PITCH
].P
= 90;
84 pidProfile
->pid
[PID_PITCH
].I
= 55;
85 pidProfile
->pid
[PID_PITCH
].D
= 60;
86 pidProfile
->pid
[PID_YAW
].P
= 123;
87 pidProfile
->pid
[PID_YAW
].I
= 75;
90 for (uint8_t rateProfileIndex
= 0; rateProfileIndex
< CONTROL_RATE_PROFILE_COUNT
; rateProfileIndex
++) {
91 controlRateConfig_t
*controlRateConfig
= controlRateProfilesMutable(rateProfileIndex
);
93 controlRateConfig
->rcRates
[FD_YAW
] = 120;
94 controlRateConfig
->rcExpo
[FD_ROLL
] = 15;
95 controlRateConfig
->rcExpo
[FD_PITCH
] = 15;
96 controlRateConfig
->rcExpo
[FD_YAW
] = 15;
97 controlRateConfig
->rates
[FD_ROLL
] = 85;
98 controlRateConfig
->rates
[FD_PITCH
] = 85;
101 batteryConfigMutable()->batteryCapacity
= 250;
102 batteryConfigMutable()->vbatmincellvoltage
= 280;
103 batteryConfigMutable()->vbatwarningcellvoltage
= 330;
105 *customMotorMixerMutable(0) = (motorMixer_t
){ 1.0f
, -0.414178f
, 1.0f
, -1.0f
}; // REAR_R
106 *customMotorMixerMutable(1) = (motorMixer_t
){ 1.0f
, -0.414178f
, -1.0f
, 1.0f
}; // FRONT_R
107 *customMotorMixerMutable(2) = (motorMixer_t
){ 1.0f
, 0.414178f
, 1.0f
, 1.0f
}; // REAR_L
108 *customMotorMixerMutable(3) = (motorMixer_t
){ 1.0f
, 0.414178f
, -1.0f
, -1.0f
}; // FRONT_L
110 vcdProfileMutable()->video_system
= VIDEO_SYSTEM_NTSC
;
111 #if defined(BEESTORM)
112 strcpy(pilotConfigMutable()->name
, "BeeStorm");
114 strcpy(pilotConfigMutable()->name
, "BeeBrain V2");
116 osdConfigMutable()->cap_alarm
= 250;
117 osdConfigMutable()->item_pos
[OSD_CRAFT_NAME
] = OSD_POS(9, 11) | OSD_PROFILE_1_FLAG
;
118 osdConfigMutable()->item_pos
[OSD_MAIN_BATT_VOLTAGE
] = OSD_POS(23, 10) | OSD_PROFILE_1_FLAG
;
119 osdConfigMutable()->item_pos
[OSD_ITEM_TIMER_2
] = OSD_POS(2, 10) | OSD_PROFILE_1_FLAG
;
120 osdConfigMutable()->item_pos
[OSD_FLYMODE
] = OSD_POS(17, 10) | OSD_PROFILE_1_FLAG
;
121 osdConfigMutable()->item_pos
[OSD_VTX_CHANNEL
] = OSD_POS(10, 10) | OSD_PROFILE_1_FLAG
;
122 osdConfigMutable()->item_pos
[OSD_RSSI_VALUE
] &= ~OSD_PROFILE_1_FLAG
;
123 osdConfigMutable()->item_pos
[OSD_ITEM_TIMER_1
] &= ~OSD_PROFILE_1_FLAG
;
124 osdConfigMutable()->item_pos
[OSD_THROTTLE_POS
] &= ~OSD_PROFILE_1_FLAG
;
125 osdConfigMutable()->item_pos
[OSD_CROSSHAIRS
] &= ~OSD_PROFILE_1_FLAG
;
126 osdConfigMutable()->item_pos
[OSD_HORIZON_SIDEBARS
] &= ~OSD_PROFILE_1_FLAG
;
127 osdConfigMutable()->item_pos
[OSD_ARTIFICIAL_HORIZON
] &= ~OSD_PROFILE_1_FLAG
;
128 osdConfigMutable()->item_pos
[OSD_CURRENT_DRAW
] &= ~OSD_PROFILE_1_FLAG
;
129 osdConfigMutable()->item_pos
[OSD_MAH_DRAWN
] &= ~OSD_PROFILE_1_FLAG
;
130 osdConfigMutable()->item_pos
[OSD_GPS_SPEED
] &= ~OSD_PROFILE_1_FLAG
;
131 osdConfigMutable()->item_pos
[OSD_GPS_LON
] &= ~OSD_PROFILE_1_FLAG
;
132 osdConfigMutable()->item_pos
[OSD_GPS_LAT
] &= ~OSD_PROFILE_1_FLAG
;
133 osdConfigMutable()->item_pos
[OSD_GPS_SATS
] &= ~OSD_PROFILE_1_FLAG
;
134 osdConfigMutable()->item_pos
[OSD_HOME_DIR
] &= ~OSD_PROFILE_1_FLAG
;
135 osdConfigMutable()->item_pos
[OSD_HOME_DIST
] &= ~OSD_PROFILE_1_FLAG
;
136 osdConfigMutable()->item_pos
[OSD_COMPASS_BAR
] &= ~OSD_PROFILE_1_FLAG
;
137 osdConfigMutable()->item_pos
[OSD_ALTITUDE
] &= ~OSD_PROFILE_1_FLAG
;
138 osdConfigMutable()->item_pos
[OSD_ROLL_PIDS
] &= ~OSD_PROFILE_1_FLAG
;
139 osdConfigMutable()->item_pos
[OSD_PITCH_PIDS
] &= ~OSD_PROFILE_1_FLAG
;
140 osdConfigMutable()->item_pos
[OSD_YAW_PIDS
] &= ~OSD_PROFILE_1_FLAG
;
141 osdConfigMutable()->item_pos
[OSD_DEBUG
] &= ~OSD_PROFILE_1_FLAG
;
142 osdConfigMutable()->item_pos
[OSD_POWER
] &= ~OSD_PROFILE_1_FLAG
;
143 osdConfigMutable()->item_pos
[OSD_PIDRATE_PROFILE
] &= ~OSD_PROFILE_1_FLAG
;
144 osdConfigMutable()->item_pos
[OSD_WARNINGS
] &= ~OSD_PROFILE_1_FLAG
;
145 osdConfigMutable()->item_pos
[OSD_AVG_CELL_VOLTAGE
] &= ~OSD_PROFILE_1_FLAG
;
146 osdConfigMutable()->item_pos
[OSD_PITCH_ANGLE
] &= ~OSD_PROFILE_1_FLAG
;
147 osdConfigMutable()->item_pos
[OSD_ROLL_ANGLE
] &= ~OSD_PROFILE_1_FLAG
;
148 osdConfigMutable()->item_pos
[OSD_MAIN_BATT_USAGE
] &= ~OSD_PROFILE_1_FLAG
;
149 osdConfigMutable()->item_pos
[OSD_DISARMED
] &= ~OSD_PROFILE_1_FLAG
;
150 osdConfigMutable()->item_pos
[OSD_NUMERICAL_HEADING
] &= ~OSD_PROFILE_1_FLAG
;
151 osdConfigMutable()->item_pos
[OSD_NUMERICAL_VARIO
] &= ~OSD_PROFILE_1_FLAG
;
152 osdConfigMutable()->item_pos
[OSD_ESC_TMP
] &= ~OSD_PROFILE_1_FLAG
;
153 osdConfigMutable()->item_pos
[OSD_ESC_RPM
] &= ~OSD_PROFILE_1_FLAG
;
154 osdConfigMutable()->item_pos
[OSD_G_FORCE
] &= ~OSD_PROFILE_1_FLAG
;
155 osdConfigMutable()->item_pos
[OSD_FLIP_ARROW
] &= ~OSD_PROFILE_1_FLAG
;
157 modeActivationConditionsMutable(0)->modeId
= BOXANGLE
;
158 modeActivationConditionsMutable(0)->auxChannelIndex
= AUX2
- NON_AUX_CHANNEL_COUNT
;
159 modeActivationConditionsMutable(0)->range
.startStep
= CHANNEL_VALUE_TO_STEP(900);
160 modeActivationConditionsMutable(0)->range
.endStep
= CHANNEL_VALUE_TO_STEP(2100);
162 analyzeModeActivationConditions();
164 #if defined(BEEBRAIN_V2D)
166 for (uint8_t rxRangeIndex
= 0; rxRangeIndex
< NON_AUX_CHANNEL_COUNT
; rxRangeIndex
++) {
167 rxChannelRangeConfig_t
*channelRangeConfig
= rxChannelRangeConfigsMutable(rxRangeIndex
);
169 channelRangeConfig
->min
= 1160;
170 channelRangeConfig
->max
= 1840;
174 serialConfigMutable()->portConfigs
[findSerialPortIndexByIdentifier(SERIALRX_UART
)].functionMask
= FUNCTION_TELEMETRY_FRSKY_HUB
| FUNCTION_RX_SERIAL
;
175 rxConfigMutable()->rssi_channel
= BBV2_FRSKY_RSSI_CH_IDX
;
176 rxFailsafeChannelConfig_t
*channelFailsafeConfig
= rxFailsafeChannelConfigsMutable(BBV2_FRSKY_RSSI_CH_IDX
- 1);
177 channelFailsafeConfig
->mode
= RX_FAILSAFE_MODE_SET
;
178 channelFailsafeConfig
->step
= CHANNEL_VALUE_TO_RXFAIL_STEP(1000);
179 osdConfigMutable()->item_pos
[OSD_RSSI_VALUE
] = OSD_POS(2, 11) | OSD_PROFILE_1_FLAG
;