Documentation
This commit is contained in:
parent
f80a7df244
commit
1008347e33
|
@ -648,6 +648,8 @@ Click on the receiver while simulation is running to specify individual NEC IR c
|
|||
|
||||
#### UnitTest
|
||||
ReceiveDemo + SendDemo in one program. Demonstrates **receiving while sending**.
|
||||
Here you see the delay of the receiver output (blue) from the IR diode input (yellow).
|
||||
![Delay](https://github.com/Arduino-IRremote/Arduino-IRremote/blob/master/pictures/IR_UnitTest_delay.bmp)
|
||||
|
||||
# WOKWI online examples
|
||||
- [Simple receiver](https://wokwi.com/projects/338611596994544210)
|
||||
|
@ -846,7 +848,7 @@ Since each hardware timer has its dedicated output pin(s), you must change timer
|
|||
**Exeptions** are currently [ESP32, ARDUINO_ARCH_RP2040, PARTICLE and ARDUINO_ARCH_MBED](https://github.com/Arduino-IRremote/Arduino-IRremote/blob/39bdf8d7bf5b90dc221f8ae9fb3efed9f0a8a1db/examples/SimpleSender/PinDefinitionsAndMore.h#L273), where **PWM generation does not require a timer**.
|
||||
|
||||
## Why do we use 30% duty cycle for sending
|
||||
We do it according to the statement in the [Vishay datasheet](https://www.vishay.com/docs/80069/circuit.pdf):
|
||||
We [do it](https://github.com/Arduino-IRremote/Arduino-IRremote/blob/master/src/IRSend.hpp#L1192) according to the statement in the [Vishay datasheet](https://www.vishay.com/docs/80069/circuit.pdf):
|
||||
- Carrier duty cycle 50 %, peak current of emitter IF = 200 mA, the resulting transmission distance is 25 m.
|
||||
- Carrier duty cycle 10 %, peak current of emitter IF = 800 mA, the resulting transmission distance is 29 m. - Factor 1.16
|
||||
The reason is, that it is not the pure energy of the fundamental which is responsible for the receiver to detect a signal.
|
||||
|
@ -859,7 +861,7 @@ The IR signal is sampled at a **50 µs interval**. For a constant 525 &micr
|
|||
And believe me, if you send a 525 µs signal, your receiver will output something between around 400 and 700 µs!<br/>
|
||||
Therefore **we decode by default with a +/- 25% margin** using the formulas [here](https://github.com/Arduino-IRremote/Arduino-IRremote/blob/master/src/IRremoteInt.h#L376-L399).<br/>
|
||||
E.g. for the NEC protocol with its 560 µs unit length, we have TICKS_LOW = 8.358 and TICKS_HIGH = 15.0. This means, we accept any value between 8 ticks / 400 µs and 15 ticks / 750 µs (inclusive) as a mark or as a zero space. For a one space we have TICKS_LOW = 25.07 and TICKS_HIGH = 45.0.<br/>
|
||||
And since the receivers generated marks are longer or shorter than the spaces, we have introduced the [`MARK_EXCESS_MICROS` value]/https://github.com/Arduino-IRremote/Arduino-IRremote#protocolunknown)
|
||||
And since the receivers generated marks are longer or shorter than the spaces, we have introduced the [`MARK_EXCESS_MICROS` value](https://github.com/Arduino-IRremote/Arduino-IRremote#compile-options--macros-for-this-library)
|
||||
to compensate for this receiver (and signal strength as well as ambient light dependent :disappointed: ) specific deviation.<br/>
|
||||
Welcome to the world of **real world signal processing**.
|
||||
|
||||
|
|
|
@ -57,9 +57,6 @@
|
|||
|
||||
IRCommandDispatcher IRDispatcher;
|
||||
|
||||
#if defined(USE_TINY_IR_RECEIVER)
|
||||
#include "TinyIRReceiver.hpp" // included in "IRremote" library
|
||||
|
||||
#if defined(LOCAL_INFO)
|
||||
#define CD_INFO_PRINT(...) Serial.print(__VA_ARGS__);
|
||||
#define CD_INFO_PRINTLN(...) Serial.println(__VA_ARGS__);
|
||||
|
@ -68,6 +65,10 @@ IRCommandDispatcher IRDispatcher;
|
|||
#define CD_INFO_PRINTLN(...) void();
|
||||
#endif
|
||||
|
||||
#if defined(USE_TINY_IR_RECEIVER)
|
||||
#define USE_CALLBACK_FOR_TINY_RECEIVER // Call the fixed function "void handleReceivedTinyIRData()" each time a frame or repeat is received.
|
||||
#include "TinyIRReceiver.hpp" // included in "IRremote" library
|
||||
|
||||
void IRCommandDispatcher::init() {
|
||||
initPCIInterruptForTinyReceiver();
|
||||
}
|
||||
|
@ -76,25 +77,20 @@ void IRCommandDispatcher::init() {
|
|||
* This is the TinyReceiver callback function, which is called if a complete command was received
|
||||
* It checks for right address and then call the dispatcher
|
||||
*/
|
||||
#if defined(ESP8266) || defined(ESP32)
|
||||
# if defined(ESP8266) || defined(ESP32)
|
||||
IRAM_ATTR
|
||||
#endif
|
||||
void handleReceivedTinyIRData(uint8_t aAddress, uint8_t aCommand, uint8_t aFlags) {
|
||||
IRDispatcher.IRReceivedData.address = aAddress;
|
||||
IRDispatcher.IRReceivedData.command = aCommand;
|
||||
IRDispatcher.IRReceivedData.isRepeat = aFlags & IRDATA_FLAGS_IS_REPEAT;
|
||||
# endif
|
||||
void handleReceivedTinyIRData() {
|
||||
IRDispatcher.IRReceivedData.address = TinyIRReceiverData.Address;
|
||||
IRDispatcher.IRReceivedData.command = TinyIRReceiverData.Command;
|
||||
IRDispatcher.IRReceivedData.isRepeat = TinyIRReceiverData.Flags & IRDATA_FLAGS_IS_REPEAT;
|
||||
IRDispatcher.IRReceivedData.MillisOfLastCode = millis();
|
||||
|
||||
CD_INFO_PRINT(F("A=0x"));
|
||||
CD_INFO_PRINT(aAddress, HEX);
|
||||
CD_INFO_PRINT(F(" C=0x"));
|
||||
CD_INFO_PRINT(aCommand, HEX);
|
||||
if (IRDispatcher.IRReceivedData.isRepeat) {
|
||||
CD_INFO_PRINT(F("R"));
|
||||
}
|
||||
CD_INFO_PRINTLN();
|
||||
# if defined(LOCAL_INFO)
|
||||
printTinyReceiverResultMinimal(&Serial);
|
||||
# endif
|
||||
|
||||
if (aAddress == IR_ADDRESS) { // IR_ADDRESS is defined in *IRCommandMapping.h
|
||||
if (TinyIRReceiverData.Address == IR_ADDRESS) { // IR_ADDRESS is defined in *IRCommandMapping.h
|
||||
IRDispatcher.IRReceivedData.isAvailable = true;
|
||||
if(!IRDispatcher.doNotUseDispatcher) {
|
||||
/*
|
||||
|
@ -212,7 +208,7 @@ void IRCommandDispatcher::checkAndCallCommand(bool aCallBlockingCommandImmediate
|
|||
if (tIsNonBlockingCommand) {
|
||||
// short command here, just call
|
||||
CD_INFO_PRINT(F("Run non blocking command: "));
|
||||
CD_INFO_PRINTLN (tCommandName);
|
||||
CD_INFO_PRINTLN(tCommandName);
|
||||
IRMapping[i].CommandToCall();
|
||||
} else {
|
||||
if (aCallBlockingCommandImmediately && currentBlockingCommandCalled == COMMAND_EMPTY) {
|
||||
|
@ -226,7 +222,7 @@ void IRCommandDispatcher::checkAndCallCommand(bool aCallBlockingCommandImmediate
|
|||
* This call is blocking!!!
|
||||
*/
|
||||
CD_INFO_PRINT(F("Run blocking command: "));
|
||||
CD_INFO_PRINTLN (tCommandName);
|
||||
CD_INFO_PRINTLN(tCommandName);
|
||||
|
||||
IRMapping[i].CommandToCall();
|
||||
#if defined(TRACE)
|
||||
|
@ -240,7 +236,7 @@ void IRCommandDispatcher::checkAndCallCommand(bool aCallBlockingCommandImmediate
|
|||
BlockingCommandToRunNext = IRReceivedData.command;
|
||||
requestToStopReceived = true; // to stop running command
|
||||
CD_INFO_PRINT(F("Requested stop and stored blocking command "));
|
||||
CD_INFO_PRINT (tCommandName);
|
||||
CD_INFO_PRINT(tCommandName);
|
||||
CD_INFO_PRINTLN(F(" as next command to run."));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,32 +49,6 @@
|
|||
#if defined(USE_TINY_IR_RECEIVER)
|
||||
//#define NO_LED_FEEDBACK_CODE // Activate this if you want to suppress LED feedback or if you do not have a LED. This saves 14 bytes code and 2 clock cycles per interrupt.
|
||||
|
||||
/*
|
||||
* Set sensible receive pin for different CPU's
|
||||
*/
|
||||
#if defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__) || defined(__AVR_ATtiny87__) || defined(__AVR_ATtiny167__)
|
||||
#include "ATtinySerialOut.hpp" // Available as Arduino library "ATtinySerialOut"
|
||||
# if defined(ARDUINO_AVR_DIGISPARKPRO)
|
||||
#define IR_RECEIVE_PIN 9 // PA3 - on Digispark board labeled as pin 9
|
||||
# else
|
||||
#define IR_RECEIVE_PIN 0 // PCINT0
|
||||
# endif
|
||||
# elif defined(__AVR_ATtiny1616__) || defined(__AVR_ATtiny3216__) || defined(__AVR_ATtiny3217__)
|
||||
#define IR_RECEIVE_PIN 10
|
||||
# elif (defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__))
|
||||
#define IR_RECEIVE_PIN 21 // INT0
|
||||
# elif defined(ESP8266)
|
||||
#define IR_RECEIVE_PIN 14 // D5
|
||||
# elif defined(ESP32)
|
||||
#define IR_RECEIVE_PIN 15
|
||||
# elif defined(ARDUINO_ARCH_MBED) && defined(ARDUINO_ARCH_MBED_NANO)
|
||||
#define IR_RECEIVE_PIN 3 // GPIO15 Use pin 3 since pin 2|GPIO25 is connected to LED on Pi pico
|
||||
# elif defined(ARDUINO_ARCH_RP2040) // Pi Pico with arduino-pico core https://github.com/earlephilhower/arduino-pico
|
||||
#define IR_RECEIVE_PIN 15 // to be compatible with the Arduino Nano RP2040 Connect (pin3)
|
||||
# else
|
||||
#define IR_RECEIVE_PIN 2 // INT0
|
||||
# endif
|
||||
|
||||
#elif defined(USE_IRMP_LIBRARY)
|
||||
/*
|
||||
* IRMP version
|
||||
|
|
|
@ -271,7 +271,7 @@ void loop() {
|
|||
}
|
||||
}
|
||||
|
||||
// Check if the command was repeated for more than 1000 ms
|
||||
// Check if repeats of the IR command was sent for more than 1000 ms
|
||||
if (detectLongPress(1000)) {
|
||||
Serial.print(F("Command 0x"));
|
||||
Serial.print(IrReceiver.decodedIRData.command, HEX);
|
||||
|
@ -292,7 +292,9 @@ void loop() {
|
|||
unsigned long sMillisOfFirstReceive;
|
||||
bool sLongPressJustDetected;
|
||||
/**
|
||||
* @return true once after the repeated command was received for longer than aLongPressDurationMillis milliseconds, false otherwise.
|
||||
* True once we received the consecutive repeats for more than aLongPressDurationMillis milliseconds.
|
||||
* The first frame, which is no repeat, is NOT counted for the duration!
|
||||
* @return true once after the repeated IR command was received for longer than aLongPressDurationMillis milliseconds, false otherwise.
|
||||
*/
|
||||
bool detectLongPress(uint16_t aLongPressDurationMillis) {
|
||||
if (!sLongPressJustDetected && (IrReceiver.decodedIRData.flags & IRDATA_FLAGS_IS_REPEAT)) {
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 1.1 MiB |
Loading…
Reference in New Issue