⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lcd_auto.lst

📁 液晶显示器程序代码
💻 LST
📖 第 1 页 / 共 5 页
字号:
1112   2                      //////////////////////////////////////////////
1113   2                      if(0x80 < (start - 2) || 0x80 > start)
1114   2                      {
1115   3                              stMUD.CLOCK = 0x80;
1116   3                              Set_H_Position();
1117   3                              Set_Clock();
1118   3                              ulSum = GetMaxSum(0);
1119   3                              
1120   3                              if(ulCompare < ulSum)
1121   3                              {
1122   4                                      ulCompare = ulSum;
1123   4                                      Result = stMUD.CLOCK;
1124   4                              }
1125   3      
1126   3                              stMUD.CLOCK = start + 1;
1127   3                      }
1128   2                      else
1129   2                      {
1130   3                              stMUD.CLOCK = start;
1131   3                              Set_H_Position();
1132   3                              Set_Clock();
1133   3                              ulSum = GetMaxSum(0);
1134   3                      }
1135   2                      ////////////////////////////////////////////////
1136   2              
1137   2      
1138   2                      while(1)
1139   2                      {
1140   3                              if(ulCompare < ulSum)
1141   3                              {
1142   4                                      ulCompare = ulSum;
1143   4                                      Result = stMUD.CLOCK;
1144   4                              }
1145   3                              if(stMUD.CLOCK == start - 2)
1146   3                                      break;    
1147   3      
1148   3                              stMUD.CLOCK -= 1;
1149   3                              Set_Clock();
1150   3                              Set_H_Position();
1151   3                              ulSum = GetMaxSum(0);        
1152   3                      }
1153   2      
1154   2                      stMUD.CLOCK = Result;
1155   2                      stMUD.PHASE = count;
1156   2                      Set_Clock();
1157   2                      Set_H_Position();
1158   2                      Set_Phase(stMUD.PHASE);
1159   2          }  
C51 COMPILER V7.06   LCD_AUTO                                                              11/21/2005 13:47:25 PAGE 20  

1160   1      
1161   1      
1162   1      
1163   1      #endif
1164   1          return (28 > stMUD.CLOCK) ? ERROR_TOO_BIG : (228 < stMUD.CLOCK) ? ERROR_TOO_SMALL : ERROR_SUCCEED;
1165   1      }
1166          
1167          //------------------------------------------------------------------//
1168          //                          Auto Position                           //
1169          //------------------------------------------------------------------//
1170          unsigned char Auto_Position(void)
1171          {
1172   1          unsigned char   Result, Curr_PosH, Curr_PosV;
1173   1      
1174   1          bAutoInProgress = 1;
1175   1      
1176   1          Curr_PosH   = stMUD.H_POSITION;     // Save current stMUD.H_POSITION
1177   1          Curr_PosV   = stMUD.V_POSITION;     // Save current stMUD.V_POSITION
1178   1      
1179   1          if (ucV_Max_Margin < stMUD.V_POSITION)
1180   1          {
1181   2              stMUD.V_POSITION    = ucV_Max_Margin;
1182   2              Set_V_Position();
1183   2          }
1184   1      
1185   1          RTDCodeW(ADC_DEFAULT);
1186   1      
1187   1          ///////////////////////////////
1188   1          //   Measure  NOISE_MARGIN   //
1189   1          ///////////////////////////////
1190   1          Result  = Min_Noise_Margin();
1191   1      
1192   1          if (ERROR_SUCCEED == (Result & 0x80))
1193   1          {   
1194   2              ///////////////////////////////
1195   2              //    Adjust (H/V)Position   //
1196   2              ///////////////////////////////
1197   2              Result  = Auto_Position_Do(Data[0]);    // Noise margin returned by Min_Noise_Margin() is saved in
             - Data[0];
1198   2          }
1199   1      
1200   1          if (ERROR_SUCCEED == (Result & 0x80))
1201   1          {
1202   2              Save_MUD(ucMode_Curr);
1203   2          }
1204   1          else
1205   1          {
1206   2              stMUD.H_POSITION    = Curr_PosH;
1207   2              stMUD.V_POSITION    = Curr_PosV;
1208   2      
1209   2              Set_H_Position();
1210   2              Set_V_Position();
1211   2          }
1212   1          
1213   1          // Restore ADC Gain/Offset
1214   1          SetADC_GainOffset();
1215   1      
1216   1          bAutoInProgress = 0;
1217   1      
1218   1          return Result;
1219   1      }
1220          
C51 COMPILER V7.06   LCD_AUTO                                                              11/21/2005 13:47:25 PAGE 21  

1221          //------------------------------------------------------------------//
1222          // Return Message => ERROR_SUCCESS   : Success                      //
1223          //                   ERROR_SUCCESS_1 : Vertical Start > Max         //
1224          //                   ERROR_SUCCESS_2 : Vertical Start < Min         //
1225          //                   ERROR_SUCCESS_4 : Vertical Start/End Fail      //
1226          //                   ERROR_SUCCESS_8 : Horizontal Start > Max       //
1227          //                   ERROR_SUCCESS_16: Horizontal Start < Min       //
1228          //                   ERROR_SUCCESS_32: Horizontal Start/End Fail    //
1229          //                   ERROR_INPUT     : 1. IVS or IHS changed        //
1230          //                                     2. underflow or overflow     //
1231          //                   ERROR_TIMEOUT   : Measure Time_Out             //
1232          //                   ERROR_NOTACTIVE : No Avtive Image              //
1233          //------------------------------------------------------------------//
1234          unsigned char Auto_Position_Do(unsigned char NM)
1235          {
1236   1          unsigned char   Result;//,ucTemp,ucTemp1;
1237   1      //      unsigned int    usTemp;
1238   1      
1239   1      /*
1240   1          
1241   1      ///////////////////////////////////////////////////////////
1242   1              stMUD.H_POSITION = 128;
1243   1          
1244   1              if(128 >= stMUD.H_POSITION)
1245   1          {
1246   1          ucTemp = 128 - stMUD.H_POSITION;
1247   1          
1248   1              if(stMUD.CLOCK > 128)
1249   1                 ucTemp1 = 128;
1250   1              else
1251   1                 ucTemp1 = stMUD.CLOCK;
1252   1      
1253   1              ucH_Min_Margin = 128 - ucTemp - (64 - (ucTemp1 >> 1));
1254   1              usIPH_ACT_STA = usIPH_ACT_STA + 50 - ucTemp - (64 - (ucTemp1 >> 1));
1255   1              usTemp = usIPH_ACT_STA;
1256   1      
1257   1              Set_H_Position();
1258   1          }
1259   1      ///////////////////////////////////////////////////////////////////    
1260   1      */
1261   1          Result      = Measure_PositionN(NM);
1262   1      
1263   1          if (ERROR_SUCCEED != (Result & 0x80))   return Result;
1264   1          Result  = ERROR_SUCCEED;
1265   1      
1266   1          /////////////////////////////////
1267   1          // Calculate Vertical Position //
1268   1          /////////////////////////////////
1269   1          NM  = 1;
1270   1          while (1)
1271   1          {
1272   2              if ((usIPV_ACT_STA + ucV_Max_Margin - 128) >= usVer_Start)
1273   2              {
1274   3                  if ((usIPV_ACT_STA + ucV_Min_Margin - 128) <= usVer_Start)
1275   3                  {
1276   4                      stMUD.V_POSITION = (usVer_Start + 128) - usIPV_ACT_STA;
1277   4                      Set_V_Position();
1278   4      
1279   4                      break;  // Success
1280   4                  }
1281   3                  else
1282   3                      Result  |= ERROR_SUCCESS_2;
C51 COMPILER V7.06   LCD_AUTO                                                              11/21/2005 13:47:25 PAGE 22  

1283   3              }
1284   2              else
1285   2                  Result  |= ERROR_SUCCESS_1;
1286   2      
1287   2              // If we can't align upper bound, we try to align lower bound.
1288   2              if (NM && usVer_End > usIPV_ACT_LEN)
1289   2              {
1290   3                  usVer_Start = usVer_End - usIPV_ACT_LEN + 1;
1291   3                  NM          = 0;
1292   3              }
1293   2              else
1294   2              {
1295   3                  Result  |= ERROR_SUCCESS_4;
1296   3                  break;
1297   3              }
1298   2          }
1299   1          
1300   1          ///////////////////////////////////
1301   1          // Calculate Horizontal Position //
1302   1          ///////////////////////////////////
1303   1          NM  = 1;
1304   1          while (1)
1305   1          {
1306   2      #if(ALIGN_LEFT == CLOCK_ALIGN)
1307   2      
1308   2              if ((usIPH_ACT_STA + (stMUD.CLOCK >> 2) + ucH_Max_Margin - 32 - 128) >= usH_Start)
1309   2              {
1310   3      
1311   3                              //if(ucH_Min_Margin  == (128 - 10))
1312   3                  if(ucH_Min_Margin  <= 128 )
1313   3                                ((unsigned int*)Data)[0] = usH_Start + 128 - stMUD.H_POSITION + 50;//((unsigned int*)Data)[0] = usH_S
             -tart + ucTemp + 100;//((unsigned int*)Data)[0] = usH_Start + 10;
1314   3                              else
1315   3                                ((unsigned int*)Data)[0] = usH_Start;// + (stMUD.H_POSITION - 128) + 10;
1316   3      
1317   3                  //if ((usIPH_ACT_STA + (stMUD.CLOCK >> 1) + ucH_Min_Margin - 64 - 128) <= (usH_Start + 50))
1318   3                              if ((usIPH_ACT_STA + (stMUD.CLOCK >> 2) + ucH_Min_Margin - 32 - 128) <= ((unsigned int*)Data)[0])
1319   3                  {
1320   4                      //usH_Start is the actual distance from Hsync to active image
1321   4                          stMUD.H_POSITION    = usH_Start + 128 + 32 - usIPH_ACT_STA - (stMUD.CLOCK >> 2);
1322   4                                      Set_H_Position();
1323   4                      
1324   4                      break;  // Success
1325   4                  }
1326   3                  else
1327   3                      Result  |= ERROR_SUCCESS_16;
1328   3              }
1329   2              else
1330   2                  Result  |= ERROR_SUCCESS_8;
1331   2      
1332   2      
1333   2      #else
                      if ((usIPH_ACT_STA + (stMUD.CLOCK >> 1) + ucH_Max_Margin - 64 - 128) >= usH_Start)
                      {
              
                                      //if(ucH_Min_Margin  == (128 - 10))
                          if(ucH_Min_Margin  <= 128 )
                                        ((unsigned int*)Data)[0] = usH_Start + 128 - stMUD.H_POSITION + 100;//((unsigned int*)Data)[0] = usH_
             -Start + ucTemp + 100;//((unsigned int*)Data)[0] = usH_Start + 10;
                                      else
                                        ((unsigned int*)Data)[0] = usH_Start;// + (stMUD.H_POSITION - 128) + 10;
              
C51 COMPILER V7.06   LCD_AUTO                                                              11/21/2005 13:47:25 PAGE 23  

                          //if ((usIPH_ACT_STA + (stMUD.CLOCK >> 1) + ucH_Min_Margin - 64 - 128) <= (usH_Start + 50))
                                      if ((usIPH_ACT_STA + (stMUD.CLOCK >> 1) + ucH_Min_Margin - 64 - 128) <= ((unsigned int*)Data)[0])
                          {
                              //usH_Start is the actual distance from Hsync to active image
                                  stMUD.H_POSITION    = usH_Start + 128 + 64 - usIPH_ACT_STA - (stMUD.CLOCK >> 1);
                                              Set_H_Position();
                              
                              break;  // Success
                          }
                          else
                              Result  |= ERROR_SUCCESS_16;
                      }
                      else
                          Result  |= ERROR_SUCCESS_8;
              
              #endif
1359   2              // If we can't align upper bound, we try to align lower bound.
1360   2              if (NM && usH_End > usIPH_ACT_WID)
1361   2              {
1362   3                  usH_Start   = usH_End - usIPH_ACT_WID + 1;
1363   3                  NM          = 0;
1364   3              }
1365   2              else
1366   2              {
1367   3                  Result  |= ERROR_SUCCESS_32;
1368   3                  break;
1369   3              }
1370   2          }
1371   1      /*
1372   1      //////////////////////////////////////////////////////////////////////////////
1373   1          if(ucH_Min_Margin == (128 - ucTemp))
1374   1              {
1375   1              if(usTemp != usIPH_ACT_STA)
1376   1                      {
1377   1                         stMUD.H_POSITION = stMUD.H_POSITION - (usTemp - usIPH_ACT_STA);
1378   1                         usIPH_ACT_STA = usTemp - 50 + ucTemp + (64 - (ucTemp1 >> 1));
1379   1                      }
1380   1                      else
1381   1                          usIPH_ACT_STA   = usIPH_ACT_STA - 50 + ucTemp + (64 - (ucTemp1 >> 1));
1382   1      
1383   1                      ucH_Min_Margin  = 128 - 50;   
1384   1                      Set_H_Position();
1385   1              }
1386   1      ////////////////////////////////////////////////////////////////////////////////
1387   1      */
13

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -