IrdaHelper
Comment:
- IrdaHelper creates a common interface to both IrdaManager and ConsumerIrManager.
IrdaManager exposes the hidden Samsung IrdaManager API to B4A.
ConsumerIrManager allows you to:
Check whether the device has an infrared emitter.
Query it's carrier frequencies.
Send infrared signals.
CarrierFrequencyRange represents a range of carrier frequencies (inclusive) on which the infrared transmitter can transmit.
ConsumerIrManager and CarrierFrequencyRange are only available when using android API 19+.
CarrierFrequencyRange
Methods:
- GetMaxFrequency As Int
Get the maximum (inclusive) frequency in this range segment.
- GetMinFrequency As Int
Get the minimum (inclusive) frequency in this range segment.
- Initialize (ConsumerIrManager1 As ConsumerIrManager, MinFrequency As Int, MaxFrequency As Int)
Create a segment of a carrier frequency range.
- IsInitialized As Boolean
ConsumerIrManager
Methods:
- GetCarrierFrequencies As CarrierFrequencyRange[]
Query the infrared transmitter's supported carrier frequencies.
Returns an array of CarrierFrequencyRange objects representing the ranges that the transmitter can support,
or Null if there was an error communicating with the Consumer IR Service.
- HasIrEmitter As Boolean
Check whether the device has an infrared emitter.
- Hex2Dec (HexData As String, Separator As String) As String
Converts a String of Hex IR codes into a String of comma separated decimal codes.
Separator denotes the separator character used in the HexData input.
- Initialize
- IsInitialized As Boolean
- Transmit (CarrierFrequency As Int, Pattern() As Int)
Transmit an infrared pattern.
This method is synchronous; when it returns the pattern has been transmitted.
Only patterns shorter than 2 seconds will be transmitted.
CarrierFrequency - The IR carrier frequency in Hertz.
Pattern - The alternating on/off pattern of pulses to transmit.
Permissions:
- android.permission.TRANSMIT_IR
IrdaHelper
Fields:
- STATE_CONSUMER_IR_MANAGER As IrdaHelperState
The ConsumerIrManager is initialized.
- STATE_IRDA_MANAGER As IrdaHelperState
The Samsung IrdaManager is initialized.
- STATE_NOT_INITIALIZED As IrdaHelperState
Neither ConsumerIrManager or IrdaManager are initialized.
Methods:
- GetConsumerIrManager As ConsumerIrManager
Returns the ConsumerIrManager if it has been initialized, otherwise Null.
- GetIrdaHelperState As IrdaHelperState
Returns the state of the IrdaHelper.
Values will be one of the STATE_???? fields.
- GetIrdaManager As IrdaManager
Returns the IrdaManager if it has been initialized, otherwise returns Null.
- GetTransmitData (CarrierFrequency As Int, Pattern() As Int) As TransmitData
Creates a TransmitData object from CarrierFrequency and Pattern.
- GetTransmitData2 (DecimalData As String) As TransmitData
Creates a TransmitData object from comma separated DecimalValues.
- GetTransmitData3 (HexData As String, Separator As String) As TransmitData
Creates a TransmitData object from HexData.
- Hex2Dec (HexData As String, Separator As String) As String
Converts a String of Hex IR codes into a String of comma separated decimal codes.
Separator denotes the separator character used in the HexData input.
- Initialize As Boolean
Initialize the IrdaHelper.
Returns a Boolean True if either:
1) The device is running android API level 19+ and has an IR emitter.
OR
2) The device is running android API level less than 19, is a Samsung device and the Samsung IrdaManager API is available
Note that on some Samsung devices the IrdaManager API is available but have no IR emitter.
- Transmit (TransmitData1 As TransmitData)
Transmits the TransmitData using using whichever object (ConsumerIrManager or IrdaManager) has been initialized.
If no object has been initialized then the Transmit method simply logs an error.
IrdaManager
Methods:
- Hex2Dec (HexData As String, Separator As String) As String
Converts a String of Hex IR codes into a String of comma separated decimal codes suitable for use with WriteIrSend.
Separator denotes the separator character used in the HexData input.
- Initialize As Boolean
Initialize the IrdaManager.
Returns True if successfully initialized, otherwise False.
If initialization fails the B4A LastException property will contain the related Exception.
- IsInitialized As Boolean
Returns whether or not the IrdaManager is initialized.
- WriteIrSend (DecimalData As String) As Boolean
Sends Data using the IrdaManager.
Returns True if successfully sent, otherwise False.
If send fails the B4A LastException property will contain the related Exception.
TransmitData
Properties:
- CarrierFrequency As Int [read only]
Returns the CarrierFrequency.
Only available if the IrdaHelperState is STATE_CONSUMER_IR_MANAGER.
- DecimalData As String [read only]
Returns the comma separated DecimalData.
Only available if the IrdaHelperState is STATE_IRDA_MANAGER.
- Pattern() As Int [read only]
Returns the Pattern.
Only available if the IrdaHelperState is STATE_CONSUMER_IR_MANAGER.