Skip to content

Commit f2be53b

Browse files
committed
CFW Settings for Main Menu Start Point
1 parent 4b110d3 commit f2be53b

File tree

6 files changed

+54
-3
lines changed

6 files changed

+54
-3
lines changed

ReadMe.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ This software is for experimental purposes only and is not meant for any illegal
4747
- OFW (Nothing Applied): [increased timeouts #2816 (By doomwastaken)](https://github.com/flipperdevices/flipperzero-firmware/pull/2816)
4848
- OFW PR: [Furi,FuriHal: various improvements #2819 (By skotopes)](https://github.com/flipperdevices/flipperzero-firmware/pull/2819)
4949
- [Loader Menu Reorder - Third time's a charm #687 (By ESurge)](https://github.com/RogueMaster/flipperzero-firmware-wPlugins/pull/687)
50+
- CFW Settings for Main Menu Start Point (By RogueMaster) Needs fixes to set added favorites.
5051

5152
<a name="release">
5253

applications/services/loader/loader_menu.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include <gui/modules/submenu.h>
55
#include <assets_icons.h>
66
#include <applications.h>
7+
#include <cfw.h>
78

89
#include "loader.h"
910
#include "loader_menu.h"
@@ -190,7 +191,9 @@ static LoaderMenuApp* loader_menu_app_alloc(LoaderMenu* loader_menu) {
190191
LoaderMenuApp* app = malloc(sizeof(LoaderMenuApp));
191192
app->gui = furi_record_open(RECORD_GUI);
192193
app->view_dispatcher = view_dispatcher_alloc();
193-
app->primary_menu = menu_pos_alloc(0);
194+
size_t my_start_point = (size_t)CFW_SETTINGS()->start_point;
195+
if(my_start_point < 0 || my_start_point > 14) my_start_point = 0;
196+
app->primary_menu = menu_pos_alloc(my_start_point);
194197
app->settings_menu = submenu_alloc();
195198

196199
loader_menu_build_menu(app, loader_menu);

applications/settings/cfw_app/scenes/cfw_app_scene_interface.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ void cfw_app_scene_interface_on_enter(void* context) {
1616
CfwApp* app = context;
1717
VariableItemList* var_item_list = app->var_item_list;
1818

19-
variable_item_list_add(var_item_list, "Mainmenu", 0, NULL, app);
19+
variable_item_list_add(var_item_list, "Main Menu", 0, NULL, app);
2020
// variable_item_list_add(var_item_list, "Lockscreen", 0, NULL, app);
2121
// variable_item_list_add(var_item_list, "Statusbar", 0, NULL, app);
2222
variable_item_list_add(var_item_list, "Common", 0, NULL, app);

applications/settings/cfw_app/scenes/cfw_app_scene_interface_mainmenu.c

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,28 @@
11
#include "../cfw_app.h"
22

3+
#define START_POINT_COUNT 15
4+
const char* const start_point_text[START_POINT_COUNT] = {
5+
"Clock",
6+
"Sub-GHz",
7+
"Sub-GHz Remote",
8+
"Sub-GHz Playlist",
9+
"125 kHz RFID",
10+
"NFC",
11+
"Infrared",
12+
"IR Remote",
13+
"GPIO",
14+
"iButton",
15+
"Bad USB",
16+
"U2F",
17+
"CFW Settings",
18+
"Settings",
19+
"Applications"};
20+
const uint32_t start_point_value[START_POINT_COUNT] =
21+
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14};
22+
323
enum VarItemListIndex {
424
VarItemListIndexWiiMenu,
25+
VarItemListIndexStartPoint,
526
VarItemListIndexApp,
627
VarItemListIndexRemoveApp,
728
VarItemListIndexAddApp,
@@ -20,6 +41,14 @@ static void cfw_app_scene_interface_mainmenu_wii_menu_changed(VariableItem* item
2041
app->save_settings = true;
2142
}
2243

44+
static void cfw_app_scene_interface_mainmenu_start_point_changed(VariableItem* item) {
45+
CfwApp* app = variable_item_get_context(item);
46+
uint32_t value = variable_item_get_current_value_index(item);
47+
variable_item_set_current_value_text(item, start_point_text[value]);
48+
CFW_SETTINGS()->start_point = value;
49+
app->save_settings = true;
50+
}
51+
2352
static void cfw_app_scene_interface_mainmenu_app_changed(VariableItem* item) {
2453
CfwApp* app = variable_item_get_context(item);
2554
app->mainmenu_app_index = variable_item_get_current_value_index(item);
@@ -32,12 +61,25 @@ void cfw_app_scene_interface_mainmenu_on_enter(void* context) {
3261
CfwSettings* cfw_settings = CFW_SETTINGS();
3362
VariableItemList* var_item_list = app->var_item_list;
3463
VariableItem* item;
64+
uint32_t value_index;
3565

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

71+
item = variable_item_list_add(
72+
var_item_list,
73+
"Start Point",
74+
START_POINT_COUNT,
75+
cfw_app_scene_interface_mainmenu_start_point_changed,
76+
app);
77+
78+
value_index =
79+
value_index_uint32(cfw_settings->start_point, start_point_value, START_POINT_COUNT);
80+
variable_item_set_current_value_index(item, value_index);
81+
variable_item_set_current_value_text(item, start_point_text[value_index]);
82+
4183
item = variable_item_list_add(
4284
var_item_list,
4385
"App",

lib/cfw/cfw.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ extern "C" {
1515

1616
typedef struct {
1717
bool wii_menu;
18+
uint32_t start_point;
1819
bool bad_pins_format;
1920
// bool lockscreen_time;
2021
// bool lockscreen_seconds;

lib/cfw/settings.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
CfwSettings cfw_settings = {
99
.wii_menu = false, // OFF
10+
.start_point = 0, // First Item
1011
.bad_pins_format = false, // OFF
1112
// .lockscreen_time = true, // ON
1213
// .lockscreen_seconds = false, // OFF
@@ -30,6 +31,8 @@ void CFW_SETTINGS_LOAD() {
3031
flipper_format_rewind(file);
3132
flipper_format_read_bool(file, "wii_menu", &x->wii_menu, 1);
3233
flipper_format_rewind(file);
34+
flipper_format_read_uint32(file, "start_point", &x->start_point, 1);
35+
flipper_format_rewind(file);
3336
flipper_format_read_bool(file, "bad_pins_format", &x->bad_pins_format, 1);
3437
// flipper_format_rewind(file);
3538
// flipper_format_read_bool(file, "lockscreen_time", &x->lockscreen_time, 1);
@@ -47,8 +50,8 @@ void CFW_SETTINGS_LOAD() {
4750
flipper_format_read_bool(file, "dark_mode", &x->dark_mode, 1);
4851
// flipper_format_rewind(file);
4952
// flipper_format_read_uint32(file, "favorite_timeout", &x->favorite_timeout, 1);
50-
flipper_format_read_uint32(file, "charge_cap", &x->charge_cap, 1);
5153
flipper_format_rewind(file);
54+
flipper_format_read_uint32(file, "charge_cap", &x->charge_cap, 1);
5255
flipper_format_rewind(file);
5356
flipper_format_read_bool(file, "rgb_backlight", &x->rgb_backlight, 1);
5457
}
@@ -65,6 +68,7 @@ void CFW_SETTINGS_SAVE() {
6568
FlipperFormat* file = flipper_format_file_alloc(storage);
6669
if(flipper_format_file_open_always(file, CFW_SETTINGS_PATH)) {
6770
flipper_format_write_bool(file, "wii_menu", &x->wii_menu, 1);
71+
flipper_format_write_uint32(file, "start_point", &x->start_point, 1);
6872
flipper_format_write_bool(file, "bad_pins_format", &x->bad_pins_format, 1);
6973
// flipper_format_write_bool(file, "lockscreen_time", &x->lockscreen_time, 1);
7074
// flipper_format_write_bool(file, "lockscreen_seconds", &x->lockscreen_seconds, 1);

0 commit comments

Comments
 (0)