diff --git a/custom_components/empty_i2c_component/empty_i2c_component.cpp b/custom_components/empty_i2c_component/empty_i2c_component.cpp index 48298d6..03715f0 100644 --- a/custom_components/empty_i2c_component/empty_i2c_component.cpp +++ b/custom_components/empty_i2c_component/empty_i2c_component.cpp @@ -15,7 +15,7 @@ void EmptyI2CComponent::loop() { } void EmptyI2CComponent::dump_config(){ - ESP_LOGCONFIG(TAG, "Empty i2c component"); + ESP_LOGCONFIG(TAG, "Empty I2C component"); } diff --git a/custom_components/empty_spi_component/__init__.py b/custom_components/empty_spi_component/__init__.py new file mode 100644 index 0000000..c813b41 --- /dev/null +++ b/custom_components/empty_spi_component/__init__.py @@ -0,0 +1,18 @@ +import esphome.codegen as cg +import esphome.config_validation as cv +from esphome.components import spi +from esphome.const import CONF_ID + +DEPENDENCIES = ['spi'] + +empty_spi_component_ns = cg.esphome_ns.namespace('empty_spi_component') +EmptySPIComponent = empty_spi_component_ns.class_('EmptySPIComponent', cg.Component, spi.SPIDevice) + +CONFIG_SCHEMA = cv.Schema({ + cv.GenerateID(): cv.declare_id(EmptySPIComponent) +}).extend(cv.COMPONENT_SCHEMA).extend(spi.spi_device_schema(cs_pin_required=True)) + +def to_code(config): + var = cg.new_Pvariable(config[CONF_ID]) + yield cg.register_component(var, config) + yield spi.register_spi_device(var, config) \ No newline at end of file diff --git a/custom_components/empty_spi_component/empty_spi_component.cpp b/custom_components/empty_spi_component/empty_spi_component.cpp new file mode 100644 index 0000000..d455002 --- /dev/null +++ b/custom_components/empty_spi_component/empty_spi_component.cpp @@ -0,0 +1,22 @@ +#include "esphome/core/log.h" +#include "empty_spi_component.h" + +namespace esphome { +namespace empty_spi_component { + +static const char *TAG = "empty_spi_component.component"; + +void EmptySPIComponent::setup() { + +} + +void EmptySPIComponent::loop() { + +} + +void EmptySPIComponent::dump_config(){ + ESP_LOGCONFIG(TAG, "Empty SPI component"); +} + +} // namespace empty_spi_component +} // namespace esphome \ No newline at end of file diff --git a/custom_components/empty_spi_component/empty_spi_component.h b/custom_components/empty_spi_component/empty_spi_component.h new file mode 100644 index 0000000..514b899 --- /dev/null +++ b/custom_components/empty_spi_component/empty_spi_component.h @@ -0,0 +1,20 @@ +#pragma once + +#include "esphome/core/component.h" +#include "esphome/components/spi/spi.h" + +namespace esphome { +namespace empty_spi_component { + +class EmptySPIComponent : public Component, + public spi::SPIDevice { + public: + void setup() override; + void loop() override; + void dump_config() override; +}; + + +} // namespace empty_spi_component +} // namespace esphome \ No newline at end of file diff --git a/custom_components/empty_uart_component/empty_uart_component.cpp b/custom_components/empty_uart_component/empty_uart_component.cpp index 95031b1..51bd8ea 100644 --- a/custom_components/empty_uart_component/empty_uart_component.cpp +++ b/custom_components/empty_uart_component/empty_uart_component.cpp @@ -15,7 +15,7 @@ void EmptyUARTComponent::loop() { } void EmptyUARTComponent::dump_config(){ - ESP_LOGCONFIG(TAG, "Empty i2c component"); + ESP_LOGCONFIG(TAG, "Empty UART component"); } } // namespace empty_uart_component diff --git a/test_empty.yaml b/test_empty.yaml index 36f9177..0f4bebf 100644 --- a/test_empty.yaml +++ b/test_empty.yaml @@ -55,4 +55,12 @@ uart: baud_rate: 9600 empty_uart_component: - id: empty_uart_component_1 \ No newline at end of file + id: empty_uart_component_1 + +spi: + clk_pin: D5 + miso_pin: D6 + +empty_spi_component: + id: empty_spi_component_1 + cs_pin: D8 \ No newline at end of file