mirror of
https://github.com/esphome/esphome.git
synced 2026-02-08 16:51:52 +00:00
reduce
This commit is contained in:
14
esphome/core/gpio.cpp
Normal file
14
esphome/core/gpio.cpp
Normal 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
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user