Xojo Conferences
MBSSep2018MunichDE
XDCMay2019MiamiUSA

Platforms to show: All Mac Windows Linux Cross-Platform

/USB/Phidget/PhidgetTextLCD
Function:
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/Phidget/PhidgetTextLCD
This example is the version from Thu, 6th Apr 2016.
Project "PhidgetTextLCD.rbp"
FileTypes
Filetype text
End FileTypes
Class Window1 Inherits Window
Control StaticText1 Inherits Label
ControlInstance StaticText1 Inherits Label
End Control
Control StaticText2 Inherits Label
ControlInstance StaticText2 Inherits Label
End Control
Control StaticText3 Inherits Label
ControlInstance StaticText3 Inherits Label
End Control
Control StaticText4 Inherits Label
ControlInstance StaticText4 Inherits Label
End Control
Control StaticText5 Inherits Label
ControlInstance StaticText5 Inherits Label
End Control
Control StaticText6 Inherits Label
ControlInstance StaticText6 Inherits Label
End Control
Control StaticText10 Inherits Label
ControlInstance StaticText10 Inherits Label
End Control
Control StaticText11 Inherits Label
ControlInstance StaticText11 Inherits Label
End Control
Control StaticText12 Inherits Label
ControlInstance StaticText12 Inherits Label
End Control
Control StaticText13 Inherits Label
ControlInstance StaticText13 Inherits Label
End Control
Control StaticText14 Inherits Label
ControlInstance StaticText14 Inherits Label
End Control
Control StaticText15 Inherits Label
ControlInstance StaticText15 Inherits Label
End Control
Control ListBox1 Inherits ListBox
ControlInstance ListBox1 Inherits ListBox
End Control
Control Timer1 Inherits Timer
ControlInstance Timer1 Inherits Timer
EventHandler Sub Action() StaticText11.text=p.GetDeviceLabel StaticText10.text=p.GetDeviceName StaticText13.text=hex(p.GetDeviceStatus) StaticText12.text=p.GetDeviceType StaticText14.text=hex(p.GetDeviceVersion) StaticText15.text=hex(p.GetSerialNumber) Statictext16.text=str(p.getColumnCount) Statictext17.text=str(p.getRowCount) Statictext18.text=str(p.getBacklight) Statictext20.text=str(p.getContrast) Statictext22.text=str(p.getCursorBlink) Statictext23.text=str(p.getCursorOn) End EventHandler
End Control
Control EditField1 Inherits TextField
ControlInstance EditField1 Inherits TextField
EventHandler Sub TextChange() p.setDisplayString 0, converttext(me.text) End EventHandler
End Control
Control EditField2 Inherits TextField
ControlInstance EditField2 Inherits TextField
EventHandler Sub TextChange() p.setDisplayString 1, converttext(me.text) End EventHandler
End Control
Control StaticText16 Inherits Label
ControlInstance StaticText16 Inherits Label
End Control
Control StaticText7 Inherits Label
ControlInstance StaticText7 Inherits Label
End Control
Control StaticText8 Inherits Label
ControlInstance StaticText8 Inherits Label
End Control
Control StaticText17 Inherits Label
ControlInstance StaticText17 Inherits Label
End Control
Control StaticText9 Inherits Label
ControlInstance StaticText9 Inherits Label
End Control
Control StaticText18 Inherits Label
ControlInstance StaticText18 Inherits Label
End Control
Control StaticText19 Inherits Label
ControlInstance StaticText19 Inherits Label
End Control
Control StaticText20 Inherits Label
ControlInstance StaticText20 Inherits Label
End Control
Control StaticText21 Inherits Label
ControlInstance StaticText21 Inherits Label
End Control
Control StaticText22 Inherits Label
ControlInstance StaticText22 Inherits Label
End Control
Control StaticText23 Inherits Label
ControlInstance StaticText23 Inherits Label
End Control
Control StaticText24 Inherits Label
ControlInstance StaticText24 Inherits Label
End Control
Control StaticText25 Inherits Label
ControlInstance StaticText25 Inherits Label
End Control
Control StaticText26 Inherits Label
ControlInstance StaticText26 Inherits Label
End Control
Control StaticText27 Inherits Label
ControlInstance StaticText27 Inherits Label
End Control
Control PushButton1 Inherits PushButton
ControlInstance PushButton1 Inherits PushButton
EventHandler Sub Action() p.setBacklight true End EventHandler
End Control
Control PushButton2 Inherits PushButton
ControlInstance PushButton2 Inherits PushButton
EventHandler Sub Action() p.setBacklight false End EventHandler
End Control
Control StaticText28 Inherits Label
ControlInstance StaticText28 Inherits Label
End Control
Control Slider1 Inherits Slider
ControlInstance Slider1 Inherits Slider
EventHandler Sub ValueChanged() p.setContrast me.Value End EventHandler
End Control
Control PushButton3 Inherits PushButton
ControlInstance PushButton3 Inherits PushButton
EventHandler Sub Action() p.setCursorOn 0 End EventHandler
End Control
Control PushButton4 Inherits PushButton
ControlInstance PushButton4 Inherits PushButton
EventHandler Sub Action() p.setCursorOn 1 End EventHandler
End Control
Control StaticText29 Inherits Label
ControlInstance StaticText29 Inherits Label
End Control
Control PushButton5 Inherits PushButton
ControlInstance PushButton5 Inherits PushButton
EventHandler Sub Action() p.setCursorBlink 0 End EventHandler
End Control
Control PushButton6 Inherits PushButton
ControlInstance PushButton6 Inherits PushButton
EventHandler Sub Action() p.setCursorBlink 1 End EventHandler
End Control
Control StaticText30 Inherits Label
ControlInstance StaticText30 Inherits Label
End Control
Control PushButton7 Inherits PushButton
ControlInstance PushButton7 Inherits PushButton
EventHandler Sub Action() // define it: cross p.setCustomCharacter 8,162948,135300 // use it: p.setDisplayString 0,"Custom character: "+chrb(8) // define it: smiley p.setCustomCharacter 9,1038304,32309 p.setCustomCharacter 10,1038304,32319 p.setCustomCharacter 11,1038304,32433 // use them p.setDisplayString 1,chrb(9)+" "+chrb(10)+" "+chrb(11) End EventHandler
End Control
Control PushButton8 Inherits PushButton
ControlInstance PushButton8 Inherits PushButton
EventHandler Sub Action() EditField1.text="äöüßµ–ñ∞∃αβρΣΩ÷¢" End EventHandler
End Control
EventHandler Sub Close() p.Close End EventHandler
EventHandler Sub Open() ' call loadPhidgetFrameworkMBS, LoadPhidgetWindowsDLLMBS or LoadPhidgetLinuxLibraryMBS p=new MyPhidget if p.Handle=0 then MsgBox "Failed to create object." end if if p.Lasterror<>0 then MsgBox "Constructor lasterror: "+str(p.Lasterror)+" "+p.GetErrorDescription(p.Lasterror) end if // -1 for first device p.Open -1 if p.Lasterror<>0 then MsgBox "Open lasterror: "+str(p.Lasterror)+" "+p.GetErrorDescription(p.Lasterror) end if End EventHandler
Protected Function converttext(t as string) As string dim u as string=ConvertEncoding(t,encodings.UTF8) dim a,i,c as integer dim s as string // Phidget uses: ASCII Standard Character Set with Katakana Extension // so we translate here a few characters manually c=len(u) for i=1 to c a=asc(mid(u,i,1)) // äöüßµ–ñ∞∃αβρΣΩ÷¢ Select case a case asc("ä") s=s+chrb(225) case asc("ß") s=S+chrb(226) case asc("€") s=S+chrb(227) case asc("µ") s=S+chrb(228) case asc("ñ") s=S+chrb(238) case asc("ö") s=S+chrb(239) case asc("∞") s=S+chrb(&hF3) case asc("π") s=S+chrb(&h7F) case asc("ü") s=S+chrb(&hF5) case asc("–") s=S+chrb(&hB0) case asc("∃") s=s+chrb(&hD6) case asc("α") s=S+chrb(&hE0) case asc("β") s=S+chrb(&hE2) case asc("ρ") s=S+chrb(&hE6) case asc("Σ") s=s+chrb(&hF6) case asc("Ω") s=s+chrb(&hF4) case asc("÷") s=S+chrb(&hFD) case asc("¢") s=s+chrb(&hEC) else s=s+chrb(a) end Select next return s End Function
Property Protected p As MyPhidget
End Class
MenuBar MenuBar1
MenuItem UntitledMenu1 = ""
MenuItem FileMenu = "&File"
MenuItem FileQuit = "Quit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem UntitledMenu0 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "Clear"
End MenuBar
Class App Inherits Application
EventHandler Sub Open() dim f as FolderItem if TargetMachO then f=FindFile("Phidget21.framework") if LoadPhidgetFrameworkMBS(f) then ' MsgBox "Framework loaded" else MsgBox "Failed to load framework" end if elseif TargetWin32 then if LoadPhidgetWindowsDLLMBS("Phidget21.dll") then ' MsgBox "DLL loaded" else MsgBox "Failed to load DLL" end if end if // use LoadPhidgetWindowsDLLMBS on Windows // use LoadPhidgetLinuxLibraryMBS on Linux End EventHandler
Function FindFile(name as string) As FolderItem // Look for file in parent folders from executable on dim parent as FolderItem = app.ExecutableFile.Parent while parent<>Nil dim file as FolderItem = parent.Child(name) if file<>Nil and file.Exists then Return file end if parent = parent.Parent wend End Function
End Class
Class MyPhidget Inherits PhidgetTextLCDMBS
EventHandler Sub Attach() window1.ListBox1.AddRow "Attached" End EventHandler
EventHandler Sub Detach() window1.ListBox1.AddRow "Detached" End EventHandler
EventHandler Sub Error(errorCode as integer, errorDescription as string) window1.ListBox1.AddRow "Error "+str(errorCode)+": "+errorDescription End EventHandler
End Class
End Project

Feedback, Comments & Corrections

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





Links
MBS FileMaker tutorial videos