From c8d4e037e739af147b7ae031887e956487740940 Mon Sep 17 00:00:00 2001 From: Rick Sellens Date: Sat, 18 Jan 2020 10:23:14 -0500 Subject: [PATCH] clanged files --- .DS_Store | Bin 0 -> 6148 bytes Adafruit_GPS.cpp | 241 ++++++++++-------- Adafruit_GPS.h | 45 ++-- .../GPS_HardwareSerial_Timing.ino | 186 ++++++++------ 4 files changed, 270 insertions(+), 202 deletions(-) create mode 100644 .DS_Store mode change 100755 => 100644 Adafruit_GPS.cpp diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..5008ddfcf53c02e82d7eee2e57c38e5672ef89f6 GIT binary patch literal 6148 zcmeH~Jr2S!425mzP>H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0 millis()) timer = millis(); + if (timer > millis()) + timer = millis(); - // approximately every 2 seconds or so, random intervals, print out the current stats + // approximately every 2 seconds or so, random intervals, print out the + // current stats static unsigned nextInterval = 2000; if (millis() - timer > nextInterval) { timer = millis(); // reset the timer @@ -104,74 +113,105 @@ void loop() // run over and over again // Time in seconds keeps increasing after we get the NMEA sentence. // This estimate will lag real time due to transmission and parsing delays, // but the lag should be small and should also be consistent. - float s = GPS.seconds + GPS.milliseconds/1000. + GPS.secondsSinceTime(); + float s = GPS.seconds + GPS.milliseconds / 1000. + GPS.secondsSinceTime(); int m = GPS.minute; int h = GPS.hour; int d = GPS.day; // Adjust time and day forward to account for elapsed time. - // This will break at month boundaries!!! Humans will have to cope with April 31,32 etc. - while(s > 60){ s -= 60; m++; } - while(m > 60){ m -= 60; h++; } - while(h > 24){ h -= 24; d++; } - // ISO Standard Date Format, with leading zeros https://xkcd.com/1179/ - Serial.print("\nDate: "); - Serial.print(GPS.year+2000, DEC); Serial.print("-"); - if(GPS.month < 10) Serial.print("0"); - Serial.print(GPS.month, DEC); Serial.print("-"); - if(d < 10) Serial.print("0"); + // This will break at month boundaries!!! Humans will have to cope with + // April 31,32 etc. + while (s > 60) { + s -= 60; + m++; + } + while (m > 60) { + m -= 60; + h++; + } + while (h > 24) { + h -= 24; + d++; + } + // ISO Standard Date Format, with leading zeros https://xkcd.com/1179/ + Serial.print("\nDate: "); + Serial.print(GPS.year + 2000, DEC); + Serial.print("-"); + if (GPS.month < 10) + Serial.print("0"); + Serial.print(GPS.month, DEC); + Serial.print("-"); + if (d < 10) + Serial.print("0"); Serial.print(d, DEC); Serial.print(" Time: "); - if(h < 10) Serial.print("0"); - Serial.print(h, DEC); Serial.print(':'); - if(m < 10) Serial.print("0"); - Serial.print(m, DEC); Serial.print(':'); - if(s < 10) Serial.print("0"); + if (h < 10) + Serial.print("0"); + Serial.print(h, DEC); + Serial.print(':'); + if (m < 10) + Serial.print("0"); + Serial.print(m, DEC); + Serial.print(':'); + if (s < 10) + Serial.print("0"); Serial.println(s, 3); - Serial.print("Fix: "); Serial.print((int)GPS.fix); - Serial.print(" quality: "); Serial.println((int)GPS.fixquality); - Serial.print("Time [s] since last fix: "); Serial.println(GPS.secondsSinceFix(),3); - Serial.print(" since last GPS time: "); Serial.println(GPS.secondsSinceTime(),3); - Serial.print(" since last GPS date: "); Serial.println(GPS.secondsSinceDate(),3); + Serial.print("Fix: "); + Serial.print((int)GPS.fix); + Serial.print(" quality: "); + Serial.println((int)GPS.fixquality); + Serial.print("Time [s] since last fix: "); + Serial.println(GPS.secondsSinceFix(), 3); + Serial.print(" since last GPS time: "); + Serial.println(GPS.secondsSinceTime(), 3); + Serial.print(" since last GPS date: "); + Serial.println(GPS.secondsSinceDate(), 3); if (GPS.fix) { Serial.print("Location: "); - Serial.print(GPS.latitude, 4); Serial.print(GPS.lat); + Serial.print(GPS.latitude, 4); + Serial.print(GPS.lat); Serial.print(", "); - Serial.print(GPS.longitude, 4); Serial.println(GPS.lon); - Serial.print("Speed (knots): "); Serial.println(GPS.speed); - Serial.print("Angle: "); Serial.println(GPS.angle); - Serial.print("Altitude: "); Serial.println(GPS.altitude); - Serial.print("Satellites: "); Serial.println((int)GPS.satellites); + Serial.print(GPS.longitude, 4); + Serial.println(GPS.lon); + Serial.print("Speed (knots): "); + Serial.println(GPS.speed); + Serial.print("Angle: "); + Serial.println(GPS.angle); + Serial.print("Altitude: "); + Serial.println(GPS.altitude); + Serial.print("Satellites: "); + Serial.println((int)GPS.satellites); } #ifdef NMEA_EXTENSIONS char latestBoat[200] = ""; - updateBoat(); //create some test data in Boat - Boat.build(latestBoat,"GN","RMC"); //make a sentence from Boat data - Serial.print("\nbuild() test output -->"); // - Serial.print(latestBoat); // - GPS.resetSentTime(); //make timing look like it came in on GPS - GPS.parse(latestBoat); //parse the test data and store in GPS + updateBoat(); // create some test data in Boat + Boat.build(latestBoat, "GN", "RMC"); // make a sentence from Boat data + Serial.print("\nbuild() test output -->"); // + Serial.print(latestBoat); // + GPS.resetSentTime(); // make timing look like it came in on GPS + GPS.parse(latestBoat); // parse the test data and store in GPS #endif } } #ifdef NMEA_EXTENSIONS -void updateBoat(){ //fill up the boat values with some test data to use in build() +void updateBoat() { // fill up the boat values with some test data to use in + // build() double t = millis() / 1000.; - double theta = t / 100.; //slow - double gamma = theta * 10; //faster - Boat.latitude = 4400 + sin(theta)*60; + double theta = t / 100.; // slow + double gamma = theta * 10; // faster + Boat.latitude = 4400 + sin(theta) * 60; Boat.lat = 'N'; - Boat.longitude = 7600 + cos(theta)*60; + Boat.longitude = 7600 + cos(theta) * 60; Boat.lon = 'W'; Boat.fixquality = 2; Boat.speed = 3 + sin(gamma); Boat.hour = abs(cos(theta)) * 24; - Boat.minute = 30 + sin(theta/2) * 30; + Boat.minute = 30 + sin(theta / 2) * 30; Boat.seconds = 30 + sin(gamma) * 30; - Boat.milliseconds = 500+ sin(gamma) * 500; - Boat.year = 1+abs(sin(theta)) * 25; - Boat.month = 1+abs(sin(gamma)) * 11; - Boat.day = 1+ abs(sin(gamma)) * 26; + Boat.milliseconds = 500 + sin(gamma) * 500; + Boat.year = 1 + abs(sin(theta)) * 25; + Boat.month = 1 + abs(sin(gamma)) * 11; + Boat.day = 1 + abs(sin(gamma)) * 26; Boat.satellites = abs(cos(gamma)) * 10; } #endif