Browse Source

Fix compilation warnings

master
Starbeamrainbowlabs 3 years ago
parent
commit
bbf12da323
  1. 3
      iot/main/main.ino
  2. 9
      iot/main/storage.cpp
  3. 4
      iot/main/storage.h

3
iot/main/main.ino

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

9
iot/main/storage.cpp

@ -10,7 +10,10 @@ SdFat* card = nullptr; @@ -10,7 +10,10 @@ SdFat* card = nullptr;
void store_init() {
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) {
@ -38,6 +41,8 @@ void store_debug(char* buffer, int size) { @@ -38,6 +41,8 @@ void store_debug(char* buffer, int size) {
}
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;
card = nullptr;
}

4
iot/main/storage.h

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

Loading…
Cancel
Save