Userdata export: Fix menu behavior, particularly with the OSD.

The behavior of the menu option was all over the place, and would
easily leave the OSD in a weird state, requiring the user to blindly
do something that completely redraws the OSD.

Fix this by making the behavior similar to that of the userdata import
feature, with the difference of giving a more specific error message
when something goes wrong.
This commit is contained in:
Ari Sundholm 2020-11-07 01:33:44 +02:00
parent b890446e3d
commit 32bbc49bf0
3 changed files with 5418 additions and 5439 deletions

File diff suppressed because it is too large Load Diff

View File

@ -332,9 +332,8 @@ int export_userdata()
goto failure;
}
strncpy(menu_row1, "Profile export", LCD_ROW_LEN+1);
strncpy(menu_row2, "Export? 1=Y, 2=N", LCD_ROW_LEN+1);
ui_disp_menu(1);
ui_disp_menu(2);
while (1) {
btn_vec = IORD_ALTERA_AVALON_PIO_DATA(PIO_1_BASE) & RC_MASK;
@ -349,9 +348,8 @@ int export_userdata()
usleep(WAITLOOP_SLEEP_US);
}
strncpy(menu_row1, "Exporting", LCD_ROW_LEN+1);
menu_row2[0] = '\0';
ui_disp_menu(1);
strncpy(menu_row2, "Exporting...", LCD_ROW_LEN+1);
ui_disp_menu(2);
/* This may wear the SD card a bit more than necessary... */
retval = copy_flash_to_sd(USERDATA_OFFSET/PAGESIZE, 512/SD_BLK_SIZE, (MAX_USERDATA_ENTRY + 1) * SECTORSIZE, databuf);
@ -361,7 +359,6 @@ int export_userdata()
SPI_CS_High();
strncpy(menu_row2, "Success", LCD_ROW_LEN+1);
ui_disp_menu(1);
return 1;
@ -376,16 +373,17 @@ failure:
errmsg = "Invalid params.";
break;
case UDATA_EXPT_CANCELLED:
errmsg = "Export cancelled";
errmsg = "Cancelled";
break;
default:
errmsg = "SD/Flash error";
break;
}
strncpy(menu_row2, errmsg, LCD_ROW_LEN+1);
ui_disp_menu(1);
usleep(1000000);
render_osd_page();
return -1;
/*
* We want the message above to remain on screen, so return a
* positive value which nevertheless stands out when debugging.
*/
return 0x0dead;
}