Platforms to show: All Mac Windows Linux Cross-Platform
/USB/IOWarrior/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/IOWarrior/IO Warrior Windows LEDs
This example is the version from Sun, 17th Mar 2012.
Project "IO Warrior Windows LEDs.xojo_binary_project"
Class Window1 Inherits Window
Control StaticText1 Inherits Label
ControlInstance StaticText1 Inherits Label
End Control
Control init Inherits Label
ControlInstance init Inherits Label
End Control
Control StaticText3 Inherits Label
ControlInstance StaticText3 Inherits Label
End Control
Control write Inherits Label
ControlInstance write Inherits Label
End Control
Control Timer1 Inherits Timer
ControlInstance Timer1 Inherits Timer
EventHandler Sub Action()
run
End EventHandler
End Control
Control StaticText4 Inherits Label
ControlInstance StaticText4 Inherits Label
End Control
Control counters Inherits Label
ControlInstance counters Inherits Label
End Control
Control CheckBox1 Inherits CheckBox
ControlInstance CheckBox1 Inherits CheckBox
EventHandler Sub Action()
if me.Value then
Timer1.Period=10
else
Timer1.Period=100
end if
End EventHandler
End Control
Control StaticText5 Inherits Label
ControlInstance StaticText5 Inherits Label
End Control
Control read Inherits Label
ControlInstance read Inherits Label
End Control
Control StaticText2 Inherits Label
ControlInstance StaticText2 Inherits Label
End Control
Control version Inherits Label
ControlInstance version Inherits Label
End Control
Control StaticText7 Inherits Label
ControlInstance StaticText7 Inherits Label
End Control
Control productid Inherits Label
ControlInstance productid Inherits Label
End Control
Control StaticText9 Inherits Label
ControlInstance StaticText9 Inherits Label
End Control
Control devicecount Inherits Label
ControlInstance devicecount Inherits Label
End Control
Control StaticText6 Inherits Label
ControlInstance StaticText6 Inherits Label
End Control
Control SerialNumber Inherits Label
ControlInstance SerialNumber Inherits Label
End Control
Control StaticText8 Inherits Label
ControlInstance StaticText8 Inherits Label
End Control
Control revision Inherits Label
ControlInstance revision Inherits Label
End Control
EventHandler Sub Open()
io=new IOWarriorWindowsMBS
// custom IDs can be used
io.USBVendorID=&h1466
io.USB24DeviceID=&h3000
if io.Open then
init.text="open successfull."
else
init.text="open failed."
end if
devicecount.text=str(io.DeviceCount)
productid.text=str(io.GetProductID)
Revision.text=str(io.GetRevision)
version.text=io.Version
SerialNumber.text=io.SerialNumber
End EventHandler
Protected Sub SetLeds(n as integer)
dim m as MemoryBlock
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 io.GetProductID
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
write.text= str(io.Write(IOW_PIPE_IO_PINS,m,m.size))
End Sub
Protected Sub run()
dim n as integer
dim v as integer
dim d as date
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
SetLeds n
counters.text=str(counter)+" "+str(n)
counter=counter+1
else
SetLeds counter
counters.text=str(counter)
counter=counter+1
if counter=256 then
counter=0
end if
end if
Exception
End Sub
Property Protected counter As integer
Property Protected io As iowarriorWindowsMBS
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
End Class
End Project
See also:
The items on this page are in the following plugins: MBS USB Plugin.