Rev 346 | Rev 355 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 346 | Rev 349 | ||
---|---|---|---|
Line 539... | Line 539... | ||
539 | uint8_t old_MKFlags = 0; |
539 | uint8_t old_MKFlags = 0; |
Line 540... | Line 540... | ||
540 | 540 | ||
541 | char* directions[8] = {"NE", "E ", "SE", "S ", "SW", "W ", "NW", "N "}; |
541 | char* directions[8] = {"NE", "E ", "SE", "S ", "SW", "W ", "NW", "N "}; |
Line -... | Line 542... | ||
- | 542 | char arrowdir[8] = {218, 217, 224, 223, 222, 221, 220, 219}; |
|
- | 543 | ||
- | 544 | /*write_ndigit_number_s_10th(5, 10, 1, 100, 0); |
|
- | 545 | write_ndigit_number_s_10th(5, 11, -1, 100, 0); |
|
542 | char arrowdir[8] = {218, 217, 224, 223, 222, 221, 220, 219}; |
546 | write_ndigit_number_s_10th(5, 12, -11, 100, 0);*/ |
543 | 547 | ||
544 | while (1) { |
548 | while (1) { |
545 | // write icons at init or after menu/mode-switch |
549 | // write icons at init or after menu/mode-switch |
546 | if (!(COSD_FLAGS & COSD_ICONS_WRITTEN) && (COSD_FLAGS & COSD_FLAG_HUD)) { |
550 | if (!(COSD_FLAGS & COSD_ICONS_WRITTEN) && (COSD_FLAGS & COSD_FLAG_HUD)) { |
Line 571... | Line 575... | ||
571 | } else if (rxd_buffer[2] == 'O') { // NC OSD Data |
575 | } else if (rxd_buffer[2] == 'O') { // NC OSD Data |
572 | Decode64(); |
576 | Decode64(); |
573 | naviData = *((NaviData_t*) pRxData); |
577 | naviData = *((NaviData_t*) pRxData); |
Line 574... | Line 578... | ||
574 | 578 | ||
575 | // first line |
579 | // first line |
Line 576... | Line 580... | ||
576 | write_3digit_number_u(2, top_line, (uint16_t) (((uint32_t) naviData.GroundSpeed * 36) / 1000)); |
580 | write_ndigit_number_u(2, top_line, (uint16_t) (((uint32_t) naviData.GroundSpeed * 36) / 1000), 100, 0); |
577 | 581 | ||
578 | write_3digit_number_u(7, top_line, naviData.RC_Quality); |
582 | write_ndigit_number_u(7, top_line, naviData.RC_Quality, 100, 0); |
579 | if (naviData.RC_Quality <= RCLVL_WRN && last_RC_Quality > RCLVL_WRN) { |
583 | if (naviData.RC_Quality <= RCLVL_WRN && last_RC_Quality > RCLVL_WRN) { |
580 | for (uint8_t x = 0; x < 4; x++) |
584 | for (uint8_t x = 0; x < 4; x++) |
581 | write_char_att_xy(7 + x, top_line, BLINK); |
585 | write_char_att_xy(7 + x, top_line, BLINK); |
582 | } else if (naviData.RC_Quality > RCLVL_WRN && last_RC_Quality <= RCLVL_WRN) { |
586 | } else if (naviData.RC_Quality > RCLVL_WRN && last_RC_Quality <= RCLVL_WRN) { |
583 | for (uint8_t x = 0; x < 4; x++) |
587 | for (uint8_t x = 0; x < 4; x++) |
584 | write_char_att_xy(7 + x, top_line, 0); |
588 | write_char_att_xy(7 + x, top_line, 0); |
Line 585... | Line 589... | ||
585 | } |
589 | } |
Line 586... | Line 590... | ||
586 | last_RC_Quality = naviData.RC_Quality; |
590 | last_RC_Quality = naviData.RC_Quality; |
Line 587... | Line 591... | ||
587 | 591 | ||
588 | write_3digit_number_u(13, top_line, naviData.CompassHeading); |
592 | write_ndigit_number_u(13, top_line, naviData.CompassHeading, 100, 0); |
Line 600... | Line 604... | ||
600 | } else { |
604 | } else { |
601 | write_char_xy(20, top_line, 233); //big arrow down |
605 | write_char_xy(20, top_line, 233); //big arrow down |
602 | } |
606 | } |
Line 603... | Line 607... | ||
603 | 607 | ||
604 | //note:lephisto:according to several sources it's /30 |
608 | //note:lephisto:according to several sources it's /30 |
605 | if (naviData.Altimeter > 300) { |
609 | if (naviData.Altimeter > 300 || naviData.Altimeter < -300) { |
606 | // above 10m only write full meters |
610 | // above 10m only write full meters |
607 | write_number_s(22, top_line, naviData.Altimeter / 30); |
611 | write_ndigit_number_s(23, top_line, naviData.Altimeter / 30, 1000, 0); |
608 | } else { |
612 | } else { |
609 | // up to 10m write meters.dm |
613 | // up to 10m write meters.dm |
- | 614 | //write_number_u_10th(21, top_line, naviData.Altimeter / 3); |
|
610 | write_number_u_10th(21, top_line, naviData.Altimeter / 3); |
615 | write_ndigit_number_s_10th(23, top_line, naviData.Altimeter / 3, 100, 0); |
Line 611... | Line 616... | ||
611 | } |
616 | } |
612 | 617 | ||
Line 613... | Line 618... | ||
613 | // seccond line |
618 | // seccond line |
614 | draw_compass(11, top_line + 1, naviData.CompassHeading); |
619 | draw_compass(11, top_line + 1, naviData.CompassHeading); |
615 | 620 | ||
Line 616... | Line 621... | ||
616 | // TODO: verify correctness |
621 | // TODO: verify correctness |
Line 617... | Line 622... | ||
617 | uint16_t heading_home = (naviData.HomePositionDeviation.Bearing + 360 - naviData.CompassHeading) % 360; |
622 | uint16_t heading_home = (naviData.HomePositionDeviation.Bearing + 360 - naviData.CompassHeading) % 360; |
618 | write_char_xy(27, top_line + 1, arrowdir[heading_conv(heading_home)]); |
623 | write_char_xy(27, top_line + 1, arrowdir[heading_conv(heading_home)]); |
619 | 624 | ||
620 | write_number_s(22, top_line + 1, naviData.HomePositionDeviation.Distance / 100); |
625 | write_ndigit_number_u(24, top_line + 1, naviData.HomePositionDeviation.Distance / 100, 100, 0); |
Line 631... | Line 636... | ||
631 | } |
636 | } |
632 | } else { |
637 | } else { |
633 | // stats |
638 | // stats |
634 | if (COSD_FLAGS & COSD_FLAG_STATS) { |
639 | if (COSD_FLAGS & COSD_FLAG_STATS) { |
635 | write_ascii_string_pgm(2, 5, stats_item_pointers[0]); // max Altitude |
640 | write_ascii_string_pgm(2, 5, stats_item_pointers[0]); // max Altitude |
636 | write_number_s(17, 5, max_Altimeter / 30); |
641 | write_ndigit_number_s(18, 5, max_Altimeter / 30, 1000, 0); |
637 | write_char_xy(22, 5, 204); // small meters m |
642 | write_char_xy(22, 5, 204); // small meters m |
638 | write_ascii_string_pgm(2, 6, stats_item_pointers[1]); // max Speed |
643 | write_ascii_string_pgm(2, 6, stats_item_pointers[1]); // max Speed |
639 | write_3digit_number_u(19, 6, (uint16_t) (((uint32_t) max_GroundSpeed * 36) / 1000)); |
644 | write_ndigit_number_u(19, 6, (uint16_t) (((uint32_t) max_GroundSpeed * 36) / 1000), 100, 0); |
640 | write_char_xy(22, 6, 203); // km/h |
645 | write_char_xy(22, 6, 203); // km/h |
641 | write_ascii_string_pgm(2, 7, stats_item_pointers[2]); // max Distance |
646 | write_ascii_string_pgm(2, 7, stats_item_pointers[2]); // max Distance |
642 | write_number_s(17, 7, max_Distance / 100); |
647 | write_ndigit_number_u(19, 7, max_Distance / 100, 100, 0); |
643 | write_char_xy(22, 7, 204); // small meters m |
648 | write_char_xy(22, 7, 204); // small meters m |
644 | write_ascii_string_pgm(2, 8, stats_item_pointers[3]); // min voltage |
649 | write_ascii_string_pgm(2, 8, stats_item_pointers[3]); // min voltage |
645 | write_number_u_10th(16, 8, min_UBat); |
650 | write_ndigit_number_u_10th(18, 8, min_UBat, 100, 0); |
646 | write_ascii_string(22, 8, "V"); // voltage |
651 | write_ascii_string(22, 8, "V"); // voltage |
647 | write_ascii_string_pgm(2, 9, stats_item_pointers[4]); // max time |
652 | write_ascii_string_pgm(2, 9, stats_item_pointers[4]); // max time |
648 | write_time(16, 9, max_FlyingTime); |
653 | write_time(16, 9, max_FlyingTime); |
649 | write_char_xy(22, 9, 210); // fly clock |
654 | write_char_xy(22, 9, 210); // fly clock |
650 | } else if (COSD_FLAGS & COSD_FLAG_ARTHORIZON) { // if no stats there is space horizon |
655 | } else if (COSD_FLAGS & COSD_FLAG_ARTHORIZON) { // if no stats there is space horizon |
651 | draw_artificial_horizon(top_line + 2, bottom_line - 1, naviData.AngleNick, naviData.AngleRoll); |
656 | draw_artificial_horizon(top_line + 2, bottom_line - 1, naviData.AngleNick, naviData.AngleRoll); |
652 | } |
657 | } |
653 | } |
658 | } |
Line 654... | Line 659... | ||
654 | 659 | ||
655 | // bottom line |
660 | // bottom line |
656 | write_number_u_10th(0, bottom_line, naviData.UBat); |
661 | write_ndigit_number_u_10th(2, bottom_line, naviData.UBat, 100, 0); |
657 | if (naviData.UBat <= UBAT_WRN && last_UBat > UBAT_WRN) { |
662 | if (naviData.UBat <= UBAT_WRN && last_UBat > UBAT_WRN) { |
658 | for (uint8_t x = 0; x < 7; x++) |
663 | for (uint8_t x = 0; x < 7; x++) |
659 | write_char_att_xy(x, bottom_line, BLINK); |
664 | write_char_att_xy(x, bottom_line, BLINK); |
660 | } else { |
665 | } else { |
Line 663... | Line 668... | ||
663 | } |
668 | } |
Line 664... | Line 669... | ||
664 | 669 | ||
665 | write_time(8, bottom_line, uptime); |
670 | write_time(8, bottom_line, uptime); |
Line 666... | Line 671... | ||
666 | write_time(16, bottom_line, naviData.FlyingTime); |
671 | write_time(16, bottom_line, naviData.FlyingTime); |
Line 667... | Line 672... | ||
667 | 672 | ||
668 | write_3digit_number_u(23, bottom_line, naviData.SatsInUse); |
673 | write_ndigit_number_u(24, bottom_line, naviData.SatsInUse, 10, 0); |
669 | 674 | ||
670 | if (naviData.NCFlags & NC_FLAG_CH) { |
675 | if (naviData.NCFlags & NC_FLAG_CH) { |