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/>.
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
,
36 FLIGHT_LOG_FIELD_CONDITION_SERVOS
,
38 FLIGHT_LOG_FIELD_CONDITION_MAG
,
39 FLIGHT_LOG_FIELD_CONDITION_BARO
,
40 FLIGHT_LOG_FIELD_CONDITION_PITOT
,
41 FLIGHT_LOG_FIELD_CONDITION_VBAT
,
42 FLIGHT_LOG_FIELD_CONDITION_AMPERAGE
,
43 FLIGHT_LOG_FIELD_CONDITION_SURFACE
,
44 FLIGHT_LOG_FIELD_CONDITION_FIXED_WING_NAV
,
45 FLIGHT_LOG_FIELD_CONDITION_MC_NAV
,
46 FLIGHT_LOG_FIELD_CONDITION_RSSI
,
48 FLIGHT_LOG_FIELD_CONDITION_NONZERO_PID_D_0
,
49 FLIGHT_LOG_FIELD_CONDITION_NONZERO_PID_D_1
,
50 FLIGHT_LOG_FIELD_CONDITION_NONZERO_PID_D_2
,
52 FLIGHT_LOG_FIELD_CONDITION_NOT_LOGGING_EVERY_FRAME
,
54 FLIGHT_LOG_FIELD_CONDITION_DEBUG
,
56 FLIGHT_LOG_FIELD_CONDITION_NAV_ACC
,
57 FLIGHT_LOG_FIELD_CONDITION_NAV_POS
,
58 FLIGHT_LOG_FIELD_CONDITION_NAV_PID
,
59 FLIGHT_LOG_FIELD_CONDITION_ACC
,
60 FLIGHT_LOG_FIELD_CONDITION_ATTITUDE
,
61 FLIGHT_LOG_FIELD_CONDITION_RC_DATA
,
62 FLIGHT_LOG_FIELD_CONDITION_RC_COMMAND
,
63 FLIGHT_LOG_FIELD_CONDITION_GYRO_RAW
,
65 FLIGHT_LOG_FIELD_CONDITION_GYRO_PEAKS_ROLL
,
66 FLIGHT_LOG_FIELD_CONDITION_GYRO_PEAKS_PITCH
,
67 FLIGHT_LOG_FIELD_CONDITION_GYRO_PEAKS_YAW
,
69 FLIGHT_LOG_FIELD_CONDITION_NEVER
,
71 FLIGHT_LOG_FIELD_CONDITION_FIRST
= FLIGHT_LOG_FIELD_CONDITION_ALWAYS
,
72 FLIGHT_LOG_FIELD_CONDITION_LAST
= FLIGHT_LOG_FIELD_CONDITION_NEVER
73 } FlightLogFieldCondition
;
75 typedef enum FlightLogFieldPredictor
{
77 FLIGHT_LOG_FIELD_PREDICTOR_0
= 0,
79 //Predict that the field is the same as last frame:
80 FLIGHT_LOG_FIELD_PREDICTOR_PREVIOUS
= 1,
82 //Predict that the slope between this field and the previous item is the same as that between the past two history items:
83 FLIGHT_LOG_FIELD_PREDICTOR_STRAIGHT_LINE
= 2,
85 //Predict that this field is the same as the average of the last two history items:
86 FLIGHT_LOG_FIELD_PREDICTOR_AVERAGE_2
= 3,
88 //Predict that this field is minthrottle
89 FLIGHT_LOG_FIELD_PREDICTOR_MINTHROTTLE
= 4,
91 //Predict that this field is the same as motor 0
92 FLIGHT_LOG_FIELD_PREDICTOR_MOTOR_0
= 5,
94 //This field always increments
95 FLIGHT_LOG_FIELD_PREDICTOR_INC
= 6,
97 //Predict this GPS co-ordinate is the GPS home co-ordinate (or no prediction if that coordinate is not set)
98 FLIGHT_LOG_FIELD_PREDICTOR_HOME_COORD
= 7,
101 FLIGHT_LOG_FIELD_PREDICTOR_1500
= 8,
103 //Predict vbatref, the reference ADC level stored in the header
104 FLIGHT_LOG_FIELD_PREDICTOR_VBATREF
= 9,
106 //Predict the last time value written in the main stream
107 FLIGHT_LOG_FIELD_PREDICTOR_LAST_MAIN_FRAME_TIME
= 10
109 } FlightLogFieldPredictor
;
111 typedef enum FlightLogFieldEncoding
{
112 FLIGHT_LOG_FIELD_ENCODING_SIGNED_VB
= 0, // Signed variable-byte
113 FLIGHT_LOG_FIELD_ENCODING_UNSIGNED_VB
= 1, // Unsigned variable-byte
114 FLIGHT_LOG_FIELD_ENCODING_NEG_14BIT
= 3, // Unsigned variable-byte but we negate the value before storing, value is 14 bits
115 FLIGHT_LOG_FIELD_ENCODING_TAG8_8SVB
= 6,
116 FLIGHT_LOG_FIELD_ENCODING_TAG2_3S32
= 7,
117 FLIGHT_LOG_FIELD_ENCODING_TAG8_4S16
= 8,
118 FLIGHT_LOG_FIELD_ENCODING_NULL
= 9 // Nothing is written to the file, take value to be zero
119 } FlightLogFieldEncoding
;
121 typedef enum FlightLogFieldSign
{
122 FLIGHT_LOG_FIELD_UNSIGNED
= 0,
123 FLIGHT_LOG_FIELD_SIGNED
= 1
124 } FlightLogFieldSign
;
126 typedef enum FlightLogEvent
{
127 FLIGHT_LOG_EVENT_SYNC_BEEP
= 0,
128 FLIGHT_LOG_EVENT_INFLIGHT_ADJUSTMENT
= 13,
129 FLIGHT_LOG_EVENT_LOGGING_RESUME
= 14,
130 FLIGHT_LOG_EVENT_FLIGHTMODE
= 30, // Add new event type for flight mode status.
131 FLIGHT_LOG_EVENT_IMU_FAILURE
= 40,
132 FLIGHT_LOG_EVENT_LOG_END
= 255
135 typedef struct flightLogEvent_syncBeep_s
{
137 } flightLogEvent_syncBeep_t
;
139 typedef struct flightLogEvent_flightMode_s
{ // New Event Data type
142 } flightLogEvent_flightMode_t
;
144 typedef struct flightLogEvent_inflightAdjustment_s
{
145 uint8_t adjustmentFunction
;
149 } flightLogEvent_inflightAdjustment_t
;
151 typedef struct flightLogEvent_loggingResume_s
{
152 uint32_t logIteration
;
153 timeUs_t currentTimeUs
;
154 } flightLogEvent_loggingResume_t
;
156 typedef struct flightLogEvent_IMUError_s
{
158 } flightLogEvent_IMUError_t
;
160 #define FLIGHT_LOG_EVENT_INFLIGHT_ADJUSTMENT_FUNCTION_FLOAT_VALUE_FLAG 128
162 typedef union flightLogEventData_u
{
163 flightLogEvent_syncBeep_t syncBeep
;
164 flightLogEvent_flightMode_t flightMode
; // New event data
165 flightLogEvent_inflightAdjustment_t inflightAdjustment
;
166 flightLogEvent_loggingResume_t loggingResume
;
167 flightLogEvent_IMUError_t imuError
;
168 } flightLogEventData_t
;
170 typedef struct flightLogEvent_s
{
171 FlightLogEvent event
;
172 flightLogEventData_t data
;