wpi-32u4-library
|
#include <IRdecoder.h>
Public Member Functions | |
IRDecoder (uint8_t p) | |
void | init (void) |
void | handleIRsensor (void) |
uint32_t | getCode (void) |
int16_t | getKeyCode (bool acceptRepeat=false) |
Private Types | |
enum | IR_STATE { IR_READY , IR_PREAMBLE , IR_REPEAT , IR_ACTIVE , IR_COMPLETE , IR_ERROR } |
Private Attributes | |
uint8_t | pin = -1 |
IR_STATE | state = IR_READY |
volatile uint32_t | lastReceiveTime = 0 |
volatile uint32_t | currCode = 0 |
volatile uint8_t | index = 0 |
volatile uint32_t | fallingEdge = 0 |
volatile uint32_t | risingEdge = 0 |
volatile uint32_t | lastRisingEdge = 0 |
A class to interpret IR remotes with NEC encoding.
NEC encoding sends four bytes: [device ID, ~divice ID, key code, ~key code]
Sending the inverse allow for easy error checking (and reduces saturation in the receiver).
Codes are send in little endian; this library reverses upon reception, so the first bit received is in the LSB of currCode. That means that the key code is found in bits [23..16] of currCode
https://techdocs.altium.com/display/FPGA/NEC+Infrared+Transmission+Protocol
This does not interpret the codes into which key was pressed. That needs to be mapped on a remote by remote basis.
Definition at line 20 of file IRdecoder.h.
|
private |
Enumerator | |
---|---|
IR_READY | |
IR_PREAMBLE | |
IR_REPEAT | |
IR_ACTIVE | |
IR_COMPLETE | |
IR_ERROR |
Definition at line 25 of file IRdecoder.h.
|
inline |
Definition at line 50 of file IRdecoder.h.
|
inline |
Definition at line 54 of file IRdecoder.h.
References currCode, IR_COMPLETE, IR_READY, IR_REPEAT, and state.
|
inline |
Definition at line 65 of file IRdecoder.h.
References currCode, IR_COMPLETE, IR_READY, IR_REPEAT, and state.
Referenced by loop().
void IRDecoder::handleIRsensor | ( | void | ) |
Definition at line 32 of file IRdecoder.cpp.
References currCode, fallingEdge, index, IR_ACTIVE, IR_COMPLETE, IR_ERROR, IR_PREAMBLE, IR_REPEAT, lastReceiveTime, lastRisingEdge, pin, risingEdge, and state.
Referenced by handleIRsensor(), and init().
void IRDecoder::init | ( | void | ) |
Definition at line 12 of file IRdecoder.cpp.
References attachPCInt(), digitalPinToPCInterrupt(), handleIRsensor(), and pin.
Referenced by setup().
|
private |
Definition at line 39 of file IRdecoder.h.
Referenced by getCode(), getKeyCode(), and handleIRsensor().
|
private |
Definition at line 42 of file IRdecoder.h.
Referenced by handleIRsensor().
|
private |
Definition at line 40 of file IRdecoder.h.
Referenced by handleIRsensor().
|
private |
Definition at line 37 of file IRdecoder.h.
Referenced by handleIRsensor().
|
private |
Definition at line 45 of file IRdecoder.h.
Referenced by handleIRsensor().
|
private |
Definition at line 23 of file IRdecoder.h.
Referenced by handleIRsensor(), and init().
|
private |
Definition at line 43 of file IRdecoder.h.
Referenced by handleIRsensor().
Definition at line 35 of file IRdecoder.h.
Referenced by getCode(), getKeyCode(), and handleIRsensor().