mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-22 05:14:46 -07:00
Merge pull request #965 from Dmitry422/dev
BT ON/OFF instead of Lock/Unlock action in desktop lock menu
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
#include "bt_i.h"
|
#include "bt_api.h"
|
||||||
#include <profiles/serial_profile.h>
|
|
||||||
|
|
||||||
FuriHalBleProfileBase* bt_profile_start(
|
FuriHalBleProfileBase* bt_profile_start(
|
||||||
Bt* bt,
|
Bt* bt,
|
||||||
|
|||||||
5
applications/services/bt/bt_service/bt_api.h
Normal file
5
applications/services/bt/bt_service/bt_api.h
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "bt_i.h"
|
||||||
|
#include <profiles/serial_profile.h>
|
||||||
|
|
||||||
|
extern void bt_set_settings(Bt* bt, const BtSettings* settings);
|
||||||
@@ -10,6 +10,8 @@
|
|||||||
#include "../views/desktop_view_lock_menu.h"
|
#include "../views/desktop_view_lock_menu.h"
|
||||||
#include "desktop_scene.h"
|
#include "desktop_scene.h"
|
||||||
|
|
||||||
|
#include "applications/services/bt/bt_service/bt_api.h"
|
||||||
|
|
||||||
#define TAG "DesktopSceneLock"
|
#define TAG "DesktopSceneLock"
|
||||||
|
|
||||||
void desktop_scene_lock_menu_callback(DesktopEvent event, void* context) {
|
void desktop_scene_lock_menu_callback(DesktopEvent event, void* context) {
|
||||||
@@ -25,6 +27,7 @@ void desktop_scene_lock_menu_on_enter(void* context) {
|
|||||||
desktop_lock_menu_set_dummy_mode_state(desktop->lock_menu, desktop->settings.dummy_mode);
|
desktop_lock_menu_set_dummy_mode_state(desktop->lock_menu, desktop->settings.dummy_mode);
|
||||||
desktop_lock_menu_set_stealth_mode_state(
|
desktop_lock_menu_set_stealth_mode_state(
|
||||||
desktop->lock_menu, furi_hal_rtc_is_flag_set(FuriHalRtcFlagStealthMode));
|
desktop->lock_menu, furi_hal_rtc_is_flag_set(FuriHalRtcFlagStealthMode));
|
||||||
|
desktop_lock_menu_set_bt_mode_state(desktop->lock_menu, furi_hal_bt_is_active());
|
||||||
desktop_lock_menu_set_idx(desktop->lock_menu, 0);
|
desktop_lock_menu_set_idx(desktop->lock_menu, 0);
|
||||||
|
|
||||||
view_dispatcher_switch_to_view(desktop->view_dispatcher, DesktopViewIdLockMenu);
|
view_dispatcher_switch_to_view(desktop->view_dispatcher, DesktopViewIdLockMenu);
|
||||||
@@ -34,6 +37,9 @@ bool desktop_scene_lock_menu_on_event(void* context, SceneManagerEvent event) {
|
|||||||
Desktop* desktop = (Desktop*)context;
|
Desktop* desktop = (Desktop*)context;
|
||||||
bool consumed = false;
|
bool consumed = false;
|
||||||
|
|
||||||
|
Bt* bt = furi_record_open(RECORD_BT);
|
||||||
|
BtSettings bts = bt->bt_settings;
|
||||||
|
|
||||||
if(event.type == SceneManagerEventTypeTick) {
|
if(event.type == SceneManagerEventTypeTick) {
|
||||||
bool check_pin_changed =
|
bool check_pin_changed =
|
||||||
scene_manager_get_scene_state(desktop->scene_manager, DesktopSceneLockMenu);
|
scene_manager_get_scene_state(desktop->scene_manager, DesktopSceneLockMenu);
|
||||||
@@ -42,10 +48,17 @@ bool desktop_scene_lock_menu_on_event(void* context, SceneManagerEvent event) {
|
|||||||
}
|
}
|
||||||
} else if(event.type == SceneManagerEventTypeCustom) {
|
} else if(event.type == SceneManagerEventTypeCustom) {
|
||||||
switch(event.event) {
|
switch(event.event) {
|
||||||
case DesktopLockMenuEventLock:
|
// old use case
|
||||||
scene_manager_set_scene_state(desktop->scene_manager, DesktopSceneLockMenu, 0);
|
// case DesktopLockMenuEventLock:
|
||||||
desktop_lock(desktop);
|
// scene_manager_set_scene_state(desktop->scene_manager, DesktopSceneLockMenu, 0);
|
||||||
consumed = true;
|
// 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;
|
break;
|
||||||
case DesktopLockMenuEventDummyModeOn:
|
case DesktopLockMenuEventDummyModeOn:
|
||||||
desktop_set_dummy_mode_state(desktop, true);
|
desktop_set_dummy_mode_state(desktop, true);
|
||||||
@@ -78,4 +91,5 @@ bool desktop_scene_lock_menu_on_event(void* context, SceneManagerEvent event) {
|
|||||||
|
|
||||||
void desktop_scene_lock_menu_on_exit(void* context) {
|
void desktop_scene_lock_menu_on_exit(void* context) {
|
||||||
UNUSED(context);
|
UNUSED(context);
|
||||||
|
furi_record_close(RECORD_BT);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,8 @@ typedef enum {
|
|||||||
DesktopDebugEventToggleDebugMode,
|
DesktopDebugEventToggleDebugMode,
|
||||||
DesktopDebugEventExit,
|
DesktopDebugEventExit,
|
||||||
|
|
||||||
DesktopLockMenuEventLock,
|
//DesktopLockMenuEventLock,
|
||||||
|
DesktopLockMenuEventBt,
|
||||||
DesktopLockMenuEventDummyModeOn,
|
DesktopLockMenuEventDummyModeOn,
|
||||||
DesktopLockMenuEventDummyModeOff,
|
DesktopLockMenuEventDummyModeOff,
|
||||||
DesktopLockMenuEventStealthModeOn,
|
DesktopLockMenuEventStealthModeOn,
|
||||||
|
|||||||
@@ -6,7 +6,8 @@
|
|||||||
#include "desktop_view_lock_menu.h"
|
#include "desktop_view_lock_menu.h"
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
DesktopLockMenuIndexLock,
|
//DesktopLockMenuIndexLock,
|
||||||
|
DesktopLockMenuIndexBt,
|
||||||
DesktopLockMenuIndexStealth,
|
DesktopLockMenuIndexStealth,
|
||||||
DesktopLockMenuIndexDummy,
|
DesktopLockMenuIndexDummy,
|
||||||
|
|
||||||
@@ -39,6 +40,11 @@ void desktop_lock_menu_set_stealth_mode_state(DesktopLockMenuView* lock_menu, bo
|
|||||||
true);
|
true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void desktop_lock_menu_set_bt_mode_state(DesktopLockMenuView* lock_menu, bool bt_mode) {
|
||||||
|
with_view_model(
|
||||||
|
lock_menu->view, DesktopLockMenuViewModel * model, { model->bt_mode = bt_mode; }, true);
|
||||||
|
}
|
||||||
|
|
||||||
void desktop_lock_menu_set_idx(DesktopLockMenuView* lock_menu, uint8_t idx) {
|
void desktop_lock_menu_set_idx(DesktopLockMenuView* lock_menu, uint8_t idx) {
|
||||||
furi_assert(idx < DesktopLockMenuIndexTotalCount);
|
furi_assert(idx < DesktopLockMenuIndexTotalCount);
|
||||||
with_view_model(
|
with_view_model(
|
||||||
@@ -56,8 +62,13 @@ void desktop_lock_menu_draw_callback(Canvas* canvas, void* model) {
|
|||||||
for(size_t i = 0; i < DesktopLockMenuIndexTotalCount; ++i) {
|
for(size_t i = 0; i < DesktopLockMenuIndexTotalCount; ++i) {
|
||||||
const char* str = NULL;
|
const char* str = NULL;
|
||||||
|
|
||||||
if(i == DesktopLockMenuIndexLock) {
|
//if(i == DesktopLockMenuIndexLock) {
|
||||||
str = "Lock";
|
if(i == DesktopLockMenuIndexBt) {
|
||||||
|
if(m->bt_mode) {
|
||||||
|
str = "Bluetooth Off";
|
||||||
|
} else {
|
||||||
|
str = "Bluetooth On";
|
||||||
|
}
|
||||||
} else if(i == DesktopLockMenuIndexStealth) {
|
} else if(i == DesktopLockMenuIndexStealth) {
|
||||||
if(m->stealth_mode) {
|
if(m->stealth_mode) {
|
||||||
str = "Unmute";
|
str = "Unmute";
|
||||||
@@ -126,10 +137,15 @@ bool desktop_lock_menu_input_callback(InputEvent* event, void* context) {
|
|||||||
update);
|
update);
|
||||||
|
|
||||||
if(event->key == InputKeyOk) {
|
if(event->key == InputKeyOk) {
|
||||||
if(idx == DesktopLockMenuIndexLock) {
|
if(idx == DesktopLockMenuIndexBt) {
|
||||||
if(event->type == InputTypeShort) {
|
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) {
|
} else if(idx == DesktopLockMenuIndexStealth) {
|
||||||
if((stealth_mode == false) && (event->type == InputTypeShort)) {
|
if((stealth_mode == false) && (event->type == InputTypeShort)) {
|
||||||
lock_menu->callback(DesktopLockMenuEventStealthModeOn, lock_menu->context);
|
lock_menu->callback(DesktopLockMenuEventStealthModeOn, lock_menu->context);
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ typedef struct {
|
|||||||
uint8_t idx;
|
uint8_t idx;
|
||||||
bool dummy_mode;
|
bool dummy_mode;
|
||||||
bool stealth_mode;
|
bool stealth_mode;
|
||||||
|
bool bt_mode;
|
||||||
} DesktopLockMenuViewModel;
|
} DesktopLockMenuViewModel;
|
||||||
|
|
||||||
void desktop_lock_menu_set_callback(
|
void desktop_lock_menu_set_callback(
|
||||||
@@ -29,6 +30,7 @@ void desktop_lock_menu_set_callback(
|
|||||||
View* desktop_lock_menu_get_view(DesktopLockMenuView* lock_menu);
|
View* desktop_lock_menu_get_view(DesktopLockMenuView* lock_menu);
|
||||||
void desktop_lock_menu_set_dummy_mode_state(DesktopLockMenuView* lock_menu, bool dummy_mode);
|
void desktop_lock_menu_set_dummy_mode_state(DesktopLockMenuView* lock_menu, bool dummy_mode);
|
||||||
void desktop_lock_menu_set_stealth_mode_state(DesktopLockMenuView* lock_menu, bool stealth_mode);
|
void desktop_lock_menu_set_stealth_mode_state(DesktopLockMenuView* lock_menu, bool stealth_mode);
|
||||||
|
void desktop_lock_menu_set_bt_mode_state(DesktopLockMenuView* lock_menu, bool bt_mode);
|
||||||
void desktop_lock_menu_set_idx(DesktopLockMenuView* lock_menu, uint8_t idx);
|
void desktop_lock_menu_set_idx(DesktopLockMenuView* lock_menu, uint8_t idx);
|
||||||
DesktopLockMenuView* desktop_lock_menu_alloc(void);
|
DesktopLockMenuView* desktop_lock_menu_alloc(void);
|
||||||
void desktop_lock_menu_free(DesktopLockMenuView* lock_menu);
|
void desktop_lock_menu_free(DesktopLockMenuView* lock_menu);
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ void power_settings_scene_power_off_on_enter(void* context) {
|
|||||||
if(!settings.happy_mode) {
|
if(!settings.happy_mode) {
|
||||||
dialog_ex_set_text(
|
dialog_ex_set_text(
|
||||||
dialog, " I will be\nwaiting for\n you here...", 78, 14, AlignLeft, AlignTop);
|
dialog, " I will be\nwaiting for\n you here...", 78, 14, AlignLeft, AlignTop);
|
||||||
dialog_ex_set_icon(dialog, 14, 10, &I_dolph_cry_49x54);
|
dialog_ex_set_icon(dialog, 24, 10, &I_dolph_cry_49x54);
|
||||||
}
|
}
|
||||||
dialog_ex_set_left_button_text(dialog, "Settings");
|
dialog_ex_set_left_button_text(dialog, "Settings");
|
||||||
dialog_ex_set_right_button_text(dialog, "Power Off");
|
dialog_ex_set_right_button_text(dialog, "Power Off");
|
||||||
|
|||||||
Reference in New Issue
Block a user