SpaIot Library
debug.h
1/*
2 * SpaIot Library (c) by espilonrt - epsilonrt@gmail.com
3 * This file is part of SpaIot library <https://github.com/epsilonrt/spaiot-lib>
4 *
5 * SpaIot library is licensed under a
6 * Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
7 *
8 * You should have received a copy of the license along with this
9 * work. If not, see <http://creativecommons.org/licenses/by-nc-sa/4.0/>.
10 *
11 * SpaIot library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY;
13 */
14
15#pragma once
16
17#include <Arduino.h>
18
19#if ! defined(NODEBUG_SPAIOT) && defined(DEBUG_ESP_PORT)
20 #define DBG(str, ...) { DEBUG_ESP_PORT.printf(str, ##__VA_ARGS__); DEBUG_ESP_PORT.println(""); }
21 #define DBGNOLN(str, ...) { DEBUG_ESP_PORT.printf(str, ##__VA_ARGS__); }
22
23#else
24 #define DBG(str, ...)
25 #define DBGNOLN(str, ...)
26#endif
27
28#if ! defined(NODEBUG_SPAIOT) && defined(DEBUG_LED)
29 #ifndef DEBUG_LED_ONSTATE
30 #define DLED_LOW HIGH
31 #define DLED_HIGH LOW
32 #else
33 #if DEBUG_LED_ONSTATE == HIGH
34 #define DLED_LOW LOW
35 #define DLED_HIGH HIGH
36 #else
37 #define DLED_LOW HIGH
38 #define DLED_HIGH LOW
39 #endif
40 #endif
41
42 #define DLED_INIT() { \
43 pinMode(DEBUG_LED, OUTPUT); \
44 digitalWrite(DEBUG_LED, DLED_LOW); \
45 }
46 #define DLED_SET() { \
47 digitalWrite(DEBUG_LED, DLED_HIGH); \
48 }
49 #define DLED_CLR() { \
50 digitalWrite(DEBUG_LED, DLED_LOW); \
51 }
52
53#else
54#define DLED_INIT()
55#define DLED_SET()
56#define DLED_CLR()
57#endif