-1

こんにちは私はアームコントローラに取り組んでいますlm3s8962im理解できるように、以下のコードを理解できません。文字が配列からのものであるかどうかをチェックしています。彼はASCII文字を使用して作成しました{つまり、whileループで:while(* pcStr!= 0)}、「文字バッファを構築して表示する」行の後のコードで彼が何をしているかを取得できませんplzは誰でもこれを説明できます

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;
                }
            }
        }
    }
4

1 に答える 1

1

彼はバイトを構築するためにいくつかのビット操作を行っています。

x |= yは と同じでx = x | y、x のすべての 1 を保持し、y の同じ位置に 1 がある場合は一部の 0 を 1 に変更します。

1 << i右から i 番目の位置に 1 ビットが 1 つあるバイトです。

x = y & 0xf0y の左 4 ビットのみを x にコピーします。

そのため、彼は配列内の値を検索し、それらの値の特定のビットをチェックしてから、それらのビットから作成された数値で別の配列を埋めています。詳細は自分で解決する必要があります。

于 2013-03-13T17:27:11.493 に答える