Fix compilation warnings

This commit is contained in:
Starbeamrainbowlabs 2019-06-27 15:58:01 +01:00
parent 18342c55fc
commit bbf12da323
3 changed files with 10 additions and 6 deletions

View File

@ -1,7 +1,6 @@
#include "settings.h" #include "settings.h"
#include <Arduino.h> #include <Arduino.h>
#include <TinyGPS++.h> #include <TinyGPS++.h>
#include <SD.h>
#include <MemoryFree.h> #include <MemoryFree.h>
#include "random.h" #include "random.h"
@ -45,7 +44,7 @@ void setup() {
store_debug(gps_data.time, 19); store_debug(gps_data.time, 19);
#endif #endif
Serial.println(freeMemory(), DEC); Serial.println(freeMemory(), DEC);
store_close(); store_end();
Serial.println(freeMemory(), DEC); Serial.println(freeMemory(), DEC);
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------

View File

@ -10,7 +10,10 @@ SdFat* card = nullptr;
void store_init() { void store_init() {
card = new SdFat(); card = new SdFat();
card->begin(PIN_SPI_CS_SD); if(!card->begin(PIN_SPI_CS_SD)) {
Serial.println("Error: MicroSD card init failed");
while(true) delay(100);
}
} }
void store_reading(uint32_t id, GPSLocation location) { void store_reading(uint32_t id, GPSLocation location) {
@ -38,6 +41,8 @@ void store_debug(char* buffer, int size) {
} }
void store_end() { void store_end() {
card.end(); // Apparently we'ree fine so long as we don't have any open file handles - there's no end() method on the SdFat class
// card->end();
delete card; delete card;
card = nullptr;
} }

View File

@ -1,7 +1,7 @@
#pragma once #pragma once
#include <SPI.h> #include <SPI.h>
#include <SD.h> #include <SdFat.h>
#include <TinyGPS++.h> #include <TinyGPS++.h>
@ -11,4 +11,4 @@ void store_reading(uint32_t id, GPSLocation location);
void store_debug(char* buffer, int size); void store_debug(char* buffer, int size);
void store_close(); void store_end();