From 0ba8402e72eacc6788a7363846bf00ff03bf3285 Mon Sep 17 00:00:00 2001 From: Frank <91616163+softhack007@users.noreply.github.com> Date: Sat, 23 Sep 2023 22:49:09 +0200 Subject: [PATCH] Align ADC init with WLED-SR Feedback from SR is "it works better with analog", so let's align the driver code as much as possible. --- usermods/audioreactive/audio_source.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/usermods/audioreactive/audio_source.h b/usermods/audioreactive/audio_source.h index 8aa7c44d68..9ca3e0c22c 100644 --- a/usermods/audioreactive/audio_source.h +++ b/usermods/audioreactive/audio_source.h @@ -666,7 +666,7 @@ class I2SAdcSource : public I2SSource { // Determine Analog channel. Only Channels on ADC1 are supported int8_t channel = digitalPinToAnalogChannel(_audioPin); - if (channel > 9) { + if ((channel < 0) || (channel > 9)) { // channel == -1 means "not an ADC pin" USER_PRINTF("AR: Incompatible GPIO used for analog audio input: %d\n", _audioPin); return; } else { @@ -681,7 +681,7 @@ class I2SAdcSource : public I2SSource { return; } - adc1_config_width(ADC_WIDTH_BIT_12); // ensure that ADC runs with 12bit resolution + // adc1_config_width(ADC_WIDTH_BIT_12); // ensure that ADC runs with 12bit resolution - should not be needed, because i2s_set_adc_mode does that any way // Enable I2S mode of ADC err = i2s_set_adc_mode(ADC_UNIT_1, adc1_channel_t(channel)); @@ -839,4 +839,4 @@ class SPH0654 : public I2SSource { #endif } }; -#endif \ No newline at end of file +#endif