From 2fdb75efdf9e0752a64f818df44be18ba7aff2f1 Mon Sep 17 00:00:00 2001 From: geeksville Date: Thu, 23 Apr 2020 16:20:07 -0700 Subject: [PATCH] make GPS 'work' on nrf52 --- platformio.ini | 1 + src/GPS.cpp | 10 +++++----- src/configuration.h | 38 +++++++++++++++++++------------------- src/screen.cpp | 2 +- src/screen.h | 2 +- 5 files changed, 27 insertions(+), 26 deletions(-) diff --git a/platformio.ini b/platformio.ini index 83f6adac5..6505e6647 100644 --- a/platformio.ini +++ b/platformio.ini @@ -82,6 +82,7 @@ upload_speed = 921600 debug_init_break = tbreak setup build_flags = ${env.build_flags} -Wall -Wextra +lib_ignore = segger_rtt ; The 1.0 release of the TBEAM board [env:tbeam] diff --git a/src/GPS.cpp b/src/GPS.cpp index 60dedf429..668e9f02c 100644 --- a/src/GPS.cpp +++ b/src/GPS.cpp @@ -9,7 +9,7 @@ HardwareSerial _serial_gps(GPS_SERIAL_NUM); #else // Assume NRF52 -// Uart _serial_gps(GPS_SERIAL_NUM); +HardwareSerial &_serial_gps = Serial1; #endif bool timeSetFromGPS; // We try to set our time from GPS each time we wake from sleep @@ -31,6 +31,9 @@ void GPS::setup() #ifdef GPS_RX_PIN _serial_gps.begin(GPS_BAUDRATE, SERIAL_8N1, GPS_RX_PIN, GPS_TX_PIN); +#else + _serial_gps.begin(GPS_BAUDRATE); +#endif // _serial_gps.setRxBufferSize(1024); // the default is 256 // ublox.enableDebugging(Serial); @@ -43,7 +46,7 @@ void GPS::setup() isConnected = ublox.begin(_serial_gps); if (isConnected) { - DEBUG_MSG("Connected to GPS successfully, TXpin=%d\n", GPS_TX_PIN); + DEBUG_MSG("Connected to GPS successfully\n"); bool factoryReset = false; bool ok; @@ -81,7 +84,6 @@ void GPS::setup() // checkUblox cyclically) ublox.assumeAutoPVT(true, true); } -#endif } void GPS::readFromRTC() @@ -145,7 +147,6 @@ void GPS::prepareSleep() void GPS::doTask() { -#ifdef GPS_RX_PIN uint8_t fixtype = 3; // If we are only using the RX pin, assume we have a 3d fix if (isConnected) { @@ -207,7 +208,6 @@ The Unix epoch (or Unix time or POSIX time or Unix timestamp) is the number of s } } else // we didn't get a location update, go back to sleep and hope the characters show up wantNewLocation = true; -#endif // Once we have sent a location once we only poll the GPS rarely, otherwise check back every 1s until we have something over // the serial diff --git a/src/configuration.h b/src/configuration.h index 98638606d..cbf930f66 100644 --- a/src/configuration.h +++ b/src/configuration.h @@ -54,24 +54,6 @@ along with this program. If not, see . #define xstr(s) str(s) #define str(s) #s -// ----------------------------------------------------------------------------- -// DEBUG -// ----------------------------------------------------------------------------- - -#ifndef NO_ESP32 -#define USE_SEGGER -#endif -#ifdef USE_SEGGER -#include "SEGGER_RTT.h" -#define DEBUG_MSG(...) SEGGER_RTT_printf(0, __VA_ARGS__) -#else -#ifdef DEBUG_PORT -#define DEBUG_MSG(...) DEBUG_PORT.printf(__VA_ARGS__) -#else -#define DEBUG_MSG(...) -#endif -#endif - // ----------------------------------------------------------------------------- // OLED // ----------------------------------------------------------------------------- @@ -217,7 +199,7 @@ along with this program. If not, see . #define NO_ESP32 // Don't use ESP32 libs (mainly bluetooth) -// Turn off GPS code for now +// We bind to the GPS using variant.h instead for this platform (Serial1) #undef GPS_RX_PIN #undef GPS_TX_PIN @@ -233,6 +215,24 @@ along with this program. If not, see . #endif +// ----------------------------------------------------------------------------- +// DEBUG +// ----------------------------------------------------------------------------- + +#ifdef NO_ESP32 +#define USE_SEGGER +#endif +#ifdef USE_SEGGER +#include "SEGGER_RTT.h" +#define DEBUG_MSG(...) SEGGER_RTT_printf(0, __VA_ARGS__) +#else +#ifdef DEBUG_PORT +#define DEBUG_MSG(...) DEBUG_PORT.printf(__VA_ARGS__) +#else +#define DEBUG_MSG(...) +#endif +#endif + // ----------------------------------------------------------------------------- // AXP192 (Rev1-specific options) // ----------------------------------------------------------------------------- diff --git a/src/screen.cpp b/src/screen.cpp index 38d0fdd30..3fe089f0a 100644 --- a/src/screen.cpp +++ b/src/screen.cpp @@ -402,7 +402,7 @@ void _screen_header() } #endif -Screen::Screen(uint8_t address, uint8_t sda, uint8_t scl) : cmdQueue(32), dispdev(address, sda, scl), ui(&dispdev) {} +Screen::Screen(uint8_t address, int sda, int scl) : cmdQueue(32), dispdev(address, sda, scl), ui(&dispdev) {} void Screen::handleSetOn(bool on) { diff --git a/src/screen.h b/src/screen.h index 017e6ae88..634cdd10c 100644 --- a/src/screen.h +++ b/src/screen.h @@ -89,7 +89,7 @@ class DebugInfo class Screen : public PeriodicTask { public: - Screen(uint8_t address, uint8_t sda = 0, uint8_t scl = 0); + Screen(uint8_t address, int sda = -1, int scl = -1); Screen(const Screen &) = delete; Screen &operator=(const Screen &) = delete;