Set blackbox file handler to NULL after closing file
[inav.git] / src / main / fc / config.h
blobddb6a826b8370f438ac3c650675c1dc008927bc7
1 /*
2 * This file is part of Cleanflight.
4 * Cleanflight is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * Cleanflight is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.
18 #pragma once
20 #include <stdint.h>
21 #include <stdbool.h>
22 #include "common/axis.h"
23 #include "common/time.h"
24 #include "config/parameter_group.h"
25 #include "drivers/adc.h"
26 #include "fc/stats.h"
28 #define MAX_PROFILE_COUNT 3
29 #define ONESHOT_FEATURE_CHANGED_DELAY_ON_BOOT_MS 1500
30 #define MAX_NAME_LENGTH 16
32 #define TASK_GYRO_LOOPTIME 250 // Task gyro always runs at 4kHz
34 typedef enum {
35 FEATURE_THR_VBAT_COMP = 1 << 0,
36 FEATURE_VBAT = 1 << 1,
37 FEATURE_TX_PROF_SEL = 1 << 2, // Profile selection by TX stick command
38 FEATURE_BAT_PROFILE_AUTOSWITCH = 1 << 3,
39 FEATURE_UNUSED_12 = 1 << 4, //was FEATURE_MOTOR_STOP
40 FEATURE_UNUSED_1 = 1 << 5, // was FEATURE_SERVO_TILT was FEATURE_DYNAMIC_FILTERS
41 FEATURE_SOFTSERIAL = 1 << 6,
42 FEATURE_GPS = 1 << 7,
43 FEATURE_UNUSED_3 = 1 << 8, // was FEATURE_FAILSAFE
44 FEATURE_UNUSED_4 = 1 << 9, // was FEATURE_SONAR
45 FEATURE_TELEMETRY = 1 << 10,
46 FEATURE_CURRENT_METER = 1 << 11,
47 FEATURE_REVERSIBLE_MOTORS = 1 << 12,
48 FEATURE_UNUSED_5 = 1 << 13, // RX_PARALLEL_PWM
49 FEATURE_UNUSED_6 = 1 << 14, // RX_MSP
50 FEATURE_RSSI_ADC = 1 << 15,
51 FEATURE_LED_STRIP = 1 << 16,
52 FEATURE_DASHBOARD = 1 << 17,
53 FEATURE_UNUSED_7 = 1 << 18, // Unused in INAV
54 FEATURE_BLACKBOX = 1 << 19,
55 FEATURE_UNUSED_10 = 1 << 20, // was FEATURE_CHANNEL_FORWARDING
56 FEATURE_TRANSPONDER = 1 << 21,
57 FEATURE_AIRMODE = 1 << 22,
58 FEATURE_SUPEREXPO_RATES = 1 << 23,
59 FEATURE_VTX = 1 << 24,
60 FEATURE_UNUSED_8 = 1 << 25, // RX_SPI
61 FEATURE_UNUSED_9 = 1 << 26, // SOFTSPI
62 FEATURE_UNUSED_11 = 1 << 27, // FEATURE_PWM_SERVO_DRIVER
63 FEATURE_PWM_OUTPUT_ENABLE = 1 << 28,
64 FEATURE_OSD = 1 << 29,
65 FEATURE_FW_LAUNCH = 1 << 30,
66 FEATURE_FW_AUTOTRIM = 1 << 31,
67 } features_e;
69 typedef struct systemConfig_s {
70 uint8_t current_profile_index;
71 uint8_t current_battery_profile_index;
72 uint8_t current_mixer_profile_index;
73 uint8_t debug_mode;
74 #ifdef USE_DEV_TOOLS
75 bool groundTestMode; // Disables motor ouput, sets heading trusted on FW (for dev use)
76 #endif
77 #ifdef USE_I2C
78 uint8_t i2c_speed;
79 #endif
80 uint8_t throttle_tilt_compensation_strength; // the correction that will be applied at throttle_correction_angle.
81 char craftName[MAX_NAME_LENGTH + 1];
82 char pilotName[MAX_NAME_LENGTH + 1];
83 } systemConfig_t;
85 PG_DECLARE(systemConfig_t, systemConfig);
87 typedef struct beeperConfig_s {
88 uint32_t beeper_off_flags;
89 uint32_t preferred_beeper_off_flags;
90 bool dshot_beeper_enabled;
91 uint8_t dshot_beeper_tone;
92 bool pwmMode;
93 } beeperConfig_t;
95 PG_DECLARE(beeperConfig_t, beeperConfig);
97 typedef struct adcChannelConfig_s {
98 uint8_t adcFunctionChannel[ADC_FUNCTION_COUNT];
99 } adcChannelConfig_t;
101 PG_DECLARE(adcChannelConfig_t, adcChannelConfig);
104 #ifdef USE_STATS
105 PG_DECLARE(statsConfig_t, statsConfig);
106 #endif
108 void beeperOffSet(uint32_t mask);
109 void beeperOffSetAll(uint8_t beeperCount);
110 void beeperOffClear(uint32_t mask);
111 void beeperOffClearAll(void);
112 uint32_t getBeeperOffMask(void);
113 void setBeeperOffMask(uint32_t mask);
114 uint32_t getPreferredBeeperOffMask(void);
115 void setPreferredBeeperOffMask(uint32_t mask);
117 void copyCurrentProfileToProfileSlot(uint8_t profileSlotIndex);
119 void initEEPROM(void);
120 void resetEEPROM(void);
121 void readEEPROM(void);
122 void writeEEPROM(void);
123 void ensureEEPROMContainsValidData(void);
124 void processDelayedSave(void);
126 void saveConfig(void);
127 void saveConfigAndNotify(void);
128 void validateAndFixConfig(void);
129 void validateAndFixTargetConfig(void);
131 uint8_t getConfigProfile(void);
132 bool setConfigProfile(uint8_t profileIndex);
133 void setConfigProfileAndWriteEEPROM(uint8_t profileIndex);
135 uint8_t getConfigBatteryProfile(void);
136 bool setConfigBatteryProfile(uint8_t profileIndex);
137 void setConfigBatteryProfileAndWriteEEPROM(uint8_t profileIndex);
139 uint8_t getConfigMixerProfile(void);
140 bool setConfigMixerProfile(uint8_t profileIndex);
141 void setConfigMixerProfileAndWriteEEPROM(uint8_t profileIndex);
143 void setGyroCalibration(float getGyroZero[XYZ_AXIS_COUNT]);
144 void setGravityCalibration(float getGravity);
146 bool canSoftwareSerialBeUsed(void);
147 void applyAndSaveBoardAlignmentDelta(int16_t roll, int16_t pitch);
149 void createDefaultConfig(void);
150 void resetConfigs(void);
151 void targetConfiguration(void);
153 uint32_t getLooptime(void);
154 uint32_t getGyroLooptime(void);