Skip to content

Commit 56c6e66

Browse files
committed
Changed TOLERANCE TOLERANCE_FOR_DECODERS_MARK_OR_SPACE_MATCHING and documented it
1 parent bd99281 commit 56c6e66

File tree

7 files changed

+14
-13
lines changed

7 files changed

+14
-13
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,7 @@ Modify them by enabling / disabling them, or change the values if applicable.
362362
| `IR_INPUT_IS_ACTIVE_HIGH` | disabled | Enable it if you use a RF receiver, which has an active HIGH output signal. |
363363
| `IR_SEND_DUTY_CYCLE_PERCENT` | 30 | Duty cycle of IR send signal. |
364364
| `MICROS_PER_TICK` | 50 | Resolution of the raw input buffer data. Corresponds to 2 pulses of each 26.3 µs at 38 kHz. |
365+
| `TOLERANCE_FOR_DECODERS_MARK_OR_SPACE_MATCHING` | 25 | Relative tolerance (in percent) for matchTicks(), matchMark() and matchSpace() functions used for protocol decoding. |
365366
| `DEBUG` | disabled | Enables lots of lovely debug output. |
366367
| `IR_USE_AVR_TIMER*` | | Selection of timer to be used for generating IR receiving sample interval. |
367368
@@ -499,7 +500,7 @@ The reason is, that it is not the pure energy of the fundamental which is respon
499500
Due to automatic gain control and other bias effects, high intensity of the 38 kHz pulse counts more than medium intensity (e.g. 50% duty cycle) at the same total energy.
500501

501502
## Increase sending power
502-
**The best way to increase the IR power** is to use 2 or 3 IR diodes in series. One diode requires 1.1 to 1.5 volt so you can supply 3 diodes with a 5 volt output.<br/>
503+
**The best way to increase the IR power for free** is to use 2 or 3 IR diodes in series. One diode requires 1.1 to 1.5 volt so you can supply 3 diodes with a 5 volt output.<br/>
503504
To keep the current for 2 diodes with 1.3 volt and 25 mA and a 5 volt supply, you must reduce the resistor by factor: (5V - 1.3V) / (5V - 2.6V) = 1.5 e.g. from 150 ohm to 100 ohm.<br/>
504505
For 3 diodes it requires factor 2.5 e.g. from 150 ohm to 60 ohm.<br/>
505506
Or compute it directly with the **U = R * I formula**. Here U is (5V - <number_of_diodes> * 1.3V) at moderate current, at higher currents you must choose more than 1.3 volt. If you want to be exact, you must check the datasheet of your diode for the appropriate **forward voltage fo a given current**.

examples/IRremoteInfo/IRremoteInfo.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ void dumpPulseParams() {
188188
;
189189
Serial.println(F(" uSecs"));
190190
Serial.print(F("Measurement tolerance: "));
191-
Serial.print(TOLERANCE);
191+
Serial.print(TOLERANCE_FOR_DECODERS_MARK_OR_SPACE_MATCHING);
192192
Serial.println(F("%"));
193193
}
194194

src/IRReceive.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,7 @@ uint8_t IRrecv::getBiphaselevel() {
651651
* Internal Hash decode function
652652
**********************************************************************************************************************/
653653
/**
654-
* Compare two (tick) values
654+
* Compare two (tick) values for Hash decoder
655655
* Use a tolerance of 20% to enable e.g. 500 and 600 (NEC timing) to be equal
656656
* @return 0 if newval is shorter, 1 if newval is equal, and 2 if newval is longer
657657
*/

src/IRremoteInt.h

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -360,24 +360,25 @@ void setBlinkPin(uint8_t aFeedbackLEDPin) __attribute__ ((deprecated ("Please us
360360
* First MARK is the one after the long gap
361361
* Pulse parameters in microseconds
362362
*/
363-
/** Relative tolerance (in percent) for some comparisons on measured data. */
364-
#define TOLERANCE 25
363+
#if !defined(TOLERANCE_FOR_DECODERS_MARK_OR_SPACE_MATCHING)
364+
#define TOLERANCE_FOR_DECODERS_MARK_OR_SPACE_MATCHING 25 // Relative tolerance (in percent) for matchTicks(), matchMark() and matchSpace() functions used for protocol decoding.
365+
#endif
365366

366367
/** Lower tolerance for comparison of measured data */
367368
//#define LTOL (1.0 - (TOLERANCE/100.))
368-
#define LTOL (100 - TOLERANCE)
369+
#define LTOL (100 - TOLERANCE_FOR_DECODERS_MARK_OR_SPACE_MATCHING)
369370
/** Upper tolerance for comparison of measured data */
370371
//#define UTOL (1.0 + (TOLERANCE/100.))
371-
#define UTOL (100 + TOLERANCE)
372+
#define UTOL (100 + TOLERANCE_FOR_DECODERS_MARK_OR_SPACE_MATCHING)
372373

373374
//#define TICKS_LOW(us) ((int)(((us)*LTOL/MICROS_PER_TICK)))
374375
//#define TICKS_HIGH(us) ((int)(((us)*UTOL/MICROS_PER_TICK + 1)))
375-
#if MICROS_PER_TICK == 50 && TOLERANCE == 25 // Defaults
376+
#if MICROS_PER_TICK == 50 && TOLERANCE_FOR_DECODERS_MARK_OR_SPACE_MATCHING == 25 // Defaults
376377
#define TICKS_LOW(us) ((us)/67 ) // (us) / ((MICROS_PER_TICK:50 / LTOL:75 ) * 100)
377378
#define TICKS_HIGH(us) (((us)/40) + 1) // (us) / ((MICROS_PER_TICK:50 / UTOL:125) * 100) + 1
378379
#else
379-
#define TICKS_LOW(us) ((uint16_t) ((long) (us) * LTOL / (MICROS_PER_TICK * 100) ))
380-
#define TICKS_HIGH(us) ((uint16_t) ((long) (us) * UTOL / (MICROS_PER_TICK * 100) + 1))
380+
#define TICKS_LOW(us) ((uint16_t) ((long) (us) * LTOL / (MICROS_PER_TICK * 100) ))
381+
#define TICKS_HIGH(us) ((uint16_t) ((long) (us) * UTOL / (MICROS_PER_TICK * 100) + 1))
381382
#endif
382383

383384
/*

src/TinyIRReceiver.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@
5050
#include <Arduino.h>
5151

5252
#include "TinyIRReceiver.h" // If not defined, it defines IR_INPUT_PIN, IR_FEEDBACK_LED_PIN and TINY_RECEIVER_USE_ARDUINO_ATTACH_INTERRUPT
53-
//#define NO_LED_FEEDBACK_CODE // Activate this if you want to suppress LED feedback or if you do not have a LED. This saves 2 bytes code and 2 clock cycles per interrupt.
5453

5554
#include "digitalWriteFast.h"
5655
/** \addtogroup TinyReceiver Minimal receiver for NEC protocol

src/ir_NEC.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
// see: https://www.sbprojects.net/knowledge/ir/nec.php
5252
// for Apple see https://en.wikipedia.org/wiki/Apple_Remote
5353
// ONKYO like NEC but 16 independent command bits
54-
// LSB first, 1 start bit + 16 bit address + 8 bit command + 8 bit inverted command + 1 stop bit.
54+
// LSB first, 1 start bit + 16 bit address (or 8 bit address and 8 bit inverted address) + 8 bit command + 8 bit inverted command + 1 stop bit.
5555
//
5656
#define NEC_ADDRESS_BITS 16 // 16 bit address or 8 bit address and 8 bit inverted address
5757
#define NEC_COMMAND_BITS 16 // Command and inverted command

src/ir_Pronto.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ void IRsend::sendPronto(const uint16_t *data, unsigned int length, uint_fast8_t
104104
uint16_t durations[intros + repeats];
105105
for (unsigned int i = 0; i < intros + repeats; i++) {
106106
uint32_t duration = ((uint32_t) data[i + numbersInPreamble]) * timebase;
107-
durations[i] = (unsigned int) ((duration <= __UINT16_MAX__) ? duration : __UINT16_MAX__);
107+
durations[i] = (unsigned int) ((duration <= UINT16_MAX) ? duration : UINT16_MAX);
108108
}
109109

110110
/*

0 commit comments

Comments
 (0)