ESPHome 2026.11.0-dev
Loading...
Searching...
No Matches
tas2780.h
Go to the documentation of this file.
1#pragma once
2
6
7namespace esphome::tas2780 {
8
9// Values are the TDM_CFG2 RX_SCFG field.
10enum ChannelSelect : uint8_t { LEFT_CHANNEL = 1, RIGHT_CHANNEL = 2, MONO_DWN_MIX = 3 };
11
13 public:
14 void setup() override;
15 void dump_config() override;
16 float get_setup_priority() const override { return setup_priority::IO; }
17 void update() override;
18
20 void reset();
22 void activate();
23 void deactivate();
25 bool apply_config();
26
27 bool set_mute_off() override { return this->set_mute_(false); }
28 bool set_mute_on() override { return this->set_mute_(true); }
29 bool set_volume(float volume) override;
30
31 bool is_muted() override { return this->is_muted_; }
32 float volume() override { return this->volume_; }
33
34 void set_amp_level(uint8_t amp_level) { this->amp_level_ = amp_level; }
35 void set_power_mode(uint8_t power_mode);
36 void set_vol_range_min(float min_val) { this->vol_range_min_ = min_val; }
37 void set_vol_range_max(float max_val) { this->vol_range_max_ = max_val; }
38 void set_selected_channel(ChannelSelect channel) { this->selected_channel_ = channel; }
39
40 protected:
41 bool select_page_(uint8_t page);
42 bool update_bits_(uint8_t reg, uint8_t mask, uint8_t value);
43 bool init_();
44 bool reinit_();
45 bool set_power_mode_(uint8_t power_mode);
47 bool write_mode_ctrl_(uint8_t mode);
48 uint8_t active_mode_() const;
49 bool set_mute_(bool muted);
50 bool write_volume_();
51 bool log_error_states_();
52 void clear_latches_();
53
54 float volume_{0};
55 float vol_range_min_{0.3f};
56 float vol_range_max_{1.0f};
57 uint8_t current_page_{0xFF};
58 uint8_t power_mode_{2};
59 uint8_t applied_power_mode_{0xFF};
60 uint8_t amp_level_{8};
62 bool active_{false};
63};
64
65} // namespace esphome::tas2780
BedjetMode mode
BedJet operating mode.
This class simplifies creating components that periodically check a state.
Definition component.h:514
This Class provides the methods to read/write bytes from/to an i2c device.
Definition i2c.h:132
I2CRegister reg(uint8_t a_register)
calls the I2CRegister constructor
Definition i2c.h:152
void activate()
Activate with the configured power mode; re-initializes first when the mode changed.
Definition tas2780.cpp:239
void set_selected_channel(ChannelSelect channel)
Definition tas2780.h:38
void update() override
Definition tas2780.cpp:318
bool select_page_(uint8_t page)
Definition tas2780.cpp:150
void reset()
Software reset and re-initialization, leaving the amplifier on or off as last requested.
Definition tas2780.cpp:257
void setup() override
Definition tas2780.cpp:142
void set_vol_range_max(float max_val)
Definition tas2780.h:37
bool set_volume(float volume) override
Definition tas2780.cpp:367
void dump_config() override
Definition tas2780.cpp:324
void set_power_mode(uint8_t power_mode)
Definition tas2780.cpp:274
bool update_bits_(uint8_t reg, uint8_t mask, uint8_t value)
Definition tas2780.cpp:161
bool set_mute_off() override
Definition tas2780.h:27
bool set_mute_(bool muted)
Definition tas2780.cpp:347
bool apply_config()
Write the amp level, channel and volume range to the device.
Definition tas2780.cpp:387
uint8_t active_mode_() const
Definition tas2780.cpp:343
float volume() override
Definition tas2780.h:32
bool is_muted() override
Definition tas2780.h:31
float get_setup_priority() const override
Definition tas2780.h:16
bool set_power_mode_(uint8_t power_mode)
Definition tas2780.cpp:283
bool set_mute_on() override
Definition tas2780.h:28
void set_amp_level(uint8_t amp_level)
Definition tas2780.h:34
ChannelSelect selected_channel_
Definition tas2780.h:61
void set_vol_range_min(float min_val)
Definition tas2780.h:36
bool write_mode_ctrl_(uint8_t mode)
Definition tas2780.cpp:339
PowerMode power_mode
Definition msa3xx.h:3
constexpr float IO
For components that represent GPIO pins like PCF8573.
Definition component.h:41