mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-04-24 03:29:57 -07:00
Revert some settings handling to how they work in OFW
This commit is contained in:
@@ -14,7 +14,7 @@ App(
|
||||
],
|
||||
stack_size=1 * 1024,
|
||||
order=1000,
|
||||
sdk_headers=["bt_service/bt.h", "bt_service/bt_keys_storage.h", "bt_settings.h"],
|
||||
sdk_headers=["bt_service/bt.h", "bt_service/bt_keys_storage.h"],
|
||||
)
|
||||
|
||||
App(
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
#include <ble/ble.h>
|
||||
#include "bt_settings.h"
|
||||
#include "bt_service/bt_i.h"
|
||||
#include "bt_service/bt.h"
|
||||
#include <profiles/serial_profile.h>
|
||||
|
||||
static void bt_cli_command_hci_info(Cli* cli, FuriString* args, void* context) {
|
||||
@@ -181,10 +181,12 @@ static void bt_cli_print_usage(void) {
|
||||
|
||||
static void bt_cli(Cli* cli, FuriString* args, void* context) {
|
||||
UNUSED(context);
|
||||
Bt* bt = furi_record_open(RECORD_BT);
|
||||
furi_record_open(RECORD_BT);
|
||||
|
||||
FuriString* cmd;
|
||||
cmd = furi_string_alloc();
|
||||
BtSettings bt_settings;
|
||||
bt_settings_load(&bt_settings);
|
||||
|
||||
do {
|
||||
if(!args_read_string_and_trim(args, cmd)) {
|
||||
@@ -217,7 +219,7 @@ static void bt_cli(Cli* cli, FuriString* args, void* context) {
|
||||
bt_cli_print_usage();
|
||||
} while(false);
|
||||
|
||||
if(bt->bt_settings.enabled) {
|
||||
if(bt_settings.enabled) {
|
||||
furi_hal_bt_start_advertising();
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#include <bt/bt_settings.h>
|
||||
#include <bt/bt_service/bt_keys_storage.h>
|
||||
|
||||
#define BT_KEYS_STORAGE_PATH CFG_PATH("bt.keys")
|
||||
#include "bt_keys_filename.h"
|
||||
|
||||
typedef enum {
|
||||
BtMessageTypeUpdateStatus,
|
||||
|
||||
5
applications/services/bt/bt_service/bt_keys_filename.h
Normal file
5
applications/services/bt/bt_service/bt_keys_filename.h
Normal file
@@ -0,0 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#define BT_KEYS_STORAGE_FILE_NAME ".bt.keys"
|
||||
|
||||
#define BT_KEYS_STORAGE_PATH INT_PATH(BT_KEYS_STORAGE_FILE_NAME)
|
||||
@@ -6,8 +6,6 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define BT_SETTINGS_PATH CFG_PATH("bt.settings")
|
||||
|
||||
typedef struct {
|
||||
bool enabled;
|
||||
} BtSettings;
|
||||
|
||||
5
applications/services/bt/bt_settings_filename.h
Normal file
5
applications/services/bt/bt_settings_filename.h
Normal file
@@ -0,0 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#define BT_SETTINGS_FILE_NAME ".bt.settings"
|
||||
|
||||
#define BT_SETTINGS_PATH INT_PATH(BT_SETTINGS_FILE_NAME)
|
||||
@@ -68,8 +68,7 @@ static void animation_manager_start_new_idle(AnimationManager* animation_manager
|
||||
static bool animation_manager_check_blocking(AnimationManager* animation_manager);
|
||||
static bool animation_manager_is_valid_idle_animation(
|
||||
const StorageAnimationManifestInfo* info,
|
||||
const DolphinStats* stats,
|
||||
const bool unlock);
|
||||
const DolphinStats* stats);
|
||||
static void animation_manager_switch_to_one_shot_view(AnimationManager* animation_manager);
|
||||
static void animation_manager_switch_to_animation_view(AnimationManager* animation_manager);
|
||||
|
||||
@@ -148,8 +147,7 @@ void animation_manager_check_blocking_process(AnimationManager* animation_manage
|
||||
|
||||
const StorageAnimationManifestInfo* manifest_info =
|
||||
animation_storage_get_meta(animation_manager->current_animation);
|
||||
bool valid = animation_manager_is_valid_idle_animation(
|
||||
manifest_info, &stats, momentum_settings.unlock_anims);
|
||||
bool valid = animation_manager_is_valid_idle_animation(manifest_info, &stats);
|
||||
|
||||
if(!valid) {
|
||||
animation_manager_start_new_idle(animation_manager);
|
||||
@@ -343,8 +341,7 @@ View* animation_manager_get_animation_view(AnimationManager* animation_manager)
|
||||
|
||||
static bool animation_manager_is_valid_idle_animation(
|
||||
const StorageAnimationManifestInfo* info,
|
||||
const DolphinStats* stats,
|
||||
const bool unlock) {
|
||||
const DolphinStats* stats) {
|
||||
furi_assert(info);
|
||||
furi_assert(info->name);
|
||||
|
||||
@@ -364,7 +361,7 @@ static bool animation_manager_is_valid_idle_animation(
|
||||
|
||||
result = (sd_status == FSE_NOT_READY);
|
||||
}
|
||||
if(!unlock) {
|
||||
if(!momentum_settings.unlock_anims) {
|
||||
if((stats->butthurt < info->min_butthurt) || (stats->butthurt > info->max_butthurt)) {
|
||||
result = false;
|
||||
}
|
||||
@@ -394,13 +391,12 @@ static StorageAnimation*
|
||||
uint32_t whole_weight = 0;
|
||||
|
||||
// Filter valid animations
|
||||
bool unlock = momentum_settings.unlock_anims;
|
||||
StorageAnimationList_it_t it;
|
||||
for(StorageAnimationList_it(it, animation_list); !StorageAnimationList_end_p(it);) {
|
||||
StorageAnimation* storage_animation = *StorageAnimationList_ref(it);
|
||||
const StorageAnimationManifestInfo* manifest_info =
|
||||
animation_storage_get_meta(storage_animation);
|
||||
bool valid = animation_manager_is_valid_idle_animation(manifest_info, &stats, unlock);
|
||||
bool valid = animation_manager_is_valid_idle_animation(manifest_info, &stats);
|
||||
|
||||
if(strcmp(manifest_info->name, HARDCODED_ANIMATION_NAME) == 0) {
|
||||
// Dont pick error anim randomly
|
||||
@@ -546,8 +542,7 @@ void animation_manager_load_and_continue_animation(AnimationManager* animation_m
|
||||
furi_record_close(RECORD_DOLPHIN);
|
||||
const StorageAnimationManifestInfo* manifest_info =
|
||||
animation_storage_get_meta(restore_animation);
|
||||
bool valid = animation_manager_is_valid_idle_animation(
|
||||
manifest_info, &stats, momentum_settings.unlock_anims);
|
||||
bool valid = animation_manager_is_valid_idle_animation(manifest_info, &stats);
|
||||
// Restore only if anim is valid and not the error anim
|
||||
if(valid && strcmp(manifest_info->name, HARDCODED_ANIMATION_NAME) != 0) {
|
||||
animation_manager_replace_current_animation(
|
||||
@@ -559,11 +554,10 @@ void animation_manager_load_and_continue_animation(AnimationManager* animation_m
|
||||
animation_manager->idle_animation_timer,
|
||||
animation_manager->freezed_animation_time_left);
|
||||
} else {
|
||||
const BubbleAnimation* bubble_animation =
|
||||
animation_storage_get_bubble_animation(
|
||||
animation_manager->current_animation);
|
||||
const BubbleAnimation* animation = animation_storage_get_bubble_animation(
|
||||
animation_manager->current_animation);
|
||||
int32_t duration = (momentum_settings.cycle_anims == 0) ?
|
||||
(bubble_animation->duration) :
|
||||
(animation->duration) :
|
||||
(momentum_settings.cycle_anims);
|
||||
furi_timer_start(
|
||||
animation_manager->idle_animation_timer,
|
||||
|
||||
@@ -57,6 +57,7 @@ static bool animation_storage_load_single_manifest_info(
|
||||
const char* name) {
|
||||
furi_assert(manifest_info);
|
||||
animation_handler_select_manifest();
|
||||
|
||||
bool result = false;
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
FlipperFormat* file = flipper_format_file_alloc(storage);
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
#define SLIDESHOW_FILE_NAME ".slideshow"
|
||||
@@ -13,6 +13,7 @@ struct DesktopSlideshowView {
|
||||
DesktopSlideshowViewCallback callback;
|
||||
void* context;
|
||||
FuriTimer* timer;
|
||||
|
||||
FuriTimer* auto_timer;
|
||||
};
|
||||
|
||||
|
||||
@@ -3,9 +3,10 @@
|
||||
#include <gui/view.h>
|
||||
|
||||
#include "desktop_events.h"
|
||||
#include "../helpers/slideshow_filename.h"
|
||||
#include <storage/storage.h>
|
||||
|
||||
#define SLIDESHOW_FS_PATH EXT_PATH(".slideshow")
|
||||
#define SLIDESHOW_FS_PATH INT_PATH(SLIDESHOW_FILE_NAME)
|
||||
|
||||
typedef struct DesktopSlideshowView DesktopSlideshowView;
|
||||
|
||||
|
||||
@@ -6,8 +6,5 @@ App(
|
||||
cdefines=["SRV_DOLPHIN"],
|
||||
stack_size=1 * 1024,
|
||||
order=50,
|
||||
sdk_headers=[
|
||||
"dolphin.h",
|
||||
"helpers/dolphin_state.h",
|
||||
],
|
||||
sdk_headers=["dolphin.h", "helpers/dolphin_state.h"],
|
||||
)
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#define DOLPHIN_STATE_FILE_NAME ".dolphin.state"
|
||||
|
||||
#define DOLPHIN_STATE_PATH INT_PATH(DOLPHIN_STATE_FILE_NAME)
|
||||
@@ -5,7 +5,6 @@ App(
|
||||
cdefines=["SRV_EXPANSION"],
|
||||
sdk_headers=[
|
||||
"expansion.h",
|
||||
"expansion_i.h",
|
||||
"expansion_settings.h",
|
||||
],
|
||||
requires=["rpc_start"],
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#include "expansion.h"
|
||||
#include "expansion_i.h"
|
||||
|
||||
#include <furi_hal_serial_control.h>
|
||||
|
||||
@@ -34,10 +33,8 @@ typedef enum {
|
||||
} ExpansionMessageType;
|
||||
|
||||
typedef union {
|
||||
union {
|
||||
FuriHalSerialId serial_id;
|
||||
bool* is_connected;
|
||||
};
|
||||
FuriHalSerialId serial_id;
|
||||
bool* is_connected;
|
||||
} ExpansionMessageData;
|
||||
|
||||
typedef struct {
|
||||
@@ -52,8 +49,6 @@ struct Expansion {
|
||||
FuriHalSerialId serial_id;
|
||||
ExpansionWorker* worker;
|
||||
ExpansionState state;
|
||||
|
||||
ExpansionSettings settings;
|
||||
};
|
||||
|
||||
static const char* const expansion_uart_names[] = {
|
||||
@@ -110,7 +105,7 @@ static void
|
||||
|
||||
if(settings.uart_index < FuriHalSerialIdMax) {
|
||||
instance->state = ExpansionStateEnabled;
|
||||
instance->serial_id = instance->settings.uart_index;
|
||||
instance->serial_id = settings.uart_index;
|
||||
furi_hal_serial_control_set_expansion_callback(
|
||||
instance->serial_id, expansion_detect_callback, instance);
|
||||
|
||||
@@ -307,7 +302,6 @@ void expansion_on_system_start(void* arg) {
|
||||
return;
|
||||
}
|
||||
|
||||
expansion_settings_load(&instance->settings);
|
||||
expansion_enable(instance);
|
||||
}
|
||||
|
||||
@@ -366,7 +360,3 @@ void expansion_set_listen_serial(Expansion* instance, FuriHalSerialId serial_id)
|
||||
furi_message_queue_put(instance->queue, &message, FuriWaitForever);
|
||||
api_lock_wait_unlock_and_free(message.api_lock);
|
||||
}
|
||||
|
||||
ExpansionSettings* expansion_get_settings(Expansion* instance) {
|
||||
return &instance->settings;
|
||||
}
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "expansion_settings.h"
|
||||
#include "expansion.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
ExpansionSettings* expansion_get_settings(Expansion* instance);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -6,4 +6,6 @@
|
||||
/**
|
||||
* @brief File name used for expansion settings.
|
||||
*/
|
||||
#define EXPANSION_SETTINGS_PATH CFG_PATH("expansion.settings")
|
||||
#define EXPANSION_SETTINGS_FILE_NAME ".expansion.settings"
|
||||
|
||||
#define EXPANSION_SETTINGS_PATH INT_PATH(EXPANSION_SETTINGS_FILE_NAME)
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
#include <momentum/momentum.h>
|
||||
#include "gui_i.h"
|
||||
#include <assets_icons.h>
|
||||
|
||||
#include <storage/storage.h>
|
||||
#include <storage/storage_i.h>
|
||||
#include <momentum/momentum.h>
|
||||
|
||||
#define TAG "GuiSrv"
|
||||
|
||||
@@ -628,7 +629,6 @@ Gui* gui_alloc(void) {
|
||||
gui->ascii_events = furi_record_open(RECORD_ASCII_EVENTS);
|
||||
|
||||
furi_pubsub_subscribe(gui->input_events, gui_input_events_callback, gui);
|
||||
furi_check(gui->ascii_events);
|
||||
furi_pubsub_subscribe(gui->ascii_events, gui_ascii_events_callback, gui);
|
||||
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
|
||||
@@ -471,26 +471,24 @@ static NotificationApp* notification_app_alloc(void) {
|
||||
app->settings.display_off_delay_ms = 30000;
|
||||
app->settings.vibro_on = true;
|
||||
|
||||
// malloc() also does memset(0), no need to init 0 values
|
||||
_Static_assert(LayerInternal == 0, "need to init layer values");
|
||||
// app->display.value[LayerInternal] = 0x00;
|
||||
// app->display.value[LayerNotification] = 0x00;
|
||||
// app->display.index = LayerInternal;
|
||||
app->display.value[LayerInternal] = 0x00;
|
||||
app->display.value[LayerNotification] = 0x00;
|
||||
app->display.index = LayerInternal;
|
||||
app->display.light = LightBacklight;
|
||||
|
||||
// app->led[0].value[LayerInternal] = 0x00;
|
||||
// app->led[0].value[LayerNotification] = 0x00;
|
||||
// app->led[0].index = LayerInternal;
|
||||
app->led[0].value[LayerInternal] = 0x00;
|
||||
app->led[0].value[LayerNotification] = 0x00;
|
||||
app->led[0].index = LayerInternal;
|
||||
app->led[0].light = LightRed;
|
||||
|
||||
// app->led[1].value[LayerInternal] = 0x00;
|
||||
// app->led[1].value[LayerNotification] = 0x00;
|
||||
// app->led[1].index = LayerInternal;
|
||||
app->led[1].value[LayerInternal] = 0x00;
|
||||
app->led[1].value[LayerNotification] = 0x00;
|
||||
app->led[1].index = LayerInternal;
|
||||
app->led[1].light = LightGreen;
|
||||
|
||||
// app->led[2].value[LayerInternal] = 0x00;
|
||||
// app->led[2].value[LayerNotification] = 0x00;
|
||||
// app->led[2].index = LayerInternal;
|
||||
app->led[2].value[LayerInternal] = 0x00;
|
||||
app->led[2].value[LayerNotification] = 0x00;
|
||||
app->led[2].index = LayerInternal;
|
||||
app->led[2].light = LightBlue;
|
||||
|
||||
app->settings.version = NOTIFICATION_SETTINGS_VERSION;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include <furi_hal.h>
|
||||
#include "notification.h"
|
||||
#include "notification_messages.h"
|
||||
#include "notification_settings_filename.h"
|
||||
|
||||
#define NOTIFICATION_LED_COUNT 3
|
||||
#define NOTIFICATION_EVENT_COMPLETE 0x00000001U
|
||||
@@ -34,7 +35,6 @@ typedef struct {
|
||||
|
||||
#define NOTIFICATION_SETTINGS_VERSION 0x02
|
||||
#define NOTIFICATION_SETTINGS_MAGIC 0x16
|
||||
#define NOTIFICATION_SETTINGS_PATH CFG_PATH("notification.settings")
|
||||
|
||||
typedef struct {
|
||||
uint8_t version;
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#define NOTIFICATION_SETTINGS_FILE_NAME ".notification.settings"
|
||||
|
||||
#define NOTIFICATION_SETTINGS_PATH INT_PATH(NOTIFICATION_SETTINGS_FILE_NAME)
|
||||
@@ -27,6 +27,7 @@ enum BtSettingsCustomEvent {
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
BtSettings settings;
|
||||
Bt* bt;
|
||||
Gui* gui;
|
||||
SceneManager* scene_manager;
|
||||
|
||||
@@ -46,7 +46,7 @@ void bt_settings_scene_start_on_enter(void* context) {
|
||||
BtSettingNum,
|
||||
bt_settings_scene_start_var_list_change_callback,
|
||||
app);
|
||||
if(app->bt->bt_settings.enabled) {
|
||||
if(app->settings.enabled) {
|
||||
variable_item_set_current_value_index(item, BtSettingOn);
|
||||
variable_item_set_current_value_text(item, bt_settings_text[BtSettingOn]);
|
||||
} else {
|
||||
|
||||
@@ -10,7 +10,7 @@ static void expansion_settings_app_uart_changed(VariableItem* item) {
|
||||
ExpansionSettingsApp* app = variable_item_get_context(item);
|
||||
const uint8_t index = variable_item_get_current_value_index(item);
|
||||
variable_item_set_current_value_text(item, expansion_uart_text[index]);
|
||||
app->settings->uart_index = index;
|
||||
app->settings.uart_index = index;
|
||||
|
||||
if(index < FuriHalSerialIdMax) {
|
||||
expansion_set_listen_serial(app->expansion, index);
|
||||
@@ -31,7 +31,6 @@ static ExpansionSettingsApp* expansion_settings_app_alloc(void) {
|
||||
|
||||
app->gui = furi_record_open(RECORD_GUI);
|
||||
app->expansion = furi_record_open(RECORD_EXPANSION);
|
||||
app->settings = expansion_get_settings(app->expansion);
|
||||
|
||||
app->view_dispatcher = view_dispatcher_alloc();
|
||||
view_dispatcher_enable_queue(app->view_dispatcher);
|
||||
@@ -50,7 +49,7 @@ static ExpansionSettingsApp* expansion_settings_app_alloc(void) {
|
||||
COUNT_OF(expansion_uart_text),
|
||||
expansion_settings_app_uart_changed,
|
||||
app);
|
||||
value_index = app->settings->uart_index;
|
||||
value_index = app->settings.uart_index;
|
||||
variable_item_set_current_value_index(item, value_index);
|
||||
variable_item_set_current_value_text(item, expansion_uart_text[value_index]);
|
||||
|
||||
@@ -69,7 +68,7 @@ static ExpansionSettingsApp* expansion_settings_app_alloc(void) {
|
||||
static void expansion_settings_app_free(ExpansionSettingsApp* app) {
|
||||
furi_assert(app);
|
||||
|
||||
expansion_settings_save(app->settings);
|
||||
expansion_settings_save(&app->settings);
|
||||
|
||||
view_dispatcher_remove_view(app->view_dispatcher, ExpansionSettingsViewVarItemList);
|
||||
variable_item_list_free(app->var_item_list);
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
#include <gui/modules/variable_item_list.h>
|
||||
|
||||
#include <expansion/expansion.h>
|
||||
#include <expansion/expansion_i.h>
|
||||
#include <expansion/expansion_settings.h>
|
||||
|
||||
typedef struct {
|
||||
@@ -16,7 +15,7 @@ typedef struct {
|
||||
ViewDispatcher* view_dispatcher;
|
||||
VariableItemList* var_item_list;
|
||||
Expansion* expansion;
|
||||
ExpansionSettings* settings;
|
||||
ExpansionSettings settings;
|
||||
} ExpansionSettingsApp;
|
||||
|
||||
typedef enum {
|
||||
|
||||
@@ -193,7 +193,7 @@ static NotificationAppSettings* alloc_settings(void) {
|
||||
variable_item_set_current_value_text(item, contrast_text[value_index]);
|
||||
|
||||
item = variable_item_list_add(
|
||||
app->variable_item_list, "LCD Brightness", BACKLIGHT_COUNT, backlight_changed, app);
|
||||
app->variable_item_list, "LCD Backlight", BACKLIGHT_COUNT, backlight_changed, app);
|
||||
value_index = value_index_float(
|
||||
app->notification->settings.display_brightness, backlight_value, BACKLIGHT_COUNT);
|
||||
variable_item_set_current_value_index(item, value_index);
|
||||
|
||||
Reference in New Issue
Block a user