LD2410Async
Asynchronous Arduino ESP32 library for the LD2410 mmWave radar sensor
Loading...
Searching...
No Matches
LD2410Debug.h
Go to the documentation of this file.
1
2
3
#pragma once
4
#include "Arduino.h"
5
6
// =======================================================================================
7
// Debug level configuration
8
// =======================================================================================
9
// If not defined by the user/project, initialize to 0 (disabled).
10
11
#ifndef LD2410ASYNC_DEBUG_LEVEL
12
#define LD2410ASYNC_DEBUG_LEVEL 0
13
#endif
14
15
#ifndef LD2410ASYNC_DEBUG_DATA_LEVEL
16
#define LD2410ASYNC_DEBUG_DATA_LEVEL 0
17
#endif
18
19
20
// =======================================================================================
21
// Helper: Hex buffer print (only compiled if needed)
22
// =======================================================================================
23
#if (LD2410ASYNC_DEBUG_LEVEL > 1) || (LD2410ASYNC_DEBUG_DATA_LEVEL > 1)
24
static
inline
void
printBuf(
const
byte
* buf,
byte
size)
25
{
26
for
(
byte
i = 0; i < size; i++) {
27
String bStr(buf[i], HEX);
28
bStr.toUpperCase();
29
if
(bStr.length() == 1) bStr =
"0"
+ bStr;
30
Serial.print(bStr);
31
Serial.print(
' '
);
32
}
33
Serial.println();
34
}
35
#endif
36
37
// =======================================================================================
38
// Normal debug macros
39
// =======================================================================================
40
#if LD2410ASYNC_DEBUG_LEVEL > 0
41
#define DEBUG_PRINT_MILLIS { Serial.print(millis()); Serial.print(" "); }
42
#define DEBUG_PRINT(...) { Serial.print(__VA_ARGS__); }
43
#define DEBUG_PRINTLN(...) { Serial.println(__VA_ARGS__); }
44
#if LD2410ASYNC_DEBUG_LEVEL > 1
45
#define DEBUG_PRINTBUF(...) { printBuf(__VA_ARGS__); }
46
#else
47
#define DEBUG_PRINTBUF(...)
48
#endif
49
#else
50
#define DEBUG_PRINT_MILLIS
51
#define DEBUG_PRINT(...)
52
#define DEBUG_PRINTLN(...)
53
#define DEBUG_PRINTBUF(...)
54
#endif
55
56
// =======================================================================================
57
// Data debug macros
58
// =======================================================================================
59
#if LD2410ASYNC_DEBUG_DATA_LEVEL > 0
60
#define DEBUG_PRINT_DATA(...) { Serial.print(__VA_ARGS__); }
61
#define DEBUG_PRINTLN_DATA(...) { Serial.println(__VA_ARGS__); }
62
#if LD2410ASYNC_DEBUG_DATA_LEVEL > 1
63
#define DEBUG_PRINTBUF_DATA(...) { printBuf(__VA_ARGS__); }
64
#else
65
#define DEBUG_PRINTBUF_DATA(...)
66
#endif
67
#else
68
#define DEBUG_PRINT_DATA(...)
69
#define DEBUG_PRINTLN_DATA(...)
70
#define DEBUG_PRINTBUF_DATA(...)
71
#endif
LD2410Debug.h
Generated by
1.12.0