ESPHome  2024.11.1
automation.h
Go to the documentation of this file.
1 #pragma once
2 
5 #include "audio_dac.h"
6 
7 namespace esphome {
8 namespace audio_dac {
9 
10 template<typename... Ts> class MuteOffAction : public Action<Ts...> {
11  public:
12  explicit MuteOffAction(AudioDac *audio_dac) : audio_dac_(audio_dac) {}
13 
14  void play(Ts... x) override { this->audio_dac_->set_mute_off(); }
15 
16  protected:
18 };
19 
20 template<typename... Ts> class MuteOnAction : public Action<Ts...> {
21  public:
22  explicit MuteOnAction(AudioDac *audio_dac) : audio_dac_(audio_dac) {}
23 
24  void play(Ts... x) override { this->audio_dac_->set_mute_on(); }
25 
26  protected:
28 };
29 
30 template<typename... Ts> class SetVolumeAction : public Action<Ts...> {
31  public:
32  explicit SetVolumeAction(AudioDac *audio_dac) : audio_dac_(audio_dac) {}
33 
34  TEMPLATABLE_VALUE(float, volume)
35 
36  void play(Ts... x) override { this->audio_dac_->set_volume(this->volume_.value(x...)); }
37 
38  protected:
40 };
41 
42 } // namespace audio_dac
43 } // namespace esphome
virtual bool set_mute_off()=0
virtual bool set_mute_on()=0
MuteOffAction(AudioDac *audio_dac)
Definition: automation.h:12
uint16_t x
Definition: tt21100.cpp:17
TEMPLATABLE_VALUE(float, volume) void play(Ts... x) override
Definition: automation.h:34
MuteOnAction(AudioDac *audio_dac)
Definition: automation.h:22
virtual bool set_volume(float volume)=0
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
SetVolumeAction(AudioDac *audio_dac)
Definition: automation.h:32
void play(Ts... x) override
Definition: automation.h:24
void play(Ts... x) override
Definition: automation.h:14