Platforms to show: All Mac Windows Linux Cross-Platform
/USB/HID Linux/USB HID IO Warrior Linux 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 Linux/USB HID IO Warrior Linux LEDs
This example is the version from Sun, 17th Mar 2012.
Project "USB HID IO Warrior Linux LEDs.xojo_binary_project"
Class Window1 Inherits Window
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
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
EventHandler Sub Close()
if h<>Nil then
call h.Close
end if
End EventHandler
EventHandler Sub Open()
if not Targetlinux then
MsgBox "Please use only with linux target"
quit
end if
h = new MyHID
h.SetDebugLevel(h.kDebugAll)
h.SetDebugOutputToStderr
const vendor = &h7C0
const product = &h1500
const retries = 3
dim e as integer = h.ForceOpen(0, vendor, product, retries)
listbox1.AddRow "ForceOpen: "+str(e)
if e=0 then
// we dump it here to see the paths for the endpoints.
call h.DumpTreeToStderr
timer1.mode=2
end if
End EventHandler
Sub send(n as integer)
const IOW_PIPE_IO_PINS=0
dim m as MemoryBlock = NewMemoryBlock(4)
m.Byte(3)=n
m.Byte(0)=IOW_PIPE_IO_PINS
if h<>Nil then
dim path(-1) as integer
path.Append &h00010000
path.Append 0
dim e as integer = h.SetOutputReport(path, m, 0, m.size)
end if
End Sub
Property Protected counter As integer
Property Protected h As myhid
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
Class MyHID Inherits LinuxHIDInterfaceMBS
End Class
End Project
See also:
The items on this page are in the following plugins: MBS USB Plugin.