Show blackbox log number in OSD only when available.

This commit is contained in:
mikeller 2019-11-02 13:50:36 +13:00
parent 086c75b3bf
commit 53955a4a6b
6 changed files with 27 additions and 14 deletions

View File

@ -76,7 +76,7 @@ static struct {
afatfsFilePtr_t logFile;
afatfsFilePtr_t logDirectory;
afatfsFinder_t logDirectoryFinder;
uint32_t largestLogFileNumber;
int32_t largestLogFileNumber;
enum {
BLACKBOX_SDCARD_INITIAL,
@ -440,7 +440,7 @@ static void blackboxLogFileCreated(afatfsFilePtr_t file)
static void blackboxCreateLogFile(void)
{
uint32_t remainder = blackboxSDCard.largestLogFileNumber + 1;
int32_t remainder = blackboxSDCard.largestLogFileNumber + 1;
char filename[] = LOGFILE_PREFIX "00000." LOGFILE_SUFFIX;
@ -488,7 +488,7 @@ static bool blackboxSDCardBeginLog(void)
memcpy(logSequenceNumberString, directoryEntry->filename + 3, 5);
logSequenceNumberString[5] = '\0';
blackboxSDCard.largestLogFileNumber = MAX((uint32_t) atoi(logSequenceNumberString), blackboxSDCard.largestLogFileNumber);
blackboxSDCard.largestLogFileNumber = MAX((int32_t)atoi(logSequenceNumberString), blackboxSDCard.largestLogFileNumber);
}
} else {
// We're done checking all the files on the card, now we can create a new log file
@ -619,12 +619,17 @@ bool isBlackboxDeviceWorking(void)
}
}
unsigned int blackboxGetLogNumber(void)
int32_t blackboxGetLogNumber(void)
{
switch (blackboxConfig()->device) {
#ifdef USE_SDCARD
return blackboxSDCard.largestLogFileNumber;
case BLACKBOX_DEVICE_SDCARD:
return blackboxSDCard.largestLogFileNumber;
#endif
return 0;
default:
return -1;
}
}
/**

View File

@ -57,7 +57,7 @@ bool blackboxDeviceEndLog(bool retainLog);
bool isBlackboxDeviceFull(void);
bool isBlackboxDeviceWorking(void);
unsigned int blackboxGetLogNumber(void);
int32_t blackboxGetLogNumber(void);
void blackboxReplenishHeaderBudget(void);
blackboxBufferReserveStatus_e blackboxDeviceReserveBufferSpace(int32_t bytes);

View File

@ -670,10 +670,13 @@ static bool osdDisplayStat(int statistic, uint8_t displayRow)
break;
case OSD_STAT_BLACKBOX_NUMBER:
if (blackboxConfig()->device && blackboxConfig()->device != BLACKBOX_DEVICE_SERIAL) {
itoa(blackboxGetLogNumber(), buff, 10);
osdDisplayStatisticLabel(displayRow, "BB LOG NUM", buff);
return true;
{
int32_t logNumber = blackboxGetLogNumber();
if (logNumber >= 0) {
itoa(logNumber, buff, 10);
osdDisplayStatisticLabel(displayRow, "BB LOG NUM", buff);
return true;
}
}
break;
#endif

View File

@ -923,7 +923,12 @@ static void osdElementLogStatus(osdElementParms_t *element)
} else if (isBlackboxDeviceFull()) {
tfp_sprintf(element->buff, "%c>", SYM_BBLOG);
} else {
tfp_sprintf(element->buff, "%c%d", SYM_BBLOG, blackboxGetLogNumber());
int32_t logNumber = blackboxGetLogNumber();
if (logNumber >= 0) {
tfp_sprintf(element->buff, "%c%d", SYM_BBLOG, logNumber);
} else {
tfp_sprintf(element->buff, "%c", SYM_BBLOG);
}
}
}
}

View File

@ -423,7 +423,7 @@ extern "C" {
int32_t getMAhDrawn() { return 0; }
int32_t getEstimatedAltitudeCm() { return 0; }
int32_t getEstimatedVario() { return 0; }
unsigned int blackboxGetLogNumber() { return 0; }
int32_t blackboxGetLogNumber() { return 0; }
bool isBlackboxDeviceWorking() { return true; }
bool isBlackboxDeviceFull() { return false; }
serialPort_t *openSerialPort(serialPortIdentifier_e, serialPortFunction_e, serialReceiveCallbackPtr, void *, uint32_t, portMode_e, portOptions_e) {return NULL;}

View File

@ -1132,7 +1132,7 @@ extern "C" {
return simulationVerticalSpeed;
}
unsigned int blackboxGetLogNumber() {
int32_t blackboxGetLogNumber() {
return 0;
}