Merge remote-tracking branch 'OFW/dev' into dev

This commit is contained in:
MX
2024-05-15 18:22:54 +03:00
parent 96db11a0d6
commit 1afa3f7ef3
83 changed files with 531 additions and 483 deletions

View File

@@ -1,5 +1,7 @@
#include "../storage_settings.h"
#include <furi_hal.h>
#include <notification/notification.h>
#include <notification/notification_messages.h>
#define BENCH_DATA_SIZE 4096
#define BENCH_COUNT 6
@@ -86,7 +88,8 @@ static void storage_settings_scene_benchmark(StorageSettings* app) {
uint32_t bench_w_speed[BENCH_COUNT] = {0, 0, 0, 0, 0, 0};
uint32_t bench_r_speed[BENCH_COUNT] = {0, 0, 0, 0, 0, 0};
dialog_ex_set_header(dialog_ex, "Benchmarking...", 64, 32, AlignCenter, AlignCenter);
dialog_ex_set_header(dialog_ex, "Benchmarking...", 74, 32, AlignCenter, AlignCenter);
dialog_ex_set_icon(dialog_ex, 12, 20, &I_LoadingHourglass_24x24);
for(size_t i = 0; i < BENCH_COUNT; i++) {
if(!storage_settings_scene_bench_write(
app->fs_api, bench_size[i], bench_data, &bench_w_speed[i]))
@@ -95,6 +98,7 @@ static void storage_settings_scene_benchmark(StorageSettings* app) {
if(i > 0) furi_string_cat_printf(app->text_string, "\n");
furi_string_cat_printf(app->text_string, "%ub : W %luK ", bench_size[i], bench_w_speed[i]);
dialog_ex_set_header(dialog_ex, NULL, 0, 0, AlignCenter, AlignCenter);
dialog_ex_set_icon(dialog_ex, 0, 0, NULL);
dialog_ex_set_text(
dialog_ex, furi_string_get_cstr(app->text_string), 0, 32, AlignLeft, AlignCenter);
@@ -110,6 +114,12 @@ static void storage_settings_scene_benchmark(StorageSettings* app) {
dialog_ex, furi_string_get_cstr(app->text_string), 0, 32, AlignLeft, AlignCenter);
}
NotificationApp* notification = furi_record_open(RECORD_NOTIFICATION);
notification_message(notification, &sequence_single_vibro);
notification_message(notification, &sequence_set_green_255);
notification_message(notification, &sequence_success);
furi_record_close(RECORD_NOTIFICATION);
free(bench_data);
}
@@ -146,11 +156,17 @@ bool storage_settings_scene_benchmark_on_event(void* context, SceneManagerEvent
if(event.type == SceneManagerEventTypeCustom) {
switch(event.event) {
case DialogExResultCenter:
consumed = scene_manager_previous_scene(app->scene_manager);
consumed = scene_manager_search_and_switch_to_previous_scene(
app->scene_manager, StorageSettingsStart);
break;
}
} else if(event.type == SceneManagerEventTypeBack && sd_status != FSE_OK) {
consumed = true;
} else if(event.type == SceneManagerEventTypeBack) {
if(sd_status == FSE_OK) {
consumed = scene_manager_search_and_switch_to_previous_scene(
app->scene_manager, StorageSettingsStart);
} else {
consumed = true;
}
}
return consumed;
@@ -160,6 +176,10 @@ void storage_settings_scene_benchmark_on_exit(void* context) {
StorageSettings* app = context;
DialogEx* dialog_ex = app->dialog_ex;
NotificationApp* notification = furi_record_open(RECORD_NOTIFICATION);
notification_message(notification, &sequence_reset_green);
furi_record_close(RECORD_NOTIFICATION);
dialog_ex_reset(dialog_ex);
furi_string_reset(app->text_string);

View File

@@ -0,0 +1,70 @@
#include "../storage_settings.h"
static void
storage_settings_scene_benchmark_confirm_dialog_callback(DialogExResult result, void* context) {
StorageSettings* app = context;
view_dispatcher_send_custom_event(app->view_dispatcher, result);
}
void storage_settings_scene_benchmark_confirm_on_enter(void* context) {
StorageSettings* app = context;
DialogEx* dialog_ex = app->dialog_ex;
FS_Error sd_status = storage_sd_status(app->fs_api);
if(sd_status == FSE_NOT_READY) {
dialog_ex_set_icon(dialog_ex, 83, 22, &I_WarningDolphinFlip_45x42);
dialog_ex_set_header(dialog_ex, "SD Card Not Mounted", 64, 3, AlignCenter, AlignTop);
dialog_ex_set_text(
dialog_ex, "Try to reinsert\nor format SD\ncard.", 3, 19, AlignLeft, AlignTop);
dialog_ex_set_center_button_text(dialog_ex, "Ok");
} else {
dialog_ex_set_header(dialog_ex, "Benchmark SD Card?", 64, 0, AlignCenter, AlignTop);
dialog_ex_set_text(
dialog_ex,
"SD will be tested in SPI\nmode. Learn more:\nr.flipper.net/sd_test",
0,
12,
AlignLeft,
AlignTop);
dialog_ex_set_icon(dialog_ex, 103, 12, &I_qr_benchmark_25x25);
dialog_ex_set_left_button_text(dialog_ex, "Cancel");
dialog_ex_set_right_button_text(dialog_ex, "Benchmark");
}
dialog_ex_set_context(dialog_ex, app);
dialog_ex_set_result_callback(
dialog_ex, storage_settings_scene_benchmark_confirm_dialog_callback);
view_dispatcher_switch_to_view(app->view_dispatcher, StorageSettingsViewDialogEx);
}
bool storage_settings_scene_benchmark_confirm_on_event(void* context, SceneManagerEvent event) {
StorageSettings* app = context;
bool consumed = false;
if(event.type == SceneManagerEventTypeCustom) {
switch(event.event) {
case DialogExResultLeft:
case DialogExResultCenter:
consumed = scene_manager_previous_scene(app->scene_manager);
break;
case DialogExResultRight:
scene_manager_next_scene(app->scene_manager, StorageSettingsBenchmark);
consumed = true;
break;
}
} else if(event.type == SceneManagerEventTypeBack) {
consumed = true;
}
return consumed;
}
void storage_settings_scene_benchmark_confirm_on_exit(void* context) {
StorageSettings* app = context;
DialogEx* dialog_ex = app->dialog_ex;
dialog_ex_reset(dialog_ex);
}

View File

@@ -5,5 +5,6 @@ ADD_SCENE(storage_settings, format_confirm, FormatConfirm)
ADD_SCENE(storage_settings, formatting, Formatting)
ADD_SCENE(storage_settings, sd_info, SDInfo)
ADD_SCENE(storage_settings, internal_info, InternalInfo)
ADD_SCENE(storage_settings, benchmark_confirm, BenchmarkConfirm)
ADD_SCENE(storage_settings, benchmark, Benchmark)
ADD_SCENE(storage_settings, factory_reset, FactoryReset)

View File

@@ -21,14 +21,14 @@ void storage_settings_scene_factory_reset_on_enter(void* context) {
dialog_ex_set_left_button_text(dialog_ex, "Cancel");
dialog_ex_set_right_button_text(dialog_ex, "Erase");
dialog_ex_set_header(dialog_ex, "Confirm Factory Reset", 64, 10, AlignCenter, AlignCenter);
dialog_ex_set_header(dialog_ex, "Confirm Factory Reset?", 64, 0, AlignCenter, AlignTop);
dialog_ex_set_text(
dialog_ex,
"Internal storage will be erased\r\nData and settings will be lost!",
"Internal storage will be erased\ndata and settings will be lost!",
64,
32,
14,
AlignCenter,
AlignCenter);
AlignTop);
view_dispatcher_switch_to_view(app->view_dispatcher, StorageSettingsViewDialogEx);
}

View File

@@ -20,8 +20,8 @@ void storage_settings_scene_format_confirm_on_enter(void* context) {
dialog_ex, "Try to reinsert\nor format SD\ncard.", 3, 19, AlignLeft, AlignTop);
dialog_ex_set_center_button_text(dialog_ex, "Ok");
} else {
dialog_ex_set_header(dialog_ex, "Format SD Card?", 64, 10, AlignCenter, AlignCenter);
dialog_ex_set_text(dialog_ex, "All data will be lost!", 64, 32, AlignCenter, AlignCenter);
dialog_ex_set_header(dialog_ex, "Format SD Card?", 64, 0, AlignCenter, AlignTop);
dialog_ex_set_text(dialog_ex, "All data will be lost!", 64, 12, AlignCenter, AlignTop);
dialog_ex_set_left_button_text(dialog_ex, "Cancel");
dialog_ex_set_right_button_text(dialog_ex, "Format");
}

View File

@@ -1,4 +1,6 @@
#include "../storage_settings.h"
#include <notification/notification.h>
#include <notification/notification_messages.h>
static const NotificationMessage message_green_165 = {
.type = NotificationMessageTypeLedGreen,
@@ -31,7 +33,8 @@ void storage_settings_scene_formatting_on_enter(void* context) {
FS_Error error;
DialogEx* dialog_ex = app->dialog_ex;
dialog_ex_set_header(dialog_ex, "Formatting...", 64, 32, AlignCenter, AlignCenter);
dialog_ex_set_header(dialog_ex, "Formatting...", 70, 32, AlignCenter, AlignCenter);
dialog_ex_set_icon(dialog_ex, 15, 20, &I_LoadingHourglass_24x24);
view_dispatcher_switch_to_view(app->view_dispatcher, StorageSettingsViewDialogEx);
notification_message_block(app->notification, &sequence_set_formatting_leds);
@@ -44,11 +47,17 @@ void storage_settings_scene_formatting_on_enter(void* context) {
if(error != FSE_OK) {
dialog_ex_set_header(dialog_ex, "Cannot Format SD Card", 64, 10, AlignCenter, AlignCenter);
dialog_ex_set_icon(dialog_ex, 0, 0, NULL);
dialog_ex_set_text(
dialog_ex, storage_error_get_desc(error), 64, 32, AlignCenter, AlignCenter);
} else {
dialog_ex_set_icon(dialog_ex, 83, 22, &I_WarningDolphinFlip_45x42);
dialog_ex_set_header(dialog_ex, "Format\ncomplete!", 14, 15, AlignLeft, AlignTop);
NotificationApp* notification = furi_record_open(RECORD_NOTIFICATION);
notification_message(notification, &sequence_single_vibro);
notification_message(notification, &sequence_set_green_255);
notification_message(notification, &sequence_success);
furi_record_close(RECORD_NOTIFICATION);
}
dialog_ex_set_center_button_text(dialog_ex, "OK");
}
@@ -75,5 +84,9 @@ void storage_settings_scene_formatting_on_exit(void* context) {
StorageSettings* app = context;
DialogEx* dialog_ex = app->dialog_ex;
NotificationApp* notification = furi_record_open(RECORD_NOTIFICATION);
notification_message(notification, &sequence_reset_green);
furi_record_close(RECORD_NOTIFICATION);
dialog_ex_reset(dialog_ex);
}

View File

@@ -27,7 +27,7 @@ void storage_settings_scene_internal_info_on_enter(void* context) {
} else {
furi_string_printf(
app->text_string,
"Label: %s\nType: LittleFS\n%lu KiB total\n%lu KiB free",
"Name: %s\nType: LittleFS\nTotal: %lu KiB\nFree: %lu KiB",
furi_hal_version_get_name_ptr() ? furi_hal_version_get_name_ptr() : "Unknown",
(uint32_t)(total_space / 1024),
(uint32_t)(free_space / 1024));

View File

@@ -27,12 +27,31 @@ void storage_settings_scene_sd_info_on_enter(void* context) {
} else {
furi_string_printf(
app->text_string,
"Label: %s\nType: %s\n%lu KiB total\n%lu KiB free\n"
"%02X%s %s v%i.%i\nSN:%04lX %02i/%i",
"Label: %s\nType: %s\n",
sd_info.label,
sd_api_get_fs_type_text(sd_info.fs_type),
sd_info.kb_total,
sd_info.kb_free,
sd_api_get_fs_type_text(sd_info.fs_type));
if(sd_info.kb_total < 1024) {
furi_string_cat_printf(app->text_string, "Total: %lu KiB\n", sd_info.kb_total);
} else if(sd_info.kb_total < 1024 * 1024) {
furi_string_cat_printf(app->text_string, "Total: %lu MiB\n", sd_info.kb_total / 1024);
} else {
furi_string_cat_printf(
app->text_string, "Total: %lu GiB\n", sd_info.kb_total / (1024 * 1024));
}
if(sd_info.kb_free < 1024) {
furi_string_cat_printf(app->text_string, "Free: %lu KiB\n", sd_info.kb_free);
} else if(sd_info.kb_free < 1024 * 1024) {
furi_string_cat_printf(app->text_string, "Free: %lu MiB\n", sd_info.kb_free / 1024);
} else {
furi_string_cat_printf(
app->text_string, "Free: %lu GiB\n", sd_info.kb_free / (1024 * 1024));
}
furi_string_cat_printf(
app->text_string,
"%02X%s %s v%i.%i\nSN:%04lX %02i/%i",
sd_info.manufacturer_id,
sd_info.oem_id,
sd_info.product_name,
@@ -41,6 +60,7 @@ void storage_settings_scene_sd_info_on_enter(void* context) {
sd_info.product_serial_number,
sd_info.manufacturing_month,
sd_info.manufacturing_year);
dialog_ex_set_text(
dialog_ex, furi_string_get_cstr(app->text_string), 4, 1, AlignLeft, AlignTop);
}

View File

@@ -109,7 +109,7 @@ bool storage_settings_scene_start_on_event(void* context, SceneManagerEvent even
case StorageSettingsStartSubmenuIndexBenchy:
scene_manager_set_scene_state(
app->scene_manager, StorageSettingsStart, StorageSettingsStartSubmenuIndexBenchy);
scene_manager_next_scene(app->scene_manager, StorageSettingsBenchmark);
scene_manager_next_scene(app->scene_manager, StorageSettingsBenchmarkConfirm);
consumed = true;
break;
case StorageSettingsStartSubmenuIndexFactoryReset: