手臂皮质 m3 显示器 [英] arm cortex m3 display

查看:29
本文介绍了手臂皮质 m3 显示器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究手臂控制器 lm3s8962,根据我的理解,我无法理解下面的代码,它正在检查字符是否来自数组,这是他使用 ascii 字符创建的{即在 while 循环中:while(*pcStr != 0) },我无法在构建并显示字符缓冲区"行之后的代码中得到他在做什么,请任何人解释一下

hi i am working on arm controller lm3s8962 i m not able to understand the code below as per my understanding it is checking if the character is from the array or not, which he created using the ascii characters{i.e in the while loop : while(*pcStr != 0) }, i am not able to get what he is doing in the code after the line "Build and display the character buffer" plz can anyone explain this

void
    RIT128x96x4StringDraw(const char *pcStr, unsigned long ulX,
                          unsigned long ulY, unsigned char ucLevel)
    {
        unsigned long ulIdx1, ulIdx2;
        unsigned char ucTemp;

        //
        // Check the arguments.
        //
        ASSERT(ulX < 128);
        ASSERT((ulX & 1) == 0);
        ASSERT(ulY < 96);
        ASSERT(ucLevel < 16);

        //
        // Setup a window starting at the specified column and row, ending
        // at the right edge of the display and 8 rows down (single character row).
        //
        g_pucBuffer[0] = 0x15;
        g_pucBuffer[1] = ulX / 2;
        g_pucBuffer[2] = 63;
        RITWriteCommand(g_pucBuffer, 3);
        g_pucBuffer[0] = 0x75;
        g_pucBuffer[1] = ulY;
        g_pucBuffer[2] = ulY + 7;
        RITWriteCommand(g_pucBuffer, 3);
        RITWriteCommand(g_pucRIT128x96x4VerticalInc,
                        sizeof(g_pucRIT128x96x4VerticalInc));

        //
        // Loop while there are more characters in the string.
        //
        while(*pcStr != 0)
        {
            //
            // Get a working copy of the current character and convert to an
            // index into the character bit-map array.
            //
            ucTemp = *pcStr++ & 0x7f;
            if(ucTemp < ' ')
            {
                ucTemp = 0;
            }
            else
            {
                ucTemp -= ' ';
            }

            //
            // Build and display the character buffer.
            //
            for(ulIdx1 = 0; ulIdx1 < 6; ulIdx1 += 2)
            {
                //
                // Convert two columns of 1-bit font data into a single data
                // byte column of 4-bit font data.
                //
                for(ulIdx2 = 0; ulIdx2 < 8; ulIdx2++)
                {
                    g_pucBuffer[ulIdx2] = 0;
                    if(g_pucFont[ucTemp][ulIdx1] & (1 << ulIdx2))
                    {
                        g_pucBuffer[ulIdx2] = (ucLevel << 4) & 0xf0;
                    }
                    if((ulIdx1 < 4) &&
                       (g_pucFont[ucTemp][ulIdx1 + 1] & (1 << ulIdx2)))
                    {
                        g_pucBuffer[ulIdx2] |= (ucLevel << 0) & 0x0f;
                    }
                }

                //
                // Send this byte column to the display.
                //
                RITWriteData(g_pucBuffer, 8);
                ulX += 2;

                //
                // Return if the right side of the display has been reached.
                //
                if(ulX == 128)
                {
                    return;
                }
            }
        }
    }

推荐答案

他正在做一些位操作来构建字节.

He is doing some bit manipulations to build up bytes.

x |= yx = x | 相同y,它保留 x 中的所有 1,如果 y 在相同位置有 1,也会将一些 0 更改为 1.

x |= y is the same as x = x | y, which keeps all the 1s in x and also changes some of the 0s to 1 if y has a 1 in the same position.

<代码>1 << 是一个字节,从右数第 i 个位置有一个 1 位.

1 << i is a byte with a single 1 bit in the ith position from the right.

x = y &0xf0 只将 y 的左 4 位复制到 x 中.

x = y & 0xf0 copies only the left 4 bits of y into x.

所以他在数组中查找值,检查这些值的特定位,然后用从这些位创建的数字填充另一个数组.你必须自己计算出细节.

So he is looking up values in an array, checking particular bits of those values, then filling up another array with number created from those bits. You will have to work out the particulars for yourself.

这篇关于手臂皮质 m3 显示器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆