diff options
author | Skorpionm <85568270+Skorpionm@users.noreply.github.com> | 2021-09-10 03:29:57 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-10 03:29:57 +0300 |
commit | f385340b2e9470026438ba1a345d29bf921989fe (patch) | |
tree | 485ca97be9ada74efb933513df9ff105e524d607 /applications/subghz/subghz.c | |
parent | fbccb9fbafd543c2f7683be6de8ac9393250e9cd (diff) |
[FL-1758] SubGhz refactoring part 1 (#689)
* SubGhz: refactoring
* WeGet: Add support for outputting formatted lines, events center button pressed, center button released
* Variable Item: slightly changed the display of data on the screen
* SubGhz: add show errors, add show preset, refactoring
* SubGhz: refactoring transmitter
* SubGhz: removed unused modules
* SubGhz: Add FuriHalSubGhzPresetOok270Async setting menu
* SubGhz: fix annotation
* SubGhz: add support Nero Radio
Co-authored-by: あく <alleteam@gmail.com>
Diffstat (limited to 'applications/subghz/subghz.c')
-rw-r--r-- | applications/subghz/subghz.c | 92 |
1 files changed, 71 insertions, 21 deletions
diff --git a/applications/subghz/subghz.c b/applications/subghz/subghz.c index 865ec8df..5b356ab1 100644 --- a/applications/subghz/subghz.c +++ b/applications/subghz/subghz.c @@ -1,5 +1,22 @@ #include "subghz_i.h" +const char* const subghz_frequencies_text[] = { + "300.00", + "315.00", + "348.00", + "387.00", + "433.08", + "433.92", + "434.78", + "438.90", + "464.00", + "779.00", + "868.35", + "915.00", + "925.00", + "928.00", +}; + const uint32_t subghz_frequencies[] = { /* 300 - 348 */ 300000000, @@ -20,7 +37,15 @@ const uint32_t subghz_frequencies[] = { 928000000, }; +const uint32_t subghz_hopper_frequencies[] = { + 315000000, + 433920000, + 868350000, +}; + const uint32_t subghz_frequencies_count = sizeof(subghz_frequencies) / sizeof(uint32_t); +const uint32_t subghz_hopper_frequencies_count = + sizeof(subghz_hopper_frequencies) / sizeof(uint32_t); const uint32_t subghz_frequencies_433_92 = 5; bool subghz_custom_event_callback(void* context, uint32_t event) { @@ -77,11 +102,6 @@ SubGhz* subghz_alloc() { SubGhzViewReceiver, subghz_receiver_get_view(subghz->subghz_receiver)); - // Dialog - subghz->dialog_ex = dialog_ex_alloc(); - view_dispatcher_add_view( - subghz->view_dispatcher, SubGhzViewDialogEx, dialog_ex_get_view(subghz->dialog_ex)); - // Popup subghz->popup = popup_alloc(); view_dispatcher_add_view( @@ -92,6 +112,11 @@ SubGhz* subghz_alloc() { view_dispatcher_add_view( subghz->view_dispatcher, SubGhzViewTextInput, text_input_get_view(subghz->text_input)); + // Custom Widget + subghz->widget = widget_alloc(); + view_dispatcher_add_view( + subghz->view_dispatcher, SubGhzViewWidget, widget_get_view(subghz->widget)); + // Transmitter subghz->subghz_transmitter = subghz_transmitter_alloc(); view_dispatcher_add_view( @@ -99,6 +124,13 @@ SubGhz* subghz_alloc() { SubGhzViewTransmitter, subghz_transmitter_get_view(subghz->subghz_transmitter)); + // Variable Item List + subghz->variable_item_list = variable_item_list_alloc(); + view_dispatcher_add_view( + subghz->view_dispatcher, + SubGhzViewVariableItemList, + variable_item_list_get_view(subghz->variable_item_list)); + // Carrier Test Module subghz->subghz_test_carrier = subghz_test_carrier_alloc(); view_dispatcher_add_view( @@ -120,17 +152,26 @@ SubGhz* subghz_alloc() { SubGhzViewStatic, subghz_test_static_get_view(subghz->subghz_test_static)); - //init Worker & Protocol - subghz->worker = subghz_worker_alloc(); - subghz->protocol = subghz_protocol_alloc(); + //init Worker & Protocol & History + subghz->txrx = furi_alloc(sizeof(SubGhzTxRx)); + subghz->txrx->frequency = subghz_frequencies[subghz_frequencies_433_92]; + subghz->txrx->preset = FuriHalSubGhzPresetOok650Async; + subghz->txrx->txrx_state = SubGhzTxRxStateIdle; + subghz->txrx->hopper_state = SubGhzHopperStateOFF; + subghz->txrx->history = subghz_history_alloc(); + subghz->txrx->worker = subghz_worker_alloc(); + subghz->txrx->protocol = subghz_protocol_alloc(); subghz_worker_set_overrun_callback( - subghz->worker, (SubGhzWorkerOverrunCallback)subghz_protocol_reset); + subghz->txrx->worker, (SubGhzWorkerOverrunCallback)subghz_protocol_reset); subghz_worker_set_pair_callback( - subghz->worker, (SubGhzWorkerPairCallback)subghz_protocol_parse); - subghz_worker_set_context(subghz->worker, subghz->protocol); + subghz->txrx->worker, (SubGhzWorkerPairCallback)subghz_protocol_parse); + subghz_worker_set_context(subghz->txrx->worker, subghz->txrx->protocol); - subghz_protocol_load_keeloq_file(subghz->protocol, "/ext/subghz/keeloq_mfcodes"); - subghz_protocol_load_nice_flor_s_file(subghz->protocol, "/ext/subghz/nice_floor_s_rx"); + //Init Error_str + string_init(subghz->error_str); + + subghz_protocol_load_keeloq_file(subghz->txrx->protocol, "/ext/subghz/keeloq_mfcodes"); + subghz_protocol_load_nice_flor_s_file(subghz->txrx->protocol, "/ext/subghz/nice_floor_s_rx"); //subghz_protocol_enable_dump_text(subghz->protocol, subghz_text_callback, subghz); @@ -160,18 +201,22 @@ void subghz_free(SubGhz* subghz) { view_dispatcher_remove_view(subghz->view_dispatcher, SubGhzViewTextInput); text_input_free(subghz->text_input); - // Receiver + // Custom Widget + view_dispatcher_remove_view(subghz->view_dispatcher, SubGhzViewWidget); + widget_free(subghz->widget); + + // Transmitter view_dispatcher_remove_view(subghz->view_dispatcher, SubGhzViewTransmitter); subghz_transmitter_free(subghz->subghz_transmitter); + // Variable Item List + view_dispatcher_remove_view(subghz->view_dispatcher, SubGhzViewVariableItemList); + variable_item_list_free(subghz->variable_item_list); + // Submenu view_dispatcher_remove_view(subghz->view_dispatcher, SubGhzViewMenu); submenu_free(subghz->submenu); - // DialogEx - view_dispatcher_remove_view(subghz->view_dispatcher, SubGhzViewDialogEx); - dialog_ex_free(subghz->dialog_ex); - // Popup view_dispatcher_remove_view(subghz->view_dispatcher, SubGhzViewPopup); popup_free(subghz->popup); @@ -186,9 +231,14 @@ void subghz_free(SubGhz* subghz) { furi_record_close("gui"); subghz->gui = NULL; - //Worker & Protocol - subghz_protocol_free(subghz->protocol); - subghz_worker_free(subghz->worker); + //Worker & Protocol & History + subghz_protocol_free(subghz->txrx->protocol); + subghz_worker_free(subghz->txrx->worker); + subghz_history_free(subghz->txrx->history); + free(subghz->txrx); + + //Error string + string_clear(subghz->error_str); // Notifications furi_record_close("notification"); |