mirror of
https://github.com/esphome/esphome.git
synced 2024-11-22 15:08:10 +01:00
Rework UART component for fixes (#419)
This commit is contained in:
parent
feab956ea9
commit
a15b647d13
1 changed files with 7 additions and 4 deletions
|
@ -3,7 +3,7 @@ import voluptuous as vol
|
|||
from esphomeyaml import pins
|
||||
import esphomeyaml.config_validation as cv
|
||||
from esphomeyaml.const import CONF_BAUD_RATE, CONF_ID, CONF_RX_PIN, CONF_TX_PIN
|
||||
from esphomeyaml.cpp_generator import Pvariable
|
||||
from esphomeyaml.cpp_generator import Pvariable, add
|
||||
from esphomeyaml.cpp_helpers import setup_component
|
||||
from esphomeyaml.cpp_types import App, Component, esphomelib_ns
|
||||
|
||||
|
@ -20,11 +20,14 @@ CONFIG_SCHEMA = vol.All(vol.Schema({
|
|||
|
||||
|
||||
def to_code(config):
|
||||
tx = config.get(CONF_TX_PIN, -1)
|
||||
rx = config.get(CONF_RX_PIN, -1)
|
||||
rhs = App.init_uart(tx, rx, config[CONF_BAUD_RATE])
|
||||
rhs = App.init_uart(config[CONF_BAUD_RATE])
|
||||
var = Pvariable(config[CONF_ID], rhs)
|
||||
|
||||
if CONF_TX_PIN in config:
|
||||
add(var.set_tx_pin(config[CONF_TX_PIN]))
|
||||
if CONF_RX_PIN in config:
|
||||
add(var.set_rx_pin(config[CONF_RX_PIN]))
|
||||
|
||||
setup_component(var, config)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue