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

📄 osdm.c

📁 keil C51 LCD 驱动源码,其中还有I2C驱动,ADC驱动,键盘操作等,是一个完整的keil源代码,供大家参考
💻 C
📖 第 1 页 / 共 4 页
字号:
//     OsdClearRow(row,row,0x1A);
//     odvwval = CurrentValue;                 /* save CurrentValue */
//     for(i=0; i<5; i++)
//     {
//        UpdateValue  = CurrentValue % 10;
//        CurrentValue = CurrentValue / 10;
//        TrmBuf[10+i] = OSDM_DEC_TABLE[UpdateValue];
//     }
//
//     CurrentValue = odvwval;                 /* restore CurrentValue */
//     for(i=14;i>9 && TrmBuf[i]==_0;i--);
//     if(i==9)
//         i=10;
//     OsdWrite(OSDAT, color);    /* set attribute */
//     OsdSetAddress(row,col);
//     SlvAdr    = OSD_ADDRESS;
//     TrmBuf[0] = OSDDT;
//     ByteCnt   = 1;
//     for(j=1;i>9;j++,i--)
//     {
//        TrmBuf[j] = TrmBuf[i];
//        ByteCnt++;  }
//     SendData();
// }
/************************************************************************/
void OsdShowData(Byte row,Byte col,Byte color)          //algu 1120 modify only show 0~999
{
    Byte i;     //,j;
    Word IDATA odvwval;

    odvwval = CurrentValue;                 /* save CurrentValue */
    for(i=0; i<3; i++)
    {
       UpdateValue  = CurrentValue % 10;
       CurrentValue = CurrentValue / 10;
       TrmBuf[12-i] = OSDM_DEC_TABLE[UpdateValue];
    }

    CurrentValue = odvwval;                 /* restore CurrentValue */
    
    for (i=10;i<12;i++)
    {
        if (TrmBuf[i]==_0)
                TrmBuf[i]=__;
        else
                break;
    }   
        
    OsdWrite(OSDAT, color);    /* set attribute */
    OsdSetAddress(row,col);
    SlvAdr    = OSD_ADDRESS;
    TrmBuf[0] = OSDDT;
    ByteCnt   = 4;
    for (i=1;i<4;i++)
        TrmBuf[i]=TrmBuf[i+9];
    
    SendData();
}

void    OsdShowWindowA()
{
        OsdMenuFrame();
//tonny PrintString(8,1,WHITE,&OSDMENU_MESSAGE[0][0]);
        OsdSetString(OSDMENU0_MESSAGE,0,OSDLanguage,1);   //TONNY
        PrintString(8,0,WHITE,DataPointer);               //TONNY
        OsdColorFont();
}

void    OsdShowWindowB()
{
        OsdMenuFrame();
//tonny PrintString(8,1,WHITE,&OSDMENU_MESSAGE[0][0]);
        OsdSetString(OSDMENU0_MESSAGE,0,OSDLanguage,1);   //TONNY
        PrintString(8,0,WHITE,DataPointer);               //TONNY
        OsdDisableWindow(4);
        FgMenuChange=1;
        OsdHandler();
        OsdWindow( 1, OSDM_WINDOW1 + (OSDPoint * 3));
        FgMenuSelect=1;
        OSDPoint=0;
}

void    OsdClearWinA()
{
        Byte    i;

#if (INTERNALOSD)       //algu 1204
        InternalOsdClearRow(0,8,14);
#endif          
        for( i=0; i<16; i++ )
                TrmBuf[i] = __;
        for(i=1;i<8;i++)
        {
                OsdWrite(OSDAT,0x00);
                OsdSetAddress(i,3);
                TrmBuf[0]=OSDDT;
                TrmBuf[1]=__;
                SlvAdr  = OSD_ADDRESS;
                ByteCnt = 13;
                SendData();
                SendData();
        }
//tonny if(OSDMenuPage!=L0_MENU0)
        if(OSDMenuPage!=L0_MENU6)
        {
                PrintChar(1,25,0x1D,BLACK);
                PrintChar(7,25,0x1E,BLACK);
        }
       
}

void    OsdClearWinB()
{
        Byte    i;

#if (INTERNALOSD)       //algu 1204
//      InternalOsdClearRow(0,8,14);
#endif     
        for( i=0; i<6; i++ )
                TrmBuf[i] = __;
        for(i=1;i<8;i++)
        {
                OsdWrite(OSDAT,0x00);
                OsdSetAddress(i,0);
                TrmBuf[0]=OSDDT;
                TrmBuf[1]=__;
                SlvAdr  = OSD_ADDRESS;
                ByteCnt = 4;
                SendData();
        }

}

void    OsdColorBar(Byte row,Byte col,Byte color)
{
        Byte  i,j;

        OsdSetAddress(row,col);         //algu 1119,col 6->col
        OsdWrite(OSDAT,color);

        UpdateValue = (Byte)(((CurrentValue-OSDMinValue)*60)/(OSDMaxValue-OSDMinValue));
        if( UpdateValue > 60 )            UpdateValue = 60;
        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<10; i++ )
                OsdWrite(OSDDT,OSDM_BAR_H[0]);       /* Empty part */

        OsdWrite(OSDDT,_HBarR);                 /* Bar Right */
//        PrintChar(row,21,__,0x00);
//        PrintChar(row,22,__,0x00);
        OsdShowData(row,col+13,color);
}

void    OutFacMenu()
{
        Byte    a;
        OsdWindow( 1, OSDM_MAIN_WINDOW1 + (OSDPoint * 3));
        OsdDisableWindow(2);
        OsdMenuItem( OSDNumber );
        a=OSDNumber-L0_FAC_MENU0;
        OsdSetString(FACMenuTitle,7,a,0);
        OsdSetRowAttr(1, 0x04, 0x14);
        PrintString(1,MIDDLE,BLUE,DataPointer);
}

/* algu 1120
void    ShowOverRange()
{
        Byte    i,j;
        OsdClearAll();
        OsdWindow( 6, OSDO_WINDOW6);
        if(FgOverRangeType)
        {
                OsdSetString(OSDM_RESOLUTION,TOTAL_MODE_NUMBER,ModeCounter,0);
                PrintString(3, MIDDLE,WHITE,DataPointer);
                OsdSetString(OSDM_MESSAGE,11,9,0); //tonny      //algu 1120 language 1->0
        }
        else
        {
                PrintString(3,10,WHITE,&Test_text1);
                j=CurVFreq/100;
                i=j%100;
                j=j/100;
                if(j!=0)
                        PrintChar(3,14,OSDM_DEC_TABLE[j],WHITE);
                PrintChar(3,15,OSDM_DEC_TABLE[(i/10)],WHITE);
                PrintChar(3,16,OSDM_DEC_TABLE[(i%10)],WHITE);
                j=CurHFreq/100;
                i=j%100;
                j=j/100;
                if(j!=0)
                        PrintChar(3, 9,OSDM_DEC_TABLE[j],WHITE);
                PrintChar(3,10,OSDM_DEC_TABLE[(i/10)],WHITE);
                PrintChar(3,11,OSDM_DEC_TABLE[(i%10)],WHITE);
                OsdSetString(OSDM_MESSAGE,11,5,0);     //tonny          //algu 1120 language 1->0
        }
        PrintString(4, MIDDLE,WHITE,DataPointer);
        if( OSDLanguage == 3 )             //tonny Language = Spanish
        {                                  //tonny Because over 30 words
                OsdSetString(ADD_OVER_RANGE_MESSAGE,0,0,0); //tonny
                PrintString(5, MIDDLE,WHITE,DataPointer);
        }
        OSDNumber = L3_UNKNOWN_MODE;
        OsdOpenUp();
}
*/

#if (INTERNALOSD) //algu 1204

void ZuracOsdLoadFont()
{
    Byte  i,j,ch,cl;
    Byte RDATA * strptr;

    strptr = ZuracOsdFont;           /* sample font address */
    for(i=0; i<INTERNALOSD_FONT; i++)
    {       
//       ZuracWriteByte(0x56,i+1);     /* Font Ram write address */
//       ZuracWriteByte(0x57,0x00);    /* top blank row */
//       ZuracWriteByte(0x58,0x00);
       for(j=0; j<20; j++)           /* 20 data rows */
       {
          ch = *strptr++;
          cl = *strptr++;
          ZuracWriteByte(0x57,cl);   /* low  byte */
          ZuracWriteByte(0x58,ch);   /* high byte */
       }
//       ZuracWriteByte(0x57,0x00);    /* bottom blank row */
//       ZuracWriteByte(0x58,0x00);
    }
    return;
}


/***************************************************************************/
/* void InternalOsdSetRowAttr()                                                    */
/* Function : set internal OSD row attribute                                        */
/***************************************************************************/
void InternalOsdSetRowAttr(Byte row, Byte attr_hi, Byte attr_lo)
{
    SlvAdr    = ZURAC_ADDRESS;
    ByteCnt   = 2;
    if( row < 8 )
    {
       TrmBuf[0] = 0x5B;
       TrmBuf[1] = (row<<5);
    }
    else
    {
       TrmBuf[0] = 0x5C;
       TrmBuf[1] = ((row-8)<<5);
    }
    SendData();
    /* write attribute */
    /* OsdWriteChar(attr_hi, attr_lo); */
    ByteCnt   = 2;
    TrmBuf[0] = OSDAT;
    TrmBuf[1] = attr_lo;
    SendData();

    ByteCnt   = 2;
    TrmBuf[0] = OSDDT;
    TrmBuf[1] = attr_hi;
    SendData();
}

/***************************************************************************/
/* void InternalOsdSetAddress(Byte row, Byte col)                                  */
/* Function : transform (row,col) to internal OSD register address setting        */
/***************************************************************************/
void InternalOsdSetAddress(Byte row, Byte col)
{
    SlvAdr    = ZURAC_ADDRESS;
    ByteCnt   = 2;
    if( row < 8 )
    {
       TrmBuf[0] = 0x5B;
       TrmBuf[1] = (row<<5) + col+1;      /* !!! transform to t8570 column */
    }
    else
    {
       TrmBuf[0] = 0x5C;
       TrmBuf[1] = ((row-8)<<5) + col+1;  /* !!! transform to t8570 column */
    }
    SendData();
}

/***************************************************************************/
/* void IntenalOsdWriteChar(Byte content, Byte attr)                              */
/* Function :  Write 'content' and 'attr' to current internal OSD address           */
/***************************************************************************/
void InternalOsdWriteChar(Byte content, Byte attr)
{
    SlvAdr    = ZURAC_ADDRESS;
    ByteCnt   = 2;
    TrmBuf[0] = OSDAT;
    TrmBuf[1] = attr;
    SendData();

    ByteCnt   = 2;
    TrmBuf[0] = OSDDT;
    TrmBuf[1] = content;
    SendData();
}


/***************************************************************************
* Function   : InternalPrintChar
* Purpose    : Print a character (ch) in position (row,col) on internal OSD
***************************************************************************/
void InternalPrintChar(Byte row,Byte col,Byte ch,Byte color)
{
    InternalOsdSetAddress(row,col);      /* set starting address */
    InternalOsdWriteChar(ch,color);      /* write character and attribute */
}

/************************************************************************
 * Function    : InternalOsdClearRow                                            *
 * Description : clear row                                              *                 *
 * Input       : startRow -                                             *
 *               endRow -                                               *
 * Output      : none                                                   *
 ************************************************************************/
void InternalOsdClearRow( 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)
                InternalOsdSetRowAttr(i,0x20,0x14);
       else
                InternalOsdSetRowAttr(i,0x20,0x15);             //set EOD
       ZuracWriteByte(OSDAT, attr);      /* set attribute */
       InternalOsdSetAddress(i, 0);        /* set starting address */
       TrmBuf[0] = OSDDT;
       TrmBuf[1] = __;
       SlvAdr  = ZURAC_ADDRESS;
       ByteCnt = 16;
       SendData();
       SendData();
       ByteCnt =2;      //algu 1128
       SendData();      //algu 1128
    }

}

#endif

⌨️ 快捷键说明

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