Skip to content

Commit

Permalink
[FL-2700] Fix IR hangup with short signals (#1535)
Browse files Browse the repository at this point in the history
* Do not use infrared worker callback for notifications
* Remove tx callback
* Port Infrared notifications to hardware blinker
* Move all blink message definitions to notification_messages.h
* Fix potential hangup after leaving debug scene
  • Loading branch information
gsurkov authored Aug 4, 2022
1 parent 4460010 commit 8a370d7
Show file tree
Hide file tree
Showing 15 changed files with 81 additions and 94 deletions.
19 changes: 0 additions & 19 deletions applications/ibutton/ibutton.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,6 @@

#define TAG "iButtonApp"

static const NotificationSequence sequence_blink_start_cyan = {
&message_blink_start_10,
&message_blink_set_color_cyan,
&message_do_not_reset,
NULL,
};

static const NotificationSequence sequence_blink_start_magenta = {
&message_blink_start_10,
&message_blink_set_color_magenta,
&message_do_not_reset,
NULL,
};

static const NotificationSequence sequence_blink_set_yellow = {
&message_blink_set_color_yellow,
NULL,
Expand All @@ -33,11 +19,6 @@ static const NotificationSequence sequence_blink_set_magenta = {
NULL,
};

static const NotificationSequence sequence_blink_stop = {
&message_blink_stop,
NULL,
};

static const NotificationSequence* ibutton_notification_sequences[] = {
&sequence_error,
&sequence_success,
Expand Down
18 changes: 9 additions & 9 deletions applications/infrared/infrared.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ static const NotificationSequence* infrared_notification_sequences[] = {
&sequence_success,
&sequence_set_only_green_255,
&sequence_reset_green,
&sequence_blink_cyan_10,
&sequence_blink_magenta_10,
&sequence_solid_yellow,
&sequence_reset_rgb};
&sequence_reset_rgb,
&sequence_blink_start_cyan,
&sequence_blink_start_magenta,
&sequence_blink_stop,
};

static void infrared_make_app_folder(Infrared* infrared) {
if(!storage_simply_mkdir(infrared->storage, INFRARED_APP_FOLDER)) {
Expand Down Expand Up @@ -301,6 +303,7 @@ void infrared_tx_start_signal(Infrared* infrared, InfraredSignal* signal) {

DOLPHIN_DEED(DolphinDeedIrSend);
infrared_worker_tx_start(infrared->worker);
infrared_play_notification_message(infrared, InfraredNotificationMessageBlinkStartSend);
}

void infrared_tx_start_button_index(Infrared* infrared, size_t button_index) {
Expand All @@ -310,14 +313,17 @@ void infrared_tx_start_button_index(Infrared* infrared, size_t button_index) {
InfraredSignal* signal = infrared_remote_button_get_signal(button);

infrared_tx_start_signal(infrared, signal);
infrared_play_notification_message(infrared, InfraredNotificationMessageBlinkStartSend);
}

void infrared_tx_start_received(Infrared* infrared) {
infrared_tx_start_signal(infrared, infrared->received_signal);
infrared_play_notification_message(infrared, InfraredNotificationMessageBlinkStartSend);
}

void infrared_tx_stop(Infrared* infrared) {
infrared_worker_tx_stop(infrared->worker);
infrared_play_notification_message(infrared, InfraredNotificationMessageBlinkStop);
}

void infrared_text_store_set(Infrared* infrared, uint32_t bank, const char* text, ...) {
Expand Down Expand Up @@ -354,12 +360,6 @@ void infrared_show_loading_popup(Infrared* infrared, bool show) {
}
}

void infrared_signal_sent_callback(void* context) {
furi_assert(context);
Infrared* infrared = context;
infrared_play_notification_message(infrared, InfraredNotificationMessageBlinkSend);
}

void infrared_signal_received_callback(void* context, InfraredWorkerSignal* received_signal) {
furi_assert(context);
Infrared* infrared = context;
Expand Down
6 changes: 3 additions & 3 deletions applications/infrared/infrared_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,11 @@ typedef enum {
InfraredNotificationMessageSuccess,
InfraredNotificationMessageGreenOn,
InfraredNotificationMessageGreenOff,
InfraredNotificationMessageBlinkRead,
InfraredNotificationMessageBlinkSend,
InfraredNotificationMessageYellowOn,
InfraredNotificationMessageYellowOff,
InfraredNotificationMessageBlinkStartRead,
InfraredNotificationMessageBlinkStartSend,
InfraredNotificationMessageBlinkStop,
} InfraredNotificationMessage;

bool infrared_add_remote_with_button(Infrared* infrared, const char* name, InfraredSignal* signal);
Expand All @@ -132,7 +133,6 @@ void infrared_text_store_clear(Infrared* infrared, uint32_t bank);
void infrared_play_notification_message(Infrared* infrared, uint32_t message);
void infrared_show_loading_popup(Infrared* infrared, bool show);

void infrared_signal_sent_callback(void* context);
void infrared_signal_received_callback(void* context, InfraredWorkerSignal* received_signal);
void infrared_text_input_callback(void* context);
void infrared_popup_closed_callback(void* context);
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ static void infrared_scene_universal_common_show_popup(Infrared* infrared, uint3
infrared_progress_view_set_back_callback(
progress, infrared_scene_universal_common_progress_back_callback, infrared);
view_stack_add_view(view_stack, infrared_progress_view_get_view(progress));
infrared_play_notification_message(infrared, InfraredNotificationMessageBlinkStartSend);
}

static void infrared_scene_universal_common_hide_popup(Infrared* infrared) {
ViewStack* view_stack = infrared->view_stack;
InfraredProgressView* progress = infrared->progress;
view_stack_remove_view(view_stack, infrared_progress_view_get_view(progress));
infrared_play_notification_message(infrared, InfraredNotificationMessageBlinkStop);
}

void infrared_scene_universal_common_on_enter(void* context) {
Expand All @@ -42,7 +44,6 @@ bool infrared_scene_universal_common_on_event(void* context, SceneManagerEvent e

if(infrared_brute_force_is_started(brute_force)) {
if(event.type == SceneManagerEventTypeTick) {
infrared_play_notification_message(infrared, InfraredNotificationMessageBlinkSend);
bool success = infrared_brute_force_send_next(brute_force);
if(success) {
success = infrared_progress_view_increase_progress(infrared->progress);
Expand Down Expand Up @@ -71,8 +72,6 @@ bool infrared_scene_universal_common_on_event(void* context, SceneManagerEvent e
brute_force, infrared_custom_event_get_value(event.event), &record_count)) {
DOLPHIN_DEED(DolphinDeedIrBruteForce);
infrared_scene_universal_common_show_popup(infrared, record_count);
infrared_play_notification_message(
infrared, InfraredNotificationMessageBlinkSend);
} else {
scene_manager_next_scene(scene_manager, InfraredSceneErrorDatabases);
}
Expand Down
1 change: 1 addition & 0 deletions applications/infrared/scenes/infrared_scene_debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,5 @@ void infrared_scene_debug_on_exit(void* context) {
InfraredWorker* worker = infrared->worker;
infrared_worker_rx_stop(worker);
infrared_worker_rx_enable_blink_on_receiving(worker, false);
infrared_worker_rx_set_received_signal_callback(worker, NULL, NULL);
}
7 changes: 3 additions & 4 deletions applications/infrared/scenes/infrared_scene_learn.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ void infrared_scene_learn_on_enter(void* context) {
infrared_worker_rx_set_received_signal_callback(
worker, infrared_signal_received_callback, context);
infrared_worker_rx_start(worker);
infrared_play_notification_message(infrared, InfraredNotificationMessageBlinkStartRead);

popup_set_icon(popup, 0, 32, &I_InfraredLearnShort_128x31);
popup_set_header(popup, NULL, 0, 0, AlignCenter, AlignCenter);
Expand All @@ -22,10 +23,7 @@ bool infrared_scene_learn_on_event(void* context, SceneManagerEvent event) {
Infrared* infrared = context;
bool consumed = false;

if(event.type == SceneManagerEventTypeTick) {
infrared_play_notification_message(infrared, InfraredNotificationMessageBlinkRead);
consumed = true;
} else if(event.type == SceneManagerEventTypeCustom) {
if(event.type == SceneManagerEventTypeCustom) {
if(event.event == InfraredCustomEventTypeSignalReceived) {
infrared_worker_rx_set_received_signal_callback(infrared->worker, NULL, NULL);
infrared_play_notification_message(infrared, InfraredNotificationMessageSuccess);
Expand All @@ -41,6 +39,7 @@ void infrared_scene_learn_on_exit(void* context) {
Infrared* infrared = context;
Popup* popup = infrared->popup;
infrared_worker_rx_stop(infrared->worker);
infrared_play_notification_message(infrared, InfraredNotificationMessageBlinkStop);
popup_set_icon(popup, 0, 0, NULL);
popup_set_text(popup, NULL, 0, 0, AlignCenter, AlignCenter);
}
7 changes: 4 additions & 3 deletions applications/infrared/scenes/infrared_scene_learn_success.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ void infrared_scene_learn_success_on_enter(void* context) {

infrared_worker_tx_set_get_signal_callback(
infrared->worker, infrared_worker_tx_get_signal_steady_callback, context);
infrared_worker_tx_set_signal_sent_callback(
infrared->worker, infrared_signal_sent_callback, context);

if(infrared_signal_is_raw(signal)) {
InfraredRawSignal* raw = infrared_signal_get_raw_signal(signal);
Expand Down Expand Up @@ -104,13 +102,16 @@ bool infrared_scene_learn_success_on_event(void* context, SceneManagerEvent even
InfraredSceneLearnSuccess,
InfraredSceneLearnSuccessStateSending);
infrared_tx_start_received(infrared);
infrared_play_notification_message(
infrared, InfraredNotificationMessageBlinkStartSend);
}
consumed = true;
} else if(event.event == DialogExReleaseCenter) {
if(scene_state == InfraredSceneLearnSuccessStateSending) {
scene_manager_set_scene_state(
scene_manager, InfraredSceneLearnSuccess, InfraredSceneLearnSuccessStateIdle);
infrared_tx_stop(infrared);
infrared_play_notification_message(infrared, InfraredNotificationMessageBlinkStop);
infrared_play_notification_message(infrared, InfraredNotificationMessageGreenOff);
}
consumed = true;
Expand All @@ -124,7 +125,7 @@ void infrared_scene_learn_success_on_exit(void* context) {
Infrared* infrared = context;
InfraredWorker* worker = infrared->worker;
dialog_ex_reset(infrared->dialog_ex);
infrared_play_notification_message(infrared, InfraredNotificationMessageBlinkStop);
infrared_play_notification_message(infrared, InfraredNotificationMessageGreenOff);
infrared_worker_tx_set_get_signal_callback(worker, NULL, NULL);
infrared_worker_tx_set_signal_sent_callback(worker, NULL, NULL);
}
4 changes: 1 addition & 3 deletions applications/infrared/scenes/infrared_scene_remote.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ void infrared_scene_remote_on_enter(void* context) {

infrared_worker_tx_set_get_signal_callback(
infrared->worker, infrared_worker_tx_get_signal_steady_callback, infrared);
infrared_worker_tx_set_signal_sent_callback(
infrared->worker, infrared_signal_sent_callback, infrared);

size_t button_count = infrared_remote_get_button_count(remote);
for(size_t i = 0; i < button_count; ++i) {
Expand Down Expand Up @@ -112,7 +110,7 @@ bool infrared_scene_remote_on_event(void* context, SceneManagerEvent event) {

void infrared_scene_remote_on_exit(void* context) {
Infrared* infrared = context;
infrared_tx_stop(infrared);
infrared_worker_tx_set_get_signal_callback(infrared->worker, NULL, NULL);
infrared_worker_tx_set_signal_sent_callback(infrared->worker, NULL, NULL);
button_menu_reset(infrared->button_menu);
}
3 changes: 1 addition & 2 deletions applications/infrared/scenes/infrared_scene_rpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ bool infrared_scene_rpc_on_event(void* context, SceneManagerEvent event) {
result = infrared_remote_load(infrared->remote, infrared->file_path);
infrared_worker_tx_set_get_signal_callback(
infrared->worker, infrared_worker_tx_get_signal_steady_callback, infrared);
infrared_worker_tx_set_signal_sent_callback(
infrared->worker, infrared_signal_sent_callback, infrared);
}
const char* remote_name = infrared_remote_get_name(infrared->remote);

Expand Down Expand Up @@ -74,5 +72,6 @@ bool infrared_scene_rpc_on_event(void* context, SceneManagerEvent event) {

void infrared_scene_rpc_on_exit(void* context) {
Infrared* infrared = context;
infrared_tx_stop(infrared);
popup_reset(infrared->popup);
}
12 changes: 0 additions & 12 deletions applications/lfrfid/scene/lfrfid_app_scene_emulate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,6 @@
#include <core/common_defines.h>
#include <dolphin/dolphin.h>

static const NotificationSequence sequence_blink_start_magenta = {
&message_blink_start_10,
&message_blink_set_color_magenta,
&message_do_not_reset,
NULL,
};

static const NotificationSequence sequence_blink_stop = {
&message_blink_stop,
NULL,
};

void LfRfidAppSceneEmulate::on_enter(LfRfidApp* app, bool /* need_restore */) {
string_init(data_string);

Expand Down
12 changes: 0 additions & 12 deletions applications/lfrfid/scene/lfrfid_app_scene_rpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,6 @@
#include <dolphin/dolphin.h>
#include <rpc/rpc_app.h>

static const NotificationSequence sequence_blink_start_magenta = {
&message_blink_start_10,
&message_blink_set_color_magenta,
&message_do_not_reset,
NULL,
};

static const NotificationSequence sequence_blink_stop = {
&message_blink_stop,
NULL,
};

void LfRfidAppSceneRpc::on_enter(LfRfidApp* app, bool /* need_restore */) {
auto popup = app->view_controller.get<PopupVM>();

Expand Down
12 changes: 0 additions & 12 deletions applications/nfc/nfc.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,18 +199,6 @@ void nfc_text_store_clear(Nfc* nfc) {
memset(nfc->text_store, 0, sizeof(nfc->text_store));
}

static const NotificationSequence sequence_blink_start_blue = {
&message_blink_start_10,
&message_blink_set_color_blue,
&message_do_not_reset,
NULL,
};

static const NotificationSequence sequence_blink_stop = {
&message_blink_stop,
NULL,
};

void nfc_blink_start(Nfc* nfc) {
notification_message(nfc->notifications, &sequence_blink_start_blue);
}
Expand Down
48 changes: 48 additions & 0 deletions applications/notification/notification_messages.c
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,54 @@ const NotificationSequence sequence_blink_white_100 = {
NULL,
};

// Hardware blink
const NotificationSequence sequence_blink_start_blue = {
&message_blink_start_10,
&message_blink_set_color_blue,
&message_do_not_reset,
NULL,
};

const NotificationSequence sequence_blink_start_red = {
&message_blink_start_10,
&message_blink_set_color_red,
&message_do_not_reset,
NULL,
};

const NotificationSequence sequence_blink_start_green = {
&message_blink_start_10,
&message_blink_set_color_green,
&message_do_not_reset,
NULL,
};

const NotificationSequence sequence_blink_start_yellow = {
&message_blink_start_10,
&message_blink_set_color_yellow,
&message_do_not_reset,
NULL,
};

const NotificationSequence sequence_blink_start_cyan = {
&message_blink_start_10,
&message_blink_set_color_cyan,
&message_do_not_reset,
NULL,
};

const NotificationSequence sequence_blink_start_magenta = {
&message_blink_start_10,
&message_blink_set_color_magenta,
&message_do_not_reset,
NULL,
};

const NotificationSequence sequence_blink_stop = {
&message_blink_stop,
NULL,
};

//General
const NotificationSequence sequence_single_vibro = {
&message_vibro_on,
Expand Down
9 changes: 9 additions & 0 deletions applications/notification/notification_messages.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,15 @@ extern const NotificationSequence sequence_blink_cyan_100;
extern const NotificationSequence sequence_blink_magenta_100;
extern const NotificationSequence sequence_blink_white_100;

// Hardware blink
extern const NotificationSequence sequence_blink_start_blue;
extern const NotificationSequence sequence_blink_start_red;
extern const NotificationSequence sequence_blink_start_green;
extern const NotificationSequence sequence_blink_start_yellow;
extern const NotificationSequence sequence_blink_start_cyan;
extern const NotificationSequence sequence_blink_start_magenta;
extern const NotificationSequence sequence_blink_stop;

// General
extern const NotificationSequence sequence_single_vibro;
extern const NotificationSequence sequence_double_vibro;
Expand Down
12 changes: 0 additions & 12 deletions applications/subghz/subghz.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,6 @@
#include "subghz_i.h"
#include <lib/toolbox/path.h>

static const NotificationSequence sequence_blink_start_magenta = {
&message_blink_start_10,
&message_blink_set_color_magenta,
&message_do_not_reset,
NULL,
};

static const NotificationSequence sequence_blink_stop = {
&message_blink_stop,
NULL,
};

bool subghz_custom_event_callback(void* context, uint32_t event) {
furi_assert(context);
SubGhz* subghz = context;
Expand Down

0 comments on commit 8a370d7

Please sign in to comment.