@@ -125,6 +125,10 @@ Nfc* nfc_alloc() {
125
125
nfc -> popup = popup_alloc ();
126
126
view_dispatcher_add_view (nfc -> view_dispatcher , NfcViewPopup , popup_get_view (nfc -> popup ));
127
127
128
+ // Loading
129
+ nfc -> loading = loading_alloc ();
130
+ view_dispatcher_add_view (nfc -> view_dispatcher , NfcViewLoading , loading_get_view (nfc -> loading ));
131
+
128
132
// Text Input
129
133
nfc -> text_input = text_input_alloc ();
130
134
view_dispatcher_add_view (
@@ -179,6 +183,10 @@ void nfc_free(Nfc* nfc) {
179
183
view_dispatcher_remove_view (nfc -> view_dispatcher , NfcViewPopup );
180
184
popup_free (nfc -> popup );
181
185
186
+ // Loading
187
+ view_dispatcher_remove_view (nfc -> view_dispatcher , NfcViewLoading );
188
+ loading_free (nfc -> loading );
189
+
182
190
// TextInput
183
191
view_dispatcher_remove_view (nfc -> view_dispatcher , NfcViewTextInput );
184
192
text_input_free (nfc -> text_input );
@@ -258,12 +266,27 @@ void nfc_blink_stop(Nfc* nfc) {
258
266
notification_message (nfc -> notifications , & sequence_blink_stop );
259
267
}
260
268
269
+ void nfc_show_loading_popup (void * context , bool show ) {
270
+ Nfc * nfc = context ;
271
+ TaskHandle_t timer_task = xTaskGetHandle (configTIMER_SERVICE_TASK_NAME );
272
+
273
+ if (show ) {
274
+ // Raise timer priority so that animations can play
275
+ vTaskPrioritySet (timer_task , configMAX_PRIORITIES - 1 );
276
+ view_dispatcher_switch_to_view (nfc -> view_dispatcher , NfcViewLoading );
277
+ } else {
278
+ // Restore default timer priority
279
+ vTaskPrioritySet (timer_task , configTIMER_TASK_PRIORITY );
280
+ }
281
+ }
282
+
261
283
int32_t nfc_app (void * p ) {
262
284
Nfc * nfc = nfc_alloc ();
263
285
char * args = p ;
264
286
265
287
// Check argument and run corresponding scene
266
288
if ((* args != '\0' )) {
289
+ nfc_device_set_loading_callback (nfc -> dev , nfc_show_loading_popup , nfc );
267
290
uint32_t rpc_ctx = 0 ;
268
291
if (sscanf (p , "RPC %lX" , & rpc_ctx ) == 1 ) {
269
292
nfc -> rpc_ctx = (void * )rpc_ctx ;
@@ -281,6 +304,7 @@ int32_t nfc_app(void* p) {
281
304
// Exit app
282
305
view_dispatcher_stop (nfc -> view_dispatcher );
283
306
}
307
+ nfc_device_set_loading_callback (nfc -> dev , NULL , nfc );
284
308
} else {
285
309
scene_manager_next_scene (nfc -> scene_manager , NfcSceneStart );
286
310
}
0 commit comments