[Taranis] Storage capacity on EEPROM disk was wrong

This commit is contained in:
bsongis@gmail.com
2013-05-21 10:05:43 +00:00
parent 53f111ccbf
commit 53e061ab6a
2 changed files with 24 additions and 29 deletions
+20 -25
View File
@@ -259,14 +259,7 @@ void onModelSelectMenu(const char *result)
int8_t sub = m_posVert; int8_t sub = m_posVert;
if (result == STR_SELECT_MODEL || result == STR_CREATE_MODEL) { if (result == STR_SELECT_MODEL || result == STR_CREATE_MODEL) {
displayPopup(STR_LOADINGMODEL); selectModel(sub);
saveTimers();
eeCheck(true); // force writing of current model data before this is changed
if (g_eeGeneral.currModel != sub) {
g_eeGeneral.currModel = sub;
STORE_GENERALVARS;
eeLoadModel(sub);
}
} }
else if (result == STR_COPY_MODEL) { else if (result == STR_COPY_MODEL) {
s_copyMode = COPY_MODE; s_copyMode = COPY_MODE;
@@ -312,6 +305,16 @@ void onModelSelectMenu(const char *result)
} }
#endif #endif
void selectModel(uint8_t sub)
{
displayPopup(STR_LOADINGMODEL);
saveTimers();
eeCheck(true); // force writing of current model data before this is changed
g_eeGeneral.currModel = sub;
STORE_GENERALVARS;
eeLoadModel(sub);
}
void menuModelSelect(uint8_t event) void menuModelSelect(uint8_t event)
{ {
if (s_warning_result) { if (s_warning_result) {
@@ -477,15 +480,7 @@ void menuModelSelect(uint8_t event)
MENU_ADD_ITEM(STR_CREATE_MODEL); MENU_ADD_ITEM(STR_CREATE_MODEL);
MENU_ADD_ITEM(STR_RESTORE_MODEL); MENU_ADD_ITEM(STR_RESTORE_MODEL);
#else #else
// TODO duplicated *3 code selectModel(sub);
displayPopup(STR_LOADINGMODEL);
saveTimers();
eeCheck(true); // force writing of current model data before this is changed
if (g_eeGeneral.currModel != sub) {
g_eeGeneral.currModel = sub;
STORE_GENERALVARS;
eeLoadModel(sub);
}
#endif #endif
} }
} }
@@ -497,12 +492,7 @@ void menuModelSelect(uint8_t event)
menuHandler = onModelSelectMenu; menuHandler = onModelSelectMenu;
#else #else
if (g_eeGeneral.currModel != sub) { if (g_eeGeneral.currModel != sub) {
displayPopup(STR_LOADINGMODEL); selectModel(sub);
saveTimers();
eeCheck(true); // force writing of current model data before this is changed
g_eeGeneral.currModel = sub;
STORE_GENERALVARS;
eeLoadModel(sub);
} }
#endif #endif
} }
@@ -4439,9 +4429,15 @@ enum menuModelTelemetryItems {
#define RSSI_ROWS (uint8_t)-1, 1, 1, #define RSSI_ROWS (uint8_t)-1, 1, 1,
#endif #endif
#if defined(FRSKY_BARS)
#define SCREEN_TYPE_ROWS 0
#else
#define SCREEN_TYPE_ROWS (uint8_t)-1
#endif
void menuModelTelemetry(uint8_t event) void menuModelTelemetry(uint8_t event)
{ {
MENU(STR_MENUTELEMETRY, menuTabModel, e_Telemetry, ITEM_TELEMETRY_MAX+1, {0, CHANNEL_ROWS CHANNEL_ROWS RSSI_ROWS USRDATA_LINES 0, 0, IF_VARIO((uint8_t)-1) IF_VARIO(0) IF_VARIO(3) 0, 2, 2, 2, 2, 0, 2, 2, 2, IF_CPUARM(2) IF_CPUARM(0) IF_CPUARM(2) IF_CPUARM(2) IF_CPUARM(2) 2 }); MENU(STR_MENUTELEMETRY, menuTabModel, e_Telemetry, ITEM_TELEMETRY_MAX+1, {0, CHANNEL_ROWS CHANNEL_ROWS RSSI_ROWS USRDATA_LINES 0, 0, IF_VARIO((uint8_t)-1) IF_VARIO(0) IF_VARIO(3) SCREEN_TYPE_ROWS, 2, 2, 2, 2, SCREEN_TYPE_ROWS, 2, 2, 2, 2, IF_CPUARM(SCREEN_TYPE_ROWS) IF_CPUARM(2) IF_CPUARM(2) IF_CPUARM(2) IF_CPUARM(2) });
uint8_t sub = m_posVert - 1; uint8_t sub = m_posVert - 1;
@@ -4653,7 +4649,6 @@ void menuModelTelemetry(uint8_t event)
case ITEM_TELEMETRY_SCREEN_LABEL1: case ITEM_TELEMETRY_SCREEN_LABEL1:
case ITEM_TELEMETRY_SCREEN_LABEL2: case ITEM_TELEMETRY_SCREEN_LABEL2:
// TODO merge this code
#if defined(CPUARM) #if defined(CPUARM)
case ITEM_TELEMETRY_SCREEN_LABEL3: case ITEM_TELEMETRY_SCREEN_LABEL3:
{ {
+4 -4
View File
@@ -140,7 +140,7 @@ int8_t STORAGE_GetCapacity (uint8_t lun, uint32_t *block_num, uint32_t *block_si
{ {
if (lun == 1) { if (lun == 1) {
*block_size = 512; *block_size = 512;
*block_num = EESIZE + 3 ; *block_num = EESIZE/512 + 3 ;
} }
else { else {
if (!SD_CARD_PRESENT()) if (!SD_CARD_PRESENT())
@@ -277,7 +277,7 @@ const char g_FATboot[BLOCKSIZE] =
0x01, // Number of FATs 0x01, // Number of FATs
0x10, 0x00, // Number of root directory entries 0x10, 0x00, // Number of root directory entries
0x83, 0x00, // Total sectors = 131 (EESIZE/512)+3, 0x00, // Total sectors = 131
0xf8, // Media descriptor 0xf8, // Media descriptor
0x01, 0x00, // Sectors per FAT table 0x01, 0x00, // Sectors per FAT table
0x20, 0x00, // Sectors per track 0x20, 0x00, // Sectors per track
@@ -670,13 +670,13 @@ int32_t fat12Write(const uint8_t *buffer, uint16_t sector, uint32_t count )
if (test->version==EEFS_VERS && test->mySize==sizeof(eeFs) && test->bs==BS) { if (test->version==EEFS_VERS && test->mySize==sizeof(eeFs) && test->bs==BS) {
offset = sector; offset = sector;
} }
if (offset && sector >= offset) { if (offset && sector >= offset && (sector-offset) < EESIZE/512) {
eeWriteBlockCmp((uint8_t *)buffer, (sector-offset)*512, 512); eeWriteBlockCmp((uint8_t *)buffer, (sector-offset)*512, 512);
} }
buffer += 512; buffer += 512;
sector++; sector++;
count--; count--;
if (sector-offset+1==EESIZE/512) { if (sector-offset+1 >= EESIZE/512) {
offset = 0; offset = 0;
} }
} }