Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added locus erase example

  • Loading branch information...
commit 319531f4d2c137ac1f34ec04d7eb4ab83d4aed4f 1 parent 513c915
Limor "Ladyada" Fried ladyada authored
Showing with 120 additions and 0 deletions.
  1. +5 −0 Adafruit_GPS.h
  2. +115 −0 examples/locus_erase/locus_erase.pde
5 Adafruit_GPS.h
View
@@ -25,6 +25,10 @@ All text above must be included in any redistribution
#define PMTK_SET_NMEA_UPDATE_5HZ "$PMTK220,200*2C"
#define PMTK_SET_NMEA_UPDATE_10HZ "$PMTK220,100*2F"
+
+#define PMTK_SET_BAUD_57600 "$PMTK250,1,0,57600*2C"
+#define PMTK_SET_BAUD_9600 "$PMTK250,1,0,9600*17"
+
// turn on only the second sentence (GPRMC)
#define PMTK_SET_NMEA_OUTPUT_RMCONLY "$PMTK314,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*29"
// turn on GPRMC and GGA
@@ -40,6 +44,7 @@ All text above must be included in any redistribution
#define PMTK_LOCUS_STARTLOG "$PMTK185,0*22"
#define PMTK_LOCUS_LOGSTARTED "$PMTK001,185,3*3C"
#define PMTK_LOCUS_QUERY_STATUS "$PMTK183*38"
+#define PMTK_LOCUS_ERASE_FLASH "$PMTK184,1*22"
#define LOCUS_OVERLAP 0
#define LOCUS_FULLSTOP 1
115 examples/locus_erase/locus_erase.pde
View
@@ -0,0 +1,115 @@
+// Test code for Adafruit GPS modules using MTK3329/MTK3339 driver
+//
+// This code erases the LOCUS built-in datalogger storage
+//
+// Tested and works great with the Adafruit Ultimate GPS module
+// using MTK33x9 chipset
+// ------> http://www.adafruit.com/products/746
+// Pick one up today at the Adafruit electronics shop
+// and help support open source hardware & software! -ada
+
+#include <Adafruit_GPS.h>
+#if ARDUINO >= 100
+ #include <SoftwareSerial.h>
+#else
+ // Older Arduino IDE requires NewSoftSerial, download from:
+ // http://arduiniana.org/libraries/newsoftserial/
+ #include <NewSoftwareSerial.h>
+ // DO NOT install NewSoftSerial if using Arduino 1.0 or later!
+#endif
+
+// Connect the GPS Power pin to 5V
+// Connect the GPS Ground pin to ground
+// If using software serial (sketch example default):
+// Connect the GPS TX (transmit) pin to Digital 3
+// Connect the GPS RX (receive) pin to Digital 2
+// If using hardware serial (e.g. Arduino Mega):
+// Connect the GPS TX (transmit) pin to Arduino RX1, RX2 or RX3
+// Connect the GPS RX (receive) pin to matching TX1, TX2 or TX3
+
+// If using software serial, keep these lines enabled
+// (you can change the pin numbers to match your wiring):
+#if ARDUINO >= 100
+ SoftwareSerial mySerial(3, 2);
+#else
+ NewSoftSerial mySerial(3, 2);
+#endif
+Adafruit_GPS GPS(&mySerial);
+// If using hardware serial (e.g. Arduino Mega), comment
+// out the above six lines and enable this line instead:
+//Adafruit_GPS GPS(&Serial1);
+
+
+// Set GPSECHO to 'false' to turn off echoing the GPS data to the Serial console
+// Set to 'true' if you want to debug and listen to the raw GPS sentences
+#define GPSECHO false
+
+// this keeps track of whether we're using the interrupt
+// off by default!
+boolean usingInterrupt = false;
+void useInterrupt(boolean); // Func prototype keeps Arduino 0023 happy
+
+void setup()
+{
+ // connect at 115200 so we can read the GPS fast enuf and
+ // also spit it out
+ Serial.begin(115200);
+ Serial.println("Adafruit GPS erase FLASH!");
+
+ // 9600 NMEA is the default baud rate for MTK
+ GPS.begin(9600);
+
+ GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_OFF);
+
+ // the nice thing about this code is you can have a timer0 interrupt go off
+ // every 1 millisecond, and read data from the GPS for you. that makes the
+ // loop code a heck of a lot easier!
+ useInterrupt(true);
+
+ Serial.println("This code will ERASE the data log stored in the FLASH - Permanently!");
+ Serial.print("Are you sure you want to do this? [Y/N]: ");
+ while (Serial.read() != 'Y') delay(10);
+ Serial.println("\nERASING! UNPLUG YOUR ARDUINO WITHIN 5 SECONDS IF YOU DIDNT MEAN TO!");
+ delay(5000);
+ GPS.sendCommand(PMTK_LOCUS_ERASE_FLASH);
+ Serial.println("Erased");
+}
+
+
+
+void loop() // run over and over again
+{
+ // If using hardware serial (e.g. Arduino Mega), change this to Serial1, etc.
+ if (mySerial.available()) {
+ char c = mySerial.read();
+ if (c) UDR0 = c;
+ }
+}
+
+/******************************************************************/
+// Interrupt is called once a millisecond, looks for any new GPS data, and stores it
+SIGNAL(TIMER0_COMPA_vect) {
+ char c = GPS.read();
+ // if you want to debug, this is a good time to do it!
+ if (GPSECHO)
+ if (c) UDR0 = c;
+ // writing direct to UDR0 is much much faster than Serial.print
+ // but only one character can be written at a time.
+
+}
+
+void useInterrupt(boolean v) {
+ if (v) {
+ // Timer0 is already used for millis() - we'll just interrupt somewhere
+ // in the middle and call the "Compare A" function above
+ OCR0A = 0xAF;
+ TIMSK0 |= _BV(OCIE0A);
+ usingInterrupt = true;
+ } else {
+ // do not call the interrupt function COMPA anymore
+ TIMSK0 &= ~_BV(OCIE0A);
+ usingInterrupt = false;
+ }
+}
+
+
Please sign in to comment.
Something went wrong with that request. Please try again.