@@ -45,7 +45,9 @@ int32_t nfc_playlist_emulation_task(void* context) {
4545 popup_set_text (nfc_playlist -> popup , furi_string_get_cstr (tmp_counter_str ), 64 , 50 , AlignCenter , AlignTop );
4646 furi_delay_ms (50 );
4747 time_counter_delay_ms -= 50 ;
48+ furi_string_reset (tmp_counter_str );
4849 };
50+ furi_string_reset (tmp_counter_str );
4951 } else if (nfc_playlist -> settings .emulate_delay > 0 ) {
5052 skip_delay = false;
5153 file_position ++ ;
@@ -70,6 +72,7 @@ int32_t nfc_playlist_emulation_task(void* context) {
7072 popup_set_text (nfc_playlist -> popup , furi_string_get_cstr (tmp_counter_str ), 64 , 50 , AlignCenter , AlignTop );
7173 furi_delay_ms (50 );
7274 time_counter_ms -= 50 ;
75+ furi_string_reset (tmp_counter_str );
7376 };
7477 } else if (!storage_file_exists (storage , file_path )) {
7578 if (nfc_playlist -> settings .skip_error ) {
@@ -84,25 +87,33 @@ int32_t nfc_playlist_emulation_task(void* context) {
8487 popup_set_text (nfc_playlist -> popup , furi_string_get_cstr (tmp_counter_str ), 64 , 50 , AlignCenter , AlignTop );
8588 furi_delay_ms (50 );
8689 time_counter_ms -= 50 ;
90+ furi_string_reset (tmp_counter_str );
8791 };
8892 } else {
8993 furi_string_printf (tmp_header_str , "Emulating:\n%s" , file_name );
9094 popup_set_header (nfc_playlist -> popup , furi_string_get_cstr (tmp_header_str ), 64 , 10 , AlignCenter , AlignTop );
91- nfc_playlist_worker_set_nfc_data (nfc_playlist -> nfc_playlist_worker , file_path );
92- nfc_playlist_worker_start (nfc_playlist -> nfc_playlist_worker );
95+ nfc_playlist_emulation_worker_set_nfc_data (nfc_playlist -> nfc_playlist_emulation_worker , file_path );
96+ nfc_playlist_emulation_worker_start (nfc_playlist -> nfc_playlist_emulation_worker );
9397 start_blink (nfc_playlist , NfcPlaylistLedState_Normal );
94- while (nfc_playlist_worker_is_emulating (nfc_playlist -> nfc_playlist_worker ) && time_counter_ms > 0 && EmulationState == NfcPlaylistEmulationState_Emulating ) {
98+ while (nfc_playlist_emulation_worker_is_emulating (nfc_playlist -> nfc_playlist_emulation_worker ) && time_counter_ms > 0 && EmulationState == NfcPlaylistEmulationState_Emulating ) {
9599 furi_string_printf (tmp_counter_str , "%ds" , (time_counter_ms /1000 ));
96100 popup_set_text (nfc_playlist -> popup , furi_string_get_cstr (tmp_counter_str ), 64 , 50 , AlignCenter , AlignTop );
97101 furi_delay_ms (50 );
98102 time_counter_ms -= 50 ;
103+ furi_string_reset (tmp_counter_str );
99104 };
100- nfc_playlist_worker_stop (nfc_playlist -> nfc_playlist_worker );
101- nfc_playlist_worker_clear_nfc_data (nfc_playlist -> nfc_playlist_worker );
105+ nfc_playlist_emulation_worker_stop (nfc_playlist -> nfc_playlist_emulation_worker );
106+ nfc_playlist_emulation_worker_clear_nfc_data (nfc_playlist -> nfc_playlist_emulation_worker );
102107 }
108+ furi_string_reset (tmp_header_str );
109+ furi_string_reset (tmp_counter_str );
103110 }
104111 popup_reset (nfc_playlist -> popup );
105- popup_set_header (nfc_playlist -> popup , EmulationState == NfcPlaylistEmulationState_Canceled ? "Emulation stopped" : "Emulation finished" , 64 , 10 , AlignCenter , AlignTop );
112+ if (nfc_playlist -> settings .playlist_length == 0 ) {
113+ popup_set_header (nfc_playlist -> popup , "Empty playlist" , 64 , 10 , AlignCenter , AlignTop );
114+ } else {
115+ popup_set_header (nfc_playlist -> popup , EmulationState == NfcPlaylistEmulationState_Canceled ? "Emulation stopped" : "Emulation finished" , 64 , 10 , AlignCenter , AlignTop );
116+ }
106117 popup_set_text (nfc_playlist -> popup , "Press back" , 64 , 50 , AlignCenter , AlignTop );
107118 stop_blink (nfc_playlist );
108119
@@ -125,15 +136,15 @@ int32_t nfc_playlist_emulation_task(void* context) {
125136void nfc_playlist_emulation_setup (void * context ) {
126137 NfcPlaylist * nfc_playlist = context ;
127138 nfc_playlist -> thread = furi_thread_alloc_ex ("NfcPlaylistEmulationWorker" , 8192 , nfc_playlist_emulation_task , nfc_playlist );
128- nfc_playlist -> nfc_playlist_worker = nfc_playlist_worker_alloc ();
139+ nfc_playlist -> nfc_playlist_emulation_worker = nfc_playlist_emulation_worker_alloc ();
129140}
130141
131142void nfc_playlist_emulation_free (NfcPlaylist * nfc_playlist ) {
132143 furi_assert (nfc_playlist );
133144 furi_thread_free (nfc_playlist -> thread );
134- nfc_playlist_worker_free (nfc_playlist -> nfc_playlist_worker );
145+ nfc_playlist_emulation_worker_free (nfc_playlist -> nfc_playlist_emulation_worker );
135146 nfc_playlist -> thread = NULL ;
136- nfc_playlist -> nfc_playlist_worker = NULL ;
147+ nfc_playlist -> nfc_playlist_emulation_worker = NULL ;
137148}
138149
139150void nfc_playlist_emulation_start (NfcPlaylist * nfc_playlist ) {
0 commit comments