58 void send_cmd_(uint8_t cmd, uint16_t argument = 0);
59 void send_cmd_(uint8_t cmd, uint16_t high, uint16_t low) {
60 this->
send_cmd_(cmd, ((high & 0xFF) << 8) | (low & 0xFF));
74#define DFPLAYER_SIMPLE_ACTION(ACTION_CLASS, ACTION_METHOD) \
75 template<typename... Ts> \
76 class ACTION_CLASS : \
77 public Action<Ts...>, \
78 public Parented<DFPlayer> { \
79 void play(const Ts &...x) override { this->parent_->ACTION_METHOD(); } \
89 void play(
const Ts &...
x)
override {
90 auto file = this->file_.value(
x...);
91 this->parent_->play_mp3(file);
100 void
play(const Ts &...
x)
override {
101 auto file = this->file_.value(
x...);
102 auto loop = this->loop_.value(
x...);
104 this->
parent_->play_file_loop(file);
106 this->
parent_->play_file(file);
117 void play(const Ts &...
x)
override {
118 auto folder = this->folder_.value(
x...);
119 auto file = this->file_.value(
x...);
120 auto loop = this->loop_.value(
x...);
122 this->
parent_->play_folder_loop(folder);
124 this->
parent_->play_folder(folder, file);
133 void play(
const Ts &...
x)
override {
134 auto device = this->device_.value(
x...);
135 this->
parent_->set_device(device);
143 void play(
const Ts &...
x)
override {
144 auto volume = this->volume_.value(
x...);
145 this->
parent_->set_volume(volume);
153 void play(
const Ts &...
x)
override {
154 auto eq = this->eq_.value(
x...);
170 bool check(
const Ts &...
x)
override {
return this->parent_->is_playing(); }
virtual void play(const Ts &...x)=0
Base class for all automation conditions.
Helper class to easily give an object a parent of type T.
void dump_config() override
CallbackManager< void()> on_finished_playback_callback_
void send_cmd_(uint8_t cmd, uint16_t argument=0)
void add_on_finished_playback_callback(F &&callback)
void send_cmd_(uint8_t cmd, uint16_t high, uint16_t low)
void set_volume(uint8_t volume)
void play_folder(uint16_t folder, uint16_t file)
void play_file_loop(uint16_t file)
void set_device(Device device)
void play_file(uint16_t file)
bool ack_reset_is_playing_
void set_eq(EqPreset preset)
char read_buffer_[DFPLAYER_READ_BUFFER_LENGTH]
void play_folder_loop(uint16_t folder)
void play_mp3(uint16_t file)
bool check(const Ts &...x) override
TEMPLATABLE_VALUE(uint16_t, file) TEMPLATABLE_VALUE(bool
loop void play(const Ts &...x) override
TEMPLATABLE_VALUE(uint16_t, folder) TEMPLATABLE_VALUE(uint16_t
TEMPLATABLE_VALUE(uint16_t, file) void play(const Ts &...x) override
TEMPLATABLE_VALUE(Device, device) void play(const Ts &...x) override
TEMPLATABLE_VALUE(EqPreset, eq) void play(const Ts &...x) override
TEMPLATABLE_VALUE(uint8_t, volume) void play(const Ts &...x) override
const size_t DFPLAYER_READ_BUFFER_LENGTH
DFPLAYER_SIMPLE_ACTION(NextAction, next) DFPLAYER_SIMPLE_ACTION(PreviousAction