Platforms to show: All Mac Windows Linux Cross-Platform

/USB/HID Windows/USB HID IO Warrior Windows LEDs
Required plugins for this example: MBS USB Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /USB/HID Windows/USB HID IO Warrior Windows LEDs
This example is the version from Sun, 17th Mar 2012.
Project "USB HID IO Warrior Windows LEDs.xojo_binary_project"
Class Window1 Inherits Window
Control Timer1 Inherits Timer
ControlInstance Timer1 Inherits Timer
EventHandler Sub Action() dim n as integer dim v as integer if CheckBox1.Value then if counter>=16 then counter=0 end if if counter>=8 then n=255-pow(2,15-counter) else n=255-pow(2,counter) end if send n counter=counter+1 else send counter counter=counter+1 if counter=256 then counter=0 end if end if End EventHandler
End Control
Control ListBox1 Inherits ListBox
ControlInstance ListBox1 Inherits ListBox
End Control
Control CheckBox1 Inherits CheckBox
ControlInstance CheckBox1 Inherits CheckBox
End Control
Control StaticText1 Inherits Label
ControlInstance StaticText1 Inherits Label
End Control
EventHandler Sub Open() if not TargetWin32 then MsgBox "Please use only with Windows!" quit end if OpenUSBDevice End EventHandler
Protected Function FindDevice() As WinHIDMBS dim h as WinHIDMBS dim p as string h=new WinHIDMBS if h.FindFirstDevice then ProductID=h.ProductID if ProductID=&h1500 and h.VendorID=&h7C0 then Return h end if while h.FindNextDevice ProductID=h.ProductID if ProductID=&h1500 and h.VendorID=&h7C0 then Return h end if wend end if End Function
Sub OpenUSBDevice() dim i as integer listbox1.AddRow "OpenUSBDevice" h=FindDevice if h=nil then MsgBox "No IOWarrior 40 device found." quit Return end if listbox1.AddRow h.Product if not h.Connect then MsgBox "Failed to connect to "+h.Product+" Device."+EndOfLine+EndOfLine+"Error: "+str(h.Lasterror) h=nil quit Return end if listbox1.AddRow "OpenUSBDevice done" timer1.mode=2 End Sub
Sub send(n as integer) dim m as MemoryBlock dim e as integer const IOW_PIPE_IO_PINS=0 const IOWKIT40_IO_REPORT_SIZE=5 const IOWKIT24_IO_REPORT_SIZE=3 const IOWKIT56_IO_REPORT_SIZE=8 const IOWKIT_PRODUCT_ID_IOW40=&h1500 const IOWKIT_PRODUCT_ID_IOW24=&h1501 const IOWKIT_PRODUCT_ID_IOW56=&h1503 Select case ProductID case IOWKIT_PRODUCT_ID_IOW40 m=NewMemoryBlock(IOWKIT40_IO_REPORT_SIZE) m.Byte(4)=n case IOWKIT_PRODUCT_ID_IOW24 m=NewMemoryBlock(IOWKIT24_IO_REPORT_SIZE) m.Byte(1)=n case IOWKIT_PRODUCT_ID_IOW56 m=NewMemoryBlock(IOWKIT56_IO_REPORT_SIZE) m.Byte(7)=n else // unknown product? Return end Select m.Byte(0)=IOW_PIPE_IO_PINS e=h.SendMessageMemory(m,0,m.size) System.DebugLog "SendMessageMemory: "+str(e)+" "+str(h.Lasterror) Exception End Sub
Property Protected ProductID As integer
Property Protected counter As integer
Property Protected h As WinHIDMBS
Property Protected last As integer
End Class
MenuBar Menu
MenuItem UntitledMenu3 = ""
MenuItem UntitledMenu2 = "File"
MenuItem FileQuit = "Quit"
MenuItem UntitledMenu0 = "Edit"
MenuItem EditUndo = "Undo"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "Cut"
MenuItem EditCopy = "Copy"
MenuItem EditPaste = "Paste"
MenuItem EditClear = "Clear"
End MenuBar
Class App Inherits Application
Property quitting As boolean
End Class
End Project

See also:

Feedback, Comments & Corrections

The items on this page are in the following plugins: MBS USB Plugin.

The biggest plugin in space...

MBS Xojo PDF Plugins

Start Chat