@@ -89,7 +89,6 @@ typedef struct {
89
89
90
90
int file_result ;
91
91
bool tx_not_allowed ;
92
- int file_blank ;
93
92
94
93
FuriString * signal ;
95
94
} UniRFRemix ;
@@ -168,14 +167,13 @@ void unirfremix_cfg_set_check(UniRFRemix* app, FuriString* file_name) {
168
167
Storage * storage = furi_record_open (RECORD_STORAGE );
169
168
FlipperFormat * fff_data_file = flipper_format_file_alloc (storage );
170
169
171
- app -> file_result = 3 ;
172
- app -> file_blank = 0 ;
170
+ app -> file_result = 1 ;
173
171
174
- app -> up_enabled = 1 ;
175
- app -> down_enabled = 1 ;
176
- app -> left_enabled = 1 ;
177
- app -> right_enabled = 1 ;
178
- app -> ok_enabled = 1 ;
172
+ app -> up_enabled = 0 ;
173
+ app -> down_enabled = 0 ;
174
+ app -> left_enabled = 0 ;
175
+ app -> right_enabled = 0 ;
176
+ app -> ok_enabled = 0 ;
179
177
180
178
int label_len = 16 ;
181
179
@@ -189,61 +187,55 @@ void unirfremix_cfg_set_check(UniRFRemix* app, FuriString* file_name) {
189
187
//set missing filenames to N/A
190
188
if (!flipper_format_read_string (fff_data_file , "UP" , app -> up_file )) {
191
189
FURI_LOG_W (TAG , "Could not read UP string" );
192
- //increment file_blank for processing later
193
- app -> file_blank ++ ;
194
190
//set label to "N/A"
195
191
app -> up_label = "N/A" ;
196
- //disable the ability to process the signal on button press
197
- app -> up_enabled = 0 ;
198
192
} else {
199
193
//check name length for proper screen fit
200
194
//then set filename as label. Might be replaced with defined label later on below.
201
195
app -> up_label = extract_filename (furi_string_get_cstr (app -> up_file ), label_len );
202
196
FURI_LOG_I (TAG , "UP file: %s" , furi_string_get_cstr (app -> up_file ));
197
+ //enable processing of the signal on button press
198
+ app -> up_enabled = 1 ;
203
199
}
204
200
205
201
//Repeat process for Down
206
202
if (!flipper_format_read_string (fff_data_file , "DOWN" , app -> down_file )) {
207
203
FURI_LOG_W (TAG , "Could not read DOWN string" );
208
- app -> file_blank ++ ;
209
204
app -> down_label = "N/A" ;
210
- app -> down_enabled = 0 ;
211
205
} else {
212
206
app -> down_label = extract_filename (furi_string_get_cstr (app -> down_file ), label_len );
213
207
FURI_LOG_I (TAG , "DOWN file: %s" , furi_string_get_cstr (app -> down_file ));
208
+ app -> down_enabled = 1 ;
214
209
}
215
210
216
211
//Repeat process for Left
217
212
if (!flipper_format_read_string (fff_data_file , "LEFT" , app -> left_file )) {
218
213
FURI_LOG_W (TAG , "Could not read LEFT string" );
219
- app -> file_blank ++ ;
220
214
app -> left_label = "N/A" ;
221
- app -> left_enabled = 0 ;
222
215
} else {
223
216
app -> left_label = extract_filename (furi_string_get_cstr (app -> left_file ), label_len );
224
217
FURI_LOG_I (TAG , "LEFT file: %s" , furi_string_get_cstr (app -> left_file ));
218
+ app -> left_enabled = 1 ;
225
219
}
226
220
227
221
//Repeat process for Right
228
222
if (!flipper_format_read_string (fff_data_file , "RIGHT" , app -> right_file )) {
229
223
FURI_LOG_W (TAG , "Could not read RIGHT string" );
230
- app -> file_blank ++ ;
231
224
app -> right_label = "N/A" ;
232
- app -> right_enabled = 0 ;
233
225
} else {
234
226
app -> right_label = extract_filename (furi_string_get_cstr (app -> right_file ), label_len );
235
227
FURI_LOG_I (TAG , "RIGHT file: %s" , furi_string_get_cstr (app -> right_file ));
228
+ app -> right_enabled = 1 ;
236
229
}
237
230
238
231
//Repeat process for Ok
239
232
if (!flipper_format_read_string (fff_data_file , "OK" , app -> ok_file )) {
240
233
FURI_LOG_W (TAG , "Could not read OK string" );
241
- app -> file_blank ++ ;
242
234
app -> ok_label = "N/A" ;
243
- app -> ok_enabled = 0 ;
244
235
} else {
245
236
app -> ok_label = extract_filename (furi_string_get_cstr (app -> ok_file ), label_len );
246
237
FURI_LOG_I (TAG , "OK file: %s" , furi_string_get_cstr (app -> ok_file ));
238
+ app -> ok_enabled = 1 ;
247
239
}
248
240
249
241
//File definitions are done.
@@ -254,15 +246,9 @@ void unirfremix_cfg_set_check(UniRFRemix* app, FuriString* file_name) {
254
246
//assign variables to values within map file
255
247
if (!flipper_format_read_string (fff_data_file , "ULABEL" , app -> up_l )) {
256
248
FURI_LOG_W (TAG , "Could not read ULABEL string" );
257
- //if Up button is disabled, set the label to "N/A";
258
- if (app -> up_enabled == 0 ) {
259
- app -> up_label = "N/A" ;
260
- }
261
249
} else {
262
- //check if button is disabled, and set label to "N/A" from missing map definition above
263
- if (app -> up_enabled == 0 ) {
264
- app -> up_label = "N/A" ;
265
- } else {
250
+ //check if button is enabled, and set label
251
+ if (app -> up_enabled == 1 ) {
266
252
//set label from map to variable and shrink to fit screen
267
253
app -> up_label = char_to_str ((char * )furi_string_get_cstr (app -> up_l ), label_len );
268
254
}
@@ -271,41 +257,26 @@ void unirfremix_cfg_set_check(UniRFRemix* app, FuriString* file_name) {
271
257
272
258
if (!flipper_format_read_string (fff_data_file , "DLABEL" , app -> down_l )) {
273
259
FURI_LOG_W (TAG , "Could not read DLABEL string" );
274
- if (app -> down_enabled == 0 ) {
275
- app -> down_label = "N/A" ;
276
- }
277
260
} else {
278
- if (app -> down_enabled == 0 ) {
279
- app -> down_label = "N/A" ;
280
- } else {
261
+ if (app -> down_enabled == 1 ) {
281
262
app -> down_label = char_to_str ((char * )furi_string_get_cstr (app -> down_l ), label_len );
282
263
}
283
264
FURI_LOG_I (TAG , "DOWN label: %s" , app -> down_label );
284
265
}
285
266
286
267
if (!flipper_format_read_string (fff_data_file , "LLABEL" , app -> left_l )) {
287
268
FURI_LOG_W (TAG , "Could not read LLABEL string" );
288
- if (app -> left_enabled == 0 ) {
289
- app -> left_label = "N/A" ;
290
- }
291
269
} else {
292
- if (app -> left_enabled == 0 ) {
293
- app -> left_label = "N/A" ;
294
- } else {
270
+ if (app -> left_enabled == 1 ) {
295
271
app -> left_label = char_to_str ((char * )furi_string_get_cstr (app -> left_l ), label_len );
296
272
}
297
273
FURI_LOG_I (TAG , "LEFT label: %s" , app -> left_label );
298
274
}
299
275
300
276
if (!flipper_format_read_string (fff_data_file , "RLABEL" , app -> right_l )) {
301
277
FURI_LOG_W (TAG , "Could not read RLABEL string" );
302
- if (app -> right_enabled == 0 ) {
303
- app -> right_label = "N/A" ;
304
- }
305
278
} else {
306
- if (app -> right_enabled == 0 ) {
307
- app -> right_label = "N/A" ;
308
- } else {
279
+ if (app -> right_enabled == 1 ) {
309
280
app -> right_label =
310
281
char_to_str ((char * )furi_string_get_cstr (app -> right_l ), label_len );
311
282
}
@@ -314,19 +285,12 @@ void unirfremix_cfg_set_check(UniRFRemix* app, FuriString* file_name) {
314
285
315
286
if (!flipper_format_read_string (fff_data_file , "OKLABEL" , app -> ok_l )) {
316
287
FURI_LOG_W (TAG , "Could not read OKLABEL string" );
317
- if (app -> ok_enabled == 0 ) {
318
- app -> ok_label = "N/A" ;
319
- }
320
288
} else {
321
- if (app -> ok_enabled == 0 ) {
322
- app -> ok_label = "N/A" ;
323
- } else {
289
+ if (app -> ok_enabled == 1 ) {
324
290
app -> ok_label = char_to_str ((char * )furi_string_get_cstr (app -> ok_l ), label_len );
325
291
}
326
292
FURI_LOG_I (TAG , "OK label: %s" , app -> ok_label );
327
293
}
328
-
329
- app -> file_result = 2 ;
330
294
}
331
295
332
296
flipper_format_file_close (fff_data_file );
@@ -339,106 +303,91 @@ void unirfremix_cfg_set_check(UniRFRemix* app, FuriString* file_name) {
339
303
//determine whether or not to continue to launch app with missing variables
340
304
//if 5 files are missing, throw error
341
305
342
- FURI_LOG_D (TAG , "app->file_blank: %d" , app -> file_blank );
306
+ //if button is still enabled, check that file exists
307
+ if (app -> up_enabled == 1 ) {
308
+ furi_string_set (file_name , app -> up_file );
309
+ fff_data_file = flipper_format_file_alloc (storage );
343
310
344
- if (app -> file_blank == 5 ) {
345
- //trigger invalid file error screen
346
- app -> file_result = 1 ;
347
- } else {
348
- //check all files
349
- //reset app->file_blank to redetermine if error needs to be thrown
350
- app -> file_blank = 0 ;
351
-
352
- //if button is still enabled, check that file exists
353
- if (app -> up_enabled == 1 ) {
354
- furi_string_set (file_name , app -> up_file );
355
- fff_data_file = flipper_format_file_alloc (storage );
356
-
357
- if (!flipper_format_file_open_existing (fff_data_file , furi_string_get_cstr (file_name ))) {
358
- FURI_LOG_W (TAG , "Could not open UP file %s" , furi_string_get_cstr (file_name ));
359
-
360
- //disable button, and set label to "N/A"
361
- app -> up_enabled = 0 ;
362
- app -> up_label = "N/A" ;
363
- app -> file_blank ++ ;
364
- }
311
+ if (!flipper_format_file_open_existing (fff_data_file , furi_string_get_cstr (file_name ))) {
312
+ FURI_LOG_W (TAG , "Could not open UP file %s" , furi_string_get_cstr (file_name ));
365
313
366
- //close the file
367
- flipper_format_file_close ( fff_data_file ) ;
368
- flipper_format_free ( fff_data_file ) ;
314
+ //disable button, and set label to "N/A"
315
+ app -> up_enabled = 0 ;
316
+ app -> up_label = "N/A" ;
369
317
}
370
318
371
- if (app -> down_enabled == 1 ) {
372
- furi_string_set (file_name , app -> down_file );
373
- fff_data_file = flipper_format_file_alloc (storage );
319
+ //close the file
320
+ flipper_format_file_close (fff_data_file );
321
+ flipper_format_free (fff_data_file );
322
+ }
374
323
375
- if (!flipper_format_file_open_existing (fff_data_file , furi_string_get_cstr (file_name ))) {
376
- FURI_LOG_W (TAG , "Could not open DOWN file %s" , furi_string_get_cstr (file_name ));
324
+ if (app -> down_enabled == 1 ) {
325
+ furi_string_set (file_name , app -> down_file );
326
+ fff_data_file = flipper_format_file_alloc (storage );
377
327
378
- app -> down_enabled = 0 ;
379
- app -> down_label = "N/A" ;
380
- app -> file_blank ++ ;
381
- }
328
+ if (!flipper_format_file_open_existing (fff_data_file , furi_string_get_cstr (file_name ))) {
329
+ FURI_LOG_W (TAG , "Could not open DOWN file %s" , furi_string_get_cstr (file_name ));
382
330
383
- flipper_format_file_close ( fff_data_file ) ;
384
- flipper_format_free ( fff_data_file ) ;
331
+ app -> down_enabled = 0 ;
332
+ app -> down_label = "N/A" ;
385
333
}
386
334
387
- if ( app -> left_enabled == 1 ) {
388
- furi_string_set ( file_name , app -> left_file );
389
- fff_data_file = flipper_format_file_alloc ( storage );
335
+ flipper_format_file_close ( fff_data_file );
336
+ flipper_format_free ( fff_data_file );
337
+ }
390
338
391
- if (!flipper_format_file_open_existing (fff_data_file , furi_string_get_cstr (file_name ))) {
392
- FURI_LOG_W (TAG , "Could not open LEFT file %s" , furi_string_get_cstr (file_name ));
339
+ if (app -> left_enabled == 1 ) {
340
+ furi_string_set (file_name , app -> left_file );
341
+ fff_data_file = flipper_format_file_alloc (storage );
393
342
394
- app -> left_enabled = 0 ;
395
- app -> left_label = "N/A" ;
396
- app -> file_blank ++ ;
397
- }
343
+ if (!flipper_format_file_open_existing (fff_data_file , furi_string_get_cstr (file_name ))) {
344
+ FURI_LOG_W (TAG , "Could not open LEFT file %s" , furi_string_get_cstr (file_name ));
398
345
399
- flipper_format_file_close ( fff_data_file ) ;
400
- flipper_format_free ( fff_data_file ) ;
346
+ app -> left_enabled = 0 ;
347
+ app -> left_label = "N/A" ;
401
348
}
402
349
403
- if ( app -> right_enabled == 1 ) {
404
- furi_string_set ( file_name , app -> right_file );
405
- fff_data_file = flipper_format_file_alloc ( storage );
350
+ flipper_format_file_close ( fff_data_file );
351
+ flipper_format_free ( fff_data_file );
352
+ }
406
353
407
- if (!flipper_format_file_open_existing (fff_data_file , furi_string_get_cstr (file_name ))) {
408
- FURI_LOG_W (TAG , "Could not open RIGHT file %s" , furi_string_get_cstr (file_name ));
354
+ if (app -> right_enabled == 1 ) {
355
+ furi_string_set (file_name , app -> right_file );
356
+ fff_data_file = flipper_format_file_alloc (storage );
409
357
410
- app -> right_enabled = 0 ;
411
- app -> right_label = "N/A" ;
412
- app -> file_blank ++ ;
413
- }
358
+ if (!flipper_format_file_open_existing (fff_data_file , furi_string_get_cstr (file_name ))) {
359
+ FURI_LOG_W (TAG , "Could not open RIGHT file %s" , furi_string_get_cstr (file_name ));
414
360
415
- flipper_format_file_close ( fff_data_file ) ;
416
- flipper_format_free ( fff_data_file ) ;
361
+ app -> right_enabled = 0 ;
362
+ app -> right_label = "N/A" ;
417
363
}
418
364
419
- if ( app -> ok_enabled == 1 ) {
420
- furi_string_set ( file_name , app -> ok_file );
421
- fff_data_file = flipper_format_file_alloc ( storage );
365
+ flipper_format_file_close ( fff_data_file );
366
+ flipper_format_free ( fff_data_file );
367
+ }
422
368
423
- if (!flipper_format_file_open_existing (fff_data_file , furi_string_get_cstr (file_name ))) {
424
- FURI_LOG_W (TAG , "Could not open OK file %s" , furi_string_get_cstr (file_name ));
369
+ if (app -> ok_enabled == 1 ) {
370
+ furi_string_set (file_name , app -> ok_file );
371
+ fff_data_file = flipper_format_file_alloc (storage );
425
372
426
- app -> ok_enabled = 0 ;
427
- app -> ok_label = "N/A" ;
428
- app -> file_blank ++ ;
429
- }
373
+ if (!flipper_format_file_open_existing (fff_data_file , furi_string_get_cstr (file_name ))) {
374
+ FURI_LOG_W (TAG , "Could not open OK file %s" , furi_string_get_cstr (file_name ));
430
375
431
- flipper_format_file_close ( fff_data_file ) ;
432
- flipper_format_free ( fff_data_file ) ;
376
+ app -> ok_enabled = 0 ;
377
+ app -> ok_label = "N/A" ;
433
378
}
434
379
435
- furi_record_close (RECORD_STORAGE );
380
+ flipper_format_file_close (fff_data_file );
381
+ flipper_format_free (fff_data_file );
382
+ }
436
383
437
- if (app -> file_blank == 5 ) {
438
- app -> file_result = 1 ;
439
- } else {
440
- app -> file_result = 2 ;
441
- }
384
+ furi_record_close (RECORD_STORAGE );
385
+
386
+ if (app -> up_enabled == 0 && app -> down_enabled == 0 && app -> left_enabled == 0 &&
387
+ app -> right_enabled == 0 && app -> ok_enabled == 0 ) {
388
+ app -> file_result = 1 ;
389
+ } else {
390
+ app -> file_result = 2 ;
442
391
}
443
392
}
444
393
@@ -742,6 +691,14 @@ static void render_callback(Canvas* canvas, void* ctx) {
742
691
canvas_set_font (canvas , FontSecondary );
743
692
canvas_draw_str_aligned (canvas , 62 , 30 , AlignCenter , AlignTop , "Please configure map." );
744
693
canvas_draw_str_aligned (canvas , 62 , 60 , AlignCenter , AlignBottom , "Press Back to Exit." );
694
+ } else if (app -> file_result == 3 ) {
695
+ //if map has no valid filenames defined
696
+ canvas_clear (canvas );
697
+ canvas_set_font (canvas , FontPrimary );
698
+ canvas_draw_str_aligned (canvas , 62 , 5 , AlignCenter , AlignTop , "Checking config." );
699
+ canvas_set_font (canvas , FontSecondary );
700
+ canvas_draw_str_aligned (canvas , 62 , 30 , AlignCenter , AlignTop , "If app is stuck..." );
701
+ canvas_draw_str_aligned (canvas , 62 , 60 , AlignCenter , AlignBottom , "Press Back to Exit." );
745
702
} else if (app -> tx_not_allowed ) {
746
703
canvas_clear (canvas );
747
704
canvas_set_font (canvas , FontPrimary );
@@ -1129,7 +1086,7 @@ int32_t unirfremix_app(void* p) {
1129
1086
furi_mutex_release (app -> model_mutex );
1130
1087
view_port_update (app -> view_port );
1131
1088
}
1132
- } else if (app -> file_result == 1 ) {
1089
+ } else if (app -> file_result == 1 || app -> file_result == 3 ) {
1133
1090
//refresh screen to update variables before processing main screen or error screens
1134
1091
view_port_update (app -> view_port );
1135
1092
0 commit comments