Skip to content

Commit fc5ec94

Browse files
sanujkulper1234
andauthored
Adding advance example and documentation (#3)
* Created an advance example that uses SoftwareSerial * Added documnetation in Readme.md * Some minor changes * Update README.md Co-Authored-By: per1234 <accounts@perglass.com> * Update README.md Co-Authored-By: per1234 <accounts@perglass.com> * Update examples/Arduino_Debug_Advance/Arduino_Debug_Advance.ino Co-Authored-By: per1234 <accounts@perglass.com> * Update README.md about Debug.print() Co-Authored-By: per1234 <accounts@perglass.com> * Update examples/Arduino_Debug_Advance/Arduino_Debug_Advance.ino Correcting spelling of Arduino in comments Co-Authored-By: per1234 <accounts@perglass.com> * Update examples/Arduino_Debug_Advance/Arduino_Debug_Advance.ino Co-Authored-By: per1234 <accounts@perglass.com> * Update README.md Adding a linebreak Co-Authored-By: per1234 <accounts@perglass.com> * Update README.md Adding one more linebreak Co-Authored-By: per1234 <accounts@perglass.com> * removing numbers & adding return types & examples * Auto formatting the code Co-authored-by: per1234 <accounts@perglass.com>
1 parent 5abab88 commit fc5ec94

File tree

2 files changed

+88
-0
lines changed

2 files changed

+88
-0
lines changed

README.md

+59
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,62 @@ If desired timestamps can be prefixed to the debug message. Timestamp output can
2727

2828
# How-To-Use Advanced
2929
Normally all debug output is redirected to the primary serial output of each board (`Serial`). In case you want to redirect the output to another output stream you can make use of `setDebugOutputStream(&Serial2)`.
30+
31+
# Documentation
32+
### Debug :
33+
Arduino_DebugUtils Object that will be used for calling member functions.
34+
35+
### Debug.setDebugLevel(int const debug_level) :
36+
Parameter debug_level in order of lowest to highest priority are : `DBG_NONE`, `DBG_ERROR`, `DBG_WARNING`, `DBG_INFO` (default), `DBG_DEBUG`, and `DBG_VERBOSE`.
37+
38+
Return type: void.
39+
40+
Example:
41+
```
42+
Debug.setDebugLevel(DBG_VERBOSE);
43+
```
44+
### Debug.setDebugOutputStream(Stream * stream) :
45+
By default, Output Stream is Serial. In advanced cases other objects could be other serial ports (if available), or can be a Software Serial object.
46+
47+
Return type: void.
48+
49+
Example:
50+
```
51+
SoftwareSerial mySerial(10, 11); // RX, TX
52+
Debug.setDebugOutputStream(&mySerial);
53+
```
54+
### Debug.timestampOn() :
55+
Calling this function switches on the timestamp in the `Debug.print()` function call;
56+
By default, printing timestamp is off, unless turned on using this function call.
57+
58+
Return type: void.
59+
60+
Example:
61+
```
62+
Debug.timestampOn();
63+
Debug.print(DBG_VERBOSE, "i = %d", i); //Output looks like : [ 21007 ] i = 21
64+
```
65+
66+
### Debug.timestampOff() :
67+
Calling this function switches off the timestamp in the `Debug.print()` function call;
68+
69+
Return type: void.
70+
71+
Example:
72+
```
73+
Debug.timestampOff();
74+
Debug.print(DBG_VERBOSE, "i = %d", i); //Output looks like : i = 21
75+
```
76+
77+
78+
### Debug.print(int const debug_level, const char * fmt, ...);
79+
This function prints the message if parameter `debug_level` in the `Debug.print(debug_level, ...)` function call belongs to the range: DBG_ERROR <= debug_level <= (<DBG_LEVEL> that has been set using `setDebugLevel()` function).
80+
81+
Return type: void.
82+
83+
Example:
84+
```
85+
Debug.setDebugLevel(DBG_VERBOSE);
86+
int i = 0;
87+
Debug.print(DBG_VERBOSE, "DBG_VERBOSE i = %d", i);
88+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
Advanced Debug can be helpful in embedded applications when
3+
there are more that two microcontrollers connected serially
4+
or a wireless sensor like XBee is connected to the serial port
5+
that will send data wirelessly to other XBee node.
6+
7+
In boards like Arduino Nano, UNO, MEGA only one serial port is available,
8+
therefore additional Software Serial ports can be made using SoftwareSerial
9+
*/
10+
11+
#include "Arduino_DebugUtils.h"
12+
#include <SoftwareSerial.h>
13+
14+
SoftwareSerial mySerial(10, 11); // RX, TX
15+
16+
void setup() {
17+
mySerial.begin(9600);
18+
Debug.setDebugOutputStream(&mySerial);
19+
Debug.setDebugLevel(DBG_VERBOSE);
20+
Debug.timestampOn();
21+
}
22+
23+
int i = 0;
24+
25+
void loop() {
26+
Debug.print(DBG_VERBOSE, "i = %d", i);
27+
i++;
28+
delay(1000);
29+
}

0 commit comments

Comments
 (0)