1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-23 16:25:31 +03:00

Use max7456WriteChar instead of direct access to screenBuffer (osd.c)

Some fix-ups for different targets.
This commit is contained in:
jflyper 2016-11-02 19:12:50 +09:00
parent 15c83c184c
commit cc69964d6b
2 changed files with 34 additions and 34 deletions

View file

@ -289,8 +289,8 @@ int cmsDrawMenuEntry(displayPort_t *pDisplay, OSD_Entry *p, uint8_t row, bool dr
} }
break; break;
} }
case OME_VISIBLE:
#ifdef OSD #ifdef OSD
case OME_VISIBLE:
if (IS_PRINTVALUE(p) && p->data) { if (IS_PRINTVALUE(p) && p->data) {
uint32_t address = (uint32_t)p->data; uint32_t address = (uint32_t)p->data;
uint16_t *val; uint16_t *val;
@ -304,8 +304,8 @@ int cmsDrawMenuEntry(displayPort_t *pDisplay, OSD_Entry *p, uint8_t row, bool dr
} }
CLR_PRINTVALUE(p); CLR_PRINTVALUE(p);
} }
#endif
break; break;
#endif
case OME_UINT8: case OME_UINT8:
if (IS_PRINTVALUE(p) && p->data) { if (IS_PRINTVALUE(p) && p->data) {
OSD_UINT8_t *ptr = p->data; OSD_UINT8_t *ptr = p->data;
@ -644,8 +644,8 @@ uint16_t cmsHandleKey(displayPort_t *pDisplay, uint8_t key)
SET_PRINTVALUE(p); SET_PRINTVALUE(p);
} }
break; break;
case OME_VISIBLE:
#ifdef OSD #ifdef OSD
case OME_VISIBLE:
if (p->data) { if (p->data) {
uint32_t address = (uint32_t)p->data; uint32_t address = (uint32_t)p->data;
uint16_t *val; uint16_t *val;
@ -658,8 +658,8 @@ uint16_t cmsHandleKey(displayPort_t *pDisplay, uint8_t key)
*val %= ~VISIBLE_FLAG; *val %= ~VISIBLE_FLAG;
SET_PRINTVALUE(p); SET_PRINTVALUE(p);
} }
#endif
break; break;
#endif
case OME_UINT8: case OME_UINT8:
case OME_FLOAT: case OME_FLOAT:
if (p->data) { if (p->data) {
@ -1018,7 +1018,7 @@ OSD_Entry menuImu[] =
// Should goto flashfs eventually. // Should goto flashfs eventually.
// //
#ifdef USE_FLASHFS #ifdef USE_FLASHFS
void cmsx_EraseFlash(displayPort_t *pDisplay, void *ptr) long cmsx_EraseFlash(displayPort_t *pDisplay, void *ptr)
{ {
UNUSED(ptr); UNUSED(ptr);
@ -1033,6 +1033,8 @@ void cmsx_EraseFlash(displayPort_t *pDisplay, void *ptr)
cmsScreenClear(pDisplay); cmsScreenClear(pDisplay);
cmsScreenResync(pDisplay); // Was max7456RefreshAll(); wedges during heavy SPI? cmsScreenResync(pDisplay); // Was max7456RefreshAll(); wedges during heavy SPI?
return 0;
} }
#endif // USE_FLASHFS #endif // USE_FLASHFS

View file

@ -266,30 +266,26 @@ void osdDrawSingleElement(uint8_t item)
#endif // VTX #endif // VTX
case OSD_CROSSHAIRS: case OSD_CROSSHAIRS:
{ elemPosX = 14 - 1; // Offset for 1 char to the left
uint8_t *screenBuffer = max7456GetScreenBuffer(); elemPosY = 6;
uint16_t position = 194;
if (maxScreenSize == VIDEO_BUFFER_CHARS_PAL) if (maxScreenSize == VIDEO_BUFFER_CHARS_PAL)
position += 30; ++elemPosY;
buff[0] = SYM_AH_CENTER_LINE;
screenBuffer[position - 1] = (SYM_AH_CENTER_LINE); buff[1] = SYM_AH_CENTER;
screenBuffer[position + 1] = (SYM_AH_CENTER_LINE_RIGHT); buff[2] = SYM_AH_CENTER_LINE_RIGHT;
screenBuffer[position] = (SYM_AH_CENTER); buff[3] = 0;
break;
return;
}
case OSD_ARTIFICIAL_HORIZON: case OSD_ARTIFICIAL_HORIZON:
{ {
uint8_t *screenBuffer = max7456GetScreenBuffer(); elemPosX = 14;
uint16_t position = 194; elemPosY = 6 - 4; // Top center of the AH area
int rollAngle = attitude.values.roll; int rollAngle = attitude.values.roll;
int pitchAngle = attitude.values.pitch; int pitchAngle = attitude.values.pitch;
if (maxScreenSize == VIDEO_BUFFER_CHARS_PAL) if (maxScreenSize == VIDEO_BUFFER_CHARS_PAL)
position += 30; ++elemPosY;
if (pitchAngle > AH_MAX_PITCH) if (pitchAngle > AH_MAX_PITCH)
pitchAngle = AH_MAX_PITCH; pitchAngle = AH_MAX_PITCH;
@ -300,13 +296,15 @@ void osdDrawSingleElement(uint8_t item)
if (rollAngle < -AH_MAX_ROLL) if (rollAngle < -AH_MAX_ROLL)
rollAngle = -AH_MAX_ROLL; rollAngle = -AH_MAX_ROLL;
for (uint8_t x = 0; x <= 8; x++) { // Convert pitchAngle to y compensation value
int y = (rollAngle * (4 - x)) / 64; pitchAngle = (pitchAngle / 8) - 41; // 41 = 4 * 9 + 5
y -= pitchAngle / 8;
y += 41; for (int8_t x = -4; x <= 4; x++) {
int y = (rollAngle * x) / 64;
y -= pitchAngle;
// y += 41; // == 4 * 9 + 5
if (y >= 0 && y <= 81) { if (y >= 0 && y <= 81) {
uint16_t pos = position - 7 + LINE * (y / 9) + 3 - 4 * LINE + x; max7456WriteChar(elemPosX + x, elemPosY + (y / 9), (SYM_AH_BAR9_0 + (y % 9)));
screenBuffer[pos] = (SYM_AH_BAR9_0 + (y % 9));
} }
} }
@ -317,23 +315,23 @@ void osdDrawSingleElement(uint8_t item)
case OSD_HORIZON_SIDEBARS: case OSD_HORIZON_SIDEBARS:
{ {
uint8_t *screenBuffer = max7456GetScreenBuffer(); elemPosX = 14;
uint16_t position = 194; elemPosY = 6;
if (maxScreenSize == VIDEO_BUFFER_CHARS_PAL) if (maxScreenSize == VIDEO_BUFFER_CHARS_PAL)
position += 30; ++elemPosY;
// Draw AH sides // Draw AH sides
int8_t hudwidth = AH_SIDEBAR_WIDTH_POS; int8_t hudwidth = AH_SIDEBAR_WIDTH_POS;
int8_t hudheight = AH_SIDEBAR_HEIGHT_POS; int8_t hudheight = AH_SIDEBAR_HEIGHT_POS;
for (int8_t x = -hudheight; x <= hudheight; x++) { for (int8_t y = -hudheight; y <= hudheight; y++) {
screenBuffer[position - hudwidth + (x * LINE)] = (SYM_AH_DECORATION); max7456WriteChar(elemPosX - hudwidth, elemPosY + y, SYM_AH_DECORATION);
screenBuffer[position + hudwidth + (x * LINE)] = (SYM_AH_DECORATION); max7456WriteChar(elemPosX + hudwidth, elemPosY + y, SYM_AH_DECORATION);
} }
// AH level indicators // AH level indicators
screenBuffer[position - hudwidth + 1] = (SYM_AH_LEFT); max7456WriteChar(elemPosX - hudwidth + 1, elemPosY, SYM_AH_LEFT);
screenBuffer[position + hudwidth - 1] = (SYM_AH_RIGHT); max7456WriteChar(elemPosX + hudwidth - 1, elemPosY, SYM_AH_RIGHT);
return; return;
} }