Page 2 of 2

Re: CSentry Android Smartphone; GPS function and button

Posted: August 26th, 2015, 4:01 pm
by alesson_aguiar
Hi, I got the example found in the forum and it is working well. I would like to put a button to get or not get coordinates. How can I do it and in which place in the code I should put it? I am so glad for any information.

Code: Select all

PROC GPS
gps(open,3,4800); // on a laptop or tablet; COM3, 4800 baud
gps(open); // on Android or the Pocket PC

if gps(read,10,"Aguarde...") then // 10 segundos buscando sinal, 
    errmsg("Latitude is %f, longitude is %f",gps(latitude),gps(longitude));
	latitude = gps(latitude);
	longitude = gps(longitude);
else
   errmsg("Ative o GPS");

endif;

gps(close);

Re: CSentry Android Smartphone; GPS function and button

Posted: August 27th, 2015, 7:33 am
by josh
You can create a userbar button as the example earlier in this post shows. You could also follow the same pattern as with the photo example (http://csprousers.org/forum/viewtopic.php?f=1&t=620). In your field GPS you create a value set 1) Take GPS 2) Skip GPS and if they choose 1 you do the code posted to read the GPS otherwise you don't. Unlike with the photo you probably want to store latitude and longitude in your data file so you would need to create those fields on the form and make sure that they are after the GPS field. When the user chooses to take the GPS you fill them in and then in the preproc of those fields use "noinput" so that the user doesn't get the chance to modify them. If the users chooses not take the GPS (option 2) then you skip over those fields.

If you want to get very fancy you can add a third option to the value set to view the captured coordinates like in the photo example and only show that option if the coordinates have already been captured using setvalueset() but that gets pretty complicated.

Re: CSentry Android Smartphone; GPS function and button

Posted: August 27th, 2015, 8:46 am
by alesson_aguiar
Ok Josh. I will try to do this. and then I will tell you if it worked.