GAP based TOF Demo
Dependencies: BLE_API X_NUCLEO_6180XA1 mbed
Fork of BLE_HeartRate_IDB0XA1 by
bricks/trace.cpp@23:677689000369, 2017-01-06 (annotated)
- Committer:
- hux
- Date:
- Fri Jan 06 15:28:18 2017 +0000
- Revision:
- 23:677689000369
- Child:
- 27:32267cee7cb8
Already nice & easy level. Still bugs!
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
hux | 23:677689000369 | 1 | // trace.cpp - trace a message depending on verbose level |
hux | 23:677689000369 | 2 | // |
hux | 23:677689000369 | 3 | |
hux | 23:677689000369 | 4 | #include "bricks/trace.h" |
hux | 23:677689000369 | 5 | |
hux | 23:677689000369 | 6 | Serial pc(USBTX, USBRX); // serial port to PC terminal |
hux | 23:677689000369 | 7 | |
hux | 23:677689000369 | 8 | static int threshold = 0; // verbose threshold, no verbose messages |
hux | 23:677689000369 | 9 | |
hux | 23:677689000369 | 10 | void verbose(int level) // setup verbose level |
hux | 23:677689000369 | 11 | { |
hux | 23:677689000369 | 12 | threshold = level; // update verbose threshold |
hux | 23:677689000369 | 13 | } |
hux | 23:677689000369 | 14 | |
hux | 23:677689000369 | 15 | |
hux | 23:677689000369 | 16 | void trace(int level, const char *msg) // trace a message |
hux | 23:677689000369 | 17 | { |
hux | 23:677689000369 | 18 | if (level <= threshold) // update verbose threshold |
hux | 23:677689000369 | 19 | { char buf[2] = " "; // must be terminated |
hux | 23:677689000369 | 20 | |
hux | 23:677689000369 | 21 | for (; *msg; msg++) |
hux | 23:677689000369 | 22 | { buf[0] = *msg; |
hux | 23:677689000369 | 23 | pc.printf(buf); |
hux | 23:677689000369 | 24 | if (*msg == '\n') |
hux | 23:677689000369 | 25 | { buf[0] = '\r'; // auto adding carriage return |
hux | 23:677689000369 | 26 | pc.printf(buf); |
hux | 23:677689000369 | 27 | } |
hux | 23:677689000369 | 28 | } |
hux | 23:677689000369 | 29 | } |
hux | 23:677689000369 | 30 | } |
hux | 23:677689000369 | 31 | |
hux | 23:677689000369 | 32 |