📄 lcd_auto.lst
字号:
ulMaxVal = 0;
delta = 4;
do
{
if (ERROR_SUCCEED != Measure_PositionN(NM)) return ERROR_ABORT;
// Set auto-tracking window
Data[0] = 6;
Data[1] = Y_INC;
Data[2] = H_BND_STA_L_75;
Data[3] = (unsigned char)(usH_Start + MEAS_H_STA_OFFSET - 2);
Data[4] = (unsigned char)(usH_End + MEAS_H_END_OFFSET + 1);
Data[5] = ((unsigned char)((usH_Start + MEAS_H_STA_OFFSET - 2) >> 4) & 0x70) | ((unsigned char
-)((usH_End + MEAS_H_END_OFFSET + 1) >> 8) & 0x0f);
Data[6] = 0;
RTDWrite(Data);
// Select color for auto-phase tracking
RTDSetByte(MARGIN_B_7D, ucResult);
C51 COMPILER V7.06 LCD_AUTO 11/21/2005 13:47:25 PAGE 15
// Set threshold
RTDSetByte(DIFF_THRED_7E, (0x7b == ucDetect) ? 0x50 : 0x70);
ulTemp0 = 0;
ucPhase = 0x00;
do
{
Set_Phase(ucPhase);
RTDSetByte(AUTO_ADJ_CTRL_7F, ucDetect);
Wait_Finish();
if (ERROR_SUCCEED != Data[0]) return Data[0];
Read_Auto_Info(1);
if (ulTemp0 < ((unsigned long *)Data)[1]) ulTemp0 = ((unsigned long *)Data)[1];
ucPhase += 0x10;
}
while (0x80 > ucPhase);
if (ulMaxVal < ulTemp0)
{
ulMaxVal = ulTemp0;
count = stMUD.CLOCK;
}
if (0x00 == delta)
{
if (128 < stMUD.CLOCK)
{
// See if default clock is the best
delta = 0xff;
stMUD.CLOCK = 128;
Set_H_Position();
Set_Clock();
continue;
}
else
break;
}
else if (0xff == delta)
{
break;
}
delta -= 1;
stMUD.CLOCK -= 1;
Set_H_Position();
Set_Clock();
}
while (1);
if (0x7b == ucDetect)
stMUD.CLOCK = ((unsigned long)0x38000 < ulMaxVal) ? count : stop;
else
stMUD.CLOCK = ((unsigned long)0x48000 < ulMaxVal) ? count : stop;
Set_Clock();
Set_H_Position();
C51 COMPILER V7.06 LCD_AUTO 11/21/2005 13:47:25 PAGE 16
Set_Clock();
}
#endif
#else
918 1 unsigned char Result;
919 1 unsigned char count, delta, stop,start;
920 1 unsigned long ulSum,ulCompare;
921 1 ulCompare = 0;
922 1 ulSum = 0;
923 1
924 1 ///////////////////////////////
925 1 // Measure (V) Start & End //
926 1 ///////////////////////////////
927 1 Result = Measure_PositionV(NM);
928 1
929 1 if (ERROR_SUCCEED != (Result & 0x80)) return Result;
930 1
931 1 NM = NM + 0x10; // See Min_Noise_Margin(). Horizontal Measure Result is the same when applying
- (NM + 0x10)
932 1
933 1 count = 10;
934 1 do
935 1 {
936 2
937 2 ///////////////////////////////
938 2 // Measure (H) Start & End //
939 2 ///////////////////////////////
940 2 Result = Measure_PositionH(NM);
941 2
942 2 if (ERROR_SUCCEED != (Result & 0x80)) return Result;
943 2
944 2 usH_End = usH_End + 1 - usH_Start;
945 2
946 2 // H_Active Delta
947 2 if (usH_End < usIPH_ACT_WID)
948 2 delta = (usIPH_ACT_WID - usH_End > 0x00ff) ? 0xff : (unsigned char)(usIPH_ACT_WID - usH_End);
949 2 else
950 2 delta = (usH_End - usIPH_ACT_WID > 0x00ff) ? 0xff : (unsigned char)(usH_End - usIPH_ACT_WID);
951 2
952 2 //if (0xc0 < delta) // The difference is too large to fine-tune.
953 2 if((usIPH_ACT_WID/3) < delta) //modified 2003/02/25
954 2 {
955 3 return (usH_End < usIPH_ACT_WID) ? ERROR_TOO_SMALL : ERROR_TOO_BIG;
956 3 }
957 2
958 2 if (1 >= delta) break; // 1023,1024,1025,1026,1027
959 2
960 2 delta = delta + (delta >> 2);//& 0xfe; // 4n number
961 2
962 2 #if(ALIGN_LEFT == CLOCK_ALIGN)
963 2 // Adjust Clock
964 2 if (usH_End < usIPH_ACT_WID) // delta < 0, Measure < Active
965 2 {
966 3 if ((178 - stMUD.CLOCK) < delta) return ERROR_TOO_SMALL;
967 3
968 3 stMUD.CLOCK += delta;
969 3
970 3 Set_Clock();
971 3 Set_H_Position();
972 3 }
973 2 else // delta >= 0, Measure >= Active
C51 COMPILER V7.06 LCD_AUTO 11/21/2005 13:47:25 PAGE 17
974 2 {
975 3 if ((stMUD.CLOCK - 78) < delta) return ERROR_TOO_BIG;
976 3
977 3 stMUD.CLOCK -= delta;
978 3
979 3 Set_H_Position();
980 3 Set_Clock();
981 3 }
982 2
983 2 #else
// Adjust Clock
if (usH_End < usIPH_ACT_WID) // delta < 0, Measure < Active
{
if ((228 - stMUD.CLOCK) < delta) return ERROR_TOO_SMALL;
stMUD.CLOCK += delta;
Set_Clock();
Set_H_Position();
}
else // delta >= 0, Measure >= Active
{
if ((stMUD.CLOCK - 28) < delta) return ERROR_TOO_BIG;
stMUD.CLOCK -= delta;
Set_H_Position();
Set_Clock();
}
#endif
1005 2 }
1006 1 while (--count);
1007 1
1008 1
1009 1
1010 1 if (0 == count) return ERROR_TIMEOUT;
1011 1
1012 1 stop = 0;
1013 1
1014 1 while (1)
1015 1 {
1016 2 count = 0x10; // Phase 4 ~ 28 step 4 (4,8,12,16,20,24,28)
1017 2 delta = 0xff;
1018 2
1019 2 while (1)
1020 2 {
1021 3
1022 3
1023 3 Set_Phase(count);
1024 3
1025 3 // Measure usH_Start & usH_End
1026 3 Result = Measure_PositionH(NM);
1027 3
1028 3 if (ERROR_SUCCEED != (Result & 0x80))
1029 3 {
1030 4 if (ERROR_NOTACTIVE == Result)
1031 4 {
1032 5 // Input pattern is black/white vertical lines.
1033 5 if (0x70 == count)
1034 5 {
1035 6 Set_Phase(stMUD.PHASE); // Restore phase
C51 COMPILER V7.06 LCD_AUTO 11/21/2005 13:47:25 PAGE 18
1036 6 break;
1037 6 }
1038 5 else
1039 5 {
1040 6 count += 0x20;
1041 6 continue;
1042 6 }
1043 5 }
1044 4
1045 4 Set_Phase(stMUD.PHASE); // Restore phase
1046 4
1047 4 return Result;
1048 4 }
1049 3
1050 3 usH_End = usH_End + 1 - usH_Start;
1051 3
1052 3 Result = (usH_End < usIPH_ACT_WID)
1053 3 ? 0x80 - (unsigned char)(usIPH_ACT_WID - usH_End)
1054 3 : 0x80 + (unsigned char)(usH_End - usIPH_ACT_WID);
1055 3
1056 3 if (Result < delta)
1057 3 {
1058 4 delta = Result; // Save the smallest width
1059 4 }
1060 3
1061 3 if (0x70 == count)
1062 3 {
1063 4 Set_Phase(stMUD.PHASE); // Restore phase
1064 4 break;
1065 4 }
1066 3
1067 3 count += 0x10;
1068 3 }
1069 2
1070 2 if (0x81 < delta)
1071 2 {
1072 3 stMUD.CLOCK -= 1;
1073 3
1074 3 Set_H_Position();
1075 3 Set_Clock();
1076 3
1077 3 stop = 1;
1078 3 }
1079 2 else if (0x80 > delta)
1080 2 {
1081 3 if (stop && (0x7f == delta)) break;
1082 3
1083 3 stMUD.CLOCK += 1;
1084 3
1085 3 Set_Clock();
1086 3 Set_H_Position();
1087 3
1088 3 if (stop) break;
1089 3 }
1090 2 else
1091 2 break;
1092 2 }
1093 1
1094 1 count = stMUD.PHASE; // Record Current Phase
1095 1 start = stMUD.CLOCK ;
1096 1
1097 1
C51 COMPILER V7.06 LCD_AUTO 11/21/2005 13:47:25 PAGE 19
1098 1 if(FindColor() != ERROR_SUCCEED) return ERROR_ABORT;
1099 1 // Set threshold
1100 1 RTDSetByte(DIFF_THRED_7E, 0x30);
1101 1
1102 1 ulSum = GetMaxSum(1); //judge if pulse information large enough
1103 1 ulCompare = GetMaxSum(0);
1104 1
1105 1
1106 1
1107 1 if((ulSum > 460000) || ((ulSum < 460000) && (ulCompare > 2000000)) )
1108 1 {
1109 2
1110 2 ulCompare = 0;
1111 2 // ulSum = 0;//GetMaxSum(0);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -