59 void send_cmd_(uint8_t cmd, uint16_t argument = 0);
60 void send_cmd_(uint8_t cmd, uint16_t high, uint16_t low) {
61 this->
send_cmd_(cmd, ((high & 0xFF) << 8) | (low & 0xFF));
75#define DFPLAYER_SIMPLE_ACTION(ACTION_CLASS, ACTION_METHOD) \
76 template<typename... Ts> \
77 class ACTION_CLASS : \
78 public Action<Ts...>, \
79 public Parented<DFPlayer> { \
80 void play(Ts... x) override { this->parent_->ACTION_METHOD(); } \
90 void play(Ts...
x)
override {
91 auto file = this->file_.value(
x...);
92 this->parent_->play_mp3(file);
102 auto file = this->file_.value(
x...);
103 auto loop = this->loop_.value(
x...);
105 this->
parent_->play_file_loop(file);
107 this->
parent_->play_file(file);
118 void play(Ts...
x)
override {
119 auto folder = this->folder_.value(
x...);
120 auto file = this->file_.value(
x...);
121 auto loop = this->loop_.value(
x...);
123 this->
parent_->play_folder_loop(folder);
125 this->
parent_->play_folder(folder, file);
134 void play(Ts...
x)
override {
135 auto device = this->device_.value(
x...);
136 this->
parent_->set_device(device);
144 void play(Ts...
x)
override {
145 auto volume = this->volume_.value(
x...);
146 this->
parent_->set_volume(volume);
154 void play(Ts...
x)
override {
155 auto eq = this->eq_.value(
x...);
171 bool check(Ts...
x)
override {
return this->parent_->is_playing(); }
virtual void play(Ts... x)=0
Base class for all automation conditions.
Helper class to easily give an object a parent of type T.
DFPlayerFinishedPlaybackTrigger(DFPlayer *parent)
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(std::function< void()> 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(Ts... x) override
TEMPLATABLE_VALUE(uint16_t, file) TEMPLATABLE_VALUE(bool
loop void play(Ts... x) override
TEMPLATABLE_VALUE(uint16_t, folder) TEMPLATABLE_VALUE(uint16_t
TEMPLATABLE_VALUE(uint16_t, file) void play(Ts... x) override
TEMPLATABLE_VALUE(Device, device) void play(Ts... x) override
TEMPLATABLE_VALUE(EqPreset, eq) void play(Ts... x) override
TEMPLATABLE_VALUE(uint8_t, volume) void play(Ts... x) override
const size_t DFPLAYER_READ_BUFFER_LENGTH
DFPLAYER_SIMPLE_ACTION(NextAction, next) DFPLAYER_SIMPLE_ACTION(PreviousAction
Providing packet encoding functions for exchanging data with a remote host.