[FL-2651, FL-2863] App name in CLI loader command, RFID data edit fix #1835

Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
Nikolay Minaylov 2022-10-07 15:46:58 +03:00 committed by GitHub
parent 38a82a1907
commit 1f742b611a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 44 additions and 15 deletions

View file

@ -54,7 +54,7 @@ static void gpio_usb_uart_draw_callback(Canvas* canvas, void* _model) {
canvas_draw_str_aligned(canvas, 116, 24, AlignRight, AlignBottom, temp_str);
} else {
canvas_set_font(canvas, FontSecondary);
canvas_draw_str_aligned(canvas, 127, 24, AlignRight, AlignBottom, "KB.");
canvas_draw_str_aligned(canvas, 127, 24, AlignRight, AlignBottom, "KiB.");
canvas_set_font(canvas, FontKeyboard);
snprintf(temp_str, 18, "%lu", model->tx_cnt / 1024);
canvas_draw_str_aligned(canvas, 111, 24, AlignRight, AlignBottom, temp_str);
@ -68,7 +68,7 @@ static void gpio_usb_uart_draw_callback(Canvas* canvas, void* _model) {
canvas_draw_str_aligned(canvas, 116, 41, AlignRight, AlignBottom, temp_str);
} else {
canvas_set_font(canvas, FontSecondary);
canvas_draw_str_aligned(canvas, 127, 41, AlignRight, AlignBottom, "KB.");
canvas_draw_str_aligned(canvas, 127, 41, AlignRight, AlignBottom, "KiB.");
canvas_set_font(canvas, FontKeyboard);
snprintf(temp_str, 18, "%lu", model->rx_cnt / 1024);
canvas_draw_str_aligned(canvas, 111, 41, AlignRight, AlignBottom, temp_str);

View file

@ -9,14 +9,11 @@ void lfrfid_scene_save_data_on_enter(void* context) {
bool need_restore = scene_manager_get_scene_state(app->scene_manager, LfRfidSceneSaveData);
if(need_restore) {
protocol_dict_set_data(app->dict, app->protocol_id, app->old_key_data, size);
} else {
if(!need_restore) {
protocol_dict_get_data(app->dict, app->protocol_id, app->old_key_data, size);
protocol_dict_get_data(app->dict, app->protocol_id, app->new_key_data, size);
}
protocol_dict_get_data(app->dict, app->protocol_id, app->new_key_data, size);
byte_input_set_header_text(byte_input, "Enter the data in hex");
byte_input_set_result_callback(
@ -41,6 +38,8 @@ bool lfrfid_scene_save_data_on_event(void* context, SceneManagerEvent event) {
}
} else if(event.type == SceneManagerEventTypeBack) {
scene_manager_set_scene_state(scene_manager, LfRfidSceneSaveData, 0);
size_t size = protocol_dict_get_data_size(app->dict, app->protocol_id);
protocol_dict_set_data(app->dict, app->protocol_id, app->old_key_data, size);
}
return consumed;

View file

@ -5,6 +5,9 @@ void lfrfid_scene_save_success_on_enter(void* context) {
LfRfid* app = context;
Popup* popup = app->popup;
// Clear state of data enter scene
scene_manager_set_scene_state(app->scene_manager, LfRfidSceneSaveData, 0);
DOLPHIN_DEED(DolphinDeedRfidSave);
popup_set_icon(popup, 32, 5, &I_DolphinNice_96x59);
popup_set_header(popup, "Saved!", 5, 7, AlignLeft, AlignTop);

View file

@ -61,6 +61,7 @@ static void loader_cli_print_usage() {
printf("Cmd list:\r\n");
printf("\tlist\t - List available applications\r\n");
printf("\topen <Application Name:string>\t - Open application by name\r\n");
printf("\tinfo\t - Show loader state\r\n");
}
static FlipperApplication const* loader_find_application_by_name_in_list(
@ -98,10 +99,15 @@ const FlipperApplication* loader_find_application_by_name(const char* name) {
return application;
}
void loader_cli_open(Cli* cli, FuriString* args, Loader* instance) {
static void loader_cli_open(Cli* cli, FuriString* args, Loader* instance) {
UNUSED(cli);
if(loader_is_locked(instance)) {
printf("Can't start, furi application is running");
if(instance->application) {
furi_assert(instance->application->name);
printf("Can't start, %s application is running", instance->application->name);
} else {
printf("Can't start, furi application is running");
}
return;
}
@ -137,7 +143,7 @@ void loader_cli_open(Cli* cli, FuriString* args, Loader* instance) {
furi_string_free(application_name);
}
void loader_cli_list(Cli* cli, FuriString* args, Loader* instance) {
static void loader_cli_list(Cli* cli, FuriString* args, Loader* instance) {
UNUSED(cli);
UNUSED(args);
UNUSED(instance);
@ -159,6 +165,22 @@ void loader_cli_list(Cli* cli, FuriString* args, Loader* instance) {
}
}
static void loader_cli_info(Cli* cli, FuriString* args, Loader* instance) {
UNUSED(cli);
UNUSED(args);
if(!loader_is_locked(instance)) {
printf("No application is running\r\n");
} else {
printf("Running application: ");
if(instance->application) {
furi_assert(instance->application->name);
printf("%s\r\n", instance->application->name);
} else {
printf("unknown\r\n");
}
}
}
static void loader_cli(Cli* cli, FuriString* args, void* _ctx) {
furi_assert(_ctx);
Loader* instance = _ctx;
@ -182,6 +204,11 @@ static void loader_cli(Cli* cli, FuriString* args, void* _ctx) {
break;
}
if(furi_string_cmp_str(cmd, "info") == 0) {
loader_cli_info(cli, args, instance);
break;
}
loader_cli_print_usage();
} while(false);

View file

@ -52,7 +52,7 @@ static void storage_cli_info(Cli* cli, FuriString* path) {
storage_cli_print_error(error);
} else {
printf(
"Label: %s\r\nType: LittleFS\r\n%luKB total\r\n%luKB free\r\n",
"Label: %s\r\nType: LittleFS\r\n%luKiB total\r\n%luKiB free\r\n",
furi_hal_version_get_name_ptr() ? furi_hal_version_get_name_ptr() : "Unknown",
(uint32_t)(total_space / 1024),
(uint32_t)(free_space / 1024));
@ -65,7 +65,7 @@ static void storage_cli_info(Cli* cli, FuriString* path) {
storage_cli_print_error(error);
} else {
printf(
"Label: %s\r\nType: %s\r\n%luKB total\r\n%luKB free\r\n",
"Label: %s\r\nType: %s\r\n%luKiB total\r\n%luKiB free\r\n",
sd_info.label,
sd_api_get_fs_type_text(sd_info.fs_type),
sd_info.kb_total,
@ -364,7 +364,7 @@ static void storage_cli_stat(Cli* cli, FuriString* path) {
storage_cli_print_error(error);
} else {
printf(
"Storage, %luKB total, %luKB free\r\n",
"Storage, %luKiB total, %luKiB free\r\n",
(uint32_t)(total_space / 1024),
(uint32_t)(free_space / 1024));
}

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 KB total\n%lu KB free",
"Label: %s\nType: LittleFS\n%lu KiB total\n%lu KiB free",
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

@ -26,7 +26,7 @@ void storage_settings_scene_sd_info_on_enter(void* context) {
} else {
furi_string_printf(
app->text_string,
"Label: %s\nType: %s\n%lu KB total\n%lu KB free",
"Label: %s\nType: %s\n%lu KiB total\n%lu KiB free",
sd_info.label,
sd_api_get_fs_type_text(sd_info.fs_type),
sd_info.kb_total,