Update OSD unit test as per comments from @ledvinap
This commit is contained in:
parent
427c5fe524
commit
270c4bd5fe
|
@ -21,6 +21,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#define SYM_END_OF_FONT 0xFF
|
||||
|
||||
// Character Symbols
|
||||
#define SYM_BLANK 0x20
|
||||
|
||||
|
|
|
@ -755,10 +755,10 @@ void pgResetFn_osdConfig(osdConfig_t *osdConfig)
|
|||
static void osdDrawLogo(int x, int y)
|
||||
{
|
||||
// display logo and help
|
||||
unsigned char fontOffset = 160;
|
||||
int fontOffset = 160;
|
||||
for (int row = 0; row < 4; row++) {
|
||||
for (int column = 0; column < 24; column++) {
|
||||
if (fontOffset != 255) // FIXME magic number
|
||||
if (fontOffset <= SYM_END_OF_FONT)
|
||||
displayWriteChar(osdDisplayPort, x + column, y + row, fontOffset++);
|
||||
}
|
||||
}
|
||||
|
@ -801,7 +801,6 @@ void osdInit(displayPort_t *osdDisplayPortToUse)
|
|||
void osdUpdateAlarms(void)
|
||||
{
|
||||
// This is overdone?
|
||||
// uint16_t *itemPos = osdConfig()->item_pos;
|
||||
|
||||
int32_t alt = osdGetMetersToSelectedUnit(getEstimatedAltitude()) / 100;
|
||||
|
||||
|
@ -1051,7 +1050,7 @@ STATIC_UNIT_TESTED void osdRefresh(timeUs_t currentTimeUs)
|
|||
armState = ARMING_FLAG(ARMED);
|
||||
}
|
||||
|
||||
statRssi = rssi * 100 / 1024;
|
||||
statRssi = scaleRange(rssi, 0, 1024, 0, 100);
|
||||
|
||||
osdUpdateStats();
|
||||
|
||||
|
|
|
@ -29,9 +29,10 @@
|
|||
// Character coordinate
|
||||
|
||||
#define OSD_POSITION_BITS 5 // 5 bits gives a range 0-31
|
||||
#define OSD_POS(x,y) ((x & 0x001F) | ((y & 0x001F) << OSD_POSITION_BITS))
|
||||
#define OSD_X(x) (x & 0x001F)
|
||||
#define OSD_Y(x) ((x >> OSD_POSITION_BITS) & 0x001F)
|
||||
#define OSD_POSITION_XY_MASK ((1 << OSD_POSITION_BITS) - 1)
|
||||
#define OSD_POS(x,y) ((x & OSD_POSITION_XY_MASK) | ((y & OSD_POSITION_XY_MASK) << OSD_POSITION_BITS))
|
||||
#define OSD_X(x) (x & OSD_POSITION_XY_MASK)
|
||||
#define OSD_Y(x) ((x >> OSD_POSITION_BITS) & OSD_POSITION_XY_MASK)
|
||||
|
||||
typedef enum {
|
||||
OSD_RSSI_VALUE,
|
||||
|
|
|
@ -102,7 +102,7 @@ void doTestArm(bool testEmpty = true)
|
|||
|
||||
// given
|
||||
// armed alert times out (0.5 seconds)
|
||||
simulationTime += 5e5;
|
||||
simulationTime += 0.5e6;
|
||||
|
||||
// when
|
||||
// sufficient OSD updates have been called
|
||||
|
@ -114,9 +114,7 @@ void doTestArm(bool testEmpty = true)
|
|||
displayPortTestPrint();
|
||||
#endif
|
||||
if (testEmpty) {
|
||||
for (size_t i = 0; i < UNITTEST_DISPLAYPORT_BUFFER_LEN; i++) {
|
||||
EXPECT_EQ(' ', testDisplayPortBuffer[i]);
|
||||
}
|
||||
displayPortTestBufferIsEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -320,7 +318,7 @@ TEST(OsdTest, TestStatsImperial)
|
|||
displayPortTestBufferSubstring(2, 6, "MAX DISTANCE : 328%c", SYM_FT);
|
||||
displayPortTestBufferSubstring(2, 7, "MIN BATTERY : 14.7%c", SYM_VOLT);
|
||||
displayPortTestBufferSubstring(2, 8, "END BATTERY : 15.2%c", SYM_VOLT);
|
||||
displayPortTestBufferSubstring(2, 9, "MIN RSSI : 25%");
|
||||
displayPortTestBufferSubstring(2, 9, "MIN RSSI : 25%%");
|
||||
displayPortTestBufferSubstring(2, 10, "MAX ALTITUDE : 6.5%c", SYM_FT);
|
||||
}
|
||||
|
||||
|
@ -369,7 +367,7 @@ TEST(OsdTest, TestStatsMetric)
|
|||
displayPortTestBufferSubstring(2, 6, "MAX DISTANCE : 100%c", SYM_M);
|
||||
displayPortTestBufferSubstring(2, 7, "MIN BATTERY : 14.7%c", SYM_VOLT);
|
||||
displayPortTestBufferSubstring(2, 8, "END BATTERY : 15.2%c", SYM_VOLT);
|
||||
displayPortTestBufferSubstring(2, 9, "MIN RSSI : 25%");
|
||||
displayPortTestBufferSubstring(2, 9, "MIN RSSI : 25%%");
|
||||
displayPortTestBufferSubstring(2, 10, "MAX ALTITUDE : 2.0%c", SYM_M);
|
||||
}
|
||||
|
||||
|
@ -406,8 +404,9 @@ TEST(OsdTest, TestAlarms)
|
|||
|
||||
// then
|
||||
// no elements should flash as all values are out of alarm range
|
||||
for (int i = 0; i < 6; i++) {
|
||||
simulationTime += 1e6;
|
||||
for (int i = 0; i < 30; i++) {
|
||||
// Check for visibility every 100ms, elements should always be visible
|
||||
simulationTime += 0.1e6;
|
||||
osdRefresh(simulationTime);
|
||||
|
||||
#ifdef DEBUG_OSD
|
||||
|
@ -433,15 +432,16 @@ TEST(OsdTest, TestAlarms)
|
|||
|
||||
// then
|
||||
// elements showing values in alarm range should flash
|
||||
for (int i = 0; i < 6; i++) {
|
||||
simulationTime += 1e6;
|
||||
for (int i = 0; i < 15; i++) {
|
||||
// Blinking should happen at 5Hz
|
||||
simulationTime += 0.2e6;
|
||||
osdRefresh(simulationTime);
|
||||
|
||||
#ifdef DEBUG_OSD
|
||||
printf("%d\n", i);
|
||||
displayPortTestPrint();
|
||||
#endif
|
||||
if (i % 2 == 1) {
|
||||
if (i % 2 == 0) {
|
||||
displayPortTestBufferSubstring(8, 1, "%c12", SYM_RSSI);
|
||||
displayPortTestBufferSubstring(12, 1, "%c13.5%c", SYM_MAIN_BATT, SYM_VOLT);
|
||||
displayPortTestBufferSubstring(1, 1, "%c01:", SYM_FLY_M); // only test the minute part of the timer
|
||||
|
|
|
@ -26,6 +26,8 @@ extern "C" {
|
|||
#include "unittest_macros.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
void displayPortTestBufferSubstring(int x, int y, const char * expectedFormat, ...) __attribute__ ((format (printf, 3, 4)));
|
||||
|
||||
#define UNITTEST_DISPLAYPORT_ROWS 16
|
||||
#define UNITTEST_DISPLAYPORT_COLS 30
|
||||
#define UNITTEST_DISPLAYPORT_BUFFER_LEN (UNITTEST_DISPLAYPORT_ROWS * UNITTEST_DISPLAYPORT_COLS)
|
||||
|
@ -146,11 +148,11 @@ void displayPortTestBufferIsEmpty()
|
|||
|
||||
void displayPortTestBufferSubstring(int x, int y, const char * expectedFormat, ...)
|
||||
{
|
||||
char expected[32];
|
||||
char expected[UNITTEST_DISPLAYPORT_BUFFER_LEN];
|
||||
|
||||
va_list args;
|
||||
va_start(args, expectedFormat);
|
||||
vsprintf(expected, expectedFormat, args);
|
||||
vsnprintf(expected, UNITTEST_DISPLAYPORT_BUFFER_LEN, expectedFormat, args);
|
||||
va_end(args);
|
||||
|
||||
#ifdef DEBUG_OSD
|
||||
|
|
Loading…
Reference in New Issue