Skip to content
This repository
Browse code

added locus erase example

  • Loading branch information...
commit 319531f4d2c137ac1f34ec04d7eb4ab83d4aed4f 1 parent 513c915
Limor "Ladyada" Fried ladyada authored

Showing 2 changed files with 120 additions and 0 deletions. Show diff stats Hide diff stats

  1. +5 0 Adafruit_GPS.h
  2. +115 0 examples/locus_erase/locus_erase.pde
5 Adafruit_GPS.h
@@ -25,6 +25,10 @@ All text above must be included in any redistribution
25 25 #define PMTK_SET_NMEA_UPDATE_5HZ "$PMTK220,200*2C"
26 26 #define PMTK_SET_NMEA_UPDATE_10HZ "$PMTK220,100*2F"
27 27
  28 +
  29 +#define PMTK_SET_BAUD_57600 "$PMTK250,1,0,57600*2C"
  30 +#define PMTK_SET_BAUD_9600 "$PMTK250,1,0,9600*17"
  31 +
28 32 // turn on only the second sentence (GPRMC)
29 33 #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"
30 34 // turn on GPRMC and GGA
@@ -40,6 +44,7 @@ All text above must be included in any redistribution
40 44 #define PMTK_LOCUS_STARTLOG "$PMTK185,0*22"
41 45 #define PMTK_LOCUS_LOGSTARTED "$PMTK001,185,3*3C"
42 46 #define PMTK_LOCUS_QUERY_STATUS "$PMTK183*38"
  47 +#define PMTK_LOCUS_ERASE_FLASH "$PMTK184,1*22"
43 48 #define LOCUS_OVERLAP 0
44 49 #define LOCUS_FULLSTOP 1
45 50
115 examples/locus_erase/locus_erase.pde
... ... @@ -0,0 +1,115 @@
  1 +// Test code for Adafruit GPS modules using MTK3329/MTK3339 driver
  2 +//
  3 +// This code erases the LOCUS built-in datalogger storage
  4 +//
  5 +// Tested and works great with the Adafruit Ultimate GPS module
  6 +// using MTK33x9 chipset
  7 +// ------> http://www.adafruit.com/products/746
  8 +// Pick one up today at the Adafruit electronics shop
  9 +// and help support open source hardware & software! -ada
  10 +
  11 +#include <Adafruit_GPS.h>
  12 +#if ARDUINO >= 100
  13 + #include <SoftwareSerial.h>
  14 +#else
  15 + // Older Arduino IDE requires NewSoftSerial, download from:
  16 + // http://arduiniana.org/libraries/newsoftserial/
  17 + #include <NewSoftwareSerial.h>
  18 + // DO NOT install NewSoftSerial if using Arduino 1.0 or later!
  19 +#endif
  20 +
  21 +// Connect the GPS Power pin to 5V
  22 +// Connect the GPS Ground pin to ground
  23 +// If using software serial (sketch example default):
  24 +// Connect the GPS TX (transmit) pin to Digital 3
  25 +// Connect the GPS RX (receive) pin to Digital 2
  26 +// If using hardware serial (e.g. Arduino Mega):
  27 +// Connect the GPS TX (transmit) pin to Arduino RX1, RX2 or RX3
  28 +// Connect the GPS RX (receive) pin to matching TX1, TX2 or TX3
  29 +
  30 +// If using software serial, keep these lines enabled
  31 +// (you can change the pin numbers to match your wiring):
  32 +#if ARDUINO >= 100
  33 + SoftwareSerial mySerial(3, 2);
  34 +#else
  35 + NewSoftSerial mySerial(3, 2);
  36 +#endif
  37 +Adafruit_GPS GPS(&mySerial);
  38 +// If using hardware serial (e.g. Arduino Mega), comment
  39 +// out the above six lines and enable this line instead:
  40 +//Adafruit_GPS GPS(&Serial1);
  41 +
  42 +
  43 +// Set GPSECHO to 'false' to turn off echoing the GPS data to the Serial console
  44 +// Set to 'true' if you want to debug and listen to the raw GPS sentences
  45 +#define GPSECHO false
  46 +
  47 +// this keeps track of whether we're using the interrupt
  48 +// off by default!
  49 +boolean usingInterrupt = false;
  50 +void useInterrupt(boolean); // Func prototype keeps Arduino 0023 happy
  51 +
  52 +void setup()
  53 +{
  54 + // connect at 115200 so we can read the GPS fast enuf and
  55 + // also spit it out
  56 + Serial.begin(115200);
  57 + Serial.println("Adafruit GPS erase FLASH!");
  58 +
  59 + // 9600 NMEA is the default baud rate for MTK
  60 + GPS.begin(9600);
  61 +
  62 + GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_OFF);
  63 +
  64 + // the nice thing about this code is you can have a timer0 interrupt go off
  65 + // every 1 millisecond, and read data from the GPS for you. that makes the
  66 + // loop code a heck of a lot easier!
  67 + useInterrupt(true);
  68 +
  69 + Serial.println("This code will ERASE the data log stored in the FLASH - Permanently!");
  70 + Serial.print("Are you sure you want to do this? [Y/N]: ");
  71 + while (Serial.read() != 'Y') delay(10);
  72 + Serial.println("\nERASING! UNPLUG YOUR ARDUINO WITHIN 5 SECONDS IF YOU DIDNT MEAN TO!");
  73 + delay(5000);
  74 + GPS.sendCommand(PMTK_LOCUS_ERASE_FLASH);
  75 + Serial.println("Erased");
  76 +}
  77 +
  78 +
  79 +
  80 +void loop() // run over and over again
  81 +{
  82 + // If using hardware serial (e.g. Arduino Mega), change this to Serial1, etc.
  83 + if (mySerial.available()) {
  84 + char c = mySerial.read();
  85 + if (c) UDR0 = c;
  86 + }
  87 +}
  88 +
  89 +/******************************************************************/
  90 +// Interrupt is called once a millisecond, looks for any new GPS data, and stores it
  91 +SIGNAL(TIMER0_COMPA_vect) {
  92 + char c = GPS.read();
  93 + // if you want to debug, this is a good time to do it!
  94 + if (GPSECHO)
  95 + if (c) UDR0 = c;
  96 + // writing direct to UDR0 is much much faster than Serial.print
  97 + // but only one character can be written at a time.
  98 +
  99 +}
  100 +
  101 +void useInterrupt(boolean v) {
  102 + if (v) {
  103 + // Timer0 is already used for millis() - we'll just interrupt somewhere
  104 + // in the middle and call the "Compare A" function above
  105 + OCR0A = 0xAF;
  106 + TIMSK0 |= _BV(OCIE0A);
  107 + usingInterrupt = true;
  108 + } else {
  109 + // do not call the interrupt function COMPA anymore
  110 + TIMSK0 &= ~_BV(OCIE0A);
  111 + usingInterrupt = false;
  112 + }
  113 +}
  114 +
  115 +

0 comments on commit 319531f

Please sign in to comment.
Something went wrong with that request. Please try again.