public PromptForm(ref GHI.Glide.Display.Window window, ref DisplayDriver43 displayTE35, ref IDriveProvider sdCard, ref GHIElectronics.TinyCLR.Devices.UsbHost.UsbHostController usbHost) : base(ref window) { //this.usbClientEDP = usbClientEDP; this.usbHost = usbHost; this.sdCard = sdCard; this.displayTE35 = displayTE35; }
public GvShell(ref DisplayDriver43 displayTE35, ref IDriveProvider sdCard, ref GHIElectronics.TinyCLR.Devices.UsbHost.UsbHostController usbHost) { this.displayTE35 = displayTE35; this.usbHost = usbHost; //this.usbClientEDP = usbClientEdp; this.sdCard = sdCard; Screen = displayTE35.Screen; //new Bitmap(ScreenWidth, ScreenHeight); ClearScreen(); MaxLine = ScreenHeight / 20; CurrentLine = 0; CurrentFont = Resources.GetFont(Resources.FontResources.NinaB); CurrentPath = "\\";// "\\SD\\"; DataLines = new ArrayList(); for (int i = 0; i < MaxLine; i++) { DataLines.Add(string.Empty); } TypedCommand = string.Empty; if (basic == null) { if (basic == null) { basic = new SBASIC(); basic.Print += Basic_Print; basic.ClearScreen += Basic_ClearScreen; } } }
private void UsbHostController_OnConnectionChangedEvent (GHIElectronics.TinyCLR.Devices.UsbHost.UsbHostController sender, GHIElectronics.TinyCLR.Devices.UsbHost.DeviceConnectionEventArgs e) { System.Diagnostics.Debug.WriteLine("e.Id = " + e.Id + " \n"); System.Diagnostics.Debug.WriteLine("e.InterfaceIndex = " + e.InterfaceIndex + " \n"); System.Diagnostics.Debug.WriteLine("e.PortNumber = " + e.PortNumber); System.Diagnostics.Debug.WriteLine("e.Type = " + ((object)(e.Type)). ToString() + " \n"); System.Diagnostics.Debug.WriteLine("e.VendorId = " + e.VendorId + " \n"); System.Diagnostics.Debug.WriteLine("e.ProductId = " + e.ProductId + " \n"); switch (e.DeviceStatus) { case GHIElectronics.TinyCLR.Devices.UsbHost.DeviceConnectionStatus.Connected: switch (e.Type) { case GHIElectronics.TinyCLR.Devices.UsbHost.BaseDevice. DeviceType.Keyboard: var keyboard = new GHIElectronics.TinyCLR.Devices.UsbHost. Keyboard(e.Id, e.InterfaceIndex); keyboard.KeyUp += Keyboard_KeyUp; keyboard.KeyDown += Keyboard_KeyDown; break; case GHIElectronics.TinyCLR.Devices.UsbHost.BaseDevice.DeviceType.Mouse: var mouse = new GHIElectronics.TinyCLR.Devices.UsbHost. Mouse(e.Id, e.InterfaceIndex); mouse.ButtonChanged += Mouse_ButtonChanged; mouse.CursorMoved += Mouse_CursorMoved; break; case GHIElectronics.TinyCLR.Devices.UsbHost.BaseDevice. DeviceType.MassStorage: var strogareController = GHIElectronics.TinyCLR.Devices.Storage. StorageController.FromName(GHIElectronics.TinyCLR.Pins. SC20260.StorageController.UsbHostMassStorage); var driver = GHIElectronics.TinyCLR.IO.FileSystem. Mount(strogareController.Hdc); var driveInfo = new System.IO.DriveInfo(driver.Name); System.Diagnostics.Debug.WriteLine ("Free: " + driveInfo.TotalFreeSpace); System.Diagnostics.Debug.WriteLine ("TotalSize: " + driveInfo.TotalSize); System.Diagnostics.Debug.WriteLine ("VolumeLabel:" + driveInfo.VolumeLabel); System.Diagnostics.Debug.WriteLine ("RootDirectory: " + driveInfo.RootDirectory); System.Diagnostics.Debug.WriteLine ("DriveFormat: " + driveInfo.DriveFormat); break; default: var rawDevice = new GHIElectronics.TinyCLR.Devices.UsbHost. RawDevice(e.Id, e.InterfaceIndex, e.Type); var devDesc = rawDevice.GetDeviceDescriptor(); var cfgDesc = rawDevice.GetConfigurationDescriptor(0); var endpointData = new byte[7]; endpointData[0] = 7; //Length in bytes of this descriptor. endpointData[1] = 5; //Descriptor type (endpoint). endpointData[2] = 0x81; //Input endpoint address. endpointData[3] = 3; //Transfer type is interrupt endpoint. endpointData[4] = 8; //Max packet size LSB. endpointData[5] = 0; //Max packet size MSB. endpointData[6] = 10; //Polling interval. var endpoint = new GHIElectronics.TinyCLR.Devices.UsbHost. Descriptors.Endpoint(endpointData, 0); var pipe = rawDevice.OpenPipe(endpoint); pipe.TransferTimeout = 10; var data = new byte[8]; var read = pipe.Transfer(data); if (read > 0) { System.Diagnostics.Debug.WriteLine("Raw Device has new data " + data[0] + ", " + data[1] + ", " + data[2] + ", " + data[3]); } else if (read == 0) { System.Diagnostics.Debug.WriteLine("No new data"); } System.Threading.Thread.Sleep(500); break; } break; case GHIElectronics.TinyCLR.Devices.UsbHost.DeviceConnectionStatus.Disconnected: System.Diagnostics.Debug.WriteLine("Device Disconnected"); //Unmount filesystem if it was mounted. break; case GHIElectronics.TinyCLR.Devices.UsbHost.DeviceConnectionStatus.Bad: System.Diagnostics.Debug.WriteLine("Bad Device"); break; } }