From 4cd1f4efb4231c0b7a324940c83f7756ca1b1466 Mon Sep 17 00:00:00 2001 From: Krzysztof Kuczek Date: Sat, 16 Jan 2021 20:06:07 +0100 Subject: [PATCH 1/3] new dashboard OLED page for Black Box --- src/main/blackbox/blackbox_io.c | 9 +++++++++ src/main/blackbox/blackbox_io.h | 1 + src/main/io/dashboard.c | 31 +++++++++++++++++++++++++++++++ src/main/io/dashboard.h | 2 +- 4 files changed, 42 insertions(+), 1 deletion(-) diff --git a/src/main/blackbox/blackbox_io.c b/src/main/blackbox/blackbox_io.c index b3515091bb..7b6ede5e5d 100644 --- a/src/main/blackbox/blackbox_io.c +++ b/src/main/blackbox/blackbox_io.c @@ -745,4 +745,13 @@ blackboxBufferReserveStatus_e blackboxDeviceReserveBufferSpace(int32_t bytes) return BLACKBOX_RESERVE_PERMANENT_FAILURE; } } +int8_t blackboxGetLogFileNo(void) +{ + // return current file number or -1 + if (blackboxSDCard.state == BLACKBOX_SDCARD_READY_TO_LOG){ + return blackboxSDCard.largestLogFileNumber; + }else { + return -1; + } +} #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..6ac23da564 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" @@ -580,6 +583,33 @@ static void showDebugPage(void) } #endif +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, "Log not started!"); + } + 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); +} + 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 +624,7 @@ static const pageEntry_t pages[PAGE_COUNT] = { #if defined(USE_TASK_STATISTICS) { PAGE_TASKS, "TASKS", showTasksPage, PAGE_FLAGS_NONE }, #endif + { PAGE_BB, "BLACK BOX", showBBPage, PAGE_FLAGS_NONE }, #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..bb02ce719c 100644 --- a/src/main/io/dashboard.h +++ b/src/main/io/dashboard.h @@ -53,7 +53,7 @@ typedef enum { #ifdef ENABLE_DEBUG_DASHBOARD_PAGE PAGE_DEBUG, #endif - + PAGE_BB, PAGE_COUNT } pageId_e; From 78049955dd36ee3fefd2837acf2b31bd2c0f1e75 Mon Sep 17 00:00:00 2001 From: Krzysztof Kuczek Date: Tue, 19 Jan 2021 10:08:42 +0100 Subject: [PATCH 2/3] cosmetic changes --- src/main/blackbox/blackbox_io.c | 12 ++++++++++-- src/main/io/dashboard.c | 31 +++++++++++++++++++++++++++++++ src/main/io/dashboard.h | 2 ++ 3 files changed, 43 insertions(+), 2 deletions(-) diff --git a/src/main/blackbox/blackbox_io.c b/src/main/blackbox/blackbox_io.c index 7b6ede5e5d..dce1c14eef 100644 --- a/src/main/blackbox/blackbox_io.c +++ b/src/main/blackbox/blackbox_io.c @@ -745,13 +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){ + if (blackboxSDCard.state == BLACKBOX_SDCARD_READY_TO_LOG) { return blackboxSDCard.largestLogFileNumber; - }else { + } else { return -1; } +#else + // will be implemented later for flash based storage + return -1; +#endif +#endif } #endif // BLACKBOX diff --git a/src/main/io/dashboard.c b/src/main/io/dashboard.c index 6ac23da564..63bd8f0050 100644 --- a/src/main/io/dashboard.c +++ b/src/main/io/dashboard.c @@ -570,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) @@ -624,7 +653,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 bb02ce719c..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; From fd7f1e699199d76238e72573172c8b2126ca8b34 Mon Sep 17 00:00:00 2001 From: Krzysztof Kuczek Date: Tue, 19 Jan 2021 20:05:52 +0100 Subject: [PATCH 3/3] cosmetic changes 2 --- src/main/io/dashboard.c | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/src/main/io/dashboard.c b/src/main/io/dashboard.c index 63bd8f0050..59699b5ac0 100644 --- a/src/main/io/dashboard.c +++ b/src/main/io/dashboard.c @@ -612,32 +612,6 @@ static void showDebugPage(void) } #endif -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, "Log not started!"); - } - 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); -} static const pageEntry_t pages[PAGE_COUNT] = { { PAGE_WELCOME, FC_FIRMWARE_NAME, showWelcomePage, PAGE_FLAGS_SKIP_CYCLING },