mirror of
https://github.com/Threnklyn/esphome-dev.git
synced 2026-06-01 02:28:28 +02:00
Add sm2135 component (#1736)
Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
This commit is contained in:
committed by
Jesse Hills
parent
7d9c043f1d
commit
9e7acd6f75
@@ -0,0 +1,33 @@
|
||||
import esphome.codegen as cg
|
||||
import esphome.config_validation as cv
|
||||
from esphome import pins
|
||||
from esphome.const import (
|
||||
CONF_CLOCK_PIN,
|
||||
CONF_DATA_PIN,
|
||||
CONF_ID,
|
||||
)
|
||||
|
||||
AUTO_LOAD = ["output"]
|
||||
CODEOWNERS = ["@BoukeHaarsma23"]
|
||||
|
||||
sm2135_ns = cg.esphome_ns.namespace("sm2135")
|
||||
SM2135 = sm2135_ns.class_("SM2135", cg.Component)
|
||||
|
||||
MULTI_CONF = True
|
||||
CONFIG_SCHEMA = cv.Schema(
|
||||
{
|
||||
cv.GenerateID(): cv.declare_id(SM2135),
|
||||
cv.Required(CONF_DATA_PIN): pins.gpio_output_pin_schema,
|
||||
cv.Required(CONF_CLOCK_PIN): pins.gpio_output_pin_schema,
|
||||
}
|
||||
).extend(cv.COMPONENT_SCHEMA)
|
||||
|
||||
|
||||
def to_code(config):
|
||||
var = cg.new_Pvariable(config[CONF_ID])
|
||||
yield cg.register_component(var, config)
|
||||
|
||||
data = yield cg.gpio_pin_expression(config[CONF_DATA_PIN])
|
||||
cg.add(var.set_data_pin(data))
|
||||
clock = yield cg.gpio_pin_expression(config[CONF_CLOCK_PIN])
|
||||
cg.add(var.set_clock_pin(clock))
|
||||
Reference in New Issue
Block a user