From 8f6521f76109dbef3ed91969e6dab2d8e9a3f397 Mon Sep 17 00:00:00 2001 From: Pablo2048 Date: Wed, 10 Jul 2024 15:49:11 +0200 Subject: [PATCH] Verze 1.1.0 - TRACEPLUS() je nyni obecne definovane a pouziva constexpr --- examples/ttest/ttest.ino | 10 ++++------ library.json | 2 +- library.properties | 2 +- src/trace.h | 14 ++++++++------ 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/examples/ttest/ttest.ino b/examples/ttest/ttest.ino index 3f2981b..40c4e06 100644 --- a/examples/ttest/ttest.ino +++ b/examples/ttest/ttest.ino @@ -1,16 +1,14 @@ #include -#define TRACE(severity, fmt, ...) trace_print(severity, (PGM_P)PSTR(fmt), ## __VA_ARGS__) -#define TRACE_INIT trace_init() -#define TRACE_ADDWEB(srv) trace_addweb(srv) -#define TRACE_POLL trace_poll() - void setup(void) { - + Serial.begin(115200); + TRACE(TRACE_INFO, F("Setup...")); } void loop(void) { + TRACE(TRACE_INFO, F("loop...")); + delay(1000); } diff --git a/library.json b/library.json index 53ad06d..0058b36 100644 --- a/library.json +++ b/library.json @@ -12,7 +12,7 @@ "type": "git", "url": "https://git.xpablo.cz/pablo2048/Trace.git" }, - "version": "1.0.0", + "version": "1.1.0", "license": "MIT", "frameworks": "arduino", "platforms": ["espressif8266","espressif32"], diff --git a/library.properties b/library.properties index b7daa05..b7d320c 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=Trace -version=1.0.0 +version=1.1.0 author=Pavel Brychta maintainer=Pavel Brychta sentence=Trace application internals & messages via web server or other output device diff --git a/src/trace.h b/src/trace.h index 5289ff0..7381a3e 100644 --- a/src/trace.h +++ b/src/trace.h @@ -37,11 +37,7 @@ #if defined(TRACE_USE_ASYNC_WEBSOCKET) #include "asyncWebsocket/traceAsyncWebsocket.hpp" - #define TRACEPLUS(when, severity, ...) \ - do { \ - if (when > 0) \ - TRACE(severity, __VA_ARGS__) \ - } while (0) + #define TRACE(severity, text, ...) \ do { \ constexpr bool trace_limit = (severity <= TRACE_LIMIT); \ @@ -55,7 +51,6 @@ #define TRACE_FORCEUPDATE(a) trace_forceupdate() #else - #define TRACEPLUS(...) ((void) 0) #if defined(ESP32) #include #define TRACE(severity, format, ...) \ @@ -142,3 +137,10 @@ #define TRACE_ADDWEB(a) ((void) 0) #define TRACE_FORCEUPDATE(a) ((void) 0) #endif + +#define TRACEPLUS(when, severity, ...) \ +do { \ + constexpr bool handle = (when != 0); \ + if (handle) \ + TRACE(severity, __VA_ARGS__); \ +} while (0)