diff --git a/esphome/components/lora/lora.cpp b/esphome/components/lora/lora.cpp index c7e5a3e10a..8f63c8b20b 100644 --- a/esphome/components/lora/lora.cpp +++ b/esphome/components/lora/lora.cpp @@ -160,5 +160,21 @@ void Lora::loop() { raw_message_ = buffer.substr(0, buffer.length() - 1); } +// pin stuff + +static const char *const TAGPin = "lora.pin"; +void LoraGPIOPin::setup() { pin_mode(flags_); } +void LoraGPIOPin::pin_mode(gpio::Flags flags) { + if (flags != gpio::FLAG_OUTPUT) { + ESP_LOGD(TAGPin, "Output only supported"); + } +} +bool LoraGPIOPin::digital_read() { return false; } +void LoraGPIOPin::digital_write(bool value) { this->parent_->digital_write(this->pin_, value != this->inverted_); } +std::string LoraGPIOPin::dump_summary() const { + char buffer[32]; + snprintf(buffer, sizeof(buffer), "%u via Lora", pin_); + return buffer; +} } // namespace lora } // namespace esphome diff --git a/esphome/components/lora/lora.h b/esphome/components/lora/lora.h index 9e41a9a4bb..b7c2a9f59a 100644 --- a/esphome/components/lora/lora.h +++ b/esphome/components/lora/lora.h @@ -65,5 +65,26 @@ class Lora : public PollingComponent, public uart::UARTDevice { GPIOPin *pin_m1{nullptr}; }; +// pin stuff + +class LoraGPIOPin : public GPIOPin { + public: + void setup() override; + void pin_mode(gpio::Flags flags) override; + bool digital_read() override; + void digital_write(bool value) override; + std::string dump_summary() const override; + + void set_parent(Lora *parent) { parent_ = parent; } + void set_pin(uint8_t pin) { pin_ = pin; } + void set_inverted(bool inverted) { inverted_ = inverted; } + void set_flags(gpio::Flags flags) { flags_ = flags; } + + protected: + Lora *parent_; + uint8_t pin_; + bool inverted_; + gpio::Flags flags_; +}; } // namespace lora } // namespace esphome diff --git a/esphome/components/lora/lora_pin.cpp b/esphome/components/lora/lora_pin.cpp deleted file mode 100644 index c754e3b4a4..0000000000 --- a/esphome/components/lora/lora_pin.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include "lora_pin.h" -#include "esphome/core/log.h" - -namespace esphome { -namespace lora { - -static const char *const TAGPin = "lora.pin"; -void LoraGPIOPin::setup() { pin_mode(flags_); } -void LoraGPIOPin::pin_mode(gpio::Flags flags) { - if (flags != gpio::FLAG_OUTPUT) { - ESP_LOGD(TAGPin, "Output only supported"); - } -} -bool LoraGPIOPin::digital_read() { return false; } -void LoraGPIOPin::digital_write(bool value) { this->parent_->digital_write(this->pin_, value != this->inverted_); } -std::string LoraGPIOPin::dump_summary() const { - char buffer[32]; - snprintf(buffer, sizeof(buffer), "%u via Lora", pin_); - return buffer; -} -} // namespace lora -} // namespace esphome diff --git a/esphome/components/lora/lora_pin.h b/esphome/components/lora/lora_pin.h deleted file mode 100644 index 0953f8546e..0000000000 --- a/esphome/components/lora/lora_pin.h +++ /dev/null @@ -1,33 +0,0 @@ -#pragma once - -#include "esphome/core/component.h" -#include "./lora.h" - -#include -#include - -namespace esphome { -namespace lora { - -class LoraGPIOPin : public GPIOPin { - public: - void setup() override; - void pin_mode(gpio::Flags flags) override; - bool digital_read() override; - void digital_write(bool value) override; - std::string dump_summary() const override; - - void set_parent(Lora *parent) { parent_ = parent; } - void set_pin(uint8_t pin) { pin_ = pin; } - void set_inverted(bool inverted) { inverted_ = inverted; } - void set_flags(gpio::Flags flags) { flags_ = flags; } - - protected: - Lora *parent_; - uint8_t pin_; - bool inverted_; - gpio::Flags flags_; -}; - -} // namespace lora -} // namespace esphome