ESPHome 2025.5.0
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 {
10namespace es7210 {
11
19
20class ES7210 : public audio_adc::AudioAdc, public Component, public i2c::I2CDevice {
21 /* Class for configuring an ES7210 ADC for microphone input.
22 * Based on code from:
23 * - https://github.com/espressif/esp-bsp/ (accessed 20241219)
24 * - https://github.com/espressif/esp-adf/ (accessed 20241219)
25 */
26 public:
27 void setup() override;
28 float get_setup_priority() const override { return setup_priority::DATA; }
29 void dump_config() override;
30
31 void set_bits_per_sample(ES7210BitsPerSample bits_per_sample) { this->bits_per_sample_ = bits_per_sample; }
32 bool set_mic_gain(float mic_gain) override;
33 void set_sample_rate(uint32_t sample_rate) { this->sample_rate_ = sample_rate; }
34
35 float mic_gain() override { return this->mic_gain_; };
36
37 protected:
43 bool es7210_update_reg_bit_(uint8_t reg_addr, uint8_t update_bits, uint8_t data);
44
48 uint8_t es7210_gain_reg_value_(float mic_gain);
49
53
54 bool setup_complete_{false};
55 bool enable_tdm_{false}; // TDM is unsupported in ESPHome as of version 2024.12
56 float mic_gain_{0};
58 uint32_t sample_rate_{0};
59};
60
61} // namespace es7210
62} // namespace esphome
bool configure_sample_rate_()
Definition es7210.cpp:99
uint8_t es7210_gain_reg_value_(float mic_gain)
Convert floating point mic gain value to register value.
Definition es7210.cpp:171
float mic_gain() override
Definition es7210.h:35
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:220
void setup() override
Definition es7210.cpp:38
void dump_config() override
Definition es7210.cpp:27
uint32_t sample_rate_
Definition es7210.h:58
bool set_mic_gain(float mic_gain) override
Definition es7210.cpp:91
void set_bits_per_sample(ES7210BitsPerSample bits_per_sample)
Definition es7210.h:31
float get_setup_priority() const override
Definition es7210.h:28
ES7210BitsPerSample bits_per_sample_
Definition es7210.h:57
void set_sample_rate(uint32_t sample_rate)
Definition es7210.h:33
This Class provides the methods to read/write bytes from/to an i2c device.
Definition i2c.h:133
@ ES7210_BITS_PER_SAMPLE_20
Definition es7210.h:15
@ ES7210_BITS_PER_SAMPLE_18
Definition es7210.h:14
@ ES7210_BITS_PER_SAMPLE_16
Definition es7210.h:13
@ ES7210_BITS_PER_SAMPLE_32
Definition es7210.h:17
@ ES7210_BITS_PER_SAMPLE_24
Definition es7210.h:16
const float DATA
For components that import data from directly connected sensors like DHT.
Definition component.cpp:19
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7