kopia lustrzana https://github.com/jgromes/RadioLib
[Print] Chore: uncrustify formatting
rodzic
b2963ef232
commit
45cc32b50a
|
@ -20,7 +20,7 @@ ITA2String::ITA2String(const char* str) {
|
||||||
ita2Len = 0;
|
ita2Len = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ITA2String::ITA2String(const ITA2String& ita2) {
|
ITA2String::ITA2String(const ITA2String &ita2) {
|
||||||
this->asciiLen = ita2.asciiLen;
|
this->asciiLen = ita2.asciiLen;
|
||||||
this->ita2Len = ita2.ita2Len;
|
this->ita2Len = ita2.ita2Len;
|
||||||
#if !RADIOLIB_STATIC_ONLY
|
#if !RADIOLIB_STATIC_ONLY
|
||||||
|
@ -29,7 +29,7 @@ ITA2String::ITA2String(const ITA2String& ita2) {
|
||||||
strcpy(this->strAscii, ita2.strAscii);
|
strcpy(this->strAscii, ita2.strAscii);
|
||||||
}
|
}
|
||||||
|
|
||||||
ITA2String& ITA2String::operator=(const ITA2String& ita2) {
|
ITA2String &ITA2String::operator=(const ITA2String &ita2) {
|
||||||
if(&ita2 != this) {
|
if(&ita2 != this) {
|
||||||
this->asciiLen = ita2.asciiLen;
|
this->asciiLen = ita2.asciiLen;
|
||||||
this->ita2Len = ita2.ita2Len;
|
this->ita2Len = ita2.ita2Len;
|
||||||
|
@ -62,9 +62,9 @@ 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 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];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// ensure the minimum possible array size is always initialized
|
// ensure the minimum possible array size is always initialized
|
||||||
|
@ -89,7 +89,7 @@ uint8_t* ITA2String::byteArr() {
|
||||||
|
|
||||||
// check the following character (skip for message end)
|
// check the following character (skip for message end)
|
||||||
if(i < (asciiLen - 1)) {
|
if(i < (asciiLen - 1)) {
|
||||||
uint16_t nextCode = getBits(strAscii[i+1]);
|
uint16_t nextCode = getBits(strAscii[i + 1]);
|
||||||
uint8_t nextShift = (nextCode >> 5) & 0b11111;
|
uint8_t nextShift = (nextCode >> 5) & 0b11111;
|
||||||
if(nextShift == RADIOLIB_ITA2_LTRS) {
|
if(nextShift == RADIOLIB_ITA2_LTRS) {
|
||||||
// next character is a letter, terminate figure shift
|
// next character is a letter, terminate figure shift
|
||||||
|
|
|
@ -39,13 +39,13 @@ class ITA2String {
|
||||||
\brief Copy constructor.
|
\brief Copy constructor.
|
||||||
\param ita2 ITA2String instance to copy.
|
\param ita2 ITA2String instance to copy.
|
||||||
*/
|
*/
|
||||||
ITA2String(const ITA2String& ita2);
|
ITA2String(const ITA2String &ita2);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Overload for assignment operator.
|
\brief Overload for assignment operator.
|
||||||
\param ita2 rvalue ITA2String.
|
\param ita2 rvalue ITA2String.
|
||||||
*/
|
*/
|
||||||
ITA2String& operator=(const ITA2String& ita2);
|
ITA2String &operator=(const ITA2String &ita2);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Default destructor.
|
\brief Default destructor.
|
||||||
|
@ -65,9 +65,9 @@ class ITA2String {
|
||||||
*/
|
*/
|
||||||
uint8_t* byteArr();
|
uint8_t* byteArr();
|
||||||
|
|
||||||
#if !RADIOLIB_GODMODE
|
#if !RADIOLIB_GODMODE
|
||||||
private:
|
private:
|
||||||
#endif
|
#endif
|
||||||
#if RADIOLIB_STATIC_ONLY
|
#if RADIOLIB_STATIC_ONLY
|
||||||
char strAscii[RADIOLIB_STATIC_ARRAY_SIZE];
|
char strAscii[RADIOLIB_STATIC_ARRAY_SIZE];
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
size_t RadioLibPrint::print(ITA2String& ita2) {
|
size_t RadioLibPrint::print(ITA2String &ita2) {
|
||||||
uint8_t enc = this->encoding;
|
uint8_t enc = this->encoding;
|
||||||
this->encoding = RADIOLIB_ITA2;
|
this->encoding = RADIOLIB_ITA2;
|
||||||
uint8_t* arr = ita2.byteArr();
|
uint8_t* arr = ita2.byteArr();
|
||||||
|
@ -13,17 +13,20 @@ size_t RadioLibPrint::print(ITA2String& ita2) {
|
||||||
return(n);
|
return(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t RadioLibPrint::println(ITA2String& ita2) {
|
size_t RadioLibPrint::println(ITA2String &ita2) {
|
||||||
size_t n = RadioLibPrint::print(ita2);
|
size_t n = RadioLibPrint::print(ita2);
|
||||||
n += RadioLibPrint::println();
|
n += RadioLibPrint::println();
|
||||||
return(n);
|
return(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t RadioLibPrint::write(const uint8_t *buffer, size_t size) {
|
size_t RadioLibPrint::write(const uint8_t* buffer, size_t size) {
|
||||||
size_t n = 0;
|
size_t n = 0;
|
||||||
while (size--) {
|
while(size--) {
|
||||||
if (write(*buffer++)) n++;
|
if(write(*buffer++)) {
|
||||||
else break;
|
n++;
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
@ -67,7 +70,7 @@ size_t RadioLibPrint::print(const __FlashStringHelper* fstr) {
|
||||||
return(n);
|
return(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t RadioLibPrint::print(const String& str) {
|
size_t RadioLibPrint::print(const String &str) {
|
||||||
size_t n = 0;
|
size_t n = 0;
|
||||||
if(this->encoding == RADIOLIB_ITA2) {
|
if(this->encoding == RADIOLIB_ITA2) {
|
||||||
ITA2String ita2 = ITA2String(str.c_str());
|
ITA2String ita2 = ITA2String(str.c_str());
|
||||||
|
@ -84,7 +87,7 @@ size_t RadioLibPrint::println(const __FlashStringHelper* fstr) {
|
||||||
return(n);
|
return(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t RadioLibPrint::println(const String& str) {
|
size_t RadioLibPrint::println(const String &str) {
|
||||||
size_t n = RadioLibPrint::print(str);
|
size_t n = RadioLibPrint::print(str);
|
||||||
n += RadioLibPrint::println();
|
n += RadioLibPrint::println();
|
||||||
return(n);
|
return(n);
|
||||||
|
@ -129,7 +132,7 @@ size_t RadioLibPrint::print(long n, int base) {
|
||||||
if(base == 0) {
|
if(base == 0) {
|
||||||
return(write(n));
|
return(write(n));
|
||||||
} else if(base == DEC) {
|
} else if(base == DEC) {
|
||||||
if (n < 0) {
|
if(n < 0) {
|
||||||
int t = RadioLibPrint::print('-');
|
int t = RadioLibPrint::print('-');
|
||||||
n = -n;
|
n = -n;
|
||||||
return(RadioLibPrint::printNumber(n, DEC) + t);
|
return(RadioLibPrint::printNumber(n, DEC) + t);
|
||||||
|
@ -213,7 +216,7 @@ size_t RadioLibPrint::println(void) {
|
||||||
|
|
||||||
size_t RadioLibPrint::printNumber(unsigned long n, uint8_t base) {
|
size_t RadioLibPrint::printNumber(unsigned long n, uint8_t base) {
|
||||||
char buf[8 * sizeof(long) + 1];
|
char buf[8 * sizeof(long) + 1];
|
||||||
char *str = &buf[sizeof(buf) - 1];
|
char* str = &buf[sizeof(buf) - 1];
|
||||||
|
|
||||||
*str = '\0';
|
*str = '\0';
|
||||||
|
|
||||||
|
@ -246,11 +249,19 @@ size_t RadioLibPrint::printFloat(double number, uint8_t digits) {
|
||||||
size_t n = 0;
|
size_t n = 0;
|
||||||
|
|
||||||
char code[] = {0x00, 0x00, 0x00, 0x00};
|
char code[] = {0x00, 0x00, 0x00, 0x00};
|
||||||
if (isnan(number)) strcpy(code, "nan");
|
if(isnan(number)) {
|
||||||
if (isinf(number)) strcpy(code, "inf");
|
strcpy(code, "nan");
|
||||||
if (number > (double)4294967040.0) strcpy(code, "ovf"); // constant determined empirically
|
}
|
||||||
if (number < (double)-4294967040.0) strcpy(code, "ovf"); // constant determined empirically
|
if(isinf(number)) {
|
||||||
|
strcpy(code, "inf");
|
||||||
|
}
|
||||||
|
if(number > (double)4294967040.0) {
|
||||||
|
strcpy(code, "ovf"); // constant determined empirically
|
||||||
|
}
|
||||||
|
if(number < (double)-4294967040.0) {
|
||||||
|
strcpy(code, "ovf"); // constant determined empirically
|
||||||
|
|
||||||
|
}
|
||||||
if(code[0] != 0x00) {
|
if(code[0] != 0x00) {
|
||||||
if(this->encoding == RADIOLIB_ITA2) {
|
if(this->encoding == RADIOLIB_ITA2) {
|
||||||
ITA2String ita2 = ITA2String(code);
|
ITA2String ita2 = ITA2String(code);
|
||||||
|
@ -264,7 +275,7 @@ size_t RadioLibPrint::printFloat(double number, uint8_t digits) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle negative numbers
|
// Handle negative numbers
|
||||||
if (number < (double)0.0) {
|
if(number < (double)0.0) {
|
||||||
if(this->encoding == RADIOLIB_ITA2) {
|
if(this->encoding == RADIOLIB_ITA2) {
|
||||||
ITA2String ita2 = ITA2String("-");
|
ITA2String ita2 = ITA2String("-");
|
||||||
uint8_t* arr = ita2.byteArr();
|
uint8_t* arr = ita2.byteArr();
|
||||||
|
|
|
@ -17,23 +17,25 @@
|
||||||
class RadioLibPrint {
|
class RadioLibPrint {
|
||||||
public:
|
public:
|
||||||
virtual size_t write(uint8_t) = 0;
|
virtual size_t write(uint8_t) = 0;
|
||||||
size_t write(const char *str) {
|
size_t write(const char* str) {
|
||||||
if (str == NULL) return 0;
|
if(str == NULL) {
|
||||||
return write(reinterpret_cast<const uint8_t *>(str), strlen(str));
|
return 0;
|
||||||
}
|
}
|
||||||
virtual size_t write(const uint8_t *buffer, size_t size);
|
return write(reinterpret_cast<const uint8_t*>(str), strlen(str));
|
||||||
size_t write(const char *buffer, size_t size) {
|
}
|
||||||
return write(reinterpret_cast<const uint8_t *>(buffer), size);
|
virtual size_t write(const uint8_t* buffer, size_t size);
|
||||||
|
size_t write(const char* buffer, size_t size) {
|
||||||
|
return write(reinterpret_cast<const uint8_t*>(buffer), size);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t print(ITA2String& ita2);
|
size_t print(ITA2String &ita2);
|
||||||
size_t println(ITA2String& ita2);
|
size_t println(ITA2String &ita2);
|
||||||
|
|
||||||
#if defined(RADIOLIB_BUILD_ARDUINO)
|
#if defined(RADIOLIB_BUILD_ARDUINO)
|
||||||
size_t print(const __FlashStringHelper *);
|
size_t print(const __FlashStringHelper*);
|
||||||
size_t print(const String &);
|
size_t print(const String &);
|
||||||
|
|
||||||
size_t println(const __FlashStringHelper *);
|
size_t println(const __FlashStringHelper*);
|
||||||
size_t println(const String &);
|
size_t println(const String &);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -56,9 +58,9 @@ class RadioLibPrint {
|
||||||
size_t println(double, int = 2);
|
size_t println(double, int = 2);
|
||||||
size_t println(void);
|
size_t println(void);
|
||||||
|
|
||||||
#if !RADIOLIB_GODMODE
|
#if !RADIOLIB_GODMODE
|
||||||
protected:
|
protected:
|
||||||
#endif
|
#endif
|
||||||
uint8_t encoding = RADIOLIB_ASCII_EXTENDED;
|
uint8_t encoding = RADIOLIB_ASCII_EXTENDED;
|
||||||
const char* lineFeed = "\r\n";
|
const char* lineFeed = "\r\n";
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue