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

📄 osdm.c

📁 keil C51 LCD 驱动源码,其中还有I2C驱动,ADC驱动,键盘操作等,是一个完整的keil源代码,供大家参考
💻 C
📖 第 1 页 / 共 4 页
字号:
                case NOSIGNAL_MESSAGE:
                case CHECK_SIGNAL_MESSAGE:
                        OsdMsgFrame(1);
                        OsdSetString(OSDM_MESSAGE,OSDM_MESSAGE_ITEM,number,0);
                        PrintString(4,2,GREEN_B+BLACK,DataPointer);
 
                        OsdSetString(OSDM_MESSAGE,OSDM_MESSAGE_ITEM,SPACE_MESSAGE,0);   
                        PrintString(3,2,RED_B,DataPointer);
                        PrintString(5,2,BLUE_B,DataPointer);
                        break;
                case OVER_RANGE_MESSAGE:
                        OsdMsgFrame(2);
                        OsdSetString(OSDM_MESSAGE,OSDM_MESSAGE_MUTIL_ITEM,number,0);    
                        PrintString(4,MIDDLE,WHITE,DataPointer);        
                        OsdSetString(OSDM_MESSAGE,OSDM_MESSAGE_ITEM,number+1,0);        
                        PrintString(5,MIDDLE,WHITE,DataPointer);
                        break;
                case POWER_SAVE_MESSAGE:
                        OsdMsgFrame(3); 
                        OsdSetString(OSDM_MESSAGE,OSDM_MESSAGE_MUTIL_ITEM,number,0);    
                        PrintString(4,MIDDLE,WHITE,DataPointer);        
                        break;
                case FAILSAFE_MESSAGE:
                        OsdClearRow(0,7,14);
                        OsdMsgFrame(4);
                        for (i=1;i<=(FAILSAFE_End_MESSAGE-FAILSAFE_MESSAGE+1);i++)
                        {
                                OsdSetString(OSDM_MESSAGE,OSDM_MESSAGE_MUTIL_ITEM,number+i-1,0);        
                                PrintString(i,2,WHITE,DataPointer);
                        
                        }
                        PrintChar(1,2,_WARN_L,YELLOW);  //algu 1205
                        PrintChar(1,3,_WARN_R,YELLOW);  //algu 1205
                        break; 
                case UNKNOW_MESSAGE:
                        OsdClearRow(0,7,14);
                        OsdMsgFrame(4);

                        OsdSetString(OSDM_MESSAGE,OSDM_MESSAGE_MUTIL_ITEM,UNKNOW_MESSAGE,0);    
                                PrintString(1,2,WHITE,DataPointer);
                        for (i=2;i<=(FAILSAFE_End_MESSAGE-FAILSAFE_MESSAGE+1);i++)
                        {
                                OsdSetString(OSDM_MESSAGE,OSDM_MESSAGE_MUTIL_ITEM,number+i,0);  // FAILSAFE_MESSAGE+i-1 -> UNKNOW_MESSAGE+i -> number+i
                                PrintString(i,2,WHITE,DataPointer);
                        
                        }
                        PrintChar(1,2,_WARN_L,YELLOW);  //algu 1205
                        PrintChar(1,3,_WARN_R,YELLOW);  //algu 1205
                        break; 
                                                        
                default :
                        OsdMsgFrame(0); 
                        OsdSetString(OSDM_MESSAGE,OSDM_MESSAGE_MUTIL_ITEM,number,0);    
                        PrintString(4,MIDDLE,WHITE,DataPointer);
                        break;
        }
#if    ( PANEL_DEFAULT == PANEL_ACER )
        OsdWrite(0xCA,0x51);
#endif
        
        SlvAdr    = OSD_ADDRESS;
        ByteCnt   = 5;
        TrmBuf[0] = 0xCC;
#if    ( PANEL_DEFAULT == PANEL_CHIMEI )
        if ( number == FAILSAFE_MESSAGE || number == UNKNOW_MESSAGE )
        {
                TrmBuf[1] = 0x7A;
                TrmBuf[2] = 0x65;
        }
        else if ( number == NOSIGNAL_MESSAGE || number == CHECK_SIGNAL_MESSAGE )
        {
                TrmBuf[1] = 0x76;
                TrmBuf[2] = 0x62;
        }
        else if ( number == OVER_RANGE_MESSAGE )
        {
                TrmBuf[1] = 0x7C;
                TrmBuf[2] = 0x5E;
        }
        else
        {
                TrmBuf[1] = 0x7C;
                TrmBuf[2] = 0x62;
        }
#elif	( PANEL_DEFAULT == PANEL_ACER )
        if ( number == FAILSAFE_MESSAGE || number == UNKNOW_MESSAGE )
        {
                TrmBuf[1] = 0x35;
                TrmBuf[2] = 0x65;
        }
        else if ( number == NOSIGNAL_MESSAGE || number == CHECK_SIGNAL_MESSAGE )
        {
                TrmBuf[1] = 0x31;
                TrmBuf[2] = 0x62;
        }
        else if ( number == OVER_RANGE_MESSAGE )
        {
                TrmBuf[1] = 0x37;
                TrmBuf[2] = 0x5E;
        }
        else
        {
                TrmBuf[1] = 0x37;
                TrmBuf[2] = 0x62;
        }
#else
        if ( number == FAILSAFE_MESSAGE || number == UNKNOW_MESSAGE )
        {
                TrmBuf[1] = 0x25;
                TrmBuf[2] = 0x65;
        }
        else if ( number == NOSIGNAL_MESSAGE || number == CHECK_SIGNAL_MESSAGE )
        {
                TrmBuf[1] = 0x21;
                TrmBuf[2] = 0x62;
        }
        else if ( number == OVER_RANGE_MESSAGE )
        {
                TrmBuf[1] = 0x27;
                TrmBuf[2] = 0x5E;
        }
        else
        {
                TrmBuf[1] = 0x27;
                TrmBuf[2] = 0x62;
        }
#endif
   
        TrmBuf[3] = 0xEC;
        TrmBuf[4] = 0x1D;
        SendData();

}
/************************************************************************/
void OsdProcessBar(Byte row,Byte color)
{
    Byte  i,j;

    OsdSetAddress(row,5);       //algu
    OsdWrite(OSDAT,color);

    UpdateValue = (Byte)(((CurrentValue-OSDMinValue)*90)/(OSDMaxValue-OSDMinValue));
    if( UpdateValue > 90 )            UpdateValue = 90;
    if( CurrentValue < OSDMinValue )  UpdateValue = 0;

    OsdWrite(OSDDT,_HBarL);                 /* Bar Left */

    j = UpdateValue / 6;
    for( i=0; i<j; i++ )
       OsdWrite(OSDDT,OSDM_BAR_H[6]);       /* Full part */

    j = UpdateValue % 6;                    /* check partial part */
    if( j!=0 )
    {
       i++;
       OsdWrite(OSDDT,OSDM_BAR_H[j]);       /* Partial part */
    }

    for( ; i<15; i++ )
       OsdWrite(OSDDT,OSDM_BAR_H[0]);       /* Empty part */

    OsdWrite(OSDDT,_HBarR);                 /* Bar Right */

}
/************************************************************************/
/************************************************************************/
void OsdDisplayValue(Byte row,Byte color, Bool sign )
{
    Byte i;
    Word IDATA odvwval;

    OsdClearRow(row,row,0x1A);
    odvwval = CurrentValue;                 /* save CurrentValue */
    if( CurrentValue >= 0x8000 )            /* abs( CurrentValue ) */
        CurrentValue = (~CurrentValue) + 1;
    for(i=0; i<4; i++)
    {
       UpdateValue  = CurrentValue % 10;
       CurrentValue = CurrentValue / 10;
       TrmBuf[10+i] = OSDM_DEC_TABLE[UpdateValue];
    }

    CurrentValue = odvwval;                 /* restore CurrentValue */
    UpdateValue = 4;
    if( sign && CurrentValue!=0 )
    {
       if(CurrentValue & 0x8000)  TrmBuf[UpdateValue++] = _MINUS;
       else                       TrmBuf[UpdateValue++] = _PLUS;
    }

    sign = 1;
    for(i=0; i<4; i++)
    {
       if( sign )   /* remove heading Zero */
       {
          if( TrmBuf[13-i] != _0 )
          {
             sign = 0;   /* change flag */
             TrmBuf[UpdateValue++] = TrmBuf[13-i];
          }
       }
       else
       {
          TrmBuf[UpdateValue++] = TrmBuf[13-i];
       }
    }
    if( sign )   /* all ZEROs, display one zero */
    {
       TrmBuf[UpdateValue++] = _0;
    }
    OsdWrite(OSDAT, color);    /* set attribute */
    UpdateValue -= 4;
    OsdSetAddress(row,(26-UpdateValue)/2);
    SlvAdr    = OSD_ADDRESS;
    ByteCnt   = UpdateValue + 1;
    TrmBuf[0] = OSDDT;
    for(i=1; i<=UpdateValue; i++)
       TrmBuf[i] = TrmBuf[3+i];
    SendData();
}
/***************************************************************************
* Function  : OsdEnable( Bool flag )
* Purpose   : Enable(1) , Disable(0) osd display
***************************************************************************/
void OsdEnable(Bool flag)
{
    SlvAdr    = OSD_ADDRESS;
    ByteCnt   = 2;
    TrmBuf[0] = 0xCF;
    if( flag )  TrmBuf[1] = 0x1D;  // Set enable bit.
    else        TrmBuf[1] = 0x1C;  // Set disable bit.
    SendData();
#if (INTERNALOSD)       //algu 1204
    SlvAdr    = ZURAC_ADDRESS;
    SendData();
#endif    

}
/***************************************************************************
* Function  : OsdClearAll
* Purpose   : Clear osd display,attribute and control registers.
***************************************************************************/
void OsdClearAll(void)
{
    Byte i;

#if (INTERNALOSD)       //algu 1204
    /* initialize Trumpion OSD T8570 */
    OsdWrite(0xC1,0x08);           /* 0xC1 */
    OsdWrite(0xC2,0x00);           /* 0xC2 */
    OsdWrite(0xC3,0xA0);           /* 0xC3 */
    OsdWrite(0xC4,0x00);           /* 0xC4 */
    OsdWrite(0xC5,0x00);           /* 0xC5 */
    OsdWrite(0xC6,0x00);           /* 0xC6 */
    OsdWrite(0xC7,0x00);           /* 0xC7 */
    OsdWrite(0xC8,0x00);           /* 0xC8 */
    OsdWrite(0xC9,0x00);           /* 0xC9 */
#if    ( PANEL_DEFAULT == PANEL_ACER )
    OsdWrite(0xCA,0x91);           /* 0xCA */
#else
    OsdWrite(0xCA,0x51);           /* 0xCA */
#endif
    OsdWrite(0xCB,0x20);           /* 0xCB */
    OsdWrite(0xCC,OSDHorPosition*2); /* 0xCC */         //algu +72//Bill
    OsdWrite(0xCD,OSDVerPosition*2+1); /* 0xCD */
    OsdWrite(0xCE,0xCC);           /* 0xCE */
    OsdWrite(0xCF,0x1C);           /* 0xCF */
    
    //initial internal osd
#if    ( PANEL_DEFAULT == PANEL_ACER )
    ZuracWriteByte(0xCA,0x91);           /* 0xCA */
#else
    ZuracWriteByte(0xCA,0x51);           /* 0xCA */
#endif
    ZuracWriteByte(0xCB,0x20);           /* 0xCB */
    ZuracWriteByte(0xCC,OSDHorPosition); /* 0xCC */     //algu +72//Bill
    ZuracWriteByte(0xCD,OSDVerPosition); /* 0xCD */
    ZuracWriteByte(0xCE,0xCC);           /* 0xCE */
    ZuracWriteByte(0xCF,0x1C);           /* 0xCF */

#else
    /* initialize Trumpion OSD T8570 */
    OsdWrite(0xC1,0x08);           /* 0xC1 */
    OsdWrite(0xC2,0x00);           /* 0xC2 */
    OsdWrite(0xC3,0xA0);           /* 0xC3 */
    OsdWrite(0xC4,0x00);           /* 0xC4 */
    OsdWrite(0xC5,0x00);           /* 0xC5 */
    OsdWrite(0xC6,0x00);           /* 0xC6 */
    OsdWrite(0xC7,0x00);           /* 0xC7 */
    OsdWrite(0xC8,0x00);           /* 0xC8 */
    OsdWrite(0xC9,0x00);           /* 0xC9 */
    OsdWrite(0xCA,0x51);           /* 0xCA */
    OsdWrite(0xCB,0x20);           /* 0xCB */
    OsdWrite(0xCC,OSDHorPosition); /* 0xCC */           //algu +72//Bill
    OsdWrite(0xCD,OSDVerPosition); /* 0xCD */
    OsdWrite(0xCE,0xCC);           /* 0xCE */
    OsdWrite(0xCF,0x1C);           /* 0xCF */
#endif    
    
#if STD_T8570
    OsdWrite(0xE2,0xCF);         /* set graphic start */
#else
    OsdWrite(0xE2,0xE4);         /* set graphic start */
#endif

//    for( i=0; i<16; i++ )  TrmBuf[i] = __;
//    for( i=0; i<16; i++ )
//    {
    // if( i!=15 )
    //    OsdSetRowAttr(i,0x00,0x14);   /* set row attribute */
    // else
    //    OsdSetRowAttr(i,0x00,0x15);   /* set row attribute,EOD */
//       if( i!=15 )
//       if( i!=8 )             //algu 1113
//          OsdSetRowAttr(i,0x04,0x14);   /* set row attribute */
 //      else
 //         OsdSetRowAttr(i,0x04,0x15);   /* set row attribute,EOD */

//       OsdWrite(OSDAT, 0x00);           /* set attribute */
//       OsdSetAddress(i, 0);             /* set starting address */
//       TrmBuf[0] = OSDDT;
//       TrmBuf[1] = __;
 //      SlvAdr    = OSD_ADDRESS;
//       ByteCnt   = 16;
//       SendData();
//       SendData();
//     }
     OsdClearRow(0,15,14);      //algu 1204

#if (INTERNALOSD)       //algu 1204

    InternalOsdClearRow(0,15,14);
#endif    

    for( i=1; i<=6; i++ )   /* disable window */
       OsdDisableWindow( i );
}
/************************************************************************
 * Function    : OsdClearRow                                            *
 * Description : clear row                                              *                 *
 * Input       : startRow -                                             *
 *               endRow -                                               *
 * Output      : none                                                   *
 ************************************************************************/
void OsdClearRow( Byte start,Byte end,Byte attr)
{
    Byte i;

    for( i=0; i<16; i++ )
       TrmBuf[i] = __;
    for( i=start; i<=end; i++ )
    {
       if (i!=8)                //algu 1204
                OsdSetRowAttr(i,0x04,0x14);
       else
                OsdSetRowAttr(i,0x04,0x15);             //set EOD
       OsdWrite(OSDAT, attr);      /* set attribute */
       OsdSetAddress(i, 0);        /* set starting address */
       TrmBuf[0] = OSDDT;
       TrmBuf[1] = __;
       SlvAdr  = OSD_ADDRESS;
       ByteCnt = 16;
       SendData();
       SendData();
       ByteCnt =2;      //algu 1128
       SendData();      //algu 1128
    }
    

⌨️ 快捷键说明

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