This commit is contained in:
Daniël Koek 2024-03-26 16:28:00 +00:00
parent 49e4bdd9bf
commit d2ba9e9a07
2 changed files with 14 additions and 19 deletions

View file

@ -54,13 +54,13 @@ async def to_code(config):
await cg.register_component(var, config)
await uart.register_uart_device(var, config)
p = await cg.gpio_pin_expression(config[CONF_PIN_AUX])
cg.add(var.set_pin_aux(p))
pin_aux = await cg.gpio_pin_expression(config[CONF_PIN_AUX])
cg.add(var.set_pin_aux(pin_aux))
p = await cg.gpio_pin_expression(config[CONF_PIN_M0])
cg.add(var.set_pin_m0(p))
p = await cg.gpio_pin_expression(config[CONF_PIN_M1])
cg.add(var.set_pin_m1(p))
pin_m0 = await cg.gpio_pin_expression(config[CONF_PIN_M0])
cg.add(var.set_pin_m0(pin_m0))
pin_m1 = await cg.gpio_pin_expression(config[CONF_PIN_M1])
cg.add(var.set_pin_m1(pin_m1))
if CONF_LORA_MESSAGE in config:
sens = await text_sensor.new_text_sensor(config[CONF_LORA_MESSAGE])

View file

@ -33,18 +33,13 @@ class Lora : public PollingComponent, public uart::UARTDevice {
void update() override;
void loop() override;
void dump_config() override;
// local
/// Helper function to read the value of a pin.
bool digital_read(uint8_t pin);
/// Helper function to write the value of a pin.
void digital_write(uint8_t pin, bool value);
/// Helper function to set the pin mode of a pin.
void pin_mode(uint8_t pin, gpio::Flags flags);
void set_message_sensor(text_sensor::TextSensor *s) { message_text_sensor_ = s; }
void set_rssi_sensor(sensor::Sensor *s) { rssi_sensor_ = s; }
void set_pin_aux(GPIOPin *s) { pin_aux_ = s; }
void set_pin_m0(GPIOPin *s) { pin_m0_ = s; }
void set_pin_m1(GPIOPin *s) { pin_m1_ = s; }
void set_message_sensor(text_sensor::TextSensor *message_text_sensor) { message_text_sensor_ = message_text_sensor; }
void set_rssi_sensor(sensor::Sensor *rssi_sensor) { rssi_sensor_ = rssi_sensor; }
void set_pin_aux(GPIOPin *pin_aux) { pin_aux_ = pin_aux; }
void set_pin_m0(GPIOPin *pin_m0) { pin_m0_ = pin_m0; }
void set_pin_m1(GPIOPin *pin_m1) { pin_m1_ = pin_m1; }
private:
ModeType mode_ = MODE_INIT;
@ -66,9 +61,9 @@ class Lora : public PollingComponent, public uart::UARTDevice {
std::string raw_message_;
text_sensor::TextSensor *message_text_sensor_{nullptr};
sensor::Sensor *rssi_sensor_{nullptr};
GPIOPin *pin_aux_{nullptr};
GPIOPin *pin_m0_{nullptr};
GPIOPin *pin_m1_{nullptr};
GPIOPin *pin_aux_;
GPIOPin *pin_m0_;
GPIOPin *pin_m1_;
};
} // namespace lora