279,7 → 279,7 |
// Returnvalue: '1' if a point was added |
//________________________________________________________________________________________________________________________________________ |
|
u8 GPX_TrackSegementAddPoint(GPX_Document_t *doc) |
u8 GPX_TrackSegementAddPoint(GPX_Document_t *doc,unsigned char part) |
{ |
|
u8 retvalue = 0; |
297,6 → 297,9 |
s16 i16_1; |
u8 u8_1, u8_2; |
// write <trkpt> tag |
switch(part) |
{ |
case 0: |
if(GPSData.Position.Latitude < 0) u8_1 = '-'; |
else u8_1 = '+'; |
i32_1 = abs(GPSData.Position.Latitude)/10000000L; |
309,6 → 312,8 |
i32_2 = abs(GPSData.Position.Longitude)%10000000L; |
sprintf(string, "lon=\"%c%ld.%07ld\">\r\n",u8_1, i32_1, i32_2); |
fputs_(string, doc->file); |
break; |
case 1: |
// write <ele> taga |
i32_2 = GPSData.Position.Altitude - NaviData.HomePosition.Altitude; |
if(i32_2 < 0) i32_2 = 0; // avoid negative altitudes in log |
325,6 → 330,8 |
// todo: add <extensions> tag with additional data to be logged |
sprintf(string, "<extensions>\r\n"); |
fputs_(string, doc->file); |
break; |
case 2: |
// Altimeter according to air pressure |
sprintf(string, "<Altimeter>%d,'%c'</Altimeter>\r\n", NaviData.Altimeter,FromFC_VarioCharacter); |
fputs_(string, doc->file); |
344,6 → 351,8 |
// Flight duration |
sprintf(string, "<FlightTime>%d</FlightTime>\r\n", NaviData.FlyingTime); |
fputs_(string, doc->file); |
break; |
case 3: |
// Ubat |
u8_1 = NaviData.UBat / 10; |
u8_2 = NaviData.UBat % 10; |
361,6 → 370,8 |
sprintf(string, "<RCQuality>%d</RCQuality>\r\n", FC.RC_Quality); |
fputs_(string, doc->file); |
// RC Received Signal Strength Indication |
break; |
case 4: |
sprintf(string, "<RCRSSI>%d</RCRSSI>\r\n", FC.RC_RSSI); |
fputs_(string, doc->file); |
// Compassind deg |
373,6 → 384,8 |
// Roll Angle in deg |
sprintf(string, "<RollAngle>%03d</RollAngle>\r\n", NaviData.AngleRoll); |
fputs_(string, doc->file); |
break; |
case 5: |
// magnetic field |
sprintf(string, "<MagnetField>%03d</MagnetField>\r\n",(u16) (EarthMagneticFieldFiltered/5)); |
fputs_(string, doc->file); |
384,6 → 397,8 |
fputs_(string, doc->file); |
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]); |
fputs_(string, doc->file); |
break; |
case 6: |
sprintf(string, "<AvaiableMotorPower>%03d</AvaiableMotorPower>\r\n",BL_MinOfMaxPWM); |
fputs_(string, doc->file); |
sprintf(string, "<FC_I2C_ErrorCounter>%03d</FC_I2C_ErrorCounter>\r\n",(s16)FC_I2C_ErrorConter); |
394,6 → 409,8 |
// NC Mode (contains the status) |
sprintf(string, "<NCFlag>0x%02X</NCFlag>\r\n", NCFlags); |
fputs_(string, doc->file); |
break; |
case 7: |
// Flags |
sprintf(string, "<FCFlags2>0x%02x,0x%02x</FCFlags2>\r\n",Logging_FCStatusFlags1,Logging_FCStatusFlags2); |
fputs_(string, doc->file); |
408,6 → 425,8 |
// Target Distance in dm |
sprintf(string, "<TargetDistance>%d</TargetDistance>\r\n", NaviData.TargetPositionDeviation.Distance); |
fputs_(string, doc->file); |
break; |
case 8: |
// RC Sticks as Nick/Roll/Yaw |
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]); |
fputs_(string, doc->file); |
419,6 → 438,8 |
fputs_(string, doc->file); |
sprintf(string, "</trkpt>\r\n"); |
fputs_(string, doc->file); |
break; |
} |
retvalue = 1; |
} |
} |
435,7 → 456,7 |
// Returnvalue: '1' if an gps coordinate was logged |
//________________________________________________________________________________________________________________________________________ |
|
u8 GPX_LoggGPSCoordinates(GPX_Document_t *doc) |
u8 GPX_LoggGPSCoordinates(GPX_Document_t *doc,unsigned char part) |
{ |
u8 retval = 0; |
while(doc->state != GPX_DOC_TRACKSEGMENT_OPENED) // automatic create document with default filename on the card. |
464,7 → 485,7 |
|
if(doc->state == GPX_DOC_TRACKSEGMENT_OPENED) // if the document was opened add coordinates to the document. |
{ |
retval = GPX_TrackSegementAddPoint(doc); // add a track segment point |
retval = GPX_TrackSegementAddPoint(doc,part); // add a track segment point |
} |
return(retval); |
} |