[components] Set pins with cg.add_pin (#21019)

Co-authored-by: Jonathan Swoboda <154711427+swoboda1337@users.noreply.github.com>
This commit is contained in:
J. Nick Koston
2026-10-18 09:10:22 -04:00
committed by GitHub
co-authored by Jonathan Swoboda
parent 0cd1ae01f1
commit ed9616d512
117 changed files with 227 additions and 564 deletions
+3 -8
View File
@@ -23,11 +23,6 @@ async def to_code(config: ConfigType) -> None:
await cg.register_component(var, config)
await stepper.register_stepper(var, config)
step_pin = await cg.gpio_pin_expression(config[CONF_STEP_PIN])
cg.add(var.set_step_pin(step_pin))
dir_pin = await cg.gpio_pin_expression(config[CONF_DIR_PIN])
cg.add(var.set_dir_pin(dir_pin))
if sleep_pin_config := config.get(CONF_SLEEP_PIN):
sleep_pin = await cg.gpio_pin_expression(sleep_pin_config)
cg.add(var.set_sleep_pin(sleep_pin))
await cg.add_pin(var.set_step_pin, config[CONF_STEP_PIN])
await cg.add_pin(var.set_dir_pin, config[CONF_DIR_PIN])
await cg.add_pin(var.set_sleep_pin, config.get(CONF_SLEEP_PIN))
+2 -4
View File
@@ -68,10 +68,8 @@ async def to_code(config: ConfigType) -> None:
config[CONF_MIN_POWER] = 0.1
await output.register_output(var, config)
pin = await cg.gpio_pin_expression(config[CONF_GATE_PIN])
cg.add(var.set_gate_pin(pin))
pin = await cg.gpio_pin_expression(config[CONF_ZERO_CROSS_PIN])
cg.add(var.set_zero_cross_pin(pin))
await cg.add_pin(var.set_gate_pin, config[CONF_GATE_PIN])
await cg.add_pin(var.set_zero_cross_pin, config[CONF_ZERO_CROSS_PIN])
cg.add(var.set_zero_cross_interrupt_type(config[CONF_ZERO_CROSS_INTERRUPT_TYPE]))
cg.add(var.set_init_with_half_cycle(config[CONF_INIT_WITH_HALF_CYCLE]))
cg.add(var.set_method(config[CONF_METHOD]))
+1 -2
View File
@@ -164,8 +164,7 @@ async def to_code(config: ConfigType) -> None:
# Remove before 2027.2.0
cg.add(var.set_is_temperature())
elif not CORE.is_nrf52 or config[CONF_PIN][CONF_NUMBER] not in EXTRA_ADC:
pin = await cg.gpio_pin_expression(config[CONF_PIN])
cg.add(var.set_pin(pin))
await cg.add_pin(var.set_pin, config[CONF_PIN])
# Skip the setters when the config matches the C++ initializers.
if config[CONF_RAW]:
+3 -10
View File
@@ -284,16 +284,9 @@ async def power_channel(config: ConfigType) -> MockObj:
async def to_code(config: ConfigType) -> None:
var = await i2c.new_i2c_component(config)
if irq0_pin := config.get(CONF_IRQ0_PIN):
pin = await cg.gpio_pin_expression(irq0_pin)
cg.add(var.set_irq0_pin(pin))
pin = await cg.gpio_pin_expression(config[CONF_IRQ1_PIN])
cg.add(var.set_irq1_pin(pin))
if reset_pin := config.get(CONF_RESET_PIN):
pin = await cg.gpio_pin_expression(reset_pin)
cg.add(var.set_reset_pin(pin))
await cg.add_pin(var.set_irq0_pin, config.get(CONF_IRQ0_PIN))
await cg.add_pin(var.set_irq1_pin, config[CONF_IRQ1_PIN])
await cg.add_pin(var.set_reset_pin, config.get(CONF_RESET_PIN))
if frequency := config.get(CONF_FREQUENCY):
cg.add(var.set_frequency(frequency))
+1 -3
View File
@@ -169,9 +169,7 @@ ADE7953_CONFIG_SCHEMA = cv.Schema(
async def register_ade7953(var: MockObj, config: ConfigType) -> None:
await cg.register_component(var, config)
if irq_pin_config := config.get(CONF_IRQ_PIN):
irq_pin = await cg.gpio_pin_expression(irq_pin_config)
cg.add(var.set_irq_pin(irq_pin))
await cg.add_pin(var.set_irq_pin, config.get(CONF_IRQ_PIN))
cg.add(var.set_pga_v(PGA_GAINS[config.get(CONF_VOLTAGE_PGA_GAIN)]))
cg.add(var.set_pga_ia(PGA_GAINS[config.get(CONF_CURRENT_PGA_GAIN_A)]))
+2 -7
View File
@@ -191,13 +191,8 @@ async def to_code(config: ConfigType) -> None:
await sensors(CONF_RS3, var.set_rs3_sensor)
await sensors(CONF_ERROR_CODE, var.set_error_code_sensor)
if (set_pin_config := config.get(CONF_SET_PIN)) is not None:
set_pin = await cg.gpio_pin_expression(set_pin_config)
cg.add(var.set_set_pin(set_pin))
if (reset_pin_config := config.get(CONF_RESET_PIN)) is not None:
reset_pin = await cg.gpio_pin_expression(reset_pin_config)
cg.add(var.set_reset_pin(reset_pin))
await cg.add_pin(var.set_set_pin, config.get(CONF_SET_PIN))
await cg.add_pin(var.set_reset_pin, config.get(CONF_RESET_PIN))
APC1_ACTION_SCHEMA = maybe_simple_id(
+1 -2
View File
@@ -48,8 +48,7 @@ AS3935_SCHEMA = cv.Schema(
async def setup_as3935(var: MockObj, config: ConfigType) -> None:
await cg.register_component(var, config)
irq_pin = await cg.gpio_pin_expression(config[CONF_IRQ_PIN])
cg.add(var.set_irq_pin(irq_pin))
await cg.add_pin(var.set_irq_pin, config[CONF_IRQ_PIN])
cg.add(var.set_indoor(config[CONF_INDOOR]))
cg.add(var.set_noise_level(config[CONF_NOISE_LEVEL]))
cg.add(var.set_watchdog_threshold(config[CONF_WATCHDOG_THRESHOLD]))
+1 -3
View File
@@ -218,9 +218,7 @@ async def to_code(config: ConfigType) -> None:
cg.add(var.set_fast_filter(config[CONF_FAST_FILTER]))
cg.add(var.set_start_position(config[CONF_START_POSITION]))
if dir_pin_config := config.get(CONF_DIR_PIN):
pin = await cg.gpio_pin_expression(dir_pin_config)
cg.add(var.set_dir_pin(pin))
await cg.add_pin(var.set_dir_pin, config.get(CONF_DIR_PIN))
if (end_position_config := config.get(CONF_END_POSITION, None)) is not None:
cg.add(var.set_end_position(end_position_config))
@@ -31,7 +31,5 @@ async def to_code(config: ConfigType) -> None:
await touchscreen.register_touchscreen(var, config)
await i2c.register_i2c_device(var, config)
if interrupt_pin := config.get(CONF_INTERRUPT_PIN):
cg.add(var.set_interrupt_pin(await cg.gpio_pin_expression(interrupt_pin)))
if reset_pin := config.get(CONF_RESET_PIN):
cg.add(var.set_reset_pin(await cg.gpio_pin_expression(reset_pin)))
await cg.add_pin(var.set_interrupt_pin, config.get(CONF_INTERRUPT_PIN))
await cg.add_pin(var.set_reset_pin, config.get(CONF_RESET_PIN))
+2 -4
View File
@@ -34,9 +34,7 @@ async def to_code(config: ConfigType) -> None:
var = cg.new_Pvariable(config[CONF_ID])
await cg.register_component(var, config)
data = await cg.gpio_pin_expression(config[CONF_DATA_PIN])
cg.add(var.set_data_pin(data))
clock = await cg.gpio_pin_expression(config[CONF_CLOCK_PIN])
cg.add(var.set_clock_pin(clock))
await cg.add_pin(var.set_data_pin, config[CONF_DATA_PIN])
await cg.add_pin(var.set_clock_pin, config[CONF_CLOCK_PIN])
cg.add(var.set_max_power_color_channels(config[CONF_MAX_POWER_COLOR_CHANNELS]))
cg.add(var.set_max_power_white_channels(config[CONF_MAX_POWER_WHITE_CHANNELS]))
+2 -4
View File
@@ -25,7 +25,5 @@ async def to_code(config: ConfigType) -> None:
var = cg.new_Pvariable(config[CONF_ID])
await cg.register_component(var, config)
data = await cg.gpio_pin_expression(config[CONF_DATA_PIN])
cg.add(var.set_data_pin(data))
clock = await cg.gpio_pin_expression(config[CONF_CLOCK_PIN])
cg.add(var.set_clock_pin(clock))
await cg.add_pin(var.set_data_pin, config[CONF_DATA_PIN])
await cg.add_pin(var.set_clock_pin, config[CONF_CLOCK_PIN])
+1 -3
View File
@@ -39,9 +39,7 @@ async def to_code(config: ConfigType) -> None:
cg.add(var.set_touch_threshold(config[CONF_TOUCH_THRESHOLD]))
cg.add(var.set_allow_multiple_touches(config[CONF_ALLOW_MULTIPLE_TOUCHES]))
if reset_pin_config := config.get(CONF_RESET_PIN):
pin = await cg.gpio_pin_expression(reset_pin_config)
cg.add(var.set_reset_pin(pin))
await cg.add_pin(var.set_reset_pin, config.get(CONF_RESET_PIN))
await cg.register_component(var, config)
await i2c.register_i2c_device(var, config)
+1 -3
View File
@@ -281,9 +281,7 @@ async def to_code(config):
if key in config:
cg.add(getattr(var, f"set_{key}")(config[key]))
if CONF_GDO0_PIN in config:
gdo0_pin = await cg.gpio_pin_expression(config[CONF_GDO0_PIN])
cg.add(var.set_gdo0_pin(gdo0_pin))
await cg.add_pin(var.set_gdo0_pin, config.get(CONF_GDO0_PIN))
if CONF_ON_PACKET in config:
await automation.build_automation(
var.get_packet_trigger(),
+4 -8
View File
@@ -39,13 +39,9 @@ async def to_code(config: ConfigType) -> None:
var = cg.new_Pvariable(config[CONF_ID])
await cg.register_component(var, config)
pin_s0 = await cg.gpio_pin_expression(config[CONF_PIN_S0])
cg.add(var.set_pin_s0(pin_s0))
pin_s1 = await cg.gpio_pin_expression(config[CONF_PIN_S1])
cg.add(var.set_pin_s1(pin_s1))
pin_s2 = await cg.gpio_pin_expression(config[CONF_PIN_S2])
cg.add(var.set_pin_s2(pin_s2))
pin_s3 = await cg.gpio_pin_expression(config[CONF_PIN_S3])
cg.add(var.set_pin_s3(pin_s3))
await cg.add_pin(var.set_pin_s0, config[CONF_PIN_S0])
await cg.add_pin(var.set_pin_s1, config[CONF_PIN_S1])
await cg.add_pin(var.set_pin_s2, config[CONF_PIN_S2])
await cg.add_pin(var.set_pin_s3, config[CONF_PIN_S3])
cg.add(var.set_switch_delay(config[CONF_DELAY]))
@@ -93,9 +93,5 @@ async def to_code(config: ConfigType) -> None:
var = cg.new_Pvariable(config[CONF_ID], uart_component, usb_cdc)
await cg.register_component(var, config)
if dtr_pin_config := config.get(CONF_DTR_PIN):
dtr_pin = await cg.gpio_pin_expression(dtr_pin_config)
cg.add(var.set_dtr_pin(dtr_pin))
if rts_pin_config := config.get(CONF_RTS_PIN):
rts_pin = await cg.gpio_pin_expression(rts_pin_config)
cg.add(var.set_rts_pin(rts_pin))
await cg.add_pin(var.set_dtr_pin, config.get(CONF_DTR_PIN))
await cg.add_pin(var.set_rts_pin, config.get(CONF_RTS_PIN))
+1 -2
View File
@@ -30,5 +30,4 @@ async def to_code(config: ConfigType) -> None:
await touchscreen.register_touchscreen(var, config)
await i2c.register_i2c_device(var, config)
if interrupt_pin := config.get(CONF_INTERRUPT_PIN):
cg.add(var.set_interrupt_pin(await cg.gpio_pin_expression(interrupt_pin)))
await cg.add_pin(var.set_interrupt_pin, config.get(CONF_INTERRUPT_PIN))
@@ -32,7 +32,5 @@ async def to_code(config: ConfigType) -> None:
await touchscreen.register_touchscreen(var, config)
await i2c.register_i2c_device(var, config)
if interrupt_pin := config.get(CONF_INTERRUPT_PIN):
cg.add(var.set_interrupt_pin(await cg.gpio_pin_expression(interrupt_pin)))
if reset_pin := config.get(CONF_RESET_PIN):
cg.add(var.set_reset_pin(await cg.gpio_pin_expression(reset_pin)))
await cg.add_pin(var.set_interrupt_pin, config.get(CONF_INTERRUPT_PIN))
await cg.add_pin(var.set_reset_pin, config.get(CONF_RESET_PIN))
@@ -33,7 +33,5 @@ async def to_code(config: ConfigType) -> None:
await touchscreen.register_touchscreen(var, config)
await i2c.register_i2c_device(var, config)
if interrupt_pin := config.get(CONF_INTERRUPT_PIN):
cg.add(var.set_interrupt_pin(await cg.gpio_pin_expression(interrupt_pin)))
if reset_pin := config.get(CONF_RESET_PIN):
cg.add(var.set_reset_pin(await cg.gpio_pin_expression(reset_pin)))
await cg.add_pin(var.set_interrupt_pin, config.get(CONF_INTERRUPT_PIN))
await cg.add_pin(var.set_reset_pin, config.get(CONF_RESET_PIN))
@@ -32,7 +32,5 @@ async def to_code(config: ConfigType) -> None:
await i2c.register_i2c_device(var, config)
cg.add(var.set_skip_probe(config[CONF_SKIP_PROBE]))
if interrupt_pin := config.get(CONF_INTERRUPT_PIN):
cg.add(var.set_interrupt_pin(await cg.gpio_pin_expression(interrupt_pin)))
if reset_pin := config.get(CONF_RESET_PIN):
cg.add(var.set_reset_pin(await cg.gpio_pin_expression(reset_pin)))
await cg.add_pin(var.set_interrupt_pin, config.get(CONF_INTERRUPT_PIN))
await cg.add_pin(var.set_reset_pin, config.get(CONF_RESET_PIN))
@@ -31,7 +31,5 @@ async def to_code(config: ConfigType) -> None:
await touchscreen.register_touchscreen(var, config)
await i2c.register_i2c_device(var, config)
if interrupt_pin := config.get(CONF_INTERRUPT_PIN):
cg.add(var.set_interrupt_pin(await cg.gpio_pin_expression(interrupt_pin)))
if reset_pin := config.get(CONF_RESET_PIN):
cg.add(var.set_reset_pin(await cg.gpio_pin_expression(reset_pin)))
await cg.add_pin(var.set_interrupt_pin, config.get(CONF_INTERRUPT_PIN))
await cg.add_pin(var.set_reset_pin, config.get(CONF_RESET_PIN))
+1 -2
View File
@@ -379,8 +379,7 @@ async def to_code(config: ConfigType) -> None:
)
)
else:
pin = await cg.gpio_pin_expression(wakeup_pins[0][CONF_PIN])
cg.add(var.set_wakeup_pin(pin))
await cg.add_pin(var.set_wakeup_pin, wakeup_pins[0][CONF_PIN])
if CONF_WAKEUP_PIN_MODE in config:
cg.add(var.set_wakeup_pin_mode(config[CONF_WAKEUP_PIN_MODE]))
if CONF_RUN_DURATION in config:
+1 -3
View File
@@ -14,7 +14,6 @@ from esphome.const import (
UNIT_CELSIUS,
UNIT_PERCENT,
)
from esphome.cpp_helpers import gpio_pin_expression
from esphome.types import ConfigType
dht_ns = cg.esphome_ns.namespace("dht")
@@ -59,8 +58,7 @@ async def to_code(config: ConfigType) -> None:
var = cg.new_Pvariable(config[CONF_ID])
await cg.register_component(var, config)
pin = await gpio_pin_expression(config[CONF_PIN])
cg.add(var.set_pin(pin))
await cg.add_pin(var.set_pin, config[CONF_PIN])
sensors = sensor.sub_sensors(config)
await sensors(CONF_TEMPERATURE, var.set_temperature_sensor)
+1 -3
View File
@@ -107,6 +107,4 @@ async def to_code(config: ConfigType) -> None:
if CONF_ACTIVE_PULLUP_RESISTANCE in config:
cg.add(var.set_val_rwpu(config[CONF_ACTIVE_PULLUP_RESISTANCE]))
if CONF_SLEEP_PIN in config:
pin = await cg.gpio_pin_expression(config[CONF_SLEEP_PIN])
cg.add(var.set_sleep_pin(pin))
await cg.add_pin(var.set_sleep_pin, config.get(CONF_SLEEP_PIN))
+1 -2
View File
@@ -27,5 +27,4 @@ async def to_code(config: ConfigType) -> None:
var = await sensor.new_sensor(config)
await cg.register_component(var, config)
pin = await cg.gpio_pin_expression(config[CONF_PIN])
cg.add(var.set_pin(pin))
await cg.add_pin(var.set_pin, config[CONF_PIN])
@@ -35,7 +35,5 @@ async def to_code(config: ConfigType) -> None:
await touchscreen.register_touchscreen(var, config)
await i2c.register_i2c_device(var, config)
interrupt_pin = await cg.gpio_pin_expression(config[CONF_INTERRUPT_PIN])
cg.add(var.set_interrupt_pin(interrupt_pin))
reset_pin = await cg.gpio_pin_expression(config[CONF_RESET_PIN])
cg.add(var.set_reset_pin(reset_pin))
await cg.add_pin(var.set_interrupt_pin, config[CONF_INTERRUPT_PIN])
await cg.add_pin(var.set_reset_pin, config[CONF_RESET_PIN])
+3 -8
View File
@@ -243,20 +243,15 @@ async def to_code(config):
config = await model.to_code(var, config)
await spi.register_spi_device(var, config, write_only=True)
dc = await cg.gpio_pin_expression(config[CONF_DC_PIN])
cg.add(var.set_dc_pin(dc))
await cg.add_pin(var.set_dc_pin, config[CONF_DC_PIN])
if CONF_LAMBDA in config:
lambda_ = await cg.process_lambda(
config[CONF_LAMBDA], [(display.DisplayRef, "it")], return_type=cg.void
)
cg.add(var.set_writer(lambda_))
if reset_pin := config.get(CONF_RESET_PIN):
reset = await cg.gpio_pin_expression(reset_pin)
cg.add(var.set_reset_pin(reset))
if busy_pin := config.get(CONF_BUSY_PIN):
busy = await cg.gpio_pin_expression(busy_pin)
cg.add(var.set_busy_pin(busy))
await cg.add_pin(var.set_reset_pin, config.get(CONF_RESET_PIN))
await cg.add_pin(var.set_busy_pin, config.get(CONF_BUSY_PIN))
if enable_pin := config.get(CONF_ENABLE_PIN):
enable = [await cg.gpio_pin_expression(pin) for pin in enable_pin]
cg.add(var.set_enable_pins(enable))
+1 -2
View File
@@ -49,5 +49,4 @@ async def to_code(config: ConfigType) -> None:
await cg.register_component(var, config)
await output.register_output(var, config)
pin = await cg.gpio_pin_expression(config[CONF_PIN])
cg.add(var.set_pin(pin))
await cg.add_pin(var.set_pin, config[CONF_PIN])
+1 -2
View File
@@ -46,8 +46,7 @@ async def to_code(config: ConfigType) -> None:
await cg.register_component(var, config)
await output.register_output(var, config)
pin = await cg.gpio_pin_expression(config[CONF_PIN])
cg.add(var.set_pin(pin))
await cg.add_pin(var.set_pin, config[CONF_PIN])
# Skip the setter when the config matches the C++ initializer (DEFAULT_FREQUENCY).
if (frequency := config[CONF_FREQUENCY]) != DEFAULT_FREQUENCY:
@@ -146,13 +146,8 @@ async def to_code(config):
new_password = config[CONF_NEW_PASSWORD]
cg.add(var.set_new_password(new_password))
if CONF_SENSING_PIN in config:
sensing_pin = await cg.gpio_pin_expression(config[CONF_SENSING_PIN])
cg.add(var.set_sensing_pin(sensing_pin))
if CONF_SENSOR_POWER_PIN in config:
sensor_power_pin = await cg.gpio_pin_expression(config[CONF_SENSOR_POWER_PIN])
cg.add(var.set_sensor_power_pin(sensor_power_pin))
await cg.add_pin(var.set_sensing_pin, config.get(CONF_SENSING_PIN))
await cg.add_pin(var.set_sensor_power_pin, config.get(CONF_SENSOR_POWER_PIN))
if CONF_IDLE_PERIOD_TO_SLEEP in config:
idle_period_to_sleep_ms = config[CONF_IDLE_PERIOD_TO_SLEEP]
@@ -28,6 +28,4 @@ async def to_code(config: ConfigType) -> None:
await i2c.register_i2c_device(var, config)
await touchscreen.register_touchscreen(var, config)
if interrupt_pin := config.get(CONF_INTERRUPT_PIN):
pin = await cg.gpio_pin_expression(interrupt_pin)
cg.add(var.set_interrupt_pin(pin))
await cg.add_pin(var.set_interrupt_pin, config.get(CONF_INTERRUPT_PIN))
+2 -6
View File
@@ -37,9 +37,5 @@ async def to_code(config: ConfigType) -> None:
await touchscreen.register_touchscreen(var, config)
await i2c.register_i2c_device(var, config)
if interrupt_pin_config := config.get(CONF_INTERRUPT_PIN):
interrupt_pin = await cg.gpio_pin_expression(interrupt_pin_config)
cg.add(var.set_interrupt_pin(interrupt_pin))
if reset_pin_config := config.get(CONF_RESET_PIN):
reset_pin = await cg.gpio_pin_expression(reset_pin_config)
cg.add(var.set_reset_pin(reset_pin))
await cg.add_pin(var.set_interrupt_pin, config.get(CONF_INTERRUPT_PIN))
await cg.add_pin(var.set_reset_pin, config.get(CONF_RESET_PIN))
@@ -129,8 +129,7 @@ async def to_code(config: ConfigType) -> None:
var = await binary_sensor.new_binary_sensor(config)
await cg.register_component(var, config)
pin = await cg.gpio_pin_expression(config[CONF_PIN])
cg.add(var.set_pin(pin))
await cg.add_pin(var.set_pin, config[CONF_PIN])
if config[CONF_USE_INTERRUPT]:
cg.add_define("USE_GPIO_BINARY_SENSOR_INTERRUPT")
+1 -2
View File
@@ -23,5 +23,4 @@ async def to_code(config: ConfigType) -> None:
var = cg.new_Pvariable(config[CONF_ID])
await cg.register_component(var, config)
pin = await cg.gpio_pin_expression(config[CONF_PIN])
cg.add(var.set_pin(pin))
await cg.add_pin(var.set_pin, config[CONF_PIN])
+1 -2
View File
@@ -45,5 +45,4 @@ async def to_code(config: ConfigType) -> None:
await output.register_output(var, config)
await cg.register_component(var, config)
pin = await cg.gpio_pin_expression(config[CONF_PIN])
cg.add(var.set_pin(pin))
await cg.add_pin(var.set_pin, config[CONF_PIN])
+1 -2
View File
@@ -33,8 +33,7 @@ async def to_code(config: ConfigType) -> None:
var = await switch.new_switch(config)
await cg.register_component(var, config)
pin = await cg.gpio_pin_expression(config[CONF_PIN])
cg.add(var.set_pin(pin))
await cg.add_pin(var.set_pin, config[CONF_PIN])
if (interlock := config.get(CONF_INTERLOCK)) is not None:
cg.add_define("USE_GPIO_SWITCH_INTERLOCK")
+2 -7
View File
@@ -226,13 +226,8 @@ async def to_code(config: ConfigType) -> None:
await touchscreen.register_touchscreen(var, config)
await i2c.register_i2c_device(var, config)
if CONF_INTERRUPT_PIN in config:
pin = await cg.gpio_pin_expression(config[CONF_INTERRUPT_PIN])
cg.add(var.set_interrupt_pin(pin))
if CONF_RESET_PIN in config:
pin = await cg.gpio_pin_expression(config[CONF_RESET_PIN])
cg.add(var.set_reset_pin(pin))
await cg.add_pin(var.set_interrupt_pin, config.get(CONF_INTERRUPT_PIN))
await cg.add_pin(var.set_reset_pin, config.get(CONF_RESET_PIN))
# Firmware table
data = _read_firmware(config)
@@ -28,7 +28,5 @@ async def to_code(config: ConfigType) -> None:
await touchscreen.register_touchscreen(var, config)
await i2c.register_i2c_device(var, config)
if interrupt_pin := config.get(CONF_INTERRUPT_PIN):
cg.add(var.set_interrupt_pin(await cg.gpio_pin_expression(interrupt_pin)))
if reset_pin := config.get(CONF_RESET_PIN):
cg.add(var.set_reset_pin(await cg.gpio_pin_expression(reset_pin)))
await cg.add_pin(var.set_interrupt_pin, config.get(CONF_INTERRUPT_PIN))
await cg.add_pin(var.set_reset_pin, config.get(CONF_RESET_PIN))
@@ -35,10 +35,8 @@ async def to_code(config: ConfigType) -> None:
var = await switch.new_switch(config)
await cg.register_component(var, config)
on_pin = await cg.gpio_pin_expression(config[CONF_ON_PIN])
cg.add(var.set_on_pin(on_pin))
off_pin = await cg.gpio_pin_expression(config[CONF_OFF_PIN])
cg.add(var.set_off_pin(off_pin))
await cg.add_pin(var.set_on_pin, config[CONF_ON_PIN])
await cg.add_pin(var.set_off_pin, config[CONF_OFF_PIN])
cg.add(var.set_pulse_length(config[CONF_PULSE_LENGTH]))
cg.add(var.set_optimistic(config[CONF_OPTIMISTIC]))
if wait_time := config.get(CONF_WAIT_TIME):
+3 -6
View File
@@ -98,12 +98,9 @@ async def to_code(config: ConfigType) -> None:
var = cg.new_Pvariable(config[CONF_ID])
await cg.register_component(var, config)
sel = await cg.gpio_pin_expression(config[CONF_SEL_PIN])
cg.add(var.set_sel_pin(sel))
cf = await cg.gpio_pin_expression(config[CONF_CF_PIN])
cg.add(var.set_cf_pin(cf))
cf1 = await cg.gpio_pin_expression(config[CONF_CF1_PIN])
cg.add(var.set_cf1_pin(cf1))
await cg.add_pin(var.set_sel_pin, config[CONF_SEL_PIN])
await cg.add_pin(var.set_cf_pin, config[CONF_CF_PIN])
await cg.add_pin(var.set_cf1_pin, config[CONF_CF1_PIN])
sensors = sensor.sub_sensors(config)
await sensors(CONF_VOLTAGE, var.set_voltage_sensor)
+2 -4
View File
@@ -39,8 +39,6 @@ async def to_code(config: ConfigType) -> None:
var = await sensor.new_sensor(config)
await cg.register_component(var, config)
dout_pin = await cg.gpio_pin_expression(config[CONF_DOUT_PIN])
cg.add(var.set_dout_pin(dout_pin))
sck_pin = await cg.gpio_pin_expression(config[CONF_CLK_PIN])
cg.add(var.set_sck_pin(sck_pin))
await cg.add_pin(var.set_dout_pin, config[CONF_DOUT_PIN])
await cg.add_pin(var.set_sck_pin, config[CONF_CLK_PIN])
cg.add(var.set_gain(config[CONF_GAIN]))
+2 -7
View File
@@ -31,10 +31,5 @@ async def to_code(config: ConfigType) -> None:
await touchscreen.register_touchscreen(var, config)
await i2c.register_i2c_device(var, config)
if interrupt_pin_config := config.get(CONF_INTERRUPT_PIN):
cg.add(
var.set_interrupt_pin(await cg.gpio_pin_expression(interrupt_pin_config))
)
if reset_pin_config := config.get(CONF_RESET_PIN):
cg.add(var.set_reset_pin(await cg.gpio_pin_expression(reset_pin_config)))
await cg.add_pin(var.set_interrupt_pin, config.get(CONF_INTERRUPT_PIN))
await cg.add_pin(var.set_reset_pin, config.get(CONF_RESET_PIN))
+19 -56
View File
@@ -184,59 +184,22 @@ async def to_code(config: ConfigType) -> None:
waveform = [element for tupl in waveform for element in tupl]
cg.add(var.set_waveform(waveform, False))
ckv = await cg.gpio_pin_expression(config[CONF_CKV_PIN])
cg.add(var.set_ckv_pin(ckv))
gmod = await cg.gpio_pin_expression(config[CONF_GMOD_PIN])
cg.add(var.set_gmod_pin(gmod))
gpio0_enable = await cg.gpio_pin_expression(config[CONF_GPIO0_ENABLE_PIN])
cg.add(var.set_gpio0_enable_pin(gpio0_enable))
oe = await cg.gpio_pin_expression(config[CONF_OE_PIN])
cg.add(var.set_oe_pin(oe))
powerup = await cg.gpio_pin_expression(config[CONF_POWERUP_PIN])
cg.add(var.set_powerup_pin(powerup))
sph = await cg.gpio_pin_expression(config[CONF_SPH_PIN])
cg.add(var.set_sph_pin(sph))
spv = await cg.gpio_pin_expression(config[CONF_SPV_PIN])
cg.add(var.set_spv_pin(spv))
vcom = await cg.gpio_pin_expression(config[CONF_VCOM_PIN])
cg.add(var.set_vcom_pin(vcom))
wakeup = await cg.gpio_pin_expression(config[CONF_WAKEUP_PIN])
cg.add(var.set_wakeup_pin(wakeup))
cl = await cg.gpio_pin_expression(config[CONF_CL_PIN])
cg.add(var.set_cl_pin(cl))
le = await cg.gpio_pin_expression(config[CONF_LE_PIN])
cg.add(var.set_le_pin(le))
display_data_0 = await cg.gpio_pin_expression(config[CONF_DISPLAY_DATA_0_PIN])
cg.add(var.set_display_data_0_pin(display_data_0))
display_data_1 = await cg.gpio_pin_expression(config[CONF_DISPLAY_DATA_1_PIN])
cg.add(var.set_display_data_1_pin(display_data_1))
display_data_2 = await cg.gpio_pin_expression(config[CONF_DISPLAY_DATA_2_PIN])
cg.add(var.set_display_data_2_pin(display_data_2))
display_data_3 = await cg.gpio_pin_expression(config[CONF_DISPLAY_DATA_3_PIN])
cg.add(var.set_display_data_3_pin(display_data_3))
display_data_4 = await cg.gpio_pin_expression(config[CONF_DISPLAY_DATA_4_PIN])
cg.add(var.set_display_data_4_pin(display_data_4))
display_data_5 = await cg.gpio_pin_expression(config[CONF_DISPLAY_DATA_5_PIN])
cg.add(var.set_display_data_5_pin(display_data_5))
display_data_6 = await cg.gpio_pin_expression(config[CONF_DISPLAY_DATA_6_PIN])
cg.add(var.set_display_data_6_pin(display_data_6))
display_data_7 = await cg.gpio_pin_expression(config[CONF_DISPLAY_DATA_7_PIN])
cg.add(var.set_display_data_7_pin(display_data_7))
await cg.add_pin(var.set_ckv_pin, config[CONF_CKV_PIN])
await cg.add_pin(var.set_gmod_pin, config[CONF_GMOD_PIN])
await cg.add_pin(var.set_gpio0_enable_pin, config[CONF_GPIO0_ENABLE_PIN])
await cg.add_pin(var.set_oe_pin, config[CONF_OE_PIN])
await cg.add_pin(var.set_powerup_pin, config[CONF_POWERUP_PIN])
await cg.add_pin(var.set_sph_pin, config[CONF_SPH_PIN])
await cg.add_pin(var.set_spv_pin, config[CONF_SPV_PIN])
await cg.add_pin(var.set_vcom_pin, config[CONF_VCOM_PIN])
await cg.add_pin(var.set_wakeup_pin, config[CONF_WAKEUP_PIN])
await cg.add_pin(var.set_cl_pin, config[CONF_CL_PIN])
await cg.add_pin(var.set_le_pin, config[CONF_LE_PIN])
await cg.add_pin(var.set_display_data_0_pin, config[CONF_DISPLAY_DATA_0_PIN])
await cg.add_pin(var.set_display_data_1_pin, config[CONF_DISPLAY_DATA_1_PIN])
await cg.add_pin(var.set_display_data_2_pin, config[CONF_DISPLAY_DATA_2_PIN])
await cg.add_pin(var.set_display_data_3_pin, config[CONF_DISPLAY_DATA_3_PIN])
await cg.add_pin(var.set_display_data_4_pin, config[CONF_DISPLAY_DATA_4_PIN])
await cg.add_pin(var.set_display_data_5_pin, config[CONF_DISPLAY_DATA_5_PIN])
await cg.add_pin(var.set_display_data_6_pin, config[CONF_DISPLAY_DATA_6_PIN])
await cg.add_pin(var.set_display_data_7_pin, config[CONF_DISPLAY_DATA_7_PIN])
+2 -4
View File
@@ -367,10 +367,8 @@ async def to_code(config: ConfigType) -> None:
await spi.register_spi_device(var, config, write_only=False)
await display.add_writer(var, config)
if reset_pin := config.get(CONF_RESET_PIN):
cg.add(var.set_reset_pin(await cg.gpio_pin_expression(reset_pin)))
if busy_pin := config.get(CONF_BUSY_PIN):
cg.add(var.set_busy_pin(await cg.gpio_pin_expression(busy_pin)))
await cg.add_pin(var.set_reset_pin, config.get(CONF_RESET_PIN))
await cg.add_pin(var.set_busy_pin, config.get(CONF_BUSY_PIN))
if enable_pins := config.get(CONF_ENABLE_PIN):
cg.add(
var.set_enable_pins(
+3 -9
View File
@@ -43,14 +43,8 @@ async def to_code(config: ConfigType) -> None:
await lcd_base.setup_lcd_display(var, config)
pins_ = [await cg.gpio_pin_expression(conf) for conf in config[CONF_DATA_PINS]]
cg.add(var.set_data_pins(*pins_))
enable = await cg.gpio_pin_expression(config[CONF_ENABLE_PIN])
cg.add(var.set_enable_pin(enable))
rs = await cg.gpio_pin_expression(config[CONF_RS_PIN])
cg.add(var.set_rs_pin(rs))
if CONF_RW_PIN in config:
rw = await cg.gpio_pin_expression(config[CONF_RW_PIN])
cg.add(var.set_rw_pin(rw))
await cg.add_pin(var.set_enable_pin, config[CONF_ENABLE_PIN])
await cg.add_pin(var.set_rs_pin, config[CONF_RS_PIN])
await cg.add_pin(var.set_rw_pin, config.get(CONF_RW_PIN))
await display.add_writer(var, config, GPIOLCDDisplay.operator("ref"))
@@ -35,5 +35,4 @@ async def to_code(config: ConfigType) -> None:
await touchscreen.register_touchscreen(var, config)
await i2c.register_i2c_device(var, config)
interrupt_pin = await cg.gpio_pin_expression(config[CONF_INTERRUPT_PIN])
cg.add(var.set_interrupt_pin(interrupt_pin))
await cg.add_pin(var.set_interrupt_pin, config[CONF_INTERRUPT_PIN])
+1 -2
View File
@@ -434,8 +434,7 @@ async def to_code(config: ConfigType) -> None:
cg.add(var.set_warmup_time(config[CONF_WARMUP_TIME]))
cg.add(var.set_preference_key(_preference_key(config)))
if (enable := config.get(CONF_ENABLE_PIN)) is not None:
cg.add(var.set_enable_pin(await cg.gpio_pin_expression(enable)))
await cg.add_pin(var.set_enable_pin, config.get(CONF_ENABLE_PIN))
if (reference := config.get(CONF_AIR_REFERENCE, config.get(CONF_R0))) is not None:
cg.add(var.set_reference(reference))
# A request on a hub without `calibration:` uses the schema defaults, never persisted.
+1 -3
View File
@@ -213,9 +213,7 @@ async def to_code(config: ConfigType) -> None:
cg.add(var.set_pclk_frequency(config[CONF_PCLK_FREQUENCY] / 1.0e6))
cg.add(var.set_lanes(int(config[CONF_LANES])))
cg.add(var.set_lane_bit_rate(config[CONF_LANE_BIT_RATE] / 1.0e6))
if reset_pin := config.get(CONF_RESET_PIN):
reset = await cg.gpio_pin_expression(reset_pin)
cg.add(var.set_reset_pin(reset))
await cg.add_pin(var.set_reset_pin, config.get(CONF_RESET_PIN))
if enable_pin := config.get(CONF_ENABLE_PIN):
enable = [await cg.gpio_pin_expression(pin) for pin in enable_pin]
cg.add(var.set_enable_pins(enable))
+6 -18
View File
@@ -315,28 +315,16 @@ async def to_code(config: ConfigType) -> None:
data_pin = await cg.gpio_pin_expression(pin)
cg.add(var.add_data_pin(data_pin, index))
if dc_pin := config.get(CONF_DC_PIN):
dc = await cg.gpio_pin_expression(dc_pin)
cg.add(var.set_dc_pin(dc))
if reset_pin := config.get(CONF_RESET_PIN):
reset = await cg.gpio_pin_expression(reset_pin)
cg.add(var.set_reset_pin(reset))
await cg.add_pin(var.set_dc_pin, config.get(CONF_DC_PIN))
await cg.add_pin(var.set_reset_pin, config.get(CONF_RESET_PIN))
if model.rotation_as_transform(config):
config[CONF_ROTATION] = 0
if de_pin := config.get(CONF_DE_PIN):
pin = await cg.gpio_pin_expression(de_pin)
cg.add(var.set_de_pin(pin))
pin = await cg.gpio_pin_expression(config[CONF_PCLK_PIN])
cg.add(var.set_pclk_pin(pin))
if hsync_pin := config.get(CONF_HSYNC_PIN):
pin = await cg.gpio_pin_expression(hsync_pin)
cg.add(var.set_hsync_pin(pin))
if vsync_pin := config.get(CONF_VSYNC_PIN):
pin = await cg.gpio_pin_expression(vsync_pin)
cg.add(var.set_vsync_pin(pin))
await cg.add_pin(var.set_de_pin, config.get(CONF_DE_PIN))
await cg.add_pin(var.set_pclk_pin, config[CONF_PCLK_PIN])
await cg.add_pin(var.set_hsync_pin, config.get(CONF_HSYNC_PIN))
await cg.add_pin(var.set_vsync_pin, config.get(CONF_VSYNC_PIN))
await display.register_display(var, config)
await display.add_writer(var, config)
+2 -7
View File
@@ -408,13 +408,8 @@ async def to_code(config: ConfigType) -> None:
enable = [await cg.gpio_pin_expression(pin) for pin in enable_pin]
cg.add(var.set_enable_pins(enable))
if reset_pin := config.get(CONF_RESET_PIN):
reset = await cg.gpio_pin_expression(reset_pin)
cg.add(var.set_reset_pin(reset))
if dc_pin := config.get(CONF_DC_PIN):
dc_pin = await cg.gpio_pin_expression(dc_pin)
cg.add(var.set_dc_pin(dc_pin))
await cg.add_pin(var.set_reset_pin, config.get(CONF_RESET_PIN))
await cg.add_pin(var.set_dc_pin, config.get(CONF_DC_PIN))
if config.get(CONF_INVERT_COLORS):
cg.add(var.set_invert_colors(True))
+1 -3
View File
@@ -145,8 +145,6 @@ async def to_code(config: ConfigType) -> None:
cg.add(var.set_resolution(2, RESOLUTION[config[CONF_Z_AXIS][CONF_RESOLUTION]]))
if await sensors(CONF_TEMPERATURE, var.set_t_sensor):
cg.add(var.set_t_oversampling(config[CONF_TEMPERATURE][CONF_OVERSAMPLING]))
if CONF_DRDY_PIN in config:
pin = await cg.gpio_pin_expression(config[CONF_DRDY_PIN])
cg.add(var.set_drdy_gpio(pin))
await cg.add_pin(var.set_drdy_gpio, config.get(CONF_DRDY_PIN))
cg.add_library("functionpointer/arduino-MLX90393", "1.0.2")
+1 -4
View File
@@ -11,7 +11,6 @@ from esphome.components.const import CONF_ROLE
import esphome.config_validation as cv
from esphome.const import CONF_ADDRESS, CONF_CONTINUOUS, CONF_FLOW_CONTROL_PIN, CONF_ID
from esphome.cpp_generator import MockObj
from esphome.cpp_helpers import gpio_pin_expression
import esphome.final_validate as fv
from esphome.types import ConfigType, TemplateArgsType
@@ -307,9 +306,7 @@ async def to_code(config: ConfigType) -> None:
await uart.register_uart_device(var, config)
if CONF_FLOW_CONTROL_PIN in config:
pin = await gpio_pin_expression(config[CONF_FLOW_CONTROL_PIN])
cg.add(var.set_flow_control_pin(pin))
await cg.add_pin(var.set_flow_control_pin, config.get(CONF_FLOW_CONTROL_PIN))
if config[CONF_ROLE] == "client":
cg.add(var.set_send_wait_time(config[CONF_SEND_WAIT_TIME]))
+2 -4
View File
@@ -33,10 +33,8 @@ async def to_code(config: ConfigType) -> None:
var = cg.new_Pvariable(config[CONF_ID])
await cg.register_component(var, config)
di = await cg.gpio_pin_expression(config[CONF_DATA_PIN])
cg.add(var.set_pin_di(di))
dcki = await cg.gpio_pin_expression(config[CONF_CLOCK_PIN])
cg.add(var.set_pin_dcki(dcki))
await cg.add_pin(var.set_pin_di, config[CONF_DATA_PIN])
await cg.add_pin(var.set_pin_dcki, config[CONF_CLOCK_PIN])
cg.add(var.set_num_channels(config[CONF_NUM_CHANNELS]))
cg.add(var.set_num_chips(config[CONF_NUM_CHIPS]))
+1 -3
View File
@@ -529,9 +529,7 @@ async def to_code(config: ConfigType) -> None:
async def _dfu_to_code(dfu_config):
cg.add_define("USE_NRF52_DFU")
var = cg.new_Pvariable(dfu_config[CONF_ID])
if CONF_RESET_PIN in dfu_config:
pin = await cg.gpio_pin_expression(dfu_config[CONF_RESET_PIN])
cg.add(var.set_reset_pin(pin))
await cg.add_pin(var.set_reset_pin, dfu_config.get(CONF_RESET_PIN))
# DFU uses cdc rate callback to enter bootloader which was disabled explicitly to save power.
zephyr_add_prj_conf("USB_DEVICE_STACK", True)
+2 -5
View File
@@ -87,11 +87,8 @@ async def to_code(config: dict[str, Any]) -> None:
await cg.register_component(var, config)
# Set pins
in_pin = await cg.gpio_pin_expression(config[CONF_IN_PIN])
cg.add(var.set_in_pin(in_pin))
out_pin = await cg.gpio_pin_expression(config[CONF_OUT_PIN])
cg.add(var.set_out_pin(out_pin))
await cg.add_pin(var.set_in_pin, config[CONF_IN_PIN])
await cg.add_pin(var.set_out_pin, config[CONF_OUT_PIN])
non_sensors = {
CONF_ID,
+2 -4
View File
@@ -47,10 +47,8 @@ async def to_code(config: ConfigType) -> None:
await display.register_display(var, config)
await spi.register_spi_device(var, config, write_only=True)
dc = await cg.gpio_pin_expression(config[CONF_DC_PIN])
cg.add(var.set_dc_pin(dc))
reset = await cg.gpio_pin_expression(config[CONF_RESET_PIN])
cg.add(var.set_reset_pin(reset))
await cg.add_pin(var.set_dc_pin, config[CONF_DC_PIN])
await cg.add_pin(var.set_reset_pin, config[CONF_RESET_PIN])
cg.add(var.set_contrast(config[CONF_CONTRAST]))
+2 -7
View File
@@ -29,10 +29,5 @@ pn71xx.register_is_writing_condition("pn7160.is_writing", PN7160)
async def setup_pn7160(var: MockObj, config: ConfigType) -> None:
await pn71xx.setup_pn71xx(var, config)
if dwl_req_pin_config := config.get(CONF_DWL_REQ_PIN):
pin = await cg.gpio_pin_expression(dwl_req_pin_config)
cg.add(var.set_dwl_req_pin(pin))
if wkup_req_pin_config := config.get(CONF_WKUP_REQ_PIN):
pin = await cg.gpio_pin_expression(wkup_req_pin_config)
cg.add(var.set_wkup_req_pin(pin))
await cg.add_pin(var.set_dwl_req_pin, config.get(CONF_DWL_REQ_PIN))
await cg.add_pin(var.set_wkup_req_pin, config.get(CONF_WKUP_REQ_PIN))
+2 -5
View File
@@ -127,11 +127,8 @@ _request_ontagremoved_trigger_slot = cg.slot_counter(
async def setup_pn71xx(var: MockObj, config: ConfigType) -> None:
await cg.register_component(var, config)
pin = await cg.gpio_pin_expression(config[CONF_IRQ_PIN])
cg.add(var.set_irq_pin(pin))
pin = await cg.gpio_pin_expression(config[CONF_VEN_PIN])
cg.add(var.set_ven_pin(pin))
await cg.add_pin(var.set_irq_pin, config[CONF_IRQ_PIN])
await cg.add_pin(var.set_ven_pin, config[CONF_VEN_PIN])
if emulation_message_config := config.get(CONF_EMULATION_MESSAGE):
cg.add(var.set_tag_emulation_message(emulation_message_config))
+1 -2
View File
@@ -35,8 +35,7 @@ async def to_code(config: ConfigType) -> None:
var = cg.new_Pvariable(config[CONF_ID])
await cg.register_component(var, config)
pin = await cg.gpio_pin_expression(config[CONF_PIN])
cg.add(var.set_pin(pin))
await cg.add_pin(var.set_pin, config[CONF_PIN])
cg.add(var.set_enable_time(config[CONF_ENABLE_TIME]))
cg.add(var.set_keep_on_time(config[CONF_KEEP_ON_TIME]))
cg.add(var.set_enable_on_boot(config[CONF_ENABLE_ON_BOOT]))
+1 -2
View File
@@ -131,8 +131,7 @@ async def to_code(config: ConfigType) -> None:
var = await sensor.new_sensor(config, use_pcnt)
await cg.register_component(var, config)
pin = await cg.gpio_pin_expression(config[CONF_PIN])
cg.add(var.set_pin(pin))
await cg.add_pin(var.set_pin, config[CONF_PIN])
count = config[CONF_COUNT_MODE]
cg.add(var.set_rising_edge_mode(count[CONF_RISING_EDGE]))
cg.add(var.set_falling_edge_mode(count[CONF_FALLING_EDGE]))
+1 -2
View File
@@ -83,8 +83,7 @@ async def to_code(config: ConfigType) -> None:
var = await sensor.new_sensor(config)
await cg.register_component(var, config)
pin = await cg.gpio_pin_expression(config[CONF_PIN])
cg.add(var.set_pin(pin))
await cg.add_pin(var.set_pin, config[CONF_PIN])
cg.add(var.set_filter_us(config[CONF_INTERNAL_FILTER]))
cg.add(var.set_timeout_us(config[CONF_TIMEOUT]))
cg.add(var.set_filter_mode(config[CONF_INTERNAL_FILTER_MODE]))
+1 -2
View File
@@ -32,5 +32,4 @@ async def to_code(config: ConfigType) -> None:
var = await sensor.new_sensor(config)
await cg.register_component(var, config)
pin = await cg.gpio_pin_expression(config[CONF_PIN])
cg.add(var.set_pin(pin))
await cg.add_pin(var.set_pin, config[CONF_PIN])
+1 -3
View File
@@ -153,6 +153,4 @@ async def to_code(config: ConfigType) -> None:
await sensors(CONF_FIELD_STRENGTH_Z, var.set_z_sensor)
await sensors(CONF_HEADING, var.set_heading_sensor)
await sensors(CONF_TEMPERATURE, var.set_temperature_sensor)
if CONF_DRDY_PIN in config:
pin = await cg.gpio_pin_expression(config[CONF_DRDY_PIN])
cg.add(var.set_drdy_pin(pin))
await cg.add_pin(var.set_drdy_pin, config.get(CONF_DRDY_PIN))
+1 -3
View File
@@ -44,9 +44,7 @@ RC522_SCHEMA = cv.Schema(
async def setup_rc522(var: MockObj, config: ConfigType) -> None:
await cg.register_component(var, config)
if CONF_RESET_PIN in config:
reset = await cg.gpio_pin_expression(config[CONF_RESET_PIN])
cg.add(var.set_reset_pin(reset))
await cg.add_pin(var.set_reset_pin, config.get(CONF_RESET_PIN))
for conf in config.get(CONF_ON_TAG, []):
trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID])
+3 -7
View File
@@ -93,16 +93,12 @@ async def to_code(config: ConfigType) -> None:
var = await sensor.new_sensor(config)
await cg.register_component(var, config)
pin_a = await cg.gpio_pin_expression(config[CONF_PIN_A])
cg.add(var.set_pin_a(pin_a))
pin_b = await cg.gpio_pin_expression(config[CONF_PIN_B])
cg.add(var.set_pin_b(pin_b))
await cg.add_pin(var.set_pin_a, config[CONF_PIN_A])
await cg.add_pin(var.set_pin_b, config[CONF_PIN_B])
cg.add(var.set_publish_initial_value(config[CONF_PUBLISH_INITIAL_VALUE]))
cg.add(var.set_restore_mode(config[CONF_RESTORE_MODE]))
if CONF_PIN_RESET in config:
pin_i = await cg.gpio_pin_expression(config[CONF_PIN_RESET])
cg.add(var.set_reset_pin(pin_i))
await cg.add_pin(var.set_reset_pin, config.get(CONF_PIN_RESET))
cg.add(var.set_resolution(config[CONF_RESOLUTION]))
if CONF_MIN_VALUE in config:
cg.add(var.set_min_value(config[CONF_MIN_VALUE]))
+1 -2
View File
@@ -27,8 +27,7 @@ async def to_code(config: ConfigType) -> None:
await cg.register_component(var, config)
await output.register_output(var, config)
pin = await cg.gpio_pin_expression(config[CONF_PIN])
cg.add(var.set_pin(pin))
await cg.add_pin(var.set_pin, config[CONF_PIN])
cg.add(var.set_frequency(config[CONF_FREQUENCY]))
+2 -7
View File
@@ -117,10 +117,5 @@ async def to_code(config: ConfigType) -> None:
CORE.add_job(_add_serial_proxy_count_define)
data.count += 1
if CONF_RTS_PIN in config:
rts_pin = await cg.gpio_pin_expression(config[CONF_RTS_PIN])
cg.add(var.set_rts_pin(rts_pin))
if CONF_DTR_PIN in config:
dtr_pin = await cg.gpio_pin_expression(config[CONF_DTR_PIN])
cg.add(var.set_dtr_pin(dtr_pin))
await cg.add_pin(var.set_rts_pin, config.get(CONF_RTS_PIN))
await cg.add_pin(var.set_dtr_pin, config.get(CONF_DTR_PIN))
+1 -3
View File
@@ -32,8 +32,6 @@ async def setup_sh1122(var: MockObj, config: ConfigType) -> None:
await display.register_display(var, config)
cg.add(var.set_model(config[CONF_MODEL]))
if (reset_pin := config.get(CONF_RESET_PIN)) is not None:
reset = await cg.gpio_pin_expression(reset_pin)
cg.add(var.set_reset_pin(reset))
await cg.add_pin(var.set_reset_pin, config.get(CONF_RESET_PIN))
cg.add(var.init_brightness(config[CONF_BRIGHTNESS]))
await display.add_writer(var, config)
+2 -4
View File
@@ -250,10 +250,8 @@ async def to_code(config: ConfigType) -> None:
await light.register_light(var, config)
await uart.register_uart_device(var, config)
nrst_pin = await cg.gpio_pin_expression(config[CONF_NRST_PIN])
cg.add(var.set_nrst_pin(nrst_pin))
boot0_pin = await cg.gpio_pin_expression(config[CONF_BOOT0_PIN])
cg.add(var.set_boot0_pin(boot0_pin))
await cg.add_pin(var.set_nrst_pin, config[CONF_NRST_PIN])
await cg.add_pin(var.set_boot0_pin, config[CONF_BOOT0_PIN])
cg.add(var.set_leading_edge(config[CONF_LEADING_EDGE]))
cg.add(var.set_warmup_brightness(config[CONF_WARMUP_BRIGHTNESS]))
@@ -43,9 +43,7 @@ async def to_code(config: ConfigType) -> None:
await cg.register_component(var, config)
await output.register_output(var, config)
if CONF_PIN in config:
pin = await cg.gpio_pin_expression(config[CONF_PIN])
cg.add(var.set_pin(pin))
await cg.add_pin(var.set_pin, config.get(CONF_PIN))
if CONF_STATE_CHANGE_ACTION in config:
await automation.build_automation(
+1 -3
View File
@@ -47,9 +47,7 @@ async def to_code(config: ConfigType) -> None:
var = cg.new_Pvariable(config[CONF_ID])
await cg.register_component(var, config)
await output.register_output(var, config)
if CONF_PIN in config:
pin = await cg.gpio_pin_expression(config[CONF_PIN])
cg.add(var.set_pin(pin))
await cg.add_pin(var.set_pin, config.get(CONF_PIN))
if CONF_STATE_CHANGE_ACTION in config:
await automation.build_automation(
var.get_state_change_trigger(),
+2 -4
View File
@@ -33,10 +33,8 @@ async def register_sm10bit_base(config: ConfigType) -> MockObj:
var = cg.new_Pvariable(config[CONF_ID])
await cg.register_component(var, config)
data = await cg.gpio_pin_expression(config[CONF_DATA_PIN])
cg.add(var.set_data_pin(data))
clock = await cg.gpio_pin_expression(config[CONF_CLOCK_PIN])
cg.add(var.set_clock_pin(clock))
await cg.add_pin(var.set_data_pin, config[CONF_DATA_PIN])
await cg.add_pin(var.set_clock_pin, config[CONF_CLOCK_PIN])
cg.add(var.set_max_power_color_channels(config[CONF_MAX_POWER_COLOR_CHANNELS]))
cg.add(var.set_max_power_white_channels(config[CONF_MAX_POWER_WHITE_CHANNELS]))
+2 -4
View File
@@ -31,10 +31,8 @@ async def to_code(config: ConfigType) -> None:
var = cg.new_Pvariable(config[CONF_ID])
await cg.register_component(var, config)
data = await cg.gpio_pin_expression(config[CONF_DATA_PIN])
cg.add(var.set_data_pin(data))
clock = await cg.gpio_pin_expression(config[CONF_CLOCK_PIN])
cg.add(var.set_clock_pin(clock))
await cg.add_pin(var.set_data_pin, config[CONF_DATA_PIN])
await cg.add_pin(var.set_clock_pin, config[CONF_CLOCK_PIN])
cg.add(var.set_num_channels(config[CONF_NUM_CHANNELS]))
cg.add(var.set_num_chips(config[CONF_NUM_CHIPS]))
+2 -4
View File
@@ -61,10 +61,8 @@ async def to_code(config: ConfigType) -> None:
var = cg.new_Pvariable(config[CONF_ID])
await cg.register_component(var, config)
data = await cg.gpio_pin_expression(config[CONF_DATA_PIN])
cg.add(var.set_data_pin(data))
clock = await cg.gpio_pin_expression(config[CONF_CLOCK_PIN])
cg.add(var.set_clock_pin(clock))
await cg.add_pin(var.set_data_pin, config[CONF_DATA_PIN])
await cg.add_pin(var.set_clock_pin, config[CONF_CLOCK_PIN])
cg.add(var.set_rgb_current(config[CONF_RGB_CURRENT]))
cg.add(var.set_cw_current(config[CONF_CW_CURRENT]))
+4 -9
View File
@@ -44,15 +44,10 @@ CONFIG_SCHEMA = cv.Schema(
async def to_code(config: ConfigType) -> None:
var = cg.new_Pvariable(config[CONF_ID])
await cg.register_component(var, config)
data_pin = await cg.gpio_pin_expression(config[CONF_DATA_PIN])
cg.add(var.set_data_pin(data_pin))
clock_pin = await cg.gpio_pin_expression(config[CONF_CLOCK_PIN])
cg.add(var.set_clock_pin(clock_pin))
load_pin = await cg.gpio_pin_expression(config[CONF_LOAD_PIN])
cg.add(var.set_load_pin(load_pin))
if CONF_CLOCK_INHIBIT_PIN in config:
clock_inhibit_pin = await cg.gpio_pin_expression(config[CONF_CLOCK_INHIBIT_PIN])
cg.add(var.set_clock_inhibit_pin(clock_inhibit_pin))
await cg.add_pin(var.set_data_pin, config[CONF_DATA_PIN])
await cg.add_pin(var.set_clock_pin, config[CONF_CLOCK_PIN])
await cg.add_pin(var.set_load_pin, config[CONF_LOAD_PIN])
await cg.add_pin(var.set_clock_inhibit_pin, config.get(CONF_CLOCK_INHIBIT_PIN))
cg.add(var.set_sr_count(config[CONF_SR_COUNT]))
+4 -9
View File
@@ -72,18 +72,13 @@ async def to_code(config: ConfigType) -> None:
var = cg.new_Pvariable(config[CONF_ID])
await cg.register_component(var, config)
if config[CONF_TYPE] == TYPE_GPIO:
data_pin = await cg.gpio_pin_expression(config[CONF_DATA_PIN])
cg.add(var.set_data_pin(data_pin))
clock_pin = await cg.gpio_pin_expression(config[CONF_CLOCK_PIN])
cg.add(var.set_clock_pin(clock_pin))
await cg.add_pin(var.set_data_pin, config[CONF_DATA_PIN])
await cg.add_pin(var.set_clock_pin, config[CONF_CLOCK_PIN])
else:
await spi.register_spi_device(var, config)
latch_pin = await cg.gpio_pin_expression(config[CONF_LATCH_PIN])
cg.add(var.set_latch_pin(latch_pin))
if oe_pin := config.get(CONF_OE_PIN):
oe_pin = await cg.gpio_pin_expression(oe_pin)
cg.add(var.set_oe_pin(oe_pin))
await cg.add_pin(var.set_latch_pin, config[CONF_LATCH_PIN])
await cg.add_pin(var.set_oe_pin, config.get(CONF_OE_PIN))
cg.add(var.set_sr_count(config[CONF_SR_COUNT]))
+2 -4
View File
@@ -27,7 +27,5 @@ async def to_code(config: ConfigType) -> None:
var = cg.new_Pvariable(config[CONF_ID])
await touchscreen.register_touchscreen(var, config)
await i2c.register_i2c_device(var, config)
if interrupt_pin := config.get(CONF_INTERRUPT_PIN):
cg.add(var.set_interrupt_pin(await cg.gpio_pin_expression(interrupt_pin)))
if reset_pin := config.get(CONF_RESET_PIN):
cg.add(var.set_reset_pin(await cg.gpio_pin_expression(reset_pin)))
await cg.add_pin(var.set_interrupt_pin, config.get(CONF_INTERRUPT_PIN))
await cg.add_pin(var.set_reset_pin, config.get(CONF_RESET_PIN))
+4 -9
View File
@@ -436,12 +436,9 @@ async def to_code(configs: list[ConfigType]) -> None:
for spi in configs:
var = cg.new_Pvariable(spi[CONF_ID])
await cg.register_component(var, spi)
clk = await cg.gpio_pin_expression(spi[CONF_CLK_PIN])
cg.add(var.set_clk(clk))
if miso := spi.get(CONF_MISO_PIN):
cg.add(var.set_miso(await cg.gpio_pin_expression(miso)))
if mosi := spi.get(CONF_MOSI_PIN):
cg.add(var.set_mosi(await cg.gpio_pin_expression(mosi)))
await cg.add_pin(var.set_clk, spi[CONF_CLK_PIN])
await cg.add_pin(var.set_miso, spi.get(CONF_MISO_PIN))
await cg.add_pin(var.set_mosi, spi.get(CONF_MOSI_PIN))
if data_pins := spi.get(CONF_DATA_PINS):
cg.add(var.set_data_pins(data_pins))
if (index := spi.get(CONF_INTERFACE_INDEX)) is not None:
@@ -491,9 +488,7 @@ async def register_spi_device(
cg.add(var.set_spi_parent(parent))
if write_only:
cg.add(var.set_write_only(True))
if cs_pin := config.get(CONF_CS_PIN):
pin = await cg.gpio_pin_expression(cs_pin)
cg.add(var.set_cs_pin(pin))
await cg.add_pin(var.set_cs_pin, config.get(CONF_CS_PIN))
if data_rate := config.get(CONF_DATA_RATE):
cg.add(var.set_data_rate(data_rate))
if spi_mode := config.get(CONF_SPI_MODE):
+1 -3
View File
@@ -80,9 +80,7 @@ async def setup_ssd1306(var: MockObj, config: ConfigType) -> None:
await display.register_display(var, config)
cg.add(var.set_model(config[CONF_MODEL]))
if CONF_RESET_PIN in config:
reset = await cg.gpio_pin_expression(config[CONF_RESET_PIN])
cg.add(var.set_reset_pin(reset))
await cg.add_pin(var.set_reset_pin, config.get(CONF_RESET_PIN))
if CONF_BRIGHTNESS in config:
cg.add(var.init_brightness(config[CONF_BRIGHTNESS]))
if CONF_CONTRAST in config:
+1 -2
View File
@@ -35,5 +35,4 @@ async def to_code(config: ConfigType) -> None:
await ssd1306_base.setup_ssd1306(var, config)
await spi.register_spi_device(var, config, write_only=True)
dc = await cg.gpio_pin_expression(config[CONF_DC_PIN])
cg.add(var.set_dc_pin(dc))
await cg.add_pin(var.set_dc_pin, config[CONF_DC_PIN])
+1 -3
View File
@@ -33,9 +33,7 @@ async def setup_ssd1322(var: MockObj, config: ConfigType) -> None:
await display.register_display(var, config)
cg.add(var.set_model(config[CONF_MODEL]))
if CONF_RESET_PIN in config:
reset = await cg.gpio_pin_expression(config[CONF_RESET_PIN])
cg.add(var.set_reset_pin(reset))
await cg.add_pin(var.set_reset_pin, config.get(CONF_RESET_PIN))
if CONF_BRIGHTNESS in config:
cg.add(var.init_brightness(config[CONF_BRIGHTNESS]))
if CONF_EXTERNAL_VCC in config:
+1 -2
View File
@@ -35,5 +35,4 @@ async def to_code(config: ConfigType) -> None:
await ssd1322_base.setup_ssd1322(var, config)
await spi.register_spi_device(var, config, write_only=True)
dc = await cg.gpio_pin_expression(config[CONF_DC_PIN])
cg.add(var.set_dc_pin(dc))
await cg.add_pin(var.set_dc_pin, config[CONF_DC_PIN])
+1 -3
View File
@@ -37,9 +37,7 @@ async def setup_ssd1325(var: MockObj, config: ConfigType) -> None:
await display.register_display(var, config)
cg.add(var.set_model(config[CONF_MODEL]))
if CONF_RESET_PIN in config:
reset = await cg.gpio_pin_expression(config[CONF_RESET_PIN])
cg.add(var.set_reset_pin(reset))
await cg.add_pin(var.set_reset_pin, config.get(CONF_RESET_PIN))
if CONF_BRIGHTNESS in config:
cg.add(var.init_brightness(config[CONF_BRIGHTNESS]))
if CONF_EXTERNAL_VCC in config:
+1 -2
View File
@@ -35,5 +35,4 @@ async def to_code(config: ConfigType) -> None:
await ssd1325_base.setup_ssd1325(var, config)
await spi.register_spi_device(var, config, write_only=True)
dc = await cg.gpio_pin_expression(config[CONF_DC_PIN])
cg.add(var.set_dc_pin(dc))
await cg.add_pin(var.set_dc_pin, config[CONF_DC_PIN])
+1 -3
View File
@@ -32,9 +32,7 @@ async def setup_ssd1327(var: MockObj, config: ConfigType) -> None:
await display.register_display(var, config)
cg.add(var.set_model(config[CONF_MODEL]))
if CONF_RESET_PIN in config:
reset = await cg.gpio_pin_expression(config[CONF_RESET_PIN])
cg.add(var.set_reset_pin(reset))
await cg.add_pin(var.set_reset_pin, config.get(CONF_RESET_PIN))
if CONF_BRIGHTNESS in config:
cg.add(var.init_brightness(config[CONF_BRIGHTNESS]))
await display.add_writer(var, config)
+1 -2
View File
@@ -35,5 +35,4 @@ async def to_code(config: ConfigType) -> None:
await ssd1327_base.setup_ssd1327(var, config)
await spi.register_spi_device(var, config, write_only=True)
dc = await cg.gpio_pin_expression(config[CONF_DC_PIN])
cg.add(var.set_dc_pin(dc))
await cg.add_pin(var.set_dc_pin, config[CONF_DC_PIN])
+1 -3
View File
@@ -23,9 +23,7 @@ SSD1331_SCHEMA = display.FULL_DISPLAY_SCHEMA.extend(
async def setup_ssd1331(var: MockObj, config: ConfigType) -> None:
await display.register_display(var, config)
if CONF_RESET_PIN in config:
reset = await cg.gpio_pin_expression(config[CONF_RESET_PIN])
cg.add(var.set_reset_pin(reset))
await cg.add_pin(var.set_reset_pin, config.get(CONF_RESET_PIN))
if CONF_BRIGHTNESS in config:
cg.add(var.init_brightness(config[CONF_BRIGHTNESS]))
await display.add_writer(var, config)
+1 -2
View File
@@ -35,5 +35,4 @@ async def to_code(config: ConfigType) -> None:
await ssd1331_base.setup_ssd1331(var, config)
await spi.register_spi_device(var, config, write_only=True)
dc = await cg.gpio_pin_expression(config[CONF_DC_PIN])
cg.add(var.set_dc_pin(dc))
await cg.add_pin(var.set_dc_pin, config[CONF_DC_PIN])
+1 -3
View File
@@ -33,9 +33,7 @@ async def setup_ssd1351(var: MockObj, config: ConfigType) -> None:
await display.register_display(var, config)
cg.add(var.set_model(config[CONF_MODEL]))
if CONF_RESET_PIN in config:
reset = await cg.gpio_pin_expression(config[CONF_RESET_PIN])
cg.add(var.set_reset_pin(reset))
await cg.add_pin(var.set_reset_pin, config.get(CONF_RESET_PIN))
if CONF_BRIGHTNESS in config:
cg.add(var.init_brightness(config[CONF_BRIGHTNESS]))
await display.add_writer(var, config)
+1 -2
View File
@@ -35,5 +35,4 @@ async def to_code(config: ConfigType) -> None:
await ssd1351_base.setup_ssd1351(var, config)
await spi.register_spi_device(var, config, write_only=True)
dc = await cg.gpio_pin_expression(config[CONF_DC_PIN])
cg.add(var.set_dc_pin(dc))
await cg.add_pin(var.set_dc_pin, config[CONF_DC_PIN])
@@ -27,7 +27,5 @@ async def to_code(config: ConfigType) -> None:
await touchscreen.register_touchscreen(var, config)
await i2c.register_i2c_device(var, config)
if interrupt_pin := config.get(CONF_INTERRUPT_PIN):
cg.add(var.set_interrupt_pin(await cg.gpio_pin_expression(interrupt_pin)))
if reset_pin := config.get(CONF_RESET_PIN):
cg.add(var.set_reset_pin(await cg.gpio_pin_expression(reset_pin)))
await cg.add_pin(var.set_interrupt_pin, config.get(CONF_INTERRUPT_PIN))
await cg.add_pin(var.set_reset_pin, config.get(CONF_RESET_PIN))
+1 -3
View File
@@ -39,9 +39,7 @@ ST7567_SCHEMA = display.FULL_DISPLAY_SCHEMA.extend(
async def setup_st7567(var: MockObj, config: ConfigType) -> None:
await display.register_display(var, config)
if CONF_RESET_PIN in config:
reset = await cg.gpio_pin_expression(config[CONF_RESET_PIN])
cg.add(var.set_reset_pin(reset))
await cg.add_pin(var.set_reset_pin, config.get(CONF_RESET_PIN))
cg.add(var.init_invert_colors(config[CONF_INVERT_COLORS]))
+1 -2
View File
@@ -35,5 +35,4 @@ async def to_code(config: ConfigType) -> None:
await st7567_base.setup_st7567(var, config)
await spi.register_spi_device(var, config, write_only=True)
dc = await cg.gpio_pin_expression(config[CONF_DC_PIN])
cg.add(var.set_dc_pin(dc))
await cg.add_pin(var.set_dc_pin, config[CONF_DC_PIN])
+6 -15
View File
@@ -209,13 +209,8 @@ async def to_code(config: ConfigType) -> None:
data_pin = await cg.gpio_pin_expression(pin)
cg.add(var.add_data_pin(data_pin, index))
if dc_pin := config.get(CONF_DC_PIN):
dc = await cg.gpio_pin_expression(dc_pin)
cg.add(var.set_dc_pin(dc))
if reset_pin := config.get(CONF_RESET_PIN):
reset = await cg.gpio_pin_expression(reset_pin)
cg.add(var.set_reset_pin(reset))
await cg.add_pin(var.set_dc_pin, config.get(CONF_DC_PIN))
await cg.add_pin(var.set_reset_pin, config.get(CONF_RESET_PIN))
if transform := config.get(CONF_TRANSFORM):
cg.add(var.set_mirror_x(transform[CONF_MIRROR_X]))
@@ -236,11 +231,7 @@ async def to_code(config: ConfigType) -> None:
await display.add_writer(var, config)
pin = await cg.gpio_pin_expression(config[CONF_DE_PIN])
cg.add(var.set_de_pin(pin))
pin = await cg.gpio_pin_expression(config[CONF_PCLK_PIN])
cg.add(var.set_pclk_pin(pin))
pin = await cg.gpio_pin_expression(config[CONF_HSYNC_PIN])
cg.add(var.set_hsync_pin(pin))
pin = await cg.gpio_pin_expression(config[CONF_VSYNC_PIN])
cg.add(var.set_vsync_pin(pin))
await cg.add_pin(var.set_de_pin, config[CONF_DE_PIN])
await cg.add_pin(var.set_pclk_pin, config[CONF_PCLK_PIN])
await cg.add_pin(var.set_hsync_pin, config[CONF_HSYNC_PIN])
await cg.add_pin(var.set_vsync_pin, config[CONF_VSYNC_PIN])
@@ -27,11 +27,7 @@ CONFIG_SCHEMA = cv.All(
async def to_code(config: ConfigType) -> None:
var = cg.new_Pvariable(config[CONF_OUTPUT_ID])
if CONF_PIN in config:
pin = await cg.gpio_pin_expression(config[CONF_PIN])
cg.add(var.set_pin(pin))
if CONF_OUTPUT in config:
out = await cg.get_variable(config[CONF_OUTPUT])
cg.add(var.set_output(out))
await cg.add_pin(var.set_pin, config.get(CONF_PIN))
await cg.add_variable(var.set_output, config.get(CONF_OUTPUT))
await cg.register_component(var, config)
await light.register_light(var, config)
+3 -7
View File
@@ -249,13 +249,9 @@ async def to_code(config: ConfigType) -> None:
],
config[CONF_ON_PACKET],
)
if CONF_DIO1_PIN in config:
dio1_pin = await cg.gpio_pin_expression(config[CONF_DIO1_PIN])
cg.add(var.set_dio1_pin(dio1_pin))
rst_pin = await cg.gpio_pin_expression(config[CONF_RST_PIN])
cg.add(var.set_rst_pin(rst_pin))
busy_pin = await cg.gpio_pin_expression(config[CONF_BUSY_PIN])
cg.add(var.set_busy_pin(busy_pin))
await cg.add_pin(var.set_dio1_pin, config.get(CONF_DIO1_PIN))
await cg.add_pin(var.set_rst_pin, config[CONF_RST_PIN])
await cg.add_pin(var.set_busy_pin, config[CONF_BUSY_PIN])
cg.add(var.set_bandwidth(config[CONF_BANDWIDTH]))
cg.add(var.set_frequency(config[CONF_FREQUENCY]))
cg.add(var.set_hw_version(config[CONF_HW_VERSION]))
+2 -5
View File
@@ -232,11 +232,8 @@ async def to_code(config: ConfigType) -> None:
],
config[CONF_ON_PACKET],
)
if CONF_DIO0_PIN in config:
dio0_pin = await cg.gpio_pin_expression(config[CONF_DIO0_PIN])
cg.add(var.set_dio0_pin(dio0_pin))
rst_pin = await cg.gpio_pin_expression(config[CONF_RST_PIN])
cg.add(var.set_rst_pin(rst_pin))
await cg.add_pin(var.set_dio0_pin, config.get(CONF_DIO0_PIN))
await cg.add_pin(var.set_rst_pin, config[CONF_RST_PIN])
cg.add(var.set_auto_cal(config[CONF_AUTO_CAL]))
cg.add(var.set_bandwidth(config[CONF_BANDWIDTH]))
cg.add(var.set_frequency(config[CONF_FREQUENCY]))
+1 -3
View File
@@ -175,6 +175,4 @@ async def to_code(config: ConfigType) -> None:
cg.add(var.set_mixer_mode(config[CONF_MIXER_MODE]))
cg.add(var.set_volume_min_db(config[CONF_VOLUME_MIN_DB]))
cg.add(var.set_volume_max_db(config[CONF_VOLUME_MAX_DB]))
if enable_pin_config := config.get(CONF_ENABLE_PIN):
enable_pin = await cg.gpio_pin_expression(enable_pin_config)
cg.add(var.set_enable_pin(enable_pin))
await cg.add_pin(var.set_enable_pin, config.get(CONF_ENABLE_PIN))
+1 -2
View File
@@ -145,8 +145,7 @@ async def to_code(config: ConfigType) -> None:
array = cg.shared_progmem_array("tca8418_keys", cg.uint8, table)
cg.add(var.set_keys(array, len(table)))
cg.add(var.set_gpi_events(config[CONF_GPI_EVENTS]))
if (interrupt_pin := config.get(CONF_INTERRUPT_PIN)) is not None:
cg.add(var.set_interrupt_pin(await cg.gpio_pin_expression(interrupt_pin)))
await cg.add_pin(var.set_interrupt_pin, config.get(CONF_INTERRUPT_PIN))
for conf in config.get(CONF_ON_KEY, []):
await automation.build_callback_automation(
+4 -9
View File
@@ -38,14 +38,9 @@ async def to_code(config: ConfigType) -> None:
var = cg.new_Pvariable(config[CONF_ID])
await cg.register_component(var, config)
data = await cg.gpio_pin_expression(config[CONF_DATA_PIN])
cg.add(var.set_data_pin(data))
clock = await cg.gpio_pin_expression(config[CONF_CLOCK_PIN])
cg.add(var.set_clock_pin(clock))
lat = await cg.gpio_pin_expression(config[CONF_LAT_PIN])
cg.add(var.set_lat_pin(lat))
if CONF_OE_PIN in config:
outenable = await cg.gpio_pin_expression(config[CONF_OE_PIN])
cg.add(var.set_outenable_pin(outenable))
await cg.add_pin(var.set_data_pin, config[CONF_DATA_PIN])
await cg.add_pin(var.set_clock_pin, config[CONF_CLOCK_PIN])
await cg.add_pin(var.set_lat_pin, config[CONF_LAT_PIN])
await cg.add_pin(var.set_outenable_pin, config.get(CONF_OE_PIN))
cg.add(var.set_num_chips(config[CONF_NUM_CHIPS]))
+2 -4
View File
@@ -28,9 +28,7 @@ async def to_code(config: ConfigType) -> None:
var = cg.new_Pvariable(config[CONF_ID])
await cg.register_component(var, config)
data = await cg.gpio_pin_expression(config[CONF_DATA_PIN])
cg.add(var.set_data_pin(data))
clock = await cg.gpio_pin_expression(config[CONF_CLOCK_PIN])
cg.add(var.set_clock_pin(clock))
await cg.add_pin(var.set_data_pin, config[CONF_DATA_PIN])
await cg.add_pin(var.set_clock_pin, config[CONF_CLOCK_PIN])
cg.add(var.set_num_chips(config[CONF_NUM_CHIPS]))

Some files were not shown because too many files have changed in this diff Show More