📄 lcd_func.lst
字号:
600 void Set_Phase(unsigned char phase)
601 {
602 1 unsigned char ucX_Ctrl, ucY_Ctrl, ucSelect;
603 1
604 1 unsigned long ulRate = (unsigned long)RTD_XTAL * usADC_Clock / usStdHS; // Standard pixel clock in
- kHz
605 1
606 1 #if (MORE_PHASE)
Data[0] = phase & 0x03;
#endif
609 1
610 1 phase = phase & 0x7c;
C51 COMPILER V6.20c LCD_FUNC 04/15/2004 12:59:09 PAGE 11
611 1 ucSelect = phase & 0x3c;
612 1 phase = phase >> 2;
613 1 ucX_Ctrl = (4 >= phase || 29 <= phase) ? 0x80 : (13 <= phase && 21 >= phase) ? 0x80 : 0x00;
614 1 ucY_Ctrl = (12 >= phase || 29 <= phase) ? 0x01 : 0x00;
615 1
616 1 #if (MORE_PHASE)
ucY_Ctrl = ucX_Ctrl | (ucSelect << 1) | ucY_Ctrl | (Data[0] << 1);
#else
619 1 ucY_Ctrl = ucX_Ctrl | (ucSelect << 1) | ucY_Ctrl;
620 1 #endif
621 1
622 1 // Issac :
623 1 // Code below is to select stable HSYNC latch edge.
624 1 // There is about 11.5ns delay between input clock into ADC and output from ADC.
625 1 // Calculating the corresponding phase delay for 11.5ns
626 1 // Original Formula :
627 1 // ucSelect = 32 * 11.5 / (1000000 / ulRate);
628 1
629 1 ucSelect = ulRate * 368 / 1000000;
630 1
631 1 ucSelect = 32 >= ucSelect ? 32 - ucSelect : 64 - ucSelect;
632 1
633 1 // Calculate the absolute value from the selected phase to transition
634 1 ucX_Ctrl = (phase >= ucSelect) ? phase - ucSelect : ucSelect - phase;
635 1
636 1 Data[0] = PROGRAM_HDELAY + (stMUD.H_POSITION - ucH_Min_Margin);
637 1
638 1 // Issac modified
639 1 // Compensate the H position shift due to the phase select
640 1 if (6 < ucSelect)
641 1 {
642 2 ucSelect = (phase + 6) < ucSelect ? Data[0] - 1 : Data[0];
643 2 }
644 1 else
645 1 {
646 2 ucSelect = phase < (ucSelect + 26) ? Data[0] - 1 : Data[0];
647 2 }
648 1
649 1 Wait_For_Event(EVENT_IEN_STOP);
650 1
651 1 // Select a correct edge to latch the stable data
652 1 RTDSetByte(MEAS_HS_LATCH_4E, (6 < ucX_Ctrl && 26 > ucX_Ctrl) ? 0x00 : 0x10);
653 1
654 1 RTDSetByte(IHS_DELAY_8D, ucSelect);
655 1
656 1 RTDSetByte(PLL_PHASE_9F, ucY_Ctrl);
657 1
658 1 Delay_Xms(2);
659 1
660 1 RTDSetByte(STATUS0_01, 0x00); // Clear status
661 1 RTDSetByte(STATUS1_1F, 0x00); // Clear status
662 1 }
663
664
665 //////////////////////////////////////////////////////////////////////////////////////////////////////
666
667
668 void Set_Bright_Contrast(void)
669 {
670 1 // Set RTD's contrast and brightness
671 1 if (100 < stGUD0.CONTRAST) stGUD0.CONTRAST = 50;
672 1 if (100 < stGUD0.RTD_R_CONTRAST) stGUD0.RTD_R_CONTRAST = 50;
C51 COMPILER V6.20c LCD_FUNC 04/15/2004 12:59:09 PAGE 12
673 1 if (100 < stGUD0.RTD_G_CONTRAST) stGUD0.RTD_G_CONTRAST = 50;
674 1 if (100 < stGUD0.RTD_B_CONTRAST) stGUD0.RTD_B_CONTRAST = 50;
675 1
676 1 Data[0] = 9;
677 1 Data[1] = Y_INC;
678 1 Data[2] = BRIGHT_R_5E;
679 1
680 1 if (SOURCE_VGA == (stGUD1.INPUT_SOURCE & 0x07))
681 1 {
682 2 Data[3] = 0x7d;
683 2 Data[4] = 0x7d;
684 2 Data[5] = 0x7d;
685 2 }
686 1 else
687 1 {
688 2 Data[3] = 0x7f;
689 2 Data[4] = 0x7f;
690 2 Data[5] = 0x7f;
691 2 }
692 1
693 1 switch ((stGUD1.INPUT_SOURCE & 0x18) >> 3)
694 1 {
695 2 case 0 :
696 2 Data[13] = stGUD4.C1_G;
697 2 Data[14] = stGUD4.C1_B;
698 2 Data[15] = stGUD4.C1_R;
699 2 break;
700 2 case 1 :
701 2 Data[13] = stGUD4.C2_G;
702 2 Data[14] = stGUD4.C2_B;
703 2 Data[15] = stGUD4.C2_R;
704 2 break;
705 2 case 2 :
706 2 Data[13] = stGUD4.C3_G;
707 2 Data[14] = stGUD4.C3_B;
708 2 Data[15] = stGUD4.C3_R;
709 2 break ;
710 2 default :
711 2 Data[13] = stGUD0.RTD_G_CONTRAST;
712 2 Data[14] = stGUD0.RTD_B_CONTRAST;
713 2 Data[15] = stGUD0.RTD_R_CONTRAST;
714 2 break;
715 2 }
716 1
717 1 #if (ANALOG_CONTRAST)
718 1 // If using the analog gain to adjust contrast, digital gain alway set to 128
719 1 if (SOURCE_VGA == (stGUD1.INPUT_SOURCE & 0x07))
720 1 Data[6] = 0x80;
721 1 else
722 1 Data[6] = (50 >= stGUD0.CONTRAST) ? 78 + stGUD0.CONTRAST : 104 + (stGUD0.CONTRAST >> 1);
723 1 #else
Data[6] = (50 >= stGUD0.CONTRAST) ? 78 + stGUD0.CONTRAST : 104 + (stGUD0.CONTRAST >> 1);
#endif
726 1
727 1 Data[7] = (50 >= Data[13]) ? (unsigned int)Data[6] * (75 + (Data[13] >> 1)) / 100
728 1 : (unsigned int)Data[6] * (88 + (Data[13] >> 2)) / 100;
729 1
730 1 Data[8] = (50 >= Data[14]) ? (unsigned int)Data[6] * (75 + (Data[14] >> 1)) / 100
731 1 : (unsigned int)Data[6] * (88 + (Data[14] >> 2)) / 100;
732 1
733 1 Data[6] = (50 >= Data[15]) ? (unsigned int)Data[6] * (75 + (Data[15] >> 1)) / 100
734 1 : (unsigned int)Data[6] * (88 + (Data[15] >> 2)) / 100;
C51 COMPILER V6.20c LCD_FUNC 04/15/2004 12:59:09 PAGE 13
735 1
736 1 Data[9] = 0;
737 1 RTDWrite(Data);
738 1
739 1 if (100 < stGUD0.BRIGHT) stGUD0.BRIGHT = 50;
740 1
741 1 Data[0] = 6;
742 1 Data[1] = Y_INC;
743 1 Data[2] = OSD_ADDR_MSB_90;
744 1 #if (PWM0 == BRIGHTNESS_PWM) //PWM0 OUTPUT
Data[3] = 0x00;
Data[4] = 0x01;
#elif (PWM1 == BRIGHTNESS_PWM) //PWM1 OUTPUT
Data[3] = 0x40;
Data[4] = 0x01;
#else //PWM2 OUTPUT
751 1 Data[3] = 0x80;
752 1 Data[4] = 0x01;
753 1 #endif
754 1
755 1 #if (INV_BRIGHTNESS)
Data[5] = MIN_BRIGHTNESS + (unsigned int)(MAX_BRIGHTNESS - MIN_BRIGHTNESS) * (100 - stGUD0.BRIGHT) / 1
-00;
#else
758 1 Data[5] = MIN_BRIGHTNESS + (unsigned int)(MAX_BRIGHTNESS - MIN_BRIGHTNESS) * stGUD0.BRIGHT / 100;
759 1 #endif
760 1 Data[6] = 0;
761 1
762 1 RTDWrite(Data);
763 1 }
764
765 void Set_Gamma(void)
766 {
767 1 switch (stGUD1.FUNCTION & 0x60)
768 1 {
769 2 case 0x20 :
770 2 WriteGamma(GAMMA_1, GAMMA_1, GAMMA_1);
771 2 break;
772 2 case 0x40 :
773 2 WriteGamma(GAMMA_2, GAMMA_2, GAMMA_2);
774 2 break;
775 2 case 0x60 :
776 2 WriteGamma(GAMMA_3, GAMMA_3, GAMMA_3);
777 2 break;
778 2 default :
779 2 RTDSetBit(COLOR_CTRL_5D, 0xeb, 0x00); // Disable gamma function and its access channel
780 2 break;
781 2 }
782 1 }
783
784 void Set_Dithering(void)
785 {
786 1 #if (NEW_DITHER)
WriteDither(DITHER_1, 0);
WriteDither(NEW_DITHER_TABLE, 1);
#else
790 1 WriteDither(DITHER_1, 0);
791 1 #endif
792 1
793 1 #if (DISP_BIT == DISP_24BIT)
RTDSetBit(COLOR_CTRL_5D, 0x97, 0x00); // Disable dithering function and its access channel
#endif
C51 COMPILER V6.20c LCD_FUNC 04/15/2004 12:59:09 PAGE 14
796 1 }
797
798 void Sharpness(void)
799 {
800 1 if (MODE_NOSIGNAL != ucMode_Curr && MODE_NOSUPPORT != ucMode_Curr)
801 1 {
802 2 // For RTD2020 rev.B and later
803 2 RTDSetByte(FILTER_CTRL0_1B, 0xc4);
804 2
805 2 switch (stGUD1.FILTER)
806 2 {
807 3 case 0 :
808 3 WriteSU_COEF(SU_COEF_1, SU_COEF_1);
809 3 break;
810 3 case 1 :
811 3 WriteSU_COEF(SU_COEF_2, SU_COEF_2);
812 3 break;
813 3 case 2 :
814 3 if((usIPH_ACT_WID == 1280) && (DISP_SIZE == DISP_1280x1024))
815 3 {
816 4 WriteSU_COEF(SU_COEF_7, SU_COEF_3);
817 4 }
818 3 else
819 3 {
820 4 WriteSU_COEF(SU_COEF_3, SU_COEF_3);
821 4 }
822 3 break;
823 3 case 3 :
824 3 WriteSU_COEF(SU_COEF_4, SU_COEF_4);
825 3 break;
826 3 default :
827 3 WriteSU_COEF(SU_COEF_5, SU_COEF_5);
828 3 break;
829 3 }
830 2
831 2 RTDSetByte(FILTER_CTRL0_1B, 0xc7);
832 2 }
833 1 }
834
835
836 #if (ANALOG_CONTRAST)
837
838 unsigned char Set_Contrast_Gain(unsigned char ContrastValue, unsigned char ColorValue)
839 {
840 1 if (45 <= ContrastValue)
841 1 {
842 2 // Decrease ADC gain
843 2 if (ColorValue & 0x80)
844 2 {
845 3 ColorValue &= 0x7f;
846 3 ColorValue = ColorValue + ContrastValue - 45;
847 3
848 3 if (ColorValue > 0x7f)
849 3 ColorValue = 0xff; //(minus)
850 3 else
851 3 ColorValue |= 0x80; //(minus)
852 3 }
853 2 else
854 2 {
855 3 if (ColorValue > (ContrastValue - 45))
856 3 ColorValue = ColorValue - (ContrastValue - 45);
857 3 else
C51 COMPILER V6.20c LCD_FUNC 04/15/2004 12:59:09 PAGE 15
858 3 ColorValue = 0x80 | (ContrastValue - 45 - ColorValue);
859 3 }
860 2 }
861 1 else
862 1 {
863 2 // Increase ADC gain
864 2 if (ColorValue & 0x80)
865 2 {
866 3 ColorValue &= 0x7f;
867 3
868 3 if ((45 - ContrastValue) > ColorValue)
869 3 ColorValue = 45 - ContrastValue - ColorValue;
870 3 else
871 3 ColorValue = 0x80 | (ColorValue - (45 - ContrastValue));
872 3 }
873 2 else
874 2 ColorValue = ColorValue + (45 - ContrastValue);
875 2 }
876 1
877 1 return ColorValue;
878 1 }
879
880 #endif
881
882 void SetColorGainOffset(unsigned char addr, unsigned char parameter, unsigned char bios)
883 {
884 1 if (bios & 0x80)
885 1 {
886 2 //(minus)
887 2 bios &= 0x7f;
888 2 RTDSetByte(addr, (parameter >= bios) ? parameter - bios : 0);
889 2 }
890 1 else
891 1 {
892 2 //(plus)
893 2 RTDSetByte(addr, (parameter >= (0xff - bios)) ? 0xff : parameter + bios);
894 2 }
895 1 }
896
897
898 void SetADC_Gain(void)
899 {
900 1 unsigned char ucRed, ucGreen, ucBlue;
901 1
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -