Home to work

This commit is contained in:
Dmitry422
2026-01-25 22:38:11 +07:00
parent 267140b161
commit 8a85ab88a7
4 changed files with 85 additions and 66 deletions

View File

@@ -98,8 +98,6 @@ typedef struct {
static SubGhzDeviceCC1101Ext* subghz_device_cc1101_ext = NULL; static SubGhzDeviceCC1101Ext* subghz_device_cc1101_ext = NULL;
bool subghz_device_cc1101_ext_is_async_tx_complete(void);
static bool subghz_device_cc1101_ext_check_init(void) { static bool subghz_device_cc1101_ext_check_init(void) {
furi_assert(subghz_device_cc1101_ext->state == SubGhzDeviceCC1101ExtStateInit); furi_assert(subghz_device_cc1101_ext->state == SubGhzDeviceCC1101ExtStateInit);
subghz_device_cc1101_ext->state = SubGhzDeviceCC1101ExtStateIdle; subghz_device_cc1101_ext->state = SubGhzDeviceCC1101ExtStateIdle;

View File

@@ -2,6 +2,8 @@
#include <lib/subghz/blocks/custom_btn.h> #include <lib/subghz/blocks/custom_btn.h>
#include "applications/main/subghz/helpers/subghz_txrx_i.h"
#define TAG "SubGhzSceneReceiverInfo" #define TAG "SubGhzSceneReceiverInfo"
void subghz_scene_receiver_info_callback(GuiButtonType result, InputType type, void* context) { void subghz_scene_receiver_info_callback(GuiButtonType result, InputType type, void* context) {
@@ -138,6 +140,12 @@ bool subghz_scene_receiver_info_on_event(void* context, SceneManagerEvent event)
return true; return true;
} else if(event.event == SubGhzCustomEventSceneReceiverInfoTxStop) { } else if(event.event == SubGhzCustomEventSceneReceiverInfoTxStop) {
//CC1101 Stop Tx -> Start RX //CC1101 Stop Tx -> Start RX
// #subghz_one_press_send# - keyword to search changes
// when user release OK button we wait until full data packed will send and later stop TX
while(!subghz_devices_is_async_complete_tx(subghz->txrx->radio_device)) {
notification_message(subghz->notifications, &sequence_blink_magenta_10);
}
//#
subghz->state_notifications = SubGhzNotificationStateIDLE; subghz->state_notifications = SubGhzNotificationStateIDLE;
widget_reset(subghz->widget); widget_reset(subghz->widget);

View File

@@ -4,8 +4,13 @@
#include <lib/subghz/blocks/custom_btn.h> #include <lib/subghz/blocks/custom_btn.h>
#include <lib/subghz/devices/devices.c> #include <lib/subghz/devices/devices.c>
#include "applications/main/subghz/helpers/subghz_txrx_i.h"
#define TAG "SubGhzSceneTransmitter" #define TAG "SubGhzSceneTransmitter"
static bool tx_stop_called = false;
void subghz_scene_transmitter_callback(SubGhzCustomEvent event, void* context) { void subghz_scene_transmitter_callback(SubGhzCustomEvent event, void* context) {
furi_assert(context); furi_assert(context);
SubGhz* subghz = context; SubGhz* subghz = context;
@@ -66,26 +71,63 @@ bool subghz_scene_transmitter_on_event(void* context, SceneManagerEvent event) {
SubGhz* subghz = context; SubGhz* subghz = context;
if(event.type == SceneManagerEventTypeCustom) { if(event.type == SceneManagerEventTypeCustom) {
if(event.event == SubGhzCustomEventViewTransmitterSendStart) { if(event.event == SubGhzCustomEventViewTransmitterSendStart) {
// if we recieve event to start transmission (user press OK button) then start/restart TX
subghz->state_notifications = SubGhzNotificationStateIDLE; subghz->state_notifications = SubGhzNotificationStateIDLE;
if(subghz_tx_start(subghz, subghz_txrx_get_fff_data(subghz->txrx))) { if(subghz_tx_start(subghz, subghz_txrx_get_fff_data(subghz->txrx))) {
subghz->state_notifications = SubGhzNotificationStateTx; subghz->state_notifications = SubGhzNotificationStateTx;
subghz_scene_transmitter_update_data_show(subghz); subghz_scene_transmitter_update_data_show(subghz);
dolphin_deed(DolphinDeedSubGhzSend); dolphin_deed(DolphinDeedSubGhzSend);
}
// #subghz_one_press_send# - keyword to search changes return true;
// #start insert# } else if(event.event == SubGhzCustomEventViewTransmitterSendStop) {
// we recieve event to stop tranmission (user release OK button) but
// TODO change while condition to subghz_devices_is_async_complete_tx(subghz->txrx->radio_device); // hardware TX still working now then set flag to stop it after hardware TX will be realy ended
// while( if(!subghz_devices_is_async_complete_tx(subghz->txrx->radio_device)) {
// !(furi_hal_subghz_is_async_tx_complete() && tx_stop_called = true;
// subghz_device_cc1101_ext_is_async_tx_complete())) { return true;
// notification_message(subghz->notifications, &sequence_blink_magenta_10); }
// } // if hardware TX not working now so just stop TX correctly
subghz->state_notifications = SubGhzNotificationStateIDLE;
while(!furi_hal_subghz_is_async_tx_complete()) { subghz_txrx_stop(subghz->txrx);
notification_message(subghz->notifications, &sequence_blink_magenta_10); if(subghz_custom_btn_get() != SUBGHZ_CUSTOM_BTN_OK) {
} subghz_custom_btn_set(SUBGHZ_CUSTOM_BTN_OK);
int32_t tmp_counter = furi_hal_subghz_get_rolling_counter_mult();
furi_hal_subghz_set_rolling_counter_mult(0);
// Calling restore!
subghz_tx_start(subghz, subghz_txrx_get_fff_data(subghz->txrx));
subghz_txrx_stop(subghz->txrx);
// Calling restore 2nd time special for FAAC SLH!
// TODO: Find better way to restore after custom button is used!!!
subghz_tx_start(subghz, subghz_txrx_get_fff_data(subghz->txrx));
subghz_txrx_stop(subghz->txrx);
furi_hal_subghz_set_rolling_counter_mult(tmp_counter);
}
return true;
} else if(event.event == SubGhzCustomEventViewTransmitterBack) {
// if user press back button then force stop TX if they was active
if(subghz->state_notifications == SubGhzNotificationStateTx) {
subghz_txrx_stop(subghz->txrx);
}
subghz->state_notifications = SubGhzNotificationStateIDLE;
scene_manager_search_and_switch_to_previous_scene(
subghz->scene_manager, SubGhzSceneStart);
return true;
} else if(event.event == SubGhzCustomEventViewTransmitterError) {
furi_string_set(subghz->error_str, "Protocol not\nfound!");
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowErrorSub);
}
} else if(event.type == SceneManagerEventTypeTick) {
if(subghz->state_notifications == SubGhzNotificationStateTx) {
// if hardware TX still working at this time so we just blink led and do nothing
if(!subghz_devices_is_async_complete_tx(subghz->txrx->radio_device)) {
notification_message(subghz->notifications, &sequence_blink_magenta_10);
return true;
}
// if hardware TX not working now and tx_stop_called = true
// (mean user release OK button early than hardware TX was ended) then we stop TX
if(tx_stop_called) {
tx_stop_called = false;
subghz->state_notifications = SubGhzNotificationStateIDLE; subghz->state_notifications = SubGhzNotificationStateIDLE;
subghz_txrx_stop(subghz->txrx); subghz_txrx_stop(subghz->txrx);
if(subghz_custom_btn_get() != SUBGHZ_CUSTOM_BTN_OK) { if(subghz_custom_btn_get() != SUBGHZ_CUSTOM_BTN_OK) {
@@ -101,39 +143,18 @@ bool subghz_scene_transmitter_on_event(void* context, SceneManagerEvent event) {
subghz_txrx_stop(subghz->txrx); subghz_txrx_stop(subghz->txrx);
furi_hal_subghz_set_rolling_counter_mult(tmp_counter); furi_hal_subghz_set_rolling_counter_mult(tmp_counter);
} }
// #end insert# return true;
} else {
// if state_notifications == SubGhzNotificationStateTx but hardware TX was ended
// and user still dont release OK button then we repeat transmission
subghz->state_notifications = SubGhzNotificationStateIDLE;
if(subghz_tx_start(subghz, subghz_txrx_get_fff_data(subghz->txrx))) {
subghz->state_notifications = SubGhzNotificationStateTx;
subghz_scene_transmitter_update_data_show(subghz);
dolphin_deed(DolphinDeedSubGhzSend);
}
return true;
} }
return true;
// #subghz_one_press_send# - keyword to search changes
// } else if(event.event == SubGhzCustomEventViewTransmitterSendStop) {
// subghz->state_notifications = SubGhzNotificationStateIDLE;
// subghz_txrx_stop(subghz->txrx);
// if(subghz_custom_btn_get() != SUBGHZ_CUSTOM_BTN_OK) {
// subghz_custom_btn_set(SUBGHZ_CUSTOM_BTN_OK);
// int32_t tmp_counter = furi_hal_subghz_get_rolling_counter_mult();
// furi_hal_subghz_set_rolling_counter_mult(0);
// // Calling restore!
// subghz_tx_start(subghz, subghz_txrx_get_fff_data(subghz->txrx));
// subghz_txrx_stop(subghz->txrx);
// // Calling restore 2nd time special for FAAC SLH!
// // TODO: Find better way to restore after custom button is used!!!
// subghz_tx_start(subghz, subghz_txrx_get_fff_data(subghz->txrx));
// subghz_txrx_stop(subghz->txrx);
// furi_hal_subghz_set_rolling_counter_mult(tmp_counter);
// }
// return true;
} else if(event.event == SubGhzCustomEventViewTransmitterBack) {
subghz->state_notifications = SubGhzNotificationStateIDLE;
scene_manager_search_and_switch_to_previous_scene(
subghz->scene_manager, SubGhzSceneStart);
return true;
} else if(event.event == SubGhzCustomEventViewTransmitterError) {
furi_string_set(subghz->error_str, "Protocol not\nfound!");
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowErrorSub);
}
} else if(event.type == SceneManagerEventTypeTick) {
if(subghz->state_notifications == SubGhzNotificationStateTx) {
notification_message(subghz->notifications, &sequence_blink_magenta_10);
} }
return true; return true;
} }

View File

@@ -6,9 +6,6 @@
#include <lib/subghz/blocks/custom_btn.h> #include <lib/subghz/blocks/custom_btn.h>
#include <applications/drivers/subghz/cc1101_ext/cc1101_ext.h>
#include <targets/f7/furi_hal/furi_hal_subghz.h>
struct SubGhzViewTransmitter { struct SubGhzViewTransmitter {
View* view; View* view;
SubGhzViewTransmitterCallback callback; SubGhzViewTransmitterCallback callback;
@@ -158,10 +155,7 @@ bool subghz_view_transmitter_input(InputEvent* event, void* context) {
true); true);
if(can_be_sent) { if(can_be_sent) {
// #subghz_one_press_send# - keyword to search changes if(event->key == InputKeyOk && event->type == InputTypePress) {
bool allow_events = furi_hal_subghz_is_async_tx_complete() && subghz_device_cc1101_ext_is_async_tx_complete ();
// #
if(event->key == InputKeyOk && event->type == InputTypePress && allow_events) {
subghz_custom_btn_set(SUBGHZ_CUSTOM_BTN_OK); subghz_custom_btn_set(SUBGHZ_CUSTOM_BTN_OK);
with_view_model( with_view_model(
subghz_transmitter->view, subghz_transmitter->view,
@@ -174,11 +168,10 @@ bool subghz_view_transmitter_input(InputEvent* event, void* context) {
subghz_transmitter->callback( subghz_transmitter->callback(
SubGhzCustomEventViewTransmitterSendStart, subghz_transmitter->context); SubGhzCustomEventViewTransmitterSendStart, subghz_transmitter->context);
return true; return true;
// #subghz_one_press_send# - keyword to search changes } else if(event->key == InputKeyOk && event->type == InputTypeRelease) {
// } else if(event->key == InputKeyOk && event->type == InputTypeRelease) { subghz_transmitter->callback(
// subghz_transmitter->callback( SubGhzCustomEventViewTransmitterSendStop, subghz_transmitter->context);
// SubGhzCustomEventViewTransmitterSendStop, subghz_transmitter->context); return true;
// return true;
} // Finish "OK" key processing } // Finish "OK" key processing
if(subghz_custom_btn_is_allowed()) { if(subghz_custom_btn_is_allowed()) {
@@ -196,7 +189,7 @@ bool subghz_view_transmitter_input(InputEvent* event, void* context) {
return true; return true;
} }
if(event->type == InputTypePress && allow_events) { if(event->type == InputTypePress) {
with_view_model( with_view_model(
subghz_transmitter->view, subghz_transmitter->view,
SubGhzViewTransmitterModel * model, SubGhzViewTransmitterModel * model,
@@ -216,11 +209,10 @@ bool subghz_view_transmitter_input(InputEvent* event, void* context) {
subghz_transmitter->callback( subghz_transmitter->callback(
SubGhzCustomEventViewTransmitterSendStart, subghz_transmitter->context); SubGhzCustomEventViewTransmitterSendStart, subghz_transmitter->context);
return true; return true;
// #subghz_one_press_send# - keyword to search changes } else if(event->type == InputTypeRelease) {
// } else if(event->type == InputTypeRelease) { subghz_transmitter->callback(
// subghz_transmitter->callback( SubGhzCustomEventViewTransmitterSendStop, subghz_transmitter->context);
// SubGhzCustomEventViewTransmitterSendStop, subghz_transmitter->context); return true;
// return true;
} }
} }
} }