Music player rework (#1189)
* Music player: cli tool and new worker * Music player cli: flush message * Music player: fix note calculation * MusicPlayer: fix # parsing and add magic * FuriHal: improve speaker volume handling. MusicPlayer: minor sustain improvements * MusicPlayer: fix buffer overseek * FuriHal: drop unused variables * MusicPlayer: LFO 4 magic * MusicPlayer: add RTTTL parser * MusicPlayer: refactoring and add file open dialog on start * MusicPlayer: fix memcpy issue and more * FuriHal: force disconnect USB on early init and then leave usb line alone for some time. * FuriHal: switch speaker to old volume. MusicPlayer: fix incorrect note history, and drop lfo from worker. Co-authored-by: DrZlo13 <who.just.the.doctor@gmail.com>
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
#include <furi.h>
|
||||
#include <cli/cli.h>
|
||||
#include <storage/storage.h>
|
||||
#include "music_player_worker.h"
|
||||
|
||||
static void music_player_cli(Cli* cli, string_t args, void* context) {
|
||||
MusicPlayerWorker* music_player_worker = music_player_worker_alloc();
|
||||
Storage* storage = furi_record_open("storage");
|
||||
|
||||
do {
|
||||
if(storage_common_stat(storage, string_get_cstr(args), NULL) == FSE_OK) {
|
||||
if(!music_player_worker_load(music_player_worker, string_get_cstr(args))) {
|
||||
printf("Failed to open file %s\r\n", string_get_cstr(args));
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if(!music_player_worker_load_rtttl_from_string(
|
||||
music_player_worker, string_get_cstr(args))) {
|
||||
printf("Argument is not a file or RTTTL\r\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
printf("Press CTRL+C to stop\r\n");
|
||||
music_player_worker_start(music_player_worker);
|
||||
while(!cli_cmd_interrupt_received(cli)) {
|
||||
osDelay(50);
|
||||
}
|
||||
music_player_worker_stop(music_player_worker);
|
||||
} while(0);
|
||||
|
||||
furi_record_close("storage");
|
||||
music_player_worker_free(music_player_worker);
|
||||
}
|
||||
|
||||
void music_player_on_system_start() {
|
||||
#ifdef SRV_CLI
|
||||
Cli* cli = furi_record_open("cli");
|
||||
|
||||
cli_add_command(cli, "music_player", CliCommandFlagDefault, music_player_cli, NULL);
|
||||
|
||||
furi_record_close("cli");
|
||||
#else
|
||||
UNUSED(music_player_cli);
|
||||
#endif
|
||||
}
|
||||
Reference in New Issue
Block a user