def to_code(config): if config[CONF_MODEL] == "M5STACK": lcd_type = ILI9341M5Stack if config[CONF_MODEL] == "TFT_2.4": lcd_type = ILI9341TFT24 rhs = lcd_type.new() var = cg.Pvariable(config[CONF_ID], rhs) yield cg.register_component(var, config) yield display.register_display(var, config) yield spi.register_spi_device(var, config) cg.add(var.set_model(config[CONF_MODEL])) dc = yield cg.gpio_pin_expression(config[CONF_DC_PIN]) cg.add(var.set_dc_pin(dc)) if CONF_LAMBDA in config: lambda_ = yield cg.process_lambda(config[CONF_LAMBDA], [(display.DisplayBufferRef, "it")], return_type=cg.void) cg.add(var.set_writer(lambda_)) if CONF_RESET_PIN in config: reset = yield cg.gpio_pin_expression(config[CONF_RESET_PIN]) cg.add(var.set_reset_pin(reset)) if CONF_LED_PIN in config: led_pin = yield cg.gpio_pin_expression(config[CONF_LED_PIN]) cg.add(var.set_led_pin(led_pin))
def to_code(config): model_type, model = MODELS[config[CONF_MODEL]] if model_type == 'a': rhs = WaveshareEPaperTypeA.new(model) var = cg.Pvariable(config[CONF_ID], rhs, type=WaveshareEPaperTypeA) elif model_type == 'b': rhs = model.new() var = cg.Pvariable(config[CONF_ID], rhs, type=model) else: raise NotImplementedError() yield cg.register_component(var, config) yield display.register_display(var, config) yield spi.register_spi_device(var, config) dc = yield cg.gpio_pin_expression(config[CONF_DC_PIN]) cg.add(var.set_dc_pin(dc)) if CONF_LAMBDA in config: lambda_ = yield cg.process_lambda(config[CONF_LAMBDA], [(display.DisplayBufferRef, 'it')], return_type=cg.void) cg.add(var.set_writer(lambda_)) if CONF_RESET_PIN in config: reset = yield cg.gpio_pin_expression(config[CONF_RESET_PIN]) cg.add(var.set_reset_pin(reset)) if CONF_BUSY_PIN in config: reset = yield cg.gpio_pin_expression(config[CONF_BUSY_PIN]) cg.add(var.set_busy_pin(reset)) if CONF_FULL_UPDATE_EVERY in config: cg.add(var.set_full_update_every(config[CONF_FULL_UPDATE_EVERY]))
def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) yield cg.register_component(var, config) sel = yield cg.gpio_pin_expression(config[CONF_SEL_PIN]) cg.add(var.set_sel_pin(sel)) cf = yield cg.gpio_pin_expression(config[CONF_CF_PIN]) cg.add(var.set_cf_pin(cf)) cf1 = yield cg.gpio_pin_expression(config[CONF_CF1_PIN]) cg.add(var.set_cf1_pin(cf1)) if CONF_VOLTAGE in config: sens = yield sensor.new_sensor(config[CONF_VOLTAGE]) cg.add(var.set_voltage_sensor(sens)) if CONF_CURRENT in config: sens = yield sensor.new_sensor(config[CONF_CURRENT]) cg.add(var.set_current_sensor(sens)) if CONF_POWER in config: sens = yield sensor.new_sensor(config[CONF_POWER]) cg.add(var.set_power_sensor(sens)) if CONF_ENERGY in config: sens = yield sensor.new_sensor(config[CONF_ENERGY]) cg.add(var.set_energy_sensor(sens)) cg.add(var.set_current_resistor(config[CONF_CURRENT_RESISTOR])) cg.add(var.set_voltage_divider(config[CONF_VOLTAGE_DIVIDER])) cg.add(var.set_change_mode_every(config[CONF_CHANGE_MODE_EVERY])) cg.add(var.set_initial_mode(INITIAL_MODES[config[CONF_INITIAL_MODE]]))
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))
def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) yield cg.register_component(var, config) sdo = yield cg.gpio_pin_expression(config[CONF_SDO_PIN]) cg.add(var.set_sdo_pin(sdo)) scl = yield cg.gpio_pin_expression(config[CONF_SCL_PIN]) cg.add(var.set_scl_pin(scl))
def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) yield cg.register_component(var, config) cg.add(var.set_decryption_key(config[CONF_DECRYPTION_KEY])) trigger = yield cg.gpio_pin_expression(config[CONF_TRIGGER_PIN]) cg.add(var.set_trigger_pin(trigger)) rx_pin = yield cg.gpio_pin_expression(config[CONF_RX_PIN]) cg.add(var.set_uart_rx_pin(rx_pin)) tx_pin = yield cg.gpio_pin_expression(config[CONF_TX_PIN]) cg.add(var.set_uart_tx_pin(tx_pin)) if CONF_INVERT_SERIAL in config: cg.add(var.set_uart_inverted(config[CONF_INVERT_SERIAL])) builtin_led_pin = yield cg.gpio_pin_expression( config[CONF_BUILTIN_LED_GPIO]) cg.add(var.set_builtin_led_pin(builtin_led_pin)) if CONF_NTP_SERVER in config: cg.add(var.set_ntp_server(config[CONF_NTP_SERVER])) if CONF_NTP_GMT_OFFSET in config: cg.add(var.set_ntp_gmt_offset(config[CONF_NTP_GMT_OFFSET])) if CONF_NTP_DAYLIGHT_OFFSET in config: cg.add(var.set_ntp_daylight_offset(config[CONF_NTP_DAYLIGHT_OFFSET])) if CONF_DELAY_BEFORE_READING_DATA in config: cg.add( var.set_delay_before_reading_data( config[CONF_DELAY_BEFORE_READING_DATA])) if CONF_MAX_WAIT_TIME_FOR_READING_DATA in config: cg.add( var.set_max_wait_time_for_reading_data( config[CONF_MAX_WAIT_TIME_FOR_READING_DATA])) if CONF_TEST_DATA in config: cg.add(var.set_test_data(config[CONF_TEST_DATA])) if CONF_COUNTER_READING_P_IN in config: sens = yield sensor.new_sensor(config[CONF_COUNTER_READING_P_IN]) cg.add(var.set_counter_reading_p_in(sens)) if CONF_COUNTER_READING_P_OUT in config: sens = yield sensor.new_sensor(config[CONF_COUNTER_READING_P_OUT]) cg.add(var.set_counter_reading_p_out(sens)) if CONF_COUNTER_READING_Q_IN in config: sens = yield sensor.new_sensor(config[CONF_COUNTER_READING_Q_IN]) cg.add(var.set_counter_reading_q_in(sens)) if CONF_COUNTER_READING_Q_OUT in config: sens = yield sensor.new_sensor(config[CONF_COUNTER_READING_Q_OUT]) cg.add(var.set_counter_reading_q_out(sens)) if CONF_POWER_USAGE_IN in config: sens = yield sensor.new_sensor(config[CONF_POWER_USAGE_IN]) cg.add(var.set_current_power_usage_in(sens)) if CONF_POWER_USAGE_OUT in config: sens = yield sensor.new_sensor(config[CONF_POWER_USAGE_OUT]) cg.add(var.set_current_power_usage_out(sens))
def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) yield cg.register_component(var, config) yield sensor.register_sensor(var, config) dout_pin = yield cg.gpio_pin_expression(config[CONF_DOUT_PIN]) cg.add(var.set_dout_pin(dout_pin)) sck_pin = yield cg.gpio_pin_expression(config[CONF_CLK_PIN]) cg.add(var.set_sck_pin(sck_pin)) cg.add(var.set_gain(config[CONF_GAIN]))
def to_code(config): cg.add_define('USE_DALI') cg.add_global(dali_ns.using) tx_pin = yield cg.gpio_pin_expression(config[CONF_TX_PIN]) rx_pin = yield cg.gpio_pin_expression(config[CONF_RX_PIN]) var = cg.new_Pvariable(config[CONF_ID]) yield cg.register_component(var, config) cg.add(var.set_tx_pin(tx_pin)) cg.add(var.set_rx_pin(rx_pin)) cg.add(var.set_frequency(int(config[CONF_FREQUENCY])))
def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) yield cg.register_component(var, config) yield text_sensor.register_text_sensor(var, config) top_pin = yield cg.gpio_pin_expression(config[CONF_TOP_PIN]) cg.add(var.set_top_pin(top_pin)) bottom_pin = yield cg.gpio_pin_expression(config[CONF_BOTTOM_PIN]) cg.add(var.set_bottom_pin(bottom_pin)) cg.add(var.set_debounce_duration(config[CONF_DEBOUNCE]))
def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) yield cg.register_component(var, config) clk_pin = yield cg.gpio_pin_expression(config[CONF_CLK_PIN]) cg.add(var.set_clk_pin(clk_pin)) dio_pin = yield cg.gpio_pin_expression(config[CONF_DIO_PIN]) cg.add(var.set_dio_pin(dio_pin)) # https://platformio.org/lib/show/6865/TM1651 cg.add_library('6865', '1.0.0')
def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) yield cg.register_component(var, config) data_pin = yield cg.gpio_pin_expression(config[CONF_DATA_PIN]) cg.add(var.set_data_pin(data_pin)) clock_pin = yield cg.gpio_pin_expression(config[CONF_CLOCK_PIN]) cg.add(var.set_clock_pin(clock_pin)) latch_pin = yield cg.gpio_pin_expression(config[CONF_LATCH_PIN]) cg.add(var.set_latch_pin(latch_pin)) oe_pin = yield cg.gpio_pin_expression(config[CONF_OE_PIN]) cg.add(var.set_oe_pin(oe_pin)) cg.add(var.set_sr_count(config[CONF_SR_COUNT]))
def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) yield cg.register_component(var, config) yield sensor.register_sensor(var, config) trigger = yield cg.gpio_pin_expression(config[CONF_TRIGGER_PIN]) cg.add(var.set_trigger_pin(trigger)) echo = yield cg.gpio_pin_expression(config[CONF_ECHO_PIN]) cg.add(var.set_echo_pin(echo)) cg.add(var.set_timeout_us(config[CONF_TIMEOUT] / (0.000343 / 2))) cg.add(var.set_pulse_time_us(config[CONF_PULSE_TIME]))
def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) yield cg.register_component(var, config) if CONF_NUM_CHIPS in config: cg.add(var.set_count(config[CONF_NUM_CHIPS])) pin = yield cg.gpio_pin_expression(config[CONF_DATA_PIN]) cg.add(var.set_data_pin(pin)) pin = yield cg.gpio_pin_expression(config[CONF_CLOCK_PIN]) cg.add(var.set_clock_pin(pin)) if CONF_LATCH_PIN in config: pin = yield cg.gpio_pin_expression(config[CONF_LATCH_PIN]) cg.add(var.set_latch_pin(pin))
def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) yield cg.register_component(var, config) di = yield cg.gpio_pin_expression(config[CONF_DATA_PIN]) cg.add(var.set_pin_di(di)) dcki = yield cg.gpio_pin_expression(config[CONF_CLOCK_PIN]) cg.add(var.set_pin_dcki(dcki)) cg.add(var.set_num_channels(config[CONF_NUM_CHANNELS])) cg.add(var.set_num_chips(config[CONF_NUM_CHIPS])) cg.add(var.set_bit_depth(config[CONF_BIT_DEPTH]))
def to_code(config): cg.add_global(spi_ns.using) var = cg.new_Pvariable(config[CONF_ID]) yield cg.register_component(var, config) clk = yield cg.gpio_pin_expression(config[CONF_CLK_PIN]) cg.add(var.set_clk(clk)) if CONF_MISO_PIN in config: miso = yield cg.gpio_pin_expression(config[CONF_MISO_PIN]) cg.add(var.set_miso(miso)) if CONF_MOSI_PIN in config: mosi = yield cg.gpio_pin_expression(config[CONF_MOSI_PIN]) cg.add(var.set_mosi(mosi))
def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) yield cg.register_component(var, config) yield stepper.register_stepper(var, config) step_pin = yield cg.gpio_pin_expression(config[CONF_STEP_PIN]) cg.add(var.set_step_pin(step_pin)) dir_pin = yield cg.gpio_pin_expression(config[CONF_DIR_PIN]) cg.add(var.set_dir_pin(dir_pin)) if CONF_SLEEP_PIN in config: sleep_pin = yield cg.gpio_pin_expression(config[CONF_SLEEP_PIN]) cg.add(var.set_sleep_pin(sleep_pin))
def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) yield cg.register_component(var, config) # override default min power to 10% if CONF_MIN_POWER not in config: config[CONF_MIN_POWER] = 0.1 yield output.register_output(var, config) pin = yield cg.gpio_pin_expression(config[CONF_GATE_PIN]) cg.add(var.set_gate_pin(pin)) pin = yield cg.gpio_pin_expression(config[CONF_ZERO_CROSS_PIN]) cg.add(var.set_zero_cross_pin(pin)) cg.add(var.set_init_with_half_cycle(config[CONF_INIT_WITH_HALF_CYCLE])) cg.add(var.set_method(config[CONF_METHOD]))
def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) yield cg.register_component(var, config) if CONF_IRQ_PIN in config: irq_pin = yield cg.gpio_pin_expression(config[CONF_IRQ_PIN]) cg.add(var.set_irq_pin(irq_pin)) yield i2c.register_i2c_device(var, config)
def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) yield ssd1327_base.setup_ssd1327(var, config) yield spi.register_spi_device(var, config) dc = yield cg.gpio_pin_expression(config[CONF_DC_PIN]) cg.add(var.set_dc_pin(dc))
def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) yield lcd_base.setup_lcd_display(var, config) pins_ = [] for conf in config[CONF_DATA_PINS]: pins_.append((yield cg.gpio_pin_expression(conf))) cg.add(var.set_data_pins(*pins_)) enable = yield cg.gpio_pin_expression(config[CONF_ENABLE_PIN]) cg.add(var.set_enable_pin(enable)) rs = yield cg.gpio_pin_expression(config[CONF_RS_PIN]) cg.add(var.set_rs_pin(rs)) if CONF_RW_PIN in config: rw = yield cg.gpio_pin_expression(config[CONF_RW_PIN]) cg.add(var.set_rw_pin(rw))
def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) yield cg.register_component(var, config) yield sensor.register_sensor(var, config) pin = yield cg.gpio_pin_expression(config[CONF_PIN]) cg.add(var.set_pin(pin))
def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) yield cg.register_component(var, config) pins = [] for conf in config[CONF_ROWS]: pin = yield cg.gpio_pin_expression(conf[CONF_PIN]) pins.append(pin) cg.add(var.set_rows(pins)) pins = [] for conf in config[CONF_COLUMNS]: pin = yield cg.gpio_pin_expression(conf[CONF_PIN]) pins.append(pin) cg.add(var.set_columns(pins)) if CONF_KEYS in config: cg.add(var.set_keys(config[CONF_KEYS])) cg.add(var.set_debounce_time(config[CONF_DEBOUNCE_TIME]))
def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) yield cg.register_component(var, config) if CONF_SLEEP_DURATION in config: cg.add(var.set_sleep_duration(config[CONF_SLEEP_DURATION])) if CONF_WAKEUP_PIN in config: pin = yield cg.gpio_pin_expression(config[CONF_WAKEUP_PIN]) cg.add(var.set_wakeup_pin(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: cg.add(var.set_run_duration(config[CONF_RUN_DURATION])) if CONF_ESP32_EXT1_WAKEUP in config: conf = config[CONF_ESP32_EXT1_WAKEUP] mask = 0 for pin in conf[CONF_PINS]: mask |= 1 << pin[CONF_NUMBER] struct = cg.StructInitializer( Ext1Wakeup, ("mask", mask), ("wakeup_mode", conf[CONF_MODE]) ) cg.add(var.set_ext1_wakeup(struct)) cg.add_define("USE_DEEP_SLEEP")
def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) yield cg.register_component(var, config) yield stepper.register_stepper(var, config) pin_a = yield cg.gpio_pin_expression(config[CONF_PIN_A]) cg.add(var.set_pin_a(pin_a)) pin_b = yield cg.gpio_pin_expression(config[CONF_PIN_B]) cg.add(var.set_pin_b(pin_b)) pin_c = yield cg.gpio_pin_expression(config[CONF_PIN_C]) cg.add(var.set_pin_c(pin_c)) pin_d = yield cg.gpio_pin_expression(config[CONF_PIN_D]) cg.add(var.set_pin_d(pin_d)) cg.add(var.set_sleep_when_done(config[CONF_SLEEP_WHEN_DONE])) cg.add(var.set_step_mode(config[CONF_STEP_MODE]))
def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) yield cg.register_component(var, config) yield display.register_display(var, config) clk = yield cg.gpio_pin_expression(config[CONF_CLK_PIN]) cg.add(var.set_clk_pin(clk)) dio = yield cg.gpio_pin_expression(config[CONF_DIO_PIN]) cg.add(var.set_dio_pin(dio)) cg.add(var.set_intensity(config[CONF_INTENSITY])) if CONF_LAMBDA in config: lambda_ = yield cg.process_lambda(config[CONF_LAMBDA], [(TM1637DisplayRef, 'it')], return_type=cg.void) cg.add(var.set_writer(lambda_))
def to_code(config): pin = yield cg.gpio_pin_expression(config[CONF_PIN]) rhs = StatusLED.new(pin) var = cg.Pvariable(config[CONF_ID], rhs) yield cg.register_component(var, config) cg.add(var.pre_setup()) cg.add_define('USE_STATUS_LED')
def to_code(config): gpio = yield cg.gpio_pin_expression(config[CONF_PIN]) var = cg.new_Pvariable(config[CONF_ID], gpio) yield cg.register_component(var, config) yield output.register_output(var, config) if CONF_CHANNEL in config: cg.add(var.set_channel(config[CONF_CHANNEL])) cg.add(var.set_frequency(config[CONF_FREQUENCY]))
def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) yield cg.register_component(var, config) yield sensor.register_sensor(var, config) pin_a = yield cg.gpio_pin_expression(config[CONF_PIN_A]) cg.add(var.set_pin_a(pin_a)) pin_b = yield cg.gpio_pin_expression(config[CONF_PIN_B]) cg.add(var.set_pin_b(pin_b)) if CONF_PIN_RESET in config: pin_i = yield cg.gpio_pin_expression(config[CONF_PIN_RESET]) cg.add(var.set_reset_pin(pin_i)) cg.add(var.set_resolution(config[CONF_RESOLUTION])) if CONF_MIN_VALUE in config: cg.add(var.set_min_value(config[CONF_MIN_VALUE])) if CONF_MAX_VALUE in config: cg.add(var.set_max_value(config[CONF_MAX_VALUE]))
def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) yield cg.register_component(var, config) yield display.register_display(var, config) yield spi.register_spi_device(var, config) dc = yield cg.gpio_pin_expression(config[CONF_DC_PIN]) cg.add(var.set_dc_pin(dc)) reset = yield cg.gpio_pin_expression(config[CONF_RESET_PIN]) cg.add(var.set_reset_pin(reset)) if CONF_LAMBDA in config: lambda_ = yield cg.process_lambda(config[CONF_LAMBDA], [(display.DisplayBufferRef, 'it')], return_type=cg.void) cg.add(var.set_writer(lambda_))
def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) yield cg.register_component(var, config) pin = yield cg.gpio_pin_expression(config[CONF_PIN]) cg.add(var.set_pin(pin)) cg.add(var.set_debounce(config[CONF_DEBOUNCE]))