30 #define IRBUFSZ 12 // Length of the max packet size in bytes
31 #define RAWBUFSZ 100 // Length of raw duration buffer
34 extern "C" void TIMER3_COMPB_vect(
void) __attribute__ ((signal));
35 extern "C"
void INT2_vect(
void) __attribute__ ((signal));
37 #if defined(__BOARD_ENGDUINOV2)
38 extern "C" void TIMER1_COMPB_vect(
void) __attribute__ ((signal));
39 #elif defined(__BOARD_ENGDUINOV3)
40 extern "C" void PCINT0_vect(
void) __attribute__ ((signal));
46 volatile uint8_t rcvstate;
47 volatile uint8_t rawlen;
48 volatile uint16_t rawbuf[RAWBUFSZ];
49 volatile bool sending;
51 void mark(uint16_t time);
52 void space(uint16_t time);
60 void send(uint8_t b,
bool startstop=
true);
61 void send(uint8_t *buf,
unsigned int len,
bool startstop=
true);
62 void send(
char *buf,
unsigned int len,
bool startstop=
true);
63 void sendRaw(
unsigned int *buf,
int len);
65 int recv(uint8_t *buf, uint16_t timeout=0,
bool startstop=
true);
66 int recvRaw(uint16_t *buf, uint16_t timeout=0);
72 friend void TIMER3_COMPB_vect();
73 #if defined(__BOARD_ENGDUINOV1)
74 friend void INT2_vect();
75 #elif defined(__BOARD_ENGDUINOV2)
76 friend void TIMER1_COMPB_vect();
77 friend void INT2_vect();
78 #elif defined(__BOARD_ENGDUINOV3)
79 friend void PCINT0_vect();
87 #define STATE_BLOCKED 1
89 #define STATE_READING 3
91 #define STATE_TIMEOUT 5
96 #define GAP 5000 // 5ms without a mark = counts between code gap
102 #define DELAYOFFSET 9 // Time that delayMicroseconds is actually late by, in us.
103 #if defined(__BOARD_ENGDUINOV1) || defined(__BOARD_ENGDUINOV3)
104 #define BITTIME (600-DELAYOFFSET) // This should give us 500 us per bit
105 #define MARKSPACESPLIT 1500
106 #elif defined(__BOARD_ENGDUINOV2)
107 #define SPACETIME (500-DELAYOFFSET) // This should give us 500 us per bit
108 #define MARKTIME (50-DELAYOFFSET) // This should give us 50 us per bit if it's a mark - but we send it twice
109 #define MARKSPACESPLIT 0.9*(2*MARKTIME + SPACETIME) // This is 90% of the least amount of time a space can occupy. Marks should be way below this.
void send(uint8_t b, bool startstop=true)
Send a byte.
Definition: EngduinoIR.cpp:232
void sendRaw(unsigned int *buf, int len)
Raw send function. Provide timings for mark and space pairs.
Definition: EngduinoIR.cpp:322
Definition: EngduinoIR.h:43
int recvRaw(uint16_t *buf, uint16_t timeout=0)
Raw receive function - returns timings for inter-mark gaps.
Definition: EngduinoIR.cpp:712
void sendBit(bool b)
Send a single bit.
Definition: EngduinoIR.cpp:192
void end()
end function - switch off the IR
Definition: EngduinoIR.cpp:168
EngduinoIRClass()
Constructor.
Definition: EngduinoIR.cpp:51
void begin()
begin function - must be called before using other functions
Definition: EngduinoIR.cpp:68
int recv(uint8_t *buf, uint16_t timeout=0, bool startstop=true)
Blocking receive of an IR transmission, with optional timeout.
Definition: EngduinoIR.cpp:655