From cf783a5bae2e30a29ac32db10511b2636f31a2b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Thu, 24 Nov 2022 09:23:17 +0100 Subject: [PATCH] make GPS pins configurable through protos --- src/gps/GPS.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/gps/GPS.cpp b/src/gps/GPS.cpp index 534a0ebea..54dc59cbb 100644 --- a/src/gps/GPS.cpp +++ b/src/gps/GPS.cpp @@ -150,9 +150,21 @@ bool GPS::setupGPS() _serial_gps->setRxBufferSize(2048); // the default is 256 #endif +// if the overrides are not dialled in, set them from the board definitions, if they exist + +#if defined(GPS_RX_PIN) +if (!config.position.rx_gpio) + config.position.rx_gpio = GPS_RX_PIN; +#endif +#if defined(GPS_TX_PIN) +if (!config.position.tx_gpio) + config.position.tx_gpio = GPS_TX_PIN; +#endif + // ESP32 has a special set of parameters vs other arduino ports -#if defined(GPS_RX_PIN) && defined(ARCH_ESP32) - _serial_gps->begin(GPS_BAUDRATE, SERIAL_8N1, GPS_RX_PIN, GPS_TX_PIN); +#if defined(ARCH_ESP32) + if(config.position.rx_gpio) + _serial_gps->begin(GPS_BAUDRATE, SERIAL_8N1, config.position.rx_gpio, config.position.tx_gpio); #else _serial_gps->begin(GPS_BAUDRATE); #endif