Subversion Repositories NaviCtrl

Compare Revisions

Ignore whitespace Rev 344 → Rev 345

/trunk/gpx.c
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,7 → 438,9
fputs_(string, doc->file);
sprintf(string, "</trkpt>\r\n");
fputs_(string, doc->file);
retvalue = 1;
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);
}
/trunk/gpx.h
23,7 → 23,7
File_t *file; // filepointer to the file where the data should be saved.
} GPX_Document_t;
 
u8 GPX_LoggGPSCoordinates(GPX_Document_t *); // intializes the gpx-document with standard filename and adds points to the file
u8 GPX_LoggGPSCoordinates(GPX_Document_t *,unsigned char part); // intializes the gpx-document with standard filename and adds points to the file
u8 GPX_DocumentInit(GPX_Document_t *); // Init the new gpx-document
u8 GPX_DocumentOpen(s8 *, GPX_Document_t *); // opens a new gpx-document. a new file is created on the sd-memorycard
u8 GPX_DocumentClose(GPX_Document_t *doc); // closes the specified document saving remaining data to the file.
31,6 → 31,6
u8 GPX_TrackEnd(GPX_Document_t *doc); // ends the actual track
u8 GPX_TrackSegmentBegin(GPX_Document_t *doc); // begins a new tracksegment within the actual track
u8 GPX_TrackSegmentEnd(GPX_Document_t *doc); // ends the actual track segment within the actual track
u8 GPX_TrackSegmentAddPoint(GPX_Document_t *); // adds a point to the tracksegment
u8 GPX_TrackSegmentAddPoint(GPX_Document_t *,unsigned char part); // adds a point to the tracksegment
 
#endif //_GPX_H
/trunk/logging.c
276,6 → 276,8
static s8* logfilename = NULL; // the pointer to the logfilename
static u32 logtimer = 0, flushtimer = 0; // the log update timer
static GPX_Document_t logfile; // the logfilehandle
static u8 part = 0;
u32 measure_time;
 
// initialize if LogDelay is zero
if(!LogDelay)
295,11 → 297,11
return logfilestate;
}
// no init
if(CheckDelay(logtimer))
if(CheckDelay(logtimer) || part)
{
logtimer = SetDelay(LogDelay); // standard interval
 
if(FC.StatusFlags & FC_STATUS_MOTOR_RUN)
if(FC.StatusFlags & FC_STATUS_MOTOR_RUN || part)
{
switch(logfilestate)
{
309,6 → 311,7
{
logfilestate = LOGFILE_START;
}
part = 0;
break;
case LOGFILE_START:
// find unused logfile name
343,12 → 346,14
UART1_PutString("\r\nError getting free gpx-file name\r\n");
}
// else retry in next loop
part = 0;
break;
case LOGFILE_OPENED:
// append new gps log data
measure_time = CountMilliseconds;
if((GPSData.Status != INVALID) && (GPSData.Flags & FLAG_GPSFIXOK) && (GPSData.SatFix == SATFIX_3D))
{
if(!GPX_LoggGPSCoordinates(&logfile))
if(!GPX_LoggGPSCoordinates(&logfile,part))
{ // error logging data
UART1_PutString("\r\nError logging to gpx-file\r\n");
GPX_DocumentClose(&logfile);
363,12 → 368,16
}
}
}
if(++part == 9) part = 0;
DebugOut.Analog[19] = CountMilliseconds - measure_time;
break;
 
case LOGFILE_ERROR:
part = 0;
break;
 
default:
part = 0;
logfilestate = LOGFILE_IDLE;
break;
}
381,11 → 390,13
{
UART1_PutString("\r\nClosing gpx-file\r\n");
logfilestate = LOGFILE_CLOSED;
part = 0;
}
else // could not be closed
{
UART1_PutString("\r\nError closing gpx-file\r\n");
logfilestate = LOGFILE_ERROR;
part = 0;
}
}
} //EOF model is not flying
/trunk/main.h
14,7 → 14,7
 
#define VERSION_MAJOR 0
#define VERSION_MINOR 26
#define VERSION_PATCH 4
#define VERSION_PATCH 5
// 0 = A
// 1 = B
// 2 = C
/trunk/menu.c
412,6 → 412,8
if(Keys & KEY3)Compass_SetCalState(0); // cancel
break;
case 17:
if(GeoMagDec < 0) sign = '-';
else sign = '+';
LCD_printfxy(0,0,"Magnetic Field");
LCD_printfxy(0,1,"Field:%3i (Percent)",EarthMagneticField/5);
LCD_printfxy(0,2,"Declination:%c%i.%1i ", sign, abs(GeoMagDec)/10,abs(GeoMagDec)%10);
/trunk/spi_slave.c
292,8 → 292,10
// avoid sending data via SPI during the update of the ToFlightCtrl structure
VIC_ITCmd(SSP0_ITLine, DISABLE); // disable SPI interrupt
ToFlightCtrl.CompassHeading = Compass_Heading;
//ToFlightCtrl.CompassHeading += 360 + ((s32) FC.Poti[7] - 100);
 
//ToFlightCtrl.CompassHeading += 360 + ((s32) Poti8 - 128);
//ToFlightCtrl.CompassHeading %= 360;
 
DebugOut.Analog[10] = ToFlightCtrl.CompassHeading;
if(ToFlightCtrl.CompassHeading >= 0) ToFlightCtrl.CompassHeading = (360 + ToFlightCtrl.CompassHeading + FromFlightCtrl.GyroYaw / 12) % 360;
// ToFlightCtrl.MagVecX = MagVector.X;
/trunk/uart1.c
150,7 → 150,7
"16 ",
"17 ",
"18 ",
"19 ",
"19 SD-Card-time ",
"EarthMagnet [%] ", //20
"Z_Speed ",
"N_Speed ",