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();
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;
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.
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.