mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-14 20:10:18 +03:00
Fix OSD_X macro to correctly load the high bit (#12038)
Resolves #12037
This commit is contained in:
parent
40de3fd4d7
commit
f8bd0b5388
2 changed files with 26 additions and 3 deletions
|
@ -73,12 +73,12 @@ extern const char * const osdTimerSourceNames[OSD_NUM_TIMER_TYPES];
|
|||
// Character coordinate
|
||||
#define OSD_POSITION_BITS 5 // 5 bits gives a range 0-31
|
||||
#define OSD_POSITION_BIT_XHD 10 // extra bit used to extend X range in a backward compatible manner for HD displays
|
||||
#define OSD_POSITIION_XHD_MASK (1 << OSD_POSITION_BIT_XHD)
|
||||
#define OSD_POSITION_XHD_MASK (1 << OSD_POSITION_BIT_XHD)
|
||||
#define OSD_POSITION_XY_MASK ((1 << OSD_POSITION_BITS) - 1)
|
||||
#define OSD_TYPE_MASK 0xC000 // bits 14-15
|
||||
#define OSD_POS(x,y) ((x & OSD_POSITION_XY_MASK) | ((x << (OSD_POSITION_BIT_XHD - OSD_POSITION_BITS)) & OSD_POSITIION_XHD_MASK) | \
|
||||
#define OSD_POS(x,y) ((x & OSD_POSITION_XY_MASK) | ((x << (OSD_POSITION_BIT_XHD - OSD_POSITION_BITS)) & OSD_POSITION_XHD_MASK) | \
|
||||
((y & OSD_POSITION_XY_MASK) << OSD_POSITION_BITS))
|
||||
#define OSD_X(x) ((x & OSD_POSITION_XY_MASK) | ((x & OSD_POSITION_BIT_XHD) >> (OSD_POSITION_BIT_XHD - OSD_POSITION_BITS)))
|
||||
#define OSD_X(x) ((x & OSD_POSITION_XY_MASK) | ((x & OSD_POSITION_XHD_MASK) >> (OSD_POSITION_BIT_XHD - OSD_POSITION_BITS)))
|
||||
#define OSD_Y(x) ((x >> OSD_POSITION_BITS) & OSD_POSITION_XY_MASK)
|
||||
#define OSD_TYPE(x) ((x & OSD_TYPE_MASK) >> 14)
|
||||
|
||||
|
|
|
@ -1263,6 +1263,29 @@ TEST_F(OsdTest, TestGpsElements)
|
|||
}
|
||||
}
|
||||
|
||||
TEST_F(OsdTest, TestHdPositioning)
|
||||
{
|
||||
// given
|
||||
// Try to round-trip the OSD_POS macro with an "HD location"
|
||||
osdElementConfigMutable()->item_pos[OSD_RSSI_VALUE] = OSD_POS(53, 0) | OSD_PROFILE_1_FLAG;
|
||||
osdConfigMutable()->rssi_alarm = 0;
|
||||
// Also try to round-trip a raw value matching one generated by the Configurator.
|
||||
osdElementConfigMutable()->item_pos[OSD_CURRENT_DRAW] = 3125 | OSD_PROFILE_1_FLAG;
|
||||
|
||||
osdAnalyzeActiveElements();
|
||||
|
||||
// when
|
||||
simulationBatteryAmperage = 0;
|
||||
rssi = 1024;
|
||||
|
||||
displayClearScreen(&testDisplayPort, DISPLAY_CLEAR_WAIT);
|
||||
osdRefresh();
|
||||
|
||||
// then
|
||||
displayPortTestBufferSubstring(53, 0, "%c99", SYM_RSSI);
|
||||
displayPortTestBufferSubstring(53, 1, " 0.00%c", SYM_AMP);
|
||||
}
|
||||
|
||||
// STUBS
|
||||
extern "C" {
|
||||
bool featureIsEnabled(uint32_t f) { return simulationFeatureFlags & f; }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue