From 90b3f009af0aac20c12f66a606fb6ea6c7260102 Mon Sep 17 00:00:00 2001 From: Frank <91616163+softhack007@users.noreply.github.com> Date: Mon, 19 Sep 2022 13:30:13 +0200 Subject: [PATCH] AR: small improvement for ADC analog mics ensure that ADC parameters are properly configured. --- usermods/audioreactive/audio_source.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/usermods/audioreactive/audio_source.h b/usermods/audioreactive/audio_source.h index c58d1991..c76b2bb0 100644 --- a/usermods/audioreactive/audio_source.h +++ b/usermods/audioreactive/audio_source.h @@ -444,13 +444,17 @@ class I2SAdcSource : public I2SSource { return; } + adc1_config_width(ADC_WIDTH_BIT_12); // ensure that ADC runs with 12bit resolution + // Enable I2S mode of ADC err = i2s_set_adc_mode(ADC_UNIT_1, adc1_channel_t(channel)); if (err != ESP_OK) { DEBUGSR_PRINTF("Failed to set i2s adc mode: %d\n", err); return; } - // adc1_config_channel_atten(adc1_channel_t(channel), ADC_ATTEN_DB_11)); //see https://github.com/espressif/arduino-esp32/blob/master/libraries/ESP32/examples/I2S/HiFreq_ADC/HiFreq_ADC.ino + + // see example in https://github.com/espressif/arduino-esp32/blob/master/libraries/ESP32/examples/I2S/HiFreq_ADC/HiFreq_ADC.ino + adc1_config_channel_atten(adc1_channel_t(channel), ADC_ATTEN_DB_11); // configure ADC input amplification #if defined(I2S_GRAB_ADC1_COMPLETELY) // according to docs from espressif, the ADC needs to be started explicitly