SimpleFOClibrary 2.4.0
Loading...
Searching...
No Matches
SimpleFOCDebug.h
Go to the documentation of this file.
1
2#ifndef __SIMPLEFOCDEBUG_H__
3#define __SIMPLEFOCDEBUG_H__
4
5#include "Arduino.h"
6
7
8/**
9 * SimpleFOCDebug class
10 *
11 * This class is used to print debug messages to a chosen output.
12 * Currently, Print instances are supported as targets, e.g. serial port.
13 *
14 * Activate debug output globally by calling enable(), optionally passing
15 * in a Print instance. If none is provided "Serial" is used by default.
16 *
17 * To produce debug output, use the macro SIMPLEFOC_DEBUG:
18 * SIMPLEFOC_DEBUG("Debug message!");
19 * SIMPLEFOC_DEBUG("a float value:", 123.456f);
20 * SIMPLEFOC_DEBUG("an integer value: ", 123);
21 *
22 * Keep debugging output short and simple. Some of our MCUs have limited
23 * RAM and limited serial output capabilities.
24 *
25 * By default, the SIMPLEFOC_DEBUG macro uses the flash string helper to
26 * help preserve memory on Arduino boards.
27 *
28 * You can also disable debug output completely. In this case all debug output
29 * and the SimpleFOCDebug class is removed from the compiled code.
30 * Add -DSIMPLEFOC_DISABLE_DEBUG to your compiler flags to disable debug in
31 * this way.
32 *
33 **/
34
35// #define SIMPLEFOC_DISABLE_DEBUG
36
37#ifndef SIMPLEFOC_DISABLE_DEBUG
38
40public:
41 static void enable(Print* debugPrint = &Serial);
42
43 static void println(const __FlashStringHelper* msg);
44 static void println(const StringSumHelper msg);
45 static void println(const char* msg);
46 static void println(const __FlashStringHelper* msg, float val);
47 static void println(const char* msg, float val);
48 static void println(const __FlashStringHelper* msg, int val);
49 static void println(const char* msg, int val);
50 static void println(const char* msg, char val);
51 static void println();
52 static void println(int val);
53 static void println(float val);
54
55 static void print(const char* msg);
56 static void print(const __FlashStringHelper* msg);
57 static void print(const StringSumHelper msg);
58 static void print(int val);
59 static void print(float val);
60
61protected:
62 static Print* _debugPrint;
63};
64
65
66#define SIMPLEFOC_DEBUG(msg, ...) \
67 SimpleFOCDebug::println(F(msg), ##__VA_ARGS__)
68
69#else //ifndef SIMPLEFOC_DISABLE_DEBUG
70
71#define SIMPLEFOC_DEBUG(msg, ...)
72
73
74#endif //ifndef SIMPLEFOC_DISABLE_DEBUG
75#endif
76
static Print * _debugPrint
static void print(const char *msg)
static void println()
static void enable(Print *debugPrint=&Serial)