Subversion Repositories Projects

Compare Revisions

Ignore whitespace Rev 412 → Rev 413

/FollowMe/temp/FollowMe/gps.c
81,7 → 81,7
}
 
// NC like sound on bad gps signals
if(FollowMe_active)
if(SysState == STATE_SEND_FOLLOWME)
{
if(!(GPSData.Flags & FLAG_GPSFIXOK) && !(beep_rythm % 5)) BeepTime = 100;
else if ((GPSData.NumOfSats < GPS_MINSATS) && !(beep_rythm % 5)) BeepTime = 10;
/FollowMe/temp/FollowMe/logging.c
59,7 → 59,7
#include "timer0.h"
#include "uart1.h"
#include "kml.h"
#include "gpx.h"
//#include "gpx.h"
#include "ssc.h"
#include "settings.h"
 
76,13 → 76,13
} logfilestate_t;
 
// logger handler prototypes
logfilestate_t Logging_KML(uint32_t LogDelay);
logfilestate_t Logging_GPX(uint32_t LogDelay);
logfilestate_t Logging_KML(uint16_t LogDelay);
//logfilestate_t Logging_GPX(uint16_t LogDelay);
 
typedef struct
{
uint32_t KML_Interval; // the kml-log interval (0 = off)
uint32_t GPX_Interval; // the gpx-log interval (0 = off)
uint16_t KML_Interval; // the kml-log interval (0 = off)
uint16_t GPX_Interval; // the gpx-log interval (0 = off)
} LogCfg_t;
 
LogCfg_t LogCfg = {500 , 1000};
114,6 → 114,7
}
 
//----------------------------------------------------------------------------------------------------
/*
int8_t* GenerateGPXLogFileName(void)
{
static uint16_t filenum = 0; // file name counter
137,16 → 138,16
}
else return NULL;
}
*/
 
 
 
//----------------------------------------------------------------------------------------------------
// logs the current gps position to a kml file
logfilestate_t Logging_KML(uint32_t LogDelay)
logfilestate_t Logging_KML(uint16_t LogDelay)
{
static logfilestate_t logfilestate = LOGFILE_IDLE; // the current logfilestate
static int8_t* logfilename = NULL; // the pointer to the logfilename
static uint32_t logtimer = 0, flushtimer = 0; // the log update timer
static uint16_t logtimer = 0, flushtimer = 0; // the log update timer
static KML_Document_t logfile; // the logfilehandle
 
// initialize if LogDelay os zero
171,13 → 172,13
{
logtimer = SetDelay(LogDelay); // standard interval
 
//if(FC.MKFlags & MKFLAG_MOTOR_RUN)
if(SysState == STATE_SEND_FOLLOWME)
{
switch(logfilestate)
{
case LOGFILE_IDLE:
case LOGFILE_CLOSED:
//if((GPSData.Status != INVALID) && (GPSData.Flags & FLAG_GPSFIXOK) && (GPSData.SatFix == SATFIX_3D) && (FC.MKFlags & MKFLAG_FLY))
if((GPSData.Status != INVALID) && (GPSData.Flags & FLAG_GPSFIXOK) && (GPSData.SatFix == SATFIX_3D))
{
logfilestate = LOGFILE_START;
}
245,8 → 246,8
logfilestate = LOGFILE_IDLE;
break;
}
} // EOF motors are not running
/*else // model is not flying
} // EOF follow me on
else // follow me off
{ // close log file if opened
if(logfilestate == LOGFILE_OPENED)
{
258,11 → 259,11
else // could not be closed
{
printf("\r\nError closing kml-file\r\n");
logfilestate = LOGFILE_ERROR;
logfilestate = LOGFILE_ERROR;
}
}
} //EOF motors are not running
*/
} //EOF follow me off
 
} // EOF Check LogTimer
 
return logfilestate;
269,12 → 270,13
}
 
//----------------------------------------------------------------------------------------------------
/*
// logs gps and state info to a gpx file
logfilestate_t Logging_GPX(uint32_t LogDelay)
logfilestate_t Logging_GPX(uint16_t LogDelay)
{
static logfilestate_t logfilestate = LOGFILE_IDLE; // the current logfilestate
static int8_t* logfilename = NULL; // the pointer to the logfilename
static uint32_t logtimer = 0, flushtimer = 0; // the log update timer
static uint16_t logtimer = 0, flushtimer = 0; // the log update timer
static GPX_Document_t logfile; // the logfilehandle
 
// initialize if LogDelay os zero
373,28 → 375,11
break;
}
} // EOF model is flying
/*
else // model is not flying
{ // close log file if opened
if(logfilestate == LOGFILE_OPENED)
{
if(GPX_DocumentClose(&logfile))
{
printf("\r\nClosing gpx-file\r\n");
logfilestate = LOGFILE_CLOSED;
}
else // could not be closed
{
printf("\r\nError closing gpx-file\r\n");
logfilestate = LOGFILE_ERROR;
}
}
} //EOF model is not flying
*/
} // EOF Check LogTimer
 
return logfilestate;
}
*/
 
//----------------------------------------------------------------------------------------------------
// initialize logging
403,9 → 388,9
LogCfg.KML_Interval = 500; //default
Settings_GetParamValue(PID_KML_LOGGING, (uint16_t*)&LogCfg.KML_Interval); // overwrite by settings value
Logging_KML(0); // initialize
LogCfg.GPX_Interval = 1000; //default
Settings_GetParamValue(PID_GPX_LOGGING, (uint16_t*)&LogCfg.GPX_Interval); // overwrite by settings value
Logging_GPX(0); // initialize
//LogCfg.GPX_Interval = 1000; //default
//Settings_GetParamValue(PID_GPX_LOGGING, (uint16_t*)&LogCfg.GPX_Interval); // overwrite by settings value
//Logging_GPX(0); // initialize
}
 
//----------------------------------------------------------------------------------------------------
412,7 → 397,7
// gobal logging handler
void Logging_Update(void)
{
static uint32_t logtimer = 0;
static uint16_t logtimer = 0;
static logfilestate_t logstate = LOGFILE_IDLE;
 
 
423,8 → 408,8
logtimer = SetDelay(10); // faster makes no sense
// call the logger handlers if no error has occured
if(logstate != LOGFILE_ERROR) logstate = Logging_KML(LogCfg.KML_Interval);
if(logstate != LOGFILE_ERROR) logstate = Logging_GPX(LogCfg.GPX_Interval);
//if(logstate != LOGFILE_ERROR) logstate = Logging_GPX(LogCfg.GPX_Interval);
 
// a logging error has occured
if(logstate == LOGFILE_ERROR)
{
/FollowMe/temp/FollowMe/main.c
14,7 → 14,7
#include "analog.h"
#include "gps.h"
#include "button.h"
//#include "logging.h"
#include "logging.h"
#include "settings.h"
 
#define FOLLOWME_INTERVAL 1000 // 1 second update
26,22 → 26,14
int16_t PowerOn = 0;
int16_t i = 0;
int16_t delay = 0;
int16_t FollowMe_active = 0;
#endif
 
uint16_t Error = 0;
SysState_t SysState = STATE_UNDEFINED;
 
typedef enum
{
STATE_UNDEFINED,
STATE_IDLE,
STATE_SEND_FOLLOWME
} SysState_t;
 
int main (void)
{
static uint16_t FollowMe_Timer = 0;
static SysState_t SysState = STATE_UNDEFINED;
 
// disable interrupts global
cli();
72,7 → 64,7
// initialize the settings
Settings_Init();
// initialize logging (needs settings)
//Logging_Init();
Logging_Init();
 
#ifdef USE_SDLOGGER
printf("\r\n\r\nHW: SD-Logger");
96,6 → 88,9
// get gps data to update the follow me position
GPS_Update();
 
// update logging
Logging_Update();
 
// check for button action and change state resectively
if(GetButton())
{
143,7 → 138,6
FollowMe_Timer = SetDelay(FOLLOWME_INTERVAL/4); // reset timer on higer frequency
}
LEDGRN_TOGGLE; // indication of active follow me
FollowMe_active = 1;
}
break;
 
150,7 → 144,6
case STATE_IDLE:
// do nothing
LEDGRN_ON;
FollowMe_active = 0;
break;
 
default:
/FollowMe/temp/FollowMe/main.h
5,12 → 5,20
#define SYSCLK F_CPU
 
 
typedef enum
{
STATE_UNDEFINED,
STATE_IDLE,
STATE_SEND_FOLLOWME
} SysState_t;
 
#define ERROR_GPS_RX_TIMEOUT 0x0001
#define ERROR_LOW_BAT 0x0002
 
extern uint16_t Error;
extern int16_t FollowMe_active;
extern int16_t UBat;
extern SysState_t SysState;
 
#endif //_MAIN_H
 
 
/FollowMe/temp/FollowMe/makefile
76,7 → 76,7
 
##########################################################################################################
# List C source files here. (C dependencies are automatically generated.)
SRC = main.c uart0.c uart1.c printf_P.c timer0.c menu.c led.c ubx.c analog.c button.c crc16.c ssc.c sdc.c fat16.c gps.c settings.c
SRC = main.c uart0.c uart1.c printf_P.c timer0.c menu.c led.c ubx.c analog.c button.c crc16.c ssc.c sdc.c fat16.c gps.c settings.c logging.c kml.c
 
##########################################################################################################
 
/FollowMe/temp/FollowMe/settings.c
141,7 → 141,7
uint8_t i;
char *tmp;
 
printf("\r\nSettings init...");
printf("\r\n Settings init...");
Settings_SetDefaultValues();
 
if(Fat16_IsValid())