Subversion Repositories NaviCtrl

Compare Revisions

Ignore whitespace Rev 897 → Rev 898

/tags/V2.20h/waypoints.h
0,0 → 1,98
#ifndef _WAYPOINTS_H
#define _WAYPOINTS_H
 
#include "ubx.h"
 
#define POINT_TYPE_INVALID 255
#define POINT_TYPE_WP 0
#define POINT_TYPE_POI 1
#define POINT_TYPE_FS 2
#define POINT_TYPE_LAND 3
#define POINT_TYPE_FLYZONE 4
 
// the waypoints list
#define MAX_LIST_LEN 101
 
typedef struct
{
GPS_Pos_t Position; // the gps position of the waypoint, see ubx.h for details
s16 Heading; // orientation, 0 no action, 1...360 fix heading, neg. = Index to POI in WP List
u8 ToleranceRadius; // in meters, if the MK is within that range around the target, then the next target is triggered
u8 HoldTime; // in seconds, if the was once in the tolerance area around a WP, this time defines the delay before the next WP is triggered
u8 Event_Flag; // future implementation and simulation
u8 Index; // to indentify different waypoints, workaround for bad communications PC <-> NC
u8 Type; // typeof Waypoint
u8 WP_EventChannelValue; // Will be transferred to the FC and can be used as Poti value there
u8 AltitudeRate; // rate to change the setpoint in steps of 0.1m/s
u8 Speed; // rate to change the Position(0 = max) in steps of 0.1m/s
u8 CamAngle; // Camera servo angle in degree (255 -> POI-Automatic)
u8 Name[4]; // Name of that point (ASCII)
u8 AutoPhotoDistance; // in [m]
u8 reserve[1]; // reserve
} __attribute__((packed)) Point_t;
 
 
#define WPL_STORE_TYPE_REL 0
#define WPL_STORE_TYPE_ABS 1
 
typedef struct
{
u8 Index;
u8 res1;
u8 OverwriteFile; // 0 = no, 1 = yes
u8 reserved[7];
s8 Name[12];
} __attribute__((packed)) WPL_Store_t;
 
extern WPL_Store_t WPL_Store;
 
// Init List, return TRUE on success
u8 PointList_Init(void);
// Clear List, return TRUE on success
u8 PointList_Clear(void);
// Returns number of points in the list
u8 PointList_GetCount(void);
// return pointer to point at position
Point_t* PointList_GetAt(u8 index);
// set a point in the list at index, returns its index on success, else 0
u8 PointList_SetAt(Point_t* pPoint);
// goto the first WP in the list and return pointer to it
Point_t* PointList_WPBegin(u32);
// goto the last WP in the list and return pointer to it
Point_t* PointList_WPEnd(void);
// goto next WP in the list and return pointer to it
Point_t* PointList_WPNext(void);
// enables/disables waypoint function
void PointList_WPActive(u8 set);
// returns pointer to actual POI
Point_t* PointList_GetPOI(void);
// save actual point list to SD card
#define WPL_ERROR 0
#define WPL_OK 1
#define WPL_FILEEXIST 2
#define WPL_NO_SDCARD_FOUND 3
#define WPL_NO_WAYPOINTS 4
u8 PointList_WriteToFile(WPL_Store_t * pWPL_Store);
// load actual point list from SD card
u8 PointList_ReadFromFile(WPL_Store_t * pWPL_Store);
// move actual point list to ref pos., the point in the list marked by RefIndex get the RefPos afterwards
u8 PointList_Move(u8 RefIndex, GPS_Pos_t* pRefPos, u16 RotationAngle);
// save actual gps positiin and heading to file
u8 PointList_SaveSinglePoint(WPL_Store_t * pWPL_Store);
// load target gps positiin and heading from file
u8 PointList_LoadSinglePoint(WPL_Store_t * pWPL_Store);
 
s32 CheckPositionInFlyzone(s32 Longitude, s32 Latitude, u8 UpdateTimer);
 
extern u32 SD_WaypointTimeout; // Setting on SD-Card
extern void ClearWLP_Name(void);
extern s16 HeadingOld;
extern Point_t PointList[MAX_LIST_LEN];
extern u8 FsPointCnt;
 
extern u8 PointCount;
extern u8 POICount;
extern u8 WPCount;
extern u8 FlyzonePointCnt;
 
#endif // _WAYPOINTS_H