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

📄 uilcd.c

📁 基于EP7312的MP3播放器源代码,包括MCU和PC端代码.
💻 C
📖 第 1 页 / 共 5 页
字号:
        ulWidth += ucCharWidth[(unsigned long)cChar];    }    //    // Return the width of the string.    //    return(ulWidth);}//****************************************************************************//// LCDPrintString draws a string on the LCD.////****************************************************************************static voidLCDPrintString(const char *pcString, unsigned long bIsUnicode,               unsigned long ulRepeat, unsigned long ulX, unsigned long ulY,               unsigned long ulEndX, unsigned long ulPreSkip,               const unsigned char *pucPreset, unsigned long ulNumPreBits,               const unsigned char *pucPostset, unsigned long ulNumPostBits){    enum    {        STATE_COPY_PRESET,        STATE_GET_CHAR,        STATE_FINISH_CHAR,        STATE_CLEAR_LINE,        STATE_DISPLAY_COLUMN    };    unsigned long ulState = STATE_COPY_PRESET, ulNext = 0;    unsigned char pucBitmap[11];    unsigned long ulLoop, ulWidth = 0, ulNumBits = ulNumPreBits;    const char *pcStr = pcString;    char cChar = 0;    //    // Loop forever.  We will explicitly return when we are done drawing the    // string.    //    while(1)    {        //        // Determine the current state.        //        switch(ulState)        {            //            // Copy date from the preset bitmap to the LCD.            //            case STATE_COPY_PRESET:            {                //                // If there are preset bits before the string, then copy them                // into the bitmap buffer.                //                if(pucPreset)                {                    //                    // Copy the preset bits into the bitmap buffer.                    //                    for(ulLoop = 0; ulLoop < 11; ulLoop++)                    {                        pucBitmap[ulLoop] = pucPreset[ulLoop];                    }                    //                    // Skip past this column of preset bits.                    //                    pucPreset += 11;                }                else                {                    //                    // Clear the bitmap buffer.                    //                    for(ulLoop = 0; ulLoop < 11; ulLoop++)                    {                        pucBitmap[ulLoop] = 0;                    }                }                //                // See if there are less than 8 bit in the current column.                //                if(ulNumBits < 8)                {                    //                    // We've copied the preset data, so start getting                    // characters from the string.                    //                    ulState = STATE_GET_CHAR;                }                else                {                    //                    // We've copied a full column of preset bits, so decrement                    // the number of preset bits by 8.                    //                    ulNumBits -= 8;                    //                    // Display this column, after which we continue copying                    // preset bits.                    //                    ulState = STATE_DISPLAY_COLUMN;                    ulNext = STATE_COPY_PRESET;                }                //                // We're done with this state.                //                break;            }            //            // Get the next character from the input string.            //            case STATE_GET_CHAR:            {                //                // See if there are any more characters to be displayed.                //                if(!*pcStr)                {                    //                    // See if we should repeat the string when we get to the                    // end.                    //                    if(ulRepeat)                    {                        //                        // Reset the string pointer to the beginning.                        //                        pcStr = pcString;                        //                        // See if we are aligned on a four bit boundary,                        // aligned with the number of prebits.                        //                        if((ulNumBits & 3) != (ulNumPreBits & 3))                        {                            //                            // We are not aligned, so force the alignment.  See                            // if we are before the first boundary.                            //                            if(ulNumBits <= (ulNumPreBits & 3))                            {                                //                                // Move to the first boundary.                                //                                ulNumBits = (ulNumPreBits & 3);                            }                            //                            // See if we are before the second boundary.                            //                            else if(ulNumBits <= ((ulNumPreBits & 3) + 4))                            {                                //                                // Move to the second boundary.                                //                                ulNumBits = (ulNumPreBits & 3) + 4;                            }                            //                            // We are after the second boundary.                            //                            else                            {                                //                                // Move to the third boundary.                                //                                ulNumBits = (ulNumPreBits & 3) + 8;                            }                            //                            // See if the alignment moved past the current                            // column.                            //                            if(ulNumBits >= 8)                            {                                //                                // Decrement the number of bits by eight.                                //                                ulNumBits -= 8;                                //                                // Display this column, after which we again                                // attempt to display the next character.                                //                                ulState = STATE_DISPLAY_COLUMN;                                ulNext = STATE_GET_CHAR;                                //                                // We're done with this state.                                //                                break;                            }                        }                    }                    else                    {                        //                        // See if there are any residual bits from the last                        // character.                        //                        if(ulNumBits > 1)                        {                            //                            // Display this column, after which we clear the                            // remainder of the line.                            //                            ulState = STATE_DISPLAY_COLUMN;                            ulNext = STATE_CLEAR_LINE;                        }                        else                        {                            //                            // Clear the remainder of the line.                            //                            ulState = STATE_CLEAR_LINE;                        }                        //                        // We're done with this state.                        //                        break;                    }                }                //                // See if we are dealing with a Unicode string.                //                if(bIsUnicode)                {                    //                    // See if the second byte of the character is non-zero, or                    // if the first byte is not a valid ASCII character.                    //                    if((pcStr[1] != 0x00) || (pcStr[0] < 0x1f) ||                       (pcStr[0] > '~'))                    {                        //                        // This is an un-representable Unicode character, so                        // simply display an underbar.                        //                        cChar = '_' - 0x1f;                    }                    else                    {                        //                        // This is a valid ASCII character, so display it.                        //                        cChar = *pcStr - 0x1f;                    }                    //                    // Skip past this Unicode character.                    //                    pcStr += 2;                }                else                {                    //                    // Get the next character to be drawn.                    //                    cChar = *pcStr++ - 0x1f;                    if(cChar >= sizeof(ucCharWidth))                    {                        cChar = '_' - 0x1f;                    }                }                //                // Get the width of this character.                //                ulWidth = ucCharWidth[(unsigned long)cChar];                //                // See if we should be skipping bits from the start of the                // string.                //                if(ulPreSkip)                {                    //                    // See if this entire character is to be skipped.                    //                    if(ulPreSkip >= ulWidth)                    {                        //                        // Decrement the count of bits to skip by the width of                        // this character.                        //                        ulPreSkip -= ulWidth;                        //                        // Go to the next character.                        //                        break;                    }                    //                    // Copy the bits for this character into the bitmap buffer,                    // skipping the first ulPreSkip columns.                    //                    for(ulLoop = 0; ulLoop < 11; ulLoop++)                    {                        pucBitmap[ulLoop] |=                            (((ucFont[(unsigned long)cChar][ulLoop] <<                               ulPreSkip) & 0xff) >> ulNumBits);                    }                    //                    // Decrement the number of bits in the buffer by the number                    // of bits skipped.                    //                    ulNumBits -= ulPreSkip;                    //                    // There are no more bits to skip.                    //                    ulPreSkip = 0;                }                else                {                    //                    // Copy the bits for this character into the bitmap buffer.                    //                    for(ulLoop = 0; ulLoop < 11; ulLoop++)                    {                        pucBitmap[ulLoop] |=                            ucFont[(unsigned long)cChar][ulLoop] >> ulNumBits;                    }                }                //                // Increment the bit position by the width of the character.                //                ulNumBits += ulWidth;                //                // If we have filled in all eight columns in the current byte,                // then write it out to the LCD.                //                if(ulNumBits >= 8)                {                    //                    // Decrement the number of bits by eight.                    //                    ulNumBits -= 8;                    //                    // Display this column, after which we copy the remainder                    // of this character into the next column.                    //                    ulState = STATE_DISPLAY_COLUMN;                    ulNext = STATE_FINISH_CHAR;                }                //                // We're done with this state.                //                break;            }            //            // Copy the remainder of the current character into the new column.            //            case STATE_FINISH_CHAR:            {                //                // If there are still bits left, then we need to re-process                // this character to get the right-most portion of it.                //                if(ulNumBits)                {                    //                    // Copy the bits for this character into the bitmap buffer.                    //                    for(ulLoop = 0; ulLoop < 11; ulLoop++)                    {                        pucBitmap[ulLoop] =                            ucFont[(unsigned long)cChar][ulLoop] <<                            (ulWidth - ulNumBits);                    }                }                else                {                    //                    // Clear the bitmap buffer.                    //                    for(ulLoop = 0; ulLoop < 11; ulLoop++)                    {                        pucBitmap[ulLoop] = 0;                    }                }                //                // Process the next character.                //                ulState = STATE_GET_CHAR;                //                // We're done with this state.                //                break;            }

⌨️ 快捷键说明

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