Browse Source

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

master
Starbeamrainbowlabs 3 years ago
parent
commit
cf2af7668e
  1. 3
      .gitmodules
  2. 1
      iot/libraries/SdFat
  3. 17
      iot/main/storage.cpp

3
.gitmodules

@ -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

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

17
iot/main/storage.cpp

@ -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();
}

Loading…
Cancel
Save