Skip to content

Commit

Permalink
Merge pull request #296 from Next-Flip/feat/settings-warnings
Browse files Browse the repository at this point in the history
Settings: Add warnings for settings you shouldn't touch
  • Loading branch information
Willy-JL authored Nov 10, 2024
2 parents 9e4ff66 + 2d559a1 commit 8b84222
Show file tree
Hide file tree
Showing 6 changed files with 112 additions and 10 deletions.
8 changes: 6 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@
- Added typedocs for all extra JS modules in Momentum (by @Willy-JL)
- RPC: Added ASCII event support (#284 by @Willy-JL)
- FBT/SDK: New app flag UnloadAssetPacks to free RAM in heavy apps like NFC, MFKey, uPython (#260 by @Willy-JL)
- OFW: Settings: Clock editing & Alarm function (目覚め時計) (by @skotopes)
- Settings:
- OFW: Clock editing & Alarm function (目覚め時計) (by @skotopes)
- Add warnings for some settings you shouldn't touch like Debug, Sleep Method, Heap Trace (#296 by @Willy-JL)
- BadKB:
- OFW: Add linux/gnome badusb demo files (by @thomasnemer)
- Add older qFlipper install demos for windows and macos (by @DXVVAY & @grugnoymeme)
Expand Down Expand Up @@ -179,7 +181,9 @@
- Move more commands as plugins on SD, refactor plugin wrapper (#276 by @Willy-JL)
- FBT: Optimize icons blob, scrub unused icons (#291 by @Willy-JL)
- OFW: BadKB: Improve ChromeOS and GNOME demo scripts (by @kowalski7cc)
- OFW: GUI: Change dialog_ex text ownership model (by @skotopes)
- GUI:
- OFW: Change dialog_ex text ownership model (by @skotopes)
- Improve some error messages to be more clear, like Sub-GHz region missing and Main Menu .fap file missing (#296 by @Willy-JL)
- OFW: CCID: App changes and improvements (by @kidbomb)
- OFW: API: Exposed `view_dispatcher_get_event_loop` (by @CookiePLMonster)
- Furi:
Expand Down
2 changes: 1 addition & 1 deletion applications/main/subghz/subghz_i.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void subghz_dialog_message_freq_error(SubGhz* subghz, SubGhzTx can_tx) {
default:
return;
case SubGhzTxBlockedRegionNotProvisioned:
message_text = "Region is not\nprovisioned.\nUpdate firmware\nor bypass region.";
message_text = "Missing region file.\nReinstall firmware\nwith Web/App\nor bypass region.";
break;
case SubGhzTxBlockedRegion:
message_text = "Frequency outside\nof region range.\nMNTM > Protocols\n> Bypass Region";
Expand Down
2 changes: 1 addition & 1 deletion applications/services/cli/cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ void cli_plugin_wrapper(const char* name, Cli* cli, FuriString* args, void* cont
handler(cli, args, context);
} else {
printf(
"CLI plugin '%s' failed (code %" PRIu16 "), update firmware or check logs\r\n",
"CLI plugin '%s' failed (code %" PRIu16 "), reinstall firmware or check logs\r\n",
name,
error);
}
Expand Down
2 changes: 1 addition & 1 deletion applications/services/loader/loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ static void loader_show_gui_error(
Storage* storage = furi_record_open(RECORD_STORAGE);
if(storage_sd_status(storage) == FSE_OK) {
header = "Update needed";
text = "Update firmware\nto run this app";
text = "Reinstall firmware\nto run this app";
} else {
header = "SD card needed";
text = "Install SD card\nto run this app";
Expand Down
6 changes: 3 additions & 3 deletions applications/services/loader/loader_menu_storage.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ int32_t loader_menu_storage_settings(void* context) {
dialog_ex_set_header(dialog_ex, "Update needed", 64, 0, AlignCenter, AlignTop);
dialog_ex_set_text(
dialog_ex,
"Update firmware\n"
"to run this app\n"
"Reinstall firmware\n"
"to run this app.\n"
"Can format SD\n"
"here if needed",
"here if needed.",
3,
17,
AlignLeft,
Expand Down
102 changes: 100 additions & 2 deletions applications/settings/system/system_settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,21 @@
#include <loader/loader.h>
#include <lib/toolbox/value_index.h>
#include <locale/locale.h>
#include <dialogs/dialogs.h>

enum VarItemListIndex {
VarItemListIndexHandOrient,
VarItemListIndexUnits,
VarItemListIndexTimeFormat,
VarItemListIndexDateFormat,
VarItemListIndexLogLevel,
VarItemListIndexLogDevice,
VarItemListIndexLogBaudRate,
VarItemListIndexDebug,
VarItemListIndexHeapTrace,
VarItemListIndexSleepMethod,
VarItemListIndexFileNaming,
};

const char* const log_level_text[] = {
"Default",
Expand Down Expand Up @@ -80,10 +95,11 @@ const char* const debug_text[] = {
};

static void debug_changed(VariableItem* item) {
SystemSettings* app = variable_item_get_context(item);
uint8_t index = variable_item_get_current_value_index(item);
variable_item_set_current_value_text(item, debug_text[index]);
if(index) {
furi_hal_rtc_set_flag(FuriHalRtcFlagDebug);
view_dispatcher_send_custom_event(app->view_dispatcher, VarItemListIndexDebug);
} else {
furi_hal_rtc_reset_flag(FuriHalRtcFlagDebug);
}
Expand All @@ -108,9 +124,13 @@ const uint32_t heap_trace_mode_value[] = {
};

static void heap_trace_mode_changed(VariableItem* item) {
SystemSettings* app = variable_item_get_context(item);
uint8_t index = variable_item_get_current_value_index(item);
variable_item_set_current_value_text(item, heap_trace_mode_text[index]);
furi_hal_rtc_set_heap_track_mode(heap_trace_mode_value[index]);
if(index) {
view_dispatcher_send_custom_event(app->view_dispatcher, VarItemListIndexHeapTrace);
}
}

const char* const measurement_units_text[] = {
Expand Down Expand Up @@ -184,10 +204,11 @@ const char* const sleep_method[] = {
};

static void sleep_method_changed(VariableItem* item) {
SystemSettings* app = variable_item_get_context(item);
uint8_t index = variable_item_get_current_value_index(item);
variable_item_set_current_value_text(item, sleep_method[index]);
if(index) {
furi_hal_rtc_set_flag(FuriHalRtcFlagLegacySleep);
view_dispatcher_send_custom_event(app->view_dispatcher, VarItemListIndexSleepMethod);
} else {
furi_hal_rtc_reset_flag(FuriHalRtcFlagLegacySleep);
}
Expand All @@ -213,6 +234,81 @@ static uint32_t system_settings_exit(void* context) {
return VIEW_NONE;
}

static bool system_settings_custom_event_callback(void* context, uint32_t event) {
furi_assert(context);
SystemSettings* app = context;

VariableItem* item = variable_item_list_get(app->var_item_list, event);
DialogsApp* dialogs = furi_record_open(RECORD_DIALOGS);
DialogMessage* msg = dialog_message_alloc();
dialog_message_set_buttons(msg, "No", NULL, "Yes");

switch(event) {
case VarItemListIndexDebug:
dialog_message_set_header(msg, "Enable Debug?", 64, 4, AlignCenter, AlignTop);
dialog_message_set_text(
msg,
"This consumes 400% more\n"
"battery life. Don't use unless\n"
"you know exactly what\n"
"you're doing.",
64,
36,
AlignCenter,
AlignCenter);
if(dialog_message_show(dialogs, msg) == DialogMessageButtonRight) {
furi_hal_rtc_set_flag(FuriHalRtcFlagDebug);
} else {
variable_item_set_current_value_text(item, debug_text[0]);
variable_item_set_current_value_index(item, 0);
}
break;
case VarItemListIndexSleepMethod:
dialog_message_set_header(msg, "Disable DeepSleep?", 64, 4, AlignCenter, AlignTop);
dialog_message_set_text(
msg,
"Disabling will consume 400%\n"
"more battery life. Only\n"
"disable if you have a\n"
"specific reason.",
64,
36,
AlignCenter,
AlignCenter);
if(dialog_message_show(dialogs, msg) == DialogMessageButtonRight) {
furi_hal_rtc_set_flag(FuriHalRtcFlagLegacySleep);
} else {
variable_item_set_current_value_text(item, sleep_method[0]);
variable_item_set_current_value_index(item, 0);
}
break;
case VarItemListIndexHeapTrace:
dialog_message_set_header(msg, "Enable Heap Trace?", 64, 4, AlignCenter, AlignTop);
dialog_message_set_text(
msg,
"Will use more RAM and might\n"
"cause Out Of Memory errors.\n"
"Don't enable without a\n"
"specific reason.",
64,
36,
AlignCenter,
AlignCenter);
if(dialog_message_show(dialogs, msg) != DialogMessageButtonRight) {
furi_hal_rtc_set_heap_track_mode(heap_trace_mode_value[0]);
variable_item_set_current_value_text(item, heap_trace_mode_text[0]);
variable_item_set_current_value_index(item, 0);
}
break;
default:
break;
}

dialog_message_free(msg);
furi_record_close(RECORD_DIALOGS);
return true;
}

SystemSettings* system_settings_alloc(void) {
SystemSettings* app = malloc(sizeof(SystemSettings));

Expand All @@ -221,6 +317,8 @@ SystemSettings* system_settings_alloc(void) {

app->view_dispatcher = view_dispatcher_alloc();
view_dispatcher_set_event_callback_context(app->view_dispatcher, app);
view_dispatcher_set_custom_event_callback(
app->view_dispatcher, system_settings_custom_event_callback);

view_dispatcher_attach_to_gui(app->view_dispatcher, app->gui, ViewDispatcherTypeFullscreen);

Expand Down

0 comments on commit 8b84222

Please sign in to comment.