Go to the documentation of this file.
37 #define VERSION_TINYIR "2.1.0"
38 #define VERSION_TINYIR_MAJOR 2
39 #define VERSION_TINYIR_MINOR 1
40 #define VERSION_TINYIR_PATCH 0
49 #if !defined(NEC_ADDRESS_BITS)
50 #define NEC_ADDRESS_BITS 16 // 16 bit address or 8 bit address and 8 bit inverted address
51 #define NEC_COMMAND_BITS 16 // Command and inverted command
52 #define NEC_BITS (NEC_ADDRESS_BITS + NEC_COMMAND_BITS)
56 #define NEC_HEADER_MARK (16 * NEC_UNIT) // 9000
57 #define NEC_HEADER_SPACE (8 * NEC_UNIT) // 4500
59 #define NEC_BIT_MARK NEC_UNIT
60 #define NEC_ONE_SPACE (3 * NEC_UNIT) // 1690
61 #define NEC_ZERO_SPACE NEC_UNIT
63 #define NEC_REPEAT_HEADER_SPACE (4 * NEC_UNIT) // 2250
65 #define NEC_REPEAT_PERIOD 110000 // Commands are repeated every 110 ms (measured from start to start) for as long as the key on the remote control is held down.
66 #define NEC_MINIMAL_DURATION 49900 // NEC_HEADER_MARK + NEC_HEADER_SPACE + 32 * 2 * NEC_UNIT + NEC_UNIT // 2.5 because we assume more zeros than ones
67 #define NEC_MAXIMUM_REPEAT_DISTANCE (NEC_REPEAT_PERIOD - NEC_MINIMAL_DURATION + 10000) // 70 ms
90 #define FAST_ADDRESS_BITS 0 // No address
91 #define FAST_COMMAND_BITS 16 // Command and inverted command (parity)
92 #define FAST_BITS (FAST_ADDRESS_BITS + FAST_COMMAND_BITS)
94 #define FAST_UNIT 526 // 20 periods of 38 kHz (526.315789)
96 #define FAST_BIT_MARK FAST_UNIT
97 #define FAST_ONE_SPACE (3 * FAST_UNIT) // 1578 -> bit period = 2104
98 #define FAST_ZERO_SPACE FAST_UNIT // 526 -> bit period = 1052
100 #define FAST_HEADER_MARK (4 * FAST_UNIT) // 2104
101 #define FAST_HEADER_SPACE (2 * FAST_UNIT) // 1052
103 #define FAST_REPEAT_PERIOD 50000 // Commands are repeated every 50 ms (measured from start to start) for as long as the key on the remote control is held down.
104 #define FAST_REPEAT_DISTANCE (FAST_REPEAT_PERIOD - (55 * FAST_UNIT)) // 19 ms
105 #define FAST_MAXIMUM_REPEAT_DISTANCE (FAST_REPEAT_DISTANCE + 10000) // 29 ms
110 #if defined(USE_FAST_PROTOCOL)
111 #define ENABLE_NEC2_REPEATS // Disables detection of special short frame NEC repeats. Saves 40 bytes program memory.
113 #define TINY_RECEIVER_ADDRESS_BITS FAST_ADDRESS_BITS
114 #define TINY_RECEIVER_COMMAND_BITS FAST_COMMAND_BITS
115 #if !defined(TINY_RECEIVER_COMMAND_HAS_8_BIT_PARITY)
116 #define TINY_RECEIVER_COMMAND_HAS_8_BIT_PARITY true // 8 bit and 8 bit parity
120 #define TINY_RECEIVER_BITS FAST_BITS
121 #define TINY_RECEIVER_UNIT FAST_UNIT
123 #define TINY_RECEIVER_HEADER_MARK FAST_HEADER_MARK
124 #define TINY_RECEIVER_HEADER_SPACE FAST_HEADER_SPACE
126 #define TINY_RECEIVER_BIT_MARK FAST_BIT_MARK
127 #define TINY_RECEIVER_ONE_SPACE FAST_ONE_SPACE
128 #define TINY_RECEIVER_ZERO_SPACE FAST_ZERO_SPACE
130 #define TINY_RECEIVER_MAXIMUM_REPEAT_DISTANCE FAST_MAXIMUM_REPEAT_DISTANCE // for repeat detection
134 #define TINY_RECEIVER_ADDRESS_BITS NEC_ADDRESS_BITS // the address bits + parity
135 # if defined(USE_ONKYO_PROTOCOL)
136 #define TINY_RECEIVER_ADDRESS_HAS_8_BIT_PARITY false // 16 bit address without parity
137 # elif defined(USE_EXTENDED_NEC_PROTOCOL)
138 #define TINY_RECEIVER_ADDRESS_HAS_8_BIT_PARITY false // 16 bit address without parity
140 #define TINY_RECEIVER_ADDRESS_HAS_8_BIT_PARITY true // 8 bit and 8 bit parity
143 #define TINY_RECEIVER_COMMAND_BITS NEC_COMMAND_BITS // the command bits + parity
144 # if defined(USE_ONKYO_PROTOCOL)
145 #define TINY_RECEIVER_COMMAND_HAS_8_BIT_PARITY false // 16 bit command without parity
147 #define TINY_RECEIVER_COMMAND_HAS_8_BIT_PARITY true // 8 bit and 8 bit parity
150 #define TINY_RECEIVER_BITS NEC_BITS
151 #define TINY_RECEIVER_UNIT NEC_UNIT
153 #define TINY_RECEIVER_HEADER_MARK NEC_HEADER_MARK
154 #define TINY_RECEIVER_HEADER_SPACE NEC_HEADER_SPACE
156 #define TINY_RECEIVER_BIT_MARK NEC_BIT_MARK
157 #define TINY_RECEIVER_ONE_SPACE NEC_ONE_SPACE
158 #define TINY_RECEIVER_ZERO_SPACE NEC_ZERO_SPACE
160 #define TINY_RECEIVER_MAXIMUM_REPEAT_DISTANCE NEC_MAXIMUM_REPEAT_DISTANCE
163 #if defined(USE_CALLBACK_FOR_TINY_RECEIVER)
168 extern void handleReceivedTinyIRData();
171 #if !defined(MICROS_IN_ONE_SECOND)
172 #define MICROS_IN_ONE_SECOND 1000000L
175 #if !defined(MICROS_IN_ONE_MILLI)
176 #define MICROS_IN_ONE_MILLI 1000L
182 #define lowerValue25Percent(aDuration) (aDuration - (aDuration / 4))
183 #define upperValue25Percent(aDuration) (aDuration + (aDuration / 4))
184 #define lowerValue50Percent(aDuration) (aDuration / 2) // (aDuration - (aDuration / 2))
185 #define upperValue50Percent(aDuration) (aDuration + (aDuration / 2))
190 #define IR_RECEIVER_STATE_WAITING_FOR_START_MARK 0
191 #define IR_RECEIVER_STATE_WAITING_FOR_START_SPACE 1
192 #define IR_RECEIVER_STATE_WAITING_FOR_FIRST_DATA_MARK 2
193 #define IR_RECEIVER_STATE_WAITING_FOR_DATA_SPACE 3
194 #define IR_RECEIVER_STATE_WAITING_FOR_DATA_MARK 4
195 #define IR_RECEIVER_STATE_WAITING_FOR_STOP_MARK 5
209 #if (TINY_RECEIVER_BITS > 16)
223 #define IRDATA_FLAGS_EMPTY 0x00
224 #define IRDATA_FLAGS_IS_REPEAT 0x01
225 #define IRDATA_FLAGS_IS_AUTO_REPEAT 0x02 // not used here, overwritten with _IRDATA_FLAGS_IS_SHORT_REPEAT
226 #define IRDATA_FLAGS_PARITY_FAILED 0x04
232 #if (TINY_RECEIVER_ADDRESS_BITS > 0)
233 # if (TINY_RECEIVER_ADDRESS_BITS == 16) && !TINY_RECEIVER_ADDRESS_HAS_8_BIT_PARITY
240 # if (TINY_RECEIVER_COMMAND_BITS == 16) && !TINY_RECEIVER_COMMAND_HAS_8_BIT_PARITY
257 void sendFAST(uint8_t aSendPin, uint16_t aCommand, uint_fast8_t aNumberOfRepeats = 0);
259 void sendONKYO(uint8_t aSendPin, uint16_t aAddress, uint16_t aCommand, uint_fast8_t aNumberOfRepeats = 0,
bool aSendNEC2Repeats =
false);
260 void sendNECMinimal(uint8_t aSendPin, uint16_t aAddress, uint16_t aCommand, uint_fast8_t aNumberOfRepeats = 0)
261 __attribute__ ((deprecated ("Renamed to
sendNEC().")));
262 void sendNEC(uint8_t aSendPin, uint16_t aAddress, uint16_t aCommand, uint_fast8_t aNumberOfRepeats = 0,
bool aSendNEC2Repeats = false);
263 void sendExtendedNEC(uint8_t aSendPin, uint16_t aAddress, uint16_t aCommand, uint_fast8_t aNumberOfRepeats = 0,
bool aSendNEC2Repeats = false);
Union to specify parts / manifestations of a 32 bit Long without casts and shifts.
uint8_t IRReceiverState
The state of the state machine.
void sendNECMinimal(uint8_t aSendPin, uint16_t aAddress, uint16_t aCommand, uint_fast8_t aNumberOfRepeats=0) __attribute__((deprecated("Renamed to sendNEC().")))
Union to specify parts / manifestations of a 16 bit Word without casts and shifts.
Control and data variables of the state machine for TinyReceiver.
uint8_t Flags
One of IRDATA_FLAGS_EMPTY, IRDATA_FLAGS_IS_REPEAT, and IRDATA_FLAGS_PARITY_FAILED.
bool enablePCIInterruptForTinyReceiver()
Initializes hardware interrupt generation according to IR_RECEIVE_PIN or use attachInterrupt() functi...
volatile TinyIRReceiverCallbackDataStruct TinyIRReceiverData
bool isTinyReceiverIdle()
void disablePCIInterruptForTinyReceiver()
bool justWritten
Is set true if new data is available. Used by the main loop, to avoid multiple evaluations of the sam...
uint32_t LastChangeMicros
Microseconds of last Pin Change Interrupt.
uint32_t IRRawDataMask
The corresponding bit mask for IRRawDataBitCounter.
Is filled before calling the user callback to transfer received data to main loop for further process...
void sendNEC(uint8_t aSendPin, uint16_t aAddress, uint16_t aCommand, uint_fast8_t aNumberOfRepeats=0, bool aSendNEC2Repeats=false)
void printTinyReceiverResultMinimal(Print *aSerial)
uint8_t IRRawDataBitCounter
How many bits are currently contained in raw data.
void sendFast8BitAndParity(uint8_t aSendPin, uint8_t aCommand, uint_fast8_t aNumberOfRepeats=0)
void sendONKYO(uint8_t aSendPin, uint16_t aAddress, uint16_t aCommand, uint_fast8_t aNumberOfRepeats=0, bool aSendNEC2Repeats=false)
bool isIRReceiverAttachedForTinyReceiver()
void sendExtendedNEC(uint8_t aSendPin, uint16_t aAddress, uint16_t aCommand, uint_fast8_t aNumberOfRepeats=0, bool aSendNEC2Repeats=false)
void sendFAST(uint8_t aSendPin, uint16_t aCommand, uint_fast8_t aNumberOfRepeats=0)
LongUnion IRRawData
The current raw data. LongUnion helps with decoding of address and command.
bool initPCIInterruptForTinyReceiver()
Sets IR_RECEIVE_PIN mode to INPUT, and if IR_FEEDBACK_LED_PIN is defined, sets feedback LED output mo...