Change save fuinction for SD card calibration data
This commit is contained in:
parent
42ca1a01b5
commit
d04d8ebf9d
@ -43,29 +43,25 @@ static void get_controller_folder_path(char *path, size_t size)
|
||||
* @param[in,out] controller_folder
|
||||
* @return 0 if opened, 1 if created and opened, -1 if error.
|
||||
*/
|
||||
static int open_or_create_controller_folder(DIR *controller_folder)
|
||||
static int create_controller_folder(void)
|
||||
{
|
||||
char foldername[48];
|
||||
int ret = -1;
|
||||
FRESULT filesystem_result;
|
||||
|
||||
if (!controller_folder)
|
||||
return -1001;
|
||||
DIR folder;
|
||||
|
||||
get_controller_folder_path(foldername, sizeof(foldername));
|
||||
|
||||
/* Check if folder is present */
|
||||
filesystem_result = f_opendir(controller_folder, foldername);
|
||||
filesystem_result = f_opendir(&folder, foldername);
|
||||
if (filesystem_result == FR_OK) {
|
||||
ret = 0;
|
||||
f_closedir(&folder);
|
||||
} else {
|
||||
filesystem_result = f_mkdir(foldername);
|
||||
if (filesystem_result == FR_OK) {
|
||||
filesystem_result = f_opendir(controller_folder, foldername);
|
||||
if (filesystem_result == FR_OK)
|
||||
ret = 1;
|
||||
else
|
||||
ret = -1;
|
||||
f_closedir(&folder);
|
||||
ret = 1;
|
||||
} else {
|
||||
ret = -1;
|
||||
}
|
||||
@ -79,7 +75,6 @@ static int open_or_create_controller_folder(DIR *controller_folder)
|
||||
|
||||
int sd_card_settings_save_calibration(float sens_deviation, float offset, bool active)
|
||||
{
|
||||
DIR folder;
|
||||
FIL cal_file;
|
||||
int status;
|
||||
FRESULT res;
|
||||
@ -87,8 +82,8 @@ int sd_card_settings_save_calibration(float sens_deviation, float offset, bool a
|
||||
int ret = 0;
|
||||
char buff[256];
|
||||
|
||||
status = open_or_create_controller_folder(&folder);
|
||||
f_closedir(&folder);
|
||||
status = create_controller_folder();
|
||||
|
||||
|
||||
if (status < 0)
|
||||
return -2;
|
||||
|
Loading…
Reference in New Issue
Block a user