mirror of
https://github.com/Threnklyn/esphome-dev.git
synced 2026-05-31 10:08:27 +02:00
Reduce static RAM usage (#2140)
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
#include "WString.h"
|
||||
#endif
|
||||
|
||||
#include "esphome/core/macros.h"
|
||||
// avoid esp-idf redefining our macros
|
||||
#include "esphome/core/esphal.h"
|
||||
|
||||
@@ -162,4 +163,28 @@ int esp_idf_log_vprintf_(const char *format, va_list args); // NOLINT
|
||||
#define ONOFF(b) ((b) ? "ON" : "OFF")
|
||||
#define TRUEFALSE(b) ((b) ? "TRUE" : "FALSE")
|
||||
|
||||
#ifdef USE_STORE_LOG_STR_IN_FLASH
|
||||
#define LOG_STR(s) PSTR(s)
|
||||
|
||||
// From Arduino 2.5 onwards, we can pass a PSTR() to printf(). For previous versions, emulate support
|
||||
// by copying the message to a local buffer first. String length is limited to 63 characters.
|
||||
// https://github.com/esp8266/Arduino/commit/6280e98b0360f85fdac2b8f10707fffb4f6e6e31
|
||||
#include <core_version.h>
|
||||
#if defined(ARDUINO_ARCH_ESP8266) && ARDUINO_VERSION_CODE < VERSION_CODE(2, 5, 0)
|
||||
#define LOG_STR_ARG(s) \
|
||||
({ \
|
||||
char __buf[64]; \
|
||||
__buf[63] = '\0'; \
|
||||
strncpy_P(__buf, s, 63); \
|
||||
__buf; \
|
||||
})
|
||||
#else
|
||||
#define LOG_STR_ARG(s) (s)
|
||||
#endif
|
||||
|
||||
#else
|
||||
#define LOG_STR(s) (s)
|
||||
#define LOG_STR_ARG(s) (s)
|
||||
#endif
|
||||
|
||||
} // namespace esphome
|
||||
|
||||
Reference in New Issue
Block a user