https://wiki.iot4.eu//wiki/index.php?title=Using_with_NeoGPS_and_Arduino&feed=atom&action=history
Using with NeoGPS and Arduino - Revision history
2024-03-28T08:49:20Z
Revision history for this page on the wiki
MediaWiki 1.39.3
https://wiki.iot4.eu//wiki/index.php?title=Using_with_NeoGPS_and_Arduino&diff=12679&oldid=prev
Admin: Created page with " <source lang=c++> #include <NMEAGPS.h> #define MAPLESERIAL #define DEBUG_PORT Serial #define PLATFORM "DUE" HardwareSerial &GPSport = Serial2; #define USING_GPS_PORT "Ser..."
2017-06-08T12:52:21Z
<p>Created page with " <source lang=c++> #include <NMEAGPS.h> #define MAPLESERIAL #define DEBUG_PORT Serial #define PLATFORM "DUE" HardwareSerial &GPSport = Serial2; #define USING_GPS_PORT "Ser..."</p>
<p><b>New page</b></p><div><br />
<source lang=c++><br />
#include <NMEAGPS.h><br />
<br />
#define MAPLESERIAL<br />
<br />
#define DEBUG_PORT Serial<br />
#define PLATFORM "DUE" <br />
HardwareSerial &GPSport = Serial2; <br />
#define USING_GPS_PORT "Serial2" <br />
<br />
<br />
static NMEAGPS gps; <br />
<br />
//----------------------------------------------------------------<br />
<br />
static void printL( Print & outs, int32_t degE7 );<br />
static void printL( Print & outs, int32_t degE7 )<br />
{<br />
// Extract and print negative sign<br />
if (degE7 < 0) {<br />
degE7 = -degE7;<br />
outs.print( '-' );<br />
}<br />
<br />
// Whole degrees<br />
int32_t deg = degE7 / 10000000L;<br />
outs.print( deg );<br />
outs.print( '.' );<br />
<br />
// Get fractional degrees<br />
degE7 -= deg*10000000L;<br />
<br />
// Print leading zeroes, if needed<br />
int32_t factor = 1000000L;<br />
while ((degE7 < factor) && (factor > 1L)){<br />
outs.print( '0' );<br />
factor /= 10L;<br />
}<br />
<br />
// Print fractional degrees<br />
outs.print( degE7 );<br />
}<br />
<br />
static void doSomeWork();<br />
<br />
static void doSomeWork( const gps_fix & fix )<br />
{<br />
// This is the best place to do your time-consuming work, right after<br />
// the RMC sentence was received. If you do anything in "loop()",<br />
// you could cause GPS characters to be lost, and you will not<br />
// get a good lat/lon.<br />
// For this example, we just print the lat/lon. If you print too much,<br />
// this routine will not get back to "loop()" in time to process<br />
// the next set of GPS data.<br />
<br />
if (fix.valid.location) {<br />
<br />
if ( fix.dateTime.seconds < 10 )<br />
DEBUG_PORT.print( '0' );<br />
DEBUG_PORT.print( fix.dateTime.seconds );<br />
DEBUG_PORT.print( ',' );<br />
<br />
// DEBUG_PORT.print( fix.latitude(), 6 ); // floating-point display<br />
// DEBUG_PORT.print( fix.latitudeL() ); // integer display<br />
printL( DEBUG_PORT, fix.latitudeL() ); // prints int like a float<br />
DEBUG_PORT.print( ',' );<br />
// DEBUG_PORT.print( fix.longitude(), 6 ); // floating-point display<br />
// DEBUG_PORT.print( fix.longitudeL() ); // integer display<br />
printL( DEBUG_PORT, fix.longitudeL() ); // prints int like a float<br />
<br />
DEBUG_PORT.print( ',' );<br />
if (fix.valid.satellites){<br />
DEBUG_PORT.print("Satellites:"); <br />
DEBUG_PORT.print( fix.satellites );<br />
}<br />
<br />
DEBUG_PORT.print( ',' );<br />
<br />
DEBUG_PORT.print( fix.speed(), 6 );<br />
DEBUG_PORT.print( F(" kn = ") );<br />
DEBUG_PORT.print( fix.speed_kph(), 6 );<br />
DEBUG_PORT.print( F(" kph") );<br />
<br />
} else {<br />
// No valid location data yet!<br />
DEBUG_PORT.print( '?' );<br />
}<br />
<br />
DEBUG_PORT.println();<br />
<br />
} // doSomeWork<br />
<br />
static void GPSloop();<br />
static void GPSloop()<br />
{<br />
while (gps.available( GPSport ))<br />
doSomeWork( gps.read() );<br />
<br />
} // GPSloop<br />
<br />
void setup() {<br />
// put your setup code here, to run once:<br />
Serial.begin(115200);<br />
GPSport.begin(9600); <br />
delay(1000);<br />
}<br />
<br />
void loop() {<br />
GPSloop();<br />
}<br />
<br />
</source></div>
Admin