ESPHome 2026.5.1
Loading...
Searching...
No Matches
es7210.h
Go to the documentation of this file.
1#pragma once
2
6
7#include "es7210_const.h"
8
9namespace esphome::es7210 {
10
18
19class ES7210 : public audio_adc::AudioAdc, public Component, public i2c::I2CDevice {
20 /* Class for configuring an ES7210 ADC for microphone input.
21 * Based on code from:
22 * - https://github.com/espressif/esp-bsp/ (accessed 20241219)
23 * - https://github.com/espressif/esp-adf/ (accessed 20241219)
24 */
25 public:
26 void setup() override;
27 void dump_config() override;
28
29 void set_bits_per_sample(ES7210BitsPerSample bits_per_sample) { this->bits_per_sample_ = bits_per_sample; }
30 bool set_mic_gain(float mic_gain) override;
31 void set_sample_rate(uint32_t sample_rate) { this->sample_rate_ = sample_rate; }
32
33 float mic_gain() override { return this->mic_gain_; };
34
35 protected:
41 bool es7210_update_reg_bit_(uint8_t reg_addr, uint8_t update_bits, uint8_t data);
42
46 uint8_t es7210_gain_reg_value_(float mic_gain);
47
51
52 bool setup_complete_{false};
53 bool enable_tdm_{false}; // TDM is unsupported in ESPHome as of version 2024.12
54 float mic_gain_{0};
57};
58
59} // namespace esphome::es7210
bool configure_sample_rate_()
Definition es7210.cpp:98
uint8_t es7210_gain_reg_value_(float mic_gain)
Convert floating point mic gain value to register value.
Definition es7210.cpp:170
float mic_gain() override
Definition es7210.h:33
bool es7210_update_reg_bit_(uint8_t reg_addr, uint8_t update_bits, uint8_t data)
Updates an I2C registry address by modifying the current state.
Definition es7210.cpp:219
void setup() override
Definition es7210.cpp:39
void dump_config() override
Definition es7210.cpp:26
uint32_t sample_rate_
Definition es7210.h:56
bool set_mic_gain(float mic_gain) override
Definition es7210.cpp:90
void set_bits_per_sample(ES7210BitsPerSample bits_per_sample)
Definition es7210.h:29
ES7210BitsPerSample bits_per_sample_
Definition es7210.h:55
void set_sample_rate(uint32_t sample_rate)
Definition es7210.h:31
This Class provides the methods to read/write bytes from/to an i2c device.
Definition i2c.h:132
@ ES7210_BITS_PER_SAMPLE_20
Definition es7210.h:14
@ ES7210_BITS_PER_SAMPLE_18
Definition es7210.h:13
@ ES7210_BITS_PER_SAMPLE_16
Definition es7210.h:12
@ ES7210_BITS_PER_SAMPLE_32
Definition es7210.h:16
@ ES7210_BITS_PER_SAMPLE_24
Definition es7210.h:15
static void uint32_t