get gps on iphone

Previous topic - Next topic

Kitty Hello

In your main program write:

Code (glbasic) Select

// 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.

Marmor

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

Kitty Hello

the 1st gen has a too inaccurate positioning system. I try to loosen that restriction in a new update.

djtoon

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

Kitty Hello

In the next update, the accuracy check is gone, and you can test the average accuracy in [m] with:
Code (glbasic) Select

IMPORT "C" float iPhoneLocation_Accuracy()



msx

#20
same here  :(

Code (glbasic) Select

_______________________________________
*** 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 ***


Code (glbasic) Select
// 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



Code (glbasic) Select
#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

msx

Nothing. Fixed. I just had to read better.

Thank you