From 75c863bffe89e797d39d8bb3dcd85451dbbb95dd Mon Sep 17 00:00:00 2001 From: etrinh Date: Wed, 12 May 2021 13:03:10 +0200 Subject: [PATCH] Add new KNX_NO_STRTOx_CONVERSION define for footprint reduction (#137) * Remove uniqueSerialNumber debug log to reduce footprint * add KNX_NO_STRTOx_CONVERSION to avoid expensive strtod conversion --- src/knx/config.h | 10 ++++++++++ src/knx/knx_value.cpp | 12 ++++++++++++ 2 files changed, 22 insertions(+) diff --git a/src/knx/config.h b/src/knx/config.h index a042ae3..f937510 100644 --- a/src/knx/config.h +++ b/src/knx/config.h @@ -65,6 +65,16 @@ // this option might be also set via compiler flag -DSMALL_GROUPOBJECT if required //#define SMALL_GROUPOBJECT +// Some defines to reduce footprint +// Do not perform conversion from KNXValue(const char*) to other types, it mainly avoids the expensive strtod +//#define KNX_NO_STRTOx_CONVERSION +// Do not print messages +//#define KNX_NO_PRINT +// Do not use SPI (Arduino variants) +//#define KNX_NO_SPI +// Do not use the default UART (Arduino variants), it must be defined by ArduinoPlatform::knxUart +// (combined with other flags (HWSERIAL_NONE for stm32) - avoid allocation of RX/TX buffers for all serial lines) +//#define KNX_NO_DEFAULT_UART #endif diff --git a/src/knx/knx_value.cpp b/src/knx/knx_value.cpp index de7a4b7..79ee503 100644 --- a/src/knx/knx_value.cpp +++ b/src/knx/knx_value.cpp @@ -343,7 +343,11 @@ uint64_t KNXValue::ulongValue() const case DoubleType: return (uint64_t)_value.doubleValue; case StringType: +#ifndef KNX_NO_STRTOx_CONVERSION return (uint64_t)strtoul(_value.stringValue, NULL, 0); +#else + return 0; +#endif } return 0; } @@ -444,7 +448,11 @@ int64_t KNXValue::longValue() const case DoubleType: return (int64_t)_value.doubleValue; case StringType: +#ifndef KNX_NO_STRTOx_CONVERSION return strtol(_value.stringValue, NULL, 0); +#else + return 0; +#endif } return 0; } @@ -476,7 +484,11 @@ double KNXValue::doubleValue() const case LongType: return _value.longValue; case StringType: +#ifndef KNX_NO_STRTOx_CONVERSION return strtod(_value.stringValue, NULL); +#else + return 0; +#endif } return 0; }