[FL-2459, FL-2469]SubGhz: displaying a long name in RAW, launching files from subfolders, bugfix (#1125)
* SubGhz: fix the RAW file is not restored when it is launched from under the folder * SubGhz: fix does not fit long RAW file name * SubGhz: fix Read not cleared after file rename * SubGhz: fix restore default frequency and modulation on output * SubGhz: fix long name output in RAW
This commit is contained in:
		| @@ -21,7 +21,7 @@ void subghz_scene_delete_raw_on_enter(void* context) { | |||||||
|     string_init(frequency_str); |     string_init(frequency_str); | ||||||
|     string_init(modulation_str); |     string_init(modulation_str); | ||||||
|  |  | ||||||
|     char delete_str[64]; |     char delete_str[256]; | ||||||
|     snprintf(delete_str, sizeof(delete_str), "\e#Delete %s?\e#", subghz->file_name); |     snprintf(delete_str, sizeof(delete_str), "\e#Delete %s?\e#", subghz->file_name); | ||||||
|     widget_add_text_box_element( |     widget_add_text_box_element( | ||||||
|         subghz->widget, 0, 0, 128, 23, AlignCenter, AlignCenter, delete_str, false); |         subghz->widget, 0, 0, 128, 23, AlignCenter, AlignCenter, delete_str, false); | ||||||
|   | |||||||
| @@ -48,6 +48,8 @@ bool subghz_scene_need_saving_on_event(void* context, SceneManagerEvent event) { | |||||||
|         } else if(event.event == SubGhzCustomEventSceneExit) { |         } else if(event.event == SubGhzCustomEventSceneExit) { | ||||||
|             if(subghz->txrx->rx_key_state == SubGhzRxKeyStateExit) { |             if(subghz->txrx->rx_key_state == SubGhzRxKeyStateExit) { | ||||||
|                 subghz->txrx->rx_key_state = SubGhzRxKeyStateIDLE; |                 subghz->txrx->rx_key_state = SubGhzRxKeyStateIDLE; | ||||||
|  |                 subghz->txrx->frequency = subghz_setting_get_default_frequency(subghz->setting); | ||||||
|  |                 subghz->txrx->preset = FuriHalSubGhzPresetOok650Async; | ||||||
|                 scene_manager_search_and_switch_to_previous_scene( |                 scene_manager_search_and_switch_to_previous_scene( | ||||||
|                     subghz->scene_manager, SubGhzSceneStart); |                     subghz->scene_manager, SubGhzSceneStart); | ||||||
|             } else { |             } else { | ||||||
|   | |||||||
| @@ -230,7 +230,8 @@ bool subghz_scene_read_raw_on_event(void* context, SceneManagerEvent event) { | |||||||
|             }; |             }; | ||||||
|             subghz_protocol_raw_save_to_file_stop( |             subghz_protocol_raw_save_to_file_stop( | ||||||
|                 (SubGhzProtocolDecoderRAW*)subghz->txrx->decoder_result); |                 (SubGhzProtocolDecoderRAW*)subghz->txrx->decoder_result); | ||||||
|             subghz_protocol_raw_gen_fff_data(subghz->txrx->fff_data, RAW_FILE_NAME); |             subghz_protocol_raw_gen_fff_data( | ||||||
|  |                 subghz->txrx->fff_data, SUBGHZ_APP_FOLDER, RAW_FILE_NAME); | ||||||
|             subghz->state_notifications = SubGhzNotificationStateIDLE; |             subghz->state_notifications = SubGhzNotificationStateIDLE; | ||||||
|  |  | ||||||
|             subghz->txrx->rx_key_state = SubGhzRxKeyStateAddKey; |             subghz->txrx->rx_key_state = SubGhzRxKeyStateAddKey; | ||||||
|   | |||||||
| @@ -71,7 +71,10 @@ void subghz_scene_receiver_on_enter(void* context) { | |||||||
|     string_init(str_buff); |     string_init(str_buff); | ||||||
|  |  | ||||||
|     if(subghz->txrx->rx_key_state == SubGhzRxKeyStateIDLE) { |     if(subghz->txrx->rx_key_state == SubGhzRxKeyStateIDLE) { | ||||||
|  |         subghz->txrx->frequency = subghz_setting_get_default_frequency(subghz->setting); | ||||||
|  |         subghz->txrx->preset = FuriHalSubGhzPresetOok650Async; | ||||||
|         subghz_history_reset(subghz->txrx->history); |         subghz_history_reset(subghz->txrx->history); | ||||||
|  |         subghz->txrx->rx_key_state = SubGhzRxKeyStateStart; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     //Load history to receiver |     //Load history to receiver | ||||||
| @@ -120,8 +123,6 @@ bool subghz_scene_receiver_on_event(void* context, SceneManagerEvent event) { | |||||||
|                 subghz_sleep(subghz); |                 subghz_sleep(subghz); | ||||||
|             }; |             }; | ||||||
|             subghz->txrx->hopper_state = SubGhzHopperStateOFF; |             subghz->txrx->hopper_state = SubGhzHopperStateOFF; | ||||||
|             subghz->txrx->frequency = subghz_setting_get_default_frequency(subghz->setting); |  | ||||||
|             subghz->txrx->preset = FuriHalSubGhzPresetOok650Async; |  | ||||||
|             subghz->txrx->idx_menu_chosen = 0; |             subghz->txrx->idx_menu_chosen = 0; | ||||||
|             subghz_receiver_set_rx_callback(subghz->txrx->receiver, NULL, subghz); |             subghz_receiver_set_rx_callback(subghz->txrx->receiver, NULL, subghz); | ||||||
|  |  | ||||||
| @@ -129,6 +130,9 @@ bool subghz_scene_receiver_on_event(void* context, SceneManagerEvent event) { | |||||||
|                 subghz->txrx->rx_key_state = SubGhzRxKeyStateExit; |                 subghz->txrx->rx_key_state = SubGhzRxKeyStateExit; | ||||||
|                 scene_manager_next_scene(subghz->scene_manager, SubGhzSceneNeedSaving); |                 scene_manager_next_scene(subghz->scene_manager, SubGhzSceneNeedSaving); | ||||||
|             } else { |             } else { | ||||||
|  |                 subghz->txrx->rx_key_state = SubGhzRxKeyStateIDLE; | ||||||
|  |                 subghz->txrx->frequency = subghz_setting_get_default_frequency(subghz->setting); | ||||||
|  |                 subghz->txrx->preset = FuriHalSubGhzPresetOok650Async; | ||||||
|                 scene_manager_search_and_switch_to_previous_scene( |                 scene_manager_search_and_switch_to_previous_scene( | ||||||
|                     subghz->scene_manager, SubGhzSceneStart); |                     subghz->scene_manager, SubGhzSceneStart); | ||||||
|             } |             } | ||||||
|   | |||||||
| @@ -84,7 +84,8 @@ bool subghz_scene_save_name_on_event(void* context, SceneManagerEvent event) { | |||||||
|  |  | ||||||
|                 if(scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneReadRAW) != |                 if(scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneReadRAW) != | ||||||
|                    SubGhzCustomEventManagerNoSet) { |                    SubGhzCustomEventManagerNoSet) { | ||||||
|                     subghz_protocol_raw_gen_fff_data(subghz->txrx->fff_data, subghz->file_name); |                     subghz_protocol_raw_gen_fff_data( | ||||||
|  |                         subghz->txrx->fff_data, SUBGHZ_APP_FOLDER, subghz->file_name); | ||||||
|                     scene_manager_set_scene_state( |                     scene_manager_set_scene_state( | ||||||
|                         subghz->scene_manager, SubGhzSceneReadRAW, SubGhzCustomEventManagerNoSet); |                         subghz->scene_manager, SubGhzSceneReadRAW, SubGhzCustomEventManagerNoSet); | ||||||
|                 } else { |                 } else { | ||||||
|   | |||||||
| @@ -32,6 +32,7 @@ bool subghz_scene_save_success_on_event(void* context, SceneManagerEvent event) | |||||||
|                 subghz->txrx->rx_key_state = SubGhzRxKeyStateRAWSave; |                 subghz->txrx->rx_key_state = SubGhzRxKeyStateRAWSave; | ||||||
|                 if(!scene_manager_search_and_switch_to_previous_scene( |                 if(!scene_manager_search_and_switch_to_previous_scene( | ||||||
|                        subghz->scene_manager, SubGhzSceneReadRAW)) { |                        subghz->scene_manager, SubGhzSceneReadRAW)) { | ||||||
|  |                     subghz->txrx->rx_key_state = SubGhzRxKeyStateIDLE; | ||||||
|                     if(!scene_manager_search_and_switch_to_previous_scene( |                     if(!scene_manager_search_and_switch_to_previous_scene( | ||||||
|                            subghz->scene_manager, SubGhzSceneSaved)) { |                            subghz->scene_manager, SubGhzSceneSaved)) { | ||||||
|                         scene_manager_next_scene(subghz->scene_manager, SubGhzSceneSaved); |                         scene_manager_next_scene(subghz->scene_manager, SubGhzSceneSaved); | ||||||
|   | |||||||
| @@ -108,6 +108,8 @@ bool subghz_scene_transmitter_on_event(void* context, SceneManagerEvent event) { | |||||||
|  |  | ||||||
| void subghz_scene_transmitter_on_exit(void* context) { | void subghz_scene_transmitter_on_exit(void* context) { | ||||||
|     SubGhz* subghz = context; |     SubGhz* subghz = context; | ||||||
|  |     //Restore default setting | ||||||
|  |     subghz->txrx->frequency = subghz_setting_get_default_frequency(subghz->setting); | ||||||
|  |     subghz->txrx->preset = FuriHalSubGhzPresetOok650Async; | ||||||
|     subghz->state_notifications = SubGhzNotificationStateIDLE; |     subghz->state_notifications = SubGhzNotificationStateIDLE; | ||||||
| } | } | ||||||
|   | |||||||
| @@ -279,8 +279,13 @@ bool subghz_key_load(SubGhz* subghz, const char* file_path) { | |||||||
|             //if RAW |             //if RAW | ||||||
|             string_t file_name; |             string_t file_name; | ||||||
|             string_init(file_name); |             string_init(file_name); | ||||||
|  |             string_t path; | ||||||
|  |             string_init(path); | ||||||
|             path_extract_filename_no_ext(file_path, file_name); |             path_extract_filename_no_ext(file_path, file_name); | ||||||
|             subghz_protocol_raw_gen_fff_data(subghz->txrx->fff_data, string_get_cstr(file_name)); |             path_extract_dirname(file_path, path); | ||||||
|  |             subghz_protocol_raw_gen_fff_data( | ||||||
|  |                 subghz->txrx->fff_data, string_get_cstr(path), string_get_cstr(file_name)); | ||||||
|  |             string_clear(path); | ||||||
|             string_clear(file_name); |             string_clear(file_name); | ||||||
|  |  | ||||||
|         } else { |         } else { | ||||||
|   | |||||||
| @@ -34,7 +34,7 @@ | |||||||
|  |  | ||||||
| #include <gui/modules/variable_item_list.h> | #include <gui/modules/variable_item_list.h> | ||||||
|  |  | ||||||
| #define SUBGHZ_MAX_LEN_NAME 40 | #define SUBGHZ_MAX_LEN_NAME 128 | ||||||
|  |  | ||||||
| /** SubGhzNotification state */ | /** SubGhzNotification state */ | ||||||
| typedef enum { | typedef enum { | ||||||
| @@ -66,6 +66,7 @@ typedef enum { | |||||||
|     SubGhzRxKeyStateNoSave, |     SubGhzRxKeyStateNoSave, | ||||||
|     SubGhzRxKeyStateNeedSave, |     SubGhzRxKeyStateNeedSave, | ||||||
|     SubGhzRxKeyStateBack, |     SubGhzRxKeyStateBack, | ||||||
|  |     SubGhzRxKeyStateStart, | ||||||
|     SubGhzRxKeyStateAddKey, |     SubGhzRxKeyStateAddKey, | ||||||
|     SubGhzRxKeyStateExit, |     SubGhzRxKeyStateExit, | ||||||
|     SubGhzRxKeyStateRAWLoad, |     SubGhzRxKeyStateRAWLoad, | ||||||
|   | |||||||
| @@ -238,9 +238,9 @@ void subghz_read_raw_draw(Canvas* canvas, SubGhzReadRAWModel* model) { | |||||||
|         elements_text_box( |         elements_text_box( | ||||||
|             canvas, |             canvas, | ||||||
|             4, |             4, | ||||||
|             12, |             20, | ||||||
|             110, |             110, | ||||||
|             44, |             30, | ||||||
|             AlignCenter, |             AlignCenter, | ||||||
|             AlignCenter, |             AlignCenter, | ||||||
|             string_get_cstr(model->file_name), |             string_get_cstr(model->file_name), | ||||||
|   | |||||||
| @@ -293,7 +293,10 @@ static bool subghz_protocol_encoder_raw_worker_init(SubGhzProtocolEncoderRAW* in | |||||||
|     return instance->is_runing; |     return instance->is_runing; | ||||||
| } | } | ||||||
|  |  | ||||||
| void subghz_protocol_raw_gen_fff_data(FlipperFormat* flipper_format, const char* file_name) { | void subghz_protocol_raw_gen_fff_data( | ||||||
|  |     FlipperFormat* flipper_format, | ||||||
|  |     const char* path, | ||||||
|  |     const char* file_name) { | ||||||
|     string_t temp_str; |     string_t temp_str; | ||||||
|     string_init(temp_str); |     string_init(temp_str); | ||||||
|     do { |     do { | ||||||
| @@ -302,7 +305,7 @@ void subghz_protocol_raw_gen_fff_data(FlipperFormat* flipper_format, const char* | |||||||
|             FURI_LOG_E(TAG, "Unable to add Protocol"); |             FURI_LOG_E(TAG, "Unable to add Protocol"); | ||||||
|             break; |             break; | ||||||
|         } |         } | ||||||
|         string_printf(temp_str, "%s/%s%s", SUBGHZ_APP_FOLDER, file_name, SUBGHZ_APP_EXTENSION); |         string_printf(temp_str, "%s/%s%s", path, file_name, SUBGHZ_APP_EXTENSION); | ||||||
|  |  | ||||||
|         if(!flipper_format_write_string_cstr( |         if(!flipper_format_write_string_cstr( | ||||||
|                flipper_format, "File_name", string_get_cstr(temp_str))) { |                flipper_format, "File_name", string_get_cstr(temp_str))) { | ||||||
|   | |||||||
| @@ -113,9 +113,13 @@ void subghz_protocol_raw_file_encoder_worker_set_callback_end( | |||||||
| /** | /** | ||||||
|  * File generation for RAW work. |  * File generation for RAW work. | ||||||
|  * @param flipper_format Pointer to a FlipperFormat instance |  * @param flipper_format Pointer to a FlipperFormat instance | ||||||
|  |  * @param path File path | ||||||
|  * @param file_name File name |  * @param file_name File name | ||||||
|  */ |  */ | ||||||
| void subghz_protocol_raw_gen_fff_data(FlipperFormat* flipper_format, const char* file_name); | void subghz_protocol_raw_gen_fff_data( | ||||||
|  |     FlipperFormat* flipper_format, | ||||||
|  |     const char* path, | ||||||
|  |     const char* file_name); | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * Deserialize and generating an upload to send. |  * Deserialize and generating an upload to send. | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user