mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-13 05:08:35 -07:00
Update multi fuzzer and subghz remote
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
#ifndef SUBREM_LIGHT
|
||||
ADD_SCENE(subrem, start, Start)
|
||||
#endif
|
||||
ADD_SCENE(subrem, open_map_file, OpenMapFile)
|
||||
ADD_SCENE(subrem, remote, Remote)
|
||||
ADD_SCENE(subrem, remote, Remote)
|
||||
ADD_SCENE(subrem, edit_menu, EditMenu)
|
||||
ADD_SCENE(subrem, edit_submenu, EditSubMenu)
|
||||
ADD_SCENE(subrem, edit_label, EditLabel)
|
||||
ADD_SCENE(subrem, open_sub_file, OpenSubFile)
|
||||
ADD_SCENE(subrem, edit_preview, EditPreview)
|
||||
ADD_SCENE(subrem, enter_new_name, EnterNewName)
|
||||
133
applications/external/subghz_remote/scenes/subrem_scene_edit_label.c
vendored
Normal file
133
applications/external/subghz_remote/scenes/subrem_scene_edit_label.c
vendored
Normal file
@@ -0,0 +1,133 @@
|
||||
#include "../subghz_remote_app_i.h"
|
||||
|
||||
#include <lib/toolbox/path.h>
|
||||
|
||||
typedef enum {
|
||||
SubRemSceneEditLabelStateTextInput,
|
||||
SubRemSceneEditLabelStateWidget,
|
||||
} SubRemSceneEditLabelState;
|
||||
|
||||
void subrem_scene_edit_label_text_input_callback(void* context) {
|
||||
furi_assert(context);
|
||||
SubGhzRemoteApp* app = context;
|
||||
view_dispatcher_send_custom_event(
|
||||
app->view_dispatcher, SubRemCustomEventSceneEditLabelInputDone);
|
||||
}
|
||||
|
||||
void subrem_scene_edit_label_widget_callback(GuiButtonType result, InputType type, void* context) {
|
||||
furi_assert(context);
|
||||
SubGhzRemoteApp* app = context;
|
||||
if((result == GuiButtonTypeCenter) && (type == InputTypeShort)) {
|
||||
view_dispatcher_send_custom_event(
|
||||
app->view_dispatcher, SubRemCustomEventSceneEditLabelWidgetAcces);
|
||||
} else if((result == GuiButtonTypeLeft) && (type == InputTypeShort)) {
|
||||
view_dispatcher_send_custom_event(
|
||||
app->view_dispatcher, SubRemCustomEventSceneEditLabelWidgetBack);
|
||||
}
|
||||
}
|
||||
|
||||
void subrem_scene_edit_label_on_enter(void* context) {
|
||||
SubGhzRemoteApp* app = context;
|
||||
|
||||
SubRemSubFilePreset* sub_preset = app->map_preset->subs_preset[app->chusen_sub];
|
||||
|
||||
FuriString* temp_str = furi_string_alloc();
|
||||
|
||||
if(furi_string_empty(sub_preset->label)) {
|
||||
if(furi_string_empty(sub_preset->file_path)) {
|
||||
path_extract_filename(sub_preset->file_path, temp_str, true);
|
||||
strcpy(app->file_name_tmp, furi_string_get_cstr(temp_str));
|
||||
} else {
|
||||
strcpy(app->file_name_tmp, "");
|
||||
}
|
||||
} else {
|
||||
strcpy(app->file_name_tmp, furi_string_get_cstr(sub_preset->label));
|
||||
}
|
||||
|
||||
TextInput* text_input = app->text_input;
|
||||
text_input_set_header_text(text_input, "Label name");
|
||||
text_input_set_result_callback(
|
||||
text_input,
|
||||
subrem_scene_edit_label_text_input_callback,
|
||||
app,
|
||||
app->file_name_tmp,
|
||||
25,
|
||||
false);
|
||||
|
||||
text_input_set_minimum_length(app->text_input, 0);
|
||||
|
||||
widget_add_string_element(
|
||||
app->widget, 63, 12, AlignCenter, AlignCenter, FontPrimary, "Empty Label Name");
|
||||
widget_add_string_element(
|
||||
app->widget, 63, 32, AlignCenter, AlignCenter, FontSecondary, "Continue?");
|
||||
|
||||
widget_add_button_element(
|
||||
app->widget, GuiButtonTypeCenter, "Ok", subrem_scene_edit_label_widget_callback, app);
|
||||
widget_add_button_element(
|
||||
app->widget, GuiButtonTypeLeft, "Back", subrem_scene_edit_label_widget_callback, app);
|
||||
|
||||
scene_manager_set_scene_state(
|
||||
app->scene_manager, SubRemSceneEditLabel, SubRemSceneEditLabelStateTextInput);
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, SubRemViewIDTextInput);
|
||||
|
||||
furi_string_free(temp_str);
|
||||
}
|
||||
|
||||
bool subrem_scene_edit_label_on_event(void* context, SceneManagerEvent event) {
|
||||
SubGhzRemoteApp* app = context;
|
||||
|
||||
FuriString* label = app->map_preset->subs_preset[app->chusen_sub]->label;
|
||||
|
||||
if(event.type == SceneManagerEventTypeBack) {
|
||||
if(scene_manager_get_scene_state(app->scene_manager, SubRemSceneEditLabel) ==
|
||||
SubRemSceneEditLabelStateWidget) {
|
||||
scene_manager_set_scene_state(
|
||||
app->scene_manager, SubRemSceneEditLabel, SubRemSceneEditLabelStateTextInput);
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, SubRemViewIDTextInput);
|
||||
return true;
|
||||
} else if(
|
||||
scene_manager_get_scene_state(app->scene_manager, SubRemSceneEditLabel) ==
|
||||
SubRemSceneEditLabelStateTextInput) {
|
||||
scene_manager_previous_scene(app->scene_manager);
|
||||
return true;
|
||||
}
|
||||
|
||||
scene_manager_previous_scene(app->scene_manager);
|
||||
return true;
|
||||
} else if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == SubRemCustomEventSceneEditLabelInputDone) {
|
||||
if(strcmp(app->file_name_tmp, "") == 0) {
|
||||
scene_manager_set_scene_state(
|
||||
app->scene_manager, SubRemSceneEditLabel, SubRemSceneEditLabelStateWidget);
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, SubRemViewIDWidget);
|
||||
|
||||
} else {
|
||||
furi_string_set(label, app->file_name_tmp);
|
||||
app->map_not_saved = true;
|
||||
scene_manager_previous_scene(app->scene_manager);
|
||||
}
|
||||
return true;
|
||||
} else if(event.event == SubRemCustomEventSceneEditLabelWidgetAcces) {
|
||||
furi_string_set(label, app->file_name_tmp);
|
||||
app->map_not_saved = true;
|
||||
scene_manager_previous_scene(app->scene_manager);
|
||||
|
||||
return true;
|
||||
} else if(event.event == SubRemCustomEventSceneEditLabelWidgetBack) {
|
||||
scene_manager_set_scene_state(
|
||||
app->scene_manager, SubRemSceneEditLabel, SubRemSceneEditLabelStateTextInput);
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, SubRemViewIDTextInput);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void subrem_scene_edit_label_on_exit(void* context) {
|
||||
SubGhzRemoteApp* app = context;
|
||||
|
||||
// Clear view
|
||||
text_input_reset(app->text_input);
|
||||
widget_reset(app->widget);
|
||||
}
|
||||
123
applications/external/subghz_remote/scenes/subrem_scene_edit_menu.c
vendored
Normal file
123
applications/external/subghz_remote/scenes/subrem_scene_edit_menu.c
vendored
Normal file
@@ -0,0 +1,123 @@
|
||||
#include "../subghz_remote_app_i.h"
|
||||
|
||||
void subrem_scene_edit_menu_callback(SubRemCustomEvent event, void* context) {
|
||||
furi_assert(context);
|
||||
SubGhzRemoteApp* app = context;
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, event);
|
||||
}
|
||||
|
||||
void subrem_scene_edit_menu_widget_callback(GuiButtonType result, InputType type, void* context) {
|
||||
furi_assert(context);
|
||||
SubGhzRemoteApp* app = context;
|
||||
if((result == GuiButtonTypeRight) && (type == InputTypeShort)) {
|
||||
app->map_not_saved = false;
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, SubRemCustomEventViewEditMenuBack);
|
||||
} else if((result == GuiButtonTypeLeft) && (type == InputTypeShort)) {
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, SubRemViewIDEditMenu);
|
||||
}
|
||||
}
|
||||
|
||||
static uint8_t subrem_scene_edit_menu_state_to_index(SubRemEditMenuState event_id) {
|
||||
uint8_t ret = 0;
|
||||
|
||||
if(event_id == SubRemEditMenuStateUP) {
|
||||
ret = SubRemSubKeyNameUp;
|
||||
} else if(event_id == SubRemEditMenuStateDOWN) {
|
||||
ret = SubRemSubKeyNameDown;
|
||||
} else if(event_id == SubRemEditMenuStateLEFT) {
|
||||
ret = SubRemSubKeyNameLeft;
|
||||
} else if(event_id == SubRemEditMenuStateRIGHT) {
|
||||
ret = SubRemSubKeyNameRight;
|
||||
} else if(event_id == SubRemEditMenuStateOK) {
|
||||
ret = SubRemSubKeyNameOk;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void subrem_scene_edit_menu_update_data(SubGhzRemoteApp* app) {
|
||||
furi_assert(app);
|
||||
uint8_t index = subrem_scene_edit_menu_state_to_index(
|
||||
scene_manager_get_scene_state(app->scene_manager, SubRemSceneEditMenu));
|
||||
|
||||
subrem_view_edit_menu_add_data_to_show(
|
||||
app->subrem_edit_menu,
|
||||
index,
|
||||
app->map_preset->subs_preset[index]->label,
|
||||
app->map_preset->subs_preset[index]->file_path,
|
||||
app->map_preset->subs_preset[index]->load_state);
|
||||
}
|
||||
|
||||
void subrem_scene_edit_menu_on_enter(void* context) {
|
||||
SubGhzRemoteApp* app = context;
|
||||
|
||||
subrem_view_edit_menu_set_callback(
|
||||
app->subrem_edit_menu, subrem_scene_edit_menu_callback, app);
|
||||
|
||||
subrem_scene_edit_menu_update_data(app);
|
||||
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, SubRemViewIDEditMenu);
|
||||
|
||||
Widget* widget = app->widget;
|
||||
|
||||
widget_add_string_element(
|
||||
widget, 63, 12, AlignCenter, AlignBottom, FontPrimary, "Changes are not saved");
|
||||
widget_add_string_element(
|
||||
widget, 63, 32, AlignCenter, AlignBottom, FontPrimary, "do you want to exit?");
|
||||
|
||||
widget_add_button_element(
|
||||
widget, GuiButtonTypeRight, "Yes", subrem_scene_edit_menu_widget_callback, app);
|
||||
widget_add_button_element(
|
||||
widget, GuiButtonTypeLeft, "No", subrem_scene_edit_menu_widget_callback, app);
|
||||
}
|
||||
|
||||
bool subrem_scene_edit_menu_on_event(void* context, SceneManagerEvent event) {
|
||||
SubGhzRemoteApp* app = context;
|
||||
|
||||
if(event.type == SceneManagerEventTypeBack) {
|
||||
// Catch widget backEvent
|
||||
return true;
|
||||
}
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == SubRemCustomEventViewEditMenuBack) {
|
||||
if(app->map_not_saved) {
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, SubRemViewIDWidget);
|
||||
} else if(!scene_manager_search_and_switch_to_previous_scene(
|
||||
app->scene_manager, SubRemSceneStart)) {
|
||||
scene_manager_stop(app->scene_manager);
|
||||
view_dispatcher_stop(app->view_dispatcher);
|
||||
}
|
||||
|
||||
return true;
|
||||
} else if(
|
||||
event.event == SubRemCustomEventViewEditMenuUP ||
|
||||
event.event == SubRemCustomEventViewEditMenuDOWN) {
|
||||
scene_manager_set_scene_state(
|
||||
app->scene_manager,
|
||||
SubRemSceneEditMenu,
|
||||
subrem_view_edit_menu_get_index(app->subrem_edit_menu));
|
||||
subrem_scene_edit_menu_update_data(app);
|
||||
|
||||
return true;
|
||||
} else if(event.event == SubRemCustomEventViewEditMenuEdit) {
|
||||
app->chusen_sub = subrem_view_edit_menu_get_index(app->subrem_edit_menu);
|
||||
scene_manager_set_scene_state(
|
||||
app->scene_manager, SubRemSceneEditSubMenu, EditSubmenuIndexEditLabel);
|
||||
scene_manager_next_scene(app->scene_manager, SubRemSceneEditSubMenu);
|
||||
|
||||
return true;
|
||||
} else if(event.event == SubRemCustomEventViewEditMenuSave) {
|
||||
scene_manager_next_scene(app->scene_manager, SubRemSceneEditPreview);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void subrem_scene_edit_menu_on_exit(void* context) {
|
||||
SubGhzRemoteApp* app = context;
|
||||
widget_reset(app->widget);
|
||||
}
|
||||
74
applications/external/subghz_remote/scenes/subrem_scene_edit_preview.c
vendored
Normal file
74
applications/external/subghz_remote/scenes/subrem_scene_edit_preview.c
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
#include "../subghz_remote_app_i.h"
|
||||
#include "../views/remote.h"
|
||||
|
||||
#define TAG "SubRemScenRemote"
|
||||
|
||||
void subghz_scene_edit_preview_save_popup_callback(void* context) {
|
||||
SubGhzRemoteApp* app = context;
|
||||
view_dispatcher_send_custom_event(
|
||||
app->view_dispatcher, SubRemCustomEventSceneEditPreviewSaved);
|
||||
}
|
||||
|
||||
void subrem_scene_edit_preview_callback(SubRemCustomEvent event, void* context) {
|
||||
furi_assert(context);
|
||||
SubGhzRemoteApp* app = context;
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, event);
|
||||
}
|
||||
|
||||
void subrem_scene_edit_preview_on_enter(void* context) {
|
||||
SubGhzRemoteApp* app = context;
|
||||
|
||||
// Setup view
|
||||
Popup* popup = app->popup;
|
||||
popup_set_icon(popup, 32, 5, &I_DolphinNice_96x59);
|
||||
popup_set_header(popup, "Saved!", 13, 22, AlignLeft, AlignBottom);
|
||||
popup_set_timeout(popup, 1500);
|
||||
popup_set_context(popup, app);
|
||||
popup_set_callback(popup, subghz_scene_edit_preview_save_popup_callback);
|
||||
popup_enable_timeout(popup);
|
||||
|
||||
subrem_view_remote_update_data_labels(app->subrem_remote_view, app->map_preset->subs_preset);
|
||||
subrem_view_remote_set_state(app->subrem_remote_view, SubRemViewRemoteStateOFF, 0);
|
||||
|
||||
subrem_view_remote_set_callback(
|
||||
app->subrem_remote_view, subrem_scene_edit_preview_callback, app);
|
||||
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, SubRemViewIDRemote);
|
||||
}
|
||||
|
||||
bool subrem_scene_edit_preview_on_event(void* context, SceneManagerEvent event) {
|
||||
SubGhzRemoteApp* app = context;
|
||||
|
||||
if(event.type == SceneManagerEventTypeBack ||
|
||||
(event.type == SceneManagerEventTypeCustom &&
|
||||
(event.event == SubRemCustomEventViewRemoteStartLEFT ||
|
||||
event.event == SubRemCustomEventViewRemoteForcedStop))) {
|
||||
scene_manager_previous_scene(app->scene_manager);
|
||||
return true;
|
||||
} else if(
|
||||
event.type == SceneManagerEventTypeCustom &&
|
||||
(event.event == SubRemCustomEventViewRemoteStartRIGHT ||
|
||||
event.event == SubRemCustomEventViewRemoteStartOK)) {
|
||||
if(subrem_save_map_to_file(app)) {
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, SubRemViewIDPopup);
|
||||
app->map_not_saved = false;
|
||||
return true;
|
||||
}
|
||||
// TODO error screen
|
||||
return true;
|
||||
} else if(
|
||||
event.type == SceneManagerEventTypeCustom &&
|
||||
event.event == SubRemCustomEventSceneEditPreviewSaved) {
|
||||
scene_manager_search_and_switch_to_previous_scene(app->scene_manager, SubRemSceneEditMenu);
|
||||
}
|
||||
// } else if(event.type == SceneManagerEventTypeTick) {
|
||||
// }
|
||||
return false;
|
||||
}
|
||||
|
||||
void subrem_scene_edit_preview_on_exit(void* context) {
|
||||
SubGhzRemoteApp* app = context;
|
||||
|
||||
subrem_view_remote_set_state(app->subrem_remote_view, SubRemViewRemoteStateIdle, 0);
|
||||
popup_reset(app->popup);
|
||||
}
|
||||
54
applications/external/subghz_remote/scenes/subrem_scene_edit_submenu.c
vendored
Normal file
54
applications/external/subghz_remote/scenes/subrem_scene_edit_submenu.c
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
#include "../subghz_remote_app_i.h"
|
||||
#include "../helpers/subrem_custom_event.h"
|
||||
|
||||
void subrem_scene_edit_submenu_text_input_callback(void* context) {
|
||||
furi_assert(context);
|
||||
SubGhzRemoteApp* app = context;
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, SubRemCustomEventSceneEditsubmenu);
|
||||
}
|
||||
|
||||
void subrem_scene_edit_submenu_callback(void* context, uint32_t index) {
|
||||
furi_assert(context);
|
||||
SubGhzRemoteApp* app = context;
|
||||
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, index);
|
||||
}
|
||||
|
||||
void subrem_scene_edit_submenu_on_enter(void* context) {
|
||||
furi_assert(context);
|
||||
|
||||
SubGhzRemoteApp* app = context;
|
||||
Submenu* submenu = app->submenu;
|
||||
submenu_add_item(
|
||||
submenu, "Edit Label", EditSubmenuIndexEditLabel, subrem_scene_edit_submenu_callback, app);
|
||||
submenu_add_item(
|
||||
submenu, "Edit File", EditSubmenuIndexEditFile, subrem_scene_edit_submenu_callback, app);
|
||||
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, SubRemViewIDSubmenu);
|
||||
}
|
||||
|
||||
bool subrem_scene_edit_submenu_on_event(void* context, SceneManagerEvent event) {
|
||||
furi_assert(context);
|
||||
|
||||
SubGhzRemoteApp* app = context;
|
||||
bool consumed = false;
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == EditSubmenuIndexEditLabel) {
|
||||
scene_manager_next_scene(app->scene_manager, SubRemSceneEditLabel);
|
||||
consumed = true;
|
||||
} else if(event.event == EditSubmenuIndexEditFile) {
|
||||
scene_manager_next_scene(app->scene_manager, SubRemSceneOpenSubFile);
|
||||
consumed = true;
|
||||
}
|
||||
}
|
||||
|
||||
return consumed;
|
||||
}
|
||||
|
||||
void subrem_scene_edit_submenu_on_exit(void* context) {
|
||||
furi_assert(context);
|
||||
|
||||
SubGhzRemoteApp* app = context;
|
||||
submenu_reset(app->submenu);
|
||||
}
|
||||
70
applications/external/subghz_remote/scenes/subrem_scene_enter_new_name.c
vendored
Normal file
70
applications/external/subghz_remote/scenes/subrem_scene_enter_new_name.c
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
#include "../subghz_remote_app_i.h"
|
||||
#include "../helpers/subrem_custom_event.h"
|
||||
|
||||
#include <gui/modules/validators.h>
|
||||
|
||||
void subrem_scene_enter_new_name_text_input_callback(void* context) {
|
||||
furi_assert(context);
|
||||
SubGhzRemoteApp* app = context;
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, SubRemCustomEventSceneNewName);
|
||||
}
|
||||
|
||||
void subrem_scene_enter_new_name_on_enter(void* context) {
|
||||
SubGhzRemoteApp* app = context;
|
||||
|
||||
// Setup view
|
||||
TextInput* text_input = app->text_input;
|
||||
|
||||
//strncpy(app->file_name_tmp, "subrem_", SUBREM_MAX_LEN_NAME);
|
||||
text_input_set_header_text(text_input, "Map file Name");
|
||||
text_input_set_result_callback(
|
||||
text_input,
|
||||
subrem_scene_enter_new_name_text_input_callback,
|
||||
app,
|
||||
app->file_name_tmp,
|
||||
25,
|
||||
false);
|
||||
|
||||
ValidatorIsFile* validator_is_file = validator_is_file_alloc_init(
|
||||
furi_string_get_cstr(app->file_path), SUBREM_APP_EXTENSION, "");
|
||||
text_input_set_validator(text_input, validator_is_file_callback, validator_is_file);
|
||||
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, SubRemViewIDTextInput);
|
||||
}
|
||||
|
||||
bool subrem_scene_enter_new_name_on_event(void* context, SceneManagerEvent event) {
|
||||
furi_assert(context);
|
||||
|
||||
SubGhzRemoteApp* app = context;
|
||||
bool consumed = false;
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == SubRemCustomEventSceneNewName) {
|
||||
if(strcmp(app->file_name_tmp, "") != 0) {
|
||||
furi_string_set(app->file_path, SUBREM_APP_FOLDER);
|
||||
furi_string_cat_printf(
|
||||
app->file_path, "/%s%s", app->file_name_tmp, SUBREM_APP_EXTENSION);
|
||||
|
||||
subrem_map_preset_reset(app->map_preset);
|
||||
scene_manager_next_scene(app->scene_manager, SubRemSceneEditMenu);
|
||||
} else { //error
|
||||
}
|
||||
consumed = true;
|
||||
}
|
||||
}
|
||||
|
||||
return consumed;
|
||||
}
|
||||
|
||||
void subrem_scene_enter_new_name_on_exit(void* context) {
|
||||
furi_assert(context);
|
||||
|
||||
SubGhzRemoteApp* app = context;
|
||||
submenu_reset(app->submenu);
|
||||
|
||||
// Clear validator & view
|
||||
void* validator_context = text_input_get_validator_callback_context(app->text_input);
|
||||
text_input_set_validator(app->text_input, NULL, NULL);
|
||||
validator_is_file_free(validator_context);
|
||||
text_input_reset(app->text_input);
|
||||
}
|
||||
@@ -5,30 +5,16 @@ void subrem_scene_open_map_file_on_enter(void* context) {
|
||||
SubGhzRemoteApp* app = context;
|
||||
|
||||
SubRemLoadMapState load_state = subrem_load_from_file(app);
|
||||
uint32_t start_scene_state =
|
||||
scene_manager_get_scene_state(app->scene_manager, SubRemSceneStart);
|
||||
|
||||
if(load_state == SubRemLoadMapStateOK || load_state == SubRemLoadMapStateNotAllOK) {
|
||||
if(load_state == SubRemLoadMapStateBack) {
|
||||
scene_manager_previous_scene(app->scene_manager);
|
||||
} else if(start_scene_state == SubmenuIndexSubRemEditMapFile) {
|
||||
scene_manager_set_scene_state(app->scene_manager, SubRemSceneEditMenu, SubRemSubKeyNameUp);
|
||||
scene_manager_next_scene(app->scene_manager, SubRemSceneEditMenu);
|
||||
} else if(start_scene_state == SubmenuIndexSubRemOpenMapFile) {
|
||||
scene_manager_next_scene(app->scene_manager, SubRemSceneRemote);
|
||||
} else {
|
||||
if(load_state != SubRemLoadMapStateBack) {
|
||||
#ifdef SUBREM_LIGHT
|
||||
dialog_message_show_storage_error(app->dialogs, "Can't load\nMap file");
|
||||
#else
|
||||
DialogMessage* message = dialog_message_alloc();
|
||||
|
||||
dialog_message_set_header(message, "Map File Error", 64, 8, AlignCenter, AlignCenter);
|
||||
dialog_message_set_text(
|
||||
message, "Can't load\nMap file", 64, 32, AlignCenter, AlignCenter);
|
||||
dialog_message_set_buttons(message, "Back", NULL, NULL);
|
||||
dialog_message_show(app->dialogs, message);
|
||||
|
||||
dialog_message_free(message);
|
||||
#endif
|
||||
}
|
||||
// TODO: Map Preset Reset
|
||||
if(!scene_manager_previous_scene(app->scene_manager)) {
|
||||
scene_manager_stop(app->scene_manager);
|
||||
view_dispatcher_stop(app->view_dispatcher);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
118
applications/external/subghz_remote/scenes/subrem_scene_open_sub_file.c
vendored
Normal file
118
applications/external/subghz_remote/scenes/subrem_scene_open_sub_file.c
vendored
Normal file
@@ -0,0 +1,118 @@
|
||||
#include "../subghz_remote_app_i.h"
|
||||
|
||||
void subrem_scene_open_sub_file_error_popup_callback(void* context) {
|
||||
SubGhzRemoteApp* app = context;
|
||||
view_dispatcher_send_custom_event(
|
||||
app->view_dispatcher, SubRemCustomEventSceneEditOpenSubErrorPopup);
|
||||
}
|
||||
|
||||
SubRemLoadSubState subrem_scene_open_sub_file_dialog(SubGhzRemoteApp* app) {
|
||||
furi_assert(app);
|
||||
|
||||
SubRemSubFilePreset* sub = app->map_preset->subs_preset[app->chusen_sub];
|
||||
|
||||
FuriString* temp_file_path = furi_string_alloc();
|
||||
|
||||
if(furi_string_empty(sub->file_path)) {
|
||||
furi_string_set(temp_file_path, SUBGHZ_RAW_FOLDER);
|
||||
} else {
|
||||
furi_string_set(temp_file_path, sub->file_path);
|
||||
}
|
||||
|
||||
SubRemLoadSubState ret = SubRemLoadSubStateNotSet;
|
||||
|
||||
DialogsFileBrowserOptions browser_options;
|
||||
|
||||
dialog_file_browser_set_basic_options(&browser_options, SUBGHZ_APP_EXTENSION, &I_sub1_10px);
|
||||
browser_options.base_path = SUBGHZ_RAW_FOLDER;
|
||||
|
||||
// Input events and views are managed by file_select
|
||||
if(!dialog_file_browser_show(app->dialogs, temp_file_path, temp_file_path, &browser_options)) {
|
||||
} else {
|
||||
// Check sub file
|
||||
SubRemSubFilePreset* sub_candidate = subrem_sub_file_preset_alloc();
|
||||
furi_string_set(sub_candidate->label, sub->label);
|
||||
furi_string_set(sub_candidate->file_path, temp_file_path);
|
||||
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
FlipperFormat* fff_file = flipper_format_file_alloc(storage);
|
||||
|
||||
if(flipper_format_file_open_existing(
|
||||
fff_file, furi_string_get_cstr(sub_candidate->file_path))) {
|
||||
ret = subrem_sub_preset_load(sub_candidate, app->txrx, fff_file);
|
||||
}
|
||||
|
||||
flipper_format_file_close(fff_file);
|
||||
flipper_format_free(fff_file);
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
|
||||
if(ret == SubRemLoadSubStateOK) {
|
||||
subrem_sub_file_preset_free(app->map_preset->subs_preset[app->chusen_sub]);
|
||||
app->map_preset->subs_preset[app->chusen_sub] = sub_candidate;
|
||||
app->map_not_saved = true;
|
||||
} else {
|
||||
subrem_sub_file_preset_free(sub_candidate);
|
||||
}
|
||||
}
|
||||
|
||||
furi_string_free(temp_file_path);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void subrem_scene_open_sub_file_on_enter(void* context) {
|
||||
furi_assert(context);
|
||||
SubGhzRemoteApp* app = context;
|
||||
|
||||
SubRemLoadSubState load_state = subrem_scene_open_sub_file_dialog(app);
|
||||
|
||||
Popup* popup = app->popup;
|
||||
// popup_set_icon();
|
||||
popup_set_header(popup, "ERROR", 63, 16, AlignCenter, AlignBottom);
|
||||
popup_set_timeout(popup, 1500);
|
||||
popup_set_context(popup, app);
|
||||
popup_set_callback(popup, subrem_scene_open_sub_file_error_popup_callback);
|
||||
popup_enable_timeout(popup);
|
||||
|
||||
if(load_state == SubRemLoadSubStateOK) {
|
||||
scene_manager_previous_scene(app->scene_manager);
|
||||
} else if(load_state == SubRemLoadSubStateNotSet) {
|
||||
scene_manager_previous_scene(app->scene_manager);
|
||||
} else {
|
||||
switch(load_state) {
|
||||
case SubRemLoadSubStateErrorFreq:
|
||||
|
||||
popup_set_text(popup, "Bad frequency", 63, 30, AlignCenter, AlignBottom);
|
||||
break;
|
||||
case SubRemLoadSubStateErrorMod:
|
||||
|
||||
popup_set_text(popup, "Bad modulation", 63, 30, AlignCenter, AlignBottom);
|
||||
break;
|
||||
case SubRemLoadSubStateErrorProtocol:
|
||||
|
||||
popup_set_text(popup, "Unsupported protocol", 63, 30, AlignCenter, AlignBottom);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, SubRemViewIDPopup);
|
||||
}
|
||||
}
|
||||
|
||||
bool subrem_scene_open_sub_file_on_event(void* context, SceneManagerEvent event) {
|
||||
SubGhzRemoteApp* app = context;
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom &&
|
||||
event.event == SubRemCustomEventSceneEditOpenSubErrorPopup) {
|
||||
scene_manager_previous_scene(app->scene_manager);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void subrem_scene_open_sub_file_on_exit(void* context) {
|
||||
SubGhzRemoteApp* app = context;
|
||||
|
||||
popup_reset(app->popup);
|
||||
}
|
||||
@@ -39,6 +39,9 @@ void subrem_scene_remote_on_enter(void* context) {
|
||||
SubGhzRemoteApp* app = context;
|
||||
|
||||
subrem_view_remote_update_data_labels(app->subrem_remote_view, app->map_preset->subs_preset);
|
||||
subrem_view_remote_set_radio(
|
||||
app->subrem_remote_view,
|
||||
subghz_txrx_radio_device_get(app->txrx) != SubGhzRadioDeviceTypeInternal);
|
||||
|
||||
subrem_view_remote_set_callback(app->subrem_remote_view, subrem_scene_remote_callback, app);
|
||||
|
||||
|
||||
@@ -27,16 +27,28 @@ void subrem_scene_start_on_enter(void* context) {
|
||||
subrem_scene_start_submenu_callback,
|
||||
app);
|
||||
#endif
|
||||
submenu_add_item(
|
||||
submenu,
|
||||
"Edit Map File",
|
||||
SubmenuIndexSubRemEditMapFile,
|
||||
subrem_scene_start_submenu_callback,
|
||||
app);
|
||||
submenu_add_item(
|
||||
submenu,
|
||||
"New Map File",
|
||||
SubmenuIndexSubRemNewMapFile,
|
||||
subrem_scene_start_submenu_callback,
|
||||
app);
|
||||
// submenu_add_item(
|
||||
// submenu,
|
||||
// "About",
|
||||
// SubmenuIndexSubGhzRemoteAbout,
|
||||
// subrem_scene_start_submenu_callback,
|
||||
// app);
|
||||
#ifndef SUBREM_LIGHT
|
||||
|
||||
submenu_set_selected_item(
|
||||
submenu, scene_manager_get_scene_state(app->scene_manager, SubRemSceneStart));
|
||||
#endif
|
||||
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, SubRemViewIDSubmenu);
|
||||
}
|
||||
|
||||
@@ -48,23 +60,33 @@ bool subrem_scene_start_on_event(void* context, SceneManagerEvent event) {
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == SubmenuIndexSubRemOpenMapFile) {
|
||||
#ifndef SUBREM_LIGHT
|
||||
scene_manager_set_scene_state(
|
||||
app->scene_manager, SubRemSceneStart, SubmenuIndexSubRemOpenMapFile);
|
||||
#endif
|
||||
|
||||
scene_manager_next_scene(app->scene_manager, SubRemSceneOpenMapFile);
|
||||
consumed = true;
|
||||
}
|
||||
// } else if(event.event == SubmenuIndexSubRemAbout) {
|
||||
// scene_manager_next_scene(app->scene_manager, SubRemSceneAbout);
|
||||
// consumed = true;
|
||||
// }
|
||||
#if FURI_DEBUG
|
||||
else if(event.event == SubmenuIndexSubRemRemoteView) {
|
||||
scene_manager_next_scene(app->scene_manager, SubRemSceneRemote);
|
||||
consumed = true;
|
||||
}
|
||||
#endif
|
||||
else if(event.event == SubmenuIndexSubRemEditMapFile) {
|
||||
scene_manager_set_scene_state(
|
||||
app->scene_manager, SubRemSceneStart, SubmenuIndexSubRemEditMapFile);
|
||||
scene_manager_next_scene(app->scene_manager, SubRemSceneOpenMapFile);
|
||||
consumed = true;
|
||||
} else if(event.event == SubmenuIndexSubRemNewMapFile) {
|
||||
scene_manager_set_scene_state(
|
||||
app->scene_manager, SubRemSceneStart, SubmenuIndexSubRemNewMapFile);
|
||||
scene_manager_next_scene(app->scene_manager, SubRemSceneEnterNewName);
|
||||
consumed = true;
|
||||
}
|
||||
// } else if(event.event == SubmenuIndexSubRemAbout) {
|
||||
// scene_manager_next_scene(app->scene_manager, SubRemSceneAbout);
|
||||
// consumed = true;
|
||||
// }
|
||||
}
|
||||
|
||||
return consumed;
|
||||
|
||||
Reference in New Issue
Block a user