If MCU does not support analog, hide analog PIN settings
- hide "Analog Mic PIN" setting if I2S-ADC is not supported by the hardware - In case of usupported config (PDM or ADC), overwrite dmType with default.
This commit is contained in:
@@ -631,6 +631,7 @@ class AudioReactive : public Usermod {
|
|||||||
#endif
|
#endif
|
||||||
#ifndef SR_DMTYPE // I2S mic type
|
#ifndef SR_DMTYPE // I2S mic type
|
||||||
uint8_t dmType = 1; // 0=none/disabled/analog; 1=generic I2S
|
uint8_t dmType = 1; // 0=none/disabled/analog; 1=generic I2S
|
||||||
|
#define SR_DMTYPE 1 // default type = I2S
|
||||||
#else
|
#else
|
||||||
uint8_t dmType = SR_DMTYPE;
|
uint8_t dmType = SR_DMTYPE;
|
||||||
#endif
|
#endif
|
||||||
@@ -1241,7 +1242,7 @@ class AudioReactive : public Usermod {
|
|||||||
DEBUGSR_PRINT(F("AR: Generic I2S Microphone with Master Clock - ")); DEBUGSR_PRINTLN(F(I2S_MIC_CHANNEL_TEXT));
|
DEBUGSR_PRINT(F("AR: Generic I2S Microphone with Master Clock - ")); DEBUGSR_PRINTLN(F(I2S_MIC_CHANNEL_TEXT));
|
||||||
//useBandPassFilter = true;
|
//useBandPassFilter = true;
|
||||||
audioSource = new I2SSource(SAMPLE_RATE, BLOCK_SIZE, 1.0f/24.0f);
|
audioSource = new I2SSource(SAMPLE_RATE, BLOCK_SIZE, 1.0f/24.0f);
|
||||||
//audioSource = new I2SSource(SAMPLE_RATE, BLOCK_SIZE, false, 1.0f/16.0f); // I2S SLAVE mode - does not work, unfortunately
|
//audioSource = new I2SSource(SAMPLE_RATE, BLOCK_SIZE, 1.0f/24.0f, false); // I2S SLAVE mode - does not work, unfortunately
|
||||||
delay(100);
|
delay(100);
|
||||||
if (audioSource) audioSource->initialize(i2swsPin, i2ssdPin, i2sckPin, mclkPin);
|
if (audioSource) audioSource->initialize(i2swsPin, i2ssdPin, i2sckPin, mclkPin);
|
||||||
break;
|
break;
|
||||||
@@ -1747,8 +1748,10 @@ class AudioReactive : public Usermod {
|
|||||||
JsonObject top = root.createNestedObject(FPSTR(_name));
|
JsonObject top = root.createNestedObject(FPSTR(_name));
|
||||||
top[FPSTR(_enabled)] = enabled;
|
top[FPSTR(_enabled)] = enabled;
|
||||||
|
|
||||||
|
#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32S3)
|
||||||
JsonObject amic = top.createNestedObject(FPSTR(_analogmic));
|
JsonObject amic = top.createNestedObject(FPSTR(_analogmic));
|
||||||
amic["pin"] = audioPin;
|
amic["pin"] = audioPin;
|
||||||
|
#endif
|
||||||
|
|
||||||
JsonObject dmic = top.createNestedObject(FPSTR(_digitalmic));
|
JsonObject dmic = top.createNestedObject(FPSTR(_digitalmic));
|
||||||
dmic[F("type")] = dmType;
|
dmic[F("type")] = dmType;
|
||||||
@@ -1802,9 +1805,20 @@ class AudioReactive : public Usermod {
|
|||||||
|
|
||||||
configComplete &= getJsonValue(top[FPSTR(_enabled)], enabled);
|
configComplete &= getJsonValue(top[FPSTR(_enabled)], enabled);
|
||||||
|
|
||||||
|
#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32S3)
|
||||||
configComplete &= getJsonValue(top[FPSTR(_analogmic)]["pin"], audioPin);
|
configComplete &= getJsonValue(top[FPSTR(_analogmic)]["pin"], audioPin);
|
||||||
|
#else
|
||||||
|
audioPin = -1; // MCU does not support analog mic
|
||||||
|
#endif
|
||||||
|
|
||||||
configComplete &= getJsonValue(top[FPSTR(_digitalmic)]["type"], dmType);
|
configComplete &= getJsonValue(top[FPSTR(_digitalmic)]["type"], dmType);
|
||||||
|
#if defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32S3)
|
||||||
|
if (dmType == 0) dmType = SR_DMTYPE; // MCU does not support analog
|
||||||
|
#if defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32C3)
|
||||||
|
if (dmType == 5) dmType = SR_DMTYPE; // MCU does not support PDM
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
configComplete &= getJsonValue(top[FPSTR(_digitalmic)]["pin"][0], i2ssdPin);
|
configComplete &= getJsonValue(top[FPSTR(_digitalmic)]["pin"][0], i2ssdPin);
|
||||||
configComplete &= getJsonValue(top[FPSTR(_digitalmic)]["pin"][1], i2swsPin);
|
configComplete &= getJsonValue(top[FPSTR(_digitalmic)]["pin"][1], i2swsPin);
|
||||||
configComplete &= getJsonValue(top[FPSTR(_digitalmic)]["pin"][2], i2sckPin);
|
configComplete &= getJsonValue(top[FPSTR(_digitalmic)]["pin"][2], i2sckPin);
|
||||||
|
|||||||
Reference in New Issue
Block a user