Modifications

Sauter à la navigation Sauter à la recherche
1 158 octets ajoutés ,  8 mai 2012 à 11:31
Ligne 162 : Ligne 162 :     
[[Fichier:GpsUltimateParse.jpg]]
 
[[Fichier:GpsUltimateParse.jpg]]
 +
 +
In this sketch, we call '''GPS.read()''' within a once-a-millisecond timer (this is the same timer that runs the '''millis()''' command). Then in the main loop we can ask if a new chunk of data has been received by calling '''GPS.newNMEAreceived()''', if this returns '''true''' then we can ask the library to parse that data with '''GPS.parse(GPS.lastNMEA())'''.
 +
 +
We do have to keep querying and parsing in the main loop - its not possible to do this in an interrupt because then we'd be dropping GPS data by accident.
 +
 +
Once data is parsed, we can just ask for data from the library like '''GPS.day''', '''GPS.month''' and '''GPS.year''' for the current date. '''GPS.fix''' will be 1 if there is a fix, 0 if there is none. If we have a fix then we can ask for '''GPS.latitude''', GPS.longitude, '''GPS.speed''' (in knots, not mph or k/hr!), '''GPS.angle''', '''GPS.altitude''' (in centimeters) and '''GPS.satellites''' (number of satellites)
 +
 +
This should make it much easier to have location-based projects. We suggest keeping the update rate at 1Hz and request that the GPS only output RMC and GGA as the parser does not keep track of other data anyways.
    
== Source ==
 
== Source ==
29 836

modifications

Menu de navigation