Subversion Repositories NaviCtrl

Rev

Rev 324 | Rev 339 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 324 Rev 338
Line 61... Line 61...
61
#include "gpx_header.h"
61
#include "gpx_header.h"
62
#include "timer1.h"
62
#include "timer1.h"
63
#include "spi_slave.h"
63
#include "spi_slave.h"
64
#include "main.h"
64
#include "main.h"
65
#include "uart1.h"
65
#include "uart1.h"
-
 
66
#include "compass.h"
-
 
67
#include "analog.h"
-
 
68
#include "main.h"
-
 
69
#include "led.h"
Line 66... Line 70...
66
 
70
 
67
//________________________________________________________________________________________________________________________________________
71
//________________________________________________________________________________________________________________________________________
68
// Function:    GPX_DocumentInit(GPX_Document_t *)
72
// Function:    GPX_DocumentInit(GPX_Document_t *)
69
//
73
//
Line 88... Line 92...
88
//
92
//
89
//
93
//
90
// Returnvalue: '1' if the gpx-file could be created.
94
// Returnvalue: '1' if the gpx-file could be created.
91
//________________________________________________________________________________________________________________________________________
95
//________________________________________________________________________________________________________________________________________
Line -... Line 96...
-
 
96
 
92
 
97
 
93
u8 GPX_DocumentOpen(s8 *name, GPX_Document_t *doc)
98
u8 GPX_DocumentOpen(s8 *name, GPX_Document_t *doc)
94
{
99
{
95
 
100
        s8 string[60];
Line 96... Line 101...
96
        u8 retvalue = 0;
101
        u8 retvalue = 0;
97
 
102
 
98
        if(doc == NULL) return(0);
103
        if(doc == NULL) return(0);
Line 99... Line 104...
99
        GPX_DocumentInit(doc);                                                                                                          // intialize the document with resetvalues
104
        GPX_DocumentInit(doc);                                                                                                          // intialize the document with resetvalues
100
        doc->file = fopen_(name,'a');                                                                                           // open a new file with the specified filename on the memorycard.
105
        doc->file = fopen_(name,'a');                                                                                           // open a new file with the specified filename on the memorycard.
101
 
106
 
102
        if(doc->file != NULL)                                                                                                           // could the file be opened?
107
        if(doc->file != NULL)                                                                                                           // could the file be opened?
103
        {
108
        {
-
 
109
                retvalue = 1;                                                                                                                   // the document could be created on the drive.
-
 
110
                doc->state = GPX_DOC_OPENED;                                                                                            // change document state to opened. At next a placemark has to be opened.
-
 
111
                fwrite_((void*)GPX_DOCUMENT_HEADER1, sizeof(GPX_DOCUMENT_HEADER1)-1,1,doc->file);// write the gpx-header to the document.
104
                retvalue = 1;                                                                                                                   // the document could be created on the drive.
112
                sprintf(string, "<desc>FC HW:%d.%d SW:%d.%d%c & NC HW:%d.%d SW:%d.%d%c</desc>\r\n", FC_Version.Hardware/10,FC_Version.Hardware%10, FC_Version.Major, FC_Version.Minor, 'a'+FC_Version.Patch, Version_HW/10, Version_HW%10, VERSION_MAJOR,  VERSION_MINOR, 'a'+ VERSION_PATCH);
105
                doc->state = GPX_DOC_OPENED;                                                                                            // change document state to opened. At next a placemark has to be opened.
-
 
-
 
113
                fputs_(string, doc->file);
-
 
114
                fwrite_((void*)GPX_DOCUMENT_HEADER2, sizeof(GPX_DOCUMENT_HEADER2)-1,1,doc->file);// write the gpx-header to the document.
106
                fwrite_((void*)GPX_DOCUMENT_HEADER, sizeof(GPX_DOCUMENT_HEADER)-1,1,doc->file);// write the gpx-header to the document.
115
        }
107
        }
116
        Logging_FCStatusFlags1 = 0;
Line 108... Line 117...
108
 
117
        Logging_FCStatusFlags2 = 0;
109
        return(retvalue);
118
        return(retvalue);
Line 153... Line 162...
153
                }
162
                }
154
        }
163
        }
155
        return(retvalue);
164
        return(retvalue);
156
}
165
}
Line -... Line 166...
-
 
166
 
-
 
167
 
157
 
168
 
158
//________________________________________________________________________________________________________________________________________
169
//________________________________________________________________________________________________________________________________________
159
// Function:    u8 GPX_TrackBegin(GPX_Document_t);
170
// Function:    u8 GPX_TrackBegin(GPX_Document_t);
160
//
171
//
161
// Description: This function adds a track to the document.
172
// Description: This function adds a track to the document.
Line 178... Line 189...
178
                }
189
                }
179
        }
190
        }
180
        return(retvalue);
191
        return(retvalue);
181
}
192
}
Line -... Line 193...
-
 
193
 
182
 
194
 
183
//________________________________________________________________________________________________________________________________________
195
//________________________________________________________________________________________________________________________________________
184
// Function:    u8 GPX_TrackEnd(KML_Document_t *doc)
196
// Function:    u8 GPX_TrackEnd(KML_Document_t *doc)
185
//
197
//
186
// Description: This function ends the track opened before.
198
// Description: This function ends the track opened before.
Line 269... Line 281...
269
 
281
 
270
u8 GPX_TrackSegementAddPoint(GPX_Document_t *doc)
282
u8 GPX_TrackSegementAddPoint(GPX_Document_t *doc)
Line 271... Line 283...
271
{
283
{
272
 
284
 
Line 273... Line 285...
273
        u8 retvalue = 0;
285
        u8 retvalue = 0;
Line 274... Line 286...
274
        s8 string[50];
286
        s8 string[100];
275
 
287
 
Line 312... Line 324...
312
                                fputs_(string, doc->file);
324
                                fputs_(string, doc->file);
313
                                // todo: add  <extensions> tag with additional data to be logged
325
                                // todo: add  <extensions> tag with additional data to be logged
314
                                sprintf(string, "<extensions>\r\n");
326
                                sprintf(string, "<extensions>\r\n");
315
                                fputs_(string, doc->file);
327
                                fputs_(string, doc->file);
316
                                // Altimeter according to air pressure
328
                                // Altimeter according to air pressure
317
                                sprintf(string, "<Altimeter>%d</Altimeter>\r\n", NaviData.Altimeter);
329
                                sprintf(string, "<Altimeter>%d,'%c'</Altimeter>\r\n", NaviData.Altimeter,FromFC_VarioCharacter);
318
                                fputs_(string, doc->file);
330
                                fputs_(string, doc->file);
319
                                // Variometer according to air pressure
331
                                // Variometer according to air pressure
320
                                sprintf(string, "<Variometer>%d</Variometer>\r\n", NaviData.Variometer);
332
                                sprintf(string, "<Variometer>%d</Variometer>\r\n", NaviData.Variometer);
321
                                fputs_(string, doc->file);
333
                                fputs_(string, doc->file);
322
                                // Course in deg
334
                                // Course in deg
Line 351... Line 363...
351
                                // RC Received Signal Strength Indication
363
                                // RC Received Signal Strength Indication
352
                                sprintf(string, "<RCRSSI>%d</RCRSSI>\r\n", FC.RC_RSSI);
364
                                sprintf(string, "<RCRSSI>%d</RCRSSI>\r\n", FC.RC_RSSI);
353
                                fputs_(string, doc->file);
365
                                fputs_(string, doc->file);
354
                                // Compassind deg
366
                                // Compassind deg
355
                                i16_1 = FromFlightCtrl.GyroHeading / 10;
367
                                i16_1 = FromFlightCtrl.GyroHeading / 10;
356
                                sprintf(string, "<Compass>%03d</Compass>\r\n", i16_1);
368
                                sprintf(string, "<Compass>%03d,%03d</Compass>\r\n", i16_1,ToFlightCtrl.CompassHeading);
357
                                fputs_(string, doc->file);
369
                                fputs_(string, doc->file);
358
                                // Nick Angle ind deg
370
                                // Nick Angle ind deg
359
                                sprintf(string, "<NickAngle>%03d</NickAngle>\r\n", NaviData.AngleNick);
371
                                sprintf(string, "<NickAngle>%03d</NickAngle>\r\n", NaviData.AngleNick);
360
                                fputs_(string, doc->file);
372
                                fputs_(string, doc->file);
361
                                // Roll Angle in deg
373
                                // Roll Angle in deg
362
                                sprintf(string, "<RollAngle>%03d</RollAngle>\r\n", NaviData.AngleRoll);
374
                                sprintf(string, "<RollAngle>%03d</RollAngle>\r\n", NaviData.AngleRoll);
363
                                fputs_(string, doc->file);
375
                                fputs_(string, doc->file);
-
 
376
                                // magnetic field 
-
 
377
                                sprintf(string, "<MagnetField>%03d</MagnetField>\r\n",(u16) (EarthMagneticField/5));
-
 
378
                                fputs_(string, doc->file);
-
 
379
                                // magnetic inclination & error 
-
 
380
                                sprintf(string, "<MagnetInclination>%02d,%02d</MagnetInclination>\r\n",(s16)EarthMagneticInclination,(s16)(EarthMagneticInclination - EarthMagneticInclinationTheoretic));
-
 
381
                                fputs_(string, doc->file);
-
 
382
                                // BL Information
-
 
383
                                sprintf(string, "<MotorCurrent>%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d</MotorCurrent>\r\n",MotorCurrent[0],MotorCurrent[1],MotorCurrent[2],MotorCurrent[3],MotorCurrent[4],MotorCurrent[5],MotorCurrent[6],MotorCurrent[7],MotorCurrent[8],MotorCurrent[9],MotorCurrent[10],MotorCurrent[11]);
-
 
384
                                fputs_(string, doc->file);
-
 
385
                                sprintf(string, "<BL_Temperature>%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d</BL_Temperature>\r\n",MotorTemperature[0],MotorTemperature[1],MotorTemperature[2],MotorTemperature[3],MotorTemperature[4],MotorTemperature[5],MotorTemperature[6],MotorTemperature[7],MotorTemperature[8],MotorTemperature[9],MotorTemperature[10],MotorTemperature[11]);
-
 
386
                                fputs_(string, doc->file);
-
 
387
                                sprintf(string, "<AvaiableMotorPower>%03d</AvaiableMotorPower>\r\n",BL_MinOfMaxPWM);
-
 
388
                                fputs_(string, doc->file);
-
 
389
                                sprintf(string, "<FC_I2C_ErrorCounter>%03d</FC_I2C_ErrorCounter>\r\n",(s16)FC_I2C_ErrorConter);
-
 
390
                                fputs_(string, doc->file);
-
 
391
                                // Analog inputs of the NC
-
 
392
                                sprintf(string, "<AnalogInputs>%d,%d,%d,%d</AnalogInputs>\r\n",AnalogData.Ch4,AnalogData.Ch5,AnalogData.Ch6,AnalogData.Ch7);
-
 
393
                                fputs_(string, doc->file);
364
                                // NC Mode (contains the status)
394
                                // NC Mode (contains the status)
365
                                sprintf(string, "<NCFlag>%02X</NCFlag>\r\n", NCFlags);
395
                                sprintf(string, "<NCFlag>0x%02X</NCFlag>\r\n", NCFlags);
366
                                fputs_(string, doc->file);
396
                                fputs_(string, doc->file);
-
 
397
                                // Flags
-
 
398
                                sprintf(string, "<FCFlags2>0x%02x,0x%02x</FCFlags2>\r\n",Logging_FCStatusFlags1,Logging_FCStatusFlags2);
-
 
399
                                fputs_(string, doc->file);
-
 
400
                                Logging_FCStatusFlags1 = 0;
-
 
401
                                Logging_FCStatusFlags2 = 0;
367
                                // Status of the complete MikroKopter
402
                                // Status of the complete MikroKopter
368
                                sprintf(string, "<ErrorCode>%03d</ErrorCode>\r\n",ErrorCode);
403
                                sprintf(string, "<ErrorCode>%03d</ErrorCode>\r\n",ErrorCode);
369
                                fputs_(string, doc->file);
404
                                fputs_(string, doc->file);
370
                                // Target Bearing in deg
405
                                // Target Bearing in deg
371
                                sprintf(string, "<TargetBearing>%03d</TargetBearing>\r\n", NaviData.TargetPositionDeviation.Bearing);
406
                                sprintf(string, "<TargetBearing>%03d</TargetBearing>\r\n", NaviData.TargetPositionDeviation.Bearing);
372
                                fputs_(string, doc->file);
407
                                fputs_(string, doc->file);
373
                                // Target Distance in dm
408
                                // Target Distance in dm
374
                                sprintf(string, "<TargetDistance>%d</TargetDistance>\r\n", NaviData.TargetPositionDeviation.Distance);
409
                                sprintf(string, "<TargetDistance>%d</TargetDistance>\r\n", NaviData.TargetPositionDeviation.Distance);
375
                                fputs_(string, doc->file);
410
                                fputs_(string, doc->file);
376
                                // RC Sticks as Nick/Roll/Yaw
411
                                // RC Sticks as Nick/Roll/Yaw
377
                                sprintf(string, "<RCSticks>%d, %d, %d</RCSticks>\r\n", FC.StickNick,FC.StickRoll, FC.StickYaw);
412
                                sprintf(string, "<RCSticks>%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d</RCSticks>\r\n", FC.StickNick,FC.StickRoll, FC.StickYaw, FC.StickGas,FC.Poti[0],FC.Poti[1],FC.Poti[2],FC.Poti[3],FC.Poti[4],FC.Poti[5],FC.Poti[6],FC.Poti[7]);
378
                                fputs_(string, doc->file);
413
                                fputs_(string, doc->file);
379
                                // GPS Sticks as Nick/Roll/Yaw
414
                                // GPS Sticks as Nick/Roll/Yaw
380
                                sprintf(string, "<GPSSticks>%d, %d, %d</GPSSticks>\r\n", ToFlightCtrl.GPSStick.Nick, ToFlightCtrl.GPSStick.Roll, ToFlightCtrl.GPSStick.Yaw);
415
                                sprintf(string, "<GPSSticks>%d,%d,%d,'%c'</GPSSticks>\r\n", ToFlightCtrl.GPSStick.Nick, ToFlightCtrl.GPSStick.Roll, ToFlightCtrl.GPSStick.Yaw,NC_GPS_ModeCharacter);
381
                                fputs_(string, doc->file);
416
                                fputs_(string, doc->file);
382
 
-
 
383
                                // eof extensions
417
                                // eof extensions
384
                                sprintf(string, "</extensions>\r\n");
418
                                sprintf(string, "</extensions>\r\n");
385
                                fputs_(string, doc->file);
419
                                fputs_(string, doc->file);
386
                                sprintf(string, "</trkpt>\r\n");
420
                                sprintf(string, "</trkpt>\r\n");
387
                                fputs_(string, doc->file);
421
                                fputs_(string, doc->file);