Changed OSD stick overlay to use custom symbols.

This commit is contained in:
mikeller 2019-01-24 21:14:14 +13:00
parent fe83d052da
commit 95eb87b678
3 changed files with 25 additions and 36 deletions

View File

@ -37,11 +37,13 @@
#define SYM_HOME 0x04 #define SYM_HOME 0x04
#define SYM_AIRCRAFT 0x05 #define SYM_AIRCRAFT 0x05
// Unit Icon´s (Metric) // Unit Icons (Metric)
#define SYM_M 0x0C #define SYM_M 0x0C
#define SYM_C 0x0E
// Unit Icon´s (Imperial) // Unit Icons (Imperial)
#define SYM_FT 0x0F #define SYM_FT 0x0F
#define SYM_F 0x0D
// Heading Graphics // Heading Graphics
#define SYM_HEADING_N 0x18 #define SYM_HEADING_N 0x18
@ -124,3 +126,11 @@
// Menu cursor // Menu cursor
#define SYM_CURSOR SYM_AH_LEFT #define SYM_CURSOR SYM_AH_LEFT
// Stick overlays
#define SYM_STICK_OVERLAY_SPRITE_HIGH 0x08
#define SYM_STICK_OVERLAY_SPRITE_MID 0x09
#define SYM_STICK_OVERLAY_SPRITE_LOW 0x0A
#define SYM_STICK_OVERLAY_CENTER 0x0B
#define SYM_STICK_OVERLAY_VERTICAL 0x16
#define SYM_STICK_OVERLAY_HORIZONTAL 0x17

View File

@ -109,15 +109,8 @@
// Stick overlay size // Stick overlay size
#define OSD_STICK_OVERLAY_WIDTH 7 #define OSD_STICK_OVERLAY_WIDTH 7
#define OSD_STICK_OVERLAY_HEIGHT 5 #define OSD_STICK_OVERLAY_HEIGHT 5
#define OSD_STICK_OVERLAY_CHARACTER_HEIGHT 3 #define OSD_STICK_OVERLAY_SPRITE_HEIGHT 3
#define OSD_STICK_OVERLAY_VERTICAL_POSITIONS (OSD_STICK_OVERLAY_HEIGHT * OSD_STICK_OVERLAY_CHARACTER_HEIGHT) #define OSD_STICK_OVERLAY_VERTICAL_POSITIONS (OSD_STICK_OVERLAY_HEIGHT * OSD_STICK_OVERLAY_SPRITE_HEIGHT)
#define STICK_OVERLAY_HORIZONTAL_CHAR '-'
#define STICK_OVERLAY_VERTICAL_CHAR '|'
#define STICK_OVERLAY_CROSS_CHAR '+'
#define STICK_OVERLAY_CURSOR_LOW_CHAR 0x86
#define STICK_OVERLAY_CURSOR_MID_CHAR 0x84
#define STICK_OVERLAY_CURSOR_HIGH_CHAR 0x82
const char * const osdTimerSourceNames[] = { const char * const osdTimerSourceNames[] = {
"ON TIME ", "ON TIME ",
@ -326,9 +319,9 @@ static char osdGetTemperatureSymbolForSelectedUnit(void)
{ {
switch (osdConfig()->units) { switch (osdConfig()->units) {
case OSD_UNIT_IMPERIAL: case OSD_UNIT_IMPERIAL:
return 'F'; return SYM_F;
default: default:
return 'C'; return SYM_C;
} }
} }
#endif #endif
@ -1306,11 +1299,11 @@ static void osdDrawStickOverlayAxis(uint8_t xpos, uint8_t ypos)
for (unsigned y = 0; y < OSD_STICK_OVERLAY_HEIGHT; y++) { for (unsigned y = 0; y < OSD_STICK_OVERLAY_HEIGHT; y++) {
// draw the axes, vertical and horizonal // draw the axes, vertical and horizonal
if ((x == ((OSD_STICK_OVERLAY_WIDTH - 1) / 2)) && (y == (OSD_STICK_OVERLAY_HEIGHT - 1) / 2)) { if ((x == ((OSD_STICK_OVERLAY_WIDTH - 1) / 2)) && (y == (OSD_STICK_OVERLAY_HEIGHT - 1) / 2)) {
displayWriteChar(osdDisplayPort, xpos + x, ypos + y, STICK_OVERLAY_CROSS_CHAR); displayWriteChar(osdDisplayPort, xpos + x, ypos + y, SYM_STICK_OVERLAY_CENTER);
} else if (x == ((OSD_STICK_OVERLAY_WIDTH - 1) / 2)) { } else if (x == ((OSD_STICK_OVERLAY_WIDTH - 1) / 2)) {
displayWriteChar(osdDisplayPort, xpos + x, ypos + y, STICK_OVERLAY_VERTICAL_CHAR); displayWriteChar(osdDisplayPort, xpos + x, ypos + y, SYM_STICK_OVERLAY_VERTICAL);
} else if (y == ((OSD_STICK_OVERLAY_HEIGHT - 1) / 2)) { } else if (y == ((OSD_STICK_OVERLAY_HEIGHT - 1) / 2)) {
displayWriteChar(osdDisplayPort, xpos + x, ypos + y, STICK_OVERLAY_HORIZONTAL_CHAR); displayWriteChar(osdDisplayPort, xpos + x, ypos + y, SYM_STICK_OVERLAY_HORIZONTAL);
} }
} }
} }
@ -1346,23 +1339,9 @@ static void osdDrawStickOverlayCursor(osd_items_e osd_item)
const uint8_t x_pos = scaleRange(constrain(rcData[horizontal_channel], PWM_RANGE_MIN, PWM_RANGE_MAX - 1), PWM_RANGE_MIN, PWM_RANGE_MAX, 0, OSD_STICK_OVERLAY_WIDTH); const uint8_t x_pos = scaleRange(constrain(rcData[horizontal_channel], PWM_RANGE_MIN, PWM_RANGE_MAX - 1), PWM_RANGE_MIN, PWM_RANGE_MAX, 0, OSD_STICK_OVERLAY_WIDTH);
const uint8_t y_pos = OSD_STICK_OVERLAY_VERTICAL_POSITIONS - 1 - scaleRange(constrain(rcData[vertical_channel], PWM_RANGE_MIN, PWM_RANGE_MAX - 1), PWM_RANGE_MIN, PWM_RANGE_MAX, 0, OSD_STICK_OVERLAY_VERTICAL_POSITIONS); const uint8_t y_pos = OSD_STICK_OVERLAY_VERTICAL_POSITIONS - 1 - scaleRange(constrain(rcData[vertical_channel], PWM_RANGE_MIN, PWM_RANGE_MAX - 1), PWM_RANGE_MIN, PWM_RANGE_MAX, 0, OSD_STICK_OVERLAY_VERTICAL_POSITIONS);
char cursor; const char cursor = SYM_STICK_OVERLAY_SPRITE_HIGH + (y_pos % OSD_STICK_OVERLAY_SPRITE_HEIGHT);
switch (y_pos % OSD_STICK_OVERLAY_CHARACTER_HEIGHT) {
case 0:
cursor = STICK_OVERLAY_CURSOR_HIGH_CHAR;
break; osdDrawStickOverlayPos(osd_item, x_pos, y_pos / OSD_STICK_OVERLAY_SPRITE_HEIGHT, cursor);
case 1:
cursor = STICK_OVERLAY_CURSOR_MID_CHAR;
break;
case 2:
cursor = STICK_OVERLAY_CURSOR_LOW_CHAR;
break;
}
osdDrawStickOverlayPos(osd_item, x_pos, y_pos / OSD_STICK_OVERLAY_CHARACTER_HEIGHT, cursor);
} }
#endif #endif

View File

@ -811,7 +811,7 @@ TEST(OsdTest, TestElementCoreTemperature)
osdRefresh(simulationTime); osdRefresh(simulationTime);
// then // then
displayPortTestBufferSubstring(1, 8, " 0C"); displayPortTestBufferSubstring(1, 8, " 0%c", SYM_C);
// given // given
simulationCoreTemperature = 33; simulationCoreTemperature = 33;
@ -821,7 +821,7 @@ TEST(OsdTest, TestElementCoreTemperature)
osdRefresh(simulationTime); osdRefresh(simulationTime);
// then // then
displayPortTestBufferSubstring(1, 8, " 33C"); displayPortTestBufferSubstring(1, 8, " 33%c", SYM_C);
// given // given
osdConfigMutable()->units = OSD_UNIT_IMPERIAL; osdConfigMutable()->units = OSD_UNIT_IMPERIAL;
@ -831,7 +831,7 @@ TEST(OsdTest, TestElementCoreTemperature)
osdRefresh(simulationTime); osdRefresh(simulationTime);
// then // then
displayPortTestBufferSubstring(1, 8, " 91F"); displayPortTestBufferSubstring(1, 8, " 91%c", SYM_F);
} }
/* /*