Main Site Documentation

Text on TFT display Fez Cobra


#1

Hello,

I have an Fez Cobra and have conntected an 4.3" TFT screen. The screen is working because the startup logo is showing on the screen.

But how can i place a simple text on the screen like: Hello World

i made a new bitmap example: Bitmap LCD = new Bitmap(Symetric.Width,Symetrc.Height) and then use:
LCD.Clear();
LCD.Drawtext(“Hello World”,MyFont, Colors.Red, 100,100);
LCD.Flush();

But this does not seems to work.


#2

What excatly do not work? Do you receive some error?


#3

Have you tried to draw a line to see if the problem is related to text only or any drawing operations?


#4

Step in code line by line, use F10


#5

When step in the code you see nothing happend on the LCD screen, the start-up logo stay and no text is added.

The way I use now is this:
public Window CreateWindow()
{
// Create a window object and set its size to the
// size of the display.
mainWindow = new Window();
mainWindow.Height = SystemMetrics.ScreenHeight;
mainWindow.Width = SystemMetrics.ScreenWidth;
// Create a single text control.
text = new Text();
text.Font = Resources.GetFont(Resources.FontResources.Arial48Bold) ;
text.TextContent = Resources.GetString(Resources.StringResources.String1);
text.HorizontalAlignment = Microsoft.SPOT.Presentation.HorizontalAlignment.Center;
text.VerticalAlignment = Microsoft.SPOT.Presentation.VerticalAlignment.Center;
// Add the text control to the window.
mainWindow.Child = text;
// Set the window visibility to visible.
mainWindow.Visibility = Visibility.Visible;

        return mainWindow;
    }

But that I don’t like, I like something simpler.


#6

If help you I use something like this and work normaly:


using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Presentation.Media;
using GHIElectronics.NETMF.Hardware;
using GHIElectronics.NETMF.System;

namespace Test
{
    class LCD
    {
        public Bitmap LCDPanel = new Bitmap(SystemMetrics.ScreenWidth, SystemMetrics.ScreenHeight);
        Font SegoeUI12Bold = Resources.GetFont(Resources.FontResources.segoe_ui_12_bold);
         
        public LCD()
        {
            LCDPanel.Clear();
            LCDPanel.Flush();
        }

        public void ShowMessage(string text)
        {
            LCDPanel.Clear();
            LCDPanel.DrawText(text, SegoeUI12Bold, Colors.White, 0, LCDPanel.Height-SegoeUI12Bold.Height-5);
            LCDPanel.Flush();
        }
    }
}


using System;
using Microsoft.SPOT;

namespace Test
{
    public class Test
    {
        public static void Main()
        {
            LCD lcd = new LCD();
			lcd.ShowMessage("LCD Show some text");
			while (true)
            {
			}
        }
    }
}

SegoeUI12Bold is font you can use small or NinaB font.


#7

Maybe we’re missing something obvious like the bitmap not being the right size. If it’s not exactly the size of the LCD it will not flush. Try replacing SystemMetrics with a hardcoded value.


#8

Thank you it works!!

I did use the example of Dejan and I can put screen on the display. Now looking how i can place text with coordinates.

Kind regards!