1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-21 07:15:18 +03:00

initial implementation of log status OSD element

This commit is contained in:
Kiripolszky Károly 2018-06-18 14:54:24 +02:00
parent 40a4ab77fe
commit c0e2ca3546
5 changed files with 44 additions and 3 deletions

View file

@ -41,6 +41,10 @@
#include "msp/msp_serial.h"
#ifdef USE_SDCARD
#include "drivers/sdcard.h"
#endif
#define BLACKBOX_SERIAL_PORT_MODE MODE_TX
// How many bytes can we transmit per loop iteration when writing headers?
@ -538,6 +542,24 @@ bool isBlackboxDeviceFull(void)
}
}
bool isBlackboxDeviceWorking(void)
{
switch (blackboxConfig()->device) {
#ifdef USE_SDCARD
case BLACKBOX_DEVICE_SDCARD:
return sdcard_isInserted() && sdcard_isFunctional() && (afatfs_getFilesystemState() == AFATFS_FILESYSTEM_STATE_READY);
#endif
#ifdef USE_FLASHFS
case BLACKBOX_DEVICE_FLASH:
return flashfsIsReady();
#endif
default:
return false;
}
}
unsigned int blackboxGetLogNumber(void)
{
#ifdef USE_SDCARD

View file

@ -56,6 +56,7 @@ bool blackboxDeviceBeginLog(void);
bool blackboxDeviceEndLog(bool retainLog);
bool isBlackboxDeviceFull(void);
bool isBlackboxDeviceWorking(void);
unsigned int blackboxGetLogNumber(void);
void blackboxReplenishHeaderBudget(void);

View file

@ -985,6 +985,9 @@ const clivalue_t valueTable[] = {
#ifdef USE_ADC_INTERNAL
{ "osd_core_temp_pos", VAR_UINT16 | MASTER_VALUE, .config.minmax = { 0, OSD_POSCFG_MAX }, PG_OSD_CONFIG, offsetof(osdConfig_t, item_pos[OSD_CORE_TEMPERATURE]) },
#endif
#ifdef USE_BLACKBOX
{ "osd_log_status_pos", VAR_UINT16 | MASTER_VALUE, .config.minmax = { 0, OSD_POSCFG_MAX }, PG_OSD_CONFIG, offsetof(osdConfig_t, item_pos[OSD_LOG_STATUS]) },
#endif
// OSD stats enabled flags are stored as bitmapped values inside a 32bit parameter
// It is recommended to keep the settings order the same as the enumeration. This way the settings are displayed in the cli in the same order making it easier on the users

View file

@ -212,6 +212,7 @@ static const uint8_t osdElementDisplayOrder[] = {
#ifdef USE_ADC_INTERNAL
OSD_CORE_TEMPERATURE,
#endif
OSD_LOG_STATUS
};
PG_REGISTER_WITH_RESET_FN(osdConfig_t, osdConfig, PG_OSD_CONFIG, 3);
@ -981,6 +982,20 @@ static bool osdDrawSingleElement(uint8_t item)
break;
#endif
#ifdef USE_BLACKBOX
case OSD_LOG_STATUS:
if (!IS_RC_MODE_ACTIVE(BOXBLACKBOX)) {
break;
} else if (!isBlackboxDeviceWorking()) {
tfp_sprintf(buff, "L-");
} else if (isBlackboxDeviceFull()) {
tfp_sprintf(buff, "L>");
} else {
tfp_sprintf(buff, "L%d", blackboxGetLogNumber());
}
break;
#endif
default:
return false;
}
@ -1294,16 +1309,16 @@ static void osdUpdateStats(void)
}
#ifdef USE_BLACKBOX
static void osdGetBlackboxStatusString(char * buff)
{
bool storageDeviceIsWorking = false;
bool storageDeviceIsWorking = isBlackboxDeviceWorking();
uint32_t storageUsed = 0;
uint32_t storageTotal = 0;
switch (blackboxConfig()->device) {
#ifdef USE_SDCARD
case BLACKBOX_DEVICE_SDCARD:
storageDeviceIsWorking = sdcard_isInserted() && sdcard_isFunctional() && (afatfs_getFilesystemState() == AFATFS_FILESYSTEM_STATE_READY);
if (storageDeviceIsWorking) {
storageTotal = sdcard_getMetadata()->numBlocks / 2000;
storageUsed = storageTotal - (afatfs_getContiguousFreeSpace() / 1024000);
@ -1313,7 +1328,6 @@ static void osdGetBlackboxStatusString(char * buff)
#ifdef USE_FLASHFS
case BLACKBOX_DEVICE_FLASH:
storageDeviceIsWorking = flashfsIsSupported();
if (storageDeviceIsWorking) {
const flashGeometry_t *geometry = flashfsGetGeometry();
storageTotal = geometry->totalSize / 1024;

View file

@ -96,6 +96,7 @@ typedef enum {
OSD_CORE_TEMPERATURE,
OSD_ANTI_GRAVITY,
OSD_G_FORCE,
OSD_LOG_STATUS,
OSD_ITEM_COUNT // MUST BE LAST
} osd_items_e;