Subversion Repositories Projects

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
805 - 1
// ///////////////////////////////////////////////////////////////////////////////
2
// Copyright (C) 2010, Frank Blumenberg
3
//
4
// See License.txt for complete licensing and attribution information.
5
// Permission is hereby granted, free of charge, to any person obtaining a copy
6
// of this software and associated documentation files (the "Software"), to deal
7
// in the Software without restriction, including without limitation the rights
8
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
// copies of the Software, and to permit persons to whom the Software is
10
// furnished to do so, subject to the following conditions:
11
//
12
// The above copyright notice and this permission notice shall be included in all
13
// copies or substantial portions of the Software.
14
//
15
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
// THE SOFTWARE.
22
//
23
// ///////////////////////////////////////////////////////////////////////////////
24
 
25
typedef enum {
26
  MKAddressAll   =0,
27
  MKAddressFC    =1,
28
  MKAddressNC    =2,
29
  MKAddressMK3MAg=3,
30
  MKAddressMKGPS =0XFE
31
} MKAddress;
32
 
33
static const int kMaxDebugData = 32;
34
 
35
typedef enum {
36
  MKCommandDebugValueRequest='d',
37
  MKCommandDebugValueResponse='D',
38
  MKCommandDebugLabelRequest='a',
39
  MKCommandDebugLabelResponse='A',
40
  MKCommandVersionRequest='v',
41
  MKCommandVersionResponse='V',
42
  MKCommandLcdMenuRequest='l',
43
  MKCommandLcdMenuResponse='L',
44
  MKCommandLcdRequest='h',
45
  MKCommandLcdResponse='H',
46
  MKCommandReadSettingsRequest='q',
47
  MKCommandReadSettingsResponse='Q',
48
  MKCommandWriteSettingsRequest='s',
49
  MKCommandWriteSettingsResponse='S',
50
  MKCommandChangeSettingsRequest='f',
51
  MKCommandChangeSettingsResponse='F',
52
  MKCommandChannelsValueRequest='p',
53
  MKCommandChannelsValueResponse='P',
54
  MKCommandMixerReadRequest='n',
55
  MKCommandMixerReadResponse='N',
56
  MKCommandMixerWriteRequest='m',
57
  MKCommandMixerWriteResponse='M',
58
  MKCommandRedirectRequest='u',
59
  MKCommandEngineTestRequest='t',
60
  MKCommandOsdRequest='o',
61
  MKCommandOsdResponse='O',
62
} MKCommandId;
63
 
64
 
65
typedef struct
66
{
67
  uint8_t SWMajor;
68
  uint8_t SWMinor;
69
  uint8_t ProtoMajor;
70
  uint8_t ProtoMinor;
71
  uint8_t SWPatch;
72
  uint8_t Reserved[5];
73
} VersionInfo;
74
 
75
typedef struct
76
{
77
  uint8_t Digital[2];
78
  uint16_t Analog[32];    // Debugvalues
79
} DebugOut;
80
 
81
typedef struct
82
{
83
  char Revision;
84
  char Name[12];
85
  signed char Motor[16][4];
86
} Mixer;
87
 
88
typedef struct
89
{
90
  unsigned char Kanalbelegung[12];       // GAS[0], GIER[1],NICK[2], ROLL[3], POTI1, POTI2, POTI3
91
  unsigned char GlobalConfig;           // 0x01=H?henregler aktiv,0x02=Kompass aktiv, 0x04=GPS aktiv, 0x08=Heading Hold aktiv
92
  unsigned char Hoehe_MinGas;           // Wert : 0-100
93
  unsigned char Luftdruck_D;            // Wert : 0-250
94
  unsigned char MaxHoehe;               // Wert : 0-32
95
  unsigned char Hoehe_P;                // Wert : 0-32
96
  unsigned char Hoehe_Verstaerkung;     // Wert : 0-50
97
  unsigned char Hoehe_ACC_Wirkung;      // Wert : 0-250
98
  unsigned char Hoehe_HoverBand;        // Wert : 0-250
99
  unsigned char Hoehe_GPS_Z;            // Wert : 0-250
100
  unsigned char Hoehe_StickNeutralPoint;// Wert : 0-250
101
  unsigned char Stick_P;                // Wert : 1-6
102
  unsigned char Stick_D;                // Wert : 0-64
103
  unsigned char Gier_P;                 // Wert : 1-20
104
  unsigned char Gas_Min;                // Wert : 0-32
105
  unsigned char Gas_Max;                // Wert : 33-250
106
  unsigned char GyroAccFaktor;          // Wert : 1-64
107
  unsigned char KompassWirkung;         // Wert : 0-32
108
  unsigned char Gyro_P;                 // Wert : 10-250
109
  unsigned char Gyro_I;                 // Wert : 0-250
110
  unsigned char Gyro_D;                 // Wert : 0-250
111
  unsigned char Gyro_Gier_P;                 // Wert : 10-250
112
  unsigned char Gyro_Gier_I;                 // Wert : 0-250
113
  unsigned char UnterspannungsWarnung;  // Wert : 0-250
114
  unsigned char NotGas;                 // Wert : 0-250     //Gaswert bei Emp?ngsverlust
115
  unsigned char NotGasZeit;             // Wert : 0-250     // Zeitbis auf NotGas geschaltet wird, wg. Rx-Problemen
116
  unsigned char Receiver;                        // 0= Summensignal, 1= Spektrum, 2 =Jeti, 3=ACT DSL, 4=ACT S3D
117
  unsigned char I_Faktor;               // Wert : 0-250
118
  unsigned char UserParam1;             // Wert : 0-250
119
  unsigned char UserParam2;             // Wert : 0-250
120
  unsigned char UserParam3;             // Wert : 0-250
121
  unsigned char UserParam4;             // Wert : 0-250
122
  unsigned char ServoNickControl;       // Wert : 0-250     // Stellung des Servos
123
  unsigned char ServoNickComp;          // Wert : 0-250     // Einfluss Gyro/Servo
124
  unsigned char ServoNickMin;           // Wert : 0-250     // Anschlag
125
  unsigned char ServoNickMax;           // Wert : 0-250     // Anschlag
126
  unsigned char ServoRollControl;       // Wert : 0-250     // Stellung des Servos
127
  unsigned char ServoRollComp;          // Wert : 0-250
128
  unsigned char ServoRollMin;           // Wert : 0-250
129
  unsigned char ServoRollMax;           // Wert : 0-250
130
  unsigned char ServoNickRefresh;       // Speed of the Servo
131
  unsigned char Servo3;                  // Value or mapping of the Servo Output
132
  unsigned char Servo4;                          // Value or mapping of the Servo Output
133
  unsigned char Servo5;                          // Value or mapping of the Servo Output
134
  unsigned char LoopGasLimit;           // Wert: 0-250  max. Gas w?hrend Looping
135
  unsigned char LoopThreshold;          // Wert: 0-250  Schwelle f?r Stickausschlag
136
  unsigned char LoopHysterese;          // Wert: 0-250  Hysterese f?r Stickausschlag
137
  unsigned char AchsKopplung1;          // Wert: 0-250  Faktor, mit dem Gier die Achsen Roll und Nick koppelt (NickRollMitkopplung)
138
  unsigned char AchsKopplung2;          // Wert: 0-250  Faktor, mit dem Nick und Roll verkoppelt werden
139
  unsigned char CouplingYawCorrection;  // Wert: 0-250  Faktor, mit dem Nick und Roll verkoppelt werden
140
  unsigned char WinkelUmschlagNick;     // Wert: 0-250  180?-Punkt
141
  unsigned char WinkelUmschlagRoll;     // Wert: 0-250  180?-Punkt
142
  unsigned char GyroAccAbgleich;        // 1/k  (Koppel_ACC_Wirkung)
143
  unsigned char Driftkomp;
144
  unsigned char DynamicStability;
145
  unsigned char UserParam5;             // Wert : 0-250
146
  unsigned char UserParam6;             // Wert : 0-250
147
  unsigned char UserParam7;             // Wert : 0-250
148
  unsigned char UserParam8;             // Wert : 0-250
149
  unsigned char J16Bitmask;             // for the J16 Output
150
  unsigned char J16Timing;              // for the J16 Output
151
  unsigned char J17Bitmask;             // for the J17 Output
152
  unsigned char J17Timing;              // for the J17 Output
153
  unsigned char WARN_J16_Bitmask;       // for the J16 Output
154
  unsigned char WARN_J17_Bitmask;       // for the J17 Output
155
  unsigned char NaviGpsModeControl;     // Parameters for the Naviboard
156
  unsigned char NaviGpsGain;
157
  unsigned char NaviGpsP;
158
  unsigned char NaviGpsI;
159
  unsigned char NaviGpsD;
160
  unsigned char NaviGpsPLimit;
161
  unsigned char NaviGpsILimit;
162
  unsigned char NaviGpsDLimit;
163
  unsigned char NaviGpsACC;
164
  unsigned char NaviGpsMinSat;
165
  unsigned char NaviStickThreshold;
166
  unsigned char NaviWindCorrection;
167
  unsigned char NaviSpeedCompensation;
168
  unsigned char NaviOperatingRadius;
169
  unsigned char NaviAngleLimitation;
170
  unsigned char NaviPH_LoginTime;
171
  unsigned char ExternalControl;        // for serial Control
172
  unsigned char BitConfig;          // (war Loop-Cfg) Bitcodiert: 0x01=oben, 0x02=unten, 0x04=links, 0x08=rechts / wird getrennt behandelt
173
  unsigned char ServoCompInvert;    // //  0x01 = Nick, 0x02 = Roll   0 oder 1  // WICHTIG!!! am Ende lassen
174
  unsigned char ExtraConfig;        // bitcodiert
175
  char Name[12];
176
} MKSetting;
177
 
178
#define CFG_HOEHENREGELUNG       0x01
179
#define CFG_HOEHEN_SCHALTER      0x02
180
#define CFG_HEADING_HOLD         0x04
181
#define CFG_KOMPASS_AKTIV        0x08
182
#define CFG_KOMPASS_FIX          0x10
183
#define CFG_GPS_AKTIV            0x20
184
#define CFG_ACHSENKOPPLUNG_AKTIV 0x40
185
#define CFG_DREHRATEN_BEGRENZER  0x80
186
 
187
#define CFG_LOOP_OBEN            0x01
188
#define CFG_LOOP_UNTEN           0x02
189
#define CFG_LOOP_LINKS           0x04
190
#define CFG_LOOP_RECHTS          0x08
191
#define CFG_MOTOR_BLINK          0x10
192
#define CFG_MOTOR_OFF_LED1       0x20
193
#define CFG_MOTOR_OFF_LED2       0x40
194
#define CFG_RES4                 0x80
195
 
196
#define CFG2_HEIGHT_LIMIT        0x01
197
#define CFG2_VARIO_BEEP          0x02
198
#define CFG_SENSITIVE_RC         0x04
199
 
200
#define CFG2_INVERT_NICK         0x01
201
#define CFG2_INVERT_ROLL         0x02
202
 
203
//////////////////////////////////////////////////////////////////////////////////////////
204
 
205
typedef struct
206
{
207
  int16_t AngleNick;  // in 0.1 deg
208
  int16_t AngleRoll;   // in 0.1 deg
209
  int16_t Heading;    // in 0.1 deg
210
  uint8_t reserve[8];
211
} Data3D_t;
212
 
213
 
214
 
215
typedef struct
216
{
217
  int32_t Longitude;      // in 1E-7 deg
218
  int32_t Latitude;       // in 1E-7 deg
219
  int32_t Altitude;       // in mm
220
  uint8_t Status;         // validity of data
221
} __attribute__((packed)) GPS_Pos_t;
222
 
223
typedef struct
224
{
225
  uint16_t Distance;      // distance to target in dm
226
  int16_t Bearing;        // course to target in deg
227
}  __attribute__((packed)) GPS_PosDev_t;
228
 
229
typedef struct
230
{
231
  uint8_t      Version;         // version of the data structure
232
  GPS_Pos_t    CurrentPosition;         // see ubx.h for details
233
  GPS_Pos_t    TargetPosition;
234
  GPS_PosDev_t TargetPositionDeviation;
235
  GPS_Pos_t    HomePosition;
236
  GPS_PosDev_t HomePositionDeviation;
237
  uint8_t      WaypointIndex;           // index of current waypoints running from 0 to WaypointNumber-1
238
  uint8_t      WaypointNumber;          // number of stored waypoints
239
  uint8_t      SatsInUse;               // number of satellites used for position solution
240
  int16_t      Altimeter;               // hight according to air pressure
241
  int16_t      Variometer;              // climb(+) and sink(-) rate
242
  uint16_t     FlyingTime;              // in seconds
243
  uint8_t      UBat;                    // Battery Voltage in 0.1 Volts
244
  uint16_t     GroundSpeed;             // speed over ground in cm/s (2D)
245
  int16_t      Heading;         // current flight direction in ° as angle to north
246
  int16_t      CompassHeading;          // current compass value in °
247
  int8_t       AngleNick;               // current Nick angle in 1°
248
  int8_t       AngleRoll;               // current Rick angle in 1°
249
  uint8_t      RC_Quality;              // RC_Quality
250
  uint8_t      FCFlags;         // Flags from FC
251
  uint8_t      NCFlags;         // Flags from NC
252
  uint8_t      Errorcode;               // 0 --> okay
253
  uint8_t      OperatingRadius;               // current operation radius around the Home Position in m
254
  int16_t      TopSpeed;                // velocity in vertical direction in cm/s
255
  uint8_t      TargetHoldTime;          // time in s to stay at the given target, counts down to 0 if target has been reached
256
  uint8_t      RC_RSSI;         // Receiver signal strength (since version 2 added)
257
  int16_t      SetpointAltitude;                        // setpoint for altitude
258
  uint8_t      Gas;                                             // for future use
259
  uint16_t     Current;                                 // actual current in 0.1A steps
260
  uint16_t     UsedCapacity;                            // used capacity in mAh
261
 
262
} __attribute__((packed)) NaviData_t;
263
 
264
typedef struct
265
{
266
  GPS_Pos_t Position;          // the gps position of the waypoint, see ubx.h for details
267
  int16_t   Heading;           // orientation, future implementation
268
  uint8_t   ToleranceRadius;   // in meters, if the MK is within that range around the target, then the next target is triggered
269
  uint8_t   HoldTime;          // in seconds, if the was once in the tolerance area around a WP, this time defies the delay before the next WP is triggered
270
  uint8_t   Event_Flag;        // future emplementation
271
  uint8_t   reserve[12];       // reserve
272
} __attribute__((packed)) WayPoint_t;
273
 
274
 
275
#define NAVIDATA_VERSION 3
276
 
277
#define NC_FLAG_FREE            0x01
278
#define NC_FLAG_PH              0x02
279
#define NC_FLAG_CH              0x04
280
#define NC_FLAG_RANGE_LIMIT     0x08
281
#define NC_FLAG_NOSERIALLINK    0x10
282
#define NC_FLAG_TARGET_REACHED  0x20
283
#define NC_FLAG_MANUAL_CONTROL  0x40
284
#define NC_FLAG_8               0x80
285
 
286
#define FCFLAG_MOTOR_RUN        0x01
287
#define FCFLAG_FLY              0x02
288
#define FCFLAG_CALIBRATE        0x04
289
#define FCFLAG_START            0x08
290
#define FCFLAG_NOTLANDUNG       0x10
291
#define FCFLAG_LOWBAT           0x20
292
#define FCFLAG_SPI_RX_ERR       0x40
293
#define FCFLAG_I2CERR           0x80
294