From 80f869ce8ad1492c2c4bfa08c48d5b50dca70b24 Mon Sep 17 00:00:00 2001 From: "Austin St. Aubin" Date: Sun, 29 Apr 2012 20:46:21 -0500 Subject: [PATCH] Added Standby and Wakeup fuctions for powering down and powering back up the GPS --- Adafruit_GPS.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/Adafruit_GPS.cpp b/Adafruit_GPS.cpp index c0b45ab..8e5e7ed 100644 --- a/Adafruit_GPS.cpp +++ b/Adafruit_GPS.cpp @@ -24,6 +24,7 @@ volatile uint8_t lineidx=0; volatile char *currentline; volatile char *lastline; volatile boolean recvdflag; +volatile boolean inStandbyMode; boolean Adafruit_GPS::parse(char *nmea) { @@ -344,3 +345,27 @@ boolean Adafruit_GPS::LOCUS_ReadStatus(void) { return true; } + +// Standby Mode Switches +boolean Adafruit_GPS::standby(void) { + if (inStandbyMode) { + return false; // Returns false if already in standby mode, so that you do not wake it up by sending commands to GPS + } + else { + inStandbyMode = true; + sendCommand(PMTK_STANDBY); + //return waitForSentence(PMTK_STANDBY_SUCCESS); // don't seem to be fast enough to catch the message, or something else just is not working + return true; + } +} + +boolean Adafruit_GPS::wakeup(void) { + if (inStandbyMode) { + inStandbyMode = false; + sendCommand(""); // send byte to wake it up + return waitForSentence(PMTK_AWAKE); + } + else { + return false; // Returns false if not in standby mode, nothing to wakeup + } +} \ No newline at end of file