/trunk/GPS.h |
---|
22,6 → 22,9 |
extern CAM_Orientation_t CAM_Orientation; |
extern Point_t* GPS_pWaypoint; |
extern u8 MaxNumberOfWaypoints; // should be 32 |
extern u32 AbsoluteFlyingRange; // Maximum distance that the MK is not allowed to exceed - keep zero if not used |
extern u32 AutoDescendRange; |
void GPS_Init(void); |
void GPS_Navigation(gps_data_t *pGPS_Data, GPS_Stick_t* pGPS_Stick); |
/trunk/compass.c |
---|
158,6 → 158,7 |
static u32 check_value_counter = 0; |
// check for new cal state |
Compass_UpdateCalState(); |
if(Compass_CalState) FC_is_Calibrated = 0; |
// initiate new compass communication |
switch(Compass_Device) |
{ |
/trunk/gpx.c |
---|
67,6 → 67,7 |
#include "analog.h" |
#include "main.h" |
#include "led.h" |
#include "timer2.h" |
//________________________________________________________________________________________________________________________________________ |
// Function: GPX_DocumentInit(GPX_Document_t *) |
409,6 → 410,10 |
// NC Mode (contains the status) |
sprintf(string, "<NCFlag>0x%02X</NCFlag>\r\n", NCFlags); |
fputs_(string, doc->file); |
sprintf(string, "<Servo>%d,%d,%d</Servo>\r\n", ServoParams.NickControl,ServoParams.RollControl,POI_KameraNick/10); // Raw Poti-Values of the Servo control and the POI_Nick in 1° |
fputs_(string, doc->file); |
sprintf(string, "<WP>%d,%d,%d</WP>\r\n",NaviData.WaypointIndex,NaviData.WaypointNumber,FC_WP_EventChannel); // x of y Waypoints and the actual value of the Event Channel |
fputs_(string, doc->file); |
break; |
case 7: |
// Flags |
/trunk/logging.c |
---|
64,6 → 64,7 |
#include "ssc.h" |
#include "settings.h" |
u8 SD_LoggingError = 0; |
#define LOG_FLUSH_INTERVAL 20000 // 20s |
208,6 → 209,7 |
UART1_PutString(logfilename); |
UART1_PutString("\r\n"); |
logtimer = SetDelay(10); // try again in open logfile in 10 mili sec |
SD_LoggingError = 1; |
} |
} |
else |
214,6 → 216,7 |
{ |
logfilestate = LOGFILE_ERROR; |
UART1_PutString("\r\nError getting free kml-file name\r\n"); |
SD_LoggingError = 2; |
} |
// else retry in next loop |
break; |
224,11 → 227,13 |
if(!KML_LoggGPSCoordinates(&logfile)) |
{ // error logging data |
UART1_PutString("\r\nError logging to kml-file\r\n"); |
SD_LoggingError = 3; |
KML_DocumentClose(&logfile); |
logfilestate = LOGFILE_ERROR; |
} |
else // sucessfully logged |
{ |
SD_LoggingError = 0; |
if(CheckDelay(flushtimer)) |
{ |
flushtimer = SetDelay(LOG_FLUSH_INTERVAL); |
259,6 → 264,7 |
else // could not be closed |
{ |
UART1_PutString("\r\nError closing kml-file\r\n"); |
SD_LoggingError = 4; |
logfilestate = LOGFILE_ERROR; |
} |
} |
337,6 → 343,7 |
UART1_PutString("\r\nError opening gpx-file: "); |
UART1_PutString(logfilename); |
UART1_PutString("\r\n"); |
SD_LoggingError = 11; |
logtimer = SetDelay(10); // try again in open logfile in 10 mili sec |
} |
} |
344,6 → 351,7 |
{ |
logfilestate = LOGFILE_ERROR; |
UART1_PutString("\r\nError getting free gpx-file name\r\n"); |
SD_LoggingError = 12; |
} |
// else retry in next loop |
part = 0; |
357,6 → 365,7 |
{ // error logging data |
UART1_PutString("\r\nError logging to gpx-file\r\n"); |
GPX_DocumentClose(&logfile); |
SD_LoggingError = 13; |
logfilestate = LOGFILE_ERROR; |
} |
else // successful log |
395,6 → 404,7 |
else // could not be closed |
{ |
UART1_PutString("\r\nError closing gpx-file\r\n"); |
SD_LoggingError = 14; |
logfilestate = LOGFILE_ERROR; |
part = 0; |
} |
409,6 → 419,7 |
// initialize logging |
void Logging_Init(void) |
{ |
SD_LoggingError = 0; |
LogCfg.KML_Interval = 500; //default |
Settings_GetParamValue(PID_KML_LOGGING, (u16*)&LogCfg.KML_Interval); // overwrite by settings value |
if(LogCfg.KML_Interval != 0 && LogCfg.KML_Interval < 500) LogCfg.KML_Interval = 500; |
430,6 → 441,7 |
if(SD_SWITCH) // a card is in slot |
{ |
if((logstate == LOGFILE_ERROR) && (FC.StatusFlags & FC_STATUS_START)) SD_LoggingError = 100; |
if(CheckDelay(logtimer)) |
{ |
logtimer = SetDelay(10); // faster makes no sense |
452,15 → 464,15 |
} |
else // a logging error has occured |
{ |
/* |
// /* |
// try to reinitialize sd-card when motors are not running |
if(!(FC.Flags & FCFLAG_MOTOR_RUN)) |
if(!(FC.StatusFlags & FC_STATUS_MOTOR_RUN)) |
{ |
if(Fat16_IsValid()) // wait for reinizialization of fat16 from outside |
{ |
Logging_Init(); // initialize the logs |
logstate = LOGFILE_IDLE; |
logtimer = SetDelay(10); // try next log in 10 mili sec |
logtimer = SetDelay(100); // try next log in 100 mili sec |
} |
else |
{ // retry in 5 seconds |
467,7 → 479,7 |
logtimer = SetDelay(5000); // try again in 5 sec |
} |
} // EOF motors are not running |
*/ |
// */ |
} //EOF logfile error |
} // EOF CheckDelay |
}// EOF Card in Slot |
/trunk/logging.h |
---|
3,5 → 3,6 |
void Logging_Init(void); |
void Logging_Update(void); // logs the current gps position to a kml file |
extern u8 SD_LoggingError; |
#endif //_LOGGING_H |
/trunk/main.c |
---|
220,6 → 220,12 |
sprintf(ErrorMSG,"ERR:FC Z-ACC"); |
newErrorCode = 15; |
} |
else if(NC_To_FC_Flags & NC_TO_FC_FLYING_RANGE) |
{ |
LED_RED_ON; |
sprintf(ErrorMSG,"ERR:Flying range!"); |
newErrorCode = 28; |
} |
else if(FC.Error[0] & FC_ERROR0_PRESSURE) |
{ |
LED_RED_ON; |
315,7 → 321,7 |
else if(NCFlags & NC_FLAG_RANGE_LIMIT && (FC.StatusFlags & FC_STATUS_FLY) && !ErrorCode) |
{ |
LED_RED_ON; |
sprintf(ErrorMSG,"ERR:Waypoint range "); |
sprintf(ErrorMSG,"ERR:GPS range "); |
newErrorCode = 25; |
DebugOut.StatusRed |= AMPEL_NC; |
} |
326,6 → 332,14 |
newErrorCode = 26; |
DebugOut.StatusRed |= AMPEL_NC; |
} |
else if(SD_LoggingError && Parameter.GlobalConfig3 & CFG3_NO_SDCARD_NO_START) |
{ |
LED_RED_ON; |
sprintf(ErrorMSG,"ERR:SD Logging aborted"); |
newErrorCode = 27; |
DebugOut.StatusRed |= AMPEL_NC; |
SD_LoggingError = 0; |
} |
else // no error occured |
{ |
StopNavigation = 0; |
/trunk/main.h |
---|
39,7 → 39,7 |
#define VERSION_SERIAL_MINOR 0 |
#ifndef FOLLOW_ME |
#define FC_SPI_COMPATIBLE 28 |
#define FC_SPI_COMPATIBLE 29 |
#else |
#define FC_SPI_COMPATIBLE 0xFF |
#endif |
/trunk/menu.c |
---|
240,7 → 240,7 |
break; |
case 5: // Navi Params 2 from FC |
LCD_printfxy(0,0,"Stick TS: %3i", Parameter.NaviStickThreshold); |
LCD_printfxy(0,1,"MaxRadius: %3i m", NaviData.OperatingRadius); |
LCD_printfxy(0,1,"MaxRadius: %3im", DebugOut.Analog[4]); |
LCD_printfxy(0,2,"WindCorr: %3i", Parameter.NaviWindCorrection); |
LCD_printfxy(0,3,"AccComp: %3i", Parameter.NaviSpeedCompensation); |
break; |
250,7 → 250,14 |
LCD_printfxy(0,2," I-Limit: %3i", Parameter.NaviGpsILimit); |
LCD_printfxy(0,3," D-Limit: %3i", Parameter.NaviGpsDLimit); |
break; |
case 7: |
case 7: // Max Ranges |
LCD_printfxy(0,0,"Maximum flying "); |
LCD_printfxy(0,1,"Range: %4im ", AbsoluteFlyingRange); |
LCD_printfxy(0,2,"Descend:%4im ", AutoDescendRange); |
if(!AbsoluteFlyingRange) LCD_printfxy(8,1,"disabled"); |
if(!AutoDescendRange) LCD_printfxy(8,2,"disabled"); |
break; |
case 8: |
LCD_printfxy(0,0,"Home Position"); |
if(NaviData.HomePosition.Status == INVALID) |
{ |
277,7 → 284,7 |
LCD_printfxy(0,3,"Alt:%c%04ld.%03ld m",sign, i1, i2); |
} |
break; |
case 8: |
case 9: |
LCD_printfxy(0,0,"Target Position"); |
if(NaviData.TargetPosition.Status == INVALID) |
{ |
304,22 → 311,22 |
LCD_printfxy(0,3,"Alt:%c%04ld.%03ld m",sign, i1, i2); |
} |
break; |
case 9: // RC stick controls from FC |
case 10: // RC stick controls from FC |
LCD_printfxy(0,0,"RC-Sticks" ); |
LCD_printfxy(0,1,"Ni:%4i Ro:%4i ",FC.StickNick, FC.StickRoll); |
LCD_printfxy(0,2,"Gs:%4i Ya:%4i ",FC.StickGas, FC.StickYaw); |
break; |
case 10: // RC poti controls from FC |
case 11: // RC poti controls from FC |
LCD_printfxy(0,0,"RC-Potis 1" ); |
LCD_printfxy(0,1,"Po1:%3i Po2:%3i ",FC.Poti[0], FC.Poti[1]); |
LCD_printfxy(0,2,"Po3:%3i Po4:%3i ",FC.Poti[2], FC.Poti[3]); |
break; |
case 11: // RC poti controls from FC |
case 12: // RC poti controls from FC |
LCD_printfxy(0,0,"RC-Potis 2" ); |
LCD_printfxy(0,1,"Po5:%3i Po6:%3i ",FC.Poti[4], FC.Poti[5]); |
LCD_printfxy(0,2,"Po7:%3i Po8:%3i ",FC.Poti[6], FC.Poti[7]); |
break; |
case 12: // attitude from FC |
case 13: // attitude from FC |
if(FromFlightCtrl.AngleNick < 0) sign = '-'; |
else sign = '+'; |
i1 = abs(FromFlightCtrl.AngleNick)/10; |
341,12 → 348,12 |
i2 = abs(FromFlightCtrl.AccRoll)%10; |
LCD_printfxy(0,3," AccRoll:%c%03ld.%01ld", sign, i1, i2); |
break; |
case 13: // gyros from FC |
case 14: // gyros from FC |
LCD_printfxy(0,0,"GyroNick: %4i", FromFlightCtrl.GyroNick); |
LCD_printfxy(0,1,"GyroRoll: %4i", FromFlightCtrl.GyroRoll); |
LCD_printfxy(0,2,"GyroYaw: %4i", FromFlightCtrl.GyroYaw); |
break; |
case 14: // Remote Control Level from FC |
case 15: // Remote Control Level from FC |
LCD_printfxy(0,0,"RC-Level: %3i", FC.RC_Quality); |
LCD_printfxy(0,1,"Ubat: %2i.%1i V", FC.BAT_Voltage/10, FC.BAT_Voltage%10); |
LCD_printfxy(0,2,"CompHeading: %3i", Compass_Heading); |
354,13 → 361,13 |
else sign = '+'; |
LCD_printfxy(0,3,"GeoMagDec: %c%i.%1i", sign, abs(GeoMagDec)/10,abs(GeoMagDec)%10); |
break; |
case 15: // User Parameter |
case 16: // User Parameter |
LCD_printfxy(0,0,"UP1:%3i UP2:%3i",Parameter.User1,Parameter.User2); |
LCD_printfxy(0,1,"UP3:%3i UP4:%3i",Parameter.User3,Parameter.User4); |
LCD_printfxy(0,2,"UP5:%3i UP6:%3i",Parameter.User5,Parameter.User6); |
LCD_printfxy(0,3,"UP7:%3i UP8:%3i",Parameter.User7,Parameter.User8); |
break; |
case 16: // magnetic field |
case 17: // magnetic field |
if(Compass_CalState) |
{ |
LCD_printfxy(0,0,"Calibration:"); |
411,7 → 418,7 |
} |
if(Keys & KEY3)Compass_SetCalState(0); // cancel |
break; |
case 17: |
case 18: |
if(GeoMagDec < 0) sign = '-'; |
else sign = '+'; |
LCD_printfxy(0,0,"Magnetic Field"); |
/trunk/settings.c |
---|
76,10 → 76,12 |
Parameter_t CFG_Parameter[] = |
{ |
//{PID , "1234567890123456" , Group, Value, Default, Min, Max }, |
{PID_KML_LOGGING , "KMLLOGGING " , 1, 500, 500, 0, 60000}, // the log interval for KML logging, 0 = off |
{PID_GPX_LOGGING , "GPXLOGGING " , 1, 1000, 1000, 0, 60000}, // the log interval for GPX logging, 0 = off |
{PID_GPS_AUTOCONFIG, "GPSAUTOCONFIG " , 1, 1, 1, 0, 1} |
//{PID , "1234567890123456" , Group, Value, Default, Min, Max }, |
{PID_KML_LOGGING , "KMLLOGGING " , 1, 500, 500, 0, 60000}, // the log interval for KML logging, 0 = off |
{PID_GPX_LOGGING , "GPXLOGGING " , 1, 1000, 1000, 0, 60000}, // the log interval for GPX logging, 0 = off |
{PID_ABSOLUTE_FLYING_RANGE , "MAX_FLYING_RANGE" , 1, 0, 0, 0, 60000}, // |
{PID_AUTO_DESCEND_RANGE , "DESCEND_RANGE " , 1, 0, 0, 0, 60000}, // |
{PID_GPS_AUTOCONFIG , "GPSAUTOCONFIG " , 1, 1, 1, 0, 1} |
}; |
/trunk/settings.h |
---|
7,7 → 7,9 |
{ |
PID_KML_LOGGING, |
PID_GPX_LOGGING, |
PID_GPS_AUTOCONFIG |
PID_GPS_AUTOCONFIG, |
PID_ABSOLUTE_FLYING_RANGE, |
PID_AUTO_DESCEND_RANGE |
} ParamId_t; |
void Settings_Init(void); |
/trunk/spi_slave.c |
---|
115,9 → 115,11 |
u8 FC_is_Calibrated = 0; |
u8 MotorCurrent[12]; |
u8 MotorTemperature[12]; |
u8 NC_To_FC_Flags = 0; |
u8 BL_MinOfMaxPWM; // indication if all BL-controllers run on full power |
u32 FC_I2C_ErrorConter; |
SPI_Version_t FC_Version; |
s16 POI_KameraNick = 0; |
//-------------------------------------------------------------- |
void SSP0_IRQHandler(void) |
331,14 → 333,15 |
if(NCRARAM_STATE_VALID == NCParams_GetValue(NCPARAMS_NEW_CAMERA_ELEVATION, &tmp)) // Elevation set via 'j' command |
{ |
ToFlightCtrl.Param.sInt[5] = tmp; |
POI_KameraNick = tmp; |
} |
else |
{ |
//if(FC.StatusFlags2 & FC_STATUS2_CAREFREE) // only, if carefree is active |
ToFlightCtrl.Param.sInt[5] = CAM_Orientation.Elevation; |
POI_KameraNick = CAM_Orientation.Elevation; |
//else ToFlightCtrl.Param.sInt[5] = 0; |
} |
ToFlightCtrl.Param.sInt[5] = POI_KameraNick; |
break; |
case SPI_NCCMD_VERSION: |
352,7 → 355,7 |
ToFlightCtrl.Param.Byte[7] = ErrorCode; |
ToFlightCtrl.Param.Byte[8] = NC_GPS_ModeCharacter; |
ToFlightCtrl.Param.Byte[9] = SerialLinkOkay; |
ToFlightCtrl.Param.Byte[10] = 0; |
ToFlightCtrl.Param.Byte[10] = NC_To_FC_Flags; |
ToFlightCtrl.Param.Byte[11] = 0; |
break; |
case SPI_MISC: |
697,7 → 700,6 |
default: |
break; |
} |
/* |
//+++++++++++++++++++++++++++++++++++++++++++++++++++ |
// Einkommentieren, falls der Flug simultert werden soll |
708,7 → 710,6 |
BL_MinOfMaxPWM = 255; |
//+++++++++++++++++++++++++++++++++++++++++++++++++++ |
*/ |
// every time we got new data from the FC via SPI call the navigation routine |
// and update GPSStick that are returned to FC |
GPS_Navigation(&GPSData, &(ToFlightCtrl.GPSStick)); |
/trunk/spi_slave.h |
---|
34,7 → 34,8 |
extern u32 FC_I2C_ErrorConter; |
extern u8 FromFC_VarioCharacter; |
extern u8 Logging_FCStatusFlags1,Logging_FCStatusFlags2; |
extern s16 POI_KameraNick; |
extern u8 NC_To_FC_Flags; |
typedef struct |
{ |
u8 Command; |
60,6 → 61,10 |
u8 Chksum; |
} __attribute__((packed)) FromFlightCtrl_t; |
//NC_To_FC_Flags |
#define NC_TO_FC_FLYING_RANGE 0x01 |
#define NC_TO_FC_EMERGENCY_LANDING 0x02 |
#define SPI_NCCMD_OSD_DATA 100 |
#define SPI_NCCMD_GPS_POS 101 |
#define SPI_NCCMD_GPS_TARGET 102 |
/trunk/uart1.c |
---|
81,7 → 81,7 |
#define FALSE 0 |
#define TRUE 1 |
#define ABO_TIMEOUT 4000 // disable abo after 4 seconds |
#define ABO_TIMEOUT 8000 // disable abo after 8 seconds |
u32 UART1_AboTimeOut = 0; |
u8 UART1_Request_VersionInfo = FALSE; |
478,7 → 478,13 |
} |
else |
{ // update WP in list at index |
UART1_Request_WritePoint = PointList_SetAt(pPoint); |
if(pPoint->Index > MaxNumberOfWaypoints) |
{ |
UART1_Request_WritePoint = 254; |
pPoint->Index = MaxNumberOfWaypoints; |
} |
else |
UART1_Request_WritePoint = PointList_SetAt(pPoint); |
if(FC.StatusFlags & FC_STATUS_FLY) PointList_WPActive(TRUE); |
if(UART1_Request_WritePoint == pPoint->Index) |
{ |
/trunk/waypoints.c |
---|
61,7 → 61,7 |
#include "uart1.h" |
// the waypoints list |
#define MAX_LIST_LEN 31 |
#define MAX_LIST_LEN 101 |
Point_t PointList[MAX_LIST_LEN]; |
u8 WPIndex = 0; // list index of GPS point representig the current WP, can be maximal WPCount |