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.
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++;
}
}
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++;
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.
‘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++;
}
}
}
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.
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.