From 808774c05f83c14ccfc1469fcc17f5ba966f0c7f Mon Sep 17 00:00:00 2001 From: Dmitry422 Date: Thu, 12 Feb 2026 16:55:19 +0700 Subject: [PATCH] BT on/off to desktop_lock_menu --- applications/services/bt/bt_service/bt_api.c | 3 +-- applications/services/bt/bt_service/bt_api.h | 5 +++++ .../desktop/scenes/desktop_scene_lock_menu.c | 21 +++++++++++++++---- .../services/desktop/views/desktop_events.h | 3 ++- .../desktop/views/desktop_view_lock_menu.c | 17 ++++++++++----- 5 files changed, 37 insertions(+), 12 deletions(-) create mode 100644 applications/services/bt/bt_service/bt_api.h diff --git a/applications/services/bt/bt_service/bt_api.c b/applications/services/bt/bt_service/bt_api.c index 39b9a099d..8b42d7920 100644 --- a/applications/services/bt/bt_service/bt_api.c +++ b/applications/services/bt/bt_service/bt_api.c @@ -1,5 +1,4 @@ -#include "bt_i.h" -#include +#include "bt_api.h" FuriHalBleProfileBase* bt_profile_start( Bt* bt, diff --git a/applications/services/bt/bt_service/bt_api.h b/applications/services/bt/bt_service/bt_api.h new file mode 100644 index 000000000..5120ccc7f --- /dev/null +++ b/applications/services/bt/bt_service/bt_api.h @@ -0,0 +1,5 @@ +#pragma once +#include "bt_i.h" +#include + +extern void bt_set_settings(Bt* bt, const BtSettings* settings); \ No newline at end of file diff --git a/applications/services/desktop/scenes/desktop_scene_lock_menu.c b/applications/services/desktop/scenes/desktop_scene_lock_menu.c index 5ca95c4c5..b74ca7f48 100644 --- a/applications/services/desktop/scenes/desktop_scene_lock_menu.c +++ b/applications/services/desktop/scenes/desktop_scene_lock_menu.c @@ -10,6 +10,8 @@ #include "../views/desktop_view_lock_menu.h" #include "desktop_scene.h" +#include "applications/services/bt/bt_service/bt_api.h" + #define TAG "DesktopSceneLock" void desktop_scene_lock_menu_callback(DesktopEvent event, void* context) { @@ -34,6 +36,9 @@ bool desktop_scene_lock_menu_on_event(void* context, SceneManagerEvent event) { Desktop* desktop = (Desktop*)context; bool consumed = false; + Bt* bt = furi_record_open(RECORD_BT); + BtSettings bts = bt->bt_settings; + if(event.type == SceneManagerEventTypeTick) { bool check_pin_changed = scene_manager_get_scene_state(desktop->scene_manager, DesktopSceneLockMenu); @@ -42,10 +47,17 @@ bool desktop_scene_lock_menu_on_event(void* context, SceneManagerEvent event) { } } else if(event.type == SceneManagerEventTypeCustom) { switch(event.event) { - case DesktopLockMenuEventLock: - scene_manager_set_scene_state(desktop->scene_manager, DesktopSceneLockMenu, 0); - desktop_lock(desktop); - consumed = true; + // old use case + // case DesktopLockMenuEventLock: + // scene_manager_set_scene_state(desktop->scene_manager, DesktopSceneLockMenu, 0); + // desktop_lock(desktop); + // consumed = true; + // break; + case DesktopLockMenuEventBt: + bts.enabled = !bts.enabled; + bt_set_settings(bt, &bts); + scene_manager_search_and_switch_to_previous_scene( + desktop->scene_manager, DesktopSceneMain); break; case DesktopLockMenuEventDummyModeOn: desktop_set_dummy_mode_state(desktop, true); @@ -78,4 +90,5 @@ bool desktop_scene_lock_menu_on_event(void* context, SceneManagerEvent event) { void desktop_scene_lock_menu_on_exit(void* context) { UNUSED(context); + furi_record_close(RECORD_BT); } diff --git a/applications/services/desktop/views/desktop_events.h b/applications/services/desktop/views/desktop_events.h index b89ef5158..724761d48 100644 --- a/applications/services/desktop/views/desktop_events.h +++ b/applications/services/desktop/views/desktop_events.h @@ -37,7 +37,8 @@ typedef enum { DesktopDebugEventToggleDebugMode, DesktopDebugEventExit, - DesktopLockMenuEventLock, + //DesktopLockMenuEventLock, + DesktopLockMenuEventBt, DesktopLockMenuEventDummyModeOn, DesktopLockMenuEventDummyModeOff, DesktopLockMenuEventStealthModeOn, diff --git a/applications/services/desktop/views/desktop_view_lock_menu.c b/applications/services/desktop/views/desktop_view_lock_menu.c index 1b6bdab9c..fefb7b1bd 100644 --- a/applications/services/desktop/views/desktop_view_lock_menu.c +++ b/applications/services/desktop/views/desktop_view_lock_menu.c @@ -6,7 +6,8 @@ #include "desktop_view_lock_menu.h" typedef enum { - DesktopLockMenuIndexLock, + //DesktopLockMenuIndexLock, + DesktopLockMenuIndexBt, DesktopLockMenuIndexStealth, DesktopLockMenuIndexDummy, @@ -56,8 +57,9 @@ void desktop_lock_menu_draw_callback(Canvas* canvas, void* model) { for(size_t i = 0; i < DesktopLockMenuIndexTotalCount; ++i) { const char* str = NULL; - if(i == DesktopLockMenuIndexLock) { - str = "Lock"; + //if(i == DesktopLockMenuIndexLock) { + if(i == DesktopLockMenuIndexBt) { + str = "Bluetooth On/Off"; } else if(i == DesktopLockMenuIndexStealth) { if(m->stealth_mode) { str = "Unmute"; @@ -126,10 +128,15 @@ bool desktop_lock_menu_input_callback(InputEvent* event, void* context) { update); if(event->key == InputKeyOk) { - if(idx == DesktopLockMenuIndexLock) { + if(idx == DesktopLockMenuIndexBt) { if(event->type == InputTypeShort) { - lock_menu->callback(DesktopLockMenuEventLock, lock_menu->context); + lock_menu->callback(DesktopLockMenuEventBt, lock_menu->context); } + // old use case + // } else if(idx == DesktopLockMenuIndexLock) { + // if(event->type == InputTypeShort) { + // lock_menu->callback(DesktopLockMenuEventLock, lock_menu->context); + // } } else if(idx == DesktopLockMenuIndexStealth) { if((stealth_mode == false) && (event->type == InputTypeShort)) { lock_menu->callback(DesktopLockMenuEventStealthModeOn, lock_menu->context);