Skip to content

Commit 0f59f10

Browse files
committed
Add support for strings stored in flash
1 parent eb3238b commit 0f59f10

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

src/Arduino_DebugUtils.cpp

+28-3
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,14 @@ void Arduino_DebugUtils::timestampOff() {
5858
_timestamp_on = false;
5959
}
6060

61-
void Arduino_DebugUtils::print(int const debug_level, const char * fmt, ...) {
61+
void Arduino_DebugUtils::print(int const debug_level, const char * fmt, ...)
62+
{
6263
if (debug_level >= DBG_ERROR &&
6364
debug_level <= DBG_VERBOSE &&
64-
debug_level <= _debug_level) {
65-
if (_timestamp_on) {
65+
debug_level <= _debug_level)
66+
{
67+
if (_timestamp_on)
68+
{
6669
char timestamp[20];
6770
snprintf(timestamp, 20, "[ %lu ] ", millis());
6871
_debug_output_stream->print(timestamp);
@@ -75,6 +78,28 @@ void Arduino_DebugUtils::print(int const debug_level, const char * fmt, ...) {
7578
}
7679
}
7780

81+
void Arduino_DebugUtils::print(int const debug_level, const __FlashStringHelper * fmt, ...)
82+
{
83+
if (debug_level >= DBG_ERROR &&
84+
debug_level <= DBG_VERBOSE &&
85+
debug_level <= _debug_level)
86+
{
87+
if (_timestamp_on)
88+
{
89+
char timestamp[20];
90+
snprintf(timestamp, 20, "[ %lu ] ", millis());
91+
_debug_output_stream->print(timestamp);
92+
}
93+
94+
String fmt_str(fmt);
95+
96+
va_list args;
97+
va_start(args, fmt_str.c_str());
98+
vPrint(fmt_str.c_str(), args);
99+
va_end(args);
100+
}
101+
}
102+
78103
/******************************************************************************
79104
PRIVATE MEMBER FUNCTIONS
80105
******************************************************************************/

src/Arduino_DebugUtils.h

+1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ class Arduino_DebugUtils {
5757
void timestampOff();
5858

5959
void print(int const debug_level, const char * fmt, ...);
60+
void print(int const debug_level, const __FlashStringHelper * fmt, ...);
6061

6162

6263
private:

0 commit comments

Comments
 (0)