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

📄 lcd_auto.lst

📁 液晶显示器程序代码
💻 LST
📖 第 1 页 / 共 5 页
字号:
                  ///////////////////////////////
                  //  Measure (V) Start & End  //
                  ///////////////////////////////
                  ucResult    = Measure_PositionV(NM);
              
                  if (ERROR_SUCCEED != (ucResult & 0x80))
                  {
                      if (ERROR_NOTACTIVE == ucResult)
                      {
                          if (0x80 < stMUD.CLOCK)
                          {
                              stMUD.CLOCK = 0x80;
                              Set_H_Position();
                              Set_Clock();
                          }
                          else
                          {
                              stMUD.CLOCK = 0x80;
                              Set_Clock();
                              Set_H_Position();
                          }
              
                          ucResult    = Measure_PositionV(NM);
                          
                          if (ERROR_SUCCEED != (ucResult & 0x80))     return ucResult;
                      }
                      else
                          return ucResult;
                  }
              
                  NM      = NM + 0x10;    // See Min_Noise_Margin(). Horizontal Measure Result is the same when applying
             - (NM + 0x10)
              
                  count   = 10;
                  do
                  {
                      ///////////////////////////////
                      //  Measure (H) Start & End  //
                      ///////////////////////////////
                      ucResult    = Measure_PositionH(NM);
              
                      if (ERROR_SUCCEED != (ucResult & 0x80))     return ucResult;
                      
                      usH_End = usH_End + 1 - usH_Start;
                        
                      // H_Active Delta
                      if (usH_End < usIPH_ACT_WID)
                          delta = (usIPH_ACT_WID - usH_End > 0x00ff) ? 0xff : (unsigned char)(usIPH_ACT_WID - usH_End);
                      else 
                          delta = (usH_End - usIPH_ACT_WID > 0x00ff) ? 0xff : (unsigned char)(usH_End - usIPH_ACT_WID);
              
                      if (0xc8 < delta)       // The difference is too large to fine-tune.
                      {
                          if (10 == count)
                          {
                              if (0x80 < stMUD.CLOCK)
C51 COMPILER V7.06   LCD_AUTO                                                              11/21/2005 13:47:25 PAGE 11  

                              {
                                  stMUD.CLOCK = 0x80;
                                  Set_H_Position();
                                  Set_Clock();
                              }
                              else
                              {
                                  stMUD.CLOCK = 0x80;
                                  Set_Clock();
                                  Set_H_Position();
                              }
              
                              continue;
                          }
                          else
                              return (usH_End < usIPH_ACT_WID) ? ERROR_TOO_SMALL : ERROR_TOO_BIG;
                      }
                      
                      if (2 >= delta)     break;  // 1023,1024,1025,1026,1027
                      
                      delta   = (delta + (delta >> 2) + 2) & 0xfc;  // 4n number
              #if(ALIGN_LEFT == CLOCK_ALIGN)
                      // Adjust Clock
                      if (usH_End < usIPH_ACT_WID)    // delta < 0, Measure < Active
                      {
                          if ((178 - stMUD.CLOCK) < delta)    return ERROR_TOO_SMALL;
                  
                          stMUD.CLOCK  += delta;
                              
                          Set_Clock();
                          Set_H_Position();
                      }
                      else                            // delta >= 0, Measure >= Active
                      {
                          if ((stMUD.CLOCK - 78) < delta)     return ERROR_TOO_BIG;
                  
                          stMUD.CLOCK -= delta;
                              
                          Set_H_Position();
                          Set_Clock();
                      }   
              
              #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();
                      }   
C51 COMPILER V7.06   LCD_AUTO                                                              11/21/2005 13:47:25 PAGE 12  

              #endif
                  }
                  while (--count);
              
                  if (0 == count)  return ERROR_TIMEOUT;
              
                  stop    = 0;
              
                  while (1)
                  {
                      count   = 0x10;     // Phase 4 ~ 28 step 8 (4,12,20,28)
                      delta   = 0x00;
              
                      while (1)
                      {
                          Set_Phase(count);
                          
                          // Measure usH_Start & usH_End
                          ucResult    = Measure_PositionH(NM);
              
                          if (ERROR_SUCCEED != (ucResult & 0x80))
                          {
                              if (ERROR_NOTACTIVE == ucResult)
                              {
                                  // Input pattern is black/white vertical lines.
                                  if (0x70 == count)
                                  {
                                      Set_Phase(stMUD.PHASE); // Restore phase
                                      break;
                                  }
                                  else
                                  {
                                      count += 0x20;
                                      continue;
                                  }
                              }
              
                              Set_Phase(stMUD.PHASE); // Restore phase
              
                              return ucResult;
                          }
                          
                          usH_End     = usH_End + 1 - usH_Start;
              
                          ucResult    = (usH_End < usIPH_ACT_WID)
                                  ? 0x80 - (unsigned char)(usIPH_ACT_WID - usH_End)
                                  : 0x80 + (unsigned char)(usH_End - usIPH_ACT_WID);
                          
                          if (ucResult > delta)
                          {
                              delta   = ucResult;     // Save the biggest width
                          }
              
                          if (0x70 == count)
                          {
                              Set_Phase(stMUD.PHASE); // Restore phase
                              break;
                          }
              
                          count += 0x20;
                      }
              
C51 COMPILER V7.06   LCD_AUTO                                                              11/21/2005 13:47:25 PAGE 13  

                      if (0x82 < delta)
                      {
                          stMUD.CLOCK -= 4;
              
                          Set_H_Position();
                          Set_Clock();
              
                          stop    = 1;
                      }
                      else if (0x80 > delta)
                      {
                          if (stop && (0x7f == delta))    break; 
              
                          stMUD.CLOCK += 4;
              
                          Set_Clock();
                          Set_H_Position();
              
                          delta   += 3;
              
                          if (stop)   break;
                      }
                      else    
                          break;
                  }
              
              #if (MORE_CLOCK)
                  if (0x84 > delta && 0x7c < delta)
                  {
                      unsigned long   ulTemp0, ulMaxVal;
                      unsigned char   ucPhase, ucDetect;
              
                      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);
              
                      RTDSetByte(DIFF_THRED_7E, 0x50);
                      
                      ulTemp0     = 0;
                      ucDetect    = 0x7b;
                      ucResult    = COLORS_GREEN;
                      ucPhase     = COLORS_GREEN;
                      do
                      {
                          RTDSetByte(MARGIN_B_7D, 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])
C51 COMPILER V7.06   LCD_AUTO                                                              11/21/2005 13:47:25 PAGE 14  

                          {
                              ulTemp0     = ((unsigned long *)Data)[1];
                              ucResult    = ucPhase;
              
                              if (0x10000 < ulTemp0)   break;
                          }
              
                          if (COLORS_GREEN == ucPhase)
                              ucPhase = COLORS_BLUE;
                          else if (COLORS_BLUE == ucPhase)
                              ucPhase = COLORS_RED;
                          else
                          {
                              if (0x10000 <= ulTemp0 || 0x77 == ucDetect)      break;
              
                              ulTemp0     = 0;
                              ucDetect    = 0x77;
                              ucPhase     = COLORS_GREEN;
                              ucResult    = COLORS_GREEN;
              
                              RTDSetByte(DIFF_THRED_7E, 0x70);
                          }
                      }
                      while (1);
                      
                      // Abort if no suitable color is found
                      if (0x8000 > ulTemp0)
                      {
                          return (28 > stMUD.CLOCK) ? ERROR_TOO_BIG : (228 < stMUD.CLOCK) ? ERROR_TOO_SMALL : ERROR_SUCC
             -EED;
                      }
              
                      // Save 4N clock
                      stop    = stMUD.CLOCK;
              
                      if (0x81 > delta)
                      {
                          stMUD.CLOCK = stMUD.CLOCK + 4;
                          Set_Clock();
                          Set_H_Position();
                      }
              

⌨️ 快捷键说明

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