mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-21 15:25:36 +03:00
initial implementation of log status OSD element
This commit is contained in:
parent
40a4ab77fe
commit
c0e2ca3546
5 changed files with 44 additions and 3 deletions
|
@ -41,6 +41,10 @@
|
||||||
|
|
||||||
#include "msp/msp_serial.h"
|
#include "msp/msp_serial.h"
|
||||||
|
|
||||||
|
#ifdef USE_SDCARD
|
||||||
|
#include "drivers/sdcard.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#define BLACKBOX_SERIAL_PORT_MODE MODE_TX
|
#define BLACKBOX_SERIAL_PORT_MODE MODE_TX
|
||||||
|
|
||||||
// How many bytes can we transmit per loop iteration when writing headers?
|
// 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)
|
unsigned int blackboxGetLogNumber(void)
|
||||||
{
|
{
|
||||||
#ifdef USE_SDCARD
|
#ifdef USE_SDCARD
|
||||||
|
|
|
@ -56,6 +56,7 @@ bool blackboxDeviceBeginLog(void);
|
||||||
bool blackboxDeviceEndLog(bool retainLog);
|
bool blackboxDeviceEndLog(bool retainLog);
|
||||||
|
|
||||||
bool isBlackboxDeviceFull(void);
|
bool isBlackboxDeviceFull(void);
|
||||||
|
bool isBlackboxDeviceWorking(void);
|
||||||
unsigned int blackboxGetLogNumber(void);
|
unsigned int blackboxGetLogNumber(void);
|
||||||
|
|
||||||
void blackboxReplenishHeaderBudget(void);
|
void blackboxReplenishHeaderBudget(void);
|
||||||
|
|
|
@ -985,6 +985,9 @@ const clivalue_t valueTable[] = {
|
||||||
#ifdef USE_ADC_INTERNAL
|
#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]) },
|
{ "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
|
#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
|
// 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
|
// 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
|
||||||
|
|
|
@ -212,6 +212,7 @@ static const uint8_t osdElementDisplayOrder[] = {
|
||||||
#ifdef USE_ADC_INTERNAL
|
#ifdef USE_ADC_INTERNAL
|
||||||
OSD_CORE_TEMPERATURE,
|
OSD_CORE_TEMPERATURE,
|
||||||
#endif
|
#endif
|
||||||
|
OSD_LOG_STATUS
|
||||||
};
|
};
|
||||||
|
|
||||||
PG_REGISTER_WITH_RESET_FN(osdConfig_t, osdConfig, PG_OSD_CONFIG, 3);
|
PG_REGISTER_WITH_RESET_FN(osdConfig_t, osdConfig, PG_OSD_CONFIG, 3);
|
||||||
|
@ -981,6 +982,20 @@ static bool osdDrawSingleElement(uint8_t item)
|
||||||
break;
|
break;
|
||||||
#endif
|
#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:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1294,16 +1309,16 @@ static void osdUpdateStats(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_BLACKBOX
|
#ifdef USE_BLACKBOX
|
||||||
|
|
||||||
static void osdGetBlackboxStatusString(char * buff)
|
static void osdGetBlackboxStatusString(char * buff)
|
||||||
{
|
{
|
||||||
bool storageDeviceIsWorking = false;
|
bool storageDeviceIsWorking = isBlackboxDeviceWorking();
|
||||||
uint32_t storageUsed = 0;
|
uint32_t storageUsed = 0;
|
||||||
uint32_t storageTotal = 0;
|
uint32_t storageTotal = 0;
|
||||||
|
|
||||||
switch (blackboxConfig()->device) {
|
switch (blackboxConfig()->device) {
|
||||||
#ifdef USE_SDCARD
|
#ifdef USE_SDCARD
|
||||||
case BLACKBOX_DEVICE_SDCARD:
|
case BLACKBOX_DEVICE_SDCARD:
|
||||||
storageDeviceIsWorking = sdcard_isInserted() && sdcard_isFunctional() && (afatfs_getFilesystemState() == AFATFS_FILESYSTEM_STATE_READY);
|
|
||||||
if (storageDeviceIsWorking) {
|
if (storageDeviceIsWorking) {
|
||||||
storageTotal = sdcard_getMetadata()->numBlocks / 2000;
|
storageTotal = sdcard_getMetadata()->numBlocks / 2000;
|
||||||
storageUsed = storageTotal - (afatfs_getContiguousFreeSpace() / 1024000);
|
storageUsed = storageTotal - (afatfs_getContiguousFreeSpace() / 1024000);
|
||||||
|
@ -1313,7 +1328,6 @@ static void osdGetBlackboxStatusString(char * buff)
|
||||||
|
|
||||||
#ifdef USE_FLASHFS
|
#ifdef USE_FLASHFS
|
||||||
case BLACKBOX_DEVICE_FLASH:
|
case BLACKBOX_DEVICE_FLASH:
|
||||||
storageDeviceIsWorking = flashfsIsSupported();
|
|
||||||
if (storageDeviceIsWorking) {
|
if (storageDeviceIsWorking) {
|
||||||
const flashGeometry_t *geometry = flashfsGetGeometry();
|
const flashGeometry_t *geometry = flashfsGetGeometry();
|
||||||
storageTotal = geometry->totalSize / 1024;
|
storageTotal = geometry->totalSize / 1024;
|
||||||
|
|
|
@ -96,6 +96,7 @@ typedef enum {
|
||||||
OSD_CORE_TEMPERATURE,
|
OSD_CORE_TEMPERATURE,
|
||||||
OSD_ANTI_GRAVITY,
|
OSD_ANTI_GRAVITY,
|
||||||
OSD_G_FORCE,
|
OSD_G_FORCE,
|
||||||
|
OSD_LOG_STATUS,
|
||||||
OSD_ITEM_COUNT // MUST BE LAST
|
OSD_ITEM_COUNT // MUST BE LAST
|
||||||
} osd_items_e;
|
} osd_items_e;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue