From 72f443c519593756d263faf0ba6cc755cb0fca83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Thu, 24 Mar 2022 18:22:31 +0100 Subject: [PATCH] free serial pins if gps_disabled is set --- src/gps/GPS.cpp | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/src/gps/GPS.cpp b/src/gps/GPS.cpp index 5cab509ab..4ce7c0f61 100644 --- a/src/gps/GPS.cpp +++ b/src/gps/GPS.cpp @@ -322,37 +322,39 @@ GPS *createGps() #ifdef NO_GPS return nullptr; #else + if (!radioConfig.preferences.gps_disabled){ #ifdef GPS_ALTITUDE_HAE - DEBUG_MSG("Using HAE altitude model\n"); + DEBUG_MSG("Using HAE altitude model\n"); #else - DEBUG_MSG("Using MSL altitude model\n"); + DEBUG_MSG("Using MSL altitude model\n"); #endif // If we don't have bidirectional comms, we can't even try talking to UBLOX #ifdef GPS_TX_PIN - // Init GPS - first try ublox - UBloxGPS *ublox = new UBloxGPS(); + // Init GPS - first try ublox + UBloxGPS *ublox = new UBloxGPS(); - if (!ublox->setup()) { - DEBUG_MSG("ERROR: No UBLOX GPS found\n"); - delete ublox; - ublox = NULL; - } else { - return ublox; - } + if (!ublox->setup()) { + DEBUG_MSG("ERROR: No UBLOX GPS found\n"); + delete ublox; + ublox = NULL; + } else { + return ublox; + } #endif - if (GPS::_serial_gps) { - // Some boards might have only the TX line from the GPS connected, in that case, we can't configure it at all. Just - // assume NMEA at 9600 baud. - DEBUG_MSG("Hoping that NMEA might work\n"); + if (GPS::_serial_gps) { + // Some boards might have only the TX line from the GPS connected, in that case, we can't configure it at all. Just + // assume NMEA at 9600 baud. + DEBUG_MSG("Hoping that NMEA might work\n"); #ifdef HAS_AIR530_GPS - GPS *new_gps = new Air530GPS(); + GPS *new_gps = new Air530GPS(); #else - GPS *new_gps = new NMEAGPS(); + GPS *new_gps = new NMEAGPS(); #endif - new_gps->setup(); - return new_gps; + new_gps->setup(); + return new_gps; + } } return nullptr; #endif -} \ No newline at end of file +}