Advertisement
peony3000

Gadgeteer GPS 01

Apr 3rd, 2012
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.23 KB | None | 0 0
  1. using System;
  2. using System.Threading;
  3. using Microsoft.SPOT;
  4. using Microsoft.SPOT.Presentation;
  5. using Microsoft.SPOT.Presentation.Controls;
  6. using Microsoft.SPOT.Presentation.Media;
  7. using Microsoft.SPOT.Touch;
  8.  
  9. using Gadgeteer.Networking;
  10. using GT = Gadgeteer;
  11. using GTM = Gadgeteer.Modules;
  12. using Gadgeteer.Modules.GHIElectronics;
  13. using Gadgeteer.Modules.Seeed;
  14.  
  15. namespace Gadgeteer_GPS_01
  16. {
  17.     public partial class Program
  18.     {
  19.        
  20.         GT.Timer timer = new GT.Timer(5000);
  21.         bool gpsPositionHasBeenReceived = false;
  22.  
  23.         void ProgramStarted()
  24.         {
  25.             //gps = new GTM.Seeed.GPS(8);
  26.             //gps.DebugPrintEnabled = true;
  27.             gps.InvalidPositionReceived += new GTM.Seeed.GPS.InvalidPositionReceivedHandler(gps_InvalidPositionReceived);
  28.             gps.PositionReceived += new GTM.Seeed.GPS.PositionReceivedHandler(gps_PositionReceived);
  29.             gps.NMEASentenceReceived+=new GPS.NMEASentenceReceivedHandler(gps_NMEASentenceReceived);
  30.            
  31.             // timer robot
  32.             timer.Tick += new GT.Timer.TickEventHandler(timer_Tick);
  33.             timer.Start();
  34.  
  35.             button.ButtonPressed += new Button.ButtonEventHandler(button_ButtonPressed);
  36.  
  37.             // tell
  38.             Debug.Print("Program Started");
  39.         }
  40.  
  41.         void button_ButtonPressed(Button sender, Button.ButtonState state)
  42.         {
  43.             Debug.Print("GPS last position " + gps.LastPosition + " age " + gps.LastValidPositionAge);
  44.         }
  45.  
  46.         void timer_Tick(GT.Timer timer)
  47.         {
  48.             Debug.Print("GPS last position " + gps.LastPosition + " age " + gps.LastValidPositionAge);
  49.         }
  50.  
  51.         void gps_InvalidPositionReceived(GTM.Seeed.GPS sender)
  52.         {
  53.             Debug.Print("Invalid position");
  54.         }
  55.  
  56.         void gps_PositionReceived(GTM.Seeed.GPS sender, GTM.Seeed.GPS.Position position)
  57.         {
  58.             gpsPositionHasBeenReceived = true;
  59.             Debug.Print(position);
  60.         }
  61.  
  62.         void gps_NMEASentenceReceived(GPS sender, string nmeaSentence)
  63.         {
  64.             if (!gpsPositionHasBeenReceived)
  65.             {
  66.                 Debug.Print("NMEA Sentence: " + nmeaSentence);
  67.             }
  68.         }
  69.  
  70.     }
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement