mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-11-23 21:13:16 +00:00
refactor[playlist]: made app a plugin
This commit is contained in:
parent
1a60093689
commit
f84d5e9b85
3 changed files with 19 additions and 13 deletions
|
@ -59,7 +59,6 @@ App(
|
|||
"clock",
|
||||
"spectrum_analyzer",
|
||||
"unirfremix",
|
||||
"playlist"
|
||||
],
|
||||
)
|
||||
|
||||
|
@ -79,5 +78,6 @@ App(
|
|||
"wifi_scanner",
|
||||
"wav_player",
|
||||
"dec_hex_converter",
|
||||
"sub_playlist",
|
||||
],
|
||||
)
|
|
@ -1,14 +1,10 @@
|
|||
App(
|
||||
appid="playlist",
|
||||
name="Playlist",
|
||||
apptype=FlipperAppType.APP,
|
||||
appid="sub_playlist",
|
||||
name=".sub Playlist",
|
||||
apptype=FlipperAppType.PLUGIN,
|
||||
entry_point="playlist_app",
|
||||
cdefines=["APP_PLAYLIST"],
|
||||
requires=[
|
||||
"gui",
|
||||
"dialogs",
|
||||
],
|
||||
icon="A_UniRFRemix_14",
|
||||
requires=["storage", "gui", "dialogs", "subghz"],
|
||||
stack_size=2 * 1024,
|
||||
order=11,
|
||||
order=31,
|
||||
)
|
||||
|
|
|
@ -45,6 +45,8 @@ typedef struct {
|
|||
string_t prev_3_path; // you get the idea
|
||||
|
||||
int state; // current state
|
||||
|
||||
ViewPort* view_port;
|
||||
} DisplayMeta;
|
||||
|
||||
typedef struct {
|
||||
|
@ -76,6 +78,11 @@ typedef struct {
|
|||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void meta_set_state(DisplayMeta* meta, int state) {
|
||||
meta->state = state;
|
||||
view_port_update(meta->view_port);
|
||||
}
|
||||
|
||||
static FuriHalSubGhzPreset str_to_preset(string_t preset) {
|
||||
if(string_cmp_str(preset, "FuriHalSubGhzPresetOok270Async") == 0) {
|
||||
return FuriHalSubGhzPresetOok270Async;
|
||||
|
@ -235,7 +242,7 @@ static int32_t playlist_worker_thread(void* ctx) {
|
|||
}
|
||||
|
||||
// update state to sending
|
||||
worker->meta->state = STATE_SENDING;
|
||||
meta_set_state(worker->meta, STATE_SENDING);
|
||||
|
||||
worker->meta->current_single_repetition = 0;
|
||||
++worker->meta->current_count;
|
||||
|
@ -251,6 +258,7 @@ static int32_t playlist_worker_thread(void* ctx) {
|
|||
string_set_str(worker->meta->prev_1_path, string_get_cstr(worker->meta->prev_0_path));
|
||||
string_reset(worker->meta->prev_0_path);
|
||||
string_set_str(worker->meta->prev_0_path, str);
|
||||
view_port_update(worker->meta->view_port);
|
||||
|
||||
for(int i = 0; i < MAX(1, worker->meta->single_repetitions); i++) {
|
||||
if(!playlist_worker_wait_pause(worker)) {
|
||||
|
@ -258,6 +266,7 @@ static int32_t playlist_worker_thread(void* ctx) {
|
|||
}
|
||||
|
||||
++worker->meta->current_single_repetition;
|
||||
view_port_update(worker->meta->view_port);
|
||||
|
||||
FURI_LOG_I(
|
||||
TAG,
|
||||
|
@ -302,7 +311,7 @@ static int32_t playlist_worker_thread(void* ctx) {
|
|||
worker->is_running = false;
|
||||
|
||||
// update state to overview
|
||||
worker->meta->state = STATE_OVERVIEW;
|
||||
meta_set_state(worker->meta, STATE_OVERVIEW);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -657,6 +666,7 @@ int32_t playlist_app(void* p) {
|
|||
// create app
|
||||
DisplayMeta* meta = playlist_meta_alloc();
|
||||
Playlist* app = playlist_alloc(meta);
|
||||
meta->view_port = app->view_port;
|
||||
|
||||
// select playlist file
|
||||
{
|
||||
|
@ -674,7 +684,7 @@ int32_t playlist_app(void* p) {
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
playlist_start_worker(app, meta);
|
||||
app->meta->state = STATE_OVERVIEW;
|
||||
meta_set_state(app->meta, STATE_OVERVIEW);
|
||||
|
||||
bool exit_loop = false;
|
||||
InputEvent input;
|
||||
|
|
Loading…
Reference in a new issue