public abstract class IRReceiver extends GPIOComponent
They are almost always used for remote control detection:
Inside the remote control is a matching IR LED, which emits IR pulses to tell the device to turn on, off, etc.
IR detectors have a demodulator inside that looks for modulated IR at 38KHz. Just shining an IR LED wont be detected, it has to be PWM blinking at 38KHz.
The PWM is a "carrier" pulsing. By PWM'ing it, we let the LED cool off half the time (reason 1). Another reason to use a PWM carrier is that the TV will only listen to certain frequencies of PWM. So a Sony remote at 37KHz wont be able to work with a JVC DVD player that only wants say 50KHz (reason 2). Finally, the most important reason is that by pulsing a carrier wave, you reduce the afects of ambient lighting (reason 3).
How to decode the signal when we don't have a $1000 oscilloscope ? The IR decoder such as the 1838B does us one favor, it 'filters out' the 38KHz signal so that we only get the big chunks of signal in the milliscond range. This is much easier for a microcontroller like the Raspberry Pi to handle. Thats what we do here.
Main source of informations: https://learn.adafruit.com/ir-sensor/ir-remote-signals.
Modifier and Type | Field and Description |
---|---|
static int |
MAX_PULSE
The maximum pulse we'll listen for.
|
static int |
RESOLUTION
What the timing resolution should be.
|
gpio
Constructor and Description |
---|
IRReceiver(GPIOPin pin)
Constructor for a new infrared receiver using a specific GPIO pin.
|
Modifier and Type | Method and Description |
---|---|
IRSignal |
decodeIRSignal(IRProtocol protocol,
IRSignal signal)
Returns the IRSignal from IRProtocol corresponding to the input signal,
or null if the input signal has no correspondance in the given protocol.
|
IRSignal |
detectSignal()
Polls until an infrared signal is detected and then return this signal.
|
getType
public static final int MAX_PULSE
public static final int RESOLUTION
public IRReceiver(GPIOPin pin)
pin
- the GPIO pin to use to deal with the infrared receiver.public IRSignal detectSignal()
! Attention ! Polling means ~100% of CPU for 1 core.
public IRSignal decodeIRSignal(IRProtocol protocol, IRSignal signal)
protocol
- the protocol to analyze.signal
- the signal to search in the protocol.