/* GPS module Copyright (C) 2018 by Xose PĂ©rez This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ #include 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()); } }