Start replacing SD with SdFat, but it's not finished yet

This commit is contained in:
Starbeamrainbowlabs 2019-06-26 18:08:42 +01:00
parent a29fba2fa2
commit cf2af7668e
3 changed files with 8 additions and 13 deletions

3
.gitmodules vendored
View file

@ -13,3 +13,6 @@
[submodule "iot/libraries/Arduino-MemoryFree"]
path = iot/libraries/Arduino-MemoryFree
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

@ -0,0 +1 @@
Subproject commit 3b79f38cb554809a45a0ccd6d9d6752b6ad948c2

View file

@ -1,19 +1,14 @@
#include <Arduino.h>
#include <SD.h>
#include <TinyGPS++.h>
#include <SdFat.h>
#include "settings.h"
#include "gps.h"
void store_init() {
// 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
}
}
SdFat* card = NULL;
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.
// 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);
@ -36,7 +31,3 @@ void store_debug(char* buffer, int size) {
handle.println();
handle.close();
}
void store_close() {
SD.end();
}