コード例 #1
0
        /*
         * NAME:        WriteCharDisplayBuf
         * DESCRIPTION: Writes one character to the display screen buffer (DisplayUpdate() needs to be called subsequently to output the buffer to the screen)
         * INPUTS:
         *
         * Character: The character we want to draw. In this sample, special characters like tabs and newlines are not supported.
         * Col:       The horizontal column we want to start drawing at. This is equivalent to the 'X' axis pixel position.
         * Row:       The vertical row we want to write to. The screen is divided up into 4 rows of 16 pixels each, so valid values for Row are 0,1,2,3.
         *
         * RETURN VALUE:
         * We return the number of horizontal pixels used. This value is 0 if Row/Col are out-of-bounds, or if the character isn't available in the font.
         */
        public UInt32 WriteCharDisplayBuf(Char Chr, UInt32 Col, UInt32 Row)
        {
            /* Check that we were able to find the font corresponding to our character */
            FontCharacterDescriptor CharDescriptor = DisplayFontTable.GetCharacterDescriptor(Chr);

            if (CharDescriptor == null)
            {
                return(0);
            }

            /* Make sure we're drawing within the boundaries of the screen buffer */
            UInt32 MaxRowValue = (SCREEN_HEIGHT_PAGES / DisplayFontTable.FontHeightBytes) - 1;
            UInt32 MaxColValue = SCREEN_WIDTH_PX;

            if (Row > MaxRowValue)
            {
                return(0);
            }
            if ((Col + CharDescriptor.CharacterWidthPx + DisplayFontTable.FontCharSpacing) > MaxColValue)
            {
                return(0);
            }

            UInt32 CharDataIndex = 0;
            UInt32 StartPage     = Row * 2;                                          //0
            UInt32 EndPage       = StartPage + CharDescriptor.CharacterHeightBytes;  //2
            UInt32 StartCol      = Col;
            UInt32 EndCol        = StartCol + CharDescriptor.CharacterWidthPx;
            UInt32 CurrentPage   = 0;
            UInt32 CurrentCol    = 0;

            /* Copy the character image into the display buffer */
            for (CurrentPage = StartPage; CurrentPage < EndPage; CurrentPage++)
            {
                for (CurrentCol = StartCol; CurrentCol < EndCol; CurrentCol++)
                {
                    byte [] Page = DisplayBuffer[(int)CurrentCol];
                    //       byte Pixel = CharDescriptor.CharacterData[CharDataIndex];
                    Page[CurrentPage] = CharDescriptor.CharacterData[CharDataIndex];
                    //            DisplayBuffer[CurrentCol, CurrentPage] = CharDescriptor.CharacterData[CharDataIndex];
                    CharDataIndex++;
                }
            }

            /* Pad blank spaces to the right of the character so there exists space between adjacent characters */
            for (CurrentPage = StartPage; CurrentPage < EndPage; CurrentPage++)
            {
                for (; CurrentCol < EndCol + DisplayFontTable.FontCharSpacing; CurrentCol++)
                {
                    byte[] Page = DisplayBuffer[(int)CurrentCol];
                    //       byte Pixel = CharDescriptor.CharacterData[CharDataIndex];
                    Page[CurrentPage] = 0x00;

                    //                   DisplayBuffer[CurrentCol, CurrentPage] = 0x00;
                }
            }

            /* Return the number of horizontal pixels used by the character */
            return(CurrentCol - StartCol);
        }
コード例 #2
0
        /*
         * NAME:        WriteCharDisplayBuf
         * DESCRIPTION: Writes one character to the display screen buffer (DisplayUpdate() needs to be called subsequently to output the buffer to the screen)
         * INPUTS:
         *
         * Character: The character we want to draw. In this sample, special characters like tabs and newlines are not supported.
         * Col:       The horizontal column we want to start drawing at. This is equivalent to the 'X' axis pixel position.
         * Row:       The vertical row we want to write to. The screen is divided up into 4 rows of 16 pixels each, so valid values for Row are 0,1,2,3.
         *
         * RETURN VALUE:
         * We return the number of horizontal pixels used. This value is 0 if Row/Col are out-of-bounds, or if the character isn't available in the font.
         */
        public uint WriteCharDisplayBuf(char Chr, uint Col, uint Row)
        {
            /* Get our character descriptor or the undefined box */
            FontCharacterDescriptor CharDescriptor = DisplayFontTable.GetCharacterDescriptor(Chr);

            /* Make sure we're drawing within the boundaries of the screen buffer */
            uint MaxRowValue = (SCREEN_HEIGHT_PAGES / DisplayFontTable.FontHeightBytes) - 1;
            uint MaxColValue = SCREEN_WIDTH_PX;

            if (Row > MaxRowValue)
            {
                return(0);
            }
            if ((Col + CharDescriptor.CharacterWidthPx + DisplayFontTable.FontCharSpacing) > MaxColValue)
            {
                return(0);
            }

            uint CharDataIndex = 0;
            uint StartPage     = Row * 2;                                          //0
            uint EndPage       = StartPage + CharDescriptor.CharacterHeightBytes;  //2
            uint StartCol      = Col;
            uint EndCol        = StartCol + CharDescriptor.CharacterWidthPx;
            uint CurrentPage   = 0;
            uint CurrentCol    = 0;

            /* Copy the character image into the display buffer */
            for (CurrentPage = StartPage; CurrentPage < EndPage; CurrentPage++)
            {
                for (CurrentCol = StartCol; CurrentCol < EndCol; CurrentCol++)
                {
                    DisplayBuffer[CurrentCol, CurrentPage] = CharDescriptor.CharacterData[CharDataIndex];
                    CharDataIndex++;
                }
            }

            /* Pad blank spaces to the right of the character so there exists space between adjacent characters */
            for (CurrentPage = StartPage; CurrentPage < EndPage; CurrentPage++)
            {
                for (; CurrentCol < EndCol + DisplayFontTable.FontCharSpacing; CurrentCol++)
                {
                    DisplayBuffer[CurrentCol, CurrentPage] = 0x00;
                }
            }

            /* Return the number of horizontal pixels used by the character */
            return(CurrentCol - StartCol);
        }
コード例 #3
0
 public void DrawText(uint x, uint y, string Line, uint color)
 {
     foreach (Char Character in Line)
     {
         FontCharacterDescriptor CharDescriptor = DisplayFontTable.GetCharacterDescriptor(Character);
         if (CharDescriptor == null)
         {
             return;
         }
         uint w = CharDescriptor.CharacterWidthPx;
         w = 16;
         uint h = CharDescriptor.CharacterHeightBytes;
         addressSet(x, y, x + w, y + h);
         DisplaySendData(CharDescriptor.CharacterData);
         x += w;
     }
 }