It relates to this posting where I said I will provide for 50 commands. Attached a B4A sample project that switches On/Off my air conditioner. I am sure you will get the drift of what to do with it - you need to find the cycle times for the commands that you want to make use of and pass them as an array of int to the library to control whatever it is that you would like to control. You can pass whatever commands you would like to pass to control your device(s) - as many as you want
Please note that this B4A project was done with B4A V6.80
Take note of the B4A manifest file
Your device must support an IR Blaster
Also posting the B4A library files (GeneralIRcontrol.zip).Extract the jar and xml and copy them to ylour additional library folder.
Sample code:
Library:
GeneralIRcontrol
Author: Github: Andrew (andrew-brill), Wrapped by: Johan Schoeman
Version: 1
You can try this to see if it will switch On/Off a Samsung TV
Frequency = 38000
ints = 173,173,22,65,22,65,22,65,22,22,22,22,22,22,22,22,22,22,22,65,22,65,22,65,22,22,22,22,22,22,22,22,22,22,22,22,22,65,22,22,22,22,22,22,22,22,22,22,22,22,22,65,22,22,22,65,22,65,22,65,22,65,22,65,22,65,22,5000
Please note that this B4A project was done with B4A V6.80
Take note of the B4A manifest file
Your device must support an IR Blaster
Also posting the B4A library files (GeneralIRcontrol.zip).Extract the jar and xml and copy them to ylour additional library folder.
Sample code:
B4X:
#Region Project Attributes
#ApplicationLabel: b4aGeneralIRremote
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: portrait
#CanInstallToExternalStorage: False
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim gr As GeneralIRcontrol
Private Button1 As Button
Private Button2 As Button
Dim frequency As Int = 38000
'Add your commands here. There are 50 commands provided for in the library
Dim AirConOn() As Int = Array As Int(173,161,26,55,26,15,25,55,26,54,26,15,26,15,25,54,27,15,25,15,25,55,26,15,25,15,26,54,26,55,26,15,25,54,27,54,27,14,26,54,26,55,26,54,27,54,26,54,27,54,26,15,26,54,26,15,26,14,26,15,25,15,26,15,26,15,25,15,26,54,26,15,25,15,26,15,25,15,26,14,26,15,26,53,27,15,25,54,27,54,26,55,26,54,27,54,26,54,27,207,173,161,26,54,27,14,26,54,27,54,26,15,25,15,26,54,26,15,26,15,25,55,26,15,25,15,26,54,26,54,27,14,26,54,27,54,26,15,25,55,26,54,27,54,26,54,27,54,26,55,26,15,25,55,26,15,25,15,26,15,25,15,25,15,26,15,25,15,26,54,26,13,27,13,26,15,25,15,26,15,25,13,27,54,26,15,26,54,26,54,27,54,26,54,27,54,26,54,27,2500)
Dim AirConOff() As Int = Array As Int(173,160,27,54,26,15,26,54,26,54,27,14,26,15,26,53,27,15,25,15,26,54,26,15,26,15,25,54,27,54,26,15,26,54,26,15,26,54,26,54,27,54,26,54,27,15,25,55,26,54,26,54,27,15,26,14,26,15,25,15,25,54,27,15,25,15,26,54,26,55,26,54,27,14,26,15,25,13,26,15,26,15,25,15,26,15,25,15,25,55,26,54,27,54,26,54,27,54,27,206,174,160,27,54,26,15,26,54,26,54,27,15,25,15,25,55,26,15,26,15,25,54,27,14,26,15,25,54,27,54,26,15,26,54,26,15,26,55,26,54,27,53,27,54,27,14,26,54,26,55,26,54,27,15,25,15,25,15,26,15,25,54,27,14,26,15,26,54,26,54,27,54,26,15,26,15,25,15,25,15,26,15,25,15,26,14,26,13,26,54,27,54,26,55,26,54,26,55,26,2500)
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("main")
gr.Initialize("")
End Sub
Sub Activity_Resume
gr.StartInfraRed
End Sub
Sub Activity_Pause (UserClosed As Boolean)
gr.StopInfraRed
End Sub
Sub Button1_Click
'Using the first command
gr.Command(frequency,AirConOn)
End Sub
Sub Button2_Click
'Using the second command
gr.Command(frequency,AirConOff)
End Sub
'Add from here onwards more buttons for the other 48 available command
Library:
GeneralIRcontrol
Author: Github: Andrew (andrew-brill), Wrapped by: Johan Schoeman
Version: 1
- GeneralIRcontrol
Methods:- Command (frequency As Int, data() As Int)
- Initialize (paramString As String)
- StartInfraRed
- StopInfraRed
- android.permission.TRANSMIT_IR
You can try this to see if it will switch On/Off a Samsung TV
Frequency = 38000
ints = 173,173,22,65,22,65,22,65,22,22,22,22,22,22,22,22,22,22,22,65,22,65,22,65,22,22,22,22,22,22,22,22,22,22,22,22,22,65,22,22,22,22,22,22,22,22,22,22,22,22,22,65,22,22,22,65,22,65,22,65,22,65,22,65,22,65,22,5000
Attachments
Last edited: