ESPHome  2024.11.0
i2s_audio_microphone.h
Go to the documentation of this file.
1 #pragma once
2 
3 #ifdef USE_ESP32
4 
5 #include "../i2s_audio.h"
6 
9 
10 namespace esphome {
11 namespace i2s_audio {
12 
14  public:
15  void setup() override;
16  void start() override;
17  void stop() override;
18 
19  void loop() override;
20 
21  void set_din_pin(int8_t pin) { this->din_pin_ = pin; }
22  void set_pdm(bool pdm) { this->pdm_ = pdm; }
23 
24  size_t read(int16_t *buf, size_t len) override;
25 
26 #if SOC_I2S_SUPPORTS_ADC
27  void set_adc_channel(adc1_channel_t channel) {
28  this->adc_channel_ = channel;
29  this->adc_ = true;
30  }
31 #endif
32 
33  protected:
34  void start_();
35  void stop_();
36  void read_();
37 
38  int8_t din_pin_{I2S_PIN_NO_CHANGE};
39 #if SOC_I2S_SUPPORTS_ADC
40  adc1_channel_t adc_channel_{ADC1_CHANNEL_MAX};
41  bool adc_{false};
42 #endif
43  bool pdm_{false};
44 
46 };
47 
48 } // namespace i2s_audio
49 } // namespace esphome
50 
51 #endif // USE_ESP32
Helper class to request loop() to be called as fast as possible.
Definition: helpers.h:613
void set_adc_channel(adc1_channel_t channel)
size_t read(int16_t *buf, size_t len) override
std::string size_t len
Definition: helpers.h:293
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7