mirror of
https://github.com/esphome/esphome.git
synced 2025-03-14 06:38:17 +00:00
Fix tests
This commit is contained in:
parent
be0f033541
commit
8b7d1bfada
@ -170,7 +170,6 @@ def i2s_audio_component_schema(
|
||||
async def register_i2s_audio_component(var, config):
|
||||
await cg.register_parented(var, config[CONF_I2S_AUDIO_ID])
|
||||
if use_legacy():
|
||||
print("Use legacy")
|
||||
cg.add(var.set_i2s_mode(I2S_MODE_OPTIONS[config[CONF_I2S_MODE]]))
|
||||
cg.add(var.set_channel(I2S_CHANNELS[config[CONF_CHANNEL]]))
|
||||
cg.add(
|
||||
@ -181,7 +180,6 @@ async def register_i2s_audio_component(var, config):
|
||||
I2S_BITS_PER_CHANNEL[config[CONF_BITS_PER_CHANNEL]]
|
||||
)
|
||||
)
|
||||
cg.add(var.set_use_apll(config[CONF_USE_APLL]))
|
||||
else:
|
||||
cg.add(var.set_i2s_role(I2S_ROLE_OPTIONS[config[CONF_I2S_MODE]]))
|
||||
slot_mode = config[CONF_CHANNEL]
|
||||
@ -196,9 +194,8 @@ async def register_i2s_audio_component(var, config):
|
||||
cg.add(
|
||||
var.set_slot_bit_width(I2S_SLOT_BIT_WIDTH[config[CONF_BITS_PER_CHANNEL]])
|
||||
)
|
||||
# cg.add(var.set_use_apll(config[CONF_USE_APLL]))
|
||||
cg.add_define("USE_I2S_APLL")
|
||||
cg.add(var.set_sample_rate(config[CONF_SAMPLE_RATE]))
|
||||
cg.add(var.set_use_apll(config[CONF_USE_APLL]))
|
||||
|
||||
|
||||
def validate_use_legacy(value):
|
||||
|
@ -127,7 +127,7 @@ void I2SAudioMicrophone::start_() {
|
||||
.auto_clear = false,
|
||||
};
|
||||
/* Allocate a new RX channel and get the handle of this channel */
|
||||
err = i2s_new_channel(&chan_cfg, NULL, &this->rx_handle);
|
||||
err = i2s_new_channel(&chan_cfg, NULL, &this->rx_handle_);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGW(TAG, "Error creating new I2S channel: %s", esp_err_to_name(err));
|
||||
this->status_set_error();
|
||||
@ -137,10 +137,11 @@ void I2SAudioMicrophone::start_() {
|
||||
/* Setting the configurations, the slot configuration and clock configuration can be generated by the macros
|
||||
* These two helper macros are defined in 'i2s_std.h' which can only be used in STD mode.
|
||||
* They can help to specify the slot and clock configurations for initialization or updating */
|
||||
#ifdef USE_I2S_APLL
|
||||
i2s_clock_src_t clk_src = I2S_CLK_SRC_APLL;
|
||||
#else
|
||||
i2s_clock_src_t clk_src = I2S_CLK_SRC_DEFAULT;
|
||||
#ifdef I2S_CLK_SRC_APLL
|
||||
if (this->use_apll_) {
|
||||
clk_src = I2S_CLK_SRC_APLL;
|
||||
}
|
||||
#endif
|
||||
i2s_std_clk_config_t clk_cfg = {
|
||||
.sample_rate_hz = this->sample_rate_,
|
||||
@ -160,7 +161,7 @@ void I2SAudioMicrophone::start_() {
|
||||
.gpio_cfg = pin_config,
|
||||
};
|
||||
/* Initialize the channel */
|
||||
err = i2s_channel_init_std_mode(this->rx_handle, &std_cfg);
|
||||
err = i2s_channel_init_std_mode(this->rx_handle_, &std_cfg);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGW(TAG, "Error initializing I2S channel: %s", esp_err_to_name(err));
|
||||
this->status_set_error();
|
||||
@ -168,7 +169,7 @@ void I2SAudioMicrophone::start_() {
|
||||
}
|
||||
|
||||
/* Before reading data, start the RX channel first */
|
||||
i2s_channel_enable(this->rx_handle);
|
||||
i2s_channel_enable(this->rx_handle_);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGW(TAG, "Error enabling I2S Microphone: %s", esp_err_to_name(err));
|
||||
this->status_set_error();
|
||||
@ -218,14 +219,14 @@ void I2SAudioMicrophone::stop_() {
|
||||
}
|
||||
#else
|
||||
/* Have to stop the channel before deleting it */
|
||||
err = i2s_channel_disable(this->rx_handle);
|
||||
err = i2s_channel_disable(this->rx_handle_);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGW(TAG, "Error stopping I2S microphone: %s", esp_err_to_name(err));
|
||||
this->status_set_error();
|
||||
return;
|
||||
}
|
||||
/* If the handle is not needed any more, delete it to release the channel resources */
|
||||
err = i2s_del_channel(this->rx_handle);
|
||||
err = i2s_del_channel(this->rx_handle_);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGW(TAG, "Error deleting I2S channel: %s", esp_err_to_name(err));
|
||||
this->status_set_error();
|
||||
@ -243,7 +244,7 @@ size_t I2SAudioMicrophone::read(int16_t *buf, size_t len) {
|
||||
#ifdef USE_I2S_LEGACY
|
||||
esp_err_t err = i2s_read(this->parent_->get_port(), buf, len, &bytes_read, (100 / portTICK_PERIOD_MS));
|
||||
#else
|
||||
esp_err_t err = i2s_channel_read(this->rx_handle, buf, len, &bytes_read, (100 / portTICK_PERIOD_MS));
|
||||
esp_err_t err = i2s_channel_read(this->rx_handle_, buf, len, &bytes_read, (100 / portTICK_PERIOD_MS));
|
||||
#endif
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGW(TAG, "Error reading from I2S microphone: %s", esp_err_to_name(err));
|
||||
|
@ -49,7 +49,7 @@ class I2SAudioMicrophone : public I2SAudioIn, public microphone::Microphone, pub
|
||||
#endif
|
||||
#else
|
||||
gpio_num_t din_pin_{I2S_GPIO_UNUSED};
|
||||
i2s_chan_handle_t rx_handle;
|
||||
i2s_chan_handle_t rx_handle_;
|
||||
#endif
|
||||
bool pdm_{false};
|
||||
|
||||
|
@ -94,6 +94,7 @@
|
||||
#ifdef USE_ARDUINO
|
||||
#define USE_PROMETHEUS
|
||||
#define USE_WIFI_WPA2_EAP
|
||||
#define USE_I2S_LEGACY
|
||||
#endif
|
||||
|
||||
// IDF-specific feature flags
|
||||
|
@ -1,6 +1,7 @@
|
||||
i2s_audio:
|
||||
i2s_lrclk_pin: GPIO18
|
||||
i2s_bclk_pin: GPIO19
|
||||
use_legacy: true
|
||||
|
||||
microphone:
|
||||
- platform: i2s_audio
|
||||
|
@ -4,9 +4,18 @@ substitutions:
|
||||
i2s_mclk_pin: GPIO17
|
||||
i2s_din_pin: GPIO33
|
||||
|
||||
<<: !include common.yaml
|
||||
i2s_audio:
|
||||
i2s_bclk_pin: ${i2s_bclk_pin}
|
||||
i2s_lrclk_pin: ${i2s_lrclk_pin}
|
||||
i2s_mclk_pin: ${i2s_mclk_pin}
|
||||
use_legacy: true
|
||||
|
||||
microphone:
|
||||
- platform: i2s_audio
|
||||
id: mic_id_external
|
||||
i2s_din_pin: ${i2s_din_pin}
|
||||
adc_type: external
|
||||
pdm: false
|
||||
- platform: i2s_audio
|
||||
id: mic_id_adc
|
||||
adc_pin: 32
|
||||
|
@ -10,6 +10,7 @@ i2s_audio:
|
||||
i2s_lrclk_pin: ${lrclk_pin}
|
||||
i2s_bclk_pin: ${bclk_pin}
|
||||
i2s_mclk_pin: ${mclk_pin}
|
||||
use_legacy: true
|
||||
|
||||
speaker:
|
||||
- platform: i2s_audio
|
||||
|
@ -2,6 +2,7 @@ i2s_audio:
|
||||
i2s_lrclk_pin: ${lrclk_pin}
|
||||
i2s_bclk_pin: ${bclk_pin}
|
||||
i2s_mclk_pin: ${mclk_pin}
|
||||
use_legacy: true
|
||||
|
||||
speaker:
|
||||
- platform: i2s_audio
|
||||
|
@ -23,6 +23,7 @@ i2s_audio:
|
||||
i2s_lrclk_pin: ${i2s_bclk_pin}
|
||||
i2s_bclk_pin: ${i2s_lrclk_pin}
|
||||
i2s_mclk_pin: ${i2s_mclk_pin}
|
||||
use_legacy: true
|
||||
|
||||
audio_dac:
|
||||
- platform: aic3204
|
||||
|
@ -18,6 +18,7 @@ i2s_audio:
|
||||
i2s_lrclk_pin: ${i2s_bclk_pin}
|
||||
i2s_bclk_pin: ${i2s_lrclk_pin}
|
||||
i2s_mclk_pin: ${i2s_mclk_pin}
|
||||
use_legacy: true
|
||||
|
||||
speaker:
|
||||
- platform: i2s_audio
|
||||
|
@ -15,6 +15,7 @@ i2s_audio:
|
||||
i2s_lrclk_pin: ${i2s_lrclk_pin}
|
||||
i2s_bclk_pin: ${i2s_bclk_pin}
|
||||
i2s_mclk_pin: ${i2s_mclk_pin}
|
||||
use_legacy: true
|
||||
|
||||
microphone:
|
||||
- platform: i2s_audio
|
||||
|
Loading…
x
Reference in New Issue
Block a user