33#include <dolphin/dolphin.h>
44
55#include <lib/subghz/blocks/custom_btn.h>
6- #include <lib/subghz/devices/devices.c>
7-
8- #include "applications/main/subghz/helpers/subghz_txrx_i.h"
96
107#define TAG "SubGhzSceneTransmitter"
118
12- static bool tx_stop_called = false;
13-
149void subghz_scene_transmitter_callback (SubGhzCustomEvent event , void * context ) {
1510 furi_assert (context );
1611 SubGhz * subghz = context ;
@@ -71,7 +66,6 @@ bool subghz_scene_transmitter_on_event(void* context, SceneManagerEvent event) {
7166 SubGhz * subghz = context ;
7267 if (event .type == SceneManagerEventTypeCustom ) {
7368 if (event .event == SubGhzCustomEventViewTransmitterSendStart ) {
74- // if we recieve event to start transmission (user press OK button) then start/restart TX
7569 subghz -> state_notifications = SubGhzNotificationStateIDLE ;
7670
7771 if (subghz_tx_start (subghz , subghz_txrx_get_fff_data (subghz -> txrx ))) {
@@ -81,13 +75,6 @@ bool subghz_scene_transmitter_on_event(void* context, SceneManagerEvent event) {
8175 }
8276 return true;
8377 } else if (event .event == SubGhzCustomEventViewTransmitterSendStop ) {
84- // if we recieve event to stop tranmission (user release OK button) but
85- // hardware TX still working now then set flag to stop it after hardware TX will be realy ended
86- if (!subghz_devices_is_async_complete_tx (subghz -> txrx -> radio_device )) {
87- tx_stop_called = true;
88- return true;
89- }
90- // if hardware TX not working now so just stop TX correctly
9178 subghz -> state_notifications = SubGhzNotificationStateIDLE ;
9279 subghz_txrx_stop (subghz -> txrx );
9380 if (subghz_custom_btn_get () != SUBGHZ_CUSTOM_BTN_OK ) {
@@ -105,10 +92,6 @@ bool subghz_scene_transmitter_on_event(void* context, SceneManagerEvent event) {
10592 }
10693 return true;
10794 } else if (event .event == SubGhzCustomEventViewTransmitterBack ) {
108- // if user press back button then force stop TX if they was active
109- if (subghz -> state_notifications == SubGhzNotificationStateTx ) {
110- subghz_txrx_stop (subghz -> txrx );
111- }
11295 subghz -> state_notifications = SubGhzNotificationStateIDLE ;
11396 scene_manager_search_and_switch_to_previous_scene (
11497 subghz -> scene_manager , SubGhzSceneStart );
@@ -119,42 +102,7 @@ bool subghz_scene_transmitter_on_event(void* context, SceneManagerEvent event) {
119102 }
120103 } else if (event .type == SceneManagerEventTypeTick ) {
121104 if (subghz -> state_notifications == SubGhzNotificationStateTx ) {
122- // if hardware TX still working at this time so we just blink led and do nothing
123- if (!subghz_devices_is_async_complete_tx (subghz -> txrx -> radio_device )) {
124- notification_message (subghz -> notifications , & sequence_blink_magenta_10 );
125- return true;
126- }
127- // if hardware TX not working now and tx_stop_called = true
128- // (mean user release OK button early than hardware TX was ended) then we stop TX
129- if (tx_stop_called ) {
130- tx_stop_called = false;
131- subghz -> state_notifications = SubGhzNotificationStateIDLE ;
132- subghz_txrx_stop (subghz -> txrx );
133- if (subghz_custom_btn_get () != SUBGHZ_CUSTOM_BTN_OK ) {
134- subghz_custom_btn_set (SUBGHZ_CUSTOM_BTN_OK );
135- int32_t tmp_counter = furi_hal_subghz_get_rolling_counter_mult ();
136- furi_hal_subghz_set_rolling_counter_mult (0 );
137- // Calling restore!
138- subghz_tx_start (subghz , subghz_txrx_get_fff_data (subghz -> txrx ));
139- subghz_txrx_stop (subghz -> txrx );
140- // Calling restore 2nd time special for FAAC SLH!
141- // TODO: Find better way to restore after custom button is used!!!
142- subghz_tx_start (subghz , subghz_txrx_get_fff_data (subghz -> txrx ));
143- subghz_txrx_stop (subghz -> txrx );
144- furi_hal_subghz_set_rolling_counter_mult (tmp_counter );
145- }
146- return true;
147- } else {
148- // if current state == SubGhzNotificationStateTx but hardware TX was ended
149- // and user still not release OK button then we repeat transmission
150- subghz -> state_notifications = SubGhzNotificationStateIDLE ;
151- if (subghz_tx_start (subghz , subghz_txrx_get_fff_data (subghz -> txrx ))) {
152- subghz -> state_notifications = SubGhzNotificationStateTx ;
153- subghz_scene_transmitter_update_data_show (subghz );
154- dolphin_deed (DolphinDeedSubGhzSend );
155- }
156- return true;
157- }
105+ notification_message (subghz -> notifications , & sequence_blink_magenta_10 );
158106 }
159107 return true;
160108 }
0 commit comments