Start replacing SD with SdFat, but it's not finished yet
This commit is contained in:
parent
a29fba2fa2
commit
cf2af7668e
3 changed files with 8 additions and 13 deletions
3
.gitmodules
vendored
3
.gitmodules
vendored
|
@ -13,3 +13,6 @@
|
||||||
[submodule "iot/libraries/Arduino-MemoryFree"]
|
[submodule "iot/libraries/Arduino-MemoryFree"]
|
||||||
path = iot/libraries/Arduino-MemoryFree
|
path = iot/libraries/Arduino-MemoryFree
|
||||||
url = https://github.com/mpflaga/Arduino-MemoryFree.git
|
url = https://github.com/mpflaga/Arduino-MemoryFree.git
|
||||||
|
[submodule "iot/libraries/SdFat"]
|
||||||
|
path = iot/libraries/SdFat
|
||||||
|
url = https://github.com/greiman/SdFat.git
|
||||||
|
|
1
iot/libraries/SdFat
Submodule
1
iot/libraries/SdFat
Submodule
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 3b79f38cb554809a45a0ccd6d9d6752b6ad948c2
|
|
@ -1,19 +1,14 @@
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include <SD.h>
|
#include <SdFat.h>
|
||||||
#include <TinyGPS++.h>
|
|
||||||
|
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
#include "gps.h"
|
#include "gps.h"
|
||||||
|
|
||||||
void store_init() {
|
SdFat* card = NULL;
|
||||||
// NOTE: If this doesn't work, then we need to use pinMode() & specify the data pin here instead.
|
|
||||||
if(!SD.begin(PIN_SPI_CS_SD)) {
|
|
||||||
Serial.println(F("Error: MicroSD card init failed"));
|
|
||||||
while(true) { delay(1); } // Pseudo-halt, but uses delay() to ensure we keep passing back control to allow easy re-programming
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void store_reading(uint32_t id, GPSLocation location) {
|
void store_reading(uint32_t id, GPSLocation location) {
|
||||||
|
SdFat card;
|
||||||
|
card.begin()
|
||||||
// Open the file to write the data to. If it doesn't exist it will be created.
|
// Open the file to write the data to. If it doesn't exist it will be created.
|
||||||
// Unlike elsewhere, FILE_WRITE opens the file with the cursor starting at the end, so it's basically actually equivalent to FILE_APPEND that we use in other environments. Confusing, I know.
|
// Unlike elsewhere, FILE_WRITE opens the file with the cursor starting at the end, so it's basically actually equivalent to FILE_APPEND that we use in other environments. Confusing, I know.
|
||||||
File handle = SD.open(SD_FILENAME, FILE_WRITE);
|
File handle = SD.open(SD_FILENAME, FILE_WRITE);
|
||||||
|
@ -36,7 +31,3 @@ void store_debug(char* buffer, int size) {
|
||||||
handle.println();
|
handle.println();
|
||||||
handle.close();
|
handle.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void store_close() {
|
|
||||||
SD.end();
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue