com.phidgets
Class IRPhidget

java.lang.Object
  extended bycom.phidgets.Phidget
      extended bycom.phidgets.IRPhidget

public final class IRPhidget
extends Phidget

This class represents a Phidget IR. All methods to send and receive IR data are implemented in this class.

The Phidget IR Receiver-Transmitter can send and receive Consumer-IR signals. Ability to learn and re-transmit codes, as well as low-level access to raw data, is provided.

Author:
Phidgets Inc.

Field Summary
static int RAWDATA_LONGSPACE
          Represents a long space (greater then 327,670 microseconds) in raw data.
 
Fields inherited from class com.phidgets.Phidget
PHIDCLASS_ACCELEROMETER, PHIDCLASS_ADVANCEDSERVO, PHIDCLASS_ANALOG, PHIDCLASS_BRIDGE, PHIDCLASS_ENCODER, PHIDCLASS_FREQUENCYCOUNTER, PHIDCLASS_GPS, PHIDCLASS_INTERFACEKIT, PHIDCLASS_LED, PHIDCLASS_MOTORCONTROL, PHIDCLASS_NOTHING, PHIDCLASS_PHSENSOR, PHIDCLASS_RFID, PHIDCLASS_SERVO, PHIDCLASS_STEPPER, PHIDCLASS_TEMPERATURESENSOR, PHIDCLASS_TEXTLCD, PHIDCLASS_TEXTLED, PHIDCLASS_WEIGHTSENSOR, PHIDGET_LOG_CRITICAL, PHIDGET_LOG_DEBUG, PHIDGET_LOG_ERROR, PHIDGET_LOG_INFO, PHIDGET_LOG_VERBOSE, PHIDGET_LOG_WARNING, PHIDID_ACCELEROMETER_2AXIS, PHIDID_ACCELEROMETER_3AXIS, PHIDID_ADVANCEDSERVO_1MOTOR, PHIDID_ADVANCEDSERVO_8MOTOR, PHIDID_ANALOG_4OUTPUT, PHIDID_BIPOLAR_STEPPER_1MOTOR, PHIDID_BRIDGE_4INPUT, PHIDID_ENCODER_1ENCODER_1INPUT, PHIDID_ENCODER_HS_1ENCODER, PHIDID_ENCODER_HS_4ENCODER_4INPUT, PHIDID_FREQUENCYCOUNTER_2INPUT, PHIDID_GPS, PHIDID_INTERFACEKIT_0_0_4, PHIDID_INTERFACEKIT_0_0_8, PHIDID_INTERFACEKIT_0_16_16, PHIDID_INTERFACEKIT_0_8_8_w_LCD, PHIDID_INTERFACEKIT_2_2_2, PHIDID_INTERFACEKIT_4_8_8, PHIDID_INTERFACEKIT_8_8_8, PHIDID_INTERFACEKIT_8_8_8_w_LCD, PHIDID_IR, PHIDID_LED_64, PHIDID_LED_64_ADV, PHIDID_LINEAR_TOUCH, PHIDID_MOTORCONTROL_1MOTOR, PHIDID_MOTORCONTROL_HC_2MOTOR, PHIDID_MOTORCONTROL_LV_2MOTOR_4INPUT, PHIDID_NOTHING, PHIDID_PHSENSOR, PHIDID_RFID, PHIDID_RFID_2OUTPUT, PHIDID_RFID_2OUTPUT_READ_WRITE, PHIDID_ROTARY_TOUCH, PHIDID_SERVO_1MOTOR, PHIDID_SERVO_1MOTOR_OLD, PHIDID_SERVO_4MOTOR, PHIDID_SERVO_4MOTOR_OLD, PHIDID_SPATIAL_ACCEL_3AXIS, PHIDID_SPATIAL_ACCEL_GYRO_COMPASS, PHIDID_TEMPERATURESENSOR, PHIDID_TEMPERATURESENSOR_4, PHIDID_TEMPERATURESENSOR_IR, PHIDID_TEXTLCD_2x20, PHIDID_TEXTLCD_2x20_w_0_8_8, PHIDID_TEXTLCD_2x20_w_8_8_8, PHIDID_TEXTLCD_ADAPTER, PHIDID_TEXTLED_1x8, PHIDID_TEXTLED_4x8, PHIDID_UNIPOLAR_STEPPER_4MOTOR, PHIDID_WEIGHTSENSOR
 
Constructor Summary
IRPhidget()
           
 
Method Summary
 void addCodeListener(CodeListener l)
          Adds a code listener.
 void addLearnListener(LearnListener l)
          Adds a code learn listener.
 void addRawDataListener(RawDataListener l)
          Adds a rawData listener.
 IRCode getLastCode()
          Returns the last received code.
 IRLearnedCode getLastLearnedCode()
          Returns the last learned code.
 int readRaw(int[] buffer)
          Reads raw data.
 int readRaw(int[] buffer, int offset, int count)
          Reads raw data.
 void removeCodeListener(CodeListener l)
           
 void removeLearnListener(LearnListener l)
           
 void removeRawDataListener(RawDataListener l)
           
 void transmit(IRCode code, IRCodeInfo codeInfo)
          Transmits a code.
 void transmitRaw(int[] data)
          Transmits raw data.
 void transmitRaw(int[] data, int gap)
          Transmits raw data.
 void transmitRaw(int[] data, int offset, int count)
          Transmits raw data.
 void transmitRaw(int[] data, int offset, int count, int gap)
          Transmits raw data.
 void transmitRaw(int[] data, int offset, int count, int gap, int carrierFrequency, int dutyCycle)
          Transmits raw data.
 void transmitRepeat()
          Transmits a repeat.
 
Methods inherited from class com.phidgets.Phidget
addAttachListener, addDetachListener, addErrorListener, addServerConnectListener, addServerDisconnectListener, close, disableLogging, enableLogging, equals, getDeviceClass, getDeviceID, getDeviceLabel, getDeviceName, getDeviceType, getDeviceVersion, getLibraryVersion, getSerialNumber, getServerAddress, getServerID, getServerPort, isAttached, isAttachedToServer, log, open, open, open, open, open, openAny, openAny, openAny, openAny, openAny, openLabel, openLabel, openLabel, openLabel, openLabel, removeAttachListener, removeDetachListener, removeErrorListener, removeServerConnectListener, removeServerDisconnectListener, setDeviceLabel, toString, waitForAttachment, waitForAttachment
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

RAWDATA_LONGSPACE

public static final int RAWDATA_LONGSPACE
Represents a long space (greater then 327,670 microseconds) in raw data. This can be considered a period of no IR activity. This is used with readRaw

See Also:
Constant Field Values
Constructor Detail

IRPhidget

public IRPhidget()
          throws PhidgetException
Method Detail

transmit

public void transmit(IRCode code,
                     IRCodeInfo codeInfo)
              throws PhidgetException
Transmits a code.

Parameters:
code - the code to transmit
codeInfo - the code specification
Throws:
PhidgetException - If this Phidget is not opened and attached. See open for information on determining if a device is attached.

transmitRepeat

public void transmitRepeat()
                    throws PhidgetException
Transmits a repeat. This needs to be called within the gap time of a transmit to be meaningful.

Throws:
PhidgetException - If this Phidget is not opened and attached. See open for information on determining if a device is attached.

transmitRaw

public void transmitRaw(int[] data,
                        int offset,
                        int count,
                        int gap,
                        int carrierFrequency,
                        int dutyCycle)
                 throws PhidgetException
Transmits raw data.

Parameters:
data - data in microseconds, must start and end with a pulse
offset - offset in the data array to start transmitting
count - number of elements of data to transmit
gap - gap size in microseconds
carrierFrequency - carrier frequency in kHz
dutyCycle - duty cycle in percent
Throws:
PhidgetException - If this Phidget is not opened and attached. See open for information on determining if a device is attached.

transmitRaw

public final void transmitRaw(int[] data)
                       throws PhidgetException
Transmits raw data.

Parameters:
data - data in microseconds, must start and end with a pulse
Throws:
PhidgetException - If this Phidget is not opened and attached. See open for information on determining if a device is attached.

transmitRaw

public final void transmitRaw(int[] data,
                              int gap)
                       throws PhidgetException
Transmits raw data.

Parameters:
data - data in microseconds, must start and end with a pulse
gap - gap size in microseconds
Throws:
PhidgetException - If this Phidget is not opened and attached. See open for information on determining if a device is attached.

transmitRaw

public final void transmitRaw(int[] data,
                              int offset,
                              int count)
                       throws PhidgetException
Transmits raw data.

Parameters:
data - data in microseconds, must start and end with a pulse
offset - offset in the data array to start transmitting
count - number of elements of data to transmit
Throws:
PhidgetException - If this Phidget is not opened and attached. See open for information on determining if a device is attached.

transmitRaw

public final void transmitRaw(int[] data,
                              int offset,
                              int count,
                              int gap)
                       throws PhidgetException
Transmits raw data.

Parameters:
data - data in microseconds, must start and end with a pulse
offset - offset in the data array to start transmitting
count - number of elements of data to transmit
gap - gap size in microseconds
Throws:
PhidgetException - If this Phidget is not opened and attached. See open for information on determining if a device is attached.

readRaw

public int readRaw(int[] buffer,
                   int offset,
                   int count)
            throws PhidgetException
Reads raw data. Use RAWDATA_LONGSPACE to detect gaps in IR data.

Parameters:
buffer - array into which data will be read.
offset - offset in data to start writing
count - maximum ammount of data to read
Returns:
ammount of data read
Throws:
PhidgetException - If this Phidget is not opened and attached. See open for information on determining if a device is attached.

readRaw

public final int readRaw(int[] buffer)
                  throws PhidgetException
Reads raw data. Use RAWDATA_LONGSPACE to detect gaps in IR data.

Parameters:
buffer - array into which data will be read.
Returns:
ammount of data read
Throws:
PhidgetException - If this Phidget is not opened and attached. See open for information on determining if a device is attached.

getLastCode

public IRCode getLastCode()
                   throws PhidgetException
Returns the last received code. This is updated right after the code event returns.

Returns:
last code
Throws:
PhidgetException - If this Phidget is not opened and attached. See open for information on determining if a device is attached.

getLastLearnedCode

public IRLearnedCode getLastLearnedCode()
                                 throws PhidgetException
Returns the last learned code. This is updated right after the learn event returns.

Returns:
last learned code
Throws:
PhidgetException - If this Phidget is not opened and attached. See open for information on determining if a device is attached.

addCodeListener

public final void addCodeListener(CodeListener l)
Adds a code listener. The code handler is a method that will be called when a new code is seen by the reader. The event is fired on each code, including repetitions.

There is no limit on the number of code handlers that can be registered for a particular Phidget.

Parameters:
l - An implemetation of the CodeListener interface

removeCodeListener

public final void removeCodeListener(CodeListener l)

addLearnListener

public final void addLearnListener(LearnListener l)
Adds a code learn listener. The learn handler is a method that will be called when a new code is learned by the reader. This requires that the code be repeated several times.

There is no limit on the number of learn handlers that can be registered for a particular Phidget.

Parameters:
l - An implemetation of the LearnListener interface

removeLearnListener

public final void removeLearnListener(LearnListener l)

addRawDataListener

public final void addRawDataListener(RawDataListener l)
Adds a rawData listener. The rawData handler is a method that will be called when a raw IR data is received.

There is no limit on the number of rawData handlers that can be registered for a particular Phidget.

Parameters:
l - An implemetation of the RawDataListener interface

removeRawDataListener

public final void removeRawDataListener(RawDataListener l)