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
This commit is contained in:
etrinh 2021-05-12 13:03:10 +02:00 committed by GitHub
parent ed54da7089
commit 75c863bffe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 0 deletions

View File

@ -65,6 +65,16 @@
// this option might be also set via compiler flag -DSMALL_GROUPOBJECT if required // this option might be also set via compiler flag -DSMALL_GROUPOBJECT if required
//#define SMALL_GROUPOBJECT //#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 #endif

View File

@ -343,7 +343,11 @@ uint64_t KNXValue::ulongValue() const
case DoubleType: case DoubleType:
return (uint64_t)_value.doubleValue; return (uint64_t)_value.doubleValue;
case StringType: case StringType:
#ifndef KNX_NO_STRTOx_CONVERSION
return (uint64_t)strtoul(_value.stringValue, NULL, 0); return (uint64_t)strtoul(_value.stringValue, NULL, 0);
#else
return 0;
#endif
} }
return 0; return 0;
} }
@ -444,7 +448,11 @@ int64_t KNXValue::longValue() const
case DoubleType: case DoubleType:
return (int64_t)_value.doubleValue; return (int64_t)_value.doubleValue;
case StringType: case StringType:
#ifndef KNX_NO_STRTOx_CONVERSION
return strtol(_value.stringValue, NULL, 0); return strtol(_value.stringValue, NULL, 0);
#else
return 0;
#endif
} }
return 0; return 0;
} }
@ -476,7 +484,11 @@ double KNXValue::doubleValue() const
case LongType: case LongType:
return _value.longValue; return _value.longValue;
case StringType: case StringType:
#ifndef KNX_NO_STRTOx_CONVERSION
return strtod(_value.stringValue, NULL); return strtod(_value.stringValue, NULL);
#else
return 0;
#endif
} }
return 0; return 0;
} }