Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: SDFileSystem Venus838 mbed MS5611 TinyGPS
Revision 7:308ab9062b76, committed 2014-06-30
- Comitter:
- matgyver
- Date:
- Mon Jun 30 04:02:08 2014 +0000
- Parent:
- 6:f91db4a7acf1
- Commit message:
- Fixed lockup issue and swapped from Timer to Ticker. Moved logging function to separate function. Added more info to debug file and added placeholders for additional information. Other minor bugfixes.
Changed in this revision
| Atlas.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r f91db4a7acf1 -r 308ab9062b76 Atlas.cpp
--- a/Atlas.cpp Thu Jun 26 14:43:31 2014 +0000
+++ b/Atlas.cpp Mon Jun 30 04:02:08 2014 +0000
@@ -3,7 +3,6 @@
#include "SDFileSystem.h"
#include "Venus838.h"
#include "TinyGPS.h"
-//#include "nmea_parser.h"
#include "MS5611I2C.h"
DigitalOut grn(LED_GRN);
@@ -14,7 +13,36 @@
TinyGPS gps;
MS5611I2C pres(I2C_SDA, I2C_SCL, false);
SDFileSystem sd(SPI_MOSI, SPI_MISO, SPI_SCK, SPI_CS, "sd");
-Timer tick;
+Ticker tick;
+
+unsigned int logCount = 0;
+
+//Function to log data
+void datalog(void) {
+ unsigned long date, time, ttf;
+ double latitude, longitude, altitude;
+ float pressure, temperature, battery;
+ //unsigned int writeCount = 0;
+ //unsigned int logCount = 0;
+
+ grn = !grn;
+ gps.get_datetime(&date, &time, &ttf);
+ gps.f_get_position(&latitude, &longitude, &ttf);
+ altitude = gps.f_altitude();
+ pressure = pres.getPressure();
+ temperature = pres.getTemperature();
+ battery = (batt.read()*3.3f) * 4.0f;
+ //wait_ms(1);
+ pc.printf("%u, %u, %u, %f, %f, %f, %f, %f, %f\r\n",
+ logCount, date, time, longitude, latitude, altitude,
+ pressure, temperature, battery);
+ FILE *fp = fopen("/sd/atlas.txt", "a");
+ fprintf(fp, "%u, %u, %u, %f, %f, %f, %f, %f %f\r\n",
+ logCount, date, time, longitude, latitude, altitude,
+ pressure, temperature, battery);
+ logCount++;
+ fclose(fp);
+}
void init() {
pc.baud(115200);
@@ -34,28 +62,29 @@
error("Could not open file for write\r\n");
ylw = LED_ON;
}
- fprintf(fp, "Hooray, we can write to the SD Card. Go get a cookie.");
-
+ fprintf(fp, "Atlas Debug File\r\n");
+ fprintf(fp, "====================\r\n");
+ fprintf(fp, "Atlas Firmware: 0.1\r\n");
+ //TODO Add calls to query GPS for fimrware and other info
+ fprintf(fp, "GPS Firmware: Update rate: Mode: \r\n");
+ //fprintf(fp, pres.printCoefficients());
printf("Closing file...\r\n");
fclose(fp);
pres.printCoefficients();
- tick.start();
+ //tick.start();
pc.printf("Atlas Ready!\r\n");
}
int main() {
- unsigned long date, time, ttf;
- double latitude, longitude, altitude;
- float pressure, temperature, battery;
- unsigned int writeCount = 0;
init();
+ tick.attach(&datalog,1.0);
FILE *fp = fopen("/sd/atlas.txt", "a");
fprintf(fp, "Atlas Logger\r\n");
- fprintf(fp, "Date Time Lon Lat Alt Pressure Temp Battery\r\n");
- fprintf(fp, "------------------------------------------------------------------\r\n");
+ fprintf(fp, "Count Date Time Lon Lat Alt Pressure Temp Battery\r\n");
+ fprintf(fp, "-------------------------------------------------------------------------\r\n");
fclose(fp);
while(true) {
if(venus.readable()) {
@@ -63,10 +92,11 @@
//pc.putc(c);
gps.encode(c);
}
+
+/*
if(tick.read_ms() >= 500) {
tick.reset();
grn = !grn;
-
gps.get_datetime(&date, &time, &ttf);
gps.f_get_position(&latitude, &longitude, &ttf);
altitude = gps.f_altitude();
@@ -74,22 +104,24 @@
temperature = pres.getTemperature();
battery = (batt.read()*3.3f) * 4.0f;
wait_ms(1);
- pc.printf("%u, %u, %f, %f, %f, %f, %f, %f\r\n",
- date, time, longitude, latitude, altitude,
+ pc.printf("%u %u, %u, %f, %f, %f, %f, %f, %f\r\n",
+ logCount, date, time, longitude, latitude, altitude,
pressure, temperature, battery
);
FILE *fp = fopen("/sd/atlas.txt", "a");
- fprintf(fp, "%u, %u, %f, %f, %f, %f, %f %f\r\n",
- date, time, longitude, latitude, altitude,
+ fprintf(fp, "%u %u, %u, %f, %f, %f, %f, %f %f\r\n",
+ logCount, date, time, longitude, latitude, altitude,
pressure, temperature, battery
);
+ logCount++;
fclose(fp);
writeCount++;
- if(writeCount > 100) {
- writeCount = 0;
- fclose(fp);
- FILE *fp = fopen("/sd/atlas.txt", "a");
- }
+ if(writeCount > 100) {
+ writeCount = 0;
+ fclose(fp);
+ FILE *fp = fopen("/sd/atlas.txt", "a");
+ }
}
+*/
}
}
\ No newline at end of file