Main Site Documentation

Raptor Display_N18 ERROR : Painting error


#1

I have a Raptor mainboard with an N18 display and USBClientDP module connected. My application is producing this error and I have tried all the ‘S’ sockets 1,3,11 with the same results.

Using mainboard GHI Electronics FEZRaptor version 1.0
Program Started
0
#### Exception System.NullReferenceException - CLR_E_NULL_REFERENCE (1) ####
#### Message:
#### Gadgeteer.Modules.GHIElectronics.Display_N18::Draw [IP: 001e] ####
#### Gadgeteer.Modules.GHIElectronics.Display_N18::Paint [IP: 004a] ####
#### Gadgeteer.Modules.Module+DisplayModule+SimpleGraphicsInterface::Redraw [IP: 000b] ####
#### Gadgeteer.Modules.Module+DisplayModule+SimpleGraphicsInterface::.ctor [IP: 0028] ####
#### Gadgeteer.Modules.Module+DisplayModule::get_SimpleGraphics [IP: 000b] ####
#### Gadgeteer.Timer::dt_Tick [IP: 0018] ####
#### Microsoft.SPOT.DispatcherTimer::FireTick [IP: 0010] ####
#### Microsoft.SPOT.Dispatcher::PushFrameImpl [IP: 0054] ####
#### Microsoft.SPOT.Dispatcher::PushFrame [IP: 001a] ####
#### Microsoft.SPOT.Dispatcher::Run [IP: 0006] ####
#### Gadgeteer.Program::Run [IP: 0020] ####
A first chance exception of type ‘System.NullReferenceException’ occurred in GTM.GHIElectronics.Display_N18.dll
Display_N18 ERROR : Painting error
#### Exception System.NullReferenceException - CLR_E_NULL_REFERENCE (1) ####
#### Message:
#### Gadgeteer.Modules.GHIElectronics.Display_N18::Draw [IP: 001e] ####
#### Gadgeteer.Modules.GHIElectronics.Display_N18::Paint [IP: 004a] ####
#### Gadgeteer.Modules.Module+DisplayModule+SimpleGraphicsInterface::Redraw [IP: 000b] ####
#### Gadgeteer.Modules.Module+DisplayModule+SimpleGraphicsInterface::set_BackgroundColor [IP: 000f] ####
#### Gadgeteer.Timer::dt_Tick [IP: 0018] ####
#### Microsoft.SPOT.DispatcherTimer::FireTick [IP: 0010] ####
#### Microsoft.SPOT.Dispatcher::PushFrameImpl [IP: 0054] ####
#### Microsoft.SPOT.Dispatcher::PushFrame [IP: 001a] ####
#### Microsoft.SPOT.Dispatcher::Run [IP: 0006] ####
#### Gadgeteer.Program::Run [IP: 0020] ####

My program is


public partial class Program
    {
        static GT.Timer t;
        static int x;
        // This method is run when the mainboard is powered up or reset.   
        void ProgramStarted()
        {
            // Use Debug.Print to show messages in Visual Studio's "Output" window during debugging.
            Debug.Print("Program Started");
            x = 0;
            t = new GT.Timer(1000);
            t.Tick += new GT.Timer.TickEventHandler(Tick);
            t.Start();
        }
        void Tick(GT.Timer timer)
        {
            Debug.Print(x.ToString());
            display_N18.SimpleGraphics.BackgroundColor = Gadgeteer.Color.Black;
            display_N18.SimpleGraphics.DisplayText("Count: " + x.ToString(), Resources.GetFont(Resources.FontResources.small), GT.Color.Yellow, 1, 1);
            x++;
        }
    }


#2

I got the exact same thing.

The whole debugger would crash on port 11 for the N18. For port 3 I get the exact same thing.


#3

Well the problem is that Mainboard.NativeBitmapConverter is null.

This is likely to mean that the CPU does not support the LCD or you will have to convert the Bitmap yourself. After you convert it maybe then you can call display_n18.DrawRaw() Like:

            Bitmap b = new Bitmap((int)display_N18.Width, (int)display_N18.Height);
            byte[] r = (byte[])Array.CreateInstance(typeof(byte),(int)(2*display_N18.Width*display_N18.Height));
            b.DrawText("Hello",f,GT.Color.Cyan,1,1);
            Mainboard.NativeBitmapConverter(b.GetBitmap(),r,GT.Mainboard.BPP.BPP16_BGR_BE); //this line throws error.. NativeBitmap is null (the function pointer)
            display_N18.DrawRaw(r, display_N18.Width, display_N18.Height, 0, 0);
            x++;

#4

I changed the code to:
[line]
Debug.Print(x.ToString());
//display_N18.SimpleGraphics.BackgroundColor = Gadgeteer.Color.Blue;
//display_N18.SimpleGraphics.DisplayText("Hello: ", f, GT.Color.Yellow, 1, 1);
Bitmap b = new Bitmap((int)display_N18.Width, (int)display_N18.Height);
byte[] r = (byte[])Array.CreateInstance(typeof(byte),(int)(2display_N18.Widthdisplay_N18.Height));
b.DrawText(“Hello”,f,GT.Color.Cyan,1,1);
//Mainboard.NativeBitmapConverter(b.GetBitmap(),r,GT.Mainboard.BPP.BPP16_BGR_BE); //this line throws error… NativeBitmap is null (the function pointer)
display_N18.DrawRaw(b.GetBitmap(), display_N18.Width, display_N18.Height, 0, 0);
x++;
[line]
Which is writing out the bitmap in the wrong format. It is writing to the display - even if distorted. So if we can figure out how to format the bytes right this will work.

I will work on it more later.


#5

It is because the Raptor driver is missing the following code and function which the N18 needs.



this.NativeBitmapConverter = new BitmapConvertBPP(BitmapConverter);

void BitmapConverter(byte[] bitmapBytes, byte[] pixelBytes, GT.Mainboard.BPP bpp)
		{
			if (bpp != GT.Mainboard.BPP.BPP16_BGR_BE)
				throw new ArgumentOutOfRangeException("bpp", "Only BPP16_BGR_LE supported");

			Util.BitmapConvertBPP(bitmapBytes, pixelBytes, Util.BPP_Type.BPP16_BGR_BE);
		}

#6

@ BillGates

That was it. Thanks for the help.


#7

I added that code, from Bill Gates, and got this:

‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘c:\users\jason\documents\visual studio 2012\Projects\GadgeteerApp3\GadgeteerApp3\bin\Debug\le\GadgeteerApp3.exe’, Symbols loaded.
#### Exception System.NotSupportedException - CLR_E_NOT_SUPPORTED (2) ####
#### Message:
#### GHI.OSHW.Hardware.RTC+Cerb::.cctor [IP: 001d] ####
An unhandled exception of type ‘System.NotSupportedException’ occurred in GHI.OSHW.Hardware.dll

[line]

This is what I have:

[line]

namespace GadgeteerApp3
{

public partial class Program
{
    // This method is run when the mainboard is powered up or reset.   
        static GT.Timer t;
        static int x;
        Font f = Resources.GetFont(Resources.FontResources.small);
        // This method is run when the mainboard is powered up or reset.   
        void ProgramStarted()
        {
            // Use Debug.Print to show messages in Visual Studio's "Output" window during debugging.
            Debug.Print("Program Started");
            x = 0;
            t = new GT.Timer(1000);
            t.Tick += new GT.Timer.TickEventHandler(Tick);
            t.Start();

            Mainboard.NativeBitmapConverter =new Gadgeteer.Mainboard.BitmapConvertBPP(BitmapConverter);
        }
            
    void BitmapConverter(byte[] bitmapBytes, byte[] pixelBytes, GT.Mainboard.BPP bpp)
    {          
        if (bpp != GT.Mainboard.BPP.BPP16_BGR_BE)
            throw new ArgumentOutOfRangeException("bpp", "Only BPP16_BGR_LE supported");
        Util.BitmapConvertBPP(bitmapBytes, pixelBytes, Util.BPP_Type.BPP16_BGR_BE);       
    } 


    void Tick(GT.Timer timer)
        {
            Debug.Print(x.ToString());
            //display_N18.SimpleGraphics.BackgroundColor = Gadgeteer.Color.Blue;
            //display_N18.SimpleGraphics.DisplayText("Hello: ", f, GT.Color.Yellow, 1, 1);

            x++;
        }
    }
}

#8

That function is indeed missing. As for the next exception that you get, it is because you are trying to load GHI.OSHW.Hardware which is for the OSHW boards only. Raptor uses the G400 which is a Premium board.


#9

for an example on how and where to insert the above fix, take a look at the FEZ cobra II mainboard driver:

http://gadgeteer.codeplex.com/SourceControl/latest#Main/Mainboards/GHIElectronics/FEZCobra II/Software/FEZCobra II/FEZCobra_II_42/FEZCobra_II_42.cs


#10

Thank you. I go this working. I am a happy camper now. Funny thing is, I had to add the Mainboard project to my solution and then add the solution to my references before it would work. If I just added the recompiled dll it didn’t which seems funny to me.


#11

Anyone looking to do this… head here: https://www.ghielectronics.com/community/codeshare/entry/819

All your problems will be solved. Including rotating that display!