flipperzero-firmware/applications/subghz/scenes/subghz_scene_save_name.c

57 lines
1.7 KiB
C
Raw Normal View History

2021-08-12 14:42:56 +00:00
#include "../subghz_i.h"
#include <lib/toolbox/random_name.h>
#include "file-worker.h"
#define SCENE_SAVE_NAME_CUSTOM_EVENT (0UL)
void subghz_scene_save_name_text_input_callback(void* context) {
SubGhz* subghz = context;
view_dispatcher_send_custom_event(subghz->view_dispatcher, SCENE_SAVE_NAME_CUSTOM_EVENT);
}
const void subghz_scene_save_name_on_enter(void* context) {
SubGhz* subghz = context;
// Setup view
TextInput* text_input = subghz->text_input;
bool dev_name_empty = false;
set_random_name(subghz->text_store, sizeof(subghz->text_store));
dev_name_empty = true;
text_input_set_header_text(text_input, "Name the KEY");
text_input_set_result_callback(
text_input,
subghz_scene_save_name_text_input_callback,
subghz,
subghz->text_store,
22, //Max len name
dev_name_empty);
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewTextInput);
}
const bool subghz_scene_save_name_on_event(void* context, SceneManagerEvent event) {
SubGhz* subghz = context;
if(event.type == SceneManagerEventTypeCustom) {
if(event.event == SCENE_SAVE_NAME_CUSTOM_EVENT) {
SubGhz: read and save static remotes. Create new static and dynamic remotes. (#646) * SubGhz: the functions of saving loading KeeLog have been modified, saving KeeLog is prohibited * SubGhz: Fix displaying Nice FlorS in the Raed scene * SubGhz: Fix displaying Faac SLH in the Raed scene * SubGhz: Fix displaying iDo in the Raed scene * SubGhz: Fix displaying Star Line in the Raed scene * SubGhz: Fix displaying Nice Flo in the Raed scene, added save and load functions. (testing needed, no remote control) * SubGhz: subghz_beginadded common encoder upload signal * SubGhz: add Came encoder * SubGhz: modified pricenton encoder, fix view transmitter hide the "Send" button if there is no encoder * SubGhz: add nice flo encoder, need testing no remote control * SubGhz: add gate_tx encoder * SubGhz: add nero_sketch encoder * SubGhz: add keelog encoder * SubGhz: add long upload upload while the button is pressed while releasing the transfer is over, with a check for sticking (maximum 200 upload repetitions) * SubGhz: fix max upload * SubGhz: Fix structure subghz add encoder * SubGhz: add generating and sending a dynamic keelog key, refactoring the code * SubGhz: add notifications * SubGhz: add creating a new remote control (Pricenton, Nice Flo 12bit, Nice Flo 24bit, CAME 12bit, CAME 24bit, Gate TX, DoorHan) * SubGhz: Fix load file, fix scene start * Subghz: Fix show key * SubGhz: Fix subghz_cli * SubGhz: Fix furi-hal-subghz * Format sources * SubGhz: standard notification scheme, fix broken assert in DMA. * SubGhz: move level alignment logic to furi-hal-subghz, fix spelling, cleanup. Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
2021-08-16 19:56:23 +00:00
if(subghz_save_protocol_to_file(subghz, subghz->text_store)) {
2021-08-12 14:42:56 +00:00
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneSaveSuccess);
return true;
} else {
//Error save
return true;
}
}
}
return false;
}
const void subghz_scene_save_name_on_exit(void* context) {
SubGhz* subghz = context;
// Clear view
text_input_set_header_text(subghz->text_input, NULL);
text_input_set_result_callback(subghz->text_input, NULL, NULL, NULL, 0, false);
}