1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-06 20:03:46 +01:00

Add more configuration for microphones - i2s/pdm/adc (#4775)

This commit is contained in:
Jesse Hills
2023-05-10 16:37:21 +12:00
committed by GitHub
parent b19c7d462b
commit 39a650ee54
6 changed files with 245 additions and 129 deletions

View File

@@ -18,14 +18,27 @@ class I2SAudioMicrophone : public I2SAudioIn, public microphone::Microphone, pub
void loop() override;
void set_din_pin(uint8_t pin) { this->din_pin_ = pin; }
void set_din_pin(int8_t pin) { this->din_pin_ = pin; }
void set_pdm(bool pdm) { this->pdm_ = pdm; }
#if SOC_I2S_SUPPORTS_ADC
void set_adc_channel(adc1_channel_t channel) {
this->adc_channel_ = channel;
this->adc_ = true;
}
#endif
protected:
void start_();
void stop_();
void read_();
uint8_t din_pin_{0};
int8_t din_pin_{I2S_PIN_NO_CHANGE};
#if SOC_I2S_SUPPORTS_ADC
adc1_channel_t adc_channel_{ADC1_CHANNEL_MAX};
bool adc_{false};
#endif
bool pdm_{false};
std::vector<uint8_t> buffer_;
HighFrequencyLoopRequester high_freq_;