Rev 373 | Rev 378 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 373 | Rev 377 | ||
---|---|---|---|
Line 161... | Line 161... | ||
161 | //direction = "N "; |
161 | //direction = "N "; |
162 | return 7; |
162 | return 7; |
163 | } |
163 | } |
Line 164... | Line 164... | ||
164 | 164 | ||
- | 165 | /** |
|
- | 166 | * convert the <heading> gotton from NC into a more |
|
- | 167 | * precise index |
|
- | 168 | */ |
|
- | 169 | uint8_t heading_fine_conv(uint16_t heading) { |
|
- | 170 | if (heading > 337) return 0; |
|
- | 171 | return (heading * 10) / 225; |
|
- | 172 | } |
|
- | 173 | ||
165 | /** |
174 | /** |
166 | * draw a compass rose at <x>/<y> for <heading> |
175 | * draw a compass rose at <x>/<y> for <heading> |
167 | */ |
176 | */ |
168 | void draw_compass(uint8_t x, uint8_t y, uint16_t heading) { |
177 | void draw_compass(uint8_t x, uint8_t y, uint16_t heading) { |
169 | //char* rose = "---N---O---S---W---N---O---S---W---N---O---S---W"; |
178 | //char* rose = "---N---O---S---W---N---O---S---W---N---O---S---W"; |
Line 179... | Line 188... | ||
179 | write_char_xy(x++, y, rose[front - 4 + i]); |
188 | write_char_xy(x++, y, rose[front - 4 + i]); |
180 | } |
189 | } |
181 | } |
190 | } |
Line 182... | Line 191... | ||
182 | 191 | ||
- | 192 | /* ########################################################################## |
|
- | 193 | * battery index |
|
- | 194 | * ##########################################################################*/ |
|
- | 195 | /** |
|
- | 196 | * draw a battery symbol at <x>/<y> according to <voltage> |
|
- | 197 | */ |
|
- | 198 | void draw_battery(uint8_t x, uint8_t y, uint16_t voltage) { |
|
- | 199 | uint8_t percent = (100* (voltage - UBAT_WRN) / (UBAT_MAX - UBAT_WRN)); |
|
- | 200 | if (percent > 100) percent = 100; |
|
- | 201 | write_char_xy(x, y, 0x9d - (percent * 13 / 100)); |
|
- | 202 | //write_ndigit_number_u(x, y-1, percent * 13 / 100, 100, 0); |
|
- | 203 | } |
|
- | 204 | ||
- | 205 | /** |
|
- | 206 | * draw variometer arrows at <x>/<y> according to <variometer> |
|
- | 207 | */ |
|
- | 208 | void draw_variometer(uint8_t x, uint8_t y, int16_t variometer) { |
|
- | 209 | if (variometer == 0) { |
|
- | 210 | write_char_xy(x, y, 0xbb); // plain line |
|
- | 211 | } else if (variometer > 0) { // gain height |
|
- | 212 | switch (variometer / 5){ |
|
- | 213 | case 0: |
|
- | 214 | write_char_xy(x, y, 0xba); // smallest arrow up |
|
- | 215 | break; |
|
- | 216 | case 1: |
|
- | 217 | write_char_xy(x, y, 0xb9); // small arrow up |
|
- | 218 | break; |
|
- | 219 | case 2: |
|
- | 220 | write_char_xy(x, y, 0xb8); // large arrow up |
|
- | 221 | break; |
|
- | 222 | default: |
|
- | 223 | write_char_xy(x, y, 0xb7); // largest arrow up |
|
- | 224 | } |
|
- | 225 | } else { // sink |
|
- | 226 | switch (variometer / -5){ |
|
- | 227 | case 0: |
|
- | 228 | write_char_xy(x, y, 0xbc); // smallest arrow down |
|
- | 229 | break; |
|
- | 230 | case 1: |
|
- | 231 | write_char_xy(x, y, 0xbd); // small arrow down |
|
- | 232 | break; |
|
- | 233 | case 2: |
|
- | 234 | write_char_xy(x, y, 0xbe); // large arrow down |
|
- | 235 | break; |
|
- | 236 | default: |
|
- | 237 | write_char_xy(x, y, 0xbf); // largest arrow down |
|
- | 238 | } |
|
- | 239 | } |
|
- | 240 | } |
|
- | 241 | ||
183 | /* ########################################################################## |
242 | /* ########################################################################## |
184 | * artificial horizon |
243 | * artificial horizon |
185 | * ##########################################################################*/ |
244 | * ##########################################################################*/ |
186 | // remember last time displayed values |
245 | // remember last time displayed values |
Line 537... | Line 596... | ||
537 | 596 | ||
538 | // flags from last round to check for changes |
597 | // flags from last round to check for changes |
Line 539... | Line 598... | ||
539 | uint8_t old_MKFlags = 0; |
598 | uint8_t old_MKFlags = 0; |
540 | 599 | ||
Line 541... | Line 600... | ||
541 | char* directions[8] = {"NE", "E ", "SE", "S ", "SW", "W ", "NW", "N "}; |
600 | char* directions[8] = {"NE", "E ", "SE", "S ", "SW", "W ", "NW", "N "}; |
542 | char arrowdir[8] = {218, 217, 224, 223, 222, 221, 220, 219}; |
601 | //char arrowdir[8] = {218, 217, 224, 223, 222, 221, 220, 219}; |
543 | 602 | ||
Line -... | Line 603... | ||
- | 603 | /*write_ndigit_number_s_10th(5, 10, 1, 100, 0); |
|
- | 604 | write_ndigit_number_s_10th(5, 11, -1, 100, 0); |
|
544 | /*write_ndigit_number_s_10th(5, 10, 1, 100, 0); |
605 | write_ndigit_number_s_10th(5, 12, -11, 100, 0);*/ |
545 | write_ndigit_number_s_10th(5, 11, -1, 100, 0); |
606 | |
546 | write_ndigit_number_s_10th(5, 12, -11, 100, 0);*/ |
607 | //write_ndigit_number_u(2,2, heading_fine_conv(45), 100, 0); |
547 | 608 | ||
548 | while (1) { |
609 | while (1) { |
549 | // write icons at init or after menu/mode-switch |
610 | // write icons at init or after menu/mode-switch |
550 | if (!(COSD_FLAGS & COSD_ICONS_WRITTEN) && (COSD_FLAGS & COSD_FLAG_HUD)) { |
611 | if (!(COSD_FLAGS & COSD_ICONS_WRITTEN) && (COSD_FLAGS & COSD_FLAG_HUD)) { |
551 | write_char_xy(5, top_line, 203); // km/h |
612 | write_char_xy(5, top_line, 203); // km/h |
552 | write_char_xy(10, top_line, 202); // RC-transmitter |
613 | write_char_xy(10, top_line, 202); // RC-transmitter |
553 | write_char_xy(16, top_line, 208); // degree symbol |
614 | write_char_xy(16, top_line, 208); // degree symbol |
554 | write_char_xy(27, top_line, 204); // small meters m |
615 | write_char_xy(27, top_line, 204); // small meters m |
555 | write_ascii_string(6, bottom_line, "V"); // voltage |
616 | //write_ascii_string(6, bottom_line, "V"); // voltage |
556 | write_char_xy(14, bottom_line, 209); // on clock |
617 | write_char_xy(14, bottom_line, 209); // on clock |
Line 590... | Line 651... | ||
590 | last_RC_Quality = naviData.RC_Quality; |
651 | last_RC_Quality = naviData.RC_Quality; |
Line 591... | Line 652... | ||
591 | 652 | ||
Line 592... | Line 653... | ||
592 | write_ndigit_number_u(13, top_line, naviData.CompassHeading, 100, 0); |
653 | write_ndigit_number_u(13, top_line, naviData.CompassHeading, 100, 0); |
593 | 654 | ||
594 | write_ascii_string(17, top_line, directions[heading_conv(naviData.CompassHeading)]); |
- | |
595 | - | ||
596 | if (naviData.Variometer == 0) { |
- | |
597 | write_char_xy(20, top_line, 206); // plain line |
- | |
598 | } else if (naviData.Variometer > 0 && naviData.Variometer <= 10) { |
655 | write_ascii_string(17, top_line, directions[heading_conv(naviData.CompassHeading)]); |
599 | write_char_xy(20, top_line, 234); // small arrow up |
- | |
600 | } else if (naviData.Variometer > 10) { |
- | |
601 | write_char_xy(20, top_line, 235); // big arrow up |
- | |
602 | } else if (naviData.Variometer < 0 && naviData.Variometer >= -10) { |
- | |
603 | write_char_xy(20, top_line, 232); // small arrow down |
- | |
604 | } else { |
- | |
Line 605... | Line 656... | ||
605 | write_char_xy(20, top_line, 233); //big arrow down |
656 | |
606 | } |
657 | draw_variometer(20, top_line, naviData.Variometer); |
607 | 658 | ||
608 | //note:lephisto:according to several sources it's /30 |
659 | //note:lephisto:according to several sources it's /30 |
Line 618... | Line 669... | ||
618 | // seccond line |
669 | // seccond line |
619 | draw_compass(11, top_line + 1, naviData.CompassHeading); |
670 | draw_compass(11, top_line + 1, naviData.CompassHeading); |
Line 620... | Line 671... | ||
620 | 671 | ||
621 | // TODO: verify correctness |
672 | // TODO: verify correctness |
622 | uint16_t heading_home = (naviData.HomePositionDeviation.Bearing + 360 - naviData.CompassHeading) % 360; |
673 | uint16_t heading_home = (naviData.HomePositionDeviation.Bearing + 360 - naviData.CompassHeading) % 360; |
- | 674 | //write_char_xy(27, top_line + 1, arrowdir[heading_conv(heading_home)]); |
|
- | 675 | // finer resolution, 0xa0 is first character and we add the index 0 <= index < 16 |
|
Line 623... | Line 676... | ||
623 | write_char_xy(27, top_line + 1, arrowdir[heading_conv(heading_home)]); |
676 | write_char_xy(27, top_line + 1, 0xa0 + heading_fine_conv(heading_home)); |
Line 624... | Line 677... | ||
624 | 677 | ||
625 | write_ndigit_number_u(24, top_line + 1, naviData.HomePositionDeviation.Distance / 10, 100, 0); |
678 | write_ndigit_number_u(24, top_line + 1, naviData.HomePositionDeviation.Distance / 10, 100, 0); |
Line 664... | Line 717... | ||
664 | write_char_att_xy(x, bottom_line, BLINK); |
717 | write_char_att_xy(x, bottom_line, BLINK); |
665 | } else { |
718 | } else { |
666 | for (uint8_t x = 0; x < 7; x++) |
719 | for (uint8_t x = 0; x < 7; x++) |
667 | write_char_att_xy(x, bottom_line, 0); |
720 | write_char_att_xy(x, bottom_line, 0); |
668 | } |
721 | } |
- | 722 | draw_battery(6, bottom_line, naviData.UBat); |
|
Line 669... | Line 723... | ||
669 | 723 | ||
670 | write_time(8, bottom_line, uptime); |
724 | write_time(8, bottom_line, uptime); |
Line 671... | Line 725... | ||
671 | write_time(16, bottom_line, naviData.FlyingTime); |
725 | write_time(16, bottom_line, naviData.FlyingTime); |