Skip to content

Commit

Permalink
Fixes UI
Browse files Browse the repository at this point in the history
  • Loading branch information
acegoal07 committed Dec 14, 2023
1 parent 4cfd1cd commit 17c86f7
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions nfc_playlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ typedef struct {
ViewDispatcher* view_dispatcher;
Submenu* menu;
Popup* popup;
NfcPlaylistWorker* nfc_worker;
int emulate_timeout;
} NfcPlaylist;

/** all custom events */
Expand All @@ -43,8 +43,6 @@ typedef enum { NfcPlaylistEvent_ShowPopupOne } NfcPlaylistEvent;
/** indices for menu items */
typedef enum { NfcPlaylistMenuSelection_One } NfcPlaylistMenuSelection;

int emulate_timeout = 2000;

/** main menu callback - sends a custom event to the scene manager based on the menu selection */
void nfc_playlist_menu_callback_main_menu(void* context, uint32_t index) {
FURI_LOG_T(TAG, "nfc_playlist_menu_callback_main_menu");
Expand All @@ -61,6 +59,7 @@ void nfc_playlist_scene_on_enter_main_menu(void* context) {
FURI_LOG_T(TAG, "nfc_playlist_scene_on_enter_main_menu");
NfcPlaylist* app = context;
submenu_reset(app->menu);
submenu_set_header(app->menu, "NFC Playlist");
submenu_add_item(
app->menu,
"Start",
Expand Down Expand Up @@ -108,7 +107,6 @@ void nfc_playlist_scene_on_enter_popup_emulating(void* context) {
Stream* stream = file_stream_alloc(storage);
FuriString* line = furi_string_alloc();
NfcPlaylistWorker* nfc_worker = nfc_playlist_worker_alloc();
app->nfc_worker = nfc_worker;
// Read file
if(file_stream_open(stream, APP_DATA_PATH("playlist.txt"), FSAM_READ, FSOM_OPEN_EXISTING)) {
popup_reset(app->popup);
Expand All @@ -122,10 +120,10 @@ void nfc_playlist_scene_on_enter_popup_emulating(void* context) {
popup_set_text(app->popup, str, 64, 30, AlignCenter, AlignTop);
view_dispatcher_switch_to_view(app->view_dispatcher, NfcPlaylistView_Popup);

nfc_playlist_worker_set_nfc_data(nfc_worker, (char*)furi_string_get_cstr(line));
nfc_playlist_worker_set_nfc_data(nfc_worker, str);
nfc_playlist_worker_start(nfc_worker);

furi_delay_ms(emulate_timeout);
furi_delay_ms(app->emulate_timeout);

nfc_playlist_worker_stop(nfc_worker);
furi_string_reset(line);
Expand All @@ -138,6 +136,7 @@ void nfc_playlist_scene_on_enter_popup_emulating(void* context) {
furi_string_free(line);
file_stream_close(stream);
stream_free(stream);
nfc_playlist_worker_free(nfc_worker);
// Close storage
furi_record_close(RECORD_STORAGE);

Expand Down Expand Up @@ -277,6 +276,8 @@ int32_t nfc_playlist_main(void* p) {
FURI_LOG_D(TAG, "Starting dispatcher...");
view_dispatcher_run(app->view_dispatcher);

app->emulate_timeout = 2000;

// free all memory
FURI_LOG_I(TAG, "Test app finishing...");
furi_record_close(RECORD_GUI);
Expand Down

0 comments on commit 17c86f7

Please sign in to comment.