Add KNX_NO_PRINT to define in project to avoid console info and reduce footprint (#127)

This commit is contained in:
etrinh 2021-03-11 09:38:06 +01:00 committed by GitHub
parent 164bf59166
commit 44075d80f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 14 additions and 0 deletions

View File

@ -112,6 +112,7 @@ int ArduinoPlatform::readWriteSpi(uint8_t *data, size_t len)
return 0;
}
#ifndef KNX_NO_PRINT
void printUint64(uint64_t value, int base = DEC)
{
char buf[8 * sizeof(uint64_t) + 1];
@ -284,3 +285,4 @@ void println(void)
{
ArduinoPlatform::SerialDebug->println();
}
#endif // KNX_NO_PRINT

View File

@ -134,6 +134,7 @@ void delayMicroseconds (unsigned int howLong)
ClockP_usleep(howLong);
}
#ifndef KNX_NO_PRINT
size_t write(uint8_t c)
{
#if defined(PRINT_UART)
@ -402,6 +403,7 @@ void println(double num)
// default: print 10 digits
println(num, 10);
}
#endif // KNX_NO_PRINT
uint32_t digitalRead(uint32_t dwPin)
{

View File

@ -8,6 +8,7 @@ const uint8_t* popByte(uint8_t& b, const uint8_t* data)
return data;
}
#ifndef KNX_NO_PRINT
void printHex(const char* suffix, const uint8_t *data, size_t length, bool newline)
{
print(suffix);
@ -21,6 +22,7 @@ void printHex(const char* suffix, const uint8_t *data, size_t length, bool newli
println();
}
}
#endif
const uint8_t* popWord(uint16_t& w, const uint8_t* data)
{

View File

@ -63,6 +63,7 @@ typedef void (*voidFuncPtr)(void);
void attachInterrupt(uint32_t pin, voidFuncPtr callback, uint32_t mode);
#endif
#ifndef KNX_NO_PRINT
void print(const char[]);
void print(char);
void print(unsigned char, int = DEC);
@ -87,6 +88,11 @@ void println(double);
void println(void);
void printHex(const char* suffix, const uint8_t *data, size_t length, bool newline = true);
#else
#define print(...) do {} while(0)
#define println(...) do {} while(0)
#define printHex(...) do {} while(0)
#endif
const uint8_t* popByte(uint8_t& b, const uint8_t* data);
const uint8_t* popWord(uint16_t& w, const uint8_t* data);

View File

@ -502,6 +502,7 @@ void LinuxPlatform::setupUart()
}
}
#ifndef KNX_NO_PRINT
void printUint64(uint64_t value, int base = DEC)
{
char buf[8 * sizeof(uint64_t) + 1];
@ -708,6 +709,7 @@ void println(void)
{
printf("\n");
}
#endif // KNX_NO_PRINT
void pinMode(uint32_t dwPin, uint32_t dwMode)
{