Skip to content

Commit

Permalink
rename timers, stop before free
Browse files Browse the repository at this point in the history
  • Loading branch information
xMasterX committed Jan 30, 2024
1 parent 4fd0ce3 commit 89e1620
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
10 changes: 6 additions & 4 deletions applications/main/lfrfid/scenes/lfrfid_scene_emulate.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#define LFRFID_EMULATION_TIME_MAX_MS (5 * 60 * 1000)

FuriTimer* timer;
FuriTimer* timer_auto_exit;

void lfrfid_scene_emulate_popup_callback(void* context) {
LfRfid* app = context;
Expand Down Expand Up @@ -31,8 +31,9 @@ void lfrfid_scene_emulate_on_enter(void* context) {
lfrfid_worker_emulate_start(app->lfworker, (LFRFIDProtocol)app->protocol_id);
notification_message(app->notifications, &sequence_blink_start_magenta);

timer = furi_timer_alloc(lfrfid_scene_emulate_popup_callback, FuriTimerTypeOnce, app);
furi_timer_start(timer, LFRFID_EMULATION_TIME_MAX_MS);
timer_auto_exit =
furi_timer_alloc(lfrfid_scene_emulate_popup_callback, FuriTimerTypeOnce, app);
furi_timer_start(timer_auto_exit, LFRFID_EMULATION_TIME_MAX_MS);

view_dispatcher_switch_to_view(app->view_dispatcher, LfRfidViewPopup);
}
Expand All @@ -59,7 +60,8 @@ bool lfrfid_scene_emulate_on_event(void* context, SceneManagerEvent event) {
void lfrfid_scene_emulate_on_exit(void* context) {
LfRfid* app = context;

furi_timer_free(timer);
furi_timer_stop(timer_auto_exit);
furi_timer_free(timer_auto_exit);

notification_message(app->notifications, &sequence_blink_stop);
popup_reset(app->popup);
Expand Down
10 changes: 6 additions & 4 deletions applications/main/nfc/scenes/nfc_scene_emulate.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#define NFC_EMULATION_TIME_MAX_MS (5 * 60 * 1000)

FuriTimer* timer;
FuriTimer* timer_auto_exit;

void nfc_scene_emulate_timer_callback(void* context) {
NfcApp* instance = context;
Expand All @@ -18,8 +18,9 @@ void nfc_scene_emulate_on_enter(void* context) {

nfc_protocol_support_on_enter(NfcProtocolSupportSceneEmulate, context);

timer = furi_timer_alloc(nfc_scene_emulate_timer_callback, FuriTimerTypeOnce, instance);
furi_timer_start(timer, NFC_EMULATION_TIME_MAX_MS);
timer_auto_exit =
furi_timer_alloc(nfc_scene_emulate_timer_callback, FuriTimerTypeOnce, instance);
furi_timer_start(timer_auto_exit, NFC_EMULATION_TIME_MAX_MS);
}

bool nfc_scene_emulate_on_event(void* context, SceneManagerEvent event) {
Expand All @@ -40,6 +41,7 @@ bool nfc_scene_emulate_on_event(void* context, SceneManagerEvent event) {
}

void nfc_scene_emulate_on_exit(void* context) {
furi_timer_free(timer);
furi_timer_stop(timer_auto_exit);
furi_timer_free(timer_auto_exit);
nfc_protocol_support_on_exit(NfcProtocolSupportSceneEmulate, context);
}

0 comments on commit 89e1620

Please sign in to comment.