Infrared Remote Control Library

Used to capture and decode signals from the infrared remote control sensor.

int IRTVInit(int type, int length, int tog_mask, int inv_mask, int mode, int bufsize, int delay);
        Input:          (type) the used code type
                        Valid values are: SPACE_CODE, PULSE_CODE, MANCHESTER_CODE, RAW_CODE
                        (length) code length (number of bits)
                        (tog_mask) the bitmask that selects the "toggle bits" in a code
                                   (bits that change when the same key is pressed repeatedly)
                        (inv_mask) the bitmask that selects the inverted bits in a code
                                   (for remote controls with alternating codes)
                        (mode) operation mode
                        Valid values are: DEFAULT_MODE, SLOPPY_MODE, REPCODE_MODE
                        (bufsize) size of the internal code buffer
                        Valid values are: 1..4
                        (delay) key repetition delay
                        >0: number of 1/100 sec (should be >20)
                        -1: no repetition
        Output:         (returncode)
                        0 = ok
                        1 = illegal type or mode
                        2 = invalid or missing "IRTV" HDT entry
        Semantics:      Initializes the IR remote control decoder.
                        To find out the correct values for the "type", "length", "tog_mask",
                        "inv_mask" and "mode" parameters, use the IR remote control analyzer
                        program (IRCA).
                        SLOPPY_MODE can be used as an alternative to DEFAULT_MODE.
                        In default mode, at least two consecutive identical code sequences
                        must be received before the code becomes valid. When using sloppy
                        mode, no error check is performed, and every code becomes valid
                        immediately. This reduces the delay between pressing the key and
                        the reaction.
                        With remote controls that use a special repetition coding, REPCODE_MODE
                        must be used (as suggested by the analyzer).
                        
                        Typical parameters | Nokia (VCN 620)          | RC5 (Philips)
                        -------------------+--------------------------+-------------------------
                        type               | SPACE_CODE               | MANCHESTER_CODE  
                        length             | 15                       | 14
                        tog_mask           | 0                        | 0x800
                        inv_mask           | 0x3FF                    | 0
                        mode               | DEFAULT_MODE/SLOPPY_MODE | DEFAULT_MODE/SLOPPY_MODE
                        
                        The type setting RAW_CODE is intended for code analysis only. If RAW_CODE
                        is specified, all of the other parameters should be set to 0. Raw codes
                        must be handled by using the IRTVGetRaw and IRTVDecodeRaw functions.
                        
void IRTVTerm(void);
        Input:          NONE
        Output:         NONE
        Semantics:      Terminates the remote control decoder and releases the
                        occupied TPU channel.

int IRTVPressed(void);
        Input:          NONE
        Output:         (returncode)
                        Code of the remote key that is currently being pressed
                        (0 for no key).
        Semantics:      Directly reads the current remote key code. Does not
                        touch the code buffer. Does not wait.

int IRTVRead(void);
        Input:          NONE
        Output:         (returncode)
                        Next code from the buffer (0 for no key).
        Semantics:      Reads and removes the next key code from the code buffer.
                        Does not wait.

int IRTVGet(void);
        Input:          NONE
        Output:         (returncode)
                        Next code from the buffer (!=0)
        Semantics:      Reads and removes the next key code from the code buffer.
                        If the buffer is empty, the function waits until a remote
                        key is pressed.

void IRTVFlush(void);
        Input:          NONE
        Output:         NONE
        Semantics:      The code buffer is emptied.

void IRTVGetRaw(int bits[2], int *count, int *duration, int *id, int *clock);
        Input:          NONE
        Output:         (bits) contains the raw code
                               bit #0 in bits[0] represents the 1st pulse in the code sequence
                               bit #0 in bits[1] represents the 1st space
                               bit #1 in bits[0] represents the 2nd pulse
                               bit #1 in bits[1] represents the 2nd space
                               ...
                               A cleared bit stands for a short signal, a set bit for a long signal.
                        (count) the number of signals (= pulses + spaces) received
                        (duration) the logical duration of the code sequence
                                   duration = (number of short signals) + 2 * (number of long signals)
                        (id) a unique ID for the current code (incremented by 1 each time)
                        (clock) the time when the code was received
        Semantics:      Returns information about the last received raw code.
                        Works only if type setting == RAW_CODE.
                        
int IRTVDecodeRaw(const int bits[2], int count, int type);
        Input:          (bits) raw code to be decoded (see IRTVGetRaw)
                        (count) number of signals (= pulses + spaces) in the raw code
                        (type) the decoding method
                        Valid values are: SPACE_CODE, PULSE_CODE, MANCHESTER_CODE
        Output:         (returncode)
                        The decoded value (0 on an illegal Manchester code)
        Semantics:      Decodes the raw code using the given method.