forked from guyzmo/avr_nrf_ancs_library
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathutilities.h
67 lines (59 loc) · 1.31 KB
/
utilities.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/** (c)2013, Bernard Pratz, bernard at pratz dot net
* under the WTFPL License
*/
#ifndef _UTILITIES_H_
#define _UTILITIES_H_
#include <Arduino.h>
void free_ram (void);
void serial_print_char(char c);
#ifdef DEBUG1
#define debug_println(...) Serial.println(__VA_ARGS__)
#define debug_print(...) Serial.print(__VA_ARGS__)
#else
#define debug_println(...)
#define debug_print(...)
#endif
#ifdef DEBUG2
#define debug2_println(...) Serial.println(__VA_ARGS__)
#define debug2_print(...) Serial.print(__VA_ARGS__)
#else
#define debug2_println(...)
#define debug2_print(...)
#endif
#ifdef DEBUG3
#define debug3_println(...) Serial.println(__VA_ARGS__)
#define debug3_print(...) Serial.print(__VA_ARGS__)
#else
#define debug3_println(...)
#define debug3_print(...)
#endif
static uint8_t base=0;
inline Print &operator <<(Print &obj, unsigned long arg)
{
switch (base) {
case HEX: obj.print("0x"); break;
case BIN: obj.print("0b"); break;
}
obj.print(arg, (int)base);
base = 0;
return obj;
}
template<class T>
inline Print &operator <<(Print &obj, T arg)
{
obj.print(arg);
return obj;
}
inline unsigned long hex(unsigned long arg)
{
base = HEX;
return arg;
}
inline unsigned long bin(unsigned long arg)
{
base = BIN;
return arg;
}
#define endl F("\n")
#define cout Serial
#endif