diff --git a/firmware/components/sd_card/sd_card.c b/firmware/components/sd_card/sd_card.c index 2c78696..c2b9433 100644 --- a/firmware/components/sd_card/sd_card.c +++ b/firmware/components/sd_card/sd_card.c @@ -356,9 +356,5 @@ esp_err_t sd_card_fill_info(const sdmmc_card_t* card) { } sd_card_info_t sd_card_get_info() { - if (sd_card_is_not_mounted()) { - ESP_LOGE(TAG, "SD card not mounted"); - } - return _sd_card_info; } diff --git a/firmware/main/modules/settings/settings_module.c b/firmware/main/modules/settings/settings_module.c index d230fe8..fbf68fe 100644 --- a/firmware/main/modules/settings/settings_module.c +++ b/firmware/main/modules/settings/settings_module.c @@ -38,23 +38,34 @@ void update_sd_card_info() { oled_screen_clear(); modals_module_show_banner("Loading..."); vTaskDelay(1000 / portTICK_PERIOD_MS); // Wait for the SD card to be mounted - sd_card_info_t sd_info = sd_card_get_info(); - char* name_str = malloc(strlen(sd_info.name) + 1); - sprintf(name_str, "Name: %s", sd_info.name); - char* capacity_str = malloc(20); - sprintf(capacity_str, "Space: %.2fGB", ((float) sd_info.total_space) / 1024); - char* speed_str = malloc(25); - sprintf(speed_str, "Speed: %.2fMHz", sd_info.speed); - char* type_str = malloc(strlen(sd_info.type) + 1 + 6); - sprintf(type_str, "Type: %s", sd_info.type); + if (sd_card_is_not_mounted()) { + sd_card_info_2[0] = ""; + sd_card_info_2[1] = "No SD Card"; + sd_card_info_2[2] = ""; + sd_card_info_2[3] = ""; + sd_card_info_2[4] = ""; + sd_card_info_2[5] = ""; + } else { + sd_card_info_t sd_info = sd_card_get_info(); + char* name_str = malloc(strlen(sd_info.name) + 1); + sprintf(name_str, "Name: %s", sd_info.name); + char* capacity_str = malloc(20); + sprintf(capacity_str, "Space: %.2fGB", + ((float) sd_info.total_space) / 1024); + char* speed_str = malloc(25); + sprintf(speed_str, "Speed: %.2fMHz", sd_info.speed); + char* type_str = malloc(strlen(sd_info.type) + 1 + 6); + sprintf(type_str, "Type: %s", sd_info.type); + + sd_card_info_2[0] = ""; + sd_card_info_2[1] = "SD Card Info"; + sd_card_info_2[2] = name_str; + sd_card_info_2[3] = capacity_str; + sd_card_info_2[4] = speed_str; + sd_card_info_2[5] = type_str; + } - sd_card_info_2[0] = ""; - sd_card_info_2[1] = "SD Card Info"; - sd_card_info_2[2] = name_str; - sd_card_info_2[3] = capacity_str; - sd_card_info_2[4] = speed_str; - sd_card_info_2[5] = type_str; sd_card_unmount(); general_register_scrolling_menu(&SD_inf); general_screen_display_scrolling_text_handler(menus_module_exit_app);