1
0
mirror of https://github.com/esphome/esphome.git synced 2026-02-08 16:51:52 +00:00
This commit is contained in:
J. Nick Koston
2025-12-30 13:08:05 -10:00
parent 53aa3f539b
commit 8ab37379e8
2 changed files with 20 additions and 6 deletions

14
esphome/core/gpio.cpp Normal file
View File

@@ -0,0 +1,14 @@
#include "esphome/core/gpio.h"
#include "esphome/core/log.h"
namespace esphome {
void log_pin(const char *tag, const char *prefix, GPIOPin *pin) {
if (pin == nullptr)
return;
char buffer[GPIO_SUMMARY_MAX_LEN];
pin->dump_summary(buffer, sizeof(buffer));
esp_log_printf_(ESPHOME_LOG_LEVEL_CONFIG, tag, __LINE__, "%s%s", prefix, buffer);
}
} // namespace esphome

View File

@@ -11,12 +11,12 @@ namespace esphome {
/// Maximum buffer size for dump_summary output
inline constexpr size_t GPIO_SUMMARY_MAX_LEN = 48;
#define LOG_PIN(prefix, pin) \
if ((pin) != nullptr) { \
char esphome_pin_buf_[GPIO_SUMMARY_MAX_LEN]; \
(pin)->dump_summary(esphome_pin_buf_, sizeof(esphome_pin_buf_)); \
ESP_LOGCONFIG(TAG, prefix "%s", esphome_pin_buf_); \
}
class GPIOPin; // Forward declaration
/// Log a pin summary to the config log
void log_pin(const char *tag, const char *prefix, GPIOPin *pin);
#define LOG_PIN(prefix, pin) log_pin(TAG, prefix, pin)
// put GPIO flags in a namespace to not pollute esphome namespace
namespace gpio {