예제 #1
0
        /// <summary>
        ///     Draw a text message on the display using the current font.
        /// </summary>
        /// <param name="x">Abscissa of the location of the text.</param>
        /// <param name="y">Ordinate of the location of the text.</param>
        /// <param name="spacing">Number of pixels between characters.</param>
        /// <param name="text">Text to display.</param>
        /// <param name="wrap">Wrap the text at the end of the display?</param>
        public static void DrawText(SSD1306 device, int x, int y, int spacing, string text, bool wrap = false)
        {
            // var font = new Font8x8();

            var fontHeight = 8;

            byte[] bitMap = new byte[text.Length * fontHeight];

            for (int index = 0; index < text.Length; index++)
            {
                byte[] characterMap = new byte[] { 0x3E, 0x63, 0x7B, 0x7B, 0x7B, 0x03, 0x1E, 0x00 };

                for (int characterSegment = 0; characterSegment < fontHeight; characterSegment++)
                {
                    bitMap[index + (characterSegment * text.Length)] = characterMap[characterSegment];
                }
            }
            device.DrawBitmap(x, y, text.Length, fontHeight, bitMap, Netduino.Foundation.Displays.DisplayBase.BitmapMode.And);
        }