[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) {
asciiLen = 1;
#if !defined(RADIOLIB_STATIC_ONLY)
#if !RADIOLIB_STATIC_ONLY
strAscii = new char[1];
#endif
strAscii[0] = c;
@ -13,7 +13,7 @@ ITA2String::ITA2String(char c) {
ITA2String::ITA2String(const char* str) {
asciiLen = strlen(str);
#if !defined(RADIOLIB_STATIC_ONLY)
#if !RADIOLIB_STATIC_ONLY
strAscii = new char[asciiLen + 1];
#endif
strcpy(strAscii, str);
@ -21,7 +21,7 @@ ITA2String::ITA2String(const char* str) {
}
ITA2String::~ITA2String() {
#if !defined(RADIOLIB_STATIC_ONLY)
#if !RADIOLIB_STATIC_ONLY
delete[] strAscii;
#endif
}
@ -40,7 +40,7 @@ size_t ITA2String::length() {
uint8_t* ITA2String::byteArr() {
// 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];
#else
uint8_t* temp = new uint8_t[asciiLen*2 + 1];
@ -87,7 +87,7 @@ uint8_t* ITA2String::byteArr() {
uint8_t* arr = new uint8_t[arrayLen];
memcpy(arr, temp, arrayLen);
#if !defined(RADIOLIB_STATIC_ONLY)
#if !RADIOLIB_STATIC_ONLY
delete[] temp;
#endif

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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