mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2025-12-12 12:42:30 +04:00
make loading subghz file from favourites a bit faster
This commit is contained in:
@@ -134,12 +134,22 @@ bool subghz_scene_read_raw_on_event(void* context, SceneManagerEvent event) {
|
|||||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneNeedSaving);
|
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneNeedSaving);
|
||||||
} else {
|
} else {
|
||||||
//Restore default setting
|
//Restore default setting
|
||||||
|
if(subghz->raw_send_only) {
|
||||||
subghz_preset_init(
|
subghz_preset_init(
|
||||||
subghz,
|
subghz,
|
||||||
subghz_setting_get_preset_name(subghz->setting, subghz->last_settings->preset),
|
"AM650",
|
||||||
|
subghz_setting_get_default_frequency(subghz->setting),
|
||||||
|
NULL,
|
||||||
|
0);
|
||||||
|
} else {
|
||||||
|
subghz_preset_init(
|
||||||
|
subghz,
|
||||||
|
subghz_setting_get_preset_name(
|
||||||
|
subghz->setting, subghz->last_settings->preset),
|
||||||
subghz->last_settings->frequency,
|
subghz->last_settings->frequency,
|
||||||
NULL,
|
NULL,
|
||||||
0);
|
0);
|
||||||
|
}
|
||||||
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)) {
|
||||||
if(!scene_manager_search_and_switch_to_previous_scene(
|
if(!scene_manager_search_and_switch_to_previous_scene(
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ void subghz_blink_stop(SubGhz* instance) {
|
|||||||
notification_message(instance->notifications, &sequence_blink_stop);
|
notification_message(instance->notifications, &sequence_blink_stop);
|
||||||
}
|
}
|
||||||
|
|
||||||
SubGhz* subghz_alloc() {
|
SubGhz* subghz_alloc(bool alloc_for_tx_only) {
|
||||||
SubGhz* subghz = malloc(sizeof(SubGhz));
|
SubGhz* subghz = malloc(sizeof(SubGhz));
|
||||||
|
|
||||||
string_init(subghz->file_path);
|
string_init(subghz->file_path);
|
||||||
@@ -88,6 +88,7 @@ SubGhz* subghz_alloc() {
|
|||||||
// Open Notification record
|
// Open Notification record
|
||||||
subghz->notifications = furi_record_open(RECORD_NOTIFICATION);
|
subghz->notifications = furi_record_open(RECORD_NOTIFICATION);
|
||||||
|
|
||||||
|
if(!alloc_for_tx_only) {
|
||||||
// SubMenu
|
// SubMenu
|
||||||
subghz->submenu = submenu_alloc();
|
subghz->submenu = submenu_alloc();
|
||||||
view_dispatcher_add_view(
|
view_dispatcher_add_view(
|
||||||
@@ -99,27 +100,31 @@ SubGhz* subghz_alloc() {
|
|||||||
subghz->view_dispatcher,
|
subghz->view_dispatcher,
|
||||||
SubGhzViewIdReceiver,
|
SubGhzViewIdReceiver,
|
||||||
subghz_view_receiver_get_view(subghz->subghz_receiver));
|
subghz_view_receiver_get_view(subghz->subghz_receiver));
|
||||||
|
}
|
||||||
// Popup
|
// Popup
|
||||||
subghz->popup = popup_alloc();
|
subghz->popup = popup_alloc();
|
||||||
view_dispatcher_add_view(
|
view_dispatcher_add_view(
|
||||||
subghz->view_dispatcher, SubGhzViewIdPopup, popup_get_view(subghz->popup));
|
subghz->view_dispatcher, SubGhzViewIdPopup, popup_get_view(subghz->popup));
|
||||||
|
if(!alloc_for_tx_only) {
|
||||||
// Text Input
|
// Text Input
|
||||||
subghz->text_input = text_input_alloc();
|
subghz->text_input = text_input_alloc();
|
||||||
view_dispatcher_add_view(
|
view_dispatcher_add_view(
|
||||||
subghz->view_dispatcher, SubGhzViewIdTextInput, text_input_get_view(subghz->text_input));
|
subghz->view_dispatcher,
|
||||||
|
SubGhzViewIdTextInput,
|
||||||
|
text_input_get_view(subghz->text_input));
|
||||||
|
|
||||||
// Byte Input
|
// Byte Input
|
||||||
subghz->byte_input = byte_input_alloc();
|
subghz->byte_input = byte_input_alloc();
|
||||||
view_dispatcher_add_view(
|
view_dispatcher_add_view(
|
||||||
subghz->view_dispatcher, SubGhzViewIdByteInput, byte_input_get_view(subghz->byte_input));
|
subghz->view_dispatcher,
|
||||||
|
SubGhzViewIdByteInput,
|
||||||
|
byte_input_get_view(subghz->byte_input));
|
||||||
|
|
||||||
// Custom Widget
|
// Custom Widget
|
||||||
subghz->widget = widget_alloc();
|
subghz->widget = widget_alloc();
|
||||||
view_dispatcher_add_view(
|
view_dispatcher_add_view(
|
||||||
subghz->view_dispatcher, SubGhzViewIdWidget, widget_get_view(subghz->widget));
|
subghz->view_dispatcher, SubGhzViewIdWidget, widget_get_view(subghz->widget));
|
||||||
|
}
|
||||||
//Dialog
|
//Dialog
|
||||||
subghz->dialogs = furi_record_open(RECORD_DIALOGS);
|
subghz->dialogs = furi_record_open(RECORD_DIALOGS);
|
||||||
|
|
||||||
@@ -129,7 +134,7 @@ SubGhz* subghz_alloc() {
|
|||||||
subghz->view_dispatcher,
|
subghz->view_dispatcher,
|
||||||
SubGhzViewIdTransmitter,
|
SubGhzViewIdTransmitter,
|
||||||
subghz_view_transmitter_get_view(subghz->subghz_transmitter));
|
subghz_view_transmitter_get_view(subghz->subghz_transmitter));
|
||||||
|
if(!alloc_for_tx_only) {
|
||||||
// Variable Item List
|
// Variable Item List
|
||||||
subghz->variable_item_list = variable_item_list_alloc();
|
subghz->variable_item_list = variable_item_list_alloc();
|
||||||
view_dispatcher_add_view(
|
view_dispatcher_add_view(
|
||||||
@@ -143,9 +148,9 @@ SubGhz* subghz_alloc() {
|
|||||||
subghz->view_dispatcher,
|
subghz->view_dispatcher,
|
||||||
SubGhzViewIdFrequencyAnalyzer,
|
SubGhzViewIdFrequencyAnalyzer,
|
||||||
subghz_frequency_analyzer_get_view(subghz->subghz_frequency_analyzer));
|
subghz_frequency_analyzer_get_view(subghz->subghz_frequency_analyzer));
|
||||||
|
}
|
||||||
// Read RAW
|
// Read RAW
|
||||||
subghz->subghz_read_raw = subghz_read_raw_alloc();
|
subghz->subghz_read_raw = subghz_read_raw_alloc(alloc_for_tx_only);
|
||||||
view_dispatcher_add_view(
|
view_dispatcher_add_view(
|
||||||
subghz->view_dispatcher,
|
subghz->view_dispatcher,
|
||||||
SubGhzViewIdReadRAW,
|
SubGhzViewIdReadRAW,
|
||||||
@@ -176,9 +181,14 @@ SubGhz* subghz_alloc() {
|
|||||||
|
|
||||||
//init setting
|
//init setting
|
||||||
subghz->setting = subghz_setting_alloc();
|
subghz->setting = subghz_setting_alloc();
|
||||||
subghz_setting_load(subghz->setting, EXT_PATH("subghz/assets/setting_user"));
|
if(alloc_for_tx_only) {
|
||||||
|
subghz_setting_load(subghz->setting, EXT_PATH("subghz/assets/setting_user"), false);
|
||||||
|
} else {
|
||||||
|
subghz_setting_load(subghz->setting, EXT_PATH("subghz/assets/setting_user"), true);
|
||||||
|
}
|
||||||
|
|
||||||
// Load last used values for Read, Read RAW, etc. or default
|
// Load last used values for Read, Read RAW, etc. or default
|
||||||
|
if(!alloc_for_tx_only) {
|
||||||
subghz->last_settings = subghz_last_settings_alloc();
|
subghz->last_settings = subghz_last_settings_alloc();
|
||||||
subghz_last_settings_load(
|
subghz_last_settings_load(
|
||||||
subghz->last_settings, subghz_setting_get_preset_count(subghz->setting));
|
subghz->last_settings, subghz_setting_get_preset_count(subghz->setting));
|
||||||
@@ -190,24 +200,32 @@ SubGhz* subghz_alloc() {
|
|||||||
subghz->last_settings->preset);
|
subghz->last_settings->preset);
|
||||||
#endif
|
#endif
|
||||||
subghz_setting_set_default_frequency(subghz->setting, subghz->last_settings->frequency);
|
subghz_setting_set_default_frequency(subghz->setting, subghz->last_settings->frequency);
|
||||||
|
}
|
||||||
//init Worker & Protocol & History & KeyBoard
|
//init Worker & Protocol & History & KeyBoard
|
||||||
subghz->lock = SubGhzLockOff;
|
subghz->lock = SubGhzLockOff;
|
||||||
subghz->txrx = malloc(sizeof(SubGhzTxRx));
|
subghz->txrx = malloc(sizeof(SubGhzTxRx));
|
||||||
subghz->txrx->preset = malloc(sizeof(SubGhzPresetDefinition));
|
subghz->txrx->preset = malloc(sizeof(SubGhzPresetDefinition));
|
||||||
string_init(subghz->txrx->preset->name);
|
string_init(subghz->txrx->preset->name);
|
||||||
|
if(!alloc_for_tx_only) {
|
||||||
subghz_preset_init(
|
subghz_preset_init(
|
||||||
subghz,
|
subghz,
|
||||||
subghz_setting_get_preset_name(subghz->setting, subghz->last_settings->preset),
|
subghz_setting_get_preset_name(subghz->setting, subghz->last_settings->preset),
|
||||||
subghz->last_settings->frequency,
|
subghz->last_settings->frequency,
|
||||||
NULL,
|
NULL,
|
||||||
0);
|
0);
|
||||||
|
} else {
|
||||||
|
subghz_preset_init(
|
||||||
|
subghz, "AM650", subghz_setting_get_default_frequency(subghz->setting), NULL, 0);
|
||||||
|
}
|
||||||
subghz->txrx->txrx_state = SubGhzTxRxStateSleep;
|
subghz->txrx->txrx_state = SubGhzTxRxStateSleep;
|
||||||
subghz->txrx->hopper_state = SubGhzHopperStateOFF;
|
subghz->txrx->hopper_state = SubGhzHopperStateOFF;
|
||||||
subghz->txrx->rx_key_state = SubGhzRxKeyStateIDLE;
|
subghz->txrx->rx_key_state = SubGhzRxKeyStateIDLE;
|
||||||
|
if(!alloc_for_tx_only) {
|
||||||
subghz->txrx->history = subghz_history_alloc();
|
subghz->txrx->history = subghz_history_alloc();
|
||||||
|
}
|
||||||
|
if(!alloc_for_tx_only) {
|
||||||
subghz->txrx->worker = subghz_worker_alloc();
|
subghz->txrx->worker = subghz_worker_alloc();
|
||||||
|
}
|
||||||
subghz->txrx->fff_data = flipper_format_string_alloc();
|
subghz->txrx->fff_data = flipper_format_string_alloc();
|
||||||
subghz->txrx->secure_data = malloc(sizeof(SecureData));
|
subghz->txrx->secure_data = malloc(sizeof(SecureData));
|
||||||
|
|
||||||
@@ -216,14 +234,17 @@ SubGhz* subghz_alloc() {
|
|||||||
subghz->txrx->environment, EXT_PATH("subghz/assets/came_atomo"));
|
subghz->txrx->environment, EXT_PATH("subghz/assets/came_atomo"));
|
||||||
subghz_environment_set_nice_flor_s_rainbow_table_file_name(
|
subghz_environment_set_nice_flor_s_rainbow_table_file_name(
|
||||||
subghz->txrx->environment, EXT_PATH("subghz/assets/nice_flor_s"));
|
subghz->txrx->environment, EXT_PATH("subghz/assets/nice_flor_s"));
|
||||||
|
|
||||||
subghz->txrx->receiver = subghz_receiver_alloc_init(subghz->txrx->environment);
|
subghz->txrx->receiver = subghz_receiver_alloc_init(subghz->txrx->environment);
|
||||||
subghz_receiver_set_filter(subghz->txrx->receiver, SubGhzProtocolFlag_Decodable);
|
subghz_receiver_set_filter(subghz->txrx->receiver, SubGhzProtocolFlag_Decodable);
|
||||||
|
|
||||||
|
if(!alloc_for_tx_only) {
|
||||||
subghz_worker_set_overrun_callback(
|
subghz_worker_set_overrun_callback(
|
||||||
subghz->txrx->worker, (SubGhzWorkerOverrunCallback)subghz_receiver_reset);
|
subghz->txrx->worker, (SubGhzWorkerOverrunCallback)subghz_receiver_reset);
|
||||||
subghz_worker_set_pair_callback(
|
subghz_worker_set_pair_callback(
|
||||||
subghz->txrx->worker, (SubGhzWorkerPairCallback)subghz_receiver_decode);
|
subghz->txrx->worker, (SubGhzWorkerPairCallback)subghz_receiver_decode);
|
||||||
subghz_worker_set_context(subghz->txrx->worker, subghz->txrx->receiver);
|
subghz_worker_set_context(subghz->txrx->worker, subghz->txrx->receiver);
|
||||||
|
}
|
||||||
|
|
||||||
//Init Error_str
|
//Init Error_str
|
||||||
string_init(subghz->error_str);
|
string_init(subghz->error_str);
|
||||||
@@ -231,7 +252,7 @@ SubGhz* subghz_alloc() {
|
|||||||
return subghz;
|
return subghz;
|
||||||
}
|
}
|
||||||
|
|
||||||
void subghz_free(SubGhz* subghz) {
|
void subghz_free(SubGhz* subghz, bool alloc_for_tx_only) {
|
||||||
furi_assert(subghz);
|
furi_assert(subghz);
|
||||||
|
|
||||||
if(subghz->rpc_ctx) {
|
if(subghz->rpc_ctx) {
|
||||||
@@ -254,6 +275,8 @@ void subghz_free(SubGhz* subghz) {
|
|||||||
view_dispatcher_remove_view(subghz->view_dispatcher, SubGhzViewIdStatic);
|
view_dispatcher_remove_view(subghz->view_dispatcher, SubGhzViewIdStatic);
|
||||||
subghz_test_static_free(subghz->subghz_test_static);
|
subghz_test_static_free(subghz->subghz_test_static);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if(!alloc_for_tx_only) {
|
||||||
// Receiver
|
// Receiver
|
||||||
view_dispatcher_remove_view(subghz->view_dispatcher, SubGhzViewIdReceiver);
|
view_dispatcher_remove_view(subghz->view_dispatcher, SubGhzViewIdReceiver);
|
||||||
subghz_view_receiver_free(subghz->subghz_receiver);
|
subghz_view_receiver_free(subghz->subghz_receiver);
|
||||||
@@ -269,14 +292,14 @@ void subghz_free(SubGhz* subghz) {
|
|||||||
// Custom Widget
|
// Custom Widget
|
||||||
view_dispatcher_remove_view(subghz->view_dispatcher, SubGhzViewIdWidget);
|
view_dispatcher_remove_view(subghz->view_dispatcher, SubGhzViewIdWidget);
|
||||||
widget_free(subghz->widget);
|
widget_free(subghz->widget);
|
||||||
|
}
|
||||||
//Dialog
|
//Dialog
|
||||||
furi_record_close(RECORD_DIALOGS);
|
furi_record_close(RECORD_DIALOGS);
|
||||||
|
|
||||||
// Transmitter
|
// Transmitter
|
||||||
view_dispatcher_remove_view(subghz->view_dispatcher, SubGhzViewIdTransmitter);
|
view_dispatcher_remove_view(subghz->view_dispatcher, SubGhzViewIdTransmitter);
|
||||||
subghz_view_transmitter_free(subghz->subghz_transmitter);
|
subghz_view_transmitter_free(subghz->subghz_transmitter);
|
||||||
|
if(!alloc_for_tx_only) {
|
||||||
// Variable Item List
|
// Variable Item List
|
||||||
view_dispatcher_remove_view(subghz->view_dispatcher, SubGhzViewIdVariableItemList);
|
view_dispatcher_remove_view(subghz->view_dispatcher, SubGhzViewIdVariableItemList);
|
||||||
variable_item_list_free(subghz->variable_item_list);
|
variable_item_list_free(subghz->variable_item_list);
|
||||||
@@ -284,15 +307,15 @@ void subghz_free(SubGhz* subghz) {
|
|||||||
// Frequency Analyzer
|
// Frequency Analyzer
|
||||||
view_dispatcher_remove_view(subghz->view_dispatcher, SubGhzViewIdFrequencyAnalyzer);
|
view_dispatcher_remove_view(subghz->view_dispatcher, SubGhzViewIdFrequencyAnalyzer);
|
||||||
subghz_frequency_analyzer_free(subghz->subghz_frequency_analyzer);
|
subghz_frequency_analyzer_free(subghz->subghz_frequency_analyzer);
|
||||||
|
}
|
||||||
// Read RAW
|
// Read RAW
|
||||||
view_dispatcher_remove_view(subghz->view_dispatcher, SubGhzViewIdReadRAW);
|
view_dispatcher_remove_view(subghz->view_dispatcher, SubGhzViewIdReadRAW);
|
||||||
subghz_read_raw_free(subghz->subghz_read_raw);
|
subghz_read_raw_free(subghz->subghz_read_raw);
|
||||||
|
if(!alloc_for_tx_only) {
|
||||||
// Submenu
|
// Submenu
|
||||||
view_dispatcher_remove_view(subghz->view_dispatcher, SubGhzViewIdMenu);
|
view_dispatcher_remove_view(subghz->view_dispatcher, SubGhzViewIdMenu);
|
||||||
submenu_free(subghz->submenu);
|
submenu_free(subghz->submenu);
|
||||||
|
}
|
||||||
// Popup
|
// Popup
|
||||||
view_dispatcher_remove_view(subghz->view_dispatcher, SubGhzViewIdPopup);
|
view_dispatcher_remove_view(subghz->view_dispatcher, SubGhzViewIdPopup);
|
||||||
popup_free(subghz->popup);
|
popup_free(subghz->popup);
|
||||||
@@ -309,14 +332,21 @@ void subghz_free(SubGhz* subghz) {
|
|||||||
|
|
||||||
//setting
|
//setting
|
||||||
subghz_setting_free(subghz->setting);
|
subghz_setting_free(subghz->setting);
|
||||||
|
if(!alloc_for_tx_only) {
|
||||||
subghz_last_settings_free(subghz->last_settings);
|
subghz_last_settings_free(subghz->last_settings);
|
||||||
|
}
|
||||||
//Worker & Protocol & History
|
//Worker & Protocol & History
|
||||||
|
|
||||||
subghz_receiver_free(subghz->txrx->receiver);
|
subghz_receiver_free(subghz->txrx->receiver);
|
||||||
|
|
||||||
subghz_environment_free(subghz->txrx->environment);
|
subghz_environment_free(subghz->txrx->environment);
|
||||||
|
if(!alloc_for_tx_only) {
|
||||||
subghz_worker_free(subghz->txrx->worker);
|
subghz_worker_free(subghz->txrx->worker);
|
||||||
|
}
|
||||||
flipper_format_free(subghz->txrx->fff_data);
|
flipper_format_free(subghz->txrx->fff_data);
|
||||||
|
if(!alloc_for_tx_only) {
|
||||||
subghz_history_free(subghz->txrx->history);
|
subghz_history_free(subghz->txrx->history);
|
||||||
|
}
|
||||||
string_clear(subghz->txrx->preset->name);
|
string_clear(subghz->txrx->preset->name);
|
||||||
free(subghz->txrx->preset);
|
free(subghz->txrx->preset);
|
||||||
free(subghz->txrx->secure_data);
|
free(subghz->txrx->secure_data);
|
||||||
@@ -338,7 +368,20 @@ void subghz_free(SubGhz* subghz) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int32_t subghz_app(void* p) {
|
int32_t subghz_app(void* p) {
|
||||||
SubGhz* subghz = subghz_alloc();
|
bool alloc_for_tx;
|
||||||
|
if(p && strlen(p)) {
|
||||||
|
alloc_for_tx = true;
|
||||||
|
} else {
|
||||||
|
alloc_for_tx = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
SubGhz* subghz = subghz_alloc(alloc_for_tx);
|
||||||
|
|
||||||
|
if(alloc_for_tx) {
|
||||||
|
subghz->raw_send_only = true;
|
||||||
|
} else {
|
||||||
|
subghz->raw_send_only = false;
|
||||||
|
}
|
||||||
|
|
||||||
//Load database
|
//Load database
|
||||||
bool load_database = subghz_environment_load_keystore(
|
bool load_database = subghz_environment_load_keystore(
|
||||||
@@ -397,7 +440,7 @@ int32_t subghz_app(void* p) {
|
|||||||
|
|
||||||
furi_hal_power_suppress_charge_exit();
|
furi_hal_power_suppress_charge_exit();
|
||||||
|
|
||||||
subghz_free(subghz);
|
subghz_free(subghz, alloc_for_tx);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -97,6 +97,7 @@ struct SubGhz {
|
|||||||
|
|
||||||
SubGhzFrequencyAnalyzer* subghz_frequency_analyzer;
|
SubGhzFrequencyAnalyzer* subghz_frequency_analyzer;
|
||||||
SubGhzReadRAW* subghz_read_raw;
|
SubGhzReadRAW* subghz_read_raw;
|
||||||
|
bool raw_send_only;
|
||||||
#if FURI_DEBUG
|
#if FURI_DEBUG
|
||||||
SubGhzTestStatic* subghz_test_static;
|
SubGhzTestStatic* subghz_test_static;
|
||||||
SubGhzTestCarrier* subghz_test_carrier;
|
SubGhzTestCarrier* subghz_test_carrier;
|
||||||
|
|||||||
@@ -181,7 +181,7 @@ void subghz_setting_load_default(SubGhzSetting* instance) {
|
|||||||
instance, subghz_frequency_list, subghz_hopper_frequency_list);
|
instance, subghz_frequency_list, subghz_hopper_frequency_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
void subghz_setting_load(SubGhzSetting* instance, const char* file_path) {
|
void subghz_setting_load(SubGhzSetting* instance, const char* file_path, bool not_skip_frequencies) {
|
||||||
furi_assert(instance);
|
furi_assert(instance);
|
||||||
|
|
||||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||||
@@ -214,6 +214,7 @@ void subghz_setting_load(SubGhzSetting* instance, const char* file_path) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Standard frequencies (optional)
|
// Standard frequencies (optional)
|
||||||
|
if(not_skip_frequencies) {
|
||||||
temp_bool = true;
|
temp_bool = true;
|
||||||
flipper_format_read_bool(fff_data_file, "Add_standard_frequencies", &temp_bool, 1);
|
flipper_format_read_bool(fff_data_file, "Add_standard_frequencies", &temp_bool, 1);
|
||||||
if(!temp_bool) {
|
if(!temp_bool) {
|
||||||
@@ -259,9 +260,11 @@ void subghz_setting_load(SubGhzSetting* instance, const char* file_path) {
|
|||||||
FURI_LOG_E(TAG, "Rewind error");
|
FURI_LOG_E(TAG, "Rewind error");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(flipper_format_read_uint32(fff_data_file, "Default_frequency", &temp_data32, 1)) {
|
if(flipper_format_read_uint32(
|
||||||
|
fff_data_file, "Default_frequency", &temp_data32, 1)) {
|
||||||
subghz_setting_set_default_frequency(instance, temp_data32);
|
subghz_setting_set_default_frequency(instance, temp_data32);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// custom preset (optional)
|
// custom preset (optional)
|
||||||
if(!flipper_format_rewind(fff_data_file)) {
|
if(!flipper_format_rewind(fff_data_file)) {
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ SubGhzSetting* subghz_setting_alloc(void);
|
|||||||
|
|
||||||
void subghz_setting_free(SubGhzSetting* instance);
|
void subghz_setting_free(SubGhzSetting* instance);
|
||||||
|
|
||||||
void subghz_setting_load(SubGhzSetting* instance, const char* file_path);
|
void subghz_setting_load(SubGhzSetting* instance, const char* file_path, bool not_skip_frequencies);
|
||||||
|
|
||||||
size_t subghz_setting_get_frequency_count(SubGhzSetting* instance);
|
size_t subghz_setting_get_frequency_count(SubGhzSetting* instance);
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ typedef struct {
|
|||||||
uint8_t ind_write;
|
uint8_t ind_write;
|
||||||
uint8_t ind_sin;
|
uint8_t ind_sin;
|
||||||
SubGhzReadRAWStatus status;
|
SubGhzReadRAWStatus status;
|
||||||
|
bool raw_send_only;
|
||||||
} SubGhzReadRAWModel;
|
} SubGhzReadRAWModel;
|
||||||
|
|
||||||
void subghz_read_raw_set_callback(
|
void subghz_read_raw_set_callback(
|
||||||
@@ -232,9 +233,11 @@ void subghz_read_raw_draw(Canvas* canvas, SubGhzReadRAWModel* model) {
|
|||||||
elements_button_right(canvas, "Save");
|
elements_button_right(canvas, "Save");
|
||||||
break;
|
break;
|
||||||
case SubGhzReadRAWStatusLoadKeyIDLE:
|
case SubGhzReadRAWStatusLoadKeyIDLE:
|
||||||
|
if(!model->raw_send_only) {
|
||||||
elements_button_left(canvas, "New");
|
elements_button_left(canvas, "New");
|
||||||
elements_button_center(canvas, "Send");
|
|
||||||
elements_button_right(canvas, "More");
|
elements_button_right(canvas, "More");
|
||||||
|
}
|
||||||
|
elements_button_center(canvas, "Send");
|
||||||
elements_text_box(
|
elements_text_box(
|
||||||
canvas,
|
canvas,
|
||||||
4,
|
4,
|
||||||
@@ -362,6 +365,7 @@ bool subghz_read_raw_input(InputEvent* event, void* context) {
|
|||||||
} else if(event->key == InputKeyLeft && event->type == InputTypeShort) {
|
} else if(event->key == InputKeyLeft && event->type == InputTypeShort) {
|
||||||
with_view_model(
|
with_view_model(
|
||||||
instance->view, (SubGhzReadRAWModel * model) {
|
instance->view, (SubGhzReadRAWModel * model) {
|
||||||
|
if(!model->raw_send_only) {
|
||||||
if(model->status == SubGhzReadRAWStatusStart) {
|
if(model->status == SubGhzReadRAWStatusStart) {
|
||||||
//Config
|
//Config
|
||||||
instance->callback(SubGhzCustomEventViewReadRAWConfig, instance->context);
|
instance->callback(SubGhzCustomEventViewReadRAWConfig, instance->context);
|
||||||
@@ -376,11 +380,13 @@ bool subghz_read_raw_input(InputEvent* event, void* context) {
|
|||||||
string_reset(model->file_name);
|
string_reset(model->file_name);
|
||||||
instance->callback(SubGhzCustomEventViewReadRAWErase, instance->context);
|
instance->callback(SubGhzCustomEventViewReadRAWErase, instance->context);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
} else if(event->key == InputKeyRight && event->type == InputTypeShort) {
|
} else if(event->key == InputKeyRight && event->type == InputTypeShort) {
|
||||||
with_view_model(
|
with_view_model(
|
||||||
instance->view, (SubGhzReadRAWModel * model) {
|
instance->view, (SubGhzReadRAWModel * model) {
|
||||||
|
if(!model->raw_send_only) {
|
||||||
if(model->status == SubGhzReadRAWStatusIDLE) {
|
if(model->status == SubGhzReadRAWStatusIDLE) {
|
||||||
//Save
|
//Save
|
||||||
instance->callback(SubGhzCustomEventViewReadRAWSave, instance->context);
|
instance->callback(SubGhzCustomEventViewReadRAWSave, instance->context);
|
||||||
@@ -388,6 +394,7 @@ bool subghz_read_raw_input(InputEvent* event, void* context) {
|
|||||||
//More
|
//More
|
||||||
instance->callback(SubGhzCustomEventViewReadRAWMore, instance->context);
|
instance->callback(SubGhzCustomEventViewReadRAWMore, instance->context);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
} else if(event->key == InputKeyOk && event->type == InputTypeShort) {
|
} else if(event->key == InputKeyOk && event->type == InputTypeShort) {
|
||||||
@@ -487,7 +494,7 @@ void subghz_read_raw_exit(void* context) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
SubGhzReadRAW* subghz_read_raw_alloc() {
|
SubGhzReadRAW* subghz_read_raw_alloc(bool raw_send_only) {
|
||||||
SubGhzReadRAW* instance = malloc(sizeof(SubGhzReadRAW));
|
SubGhzReadRAW* instance = malloc(sizeof(SubGhzReadRAW));
|
||||||
|
|
||||||
// View allocation and configuration
|
// View allocation and configuration
|
||||||
@@ -505,6 +512,7 @@ SubGhzReadRAW* subghz_read_raw_alloc() {
|
|||||||
string_init(model->preset_str);
|
string_init(model->preset_str);
|
||||||
string_init(model->sample_write);
|
string_init(model->sample_write);
|
||||||
string_init(model->file_name);
|
string_init(model->file_name);
|
||||||
|
model->raw_send_only = raw_send_only;
|
||||||
model->rssi_history = malloc(SUBGHZ_READ_RAW_RSSI_HISTORY_SIZE * sizeof(uint8_t));
|
model->rssi_history = malloc(SUBGHZ_READ_RAW_RSSI_HISTORY_SIZE * sizeof(uint8_t));
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ void subghz_read_raw_set_callback(
|
|||||||
SubGhzReadRAWCallback callback,
|
SubGhzReadRAWCallback callback,
|
||||||
void* context);
|
void* context);
|
||||||
|
|
||||||
SubGhzReadRAW* subghz_read_raw_alloc();
|
SubGhzReadRAW* subghz_read_raw_alloc(bool raw_send_only);
|
||||||
|
|
||||||
void subghz_read_raw_free(SubGhzReadRAW* subghz_static);
|
void subghz_read_raw_free(SubGhzReadRAW* subghz_static);
|
||||||
|
|
||||||
|
|||||||
@@ -827,7 +827,7 @@ static void input_callback(InputEvent* input_event, void* ctx) {
|
|||||||
void unirfremix_subghz_alloc(UniRFRemix* app) {
|
void unirfremix_subghz_alloc(UniRFRemix* app) {
|
||||||
// load subghz presets
|
// load subghz presets
|
||||||
app->setting = subghz_setting_alloc();
|
app->setting = subghz_setting_alloc();
|
||||||
subghz_setting_load(app->setting, EXT_PATH("subghz/assets/setting_user"));
|
subghz_setting_load(app->setting, EXT_PATH("subghz/assets/setting_user"), false);
|
||||||
|
|
||||||
// load mfcodes
|
// load mfcodes
|
||||||
app->environment = subghz_environment_alloc();
|
app->environment = subghz_environment_alloc();
|
||||||
|
|||||||
Reference in New Issue
Block a user