Skip to content

Commit 73067ba

Browse files
committed
Apply Arduino formatting via astyle and examples_formatter.conf
1 parent a60ea8d commit 73067ba

File tree

3 files changed

+80
-93
lines changed

3 files changed

+80
-93
lines changed

examples/Arduino_Debug_Basic/Arduino_Debug_Basic.ino

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#include "ArduinoDebugUtils.h"
22

33
void setup() {
4-
54
Serial.begin(9600);
65

76
ArduinoDebugUtils.timestampOn();

src/ArduinoDebugUtils.cpp

Lines changed: 59 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -25,88 +25,78 @@
2525
NAMESPACE
2626
******************************************************************************/
2727

28-
namespace impl
29-
{
28+
namespace impl {
3029

31-
/******************************************************************************
32-
CONSTANTS
33-
******************************************************************************/
30+
/******************************************************************************
31+
CONSTANTS
32+
******************************************************************************/
3433

35-
static int const DEFAULT_DEBUG_LEVEL = DEBUG_LVL_INFO;
36-
static Stream * DEFAULT_OUTPUT_STREAM = &Serial;
34+
static int const DEFAULT_DEBUG_LEVEL = DEBUG_LVL_INFO;
35+
static Stream * DEFAULT_OUTPUT_STREAM = &Serial;
3736

38-
/******************************************************************************
39-
CTOR/DTOR
40-
******************************************************************************/
37+
/******************************************************************************
38+
CTOR/DTOR
39+
******************************************************************************/
4140

42-
ArduinoDebugUtils::ArduinoDebugUtils()
43-
{
44-
timestampOff();
45-
setDebugLevel(DEFAULT_DEBUG_LEVEL);
46-
setDebugOutputStream(DEFAULT_OUTPUT_STREAM);
47-
}
41+
ArduinoDebugUtils::ArduinoDebugUtils() {
42+
timestampOff();
43+
setDebugLevel(DEFAULT_DEBUG_LEVEL);
44+
setDebugOutputStream(DEFAULT_OUTPUT_STREAM);
45+
}
4846

49-
/******************************************************************************
50-
PUBLIC MEMBER FUNCTIONS
51-
******************************************************************************/
47+
/******************************************************************************
48+
PUBLIC MEMBER FUNCTIONS
49+
******************************************************************************/
5250

53-
void ArduinoDebugUtils::setDebugLevel(int const debug_level)
54-
{
55-
_debug_level = debug_level;
56-
}
57-
58-
void ArduinoDebugUtils::setDebugOutputStream(Stream * stream)
59-
{
60-
_debug_output_stream = stream;
61-
}
62-
63-
void ArduinoDebugUtils::timestampOn()
64-
{
65-
_timestamp_on = true;
66-
}
67-
68-
void ArduinoDebugUtils::timestampOff()
69-
{
70-
_timestamp_on = false;
71-
}
72-
73-
void ArduinoDebugUtils::debugPrint(int const debug_level, const char * fmt, ...)
74-
{
75-
if (debug_level >= DEBUG_LVL_ERROR &&
76-
debug_level <= DEBUG_LVL_VERBOSE &&
77-
debug_level <= _debug_level)
78-
{
79-
if(_timestamp_on)
80-
{
81-
char timestamp[20];
82-
snprintf(timestamp, 20, "[ %lu ] ", millis());
83-
_debug_output_stream->print(timestamp);
84-
}
51+
void ArduinoDebugUtils::setDebugLevel(int const debug_level) {
52+
_debug_level = debug_level;
53+
}
8554

86-
va_list args;
87-
va_start(args, fmt);
88-
vDebugPrint(fmt, args);
89-
va_end(args);
55+
void ArduinoDebugUtils::setDebugOutputStream(Stream * stream) {
56+
_debug_output_stream = stream;
9057
}
91-
}
9258

93-
/******************************************************************************
94-
PRIVATE MEMBER FUNCTIONS
95-
******************************************************************************/
59+
void ArduinoDebugUtils::timestampOn() {
60+
_timestamp_on = true;
61+
}
9662

97-
void ArduinoDebugUtils::vDebugPrint(char const * fmt, va_list args)
98-
{
99-
static size_t const MSG_BUF_SIZE = 120;
100-
char msg_buf[MSG_BUF_SIZE] = {0};
63+
void ArduinoDebugUtils::timestampOff() {
64+
_timestamp_on = false;
65+
}
10166

102-
vsnprintf(msg_buf, MSG_BUF_SIZE, fmt, args);
67+
void ArduinoDebugUtils::debugPrint(int const debug_level, const char * fmt, ...) {
68+
if (debug_level >= DEBUG_LVL_ERROR &&
69+
debug_level <= DEBUG_LVL_VERBOSE &&
70+
debug_level <= _debug_level) {
71+
if (_timestamp_on) {
72+
char timestamp[20];
73+
snprintf(timestamp, 20, "[ %lu ] ", millis());
74+
_debug_output_stream->print(timestamp);
75+
}
76+
77+
va_list args;
78+
va_start(args, fmt);
79+
vDebugPrint(fmt, args);
80+
va_end(args);
81+
}
82+
}
10383

104-
_debug_output_stream->println(msg_buf);
105-
}
84+
/******************************************************************************
85+
PRIVATE MEMBER FUNCTIONS
86+
******************************************************************************/
10687

107-
/******************************************************************************
108-
NAMESPACE
109-
******************************************************************************/
88+
void ArduinoDebugUtils::vDebugPrint(char const * fmt, va_list args) {
89+
static size_t const MSG_BUF_SIZE = 120;
90+
char msg_buf[MSG_BUF_SIZE] = {0};
91+
92+
vsnprintf(msg_buf, MSG_BUF_SIZE, fmt, args);
93+
94+
_debug_output_stream->println(msg_buf);
95+
}
96+
97+
/******************************************************************************
98+
NAMESPACE
99+
******************************************************************************/
110100

111101
} /* impl */
112102

src/ArduinoDebugUtils.h

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -41,42 +41,40 @@ static int const DEBUG_LVL_VERBOSE = 4;
4141
NAMESPACE
4242
******************************************************************************/
4343

44-
namespace impl
45-
{
44+
namespace impl {
4645

47-
/******************************************************************************
48-
CLASS DECLARATION
49-
******************************************************************************/
46+
/******************************************************************************
47+
CLASS DECLARATION
48+
******************************************************************************/
5049

51-
class ArduinoDebugUtils
52-
{
50+
class ArduinoDebugUtils {
5351

54-
public:
52+
public:
5553

56-
ArduinoDebugUtils();
54+
ArduinoDebugUtils();
5755

58-
void setDebugLevel(int const debug_level);
59-
void setDebugOutputStream(Stream * stream);
56+
void setDebugLevel(int const debug_level);
57+
void setDebugOutputStream(Stream * stream);
6058

61-
void timestampOn();
62-
void timestampOff();
59+
void timestampOn();
60+
void timestampOff();
6361

64-
void debugPrint(int const debug_level, const char * fmt, ...);
62+
void debugPrint(int const debug_level, const char * fmt, ...);
6563

6664

67-
private:
65+
private:
6866

69-
bool _timestamp_on;
70-
int _debug_level;
71-
Stream * _debug_output_stream;
67+
bool _timestamp_on;
68+
int _debug_level;
69+
Stream * _debug_output_stream;
7270

73-
void vDebugPrint(char const * fmt, va_list args);
71+
void vDebugPrint(char const * fmt, va_list args);
7472

75-
};
73+
};
7674

77-
/******************************************************************************
78-
NAMESPACE
79-
******************************************************************************/
75+
/******************************************************************************
76+
NAMESPACE
77+
******************************************************************************/
8078

8179
} /* impl */
8280

0 commit comments

Comments
 (0)