parent
ae2bff7380
commit
33bff3a1e8
@ -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)
|
||||
@ -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
|
||||
@ -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<spi::BIT_ORDER_MSB_FIRST,spi::CLOCK_POLARITY_LOW,
|
||||
spi::CLOCK_PHASE_LEADING,spi::DATA_RATE_1KHZ> {
|
||||
public:
|
||||
void setup() override;
|
||||
void loop() override;
|
||||
void dump_config() override;
|
||||
};
|
||||
|
||||
|
||||
} // namespace empty_spi_component
|
||||
} // namespace esphome
|
||||
Loading…
Reference in new issue