Merge pull request #462 from gid9798/DecodeRAW_scenemanger

Using scene manager functions in DecodeRAW
This commit is contained in:
MX 2023-05-11 17:55:08 +03:00 committed by GitHub
commit de73ee8bfc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 22 additions and 36 deletions

View file

@ -91,3 +91,9 @@ typedef enum {
SubGhzViewReceiverModeLive,
SubGhzViewReceiverModeFile,
} SubGhzViewReceiverMode;
typedef enum {
SubGhzDecodeRawStateStart,
SubGhzDecodeRawStateLoading,
SubGhzDecodeRawStateLoaded,
} SubGhzDecodeRawState;

View file

@ -120,7 +120,8 @@ bool subghz_scene_decode_raw_next(SubGhz* subghz) {
uint32_t duration = level_duration_get_duration(level_duration);
subghz_receiver_decode(receiver, level, duration);
} else {
subghz->decode_raw_state = SubGhzDecodeRawStateLoaded;
scene_manager_set_scene_state(
subghz->scene_manager, SubGhzSceneDecodeRAW, SubGhzDecodeRawStateLoaded);
subghz->state_notifications = SubGhzNotificationStateIDLE;
subghz_view_receiver_add_data_progress(subghz->subghz_receiver, "Done!");
@ -155,11 +156,13 @@ void subghz_scene_decode_raw_on_enter(void* context) {
subghz_txrx_receiver_set_filter(subghz->txrx, SubGhzProtocolFlag_Decodable);
if(subghz->decode_raw_state == SubGhzDecodeRawStateStart) {
if(scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneDecodeRAW) ==
SubGhzDecodeRawStateStart) {
//Decode RAW to history
subghz_history_reset(subghz->history);
if(subghz_scene_decode_raw_start(subghz)) {
subghz->decode_raw_state = SubGhzDecodeRawStateLoading;
scene_manager_set_scene_state(
subghz->scene_manager, SubGhzSceneDecodeRAW, SubGhzDecodeRawStateLoading);
subghz->state_notifications = SubGhzNotificationStateRx;
}
} else {
@ -192,10 +195,9 @@ bool subghz_scene_decode_raw_on_event(void* context, SceneManagerEvent event) {
if(event.type == SceneManagerEventTypeCustom) {
switch(event.event) {
case SubGhzCustomEventViewReceiverBack:
subghz->decode_raw_state = SubGhzDecodeRawStateStart;
scene_manager_set_scene_state(
subghz->scene_manager, SubGhzSceneDecodeRAW, SubGhzDecodeRawStateStart);
subghz->idx_menu_chosen = 0;
subghz->in_decoder_scene = false;
subghz->in_decoder_scene_skip = false;
subghz_txrx_set_rx_calback(subghz->txrx, NULL, subghz);
@ -214,7 +216,6 @@ bool subghz_scene_decode_raw_on_event(void* context, SceneManagerEvent event) {
case SubGhzCustomEventViewReceiverOK:
subghz->idx_menu_chosen = subghz_view_receiver_get_idx_menu(subghz->subghz_receiver);
subghz->state_notifications = SubGhzNotificationStateIDLE;
subghz->in_decoder_scene = true;
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneReceiverInfo);
consumed = true;
break;
@ -242,7 +243,7 @@ bool subghz_scene_decode_raw_on_event(void* context, SceneManagerEvent event) {
break;
}
switch(subghz->decode_raw_state) {
switch(scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneDecodeRAW)) {
case SubGhzDecodeRawStateLoading:
subghz_scene_decode_raw_next(subghz);
break;

View file

@ -141,7 +141,7 @@ bool subghz_scene_receiver_info_on_event(void* context, SceneManagerEvent event)
subghz_scene_receiver_info_draw_widget(subghz);
subghz_txrx_stop(subghz->txrx);
if(!subghz->in_decoder_scene) {
if(!scene_manager_has_previous_scene(subghz->scene_manager, SubGhzSceneDecodeRAW)) {
subghz_txrx_rx_start(subghz->txrx);
subghz_txrx_hopper_unpause(subghz->txrx);
@ -161,9 +161,6 @@ bool subghz_scene_receiver_info_on_event(void* context, SceneManagerEvent event)
if(subghz_txrx_protocol_is_serializable(subghz->txrx)) {
subghz_file_name_clear(subghz);
if(subghz->in_decoder_scene) {
subghz->in_decoder_scene_skip = true;
}
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneSaveName);
}
return true;
@ -192,9 +189,7 @@ bool subghz_scene_receiver_info_on_event(void* context, SceneManagerEvent event)
void subghz_scene_receiver_info_on_exit(void* context) {
SubGhz* subghz = context;
if(subghz->in_decoder_scene && !subghz->in_decoder_scene_skip) {
subghz->in_decoder_scene = false;
}
widget_reset(subghz->widget);
keeloq_reset_mfname();
keeloq_reset_kl_type();

View file

@ -127,7 +127,7 @@ bool subghz_scene_save_name_on_event(void* context, SceneManagerEvent event) {
if(!(strcmp(subghz->file_name_tmp, "") == 0) ||
scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneReadRAW) !=
SubGhzCustomEventManagerNoSet) {
if(!subghz->in_decoder_scene) {
if(!scene_manager_has_previous_scene(subghz->scene_manager, SubGhzSceneDecodeRAW)) {
furi_string_set(subghz->file_path, subghz->file_path_tmp);
}
}

View file

@ -24,7 +24,7 @@ bool subghz_scene_save_success_on_event(void* context, SceneManagerEvent event)
SubGhz* subghz = context;
if(event.type == SceneManagerEventTypeCustom) {
if(event.event == SubGhzCustomEventSceneSaveSuccess) {
if(!subghz->in_decoder_scene) {
if(!scene_manager_has_previous_scene(subghz->scene_manager, SubGhzSceneDecodeRAW)) {
if(!scene_manager_search_and_switch_to_previous_scene(
subghz->scene_manager, SubGhzSceneReceiver)) {
subghz_rx_key_state_set(subghz, SubGhzRxKeyStateRAWSave);
@ -38,7 +38,9 @@ bool subghz_scene_save_success_on_event(void* context, SceneManagerEvent event)
}
}
} else {
subghz->decode_raw_state = SubGhzDecodeRawStateStart;
scene_manager_set_scene_state(
subghz->scene_manager, SubGhzSceneDecodeRAW, SubGhzDecodeRawStateStart);
subghz->idx_menu_chosen = 0;
subghz_txrx_set_rx_calback(subghz->txrx, NULL, subghz);
@ -64,11 +66,6 @@ bool subghz_scene_save_success_on_event(void* context, SceneManagerEvent event)
void subghz_scene_save_success_on_exit(void* context) {
SubGhz* subghz = context;
if(subghz->in_decoder_scene) {
subghz->in_decoder_scene = false;
subghz->in_decoder_scene_skip = false;
}
// Clear view
Popup* popup = subghz->popup;

View file

@ -60,9 +60,6 @@ SubGhz* subghz_alloc(bool alloc_for_tx_only) {
// GUI
subghz->gui = furi_record_open(RECORD_GUI);
subghz->in_decoder_scene = false;
subghz->in_decoder_scene_skip = false;
// View Dispatcher
subghz->view_dispatcher = view_dispatcher_alloc();
view_dispatcher_enable_queue(subghz->view_dispatcher);

View file

@ -54,12 +54,6 @@ typedef struct {
uint8_t seed[4];
} SecureData;
typedef enum {
SubGhzDecodeRawStateStart,
SubGhzDecodeRawStateLoading,
SubGhzDecodeRawStateLoaded,
} SubGhzDecodeRawState;
struct SubGhz {
Gui* gui;
NotificationApp* notifications;
@ -98,16 +92,12 @@ struct SubGhz {
FuriString* error_str;
SubGhzLock lock;
bool in_decoder_scene;
bool in_decoder_scene_skip;
bool ignore_starline;
bool ignore_auto_alarms;
bool ignore_magellan;
SecureData* secure_data;
SubGhzDecodeRawState decode_raw_state;
SubGhzFileEncoderWorker* decode_raw_file_worker_encoder;
SubGhzThresholdRssi* threshold_rssi;