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: Servo TMP36 GZ buffered-serial1 chan_fatfs_sd nmea_parser watchdog mbed-rtos mbed
Fork of HARP2 by
Diff: main.cpp
- Revision:
- 12:0d943d69d3ec
- Parent:
- 11:890a721158a5
- Child:
- 13:db6af0620264
diff -r 890a721158a5 -r 0d943d69d3ec main.cpp
--- a/main.cpp Tue Dec 11 06:46:11 2012 +0000
+++ b/main.cpp Tue Dec 11 23:57:13 2012 +0000
@@ -1,9 +1,7 @@
#include "mbed.h"
#include "rtos.h"
#include "buffered_serial.h"
-#include "SDFileSystem.h"
-
-SDFileSystem sd(p5, p6, p7, p8, "sd");
+#include "ff.h"
#define CELLS 3.0
#define LIPO_EMPTY 3.4
@@ -18,25 +16,27 @@
BufferedSerial gps(NC, p14);
AnalogIn gps_battery(p20);
+#define FSS_DBG
+
void gps_thread(void const *args)
{
char buffer[80];
+ FATFS fs;
+ FIL fp;
DigitalOut gps_led(LED4);
gps.baud(4800);
- mkdir("/sd/hab", 0777);
- FILE *fp = fopen("/sd/hab/gps.txt", "a");
- fputs("--- new log --- \r\n", fp);
- fclose(fp);
+
+ f_mount(0, &fs);
+ f_open(&fp, "0:gps.txt", FA_CREATE_ALWAYS | FA_WRITE);
while(true) {
- fp = fopen("/sd/hab/gps.txt", "a");
gps.read_line(buffer);
gps_led = !gps_led;
- //pc.puts(buffer);
- fputs(buffer, fp);
- fclose(fp);
+ pc.puts(buffer);
+ f_puts(buffer, &fp);
+ f_sync(&fp);
}
}
@@ -47,11 +47,11 @@
while(true) {
float sample = gps_battery.read();
- pc.printf("Sample: %f Volts\r\n", sample*3.3);
+ //pc.printf("Sample: %f Volts\r\n", sample*3.3);
float voltage = sample*BAT_MUL*3.3;
- pc.printf("Battery Voltage: %f Volts\r\n", voltage);
+ //pc.printf("Battery Voltage: %f Volts\r\n", voltage);
float level = (voltage-BAT_EMPTY) / (BAT_RANGE);
- pc.printf("Battery Level: %f \r\n", level);
+ //pc.printf("Battery Level: %f \r\n", level);
Thread::wait(1000);
}
}
\ No newline at end of file
