diff --git a/src/main/blackbox/blackbox_io.c b/src/main/blackbox/blackbox_io.c index b3515091bb..dce1c14eef 100644 --- a/src/main/blackbox/blackbox_io.c +++ b/src/main/blackbox/blackbox_io.c @@ -745,4 +745,21 @@ blackboxBufferReserveStatus_e blackboxDeviceReserveBufferSpace(int32_t bytes) return BLACKBOX_RESERVE_PERMANENT_FAILURE; } } + +int8_t blackboxGetLogFileNo(void) +{ +#ifdef USE_BLACKBOX +#ifdef USE_SDCARD + // return current file number or -1 + if (blackboxSDCard.state == BLACKBOX_SDCARD_READY_TO_LOG) { + return blackboxSDCard.largestLogFileNumber; + } else { + return -1; + } +#else + // will be implemented later for flash based storage + return -1; +#endif +#endif +} #endif // BLACKBOX diff --git a/src/main/blackbox/blackbox_io.h b/src/main/blackbox/blackbox_io.h index ba3ec1cc18..a46124e4d5 100644 --- a/src/main/blackbox/blackbox_io.h +++ b/src/main/blackbox/blackbox_io.h @@ -63,3 +63,4 @@ int32_t blackboxGetLogNumber(void); void blackboxReplenishHeaderBudget(void); blackboxBufferReserveStatus_e blackboxDeviceReserveBufferSpace(int32_t bytes); +int8_t blackboxGetLogFileNo(void); diff --git a/src/main/io/dashboard.c b/src/main/io/dashboard.c index 4dabcf24cb..59699b5ac0 100644 --- a/src/main/io/dashboard.c +++ b/src/main/io/dashboard.c @@ -63,6 +63,9 @@ #include "io/dashboard.h" #include "io/displayport_oled.h" +#include "blackbox/blackbox_io.h" +#include "blackbox/blackbox.h" + #include "rx/rx.h" #include "scheduler/scheduler.h" @@ -567,6 +570,35 @@ static void showTasksPage(void) } #endif +#ifdef USE_BLACKBOX +static void showBBPage(void) +{ + uint8_t rowIndex = PAGE_TITLE_LINE_COUNT; + int8_t fileNo; + if (isBlackboxDeviceWorking()) { + switch (blackboxConfig()->device) { + case BLACKBOX_DEVICE_SDCARD: + fileNo = blackboxGetLogFileNo(); + if( fileNo > 0) { + tfp_sprintf(lineBuffer, "File no: %d", fileNo); + } else { + tfp_sprintf(lineBuffer, "Not ready yet"); + } + break; + default: + tfp_sprintf(lineBuffer, "Not supp. dev."); + break; + } + } else { + tfp_sprintf(lineBuffer, "BB not working"); + } + + padLineBuffer(); + i2c_OLED_set_line(bus, rowIndex++); + i2c_OLED_send_string(bus, lineBuffer); +} +#endif + #ifdef ENABLE_DEBUG_DASHBOARD_PAGE static void showDebugPage(void) @@ -580,6 +612,7 @@ static void showDebugPage(void) } #endif + static const pageEntry_t pages[PAGE_COUNT] = { { PAGE_WELCOME, FC_FIRMWARE_NAME, showWelcomePage, PAGE_FLAGS_SKIP_CYCLING }, { PAGE_ARMED, "ARMED", showArmedPage, PAGE_FLAGS_SKIP_CYCLING }, @@ -594,6 +627,9 @@ static const pageEntry_t pages[PAGE_COUNT] = { #if defined(USE_TASK_STATISTICS) { PAGE_TASKS, "TASKS", showTasksPage, PAGE_FLAGS_NONE }, #endif +#ifdef USE_BLACKBOX + { PAGE_BB, "BLACK BOX", showBBPage, PAGE_FLAGS_NONE }, +#endif #ifdef ENABLE_DEBUG_DASHBOARD_PAGE { PAGE_DEBUG, "DEBUG", showDebugPage, PAGE_FLAGS_NONE }, #endif diff --git a/src/main/io/dashboard.h b/src/main/io/dashboard.h index 626b139e5b..53597795ad 100644 --- a/src/main/io/dashboard.h +++ b/src/main/io/dashboard.h @@ -53,7 +53,9 @@ typedef enum { #ifdef ENABLE_DEBUG_DASHBOARD_PAGE PAGE_DEBUG, #endif - +#ifdef USE_BLACKBOX + PAGE_BB, +#endif PAGE_COUNT } pageId_e;