mirror of
https://github.com/esphome/esphome.git
synced 2024-11-28 17:54:13 +01:00
Make i2s_audio bclk_pin optional (#4801)
This commit is contained in:
parent
5099595aee
commit
8822b6c808
2 changed files with 10 additions and 6 deletions
|
@ -42,8 +42,8 @@ I2S_PORTS = {
|
||||||
CONFIG_SCHEMA = cv.Schema(
|
CONFIG_SCHEMA = cv.Schema(
|
||||||
{
|
{
|
||||||
cv.GenerateID(): cv.declare_id(I2SAudioComponent),
|
cv.GenerateID(): cv.declare_id(I2SAudioComponent),
|
||||||
cv.Required(CONF_I2S_BCLK_PIN): pins.internal_gpio_output_pin_number,
|
|
||||||
cv.Required(CONF_I2S_LRCLK_PIN): pins.internal_gpio_output_pin_number,
|
cv.Required(CONF_I2S_LRCLK_PIN): pins.internal_gpio_output_pin_number,
|
||||||
|
cv.Optional(CONF_I2S_BCLK_PIN): pins.internal_gpio_output_pin_number,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -66,5 +66,6 @@ async def to_code(config):
|
||||||
var = cg.new_Pvariable(config[CONF_ID])
|
var = cg.new_Pvariable(config[CONF_ID])
|
||||||
await cg.register_component(var, config)
|
await cg.register_component(var, config)
|
||||||
|
|
||||||
cg.add(var.set_bclk_pin(config[CONF_I2S_BCLK_PIN]))
|
|
||||||
cg.add(var.set_lrclk_pin(config[CONF_I2S_LRCLK_PIN]))
|
cg.add(var.set_lrclk_pin(config[CONF_I2S_LRCLK_PIN]))
|
||||||
|
if CONF_I2S_BCLK_PIN in config:
|
||||||
|
cg.add(var.set_bclk_pin(config[CONF_I2S_BCLK_PIN]))
|
||||||
|
|
|
@ -29,8 +29,8 @@ class I2SAudioComponent : public Component {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_bclk_pin(uint8_t pin) { this->bclk_pin_ = pin; }
|
void set_bclk_pin(int pin) { this->bclk_pin_ = pin; }
|
||||||
void set_lrclk_pin(uint8_t pin) { this->lrclk_pin_ = pin; }
|
void set_lrclk_pin(int pin) { this->lrclk_pin_ = pin; }
|
||||||
|
|
||||||
void lock() { this->lock_.lock(); }
|
void lock() { this->lock_.lock(); }
|
||||||
bool try_lock() { return this->lock_.try_lock(); }
|
bool try_lock() { return this->lock_.try_lock(); }
|
||||||
|
@ -41,8 +41,11 @@ class I2SAudioComponent : public Component {
|
||||||
protected:
|
protected:
|
||||||
Mutex lock_;
|
Mutex lock_;
|
||||||
|
|
||||||
uint8_t bclk_pin_;
|
I2SAudioIn *audio_in_{nullptr};
|
||||||
uint8_t lrclk_pin_;
|
I2SAudioOut *audio_out_{nullptr};
|
||||||
|
|
||||||
|
int bclk_pin_{I2S_PIN_NO_CHANGE};
|
||||||
|
int lrclk_pin_;
|
||||||
i2s_port_t port_{};
|
i2s_port_t port_{};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue