163,6 → 163,15 |
} |
|
/** |
* convert the <heading> gotton from NC into a more |
* precise index |
*/ |
uint8_t heading_fine_conv(uint16_t heading) { |
if (heading > 337) return 0; |
return (heading * 10) / 225; |
} |
|
/** |
* draw a compass rose at <x>/<y> for <heading> |
*/ |
void draw_compass(uint8_t x, uint8_t y, uint16_t heading) { |
181,6 → 190,56 |
} |
|
/* ########################################################################## |
* battery index |
* ##########################################################################*/ |
/** |
* draw a battery symbol at <x>/<y> according to <voltage> |
*/ |
void draw_battery(uint8_t x, uint8_t y, uint16_t voltage) { |
uint8_t percent = (100* (voltage - UBAT_WRN) / (UBAT_MAX - UBAT_WRN)); |
if (percent > 100) percent = 100; |
write_char_xy(x, y, 0x9d - (percent * 13 / 100)); |
//write_ndigit_number_u(x, y-1, percent * 13 / 100, 100, 0); |
} |
|
/** |
* draw variometer arrows at <x>/<y> according to <variometer> |
*/ |
void draw_variometer(uint8_t x, uint8_t y, int16_t variometer) { |
if (variometer == 0) { |
write_char_xy(x, y, 0xbb); // plain line |
} else if (variometer > 0) { // gain height |
switch (variometer / 5){ |
case 0: |
write_char_xy(x, y, 0xba); // smallest arrow up |
break; |
case 1: |
write_char_xy(x, y, 0xb9); // small arrow up |
break; |
case 2: |
write_char_xy(x, y, 0xb8); // large arrow up |
break; |
default: |
write_char_xy(x, y, 0xb7); // largest arrow up |
} |
} else { // sink |
switch (variometer / -5){ |
case 0: |
write_char_xy(x, y, 0xbc); // smallest arrow down |
break; |
case 1: |
write_char_xy(x, y, 0xbd); // small arrow down |
break; |
case 2: |
write_char_xy(x, y, 0xbe); // large arrow down |
break; |
default: |
write_char_xy(x, y, 0xbf); // largest arrow down |
} |
} |
} |
|
/* ########################################################################## |
* artificial horizon |
* ##########################################################################*/ |
// remember last time displayed values |
539,12 → 598,14 |
uint8_t old_MKFlags = 0; |
|
char* directions[8] = {"NE", "E ", "SE", "S ", "SW", "W ", "NW", "N "}; |
char arrowdir[8] = {218, 217, 224, 223, 222, 221, 220, 219}; |
//char arrowdir[8] = {218, 217, 224, 223, 222, 221, 220, 219}; |
|
/*write_ndigit_number_s_10th(5, 10, 1, 100, 0); |
write_ndigit_number_s_10th(5, 11, -1, 100, 0); |
write_ndigit_number_s_10th(5, 12, -11, 100, 0);*/ |
|
//write_ndigit_number_u(2,2, heading_fine_conv(45), 100, 0); |
|
while (1) { |
// write icons at init or after menu/mode-switch |
if (!(COSD_FLAGS & COSD_ICONS_WRITTEN) && (COSD_FLAGS & COSD_FLAG_HUD)) { |
552,7 → 613,7 |
write_char_xy(10, top_line, 202); // RC-transmitter |
write_char_xy(16, top_line, 208); // degree symbol |
write_char_xy(27, top_line, 204); // small meters m |
write_ascii_string(6, bottom_line, "V"); // voltage |
//write_ascii_string(6, bottom_line, "V"); // voltage |
write_char_xy(14, bottom_line, 209); // on clock |
write_char_xy(22, bottom_line, 210); // fly clock |
write_char_xy(26, bottom_line, 200); // sat1 |
592,19 → 653,9 |
write_ndigit_number_u(13, top_line, naviData.CompassHeading, 100, 0); |
|
write_ascii_string(17, top_line, directions[heading_conv(naviData.CompassHeading)]); |
|
draw_variometer(20, top_line, naviData.Variometer); |
|
if (naviData.Variometer == 0) { |
write_char_xy(20, top_line, 206); // plain line |
} else if (naviData.Variometer > 0 && naviData.Variometer <= 10) { |
write_char_xy(20, top_line, 234); // small arrow up |
} else if (naviData.Variometer > 10) { |
write_char_xy(20, top_line, 235); // big arrow up |
} else if (naviData.Variometer < 0 && naviData.Variometer >= -10) { |
write_char_xy(20, top_line, 232); // small arrow down |
} else { |
write_char_xy(20, top_line, 233); //big arrow down |
} |
|
//note:lephisto:according to several sources it's /30 |
if (naviData.Altimeter > 300 || naviData.Altimeter < -300) { |
// above 10m only write full meters |
620,7 → 671,9 |
|
// TODO: verify correctness |
uint16_t heading_home = (naviData.HomePositionDeviation.Bearing + 360 - naviData.CompassHeading) % 360; |
write_char_xy(27, top_line + 1, arrowdir[heading_conv(heading_home)]); |
//write_char_xy(27, top_line + 1, arrowdir[heading_conv(heading_home)]); |
// finer resolution, 0xa0 is first character and we add the index 0 <= index < 16 |
write_char_xy(27, top_line + 1, 0xa0 + heading_fine_conv(heading_home)); |
|
write_ndigit_number_u(24, top_line + 1, naviData.HomePositionDeviation.Distance / 10, 100, 0); |
|
666,6 → 719,7 |
for (uint8_t x = 0; x < 7; x++) |
write_char_att_xy(x, bottom_line, 0); |
} |
draw_battery(6, bottom_line, naviData.UBat); |
|
write_time(8, bottom_line, uptime); |
write_time(16, bottom_line, naviData.FlyingTime); |