ESPHome 2026.11.0b6
Loading...
Searching...
No Matches
es8388.h
Go to the documentation of this file.
1#pragma once
2
3#include <map>
4
8#ifdef USE_ES8388_SELECT
10#endif
11
12#include "es8388_const.h"
13
14namespace esphome::es8388 {
15
21
27
40
41class ES8388 final : public audio_dac::AudioDac, public Component, public i2c::I2CDevice {
42#ifdef USE_ES8388_SELECT
43 SUB_SELECT(dac_output)
44 SUB_SELECT(adc_input_mic)
45#endif
46
47 public:
49 // Component overrides //
51
52 void setup() override;
53 void dump_config() override;
54
56 // AudioDac overrides //
58
62 bool set_volume(float volume) override;
63
66 float volume() override;
67
70 bool set_mute_off() override { return this->set_mute_state_(false); }
71
74 bool set_mute_on() override { return this->set_mute_state_(true); }
75
76 bool is_muted() override { return this->is_muted_; }
77
78 optional<DacOutputLine> get_dac_power();
79 optional<AdcInputMicLine> get_mic_input();
80
81 bool set_dac_output(DacOutputLine line);
82 bool set_adc_input_mic(AdcInputMicLine line);
83
84 void set_mic_gain(ES8388MicGain gain) { this->mic_gain_ = gain; }
85
86#ifdef USE_ES8388_SELECT
88 void set_dac_output_initial(DacOutputLine line) { this->dac_output_initial_ = line; }
89 void set_adc_input_mic_initial(AdcInputMicLine line) { this->adc_input_mic_initial_ = line; }
90#endif
91
92 protected:
96 bool set_mute_state_(bool mute_state);
97
99
100#ifdef USE_ES8388_SELECT
101 optional<DacOutputLine> dac_output_initial_{};
102 optional<AdcInputMicLine> adc_input_mic_initial_{};
103#endif
104};
105
106} // namespace esphome::es8388
virtual void setup()
Where the component's initialization should happen.
Definition component.cpp:84
optional< DacOutputLine > dac_output_initial_
Definition es8388.h:101
bool set_mute_state_(bool mute_state)
Mutes or unmutes the DAC audio out.
Definition es8388.cpp:168
optional< AdcInputMicLine > adc_input_mic_initial_
Definition es8388.h:102
ES8388MicGain mic_gain_
Definition es8388.h:98
This Class provides the methods to read/write bytes from/to an i2c device.
Definition i2c.h:144
AlsGain501 gain
@ ADC_INPUT_MIC_LINE1
Definition es8388.h:23
@ ADC_INPUT_MIC_DIFFERENCE
Definition es8388.h:25
@ ADC_INPUT_MIC_LINE2
Definition es8388.h:24
ES8388MicGain
ADC PGA gain (reg 0x09): the same 3 dB step in both channel nibbles.
Definition es8388.h:29
@ ES8388_MIC_GAIN_21DB
Definition es8388.h:37
@ ES8388_MIC_GAIN_9DB
Definition es8388.h:33
@ ES8388_MIC_GAIN_24DB
Definition es8388.h:38
@ ES8388_MIC_GAIN_12DB
Definition es8388.h:34
@ ES8388_MIC_GAIN_6DB
Definition es8388.h:32
@ ES8388_MIC_GAIN_0DB
Definition es8388.h:30
@ ES8388_MIC_GAIN_18DB
Definition es8388.h:36
@ ES8388_MIC_GAIN_15DB
Definition es8388.h:35
@ ES8388_MIC_GAIN_3DB
Definition es8388.h:31