Skip to content

Commit

Permalink
[FL-2456] App notifications update (#1175)
Browse files Browse the repository at this point in the history
* Notifications update: SubGHz
* Notifications: ibutton, infrared, rfid
  • Loading branch information
nminaylov authored Apr 28, 2022
1 parent af5e03e commit 4526503
Show file tree
Hide file tree
Showing 29 changed files with 138 additions and 99 deletions.
1 change: 1 addition & 0 deletions applications/desktop/helpers/pin_lock.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ void desktop_pin_lock_init(DesktopSettings* settings) {
furi_hal_rtc_set_flag(FuriHalRtcFlagLock);
furi_hal_usb_disable();
} else {
furi_hal_rtc_set_pin_fails(0);
furi_hal_rtc_reset_flag(FuriHalRtcFlagLock);
furi_hal_usb_enable();
}
Expand Down
12 changes: 6 additions & 6 deletions applications/ibutton/ibutton_app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,16 +133,16 @@ uint8_t iButtonApp::get_file_name_size() {
return file_name_size;
}

void iButtonApp::notify_green_blink() {
notification_message(notification, &sequence_blink_green_10);
void iButtonApp::notify_read() {
notification_message(notification, &sequence_blink_cyan_10);
}

void iButtonApp::notify_yellow_blink() {
notification_message(notification, &sequence_blink_yellow_10);
void iButtonApp::notify_emulate() {
notification_message(notification, &sequence_blink_magenta_10);
}

void iButtonApp::notify_red_blink() {
notification_message(notification, &sequence_blink_red_10);
void iButtonApp::notify_yellow_blink() {
notification_message(notification, &sequence_blink_yellow_10);
}

void iButtonApp::notify_error() {
Expand Down
4 changes: 2 additions & 2 deletions applications/ibutton/ibutton_app.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ class iButtonApp {
iButtonWorker* get_key_worker();
iButtonKey* get_key();

void notify_green_blink();
void notify_read();
void notify_yellow_blink();
void notify_red_blink();
void notify_emulate();

void notify_error();
void notify_success();
Expand Down
2 changes: 1 addition & 1 deletion applications/ibutton/scene/ibutton_scene_emulate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ bool iButtonSceneEmulate::on_event(iButtonApp* app, iButtonEvent* event) {
app->notify_yellow_blink();
consumed = true;
} else if(event->type == iButtonEvent::Type::EventTypeTick) {
app->notify_red_blink();
app->notify_emulate();
consumed = true;
}

Expand Down
2 changes: 1 addition & 1 deletion applications/ibutton/scene/ibutton_scene_read.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ bool iButtonSceneRead::on_event(iButtonApp* app, iButtonEvent* event) {
}
} else if(event->type == iButtonEvent::Type::EventTypeTick) {
consumed = true;
app->notify_red_blink();
app->notify_read();
}

return consumed;
Expand Down
2 changes: 1 addition & 1 deletion applications/ibutton/scene/ibutton_scene_write.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ bool iButtonSceneWrite::on_event(iButtonApp* app, iButtonEvent* event) {
if(blink_yellow) {
app->notify_yellow_blink();
} else {
app->notify_red_blink();
app->notify_emulate();
}
}

Expand Down
44 changes: 5 additions & 39 deletions applications/infrared/infrared_app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,46 +211,12 @@ void InfraredApp::notify_success() {
notification_message(notification, &sequence_success);
}

void InfraredApp::notify_red_blink() {
notification_message(notification, &sequence_blink_red_10);
void InfraredApp::notify_blink_read() {
notification_message(notification, &sequence_blink_cyan_10);
}

void InfraredApp::notify_click() {
static const NotificationSequence sequence = {
&message_click,
&message_delay_1,
&message_sound_off,
NULL,
};

notification_message_block(notification, &sequence);
}

void InfraredApp::notify_click_and_green_blink() {
static const NotificationSequence sequence = {
&message_click,
&message_delay_1,
&message_sound_off,
&message_green_255,
&message_delay_10,
&message_green_0,
&message_do_not_reset,
NULL,
};

notification_message_block(notification, &sequence);
}

void InfraredApp::notify_blink_green() {
static const NotificationSequence sequence = {
&message_green_255,
&message_delay_10,
&message_green_0,
&message_do_not_reset,
NULL,
};

notification_message(notification, &sequence);
void InfraredApp::notify_blink_send() {
notification_message(notification, &sequence_blink_magenta_10);
}

DialogsApp* InfraredApp::get_dialogs() {
Expand Down Expand Up @@ -279,5 +245,5 @@ void InfraredApp::set_received_signal(const InfraredAppSignal& signal) {

void InfraredApp::signal_sent_callback(void* context) {
InfraredApp* app = static_cast<InfraredApp*>(context);
app->notify_blink_green();
app->notify_blink_send();
}
10 changes: 3 additions & 7 deletions applications/infrared/infrared_app.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,17 +217,13 @@ class InfraredApp {
/** Play success notification */
void notify_success();
/** Play red blink notification */
void notify_red_blink();
void notify_blink_read();
/** Light green */
void notify_green_on();
/** Disable green light */
void notify_green_off();
/** Play click sound */
void notify_click();
/** Play click and green notification */
void notify_click_and_green_blink();
/** Blink green light */
void notify_blink_green();
/** Blink on send */
void notify_blink_send();

/** Get Dialogs instance */
DialogsApp* get_dialogs();
Expand Down
2 changes: 1 addition & 1 deletion applications/infrared/scene/infrared_app_scene_learn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ bool InfraredAppSceneLearn::on_event(InfraredApp* app, InfraredAppEvent* event)
switch(event->type) {
case InfraredAppEvent::Type::Tick:
consumed = true;
app->notify_red_blink();
app->notify_blink_read();
break;
case InfraredAppEvent::Type::InfraredMessageReceived:
app->notify_success();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ bool InfraredAppSceneLearnSuccess::on_event(InfraredApp* app, InfraredAppEvent*
case DialogExPressCenter:
if(!button_pressed) {
button_pressed = true;
app->notify_click_and_green_blink();

auto signal = app->get_received_signal();
if(signal.is_raw()) {
Expand Down
3 changes: 0 additions & 3 deletions applications/infrared/scene/infrared_app_scene_remote.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,12 @@ bool InfraredAppSceneRemote::on_event(InfraredApp* app, InfraredAppEvent* event)
switch(event->payload.menu_index) {
case ButtonIndexPlus:
furi_assert(event->type == InfraredAppEvent::Type::MenuSelected);
app->notify_click();
buttonmenu_item_selected = event->payload.menu_index;
app->set_learn_new_remote(false);
app->switch_to_next_scene(InfraredApp::Scene::Learn);
break;
case ButtonIndexEdit:
furi_assert(event->type == InfraredAppEvent::Type::MenuSelected);
app->notify_click();
buttonmenu_item_selected = event->payload.menu_index;
app->switch_to_next_scene(InfraredApp::Scene::Edit);
break;
Expand All @@ -89,7 +87,6 @@ bool InfraredAppSceneRemote::on_event(InfraredApp* app, InfraredAppEvent* event)

if(pressed && !button_pressed) {
button_pressed = true;
app->notify_click_and_green_blink();

auto button_signal =
app->get_remote_manager()->get_button_data(event->payload.menu_index);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ bool InfraredAppSceneUniversalCommon::on_event(InfraredApp* app, InfraredAppEven
if(brute_force_started) {
if(event->type == InfraredAppEvent::Type::Tick) {
auto view_manager = app->get_view_manager();
app->notify_blink_send();
InfraredAppEvent tick_event = {.type = InfraredAppEvent::Type::Tick};
view_manager->send_event(&tick_event);
bool result = brute_force.send_next_bruteforce();
Expand All @@ -81,6 +82,7 @@ bool InfraredAppSceneUniversalCommon::on_event(InfraredApp* app, InfraredAppEven
DOLPHIN_DEED(DolphinDeedIrBruteForce);
brute_force_started = true;
show_popup(app, record_amount);
app->notify_blink_send();
} else {
app->switch_to_previous_scene();
}
Expand Down
2 changes: 1 addition & 1 deletion applications/lfrfid/scene/lfrfid_app_scene_emulate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ bool LfRfidAppSceneEmulate::on_event(LfRfidApp* app, LfRfidApp::Event* event) {
bool consumed = false;

if(event->type == LfRfidApp::EventType::Tick) {
notification_message(app->notification, &sequence_blink_cyan_10);
notification_message(app->notification, &sequence_blink_magenta_10);
}

return consumed;
Expand Down
4 changes: 2 additions & 2 deletions applications/lfrfid/scene/lfrfid_app_scene_read.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ bool LfRfidAppSceneRead::on_event(LfRfidApp* app, LfRfidApp::Event* event) {
if(app->worker.any_read()) {
notification_message(app->notification, &sequence_blink_green_10);
} else if(app->worker.detect()) {
notification_message(app->notification, &sequence_blink_blue_10);
notification_message(app->notification, &sequence_blink_cyan_10);
} else {
notification_message(app->notification, &sequence_blink_red_10);
notification_message(app->notification, &sequence_blink_cyan_10);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions applications/lfrfid/scene/lfrfid_app_scene_write.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ bool LfRfidAppSceneWrite::on_event(LfRfidApp* app, LfRfidApp::Event* event) {

switch(result) {
case RfidWorker::WriteResult::Nothing:
notification_message(app->notification, &sequence_blink_yellow_10);
notification_message(app->notification, &sequence_blink_magenta_10);
break;
case RfidWorker::WriteResult::Ok:
notification_message(app->notification, &sequence_success);
Expand All @@ -51,7 +51,7 @@ bool LfRfidAppSceneWrite::on_event(LfRfidApp* app, LfRfidApp::Event* event) {
AlignTop);
card_not_supported = true;
}
notification_message(app->notification, &sequence_blink_red_10);
notification_message(app->notification, &sequence_blink_yellow_10);
break;
}
}
Expand Down
7 changes: 7 additions & 0 deletions applications/notification/notification_messages.c
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,13 @@ const NotificationSequence sequence_blink_cyan_10 = {
NULL,
};

const NotificationSequence sequence_blink_magenta_10 = {
&message_red_255,
&message_blue_255,
&message_delay_10,
NULL,
};

const NotificationSequence sequence_blink_red_100 = {
&message_red_255,
&message_delay_100,
Expand Down
1 change: 1 addition & 0 deletions applications/notification/notification_messages.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ extern const NotificationSequence sequence_blink_red_10;
extern const NotificationSequence sequence_blink_green_10;
extern const NotificationSequence sequence_blink_yellow_10;
extern const NotificationSequence sequence_blink_cyan_10;
extern const NotificationSequence sequence_blink_magenta_10;

extern const NotificationSequence sequence_blink_red_100;
extern const NotificationSequence sequence_blink_green_100;
Expand Down
3 changes: 2 additions & 1 deletion applications/subghz/helpers/subghz_custom_event.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ typedef enum {
SubGhzCustomEventSceneShowErrorOk,
SubGhzCustomEventSceneShowErrorSub,
SubGhzCustomEventSceneShowOnlyRX,
SubGhzCustomEventSceneAnalyzerLock,
SubGhzCustomEventSceneAnalyzerUnlock,

SubGhzCustomEventSceneExit,
SubGhzCustomEventSceneStay,
Expand All @@ -35,7 +37,6 @@ typedef enum {
SubGhzCustomEventViewReadRAWSendStart,
SubGhzCustomEventViewReadRAWSendStop,
SubGhzCustomEventViewReadRAWSave,
SubGhzCustomEventViewReadRAWVibro,
SubGhzCustomEventViewReadRAWTXRXStop,
SubGhzCustomEventViewReadRAWMore,

Expand Down
14 changes: 12 additions & 2 deletions applications/subghz/scenes/subghz_scene_frequency_analyzer.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,20 @@ void subghz_scene_frequency_analyzer_on_enter(void* context) {
}

bool subghz_scene_frequency_analyzer_on_event(void* context, SceneManagerEvent event) {
//SubGhz* subghz = context;
SubGhz* subghz = context;
if(event.type == SceneManagerEventTypeCustom) {
if(event.event == SubGhzCustomEventSceneAnalyzerLock) {
notification_message(subghz->notifications, &sequence_set_green_255);
return true;
} else if(event.event == SubGhzCustomEventSceneAnalyzerUnlock) {
notification_message(subghz->notifications, &sequence_reset_rgb);
return true;
}
}
return false;
}

void subghz_scene_frequency_analyzer_on_exit(void* context) {
// SubGhz* subghz = context;
SubGhz* subghz = context;
notification_message(subghz->notifications, &sequence_reset_rgb);
}
29 changes: 18 additions & 11 deletions applications/subghz/scenes/subghz_scene_read_raw.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,7 @@ bool subghz_scene_read_raw_on_event(void* context, SceneManagerEvent event) {

case SubGhzCustomEventViewReadRAWErase:
subghz->txrx->rx_key_state = SubGhzRxKeyStateIDLE;
return true;
break;

case SubGhzCustomEventViewReadRAWVibro:
notification_message(subghz->notifications, &sequence_single_vibro);
notification_message(subghz->notifications, &sequence_reset_rgb);
return true;
break;

Expand Down Expand Up @@ -209,7 +205,7 @@ bool subghz_scene_read_raw_on_event(void* context, SceneManagerEvent event) {
(SubGhzProtocolEncoderRAW*)subghz->txrx->transmitter->protocol_instance,
subghz_scene_read_raw_callback_end_tx,
subghz);
subghz->state_notifications = SubGhzNotificationStateTX;
subghz->state_notifications = SubGhzNotificationStateTx;
}
}
}
Expand All @@ -231,6 +227,10 @@ bool subghz_scene_read_raw_on_event(void* context, SceneManagerEvent event) {
subghz_rx_end(subghz);
subghz_sleep(subghz);
};

size_t spl_count = subghz_protocol_raw_get_sample_write(
(SubGhzProtocolDecoderRAW*)subghz->txrx->decoder_result);

subghz_protocol_raw_save_to_file_stop(
(SubGhzProtocolDecoderRAW*)subghz->txrx->decoder_result);

Expand All @@ -241,6 +241,12 @@ bool subghz_scene_read_raw_on_event(void* context, SceneManagerEvent event) {
subghz_protocol_raw_gen_fff_data(subghz->txrx->fff_data, string_get_cstr(temp_str));
string_clear(temp_str);

if(spl_count > 0) {
notification_message(subghz->notifications, &sequence_set_green_255);
} else {
notification_message(subghz->notifications, &sequence_reset_rgb);
}

subghz->state_notifications = SubGhzNotificationStateIDLE;
subghz->txrx->rx_key_state = SubGhzRxKeyStateAddKey;

Expand All @@ -263,7 +269,7 @@ bool subghz_scene_read_raw_on_event(void* context, SceneManagerEvent event) {
subghz_begin(subghz, subghz->txrx->preset);
subghz_rx(subghz, subghz->txrx->frequency);
}
subghz->state_notifications = SubGhzNotificationStateRX;
subghz->state_notifications = SubGhzNotificationStateRx;
subghz->txrx->rx_key_state = SubGhzRxKeyStateAddKey;
} else {
string_set(subghz->error_str, "Function requires\nan SD card.");
Expand All @@ -288,16 +294,16 @@ bool subghz_scene_read_raw_on_event(void* context, SceneManagerEvent event) {
}
} else if(event.type == SceneManagerEventTypeTick) {
switch(subghz->state_notifications) {
case SubGhzNotificationStateRX:
notification_message(subghz->notifications, &sequence_blink_blue_10);
case SubGhzNotificationStateRx:
notification_message(subghz->notifications, &sequence_blink_cyan_10);
subghz_read_raw_update_sample_write(
subghz->subghz_read_raw,
subghz_protocol_raw_get_sample_write(
(SubGhzProtocolDecoderRAW*)subghz->txrx->decoder_result));
subghz_read_raw_add_data_rssi(subghz->subghz_read_raw, furi_hal_subghz_get_rssi());
break;
case SubGhzNotificationStateTX:
notification_message(subghz->notifications, &sequence_blink_green_10);
case SubGhzNotificationStateTx:
notification_message(subghz->notifications, &sequence_blink_magenta_10);
subghz_read_raw_update_sin(subghz->subghz_read_raw);
break;
default:
Expand All @@ -316,6 +322,7 @@ void subghz_scene_read_raw_on_exit(void* context) {
subghz_sleep(subghz);
};
subghz->state_notifications = SubGhzNotificationStateIDLE;
notification_message(subghz->notifications, &sequence_reset_rgb);

//filter restoration
subghz_receiver_set_filter(subghz->txrx->receiver, SubGhzProtocolFlag_Decodable);
Expand Down
Loading

0 comments on commit 4526503

Please sign in to comment.