No auto stop emulate after 5 mins --nobuild

This commit is contained in:
Willy-JL
2024-02-22 09:59:39 +00:00
parent e2ab71e1d3
commit f41609de23
2 changed files with 22 additions and 26 deletions

View File

@@ -2,9 +2,7 @@
#include <xtreme/xtreme.h> #include <xtreme/xtreme.h>
#define LFRFID_EMULATION_TIME_MAX_MS (5 * 60 * 1000) FuriTimer* timer_auto_exit = NULL;
FuriTimer* timer_auto_exit;
void lfrfid_scene_emulate_popup_callback(void* context) { void lfrfid_scene_emulate_popup_callback(void* context) {
LfRfid* app = context; LfRfid* app = context;
@@ -33,15 +31,12 @@ void lfrfid_scene_emulate_on_enter(void* context) {
lfrfid_worker_emulate_start(app->lfworker, (LFRFIDProtocol)app->protocol_id); lfrfid_worker_emulate_start(app->lfworker, (LFRFIDProtocol)app->protocol_id);
notification_message(app->notifications, &sequence_blink_start_magenta); notification_message(app->notifications, &sequence_blink_start_magenta);
timer_auto_exit = if(app->fav_timeout) {
furi_timer_alloc(lfrfid_scene_emulate_popup_callback, FuriTimerTypeOnce, app); timer_auto_exit =
furi_timer_alloc(lfrfid_scene_emulate_popup_callback, FuriTimerTypeOnce, app);
if(!furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug) || app->fav_timeout)
furi_timer_start( furi_timer_start(
timer_auto_exit, timer_auto_exit, xtreme_settings.favorite_timeout * furi_kernel_get_tick_frequency());
app->fav_timeout ? }
xtreme_settings.favorite_timeout * furi_kernel_get_tick_frequency() :
LFRFID_EMULATION_TIME_MAX_MS);
view_dispatcher_switch_to_view(app->view_dispatcher, LfRfidViewPopup); view_dispatcher_switch_to_view(app->view_dispatcher, LfRfidViewPopup);
} }
@@ -68,8 +63,11 @@ bool lfrfid_scene_emulate_on_event(void* context, SceneManagerEvent event) {
void lfrfid_scene_emulate_on_exit(void* context) { void lfrfid_scene_emulate_on_exit(void* context) {
LfRfid* app = context; LfRfid* app = context;
furi_timer_stop(timer_auto_exit); if(timer_auto_exit) {
furi_timer_free(timer_auto_exit); furi_timer_stop(timer_auto_exit);
furi_timer_free(timer_auto_exit);
timer_auto_exit = NULL;
}
notification_message(app->notifications, &sequence_blink_stop); notification_message(app->notifications, &sequence_blink_stop);
popup_reset(app->popup); popup_reset(app->popup);

View File

@@ -4,9 +4,7 @@
#include <xtreme/xtreme.h> #include <xtreme/xtreme.h>
#define NFC_EMULATION_TIME_MAX_MS (5 * 60 * 1000) FuriTimer* timer_auto_exit = NULL;
FuriTimer* timer_auto_exit;
void nfc_scene_emulate_timer_callback(void* context) { void nfc_scene_emulate_timer_callback(void* context) {
NfcApp* instance = context; NfcApp* instance = context;
@@ -20,15 +18,12 @@ void nfc_scene_emulate_on_enter(void* context) {
nfc_protocol_support_on_enter(NfcProtocolSupportSceneEmulate, context); nfc_protocol_support_on_enter(NfcProtocolSupportSceneEmulate, context);
timer_auto_exit = if(instance->fav_timeout) {
furi_timer_alloc(nfc_scene_emulate_timer_callback, FuriTimerTypeOnce, instance); timer_auto_exit =
furi_timer_alloc(nfc_scene_emulate_timer_callback, FuriTimerTypeOnce, instance);
if(!furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug) || instance->fav_timeout)
furi_timer_start( furi_timer_start(
timer_auto_exit, timer_auto_exit, xtreme_settings.favorite_timeout * furi_kernel_get_tick_frequency());
instance->fav_timeout ? }
xtreme_settings.favorite_timeout * furi_kernel_get_tick_frequency() :
NFC_EMULATION_TIME_MAX_MS);
} }
bool nfc_scene_emulate_on_event(void* context, SceneManagerEvent event) { bool nfc_scene_emulate_on_event(void* context, SceneManagerEvent event) {
@@ -49,7 +44,10 @@ bool nfc_scene_emulate_on_event(void* context, SceneManagerEvent event) {
} }
void nfc_scene_emulate_on_exit(void* context) { void nfc_scene_emulate_on_exit(void* context) {
furi_timer_stop(timer_auto_exit); if(timer_auto_exit) {
furi_timer_free(timer_auto_exit); furi_timer_stop(timer_auto_exit);
furi_timer_free(timer_auto_exit);
timer_auto_exit = NULL;
}
nfc_protocol_support_on_exit(NfcProtocolSupportSceneEmulate, context); nfc_protocol_support_on_exit(NfcProtocolSupportSceneEmulate, context);
} }