mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-13 17:48:35 -07:00
Merge branch 'fz-dev' into dev
This commit is contained in:
@@ -49,6 +49,8 @@ typedef enum {
|
||||
SubGhzCustomEventSceneExit,
|
||||
SubGhzCustomEventSceneStay,
|
||||
|
||||
SubGhzCustomEventSceneRpcLoad,
|
||||
|
||||
SubGhzCustomEventViewReceiverOK,
|
||||
SubGhzCustomEventViewReceiverConfig,
|
||||
SubGhzCustomEventViewReceiverBack,
|
||||
|
||||
@@ -2,24 +2,40 @@
|
||||
|
||||
void subghz_scene_rpc_on_enter(void* context) {
|
||||
SubGhz* subghz = context;
|
||||
Widget* widget = subghz->widget;
|
||||
Popup* popup = subghz->popup;
|
||||
|
||||
widget_add_text_box_element(
|
||||
widget, 0, 0, 128, 28, AlignCenter, AlignCenter, "RPC mode", false);
|
||||
popup_set_header(popup, "Sub-GHz", 82, 28, AlignCenter, AlignBottom);
|
||||
popup_set_text(popup, "RPC mode", 82, 32, AlignCenter, AlignTop);
|
||||
|
||||
popup_set_icon(popup, 2, 14, &I_Warning_30x23); // TODO: icon
|
||||
|
||||
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewIdPopup);
|
||||
|
||||
notification_message(subghz->notifications, &sequence_display_backlight_on);
|
||||
|
||||
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewIdWidget);
|
||||
}
|
||||
|
||||
bool subghz_scene_rpc_on_event(void* context, SceneManagerEvent event) {
|
||||
SubGhz* subghz = context;
|
||||
Popup* popup = subghz->popup;
|
||||
bool consumed = false;
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
consumed = true;
|
||||
if(event.event == SubGhzCustomEventSceneExit) {
|
||||
view_dispatcher_stop(subghz->view_dispatcher);
|
||||
} else if(event.event == SubGhzCustomEventSceneRpcLoad) {
|
||||
string_t file_name;
|
||||
string_init(file_name);
|
||||
path_extract_filename(subghz->file_path, file_name, true);
|
||||
|
||||
snprintf(
|
||||
subghz->file_name_tmp,
|
||||
SUBGHZ_MAX_LEN_NAME,
|
||||
"loaded\n%s",
|
||||
string_get_cstr(file_name));
|
||||
popup_set_text(popup, subghz->file_name_tmp, 82, 32, AlignCenter, AlignTop);
|
||||
|
||||
string_clear(file_name);
|
||||
}
|
||||
}
|
||||
return consumed;
|
||||
@@ -27,8 +43,9 @@ bool subghz_scene_rpc_on_event(void* context, SceneManagerEvent event) {
|
||||
|
||||
void subghz_scene_rpc_on_exit(void* context) {
|
||||
SubGhz* subghz = context;
|
||||
Popup* popup = subghz->popup;
|
||||
|
||||
//subghz_rpc_exit_callback(subghz);
|
||||
|
||||
widget_reset(subghz->widget);
|
||||
popup_set_header(popup, NULL, 0, 0, AlignCenter, AlignBottom);
|
||||
popup_set_text(popup, NULL, 0, 0, AlignCenter, AlignTop);
|
||||
popup_set_icon(popup, 0, 0, NULL);
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ bool subghz_scene_set_type_submenu_gen_data_protocol(
|
||||
subghz_receiver_search_decoder_base_by_name(subghz->txrx->receiver, protocol_name);
|
||||
|
||||
if(subghz->txrx->decoder_result == NULL) {
|
||||
string_set_str(subghz->error_str, "Protocol not found");
|
||||
string_set_str(subghz->error_str, "Protocol not\nfound!");
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowErrorSub);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -11,8 +11,8 @@ void subghz_scene_show_error_sub_on_enter(void* context) {
|
||||
|
||||
// Setup view
|
||||
Popup* popup = subghz->popup;
|
||||
popup_set_icon(popup, 32, 12, &I_DolphinFirstStart7_61x51);
|
||||
popup_set_header(popup, string_get_cstr(subghz->error_str), 64, 8, AlignCenter, AlignBottom);
|
||||
popup_set_icon(popup, 72, 14, &I_DolphinFirstStart8_56x51);
|
||||
popup_set_header(popup, string_get_cstr(subghz->error_str), 14, 15, AlignLeft, AlignTop);
|
||||
popup_set_timeout(popup, 1500);
|
||||
popup_set_context(popup, subghz);
|
||||
popup_set_callback(popup, subghz_scene_show_error_sub_popup_callback);
|
||||
|
||||
@@ -96,7 +96,7 @@ bool subghz_scene_transmitter_on_event(void* context, SceneManagerEvent event) {
|
||||
subghz->scene_manager, SubGhzSceneStart);
|
||||
return true;
|
||||
} else if(event.event == SubGhzCustomEventViewTransmitterError) {
|
||||
string_set_str(subghz->error_str, "Protocol not found");
|
||||
string_set_str(subghz->error_str, "Protocol not\nfound!");
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowErrorSub);
|
||||
}
|
||||
} else if(event.type == SceneManagerEventTypeTick) {
|
||||
|
||||
@@ -5,6 +5,18 @@
|
||||
#include "subghz_i.h"
|
||||
#include <lib/toolbox/path.h>
|
||||
|
||||
static const NotificationSequence sequence_blink_start_magenta = {
|
||||
&message_blink_start_10,
|
||||
&message_blink_set_color_magenta,
|
||||
&message_do_not_reset,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static const NotificationSequence sequence_blink_stop = {
|
||||
&message_blink_stop,
|
||||
NULL,
|
||||
};
|
||||
|
||||
bool subghz_custom_event_callback(void* context, uint32_t event) {
|
||||
furi_assert(context);
|
||||
SubGhz* subghz = context;
|
||||
@@ -36,6 +48,7 @@ static bool subghz_rpc_command_callback(RpcAppSystemEvent event, const char* arg
|
||||
if(event == RpcAppEventSessionClose) {
|
||||
rpc_system_app_set_callback(subghz->rpc_ctx, NULL, NULL);
|
||||
subghz->rpc_ctx = NULL;
|
||||
notification_message(subghz->notifications, &sequence_blink_stop);
|
||||
view_dispatcher_send_custom_event(subghz->view_dispatcher, SubGhzCustomEventSceneExit);
|
||||
if(subghz->txrx->txrx_state == SubGhzTxRxStateTx) {
|
||||
subghz_tx_stop(subghz);
|
||||
@@ -53,15 +66,19 @@ static bool subghz_rpc_command_callback(RpcAppSystemEvent event, const char* arg
|
||||
if(arg) {
|
||||
if(subghz_key_load(subghz, arg, false)) {
|
||||
string_set_str(subghz->file_path, arg);
|
||||
view_dispatcher_send_custom_event(
|
||||
subghz->view_dispatcher, SubGhzCustomEventSceneRpcLoad);
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
} else if(event == RpcAppEventButtonPress) {
|
||||
if(subghz->txrx->txrx_state == SubGhzTxRxStateSleep) {
|
||||
notification_message(subghz->notifications, &sequence_blink_start_magenta);
|
||||
result = subghz_tx_start(subghz, subghz->txrx->fff_data);
|
||||
}
|
||||
} else if(event == RpcAppEventButtonRelease) {
|
||||
if(subghz->txrx->txrx_state == SubGhzTxRxStateTx) {
|
||||
notification_message(subghz->notifications, &sequence_blink_stop);
|
||||
subghz_tx_stop(subghz);
|
||||
subghz_sleep(subghz);
|
||||
result = true;
|
||||
@@ -83,8 +100,6 @@ SubGhz* subghz_alloc() {
|
||||
// View Dispatcher
|
||||
subghz->view_dispatcher = view_dispatcher_alloc();
|
||||
view_dispatcher_enable_queue(subghz->view_dispatcher);
|
||||
view_dispatcher_attach_to_gui(
|
||||
subghz->view_dispatcher, subghz->gui, ViewDispatcherTypeFullscreen);
|
||||
|
||||
subghz->scene_manager = scene_manager_alloc(&subghz_scene_handlers, subghz);
|
||||
view_dispatcher_set_event_callback_context(subghz->view_dispatcher, subghz);
|
||||
@@ -224,6 +239,8 @@ void subghz_free(SubGhz* subghz) {
|
||||
|
||||
if(subghz->rpc_ctx) {
|
||||
rpc_system_app_set_callback(subghz->rpc_ctx, NULL, NULL);
|
||||
rpc_system_app_send_exited(subghz->rpc_ctx);
|
||||
notification_message(subghz->notifications, &sequence_blink_stop);
|
||||
subghz->rpc_ctx = NULL;
|
||||
}
|
||||
|
||||
@@ -333,24 +350,33 @@ int32_t subghz_app(void* p) {
|
||||
if(sscanf(p, "RPC %lX", &rpc_ctx) == 1) {
|
||||
subghz->rpc_ctx = (void*)rpc_ctx;
|
||||
rpc_system_app_set_callback(subghz->rpc_ctx, subghz_rpc_command_callback, subghz);
|
||||
rpc_system_app_send_started(subghz->rpc_ctx);
|
||||
view_dispatcher_attach_to_gui(
|
||||
subghz->view_dispatcher, subghz->gui, ViewDispatcherTypeDesktop);
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneRpc);
|
||||
} else if(subghz_key_load(subghz, p, true)) {
|
||||
string_set_str(subghz->file_path, p);
|
||||
|
||||
if((!strcmp(subghz->txrx->decoder_result->protocol->name, "RAW"))) {
|
||||
//Load Raw TX
|
||||
subghz->txrx->rx_key_state = SubGhzRxKeyStateRAWLoad;
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneReadRAW);
|
||||
} else {
|
||||
//Load transmitter TX
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneTransmitter);
|
||||
}
|
||||
} else {
|
||||
//exit app
|
||||
scene_manager_stop(subghz->scene_manager);
|
||||
view_dispatcher_stop(subghz->view_dispatcher);
|
||||
view_dispatcher_attach_to_gui(
|
||||
subghz->view_dispatcher, subghz->gui, ViewDispatcherTypeFullscreen);
|
||||
if(subghz_key_load(subghz, p, true)) {
|
||||
string_set_str(subghz->file_path, p);
|
||||
|
||||
if((!strcmp(subghz->txrx->decoder_result->protocol->name, "RAW"))) {
|
||||
//Load Raw TX
|
||||
subghz->txrx->rx_key_state = SubGhzRxKeyStateRAWLoad;
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneReadRAW);
|
||||
} else {
|
||||
//Load transmitter TX
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneTransmitter);
|
||||
}
|
||||
} else {
|
||||
//exit app
|
||||
scene_manager_stop(subghz->scene_manager);
|
||||
view_dispatcher_stop(subghz->view_dispatcher);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
view_dispatcher_attach_to_gui(
|
||||
subghz->view_dispatcher, subghz->gui, ViewDispatcherTypeFullscreen);
|
||||
string_set_str(subghz->file_path, SUBGHZ_APP_FOLDER);
|
||||
if(load_database) {
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneStart);
|
||||
|
||||
@@ -676,7 +676,7 @@ static void subghz_cli_command_chat(Cli* cli, string_t args) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(cli_is_connected(cli)) {
|
||||
if(!cli_is_connected(cli)) {
|
||||
printf("\r\n");
|
||||
chat_event.event = SubGhzChatEventUserExit;
|
||||
subghz_chat_worker_put_event_chat(subghz_chat, &chat_event);
|
||||
|
||||
@@ -205,15 +205,19 @@ void subghz_tx_stop(SubGhz* subghz) {
|
||||
void subghz_dialog_message_show_only_rx(SubGhz* subghz) {
|
||||
DialogsApp* dialogs = subghz->dialogs;
|
||||
DialogMessage* message = dialog_message_alloc();
|
||||
|
||||
dialog_message_set_header(message, "Transmission is blocked", 63, 3, AlignCenter, AlignTop);
|
||||
|
||||
dialog_message_set_text(
|
||||
message,
|
||||
"This frequency can\nonly be used for RX\nin your region",
|
||||
38,
|
||||
23,
|
||||
AlignCenter,
|
||||
AlignCenter);
|
||||
dialog_message_set_icon(message, &I_DolphinFirstStart7_61x51, 67, 12);
|
||||
dialog_message_set_buttons(message, "Back", NULL, NULL);
|
||||
"This frequency\nis restricted to\nreceiving only\nin your region.",
|
||||
3,
|
||||
17,
|
||||
AlignLeft,
|
||||
AlignTop);
|
||||
|
||||
dialog_message_set_icon(message, &I_DolphinFirstStart8_56x51, 72, 14);
|
||||
|
||||
dialog_message_show(dialogs, message);
|
||||
dialog_message_free(message);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user