diff --git a/app.c b/app.c index 0f860d08e9a..d0a5ca74403 100644 --- a/app.c +++ b/app.c @@ -118,6 +118,7 @@ ProtoViewApp* protoview_app_alloc() { // GUI app->gui = furi_record_open(RECORD_GUI); + app->notification = furi_record_open(RECORD_NOTIFICATION); app->view_port = view_port_alloc(); view_port_draw_callback_set(app->view_port, render_callback, app); view_port_input_callback_set(app->view_port, input_callback, app); @@ -189,6 +190,7 @@ void protoview_app_free(ProtoViewApp *app) { gui_remove_view_port(app->gui, app->view_port); view_port_free(app->view_port); furi_record_close(RECORD_GUI); + furi_record_close(RECORD_NOTIFICATION); furi_message_queue_free(app->event_queue); app->gui = NULL; diff --git a/app.h b/app.h index c1e17b5d0aa..f5b0d5ec512 100644 --- a/app.h +++ b/app.h @@ -120,6 +120,7 @@ typedef struct ProtoViewMsgInfo { struct ProtoViewApp { /* GUI */ Gui *gui; + NotificationApp *notification; ViewPort *view_port; /* We just use a raw viewport and we render everything into the low level canvas. */ ProtoViewCurrentView current_view; /* Active left-right view ID. */ diff --git a/signal.c b/signal.c index 1ea195245ca..4646d47977f 100644 --- a/signal.c +++ b/signal.c @@ -120,6 +120,31 @@ uint32_t search_coherent_signal(RawSamplesBuffer *s, uint32_t idx) { return len; } +/* Called when we detect a message. Just blinks when the message was + * not decoded. Vibrates, too, when the message was correctly decoded. */ +void notify_signal_detected(ProtoViewApp *app, bool decoded) { + static const NotificationSequence decoded_seq = { + &message_vibro_on, + &message_green_255, + &message_delay_50, + &message_green_0, + &message_vibro_off, + NULL + }; + + static const NotificationSequence unknown_seq = { + &message_red_255, + &message_delay_50, + &message_red_0, + NULL + }; + + if (decoded) + notification_message(app->notification, &decoded_seq); + else + notification_message(app->notification, &unknown_seq); +} + /* Search the buffer with the stored signal (last N samples received) * in order to find a coherent signal. If a signal that does not appear to * be just noise is found, it is set in DetectedSamples global signal @@ -179,6 +204,7 @@ void scan_for_signal(ProtoViewApp *app) { app->us_scale = 10; else if (DetectedSamples->short_pulse_dur < 145) app->us_scale = 30; + notify_signal_detected(app,decoded); } else { /* If the structure was not filled, discard it. Otherwise * now the owner is app->msg_info. */ diff --git a/view_info.c b/view_info.c index fd7dd09cebc..53947285b1c 100644 --- a/view_info.c +++ b/view_info.c @@ -236,6 +236,19 @@ LevelDuration radio_tx_feed_data(void *ctx) { return level_duration_reset(); } +/* Vibrate and produce a click sound when a signal is sent. */ +void notify_signal_sent(ProtoViewApp *app) { + static const NotificationSequence sent_seq = { + &message_vibro_on, + &message_note_g1, + &message_delay_10, + &message_sound_off, + &message_vibro_off, + NULL + }; + notification_message(app->notification, &sent_seq); +} + /* Handle input for the info view. */ void process_input_info(ProtoViewApp *app, InputEvent input) { if (process_subview_updown(app,input,SubViewInfoLast)) return; @@ -265,6 +278,7 @@ void process_input_info(ProtoViewApp *app, InputEvent input) { SendSignalCtx send_state; send_signal_init(&send_state,app); radio_tx_signal(app,radio_tx_feed_data,&send_state); + notify_signal_sent(app); } } }