Merge pull request #10313 from P-I-Engineer/patch-1
[inav.git] / src / main / blackbox / blackbox_fielddefs.h
blob17595157dd20ebb22ece0c7a168e529f254b04eb
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>
23 #include "common/time.h"
25 typedef enum FlightLogFieldCondition {
26 FLIGHT_LOG_FIELD_CONDITION_ALWAYS = 0,
27 FLIGHT_LOG_FIELD_CONDITION_MOTORS,
28 FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_MOTORS_1,
29 FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_MOTORS_2,
30 FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_MOTORS_3,
31 FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_MOTORS_4,
32 FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_MOTORS_5,
33 FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_MOTORS_6,
34 FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_MOTORS_7,
35 FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_MOTORS_8,
37 FLIGHT_LOG_FIELD_CONDITION_SERVOS,
38 FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_1,
39 FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_2,
40 FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_3,
41 FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_4,
42 FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_5,
43 FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_6,
44 FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_7,
45 FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_8,
46 FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_9,
47 FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_10,
48 FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_11,
49 FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_12,
50 FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_13,
51 FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_14,
52 FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_15,
53 FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_16,
54 FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_17,
55 FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_18,
56 FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_19,
57 FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_20,
58 FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_21,
59 FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_22,
60 FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_23,
61 FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_24,
62 FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_25,
63 FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_26,
65 FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_27,
66 FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_28,
67 FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_29,
68 FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_30,
69 FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_31,
70 FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_32,
71 FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_33,
72 FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_34,
75 FLIGHT_LOG_FIELD_CONDITION_MAG,
76 FLIGHT_LOG_FIELD_CONDITION_BARO,
77 FLIGHT_LOG_FIELD_CONDITION_PITOT,
78 FLIGHT_LOG_FIELD_CONDITION_VBAT,
79 FLIGHT_LOG_FIELD_CONDITION_AMPERAGE,
80 FLIGHT_LOG_FIELD_CONDITION_SURFACE,
81 FLIGHT_LOG_FIELD_CONDITION_FIXED_WING_NAV,
82 FLIGHT_LOG_FIELD_CONDITION_MC_NAV,
83 FLIGHT_LOG_FIELD_CONDITION_RSSI,
85 FLIGHT_LOG_FIELD_CONDITION_NONZERO_PID_D_0,
86 FLIGHT_LOG_FIELD_CONDITION_NONZERO_PID_D_1,
87 FLIGHT_LOG_FIELD_CONDITION_NONZERO_PID_D_2,
89 FLIGHT_LOG_FIELD_CONDITION_NOT_LOGGING_EVERY_FRAME,
91 FLIGHT_LOG_FIELD_CONDITION_DEBUG,
93 FLIGHT_LOG_FIELD_CONDITION_NAV_ACC,
94 FLIGHT_LOG_FIELD_CONDITION_NAV_POS,
95 FLIGHT_LOG_FIELD_CONDITION_NAV_PID,
96 FLIGHT_LOG_FIELD_CONDITION_ACC,
97 FLIGHT_LOG_FIELD_CONDITION_ATTITUDE,
98 FLIGHT_LOG_FIELD_CONDITION_RC_DATA,
99 FLIGHT_LOG_FIELD_CONDITION_RC_COMMAND,
100 FLIGHT_LOG_FIELD_CONDITION_GYRO_RAW,
102 FLIGHT_LOG_FIELD_CONDITION_GYRO_PEAKS_ROLL,
103 FLIGHT_LOG_FIELD_CONDITION_GYRO_PEAKS_PITCH,
104 FLIGHT_LOG_FIELD_CONDITION_GYRO_PEAKS_YAW,
106 FLIGHT_LOG_FIELD_CONDITION_NEVER,
108 FLIGHT_LOG_FIELD_CONDITION_FIRST = FLIGHT_LOG_FIELD_CONDITION_ALWAYS,
109 FLIGHT_LOG_FIELD_CONDITION_LAST = FLIGHT_LOG_FIELD_CONDITION_NEVER
110 } FlightLogFieldCondition;
112 typedef enum FlightLogFieldPredictor {
113 //No prediction:
114 FLIGHT_LOG_FIELD_PREDICTOR_0 = 0,
116 //Predict that the field is the same as last frame:
117 FLIGHT_LOG_FIELD_PREDICTOR_PREVIOUS = 1,
119 //Predict that the slope between this field and the previous item is the same as that between the past two history items:
120 FLIGHT_LOG_FIELD_PREDICTOR_STRAIGHT_LINE = 2,
122 //Predict that this field is the same as the average of the last two history items:
123 FLIGHT_LOG_FIELD_PREDICTOR_AVERAGE_2 = 3,
125 //Predict that this field is minthrottle
126 FLIGHT_LOG_FIELD_PREDICTOR_MINTHROTTLE = 4,
128 //Predict that this field is the same as motor 0
129 FLIGHT_LOG_FIELD_PREDICTOR_MOTOR_0 = 5,
131 //This field always increments
132 FLIGHT_LOG_FIELD_PREDICTOR_INC = 6,
134 //Predict this GPS co-ordinate is the GPS home co-ordinate (or no prediction if that coordinate is not set)
135 FLIGHT_LOG_FIELD_PREDICTOR_HOME_COORD = 7,
137 //Predict 1500
138 FLIGHT_LOG_FIELD_PREDICTOR_1500 = 8,
140 //Predict vbatref, the reference ADC level stored in the header
141 FLIGHT_LOG_FIELD_PREDICTOR_VBATREF = 9,
143 //Predict the last time value written in the main stream
144 FLIGHT_LOG_FIELD_PREDICTOR_LAST_MAIN_FRAME_TIME = 10
146 } FlightLogFieldPredictor;
148 typedef enum FlightLogFieldEncoding {
149 FLIGHT_LOG_FIELD_ENCODING_SIGNED_VB = 0, // Signed variable-byte
150 FLIGHT_LOG_FIELD_ENCODING_UNSIGNED_VB = 1, // Unsigned variable-byte
151 FLIGHT_LOG_FIELD_ENCODING_NEG_14BIT = 3, // Unsigned variable-byte but we negate the value before storing, value is 14 bits
152 FLIGHT_LOG_FIELD_ENCODING_TAG8_8SVB = 6,
153 FLIGHT_LOG_FIELD_ENCODING_TAG2_3S32 = 7,
154 FLIGHT_LOG_FIELD_ENCODING_TAG8_4S16 = 8,
155 FLIGHT_LOG_FIELD_ENCODING_NULL = 9 // Nothing is written to the file, take value to be zero
156 } FlightLogFieldEncoding;
158 typedef enum FlightLogFieldSign {
159 FLIGHT_LOG_FIELD_UNSIGNED = 0,
160 FLIGHT_LOG_FIELD_SIGNED = 1
161 } FlightLogFieldSign;
163 typedef enum FlightLogEvent {
164 FLIGHT_LOG_EVENT_SYNC_BEEP = 0,
165 FLIGHT_LOG_EVENT_INFLIGHT_ADJUSTMENT = 13,
166 FLIGHT_LOG_EVENT_LOGGING_RESUME = 14,
167 FLIGHT_LOG_EVENT_FLIGHTMODE = 30, // Add new event type for flight mode status.
168 FLIGHT_LOG_EVENT_IMU_FAILURE = 40,
169 FLIGHT_LOG_EVENT_LOG_END = 255
170 } FlightLogEvent;
172 typedef struct flightLogEvent_syncBeep_s {
173 uint32_t time;
174 } flightLogEvent_syncBeep_t;
176 typedef struct flightLogEvent_flightMode_s { // New Event Data type
177 uint32_t flags;
178 uint32_t lastFlags;
179 } flightLogEvent_flightMode_t;
181 typedef struct flightLogEvent_inflightAdjustment_s {
182 uint8_t adjustmentFunction;
183 bool floatFlag;
184 int32_t newValue;
185 float newFloatValue;
186 } flightLogEvent_inflightAdjustment_t;
188 typedef struct flightLogEvent_loggingResume_s {
189 uint32_t logIteration;
190 timeUs_t currentTimeUs;
191 } flightLogEvent_loggingResume_t;
193 typedef struct flightLogEvent_IMUError_s {
194 uint32_t errorCode;
195 } flightLogEvent_IMUError_t;
197 #define FLIGHT_LOG_EVENT_INFLIGHT_ADJUSTMENT_FUNCTION_FLOAT_VALUE_FLAG 128
199 typedef union flightLogEventData_u {
200 flightLogEvent_syncBeep_t syncBeep;
201 flightLogEvent_flightMode_t flightMode; // New event data
202 flightLogEvent_inflightAdjustment_t inflightAdjustment;
203 flightLogEvent_loggingResume_t loggingResume;
204 flightLogEvent_IMUError_t imuError;
205 } flightLogEventData_t;
207 typedef struct flightLogEvent_s {
208 FlightLogEvent event;
209 flightLogEventData_t data;
210 } flightLogEvent_t;