Skip to content

Commit

Permalink
CFW Settings for Main Menu Start Point
Browse files Browse the repository at this point in the history
  • Loading branch information
RogueMaster committed Jun 30, 2023
1 parent 4b110d3 commit f2be53b
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 3 deletions.
1 change: 1 addition & 0 deletions ReadMe.md
Expand Up @@ -47,6 +47,7 @@ This software is for experimental purposes only and is not meant for any illegal
- OFW (Nothing Applied): [increased timeouts #2816 (By doomwastaken)](https://github.com/flipperdevices/flipperzero-firmware/pull/2816)
- OFW PR: [Furi,FuriHal: various improvements #2819 (By skotopes)](https://github.com/flipperdevices/flipperzero-firmware/pull/2819)
- [Loader Menu Reorder - Third time's a charm #687 (By ESurge)](https://github.com/RogueMaster/flipperzero-firmware-wPlugins/pull/687)
- CFW Settings for Main Menu Start Point (By RogueMaster) Needs fixes to set added favorites.

<a name="release">

Expand Down
5 changes: 4 additions & 1 deletion applications/services/loader/loader_menu.c
Expand Up @@ -4,6 +4,7 @@
#include <gui/modules/submenu.h>
#include <assets_icons.h>
#include <applications.h>
#include <cfw.h>

#include "loader.h"
#include "loader_menu.h"
Expand Down Expand Up @@ -190,7 +191,9 @@ static LoaderMenuApp* loader_menu_app_alloc(LoaderMenu* loader_menu) {
LoaderMenuApp* app = malloc(sizeof(LoaderMenuApp));
app->gui = furi_record_open(RECORD_GUI);
app->view_dispatcher = view_dispatcher_alloc();
app->primary_menu = menu_pos_alloc(0);
size_t my_start_point = (size_t)CFW_SETTINGS()->start_point;
if(my_start_point < 0 || my_start_point > 14) my_start_point = 0;
app->primary_menu = menu_pos_alloc(my_start_point);
app->settings_menu = submenu_alloc();

loader_menu_build_menu(app, loader_menu);
Expand Down
Expand Up @@ -16,7 +16,7 @@ void cfw_app_scene_interface_on_enter(void* context) {
CfwApp* app = context;
VariableItemList* var_item_list = app->var_item_list;

variable_item_list_add(var_item_list, "Mainmenu", 0, NULL, app);
variable_item_list_add(var_item_list, "Main Menu", 0, NULL, app);
// variable_item_list_add(var_item_list, "Lockscreen", 0, NULL, app);
// variable_item_list_add(var_item_list, "Statusbar", 0, NULL, app);
variable_item_list_add(var_item_list, "Common", 0, NULL, app);
Expand Down
@@ -1,7 +1,28 @@
#include "../cfw_app.h"

#define START_POINT_COUNT 15
const char* const start_point_text[START_POINT_COUNT] = {
"Clock",
"Sub-GHz",
"Sub-GHz Remote",
"Sub-GHz Playlist",
"125 kHz RFID",
"NFC",
"Infrared",
"IR Remote",
"GPIO",
"iButton",
"Bad USB",
"U2F",
"CFW Settings",
"Settings",
"Applications"};
const uint32_t start_point_value[START_POINT_COUNT] =
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14};

enum VarItemListIndex {
VarItemListIndexWiiMenu,
VarItemListIndexStartPoint,
VarItemListIndexApp,
VarItemListIndexRemoveApp,
VarItemListIndexAddApp,
Expand All @@ -20,6 +41,14 @@ static void cfw_app_scene_interface_mainmenu_wii_menu_changed(VariableItem* item
app->save_settings = true;
}

static void cfw_app_scene_interface_mainmenu_start_point_changed(VariableItem* item) {
CfwApp* app = variable_item_get_context(item);
uint32_t value = variable_item_get_current_value_index(item);
variable_item_set_current_value_text(item, start_point_text[value]);
CFW_SETTINGS()->start_point = value;
app->save_settings = true;
}

static void cfw_app_scene_interface_mainmenu_app_changed(VariableItem* item) {
CfwApp* app = variable_item_get_context(item);
app->mainmenu_app_index = variable_item_get_current_value_index(item);
Expand All @@ -32,12 +61,25 @@ void cfw_app_scene_interface_mainmenu_on_enter(void* context) {
CfwSettings* cfw_settings = CFW_SETTINGS();
VariableItemList* var_item_list = app->var_item_list;
VariableItem* item;
uint32_t value_index;

item = variable_item_list_add(
var_item_list, "Menu Style", 2, cfw_app_scene_interface_mainmenu_wii_menu_changed, app);
variable_item_set_current_value_index(item, cfw_settings->wii_menu);
variable_item_set_current_value_text(item, cfw_settings->wii_menu ? "Wii Grid" : "App List");

item = variable_item_list_add(
var_item_list,
"Start Point",
START_POINT_COUNT,
cfw_app_scene_interface_mainmenu_start_point_changed,
app);

value_index =
value_index_uint32(cfw_settings->start_point, start_point_value, START_POINT_COUNT);
variable_item_set_current_value_index(item, value_index);
variable_item_set_current_value_text(item, start_point_text[value_index]);

item = variable_item_list_add(
var_item_list,
"App",
Expand Down
1 change: 1 addition & 0 deletions lib/cfw/cfw.h
Expand Up @@ -15,6 +15,7 @@ extern "C" {

typedef struct {
bool wii_menu;
uint32_t start_point;
bool bad_pins_format;
// bool lockscreen_time;
// bool lockscreen_seconds;
Expand Down
6 changes: 5 additions & 1 deletion lib/cfw/settings.c
Expand Up @@ -7,6 +7,7 @@

CfwSettings cfw_settings = {
.wii_menu = false, // OFF
.start_point = 0, // First Item
.bad_pins_format = false, // OFF
// .lockscreen_time = true, // ON
// .lockscreen_seconds = false, // OFF
Expand All @@ -30,6 +31,8 @@ void CFW_SETTINGS_LOAD() {
flipper_format_rewind(file);
flipper_format_read_bool(file, "wii_menu", &x->wii_menu, 1);
flipper_format_rewind(file);
flipper_format_read_uint32(file, "start_point", &x->start_point, 1);
flipper_format_rewind(file);
flipper_format_read_bool(file, "bad_pins_format", &x->bad_pins_format, 1);
// flipper_format_rewind(file);
// flipper_format_read_bool(file, "lockscreen_time", &x->lockscreen_time, 1);
Expand All @@ -47,8 +50,8 @@ void CFW_SETTINGS_LOAD() {
flipper_format_read_bool(file, "dark_mode", &x->dark_mode, 1);
// flipper_format_rewind(file);
// flipper_format_read_uint32(file, "favorite_timeout", &x->favorite_timeout, 1);
flipper_format_read_uint32(file, "charge_cap", &x->charge_cap, 1);
flipper_format_rewind(file);
flipper_format_read_uint32(file, "charge_cap", &x->charge_cap, 1);
flipper_format_rewind(file);
flipper_format_read_bool(file, "rgb_backlight", &x->rgb_backlight, 1);
}
Expand All @@ -65,6 +68,7 @@ void CFW_SETTINGS_SAVE() {
FlipperFormat* file = flipper_format_file_alloc(storage);
if(flipper_format_file_open_always(file, CFW_SETTINGS_PATH)) {
flipper_format_write_bool(file, "wii_menu", &x->wii_menu, 1);
flipper_format_write_uint32(file, "start_point", &x->start_point, 1);
flipper_format_write_bool(file, "bad_pins_format", &x->bad_pins_format, 1);
// flipper_format_write_bool(file, "lockscreen_time", &x->lockscreen_time, 1);
// flipper_format_write_bool(file, "lockscreen_seconds", &x->lockscreen_seconds, 1);
Expand Down

0 comments on commit f2be53b

Please sign in to comment.