[FL-2456] App notifications update (#1175)
* Notifications update: SubGHz * Notifications: ibutton, infrared, rfid
This commit is contained in:
@@ -19,6 +19,8 @@ typedef enum {
|
||||
SubGhzCustomEventSceneShowErrorOk,
|
||||
SubGhzCustomEventSceneShowErrorSub,
|
||||
SubGhzCustomEventSceneShowOnlyRX,
|
||||
SubGhzCustomEventSceneAnalyzerLock,
|
||||
SubGhzCustomEventSceneAnalyzerUnlock,
|
||||
|
||||
SubGhzCustomEventSceneExit,
|
||||
SubGhzCustomEventSceneStay,
|
||||
@@ -35,7 +37,6 @@ typedef enum {
|
||||
SubGhzCustomEventViewReadRAWSendStart,
|
||||
SubGhzCustomEventViewReadRAWSendStop,
|
||||
SubGhzCustomEventViewReadRAWSave,
|
||||
SubGhzCustomEventViewReadRAWVibro,
|
||||
SubGhzCustomEventViewReadRAWTXRXStop,
|
||||
SubGhzCustomEventViewReadRAWMore,
|
||||
|
||||
|
@@ -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);
|
||||
}
|
||||
|
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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.");
|
||||
@@ -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:
|
||||
@@ -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);
|
||||
|
@@ -1,6 +1,19 @@
|
||||
#include "../subghz_i.h"
|
||||
#include "../views/receiver.h"
|
||||
|
||||
static const NotificationSequence subghs_sequence_rx = {
|
||||
&message_green_255,
|
||||
|
||||
&message_vibro_on,
|
||||
&message_note_c6,
|
||||
&message_delay_50,
|
||||
&message_sound_off,
|
||||
&message_vibro_off,
|
||||
|
||||
&message_delay_50,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static void subghz_scene_receiver_update_statusbar(void* context) {
|
||||
SubGhz* subghz = context;
|
||||
string_t history_stat_str;
|
||||
@@ -50,6 +63,8 @@ static void subghz_scene_add_to_history_callback(
|
||||
subghz_receiver_reset(receiver);
|
||||
string_reset(str_buff);
|
||||
|
||||
subghz->state_notifications = SubGhzNotificationStateRxDone;
|
||||
|
||||
subghz_history_get_text_item_menu(
|
||||
subghz->txrx->history, str_buff, subghz_history_get_item(subghz->txrx->history) - 1);
|
||||
subghz_view_receiver_add_item_to_menu(
|
||||
@@ -95,7 +110,7 @@ void subghz_scene_receiver_on_enter(void* context) {
|
||||
subghz_receiver_set_rx_callback(
|
||||
subghz->txrx->receiver, subghz_scene_add_to_history_callback, subghz);
|
||||
|
||||
subghz->state_notifications = SubGhzNotificationStateRX;
|
||||
subghz->state_notifications = SubGhzNotificationStateRx;
|
||||
if(subghz->txrx->txrx_state == SubGhzTxRxStateRx) {
|
||||
subghz_rx_end(subghz);
|
||||
};
|
||||
@@ -161,8 +176,12 @@ bool subghz_scene_receiver_on_event(void* context, SceneManagerEvent event) {
|
||||
}
|
||||
|
||||
switch(subghz->state_notifications) {
|
||||
case SubGhzNotificationStateRX:
|
||||
notification_message(subghz->notifications, &sequence_blink_blue_10);
|
||||
case SubGhzNotificationStateRx:
|
||||
notification_message(subghz->notifications, &sequence_blink_cyan_10);
|
||||
break;
|
||||
case SubGhzNotificationStateRxDone:
|
||||
notification_message(subghz->notifications, &subghs_sequence_rx);
|
||||
subghz->state_notifications = SubGhzNotificationStateRx;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@@ -126,7 +126,7 @@ bool subghz_scene_receiver_info_on_event(void* context, SceneManagerEvent event)
|
||||
subghz->txrx->history, subghz->txrx->idx_menu_chosen))) {
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowOnlyRx);
|
||||
} else {
|
||||
subghz->state_notifications = SubGhzNotificationStateTX;
|
||||
subghz->state_notifications = SubGhzNotificationStateTx;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@@ -143,7 +143,7 @@ bool subghz_scene_receiver_info_on_event(void* context, SceneManagerEvent event)
|
||||
if(subghz->txrx->hopper_state == SubGhzHopperStatePause) {
|
||||
subghz->txrx->hopper_state = SubGhzHopperStateRunnig;
|
||||
}
|
||||
subghz->state_notifications = SubGhzNotificationStateRX;
|
||||
subghz->state_notifications = SubGhzNotificationStateRx;
|
||||
return true;
|
||||
} else if(event.event == SubGhzCustomEventSceneReceiverInfoSave) {
|
||||
//CC1101 Stop RX -> Save
|
||||
@@ -171,11 +171,15 @@ bool subghz_scene_receiver_info_on_event(void* context, SceneManagerEvent event)
|
||||
subghz_hopper_update(subghz);
|
||||
}
|
||||
switch(subghz->state_notifications) {
|
||||
case SubGhzNotificationStateTX:
|
||||
notification_message(subghz->notifications, &sequence_blink_red_10);
|
||||
case SubGhzNotificationStateTx:
|
||||
notification_message(subghz->notifications, &sequence_blink_magenta_10);
|
||||
break;
|
||||
case SubGhzNotificationStateRX:
|
||||
notification_message(subghz->notifications, &sequence_blink_blue_10);
|
||||
case SubGhzNotificationStateRx:
|
||||
notification_message(subghz->notifications, &sequence_blink_cyan_10);
|
||||
break;
|
||||
case SubGhzNotificationStateRxDone:
|
||||
notification_message(subghz->notifications, &sequence_blink_green_100);
|
||||
subghz->state_notifications = SubGhzNotificationStateRx;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@@ -1,6 +1,13 @@
|
||||
#include "../subghz_i.h"
|
||||
#include "../helpers/subghz_custom_event.h"
|
||||
|
||||
static const NotificationSequence subghs_sequence_sd_error = {
|
||||
&message_red_255,
|
||||
&message_green_255,
|
||||
&message_do_not_reset,
|
||||
NULL,
|
||||
};
|
||||
|
||||
void subghz_scene_show_error_callback(GuiButtonType result, InputType type, void* context) {
|
||||
furi_assert(context);
|
||||
SubGhz* subghz = context;
|
||||
@@ -31,6 +38,8 @@ void subghz_scene_show_error_on_enter(void* context) {
|
||||
SubGhzCustomEventManagerSet) {
|
||||
widget_add_button_element(
|
||||
subghz->widget, GuiButtonTypeRight, "Ok", subghz_scene_show_error_callback, subghz);
|
||||
} else {
|
||||
notification_message(subghz->notifications, &subghs_sequence_sd_error);
|
||||
}
|
||||
|
||||
widget_add_button_element(
|
||||
@@ -81,4 +90,5 @@ void subghz_scene_show_error_on_exit(void* context) {
|
||||
subghz->scene_manager, SubGhzSceneShowError, SubGhzCustomEventManagerNoSet);
|
||||
widget_reset(subghz->widget);
|
||||
string_reset(subghz->error_str);
|
||||
notification_message(subghz->notifications, &sequence_reset_rgb);
|
||||
}
|
||||
|
@@ -18,6 +18,8 @@ void subghz_scene_show_error_sub_on_enter(void* context) {
|
||||
popup_set_callback(popup, subghz_scene_show_error_sub_popup_callback);
|
||||
popup_enable_timeout(popup);
|
||||
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewIdPopup);
|
||||
|
||||
notification_message(subghz->notifications, &sequence_set_red_255);
|
||||
}
|
||||
|
||||
bool subghz_scene_show_error_sub_on_event(void* context, SceneManagerEvent event) {
|
||||
@@ -45,4 +47,6 @@ void subghz_scene_show_error_sub_on_exit(void* context) {
|
||||
popup_set_timeout(popup, 0);
|
||||
popup_disable_timeout(popup);
|
||||
string_reset(subghz->error_str);
|
||||
|
||||
notification_message(subghz->notifications, &sequence_reset_rgb);
|
||||
}
|
||||
|
@@ -76,7 +76,7 @@ bool subghz_scene_transmitter_on_event(void* context, SceneManagerEvent event) {
|
||||
if(!subghz_tx_start(subghz, subghz->txrx->fff_data)) {
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowOnlyRx);
|
||||
} else {
|
||||
subghz->state_notifications = SubGhzNotificationStateTX;
|
||||
subghz->state_notifications = SubGhzNotificationStateTx;
|
||||
subghz_scene_transmitter_update_data_show(subghz);
|
||||
}
|
||||
}
|
||||
@@ -98,8 +98,8 @@ bool subghz_scene_transmitter_on_event(void* context, SceneManagerEvent event) {
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowErrorSub);
|
||||
}
|
||||
} else if(event.type == SceneManagerEventTypeTick) {
|
||||
if(subghz->state_notifications == SubGhzNotificationStateTX) {
|
||||
notification_message(subghz->notifications, &sequence_blink_red_10);
|
||||
if(subghz->state_notifications == SubGhzNotificationStateTx) {
|
||||
notification_message(subghz->notifications, &sequence_blink_magenta_10);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@@ -41,8 +41,9 @@
|
||||
typedef enum {
|
||||
SubGhzNotificationStateStarting,
|
||||
SubGhzNotificationStateIDLE,
|
||||
SubGhzNotificationStateTX,
|
||||
SubGhzNotificationStateRX,
|
||||
SubGhzNotificationStateTx,
|
||||
SubGhzNotificationStateRx,
|
||||
SubGhzNotificationStateRxDone,
|
||||
} SubGhzNotificationState;
|
||||
|
||||
/** SubGhzTxRx state */
|
||||
|
@@ -19,6 +19,7 @@ struct SubGhzFrequencyAnalyzer {
|
||||
SubGhzFrequencyAnalyzerWorker* worker;
|
||||
SubGhzFrequencyAnalyzerCallback callback;
|
||||
void* context;
|
||||
bool locked;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
@@ -86,6 +87,17 @@ bool subghz_frequency_analyzer_input(InputEvent* event, void* context) {
|
||||
|
||||
void subghz_frequency_analyzer_pair_callback(void* context, uint32_t frequency, float rssi) {
|
||||
SubGhzFrequencyAnalyzer* instance = context;
|
||||
if((rssi == 0.f) && (instance->locked)) {
|
||||
if(instance->callback) {
|
||||
instance->callback(SubGhzCustomEventSceneAnalyzerUnlock, instance->context);
|
||||
}
|
||||
} else if((rssi != 0.f) && (!instance->locked)) {
|
||||
if(instance->callback) {
|
||||
instance->callback(SubGhzCustomEventSceneAnalyzerLock, instance->context);
|
||||
}
|
||||
}
|
||||
|
||||
instance->locked = (rssi != 0.f);
|
||||
with_view_model(
|
||||
instance->view, (SubGhzFrequencyAnalyzerModel * model) {
|
||||
model->rssi = rssi;
|
||||
|
@@ -293,7 +293,6 @@ bool subghz_read_raw_input(InputEvent* event, void* context) {
|
||||
case SubGhzReadRAWStatusIDLE:
|
||||
// Start TX
|
||||
instance->callback(SubGhzCustomEventViewReadRAWSendStart, instance->context);
|
||||
instance->callback(SubGhzCustomEventViewReadRAWVibro, instance->context);
|
||||
model->satus = SubGhzReadRAWStatusTXRepeat;
|
||||
ret = true;
|
||||
break;
|
||||
@@ -304,7 +303,6 @@ bool subghz_read_raw_input(InputEvent* event, void* context) {
|
||||
case SubGhzReadRAWStatusLoadKeyIDLE:
|
||||
// Start Load Key TX
|
||||
instance->callback(SubGhzCustomEventViewReadRAWSendStart, instance->context);
|
||||
instance->callback(SubGhzCustomEventViewReadRAWVibro, instance->context);
|
||||
model->satus = SubGhzReadRAWStatusLoadKeyTXRepeat;
|
||||
ret = true;
|
||||
break;
|
||||
|
Reference in New Issue
Block a user