FEZ Cerberus with N18 display yields 'System.NullReferenceException' error in driver

Hi all,

Today I received my FEZ Cerberus and N18 display.
After updating firmware ready to give it a try.

Took the sample from http://www.tinyclr.com/codeshare/entry/636 and copied the example program (below)


using System;
using System.Collections;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Presentation.Controls;
using Microsoft.SPOT.Presentation.Media;
using Microsoft.SPOT.Touch;

using Gadgeteer.Networking;
using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;
using Gadgeteer.Modules.GHIElectronics;

namespace N18_Test
{
	public partial class Program
	{
        GTM.GHIElectronics.Display_N18 display_N18;

		// This method is run when the mainboard is powered up or reset.   
		void ProgramStarted()
		{
			/*******************************************************************************************
			Modules added in the Program.gadgeteer designer view are used by typing 
			their name followed by a period, e.g.  button.  or  camera.
            
			Many modules generate useful events. Type +=<tab><tab> to add a handler to an event, e.g.:
				button.ButtonPressed +=<tab><tab>
            
			If you want to do something periodically, use a GT.Timer and handle its Tick event, e.g.:
				GT.Timer timer = new GT.Timer(1000); // every second (1000ms)
				timer.Tick +=<tab><tab>
				timer.Start();
			*******************************************************************************************/

            display_N18 = new GTM.GHIElectronics.Display_N18(5);
            display_N18.Initialize(4000);

            ///////////////////////////////////////////////////////////////////////////////////////////////
            // Usage example #1. Simple Graphics support.
            display_N18.SimpleGraphics.Clear();
            display_N18.SimpleGraphics.DisplayText("Hello World!", Resources.GetFont(Resources.FontResources.NinaB), GT.Color.Red, 5, 5);

            
            ///////////////////////////////////////////////////////////////////////////////////////////////
            // Usage example #2. Passing a Bitmap to the driver.
            Bitmap picture = Resources.GetBitmap(Resources.BitmapResources.LogoFSE_zwarte_achtegrond );
            display_N18.DrawBitmap(picture);


            // Usage example #3. Passing raw bitmap information to the driver, placing it at a certain location.
            byte[] newRender = new byte[100 * 100 * 4];
            Bitmap pic2 = Resources.GetBitmap(Resources.BitmapResources.LogoFSE_zwarte_achtegrond);

            Array.Copy(pic2.GetBitmap(), newRender, newRender.Length);

            display_N18.DrawBitmapRawData(newRender, 0, 0, 100, 100);



			// Use Debug.Print to show messages in Visual Studio's "Output" window during debugging.
			Debug.Print("Program Started");
		}
	}
}

When run, the mentioned exception occurs in the driver, in the function below, at the line
GTM.Module.Mainboard.NativeBitmapConverter(/bitmapbytes/bitmapData, vram, Mainboard.BPP.BPP16_BGR_BE);
The debugger states NativeBitmapConverter() is null?


        public void DrawBitmapRawData(byte[] bitmapData, uint x, uint y, uint width, uint height)
        {
            SetClippingArea(x, y, width-1, height-1);
            {
                WriteCommand(0x2C);

                if(vram != null)
                {
                    if (vram.Length != (width * height * 2))
                        vram = new byte[width * height * 2];
                }
                else
                    vram = new byte[width * height * 2];

                GTM.Module.Mainboard.NativeBitmapConverter(/*bitmapbytes*/bitmapData, vram, Mainboard.BPP.BPP16_BGR_BE);

                DataWrite(vram);
            }
            SetClippingArea(0, 0, Width, Height);
        }


Is there a bug in the driver?

This driver works on all boards, excluding Cerb-family boards while using Gadgeteer, as the mainboard drivers required modification for it to work properly. Will be fixed in the next SDK.

Hi Steven,

Thanks for your reply.

Wouldn’t it be a good idea to make a note on the catalog page of the N18 display stating N18 won’t work on Cerb family boards then?

The parts are used in a new system being developed at the moment. I have to deal with a very tight schedule. Had I known about this while ordering this system I would definitely have selected something else! When is the next SDK scheduled for release?

Is there any possible workaround you know of? Or maybe I can participate in beta testing?

TIA Jos

@ JdV - it does work but driver some updates as Steven explained.

@ Gus -

Got the display working now, at least I can display a red/green/blue screen on it.

Question: is there any info wrt the time schedule for the driver update/next SDK?
I need to know, since making my own driver will cost a lot of time.
I have to make a decision between staying with the N18 or switching to another display e.g. the OLED.

TIA Jos

Today :slight_smile:

Thats great news! Can’t wait to grab it from the download page!

Thanks.

@ Gus

I believe the download link on http://www.ghielectronics.com/support/dotnet-micro-framework to download GHI Software Package v4.2 is still pointing to the previous release.

Yes correct. It will come later

Caution software dude asking a hardware question, so looking at this line:

display_N18.Initialize(4000);

where 4000 is the SPI Clock Rate in Khz, what or where would I find this value for the different mainboards?

@ Duke Nukem - 4000 should be fine for all the boards.

@ Gus -
I certainly don’t want to “push” things however, I have the N18 display on my desk and like to get started with it.
But … I still can’t download the updated sdk required to operate the display in a proper way.
Can u pls help me in some way?

TIA Jos

Hadn’t noticed this one. Thanks!

@ JdV - The SDK was there for few days on beta but we now making final changes to release non-beta in about a week. We understand you like this working ASAP and we are trying our best to release something complete and stable for everyone and on every product.

OK, now I understand what’s going on.
Still have to be a little patient …

thanks