From 41a8ca6d5d6a1ae47971b4d631da62334b9c05b8 Mon Sep 17 00:00:00 2001 From: Christian Stehno Date: Sun, 2 Apr 2023 01:20:16 +0200 Subject: [PATCH] Improve speed of single gnss enable/check method by skipping full loop after finding match --- src/SparkFun_u-blox_GNSS_Arduino_Library.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/SparkFun_u-blox_GNSS_Arduino_Library.cpp b/src/SparkFun_u-blox_GNSS_Arduino_Library.cpp index 460dbce..7f9d2fe 100644 --- a/src/SparkFun_u-blox_GNSS_Arduino_Library.cpp +++ b/src/SparkFun_u-blox_GNSS_Arduino_Library.cpp @@ -8293,6 +8293,7 @@ bool SFE_UBLOX_GNSS::enableGNSS(bool enable, sfe_ublox_gnss_ids_e id, uint16_t m payloadCfg[(block * 8) + 4 + 4] |= 0x01; // Set the enable bit in flags (Little Endian) else payloadCfg[(block * 8) + 4 + 4] &= 0xFE; // Clear the enable bit in flags (Little Endian) + break; } } @@ -8310,8 +8311,6 @@ bool SFE_UBLOX_GNSS::isGNSSenabled(sfe_ublox_gnss_ids_e id, uint16_t maxWait) if (sendCommand(&packetCfg, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED) // We are expecting data and an ACK return (false); - bool retVal = false; - uint8_t numConfigBlocks = payloadCfg[3]; // Extract the numConfigBlocks for (uint8_t block = 0; block < numConfigBlocks; block++) // Check each configuration block @@ -8320,11 +8319,11 @@ bool SFE_UBLOX_GNSS::isGNSSenabled(sfe_ublox_gnss_ids_e id, uint16_t maxWait) { // We have a match so check the enable bit in flags if ((payloadCfg[(block * 8) + 4 + 4] & 0x01) > 0) // Check the enable bit in flags (Little Endian) - retVal = true; + return true; } } - return (retVal); + return false; } // Reset ESF automatic IMU-mount alignment