I am running a domino with the 128x64 graphics display. This is the code I am trying to use.
using System;
using System.IO;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.IO;
using Microsoft.SPOT.Hardware;
using GHIElectronics.NETMF.FEZ;
using GHIElectronics.Graphics.Simple128x64;
using GHIElectronics.NETMF.IO;
using GHIElectronics.NETMF.USBHost;
namespace FEZ_Domino_Application1
{
public class Program
{
public static void Main()
{
// Init Display
FEZ_Extensions.Graphical128x64Display.Initialize(FEZ_Pin.Digital.UEXT3, FEZ_Pin.Digital.UEXT4, FEZ_Pin.Digital.UEXT10, SPI.SPI_module.SPI2);
// Display FEZ message
FEZ_Extensions.Graphical128x64Display.Print(0, 1, "File Transfer Station");
FEZ_Extensions.Graphical128x64Display.Print(9, 4, "UNLV Senior Design");
Thread.Sleep(100);
// Subscribe to RemovableMedia events
RemovableMedia.Insert += RemovableMedia_Insert;
RemovableMedia.Eject += RemovableMedia_Eject;
// Subscribe to USB events
USBHostController.DeviceConnectedEvent += DeviceConnectedEvent;
// Sleep forever
Thread.Sleep(Timeout.Infinite);
}
static void DeviceConnectedEvent(USBH_Device device)
{
if (device.TYPE == USBH_DeviceType.MassStorage)
{
Debug.Print("USB Mass Storage detected...");
GPainter paint = new GPainter();
paint.Clear();
paint.PrintSmall(0, 1, "USB device detected");
//....
//....
}
}
}
}
Visual studios is coming back to me and giving the following errors:
Error 1 The name ‘RemovableMedia_Insert’ does not exist in the current context C:\Users\Aaron\documents\visual studio 2010\Projects\Program.cs 33 38 FEZ Domino Application1
Error 2 The name ‘RemovableMedia_Eject’ does not exist in the current context C:\Users\Aaron\documents\visual studio 2010\Projects\Program.cs 34 37 FEZ Domino Application1
Error 3 No overload for ‘DeviceConnectedEvent’ matches delegate ‘GHIElectronics.NETMF.USBHost.USBH_DeviceConnectionEventHandler’ C:\Users\Aaron\documents\visual studio 2010\Projects\Program.cs 37 55 FEZ Domino Application1
Error 4 The type or namespace name ‘USBH_Device’ could not be found (are you missing a using directive or an assembly reference?) C:\Users\Aaron\documents\visual studio 2010\Projects\Program.cs 42 42 FEZ Domino Application1
Error 5 The name ‘USBH_DeviceType’ does not exist in the current context C:\Users\Aaron\documents\visual studio 2010\Projects\Program.cs 44 32 FEZ Domino Application1
It seems that this would be an error from me not including the proper files into the project, however I have placed these files in code as well as in the references section. Could it be that I need to insert another .cs file or something into my project? I am still very new to c#. I will include a image of my solutions explorer window if that might help to see how I have this configured.
I did try your code, but without the Graphics LCD.
It worked fine without any alteration at all.
One thing that I noticed the different was in your References.
If you add
GHIElectronics.NETMF.System
to the References you should be fine with your existing code.
using System;
using System.IO;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.IO;
using Microsoft.SPOT.Hardware;
using GHIElectronics.NETMF.FEZ;
using GHIElectronics.Graphics.Simple128x64;
using GHIElectronics.NETMF.IO;
using GHIElectronics.NETMF.USBHost;
namespace FEZ_Domino_Application1 {
public class Program {
public static void Main() {
// Subscribe to RemovableMedia events
RemovableMedia.Insert += new InsertEventHandler(RemovableMedia_Insert);
RemovableMedia.Eject += new EjectEventHandler(RemovableMedia_Eject);
// Subscribe to USB events
USBHostController.DeviceConnectedEvent += DeviceConnectedEvent);
// Sleep forever
Thread.Sleep(Timeout.Infinite);
}
static void DeviceConnectedEvent(USBH_Device device) {
if (device.TYPE == USBH_DeviceType.MassStorage) {
Debug.Print("USB Mass Storage detected...");
GPainter paint = new GPainter();
paint.Clear();
paint.PrintSmall(0, 1, "USB device detected");
//....
//....
}
}
}
}
I have since placed the GHIElectronics.NETMF.System to the references and it compiles without error. Since C# complains at any sight of error im assuming it is working, however I am not getting any feedback on the LCD, which I am guessing because it does not exist in the scope of the event handlers.
You needed to add this line in the code
FEZ_Extension.Graphicsal128x64Display.Flush(paint.vram);
in the DeviceConnectedEvent() method.
like this:
static void DeviceConnectedEvent(USBH_Device device) {
if (device.TYPE == USBH_DeviceType.MassStorage) {
Debug.Print("USB Mass Storage detected...");
GPainter paint = new GPainter();
paint.Clear();
paint.PrintSmall(0, 1, "USB device detected");
// this line need to be added
FEZ_Extension.Graphicsal128x64Display.Flush(paint.vram);
//....
//....
}