did anyone do it?
INLINE
}extern "C" {
#ifdef IPHONE
void iPhoneLocation_Init();
int iPhoneLocation_Enable(int enable);
int iPhoneLocation_Poll(float* latitude, float* longitude, float* altitude, float* speed, float* heading);
void iPhoneKeepAwake(int bKeepAwake);
#else
void iPhoneLocation_Init() {}
int iPhoneLocation_Enable(int enable) {return 1;}
int iPhoneLocation_Poll(float* latitude, float* longitude, float* altitude, float* speed, float* heading)
{
*latitude=48.717417; *longitude=11.49882;
*altitude=512; *speed=0; *heading=0;
// ok go about 100km/h north
static double t1=GETTIMERALL();
double t = (GETTIMERALL() - t1)/1000. / 60.0 / 60.0; // hours
*latitude=48.717417 - 0.1 * t;
return 1;
}
void iPhoneKeepAwake(int bKeepAwake){}
#endif
} namespace __GLBASIC__{
ENDINLINE
code
INLINE
iPhoneLocation_Init();
if(!iPhoneLocation_Enable(TRUE))
{
ConsolePrt(CGStr("Failed to init location"));
return FALSE;
}
ENDINLINE
LOCAL lat, lon
LOCAL bGotGPS%=FALSE
INLINE
float latitude=0.0f, longitude=0.0f, altitude, speed, heading;
if(iPhoneLocation_Poll(&latitude, &longitude, &altitude, &speed, &heading))
{
lat = latitude;
lon = longitude;
bGotGPS=TRUE;
}
ENDINLINE
Like this, sort of...
The "heading" value should be what the compass returns if available. Otherwise it's extrapolated from the moving direction.
im getting this weird error
"gpc_temp0.cpp:151: error: expected unqualified-id before "if"
???
uh-huh.
Can you open the file %Temp%\glbasic\gpc_temp0.cpp and see what line 151 is?
/* ---- ENDINLINE ---- */
#undef __GLBNO__
#define __GLBNO__ 31
//NDIF.
#undef __GLBNO__
#define __GLBNO__ 32
return 0;
} // end main
// ------------------------ //
DGInt __end_main__foo__()
{
__PPRegisterFunction
return 0;
}
void __GLB_Defaults(){
__DG_RESX=640;
__DG_RESY=480;
__DG_FULLSCREEN=0;
__DG_MULTISAMPLE=0;
__DG_FRAMERATE=60;
__DG_DEBUG=0;
__DG_WANTMOUSE=GLB_WANTMOUSE_AT_START;
__DG_SCHOOLVER=0;
__g_AppName= "gps";
}
#include "glblicence.inc"
} // namespace
See the attached file.
// -------------------------------------------------------
// distance between 2 GPS points in [m]
// -------------------------------------------------------
FUNCTION GPS_dist: lat1, lon1, lat2, lon2
CONSTANT R = 6371000
CONSTANT PI = 3.14159265358979323846264338327950288
LOCAL dLat, dLon, a,c,d
dLat = (lat2 - lat1)
dLon = (lon2 - lon1)
a = SIN(dLat / 2) * SIN(dLat / 2) + COS(lat1) * COS(lat2) * SIN(dLon / 2) * SIN(dLon / 2)
c = 2.0 * ATAN(SQR(a), SQR(1.0 - a))*PI/180.0
d = R * c
RETURN d
ENDFUNCTION
This might be handy as well.
[attachment deleted by admin]
i got this trying to compile:
glbasic\gpc_temp0.cpp:124: error: expected unqualified-id before "return"
*** FATAL ERROR - Please post this output in the forum
here is the c code from that line :
#undef __GLBNO__
#define __GLBNO__ 39
#undef __GLBNO__
#define __GLBNO__ 40
//Get GPS data. return TRUE/FALSE whether it got data or not..
#undef __GLBNO__
#define __GLBNO__ 41
#undef __GLBNO__
#define __GLBNO__ 42
return 0;
} // end main
// ------------------------ //
DGNat iPhoneGPS(DGInt& lat, DGInt& lon, DGInt& alt, DGInt& spd, DGInt& head)
{
__PPRegisterFunction
#undef __GLBNO__
#define __GLBNO__ 43
#undef __GLBNO__
#define __GLBNO__ 44
#undef __GLBNO__
#define __GLBNO__ 45
/* ---- INLINE ---- */
iPhoneLocation_Init();
if(!iPhoneLocation_Enable(TRUE))
any progress on this kitty?\
what version are you using? The file I attached compiles fine for me.
8.148
same error here also 8.148 IDE
no explizit, iphone
/cygdrive/C/DOKUME~1/Besitzer/LOKALE~1/Temp/glbasic/gpc_temp0.cpp:124: error: expected unqualified-id before 'return'
#include "gpc_temp.h"
void __GQuitNProfile()
{
__PPExportProf("profile.csv", __DATE__, __TIME__);
}
namespace __GLBASIC__{
#define CODEFILE_Str() (DGStr("vfff.gbas.gbas"))
void __glb_init_globals();
int __MainGameSub_(void)
{ __PPRegisterFunction
__glb_init_globals();
/* GBAS: Z:\glcode\GLBasic\vfff\vfff.gbas */
#undef __GLBNO__
#define __GLBNO__ 0
//--------------------------------- //.
#undef __GLBNO__
#define __GLBNO__ 1
//Project: SpyKit.
#undef __GLBNO__
#define __GLBNO__ 2
//Start: Wednesday, November 10, 2010.
#undef __GLBNO__
#define __GLBNO__ 3
//IDE Version: 8.148.
#undef __GLBNO__
#define __GLBNO__ 4
#undef __GLBNO__
#define __GLBNO__ 5
#undef __GLBNO__
#define __GLBNO__ 6
#undef __GLBNO__
#define __GLBNO__ 7
#undef __GLBNO__
#define __GLBNO__ 8
/* ---- INLINE ---- */
}extern "C" {
#ifdef IPHONE
void iPhoneLocation_Init();
int iPhoneLocation_Enable(int enable);
int iPhoneLocation_Poll(float* latitude, float* longitude, float* altitude, float* speed, float* heading);
#else
void iPhoneLocation_Init() {}
int iPhoneLocation_Enable(int enable) {return 1;}
int iPhoneLocation_Poll(float* latitude, float* longitude, float* altitude, float* speed, float* heading)
{
*latitude=48.717417;*longitude=11.49882;
*altitude=512;*speed=0;*heading=0;
//ok go about 100km/h north
static double t1=GETTIMERALL();
double t = (GETTIMERALL() - t1)/1000. / 60.0 / 60.0;//hours
*latitude=48.717417 - 0.1 * t;
return 1;
}
#endif
} namespace __GLBASIC__{
/* ---- ENDINLINE ---- */
#undef __GLBNO__
#define __GLBNO__ 38
#undef __GLBNO__
#define __GLBNO__ 39
#undef __GLBNO__
#define __GLBNO__ 40
//Get GPS data. return TRUE/FALSE whether it got data or not..
#undef __GLBNO__
#define __GLBNO__ 41
#undef __GLBNO__
#define __GLBNO__ 42
return 0;
} // end main
// ------------------------ //
DGNat iPhoneGPS(DGInt& lat, DGInt& lon, DGInt& alt, DGInt& spd, DGInt& head)
{
__PPRegisterFunction
#undef __GLBNO__
#define __GLBNO__ 43
#undef __GLBNO__
#define __GLBNO__ 44
#undef __GLBNO__
#define __GLBNO__ 45
/* ---- INLINE ---- */
iPhoneLocation_Init();
if(!iPhoneLocation_Enable(TRUE))
{
return FALSE;
}
/* ---- ENDINLINE ---- */
#undef __GLBNO__
#define __GLBNO__ 51
#undef __GLBNO__
#define __GLBNO__ 52
#undef __GLBNO__
#define __GLBNO__ 53
/* ---- INLINE ---- */
float latitude=0.0f, longitude=0.0f, altitude, speed, heading;
if(iPhoneLocation_Poll(&latitude, &longitude, &altitude, &speed, &heading))
{
lat = latitude;
lon = longitude;
alt = altitude;
spd = speed;
head= heading;
return TRUE;
}
/* ---- ENDINLINE ---- */
#undef __GLBNO__
#define __GLBNO__ 64
#undef __GLBNO__
#define __GLBNO__ 65
return FALSE;
#undef __GLBNO__
#define __GLBNO__ 66
return 0;
}
// ------------------------ //
DGInt __end_main__foo__()
{
__PPRegisterFunction
#undef __GLBNO__
#define __GLBNO__ 67
return 0;
}
void __GLB_Defaults(){
__DG_RESX=320;
__DG_RESY=480;
__DG_FULLSCREEN=1;
__DG_MULTISAMPLE=0;
__DG_FRAMERATE=60;
__DG_DEBUG=0;
__DG_WANTMOUSE=GLB_WANTMOUSE_AT_START;
__DG_SCHOOLVER=0;
__g_AppName= "vfff";
}
#include "glblicence.inc"
} // namespace
bug??!?
DUUUUDE!! Make that the 2nd file of your project, no the main program.
:shit: sry gernot
ok it compiles but what now?
how do you use it?
i call iPhoneGPS();
what do i need for params ?
i seems like i need to give it my location isnt it the other way around?
In your main program write:
// FUNCTION iPhoneGPS%: BYREF lat, BYREF lon, BYREF alt, BYREF spd, BYREF head
LOCAL lat, lon, alt, spd, head
IF iPhoneGPS(lat, lon, alt, spd, head)
STDOUT "You are here: "+lat+", "+lon+", "+alt+"\n"
ENDIF
It's BYREF, thus you get something in return. Like MOUSESTATE.
returns allway zero for all variables maybe this will not work with iphone first gen .
the spykit reads also error on this type of iphone so i guess its not my fault :S
the 1st gen has a too inaccurate positioning system. I try to loosen that restriction in a new update.
i seem to get an error if anoder gps program is paused or working
any ideas how to stop them and init the gps again?
10x
In the next update, the accuracy check is gone, and you can test the average accuracy in [m] with:
IMPORT "C" float iPhoneLocation_Accuracy()
same here :(
_______________________________________
*** Configuration: WIN32 ***
precompiling:
GPC - GLBasic Precompiler V.10.060 SN:b711f88f - 3D, NET
Wordcount:1 commands
compiling:
C:\DOCUME~1\PROPIE~1\CONFIG~1\Temp\glbasic\gpc_temp0.cpp:131: error: expected unqualified-id before "return"
*** FATAL ERROR - Please post this output in the forum
_______________________________________
*** Finished ***
Elapsed: 3.5 sec. Time: 18:54
Build: 0 succeeded.
*** 1 FAILED ***
// Get GPS data. return TRUE/FALSE whether it got data or not..
#undef __GLBNO__
#define __GLBNO__ 43
#undef __GLBNO__
#define __GLBNO__ 44
return 0;
} // end main
// ------------------------ //
DGNat iPhoneGPS(DGInt& lat, DGInt& lon, DGInt& alt, DGInt& spd, DGInt& head)
{
__PPRegisterFunction
#include "gpc_temp.h"
void __GQuitNProfile()
{
__PPExportProf("profile.csv", __DATE__, __TIME__);
}
namespace __GLBASIC__{
#define CODEFILE_Str() (DGStr("GPS.gbas"))
void __glb_init_globals();
int __MainGameSub_(void)
{ __PPRegisterFunction
__glb_init_globals();
/* GBAS: C:\Documents and Settings\Propietario\Mis documentos\GLBasic\GPS\GPS.gbas */
#undef __GLBNO__
#define __GLBNO__ 0
// --------------------------------- //.
#undef __GLBNO__
#define __GLBNO__ 1
// Project: GPS.
#undef __GLBNO__
#define __GLBNO__ 2
// Start: Wednesday, January 15, 2014.
#undef __GLBNO__
#define __GLBNO__ 3
// IDE Version: 11.559.
#undef __GLBNO__
#define __GLBNO__ 4
#undef __GLBNO__
#define __GLBNO__ 5
#undef __GLBNO__
#define __GLBNO__ 6
// SETCURRENTDIR("Media") // go to media files.
#undef __GLBNO__
#define __GLBNO__ 7
#undef __GLBNO__
#define __GLBNO__ 8
#undef __GLBNO__
#define __GLBNO__ 9
#undef __GLBNO__
#define __GLBNO__ 10
/* ---- INLINE ---- */
}extern "C" {
#ifdef IPHONE
void iPhoneLocation_Init();
int iPhoneLocation_Enable(int enable);
int iPhoneLocation_Poll(float* latitude, float* longitude, float* altitude, float* speed, float* heading);
#else
void iPhoneLocation_Init() {}
int iPhoneLocation_Enable(int enable) {return 1;}
int iPhoneLocation_Poll(float* latitude, float* longitude, float* altitude, float* speed, float* heading)
{
*latitude=48.717417; *longitude=11.49882;
*altitude=512; *speed=0; *heading=0;
// ok go about 100km/h north
static double t1=GETTIMERALL();
double t = (GETTIMERALL() - t1)/1000. / 60.0 / 60.0; // hours
*latitude=48.717417 - 0.1 * t;
return 1;
}
#endif
} namespace __GLBASIC__{
/* ---- ENDINLINE ---- */
#undef __GLBNO__
#define __GLBNO__ 40
#undef __GLBNO__
#define __GLBNO__ 41
#undef __GLBNO__
#define __GLBNO__ 42
// Get GPS data. return TRUE/FALSE whether it got data or not..
#undef __GLBNO__
#define __GLBNO__ 43
#undef __GLBNO__
#define __GLBNO__ 44
return 0;
} // end main
// ------------------------ //
DGNat iPhoneGPS(DGInt& lat, DGInt& lon, DGInt& alt, DGInt& spd, DGInt& head)
{
__PPRegisterFunction
#undef __GLBNO__
#define __GLBNO__ 45
#undef __GLBNO__
#define __GLBNO__ 46
#undef __GLBNO__
#define __GLBNO__ 47
/* ---- INLINE ---- */
iPhoneLocation_Init();
if(!iPhoneLocation_Enable(true))
{
return false;
}
/* ---- ENDINLINE ---- */
#undef __GLBNO__
#define __GLBNO__ 53
#undef __GLBNO__
#define __GLBNO__ 54
#undef __GLBNO__
#define __GLBNO__ 55
/* ---- INLINE ---- */
float latitude=0.0f, longitude=0.0f, altitude, speed, heading;
if(iPhoneLocation_Poll(&latitude, &longitude, &altitude, &speed, &heading))
{
lat = latitude;
lon = longitude;
alt = altitude;
spd = speed;
head= heading;
return true;
}
/* ---- ENDINLINE ---- */
#undef __GLBNO__
#define __GLBNO__ 66
#undef __GLBNO__
#define __GLBNO__ 67
return FALSE;
#undef __GLBNO__
#define __GLBNO__ 68
return 0;
}
// ------------------------ //
DGInt __end_main__foo__()
{
__PPRegisterFunction
#undef __GLBNO__
#define __GLBNO__ 74
return 0;
}
extern "C" void __GLB_Defaults(){
__DG_RESX=640;
__DG_RESY=480;
__DG_FULLSCREEN=0;
__DG_MULTISAMPLE=0;
__DG_FRAMERATE=60;
__DG_DEBUG=0;
__DG_WANTMOUSE=GLB_WANTMOUSE_AT_START;
__DG_SCHOOLVER=0;
__glb_AppName()= "GPS";
}
#include "glblicence.inc"
} // namespace
Nothing. Fixed. I just had to read better.
Thank you