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.
This commit is contained in:
Frank
2023-09-23 22:49:09 +02:00
committed by GitHub
parent 015ce11b72
commit 0ba8402e72

View File

@@ -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
#endif