90 void send_cmd_(uint8_t cmd, uint16_t high, uint16_t low) {
91 this->
send_cmd_(cmd, ((high & 0xFF) << 8) | (low & 0xFF));
105 #define DFPLAYER_SIMPLE_ACTION(ACTION_CLASS, ACTION_METHOD) \ 106 template<typename... Ts> \ 107 class ACTION_CLASS : \ 108 public Action<Ts...>, \ 109 public Parented<DFPlayer> { \ 110 void play(Ts... x) override { this->parent_->ACTION_METHOD(); } \ 118 TEMPLATABLE_VALUE(uint16_t, file)
119 TEMPLATABLE_VALUE(
bool, loop)
121 void play(Ts... x)
override {
122 auto file = this->file_.value(x...);
123 auto loop = this->loop_.value(x...);
125 this->
parent_->play_file_loop(file);
127 this->
parent_->play_file(file);
134 TEMPLATABLE_VALUE(uint16_t, folder)
135 TEMPLATABLE_VALUE(uint16_t, file)
138 void play(Ts... x)
override {
139 auto folder = this->folder_.value(x...);
140 auto file = this->file_.value(x...);
141 auto loop = this->loop_.value(x...);
143 this->
parent_->play_folder_loop(folder);
145 this->
parent_->play_folder(folder, file);
154 void play(Ts... x)
override {
155 auto device = this->device_.value(x...);
156 this->
parent_->set_device(device);
164 void play(Ts... x)
override {
165 auto volume = this->volume_.value(x...);
166 this->
parent_->set_volume(volume);
174 void play(Ts... x)
override {
175 auto eq = this->eq_.value(x...);
void send_cmd_(uint8_t cmd, uint16_t argument=0)
void dump_config() override
bool check(Ts... x) override
CallbackManager< void()> on_finished_playback_callback_
void play_file_loop(uint16_t file)
void add_on_finished_playback_callback(std::function< void()> callback)
DFPLAYER_SIMPLE_ACTION(NextAction, next) DFPLAYER_SIMPLE_ACTION(PreviousAction
void set_device(Device device)
void send_cmd_(uint8_t cmd, uint16_t high, uint16_t low)
void play_file(uint16_t file)
void play_folder_loop(uint16_t folder)
TEMPLATABLE_VALUE(Device, device) void play(Ts... x) override
Base class for all automation conditions.
const size_t DFPLAYER_READ_BUFFER_LENGTH
void play_folder(uint16_t folder, uint16_t file)
TEMPLATABLE_VALUE(uint8_t, volume) void play(Ts... x) override
void set_eq(EqPreset preset)
TEMPLATABLE_VALUE(EqPreset, eq) void play(Ts... x) override
void set_volume(uint8_t volume)
bool ack_reset_is_playing_
char read_buffer_[DFPLAYER_READ_BUFFER_LENGTH]
Helper class to easily give an object a parent of type T.
DFPlayerFinishedPlaybackTrigger(DFPlayer *parent)