[Print] Reworked macro configuration system

pull/893/head
jgromes 2023-11-27 21:18:10 +01:00
rodzic 395101ec20
commit e6a6923b25
4 zmienionych plików z 10 dodań i 10 usunięć

Wyświetl plik

@ -4,7 +4,7 @@
ITA2String::ITA2String(char c) { ITA2String::ITA2String(char c) {
asciiLen = 1; asciiLen = 1;
#if !defined(RADIOLIB_STATIC_ONLY) #if !RADIOLIB_STATIC_ONLY
strAscii = new char[1]; strAscii = new char[1];
#endif #endif
strAscii[0] = c; strAscii[0] = c;
@ -13,7 +13,7 @@ ITA2String::ITA2String(char c) {
ITA2String::ITA2String(const char* str) { ITA2String::ITA2String(const char* str) {
asciiLen = strlen(str); asciiLen = strlen(str);
#if !defined(RADIOLIB_STATIC_ONLY) #if !RADIOLIB_STATIC_ONLY
strAscii = new char[asciiLen + 1]; strAscii = new char[asciiLen + 1];
#endif #endif
strcpy(strAscii, str); strcpy(strAscii, str);
@ -21,7 +21,7 @@ ITA2String::ITA2String(const char* str) {
} }
ITA2String::~ITA2String() { ITA2String::~ITA2String() {
#if !defined(RADIOLIB_STATIC_ONLY) #if !RADIOLIB_STATIC_ONLY
delete[] strAscii; delete[] strAscii;
#endif #endif
} }
@ -40,7 +40,7 @@ size_t ITA2String::length() {
uint8_t* ITA2String::byteArr() { uint8_t* ITA2String::byteArr() {
// create temporary array 2x the string length (figures may be 3 bytes) // create temporary array 2x the string length (figures may be 3 bytes)
#if defined(RADIOLIB_STATIC_ONLY) #if RADIOLIB_STATIC_ONLY
uint8_t temp[RADIOLIB_STATIC_ARRAY_SIZE*2 + 1]; uint8_t temp[RADIOLIB_STATIC_ARRAY_SIZE*2 + 1];
#else #else
uint8_t* temp = new uint8_t[asciiLen*2 + 1]; uint8_t* temp = new uint8_t[asciiLen*2 + 1];
@ -87,7 +87,7 @@ uint8_t* ITA2String::byteArr() {
uint8_t* arr = new uint8_t[arrayLen]; uint8_t* arr = new uint8_t[arrayLen];
memcpy(arr, temp, arrayLen); memcpy(arr, temp, arrayLen);
#if !defined(RADIOLIB_STATIC_ONLY) #if !RADIOLIB_STATIC_ONLY
delete[] temp; delete[] temp;
#endif #endif

Wyświetl plik

@ -53,10 +53,10 @@ class ITA2String {
*/ */
uint8_t* byteArr(); uint8_t* byteArr();
#if !defined(RADIOLIB_GODMODE) #if !RADIOLIB_GODMODE
private: private:
#endif #endif
#if defined(RADIOLIB_STATIC_ONLY) #if RADIOLIB_STATIC_ONLY
char strAscii[RADIOLIB_STATIC_ARRAY_SIZE]; char strAscii[RADIOLIB_STATIC_ARRAY_SIZE];
#else #else
char* strAscii; char* strAscii;

Wyświetl plik

@ -42,7 +42,7 @@ size_t RadioLibPrint::print(const __FlashStringHelper* fstr) {
} }
// dynamically allocate memory // dynamically allocate memory
#if defined(RADIOLIB_STATIC_ONLY) #if RADIOLIB_STATIC_ONLY
char str[RADIOLIB_STATIC_ARRAY_SIZE]; char str[RADIOLIB_STATIC_ARRAY_SIZE];
#else #else
char* str = new char[len]; char* str = new char[len];
@ -61,7 +61,7 @@ size_t RadioLibPrint::print(const __FlashStringHelper* fstr) {
} else { } else {
n = write((uint8_t*)str, len); n = write((uint8_t*)str, len);
} }
#if !defined(RADIOLIB_STATIC_ONLY) #if !RADIOLIB_STATIC_ONLY
delete[] str; delete[] str;
#endif #endif
return(n); return(n);

Wyświetl plik

@ -53,7 +53,7 @@ class RadioLibPrint {
size_t println(double, int = 2); size_t println(double, int = 2);
size_t println(void); size_t println(void);
#if !defined(RADIOLIB_GODMODE) #if !RADIOLIB_GODMODE
protected: protected:
#endif #endif
uint8_t encoding = RADIOLIB_ASCII_EXTENDED; uint8_t encoding = RADIOLIB_ASCII_EXTENDED;