Skip to content

Commit

Permalink
Align ADC init with WLED-SR
Browse files Browse the repository at this point in the history
Feedback from SR is "it works better with analog", so let's align the driver code as much as possible.
  • Loading branch information
softhack007 authored Sep 23, 2023
1 parent 015ce11 commit 0ba8402
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions usermods/audioreactive/audio_source.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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));
Expand Down Expand Up @@ -839,4 +839,4 @@ class SPH0654 : public I2SSource {
#endif
}
};
#endif
#endif

0 comments on commit 0ba8402

Please sign in to comment.