Commit try

This commit is contained in:
Scobber 2019-07-11 18:07:14 +10:00
parent cc953e1e96
commit 30a4166ed6
2 changed files with 49 additions and 0 deletions

View File

@ -94,6 +94,7 @@ void ttn_register(void (*callback)(uint8_t message));
#define GPS_RX_PIN 12
#define GPS_TX_PIN 15
#define GPS_BAUDRATE 9600
#define USE_GPS 1
// -----------------------------------------------------------------------------
// LoRa SPI

View File

@ -25,9 +25,57 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <rom/rtc.h>
#include "dataformats.h"
// Message counter, stored in RTC memory, survives deep sleep
RTC_DATA_ATTR uint32_t count = 0;
// -----------------------------------------------------------------------------
// Submodules
// -----------------------------------------------------------------------------
#ifdef USE_GPS 1
#include <TinyGPS++.h>
uint32_t LatitudeBinary, LongitudeBinary;
uint16_t altitudeGps;
uint8_t hdopGps;
char t[32]; // used to sprintf for Serial output
TinyGPSPlus _gps;
HardwareSerial _serial_gps(GPS_SERIAL_NUM);
void gps_time(char * buffer, uint8_t size) {
snprintf(buffer, size, "%02d:%02d:%02d", _gps.time.hour(), _gps.time.minute(), _gps.time.second());
}
float gps_latitude() {
return _gps.location.lat();
}
float gps_longitude() {
return _gps.location.lng();
}
float gps_altitude() {
return _gps.altitude.meters();
}
float gps_hdop() {
return _gps.hdop.hdop();
}
uint8_t gps_sats() {
return _gps.satellites.value();
}
void gps_setup() {
_serial_gps.begin(GPS_BAUDRATE, SERIAL_8N1, GPS_RX_PIN, GPS_TX_PIN);
}
static void gps_loop() {
while (_serial_gps.available()) {
_gps.encode(_serial_gps.read());
}
}
#endif
// -----------------------------------------------------------------------------
// Application
// -----------------------------------------------------------------------------