Subversion Repositories NaviCtrl

Rev

Rev 785 | Rev 844 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 785 Rev 802
1
#ifndef _WAYPOINTS_H
1
#ifndef _WAYPOINTS_H
2
#define _WAYPOINTS_H
2
#define _WAYPOINTS_H
3
 
3
 
4
#include "ubx.h"
4
#include "ubx.h"
5
 
5
 
6
#define POINT_TYPE_INVALID 255
6
#define POINT_TYPE_INVALID 255
7
#define POINT_TYPE_WP   0
7
#define POINT_TYPE_WP           0
8
#define POINT_TYPE_POI  1
8
#define POINT_TYPE_POI          1
9
#define POINT_TYPE_FS   2
9
#define POINT_TYPE_FS           2
10
#define POINT_TYPE_LAND 3
10
#define POINT_TYPE_LAND         3
-
 
11
#define POINT_TYPE_FLYZONE      4
11
 
12
 
12
// the waypoints list
13
// the waypoints list
13
#define MAX_LIST_LEN 101
14
#define MAX_LIST_LEN 101
14
 
15
 
15
typedef struct
16
typedef struct
16
{
17
{
17
        GPS_Pos_t Position;             // the gps position of the waypoint, see ubx.h for details
18
        GPS_Pos_t Position;             // the gps position of the waypoint, see ubx.h for details
18
        s16 Heading;                    // orientation, 0 no action, 1...360 fix heading, neg. = Index to POI in WP List
19
        s16 Heading;                    // orientation, 0 no action, 1...360 fix heading, neg. = Index to POI in WP List
19
        u8  ToleranceRadius;    // in meters, if the MK is within that range around the target, then the next target is triggered
20
        u8  ToleranceRadius;    // in meters, if the MK is within that range around the target, then the next target is triggered
20
        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
21
        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
21
        u8  Event_Flag;                 // future implementation
22
        u8  Event_Flag;                 // future implementation
22
        u8  Index;              // to indentify different waypoints, workaround for bad communications PC <-> NC
23
        u8  Index;              // to indentify different waypoints, workaround for bad communications PC <-> NC
23
        u8  Type;                               // typeof Waypoint
24
        u8  Type;                               // typeof Waypoint
24
        u8  WP_EventChannelValue;  // Will be transferred to the FC and can be used as Poti value there
25
        u8  WP_EventChannelValue;  // Will be transferred to the FC and can be used as Poti value there
25
        u8      AltitudeRate;           // rate to change the setpoint in steps of 0.1m/s
26
        u8      AltitudeRate;           // rate to change the setpoint in steps of 0.1m/s
26
        u8      Speed;                          // rate to change the Position(0 = max) in steps of 0.1m/s
27
        u8      Speed;                          // rate to change the Position(0 = max) in steps of 0.1m/s
27
        u8      CamAngle;                       // Camera servo angle in degree (255 -> POI-Automatic)
28
        u8      CamAngle;                       // Camera servo angle in degree (255 -> POI-Automatic)
28
        u8  Name[4];                // Name of that point (ASCII)
29
        u8  Name[4];                // Name of that point (ASCII)
29
        u8  AutoPhotoDistance;  // in [m]
30
        u8  AutoPhotoDistance;  // in [m]
30
    u8  reserve[1];                 // reserve
31
    u8  reserve[1];                 // reserve
31
} __attribute__((packed)) Point_t;
32
} __attribute__((packed)) Point_t;
32
 
33
 
33
 
34
 
34
#define WPL_STORE_TYPE_REL 0
35
#define WPL_STORE_TYPE_REL 0
35
#define WPL_STORE_TYPE_ABS 1
36
#define WPL_STORE_TYPE_ABS 1
36
 
37
 
37
typedef struct
38
typedef struct
38
{
39
{
39
        u8 Index;
40
        u8 Index;
40
        u8 res1;                  
41
        u8 res1;                  
41
        u8 OverwriteFile;         // 0 = no, 1 = yes
42
        u8 OverwriteFile;         // 0 = no, 1 = yes
42
        u8 reserved[7];
43
        u8 reserved[7];
43
        s8 Name[12];
44
        s8 Name[12];
44
} __attribute__((packed)) WPL_Store_t;
45
} __attribute__((packed)) WPL_Store_t;
45
 
46
 
46
extern WPL_Store_t WPL_Store;
47
extern WPL_Store_t WPL_Store;
47
 
48
 
48
// Init List, return TRUE on success
49
// Init List, return TRUE on success
49
u8 PointList_Init(void);
50
u8 PointList_Init(void);
50
// Clear List, return TRUE on success
51
// Clear List, return TRUE on success
51
u8 PointList_Clear(void);
52
u8 PointList_Clear(void);
52
// Returns number of points in the list
53
// Returns number of points in the list
53
u8 PointList_GetCount(void);
54
u8 PointList_GetCount(void);
54
// return pointer to point at position
55
// return pointer to point at position
55
Point_t* PointList_GetAt(u8 index);
56
Point_t* PointList_GetAt(u8 index);
56
// set a point in the list at index, returns its index on success, else 0
57
// set a point in the list at index, returns its index on success, else 0
57
u8 PointList_SetAt(Point_t* pPoint);
58
u8 PointList_SetAt(Point_t* pPoint);
58
// goto the first WP in the list and return pointer to it
59
// goto the first WP in the list and return pointer to it
59
Point_t* PointList_WPBegin(u32);
60
Point_t* PointList_WPBegin(u32);
60
// goto the last WP in the list and return pointer to it
61
// goto the last WP in the list and return pointer to it
61
Point_t* PointList_WPEnd(void);
62
Point_t* PointList_WPEnd(void);
62
// goto next WP in the list and return pointer to it
63
// goto next WP in the list and return pointer to it
63
Point_t* PointList_WPNext(void);
64
Point_t* PointList_WPNext(void);
64
// enables/disables waypoint function
65
// enables/disables waypoint function
65
void PointList_WPActive(u8 set);
66
void PointList_WPActive(u8 set);
66
// returns pointer to actual POI
67
// returns pointer to actual POI
67
Point_t* PointList_GetPOI(void);
68
Point_t* PointList_GetPOI(void);
68
// save actual point list to SD card
69
// save actual point list to SD card
69
#define WPL_ERROR                       0
70
#define WPL_ERROR                       0
70
#define WPL_OK                          1
71
#define WPL_OK                          1
71
#define WPL_FILEEXIST           2
72
#define WPL_FILEEXIST           2
72
#define WPL_NO_SDCARD_FOUND     3
73
#define WPL_NO_SDCARD_FOUND     3
73
#define WPL_NO_WAYPOINTS        4
74
#define WPL_NO_WAYPOINTS        4
74
u8 PointList_WriteToFile(WPL_Store_t * pWPL_Store);
75
u8 PointList_WriteToFile(WPL_Store_t * pWPL_Store);
75
// load actual point list from SD card
76
// load actual point list from SD card
76
u8 PointList_ReadFromFile(WPL_Store_t * pWPL_Store);
77
u8 PointList_ReadFromFile(WPL_Store_t * pWPL_Store);
77
// move actual point list to ref pos., the point in the list marked by RefIndex get the RefPos afterwards
78
// move actual point list to ref pos., the point in the list marked by RefIndex get the RefPos afterwards
78
u8 PointList_Move(u8 RefIndex, GPS_Pos_t* pRefPos, u16 RotationAngle);
79
u8 PointList_Move(u8 RefIndex, GPS_Pos_t* pRefPos, u16 RotationAngle);
79
// save actual gps positiin and heading to file
80
// save actual gps positiin and heading to file
80
u8 PointList_SaveSinglePoint(WPL_Store_t * pWPL_Store);
81
u8 PointList_SaveSinglePoint(WPL_Store_t * pWPL_Store);
81
// load target gps positiin and heading from file
82
// load target gps positiin and heading from file
82
u8 PointList_LoadSinglePoint(WPL_Store_t * pWPL_Store);
83
u8 PointList_LoadSinglePoint(WPL_Store_t * pWPL_Store);
-
 
84
 
-
 
85
s32 CheckPositionInFlyzone(s32 Longitude, s32 Latitude, u8 UpdateTimer);
83
 
86
 
84
extern u32 SD_WaypointTimeout; // Setting on SD-Card
87
extern u32 SD_WaypointTimeout; // Setting on SD-Card
85
extern void ClearWLP_Name(void);
88
extern void ClearWLP_Name(void);
86
extern s16 HeadingOld;
89
extern s16 HeadingOld;
87
extern Point_t PointList[MAX_LIST_LEN];
90
extern Point_t PointList[MAX_LIST_LEN];
88
extern u8 FsPointCnt;
91
extern u8 FsPointCnt;
89
 
92
 
90
extern u8  PointCount;
93
extern u8  PointCount;
91
extern u8  POICount;
94
extern u8  POICount;
92
extern u8  WPCount;
95
extern u8  WPCount;
93
 
-
 
-
 
96
extern u8  FlyzonePointCnt;
94
 
97
 
95
#endif // _WAYPOINTS_H
98
#endif // _WAYPOINTS_H
96
 
99