JXCT Soil Sensor 7-in-1
3.10.1
IoT система мониторинга почвы на базе ESP32
Загрузка...
Поиск...
Не найдено
debug.h
См. документацию.
1
#ifndef DEBUG_H
2
#define DEBUG_H
3
4
#ifdef TEST_BUILD
5
#include "../test/stubs/esp32_stubs.h"
6
#else
7
#include <Arduino.h>
8
#endif
9
10
// Условная компиляция отладки
11
// В релизной сборке весь отладочный код будет исключен из прошивки
12
#ifdef DEBUG_MODE
13
#define DEBUG_PRINT(x) Serial.print(x)
14
#define DEBUG_PRINTLN(x) Serial.println(x)
15
#define DEBUG_PRINTF(fmt, ...) Serial.printf(fmt, ##__VA_ARGS__)
16
#define DEBUG_PRINT_VAR(name, value) Serial.printf("[DEBUG] %s = %s\n", name, String(value).c_str())
17
#define DEBUG_PRINT_INT(name, value) Serial.printf("[DEBUG] %s = %d\n", name, value)
18
#define DEBUG_PRINT_FLOAT(name, value) Serial.printf("[DEBUG] %s = %.2f\n", name, value)
19
#else
20
// В релизной сборке эти макросы превращаются в пустые операции
21
#define DEBUG_PRINT(x)
22
#define DEBUG_PRINTLN(x)
23
#define DEBUG_PRINTF(fmt, ...)
24
#define DEBUG_PRINT_VAR(name, value)
25
#define DEBUG_PRINT_INT(name, value)
26
#define DEBUG_PRINT_FLOAT(name, value)
27
#endif
28
29
// Критические ошибки всегда выводятся (для отладки в продакшне)
30
#define ERROR_PRINT(x) Serial.print(x)
31
#define ERROR_PRINTLN(x) Serial.println(x)
32
#define ERROR_PRINTF(fmt, ...) Serial.printf(fmt, ##__VA_ARGS__)
33
34
// Информационные сообщения (можно отключить в критических случаях)
35
#ifdef INFO_MODE
36
#define INFO_PRINT(x) Serial.print(x)
37
#define INFO_PRINTLN(x) Serial.println(x)
38
#define INFO_PRINTF(fmt, ...) Serial.printf(fmt, ##__VA_ARGS__)
39
#else
40
#define INFO_PRINT(x)
41
#define INFO_PRINTLN(x)
42
#define INFO_PRINTF(fmt, ...)
43
#endif
44
45
#endif
// DEBUG_H
include
debug.h
Создано системой
1.9.8