Subversion Repositories NaviCtrl

Compare Revisions

Ignore whitespace Rev 801 → Rev 802

/trunk/waypoints.c
74,6 → 74,7
u8 PointCount = 0; // number of points in the list can be maximal equal to MAX_LIST_LEN
u8 POICount = 0; // number of point of interest in the list
u8 FsPointCnt = 0;
u8 FlyzonePointCnt = 0;
s16 HeadingOld = -1;
u32 SD_WaypointTimeout = 5; // Setting on SD-Card
 
89,10 → 90,13
u8 i;
WPIndex = 0; // real list position are 1 ,2, 3 ...
POIIndex = 0; // real list position are 1 ,2, 3 ...
 
WPCount = 0; // no waypoints
FsPointCnt = 0;
POICount = 0;
PointCount = 0; // no contents
FlyzonePointCnt = 0;
 
WPActive = FALSE;
NaviData.WaypointNumber = WPCount;
NaviData.WaypointIndex = 0;
118,6 → 122,42
return TRUE;
}
 
 
s32 CheckPositionInFlyzone(s32 Longitude, s32 Latitude, u8 UpdateTimer)
{
#define POINTS 31
static Vec2D_t poly[POINTS+1];
Vec2D_t check_pos;
u32 z = 0;
u32 i;
s32 wn;
if(FlyzonePointCnt < 3) return(100); // too small - return 100
 
check_pos.x = Longitude >> 8;
check_pos.y = Latitude >> 8;
 
if(UpdateTimer == 0)
{
for(i=0; i < PointCount; i++)
{
if(PointList[i].Type == POINT_TYPE_FLYZONE)
{
poly[z].x = PointList[i].Position.Longitude >> 8;
poly[z].y = PointList[i].Position.Latitude >> 8;
z++;
if(z >= FlyzonePointCnt) break; // we found them all
if(z >= POINTS) break; // too many
}
}
// close polygon
poly[z].x = poly[0].x;
poly[z].y = poly[0].y;
}
wn = PointPolyCheck(check_pos,poly,FlyzonePointCnt);
return(wn);
}
 
 
u8 PointList_GetCount(void)
{
return PointCount; // number of points in the list
134,6 → 174,7
// if index is in range
if((pPoint->Index > 0) && (pPoint->Index <= MAX_LIST_LEN))
{
UpdateFlyzoneTimer = 2; // makes an update of the flightzone in some milliseconds
// check list entry before update
switch(PointList[pPoint->Index-1].Type)
{
160,6 → 201,10
FsPointCnt++;
PointCount++;
break;
case POINT_TYPE_FLYZONE:
FlyzonePointCnt++;
PointCount++;
break;
}
break;
170,12 → 215,11
WPCount--;
PointCount--;
break;
 
default:
case POINT_TYPE_LAND:
break;
case POINT_TYPE_WP:
FsPointCnt--;
FsPointCnt--; // the landing point is also a Failsafe-Pt
break;
case POINT_TYPE_FS:
FsPointCnt++;
185,6 → 229,10
POICount++;
WPCount--;
break;
case POINT_TYPE_FLYZONE:
FlyzonePointCnt++;
WPCount--;
break;
}
break;
case POINT_TYPE_WP:
197,7 → 245,7
 
default:
case POINT_TYPE_LAND:
FsPointCnt++;
FsPointCnt++; // the landing point is also a Failsafe-Pt
break;
case POINT_TYPE_WP:
//nothing to do
210,8 → 258,40
POICount++;
WPCount--;
break;
case POINT_TYPE_FLYZONE:
FlyzonePointCnt++;
WPCount--;
break;
}
break;
case POINT_TYPE_FLYZONE:
switch(pPoint->Type)
{
case POINT_TYPE_INVALID:
FlyzonePointCnt--;
PointCount--;
break;
default:
case POINT_TYPE_LAND:
FsPointCnt++; // the landing point is also a Failsafe-Pt
break;
case POINT_TYPE_WP:
WPCount++;
FlyzonePointCnt--;
break;
case POINT_TYPE_FLYZONE:
//nothing to do
break;
case POINT_TYPE_FS:
FsPointCnt++;
FlyzonePointCnt--;
break;
case POINT_TYPE_POI:
POICount++;
FlyzonePointCnt--;
break;
}
break;
case POINT_TYPE_POI: // was a poi
switch(pPoint->Type)
220,6 → 300,10
POICount--;
PointCount--;
break;
case POINT_TYPE_FS:
FsPointCnt++;
POICount--;
break;
 
case POINT_TYPE_LAND:
FsPointCnt++; // break fehlt absichtlich
227,12 → 311,10
WPCount++;
POICount--;
break;
 
case POINT_TYPE_FS:
FsPointCnt++;
case POINT_TYPE_FLYZONE:
FlyzonePointCnt++;
POICount--;
break;
case POINT_TYPE_POI:
default:
// nothing to do
245,19 → 327,20
FsPointCnt--;
PointCount--;
break;
 
case POINT_TYPE_LAND:
FsPointCnt++;
FsPointCnt++; // (wird gleich wieder abgezogen)
case POINT_TYPE_WP:
WPCount++;
FsPointCnt--;
break;
case POINT_TYPE_POI:
POICount++;
FsPointCnt--;
break;
 
case POINT_TYPE_FLYZONE:
FlyzonePointCnt++;
FsPointCnt--;
break;
case POINT_TYPE_FS:
break;
default:
701,6 → 784,9
case POINT_TYPE_POI:
POICount++;
break;
case POINT_TYPE_FLYZONE:
FlyzonePointCnt++;
break;
}
}
else if(strcmp(name, "PREFIX") == 0)
/trunk/waypoints.h
4,10 → 4,11
#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_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
81,6 → 82,8
// 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;
90,6 → 93,6
extern u8 PointCount;
extern u8 POICount;
extern u8 WPCount;
extern u8 FlyzonePointCnt;
 
 
#endif // _WAYPOINTS_H