7 changed files with 116 additions and 0 deletions
@ -0,0 +1,5 @@
@@ -0,0 +1,5 @@
|
||||
-include/home/sbrl/Downloads/arduino/hardware/arduino/avr/cores/arduino/Arduino.h |
||||
-include/home/sbrl/Arduino/libraries/TinyGPSPlus/src/TinyGPS++.h |
||||
-include/home/sbrl/Downloads/arduino/libraries/SD/src/SD.h |
||||
-I/home/sbrl/Downloads/arduino/libraries/ |
||||
-I |
@ -0,0 +1,6 @@
@@ -0,0 +1,6 @@
|
||||
#include "gps.h" |
||||
#include "settings.h" |
||||
|
||||
void gps_begin() { |
||||
serial_gps.begin(BAUD_GPS); |
||||
} |
@ -0,0 +1,25 @@
@@ -0,0 +1,25 @@
|
||||
#pragma once |
||||
|
||||
#include <SoftwareSerial.h> |
||||
|
||||
#include <TinyGPS++.h> |
||||
|
||||
#include "settings.h" |
||||
|
||||
|
||||
// The GPS message decoder
|
||||
TinyGPSPlus gps; |
||||
// The serial connection to the GPS device
|
||||
SoftwareSerial serial_gps(PIN_GPS_RX, PIN_GPS_TX); |
||||
|
||||
/**
|
||||
* Initialises the connection to the GPS device. |
||||
*/ |
||||
void gps_begin(); |
||||
|
||||
/**
|
||||
* Fetches the current location from the GPS device. |
||||
* May take a moment, as the GPS device needs time to acquire a satellite fix. |
||||
* @return TinyGPSLocation The current location. |
||||
*/ |
||||
TinyGPSLocation get_location(); |
@ -0,0 +1,18 @@
@@ -0,0 +1,18 @@
|
||||
#include <Arduino.h> |
||||
|
||||
#include "settings.h" |
||||
#include "gps.h" |
||||
|
||||
void setup() { |
||||
Serial.begin(BAUD_PC); |
||||
|
||||
gps_begin(); |
||||
|
||||
|
||||
|
||||
get_location(); |
||||
} |
||||
|
||||
void loop() { |
||||
|
||||
} |
@ -0,0 +1,33 @@
@@ -0,0 +1,33 @@
|
||||
#pragma once |
||||
|
||||
//////////////////////////////////
|
||||
////////////// Main //////////////
|
||||
//////////////////////////////////
|
||||
|
||||
// The speed at which we should talk over our main hardware serial connection.
|
||||
#define BAUD_PC 115200 |
||||
|
||||
// Multiple devices can use the same SPI data pin AFAIKT, but some libraries *cough* SD *cough* are too stupid to figure out which pin it is on their own.
|
||||
#define PIN_SPI_DATA 9 |
||||
|
||||
/////////////////////////////////
|
||||
////////////// GPS //////////////
|
||||
/////////////////////////////////
|
||||
|
||||
// The *TX* gin of the GPS device.
|
||||
// This is swapped because we receive the GPS device's message on our side on the RX pin, and the GPS device transmits messages on the TX.
|
||||
#define PIN_GPS_RX 4 |
||||
// The *RX* pin on the GPS device.
|
||||
// This is swapped because where the GPs device is receiving, we aresending and vice versa.
|
||||
// The TX / RX here are according to *our* side, not the GPS device's side.
|
||||
#define PIN_GPS_TX 3 |
||||
// The speed at which we should talk to the GPS device. Some GPS devices require a certain speed in order to use certain commands, so it's important that you check the datasheets for the device you're using.
|
||||
// 9600 is the correct speed for a NEO-6M.
|
||||
#define BAUD_GPS 9600 |
||||
|
||||
//////////////////////////////////
|
||||
////////// microSD Card //////////
|
||||
//////////////////////////////////
|
||||
|
||||
//
|
||||
#define PIN_SD_SPI_CHIP_SELECT 3 |
@ -0,0 +1,17 @@
@@ -0,0 +1,17 @@
|
||||
#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; |
||||
} |
Loading…
Reference in new issue