Display N18 WPF - Black Screen

I’ve been trying to get WPF working on my N18 Display but no matter what I try it displays a black screen. Here is a sample of code I an trying to use.

using System;
using Microsoft.SPOT;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Presentation.Controls;
using Microsoft.SPOT.Presentation.Media;
using Microsoft.SPOT.Presentation.Shapes;
using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;
using Gadgeteer.Modules.GHIElectronics;
namespace GPSTest
    public partial class Program
        Window mMainWindow = null;
        Canvas mCanvas = null;
        Border mBackground = null;
        void ProgramStarted()
            mMainWindow = display.WPFWindow;
            mCanvas = new Canvas();
            mMainWindow.Child = mCanvas;
            //Add a gray background.
            mBackground = new Border();
            mBackground.Background = new SolidColorBrush(Colors.Gray);
            mBackground.Width = 128;
            mBackground.Height = 160;
            Canvas.SetLeft(mBackground, 0);
            Canvas.SetTop(mBackground, 0);

Does anyone have any information on why WPF won’t display. I have been able to use SimpleGraphics, but I need to be able to update labels on the display without clearing and redrawing.


I am running this on a FEZ Hydra btw.

Apparently the Hydra has multiple issues with displays. They are supposed to release a new SDK today or tomorrow. I’d wait before trying to debug until it comes out. I’m personally having issues with both the TE35 and CP7 with the Hydra.

@ NXTwoThou - I suspect it may have more to do with the N18 than the Fez Hydra as I had this same issue running the FEZ Cobra II a few months back. See http://www.ghielectronics.com/community/forum/topic?id=10031&page=4#msg106253

Unfortunately work has gotten in the way and I haven’t had time to test further :frowning:

But I will most definately be holding thumbs that new SDK fixes the problem when I get round to testing again.

It’s actually been a bug in our driver that we did not catch before the most recent SDK was released. The only work around we have right now is to download the source of the latest driver from http://gadgeteer.codeplex.com/ under Main/Modules/GHIElectronics/Display N18/Software/Display N18. Add the Display_N18_42 project as an existing project to your solution and reference it. To fix the bug, you need to change line the “public Display_N18(int socketNumber) : base(WPFRenderOptions.Ignore)” to “public Display_N18(int socketNumber) : base(WPFRenderOptions.Intercepted)”. Then your code and WPF should work. (Make sure to drop the call to display.Initialize() as that method was taken out.)

I added the Display_N18_42 project to my Gadgeteer solution and got WPF working with N18 display in my Cobra II compatible G120 board.
However, I’d like to learn NETMF programming by testing non-Gadgeteer WPF Application examples e.g. SimpleWPFApplication that can be found in the Microsoft.NET Micro Framework 4.2\Samples directory and many other nice examples in various NETMF books.

Now based on my testing it seems impossible to initialize N18 display with this driver in the ordinary WPF applications as it is made for the Gadgeteer framework. On the otherhand it would require a lot of work to modify all those projects to Gadgeteer applications.

I’d like to know if anybody is interested in to modify the Display_N18_42 driver project so that non-Gadgeteer WPF applications work by using G120 Module and N18 Display?

It is not hard at all.

MyBitmap.draw something

data = MyBitmap.GetBytes()



The gadgeteer driver includes everything you need to get started.

My N18 display can show WPF UIElements in Gadgeteer applications i.e. associates to a WPF Window in ProgramStarted() using mainWindow = Display_N18.WPFWindow;

My problem is how to initiate and associate the N18 Display driver in non-Gadgeteer WPF applications I.e. I want to omit Program.generated.cs and use of the Sockets based SPI and Digital Ouput pin configurations.

The code above is not gadgeteer. The first step is to get the display to work without gadgeteer. Use console application for start, no WPF yet.

The second step is then to make a window app that uses WPF. All you have to do is overload the draw method (forgot what was called) and then inside your overload you will put the code above.

By the way, why WPF? Have you looked at Glide? http://ghielectronics.com/glide

Thanks, I will try to get the display working in a console application first.
Yes, I’ve been aware of the Glide and I have a plan to test it later when I have learned the capabilities with the basic WPF :slight_smile:

Keep in mind that WPF and Glide run in the emulator if you want a quick way to test.

I agree that it is a good idea to test the GUI design in the emulator first. Anyway, now I want to ensure my HW is working :slight_smile:
Am I on the right track with my modified constructor to by-pass Gadgeteer Sockets with direct access to SPI and Output Ports?

public class Display_N18 : GTM.Module.DisplayModule
        // private GTI.SPI _spi;
        private SPI _spi;
        // private GTI.SPI.Configuration _spiConfig;
        private SPI.Configuration _spiConfig;
        // private GT.Socket _socket;
        // private GTI.DigitalOutput _resetPin;
        private OutputPort _resetPin;
        // private GTI.DigitalOutput _backlightPin;
        private OutputPort _backlightPin;
		// private GTI.DigitalOutput _rs;
        private OutputPort _rs;
		private byte[] byteArray;
		private ushort[] shortArray;
 /// <summary>Constructor</summary>  
 public Display_N18(int socketNumber) : base(WPFRenderOptions.Intercept)
	    this.byteArray = new byte[1];
	    this.shortArray = new ushort[2];
            // Socket socket = Socket.GetSocket(socketNumber, true, this, null);
            // socket.EnsureTypeIsSupported('S', this);
            //this._socket = socket;
            // this._resetPin = new GTI.DigitalOutput(socket, Socket.Pin.Three, false, this);
            this._resetPin = new OutputPort(G120.Pin.P2_21, false);
            // this._backlightPin = new GTI.DigitalOutput(socket, Socket.Pin.Four, true, this);
            this._backlightPin = new OutputPort(G120.Pin.P1_14, true);
            // this._rs = new GTI.DigitalOutput(socket, Socket.Pin.Five, false, this);
            this._rs = new OutputPort(G120.Pin.P1_16, false);



My quick and dirty non-Gadgeteer N18 driver modification works in a console application.

I have replaced Cobra II Socket 6 with direct access to SPI2 and Output Pins in the G120 module and modified the Bitmap conversions to use GHI.Util. However, I could not get rid of all Gadgeteer dependencies.

Any advice how to continue to get the driver working in WPF applications?

BR, Seppo

Its getting clearer when reading excellent Programmers Heaven C# School. A stupid programmer with non-object oriented background trying to destroy my driver class :slight_smile:

your code is still using gadgeteer.

Yes, unfortunately this is getting too much time consuming for me to solve all the required changes in the driver.
I’d eventually like to start developing my GUI application instead of programming the platform, so maybe it is then the gadgeteer way with Glide.

Hello, you can check out if this article works of your black screen problem.
http:// www. windowspasswordsrecovery .com/fix-windows/black-screen-of-death.html