Rev 335 | Rev 339 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 335 | Rev 336 | ||
---|---|---|---|
Line 513... | Line 513... | ||
513 | char* directions[8] = {"NE", "E ", "SE", "S ", "SW", "W ", "NW", "N "}; |
513 | char* directions[8] = {"NE", "E ", "SE", "S ", "SW", "W ", "NW", "N "}; |
514 | char arrowdir[8] = { 218, 217, 224, 223, 222, 221, 220, 219}; |
514 | char arrowdir[8] = { 218, 217, 224, 223, 222, 221, 220, 219}; |
Line 515... | Line 515... | ||
515 | 515 | ||
516 | while (1) { |
516 | while (1) { |
517 | // write icons at init or after menu/mode-switch |
517 | // write icons at init or after menu/mode-switch |
518 | if (!(COSD_FLAGS & COSD_ICONS_WRITTEN)) { |
518 | if (!(COSD_FLAGS & COSD_ICONS_WRITTEN) && !(COSD_FLAGS & COSD_FLAG_NOOSD)) { |
519 | write_char_xy(5, top_line, 203); // km/h |
519 | write_char_xy(5, top_line, 203); // km/h |
520 | write_char_xy(10, top_line, 202); // RC-transmitter |
520 | write_char_xy(10, top_line, 202); // RC-transmitter |
521 | write_char_xy(16, top_line, 208); // degree symbol |
521 | write_char_xy(16, top_line, 208); // degree symbol |
522 | write_char_xy(27, top_line, 204); // small meters m |
522 | write_char_xy(27, top_line, 204); // small meters m |
Line 526... | Line 526... | ||
526 | write_char_xy(26, bottom_line, 200); // sat1 |
526 | write_char_xy(26, bottom_line, 200); // sat1 |
527 | write_char_xy(27, bottom_line, 201); // sat2 |
527 | write_char_xy(27, bottom_line, 201); // sat2 |
528 | COSD_FLAGS |= COSD_ICONS_WRITTEN; |
528 | COSD_FLAGS |= COSD_ICONS_WRITTEN; |
529 | } |
529 | } |
530 | if (rxd_buffer_locked) { |
530 | if (rxd_buffer_locked) { |
- | 531 | if (!(COSD_FLAGS & COSD_FLAG_NOOSD)) { |
|
531 | if (rxd_buffer[2] == 'D') { // FC Data |
532 | if (rxd_buffer[2] == 'D') { // FC Data |
532 | /*Decode64(); |
533 | /*Decode64(); |
533 | debugData = *((DebugOut_t*) pRxData); |
534 | debugData = *((DebugOut_t*) pRxData); |
534 | write_number_s(12, 2, RxDataLen); |
535 | write_number_s(12, 2, RxDataLen); |
535 | write_number_s(20, 2, setsReceived++); |
536 | write_number_s(20, 2, setsReceived++); |
536 | write_number_s(12, 3, debugData.Analog[0]); // AngleNick |
537 | write_number_s(12, 3, debugData.Analog[0]); // AngleNick |
537 | write_number_s(12, 4, debugData.Analog[1]); // AngleRoll |
538 | write_number_s(12, 4, debugData.Analog[1]); // AngleRoll |
538 | write_number_s(12, 5, debugData.Analog[5]); // Height |
539 | write_number_s(12, 5, debugData.Analog[5]); // Height |
539 | write_number_s(12, 6, debugData.Analog[9]); // Voltage |
540 | write_number_s(12, 6, debugData.Analog[9]); // Voltage |
540 | write_number_s(12, 7, debugData.Analog[10]);// RC Signal |
541 | write_number_s(12, 7, debugData.Analog[10]);// RC Signal |
541 | write_number_s(12, 8, debugData.Analog[11]);// Gyro compass*/ |
542 | write_number_s(12, 8, debugData.Analog[11]);// Gyro compass*/ |
542 | } else if (rxd_buffer[2] == 'O') { // NC OSD Data |
543 | } else if (rxd_buffer[2] == 'O') { // NC OSD Data |
543 | Decode64(); |
544 | Decode64(); |
544 | naviData = *((NaviData_t*) pRxData); |
545 | naviData = *((NaviData_t*) pRxData); |
545 | 546 | ||
546 | // first line |
547 | // first line |
547 | write_3digit_number_u(2, top_line, (uint16_t)(((uint32_t)naviData.GroundSpeed*36)/1000)); |
548 | write_3digit_number_u(2, top_line, (uint16_t)(((uint32_t)naviData.GroundSpeed*36)/1000)); |
548 | 549 | ||
549 | write_3digit_number_u(7, top_line, naviData.RC_Quality); |
550 | write_3digit_number_u(7, top_line, naviData.RC_Quality); |
550 | if (naviData.RC_Quality <= RCLVL_WRN && last_RC_Quality > RCLVL_WRN) { |
551 | if (naviData.RC_Quality <= RCLVL_WRN && last_RC_Quality > RCLVL_WRN) { |
551 | for (uint8_t x = 0; x < 4; x++) |
552 | for (uint8_t x = 0; x < 4; x++) |
552 | write_char_att_xy(7 + x, top_line, BLINK); |
553 | write_char_att_xy(7 + x, top_line, BLINK); |
553 | } else if (naviData.RC_Quality > RCLVL_WRN && last_RC_Quality <= RCLVL_WRN) { |
554 | } else if (naviData.RC_Quality > RCLVL_WRN && last_RC_Quality <= RCLVL_WRN) { |
554 | for (uint8_t x = 0; x < 4; x++) |
555 | for (uint8_t x = 0; x < 4; x++) |
555 | write_char_att_xy(7 + x, top_line, 0); |
556 | write_char_att_xy(7 + x, top_line, 0); |
556 | } |
557 | } |
557 | last_RC_Quality = naviData.RC_Quality; |
558 | last_RC_Quality = naviData.RC_Quality; |
558 | 559 | ||
559 | write_3digit_number_u(13, top_line, naviData.CompassHeading); |
560 | write_3digit_number_u(13, top_line, naviData.CompassHeading); |
560 | 561 | ||
561 | write_ascii_string(17, top_line, directions[heading_conv(naviData.CompassHeading)]); |
562 | write_ascii_string(17, top_line, directions[heading_conv(naviData.CompassHeading)]); |
562 | 563 | ||
563 | if (naviData.Variometer == 0) { |
564 | if (naviData.Variometer == 0) { |
564 | write_char_xy(20, top_line, 206); // plain line |
565 | write_char_xy(20, top_line, 206); // plain line |
565 | } else if (naviData.Variometer > 0 && naviData.Variometer <= 10) { |
566 | } else if (naviData.Variometer > 0 && naviData.Variometer <= 10) { |
566 | write_char_xy(20, top_line, 234); // small arrow up |
567 | write_char_xy(20, top_line, 234); // small arrow up |
567 | } else if (naviData.Variometer > 10) { |
568 | } else if (naviData.Variometer > 10) { |
568 | write_char_xy(20, top_line, 235); // big arrow up |
569 | write_char_xy(20, top_line, 235); // big arrow up |
569 | } else if (naviData.Variometer < 0 && naviData.Variometer >= -10) { |
570 | } else if (naviData.Variometer < 0 && naviData.Variometer >= -10) { |
570 | write_char_xy(20, top_line, 232); // small arrow down |
571 | write_char_xy(20, top_line, 232); // small arrow down |
571 | } else { |
572 | } else { |
572 | write_char_xy(20, top_line, 233); //big arrow down |
573 | write_char_xy(20, top_line, 233); //big arrow down |
573 | } |
574 | } |
Line 574... | Line 575... | ||
574 | 575 | ||
575 | // TODO: is this really dm? |
576 | // TODO: is this really dm? |
576 | //note:lephisto:according to several sources it's /30 |
577 | //note:lephisto:according to several sources it's /30 |
- | 578 | //write_number_s(22, top_line, naviData.Altimeter/30); |
|
- | 579 | if (naviData.Altimeter > 300) { |
|
- | 580 | // above 10m only write full meters |
|
- | 581 | write_number_s(22, top_line, naviData.Altimeter/30); |
|
- | 582 | } else { |
|
- | 583 | // up to 10m write meters.dm |
|
- | 584 | write_number_u_10th(21, top_line, naviData.Altimeter/3); |
|
577 | write_number_s(22, top_line, naviData.Altimeter/30); |
585 | } |
578 | 586 | ||
579 | // seccond line |
587 | // seccond line |
580 | draw_compass(11, top_line + 1, naviData.CompassHeading); |
588 | draw_compass(11, top_line + 1, naviData.CompassHeading); |
581 | 589 | ||
582 | // TODO: verify correctness |
590 | // TODO: verify correctness |
583 | uint16_t heading_home = (naviData.HomePositionDeviation.Bearing + 360 - naviData.CompassHeading) % 360; |
591 | uint16_t heading_home = (naviData.HomePositionDeviation.Bearing + 360 - naviData.CompassHeading) % 360; |
Line 584... | Line 592... | ||
584 | write_char_xy(27, top_line + 1, arrowdir[heading_conv(heading_home)]); |
592 | write_char_xy(27, top_line + 1, arrowdir[heading_conv(heading_home)]); |
- | 593 | ||
- | 594 | ||
- | 595 | write_number_s(22, top_line + 1, naviData.HomePositionDeviation.Distance/100); |
|
- | 596 | ||
- | 597 | // center |
|
- | 598 | if (naviData.MKFlags & FLAG_MOTOR_RUN) { // should be engines running |
|
- | 599 | if (!(old_MKFlags & FLAG_MOTOR_RUN)) { // motors just started, clear middle |
|
- | 600 | clear(); |
|
- | 601 | // update flags to paint display again if needed |
|
- | 602 | COSD_FLAGS &= ~COSD_ICONS_WRITTEN; |
|
- | 603 | } |
|
- | 604 | if (COSD_FLAGS & COSD_FLAG_ARTHORIZON) { |
|
- | 605 | draw_artificial_horizon(top_line + 2, bottom_line - 1, naviData.AngleNick, naviData.AngleRoll); |
|
- | 606 | } |
|
- | 607 | } else { |
|
- | 608 | // stats |
|
- | 609 | write_ascii_string(2, 5, "max Altitude:"); |
|
- | 610 | write_number_s(17, 5, max_Altimeter/30); |
|
- | 611 | write_char_xy(22, 5, 204); // small meters m |
|
- | 612 | write_ascii_string(2, 6, "max Speed :"); |
|
- | 613 | write_3digit_number_u(19, 6, (uint16_t)(((uint32_t)max_GroundSpeed*36)/1000)); |
|
- | 614 | write_char_xy(22, 6, 203); // km/h |
|
- | 615 | write_ascii_string(2, 7, "max Distance:"); |
|
- | 616 | write_number_s(17, 7, max_Distance/100); |
|
- | 617 | write_char_xy(22, 7, 204); // small meters m |
|
- | 618 | write_ascii_string(2, 8, "min voltage :"); |
|
- | 619 | //write_number_s(17, 8, min_UBat/10); |
|
- | 620 | write_number_u_10th(16, 8, min_UBat); |
|
- | 621 | write_ascii_string(22, 8, "V"); // voltage |
|
- | 622 | write_ascii_string(2, 9, "max time :"); |
|
- | 623 | write_time(16, 9, max_FlyingTime); |
|
- | 624 | write_char_xy(22, 9, 210); // fly clock |
|
- | 625 | } |
|
- | 626 | ||
- | 627 | // bottom line |
|
- | 628 | write_number_u_10th(0, bottom_line, naviData.UBat); |
|
- | 629 | if (naviData.UBat <= UBAT_WRN && last_UBat > UBAT_WRN) { |
|
- | 630 | for (uint8_t x = 0; x < 7; x++) |
|
- | 631 | write_char_att_xy(x, bottom_line, BLINK); |
|
- | 632 | } else { |
|
- | 633 | for (uint8_t x = 0; x < 7; x++) |
|
- | 634 | write_char_att_xy(x, bottom_line, 0); |
|
- | 635 | } |
|
- | 636 | ||
- | 637 | write_time(8, bottom_line, uptime); |
|
- | 638 | write_time(16, bottom_line, naviData.FlyingTime); |
|
- | 639 | ||
- | 640 | write_3digit_number_u(23, bottom_line, naviData.SatsInUse); |
|
- | 641 | ||
- | 642 | if (naviData.NCFlags & NC_FLAG_CH) { |
|
- | 643 | write_char_xy(27, bottom_line, 231); // gps ch |
|
- | 644 | } else if (naviData.NCFlags & NC_FLAG_PH) { |
|
- | 645 | write_char_xy(27, bottom_line, 230); // gps ph |
|
- | 646 | } else { // (naviData.NCFlags & NC_FLAG_FREE) |
|
- | 647 | write_char_xy(27, bottom_line, 201); // sat2 (free) |
|
- | 648 | } |
|
Line 585... | Line 649... | ||
585 | 649 | ||
586 | 650 | //write_number_s(8, 5, RxDataLen); |
|
587 | write_number_s(22, top_line + 1, naviData.HomePositionDeviation.Distance/100); |
651 | //write_number_s(16, 5, setsReceived++); |
588 | - | ||
589 | // center |
652 | |
590 | if (naviData.MKFlags & FLAG_MOTOR_RUN) { // should be engines running |
653 | // remember statistics |
591 | if (!(old_MKFlags & FLAG_MOTOR_RUN)) { // motors just started, clear middle |
654 | if (naviData.Altimeter > max_Altimeter) max_Altimeter = naviData.Altimeter; |
592 | clear(); |
- | |
593 | // update flags to paint display again if needed |
- | |
594 | COSD_FLAGS &= ~COSD_ICONS_WRITTEN; |
- | |
595 | } |
- | |
596 | if (COSD_FLAGS & COSD_FLAG_ARTHORIZON) { |
- | |
597 | draw_artificial_horizon(top_line + 2, bottom_line - 1, naviData.AngleNick, naviData.AngleRoll); |
- | |
598 | } |
- | |
599 | } else { |
- | |
600 | // stats |
- | |
601 | write_ascii_string(2, 5, "max Altitude:"); |
- | |
602 | write_number_s(17, 5, max_Altimeter/10); |
- | |
603 | write_char_xy(22, 5, 204); // small meters m |
- | |
604 | write_ascii_string(2, 6, "max Speed :"); |
- | |
605 | write_3digit_number_u(19, 6, (uint16_t)(((uint32_t)max_GroundSpeed*36)/1000)); |
- | |
606 | write_char_xy(22, 6, 203); // km/h |
- | |
607 | write_ascii_string(2, 7, "max Distance:"); |
- | |
608 | write_number_s(17, 7, max_Distance/100); |
- | |
609 | write_char_xy(22, 7, 204); // small meters m |
- | |
610 | write_ascii_string(2, 8, "min voltage :"); |
- | |
611 | //write_number_s(17, 8, min_UBat/10); |
- | |
612 | write_number_u_10th(16, 8, min_UBat); |
- | |
613 | write_ascii_string(22, 8, "V"); // voltage |
- | |
614 | write_ascii_string(2, 9, "max time :"); |
- | |
615 | write_time(16, 9, max_FlyingTime); |
- | |
616 | write_char_xy(22, 9, 210); // fly clock |
- | |
617 | } |
- | |
618 | - | ||
619 | // bottom line |
- | |
620 | write_number_u_10th(0, bottom_line, naviData.UBat); |
- | |
621 | if (naviData.UBat <= UBAT_WRN && last_UBat > UBAT_WRN) { |
- | |
622 | for (uint8_t x = 0; x < 7; x++) |
- | |
623 | write_char_att_xy(x, bottom_line, BLINK); |
- | |
624 | } else { |
- | |
625 | for (uint8_t x = 0; x < 7; x++) |
- | |
626 | write_char_att_xy(x, bottom_line, 0); |
- | |
627 | } |
- | |
628 | - | ||
629 | write_time(8, bottom_line, uptime); |
- | |
630 | write_time(16, bottom_line, naviData.FlyingTime); |
- | |
631 | - | ||
632 | write_3digit_number_u(23, bottom_line, naviData.SatsInUse); |
- | |
633 | - | ||
634 | if (naviData.NCFlags & NC_FLAG_CH) { |
- | |
635 | write_char_xy(27, bottom_line, 231); // gps ch |
- | |
636 | } else if (naviData.NCFlags & NC_FLAG_PH) { |
- | |
637 | write_char_xy(27, bottom_line, 230); // gps ph |
- | |
638 | } else { // (naviData.NCFlags & NC_FLAG_FREE) |
- | |
639 | write_char_xy(27, bottom_line, 201); // sat2 (free) |
- | |
640 | } |
- | |
641 | - | ||
642 | //write_number_s(8, 5, RxDataLen); |
- | |
643 | //write_number_s(16, 5, setsReceived++); |
- | |
644 | - | ||
645 | // remember statistics |
- | |
646 | if (naviData.Altimeter > max_Altimeter) max_Altimeter = naviData.Altimeter; |
- | |
647 | if (naviData.GroundSpeed > max_GroundSpeed) max_GroundSpeed = naviData.GroundSpeed; |
655 | if (naviData.GroundSpeed > max_GroundSpeed) max_GroundSpeed = naviData.GroundSpeed; |
648 | if (naviData.HomePositionDeviation.Distance > max_Distance) { |
656 | if (naviData.HomePositionDeviation.Distance > max_Distance) { |
Line 649... | Line 657... | ||
649 | max_Distance = naviData.HomePositionDeviation.Distance; |
657 | max_Distance = naviData.HomePositionDeviation.Distance; |
650 | } |
658 | } |
- | 659 | if (naviData.UBat < min_UBat) min_UBat = naviData.UBat; |
|
651 | if (naviData.UBat < min_UBat) min_UBat = naviData.UBat; |
660 | if (naviData.FlyingTime > max_FlyingTime) max_FlyingTime = naviData.FlyingTime; |
652 | if (naviData.FlyingTime > max_FlyingTime) max_FlyingTime = naviData.FlyingTime; |
661 | |
653 | 662 | old_MKFlags = naviData.MKFlags; |
|
654 | old_MKFlags = naviData.MKFlags; |
663 | } // (!(COSD_FLAGS & COSD_FLAG_NOOSD)) |
655 | } |
664 | } |