的ARM Cortex M3显示器 [英] arm cortex m3 display

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

问题描述

您好我工作的ARM控制器LM3S8962 IM无法理解如下,我的理解是检查code如果字符是从阵列与否,这是他创造了使用ASCII字符{即在而循环:while(!* pcStr = 0)},
我不能够得到什么,他是行之后做了code生成和显示的字符缓冲区PLZ任何人都可以解释这种

 无效
    RIT128x96x4StringDraw(为const char * pcStr,无符号长ULX,
                          无符号长ULY,unsigned char型ucLevel)
    {
        无符号长ulIdx1,ulIdx2;
        unsigned char型ucTemp;        //
        //检查的参数。
        //
        ASSERT(ULX< 128);
        ASSERT((ULX&安培; 1)== 0);
        ASSERT(ULY< 96);
        ASSERT(ucLevel&下; 16);        //
        //设置一个窗口,开始在指定的行和列,结束
        //在显示和8行的右边缘向下(单个字符行)。
        //
        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));        //
        //循环同时有字符串中的多个字符。
        //
        而(* pcStr!= 0)
        {
            //
            //获取当前字符的工作副本,并转换为
            //索引字符位图阵列。
            //
            ucTemp = * pcStr ++放大器; 0x7F的;
            如果(ucTemp&所述;'')
            {
                ucTemp = 0;
            }
            其他
            {
                ucTemp - ='';
            }            //
            //生成并显示的字符缓冲区。
            //
            为(ulIdx1 = 0; ulIdx1 6;; ulIdx1 + = 2)
            {
                //
                //转换的1位字体数据两列到一个单一的数据
                //的4位的字体数据字节列。
                //
                为(ulIdx2 = 0; ulIdx2&下; 8; ulIdx2 ++)
                {
                    g_pucBuffer [ulIdx2] = 0;
                    如果(g_pucFont [ucTemp] [ulIdx1]及(1下;&下; ulIdx2))
                    {
                        g_pucBuffer [ulIdx2] =(ucLevel&下; 4;)及0XF0;
                    }
                    如果((ulIdx1 4;)及&放大器;
                       (g_pucFont [ucTemp] [ulIdx1 + 1]放大器;(1 <<;&下; ulIdx2)))
                    {
                        g_pucBuffer [ulIdx2] | =(ucLevel&所述;℃,)及为0x0F;
                    }
                }                //
                //发送此字节栏显示。
                //
                RITWriteData(g_pucBuffer,8);
                ULX + = 2;                //
                如果显示器的右侧已经达到//返回。
                //
                如果(ULX == 128)
                {
                    返回;
                }
            }
        }
    }


解决方案

他做一些位操作来建立字节。

X | = Y 相同 X = X |是,这使以x的所有的1和也改变了一些0到1如果y在相同的位置具有1

1 LT;&LT;我是从右侧的第i个位置的单个1位的一个字节。

X = Y&安培; 0XF0 将只留下4位的y成X个。

所以,他期待了值的数组,检查这些值的特定位,则填补了从那些位号创建另一个数组。你将不得不为自己制定出细节。

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 |= 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 is a byte with a single 1 bit in the ith position from the right.

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.

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

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