parent
ba8068be19
commit
0cdd8f5539
@ -1,6 +0,0 @@
|
||||
#include "gps.h"
|
||||
#include "settings.h"
|
||||
|
||||
void gps_begin() {
|
||||
serial_gps.begin(BAUD_GPS);
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
#include "gps.h"
|
||||
#include "settings.h"
|
||||
|
||||
void gps_begin() {
|
||||
serial_gps.begin(BAUD_GPS);
|
||||
}
|
||||
|
||||
TinyGPSLocation gps_location() {
|
||||
Serial.print("[gps] Getting location: ");
|
||||
while(serial_gps.available() > 0) {
|
||||
if(!gps.encode(serial_gps.read()))
|
||||
continue;
|
||||
|
||||
if(!gps.location.isValid() || gis.location.isUpdated()) {
|
||||
Serial.print(".");
|
||||
delay(100);
|
||||
continue;
|
||||
}
|
||||
|
||||
Serial.println("ok");
|
||||
return gps.location;
|
||||
}
|
||||
}
|
||||
|
||||
void gps_end() {
|
||||
Serial.println(F("[warning] Putting the GPS device to sleep isn't implemented yet."));
|
||||
}
|
@ -0,0 +1 @@
|
||||
#pragma once
|
@ -1,17 +0,0 @@
|
||||
#include <Arduino.h>
|
||||
#include <SD.h>
|
||||
|
||||
#include "settings.h"
|
||||
|
||||
void store_init() {
|
||||
pinMode(PIN_SPI_CHIP_SELECT, OUTPUT);
|
||||
|
||||
if(!SD.begin(PIN_SPI_DATA)) {
|
||||
Serial.println("Error: Failed to initialise connection to microSD card");
|
||||
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, TinyGPSLocation location) {
|
||||
File handle;
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
#include <Arduino.h>
|
||||
#include <SD.h>
|
||||
|
||||
#include "settings.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_SD_SPI_CHIP_SELECT)) {
|
||||
Serial.println(F("Error: Failed to initialise connection to microSD card"));
|
||||
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, TinyGPSLocation location) {
|
||||
// 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);
|
||||
|
||||
handle.print(id);
|
||||
handle.print("\t");
|
||||
|
||||
handle.print(location.longitude());
|
||||
handle.print("\t");
|
||||
|
||||
handle.print(location.latitude());
|
||||
handle.println();
|
||||
|
||||
handle.close();
|
||||
}
|
||||
|
||||
void store_close() {
|
||||
SD.end();
|
||||
}
|
Loading…
Reference in new issue