Documentation
This commit is contained in:
parent
e8f8f2dd63
commit
0b66125205
22
README.md
22
README.md
|
@ -23,7 +23,27 @@ Whether you use the Adafruit Neopixel lib, or FastLED, interrupts get disabled o
|
|||
|
||||
# Supported IR Protocols
|
||||
Aiwa, BoseWave, Denon, Dish, JVC, Lego, LG, MagiQuest, Mitsubishi, NEC, Panasonic, RC5, RC6, Samsung, Sanyo, Sharp, Sony, Whynter, (Pronto).<br/>
|
||||
To receive IR signals in NEC standard format, you must comment out the line `#define USE_NEC_STANDARD` in [IRremote.h](src/IRremote.h#L74).
|
||||
Protocols can be switched off and on by changing the lines in *IRremote.h*:
|
||||
|
||||
```
|
||||
#define DECODE_<PROTOCOL_NAME> 1
|
||||
#define SEND_<PROTOCOL_NAME> 1
|
||||
```
|
||||
|
||||
# Useful defines
|
||||
You may modify the behavior of the library by changing this values in the source code or just defining a new value for compile (the latter is not possible with the Arduino IDE, so consider to use [sloeber](https://eclipse.baeyens.it).
|
||||
| Name | File | Default value | Description |
|
||||
|-|-|-|-|
|
||||
| `DEBUG` | IRremote.h | disabled | Enables lots of lovely debug output. |
|
||||
| `USE_NEC_STANDARD` | IRremote.h | disabled | Use LSB first, address/code schema for encoding. |
|
||||
| `USE_NO_SEND_PWM` | IRremote.h | disabled | Use no carrier PWM, just simulate an active low receiver signal. |
|
||||
| `USE_SOFT_SEND_PWM` | IRremote.h | disabled | Use carrier PWM generation in software, instead of hardware PWM. |
|
||||
| `PULSE_CORRECTION_MICROS` | IRremote.h | 3 | If USE_SOFT_SEND_PWM, this amount is subtracted from the on-time of the pulses. |
|
||||
| `USE_SPIN_WAIT` | IRremote.h | disabled | If USE_SOFT_SEND_PWM, use spin wait instead of delayMicros(). |
|
||||
| `RAW_BUFFER_LENGTH` | IRremoteint.h | 101 | Buffer size of raw input buffer. Must be odd! |
|
||||
| `IR_SEND_DUTY_CYCLE` | IRremoteBoardDefs.h | 30 | Duty cycle of IR send signal. |
|
||||
| `MICROS_PER_TICK` | IRremoteBoardDefs.h | 50 | Resolution of the raw input buffer data. |
|
||||
|
||||
|
||||
# Handling unknown Protocols
|
||||
## Disclaimer
|
||||
|
|
|
@ -23,18 +23,8 @@
|
|||
#define IRremote_h
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// The ISR header contains several useful macros the user may wish to use
|
||||
//
|
||||
#include "private/IRremoteInt.h"
|
||||
|
||||
#ifdef ARDUINO_ARCH_AVR
|
||||
#include <avr/pgmspace.h>
|
||||
#define HAS_FLASH_READ 1
|
||||
#define STRCPY_PF_CAST(x) (x)
|
||||
#else
|
||||
#define HAS_FLASH_READ 0
|
||||
#endif
|
||||
|
||||
/****************************************************
|
||||
* PROTOCOLS
|
||||
****************************************************/
|
||||
|
@ -200,7 +190,7 @@ struct decode_results {
|
|||
/**
|
||||
* DEPRECATED
|
||||
* Decoded value for NEC and others when a repeat code is received
|
||||
* Use Flag isRepeat instead
|
||||
* Use Flag decode_results.isRepeat (see above) instead
|
||||
*/
|
||||
#define REPEAT 0xFFFFFFFF
|
||||
|
||||
|
@ -392,7 +382,7 @@ private:
|
|||
* SENDING
|
||||
****************************************************/
|
||||
/**
|
||||
* Define to use no carrier PWM, just simulate a receiver signal.
|
||||
* Define to use no carrier PWM, just simulate an active low receiver signal.
|
||||
*/
|
||||
//#define USE_NO_SEND_PWM
|
||||
/**
|
||||
|
@ -400,7 +390,13 @@ private:
|
|||
*/
|
||||
//#define USE_SOFT_SEND_PWM
|
||||
/**
|
||||
* Define to use spin wait instead of delayMicros() for USE_SOFT_SEND_PWM.
|
||||
* If USE_SOFT_SEND_PWM, this amount is subtracted from the on-time of the pulses.
|
||||
*/
|
||||
#ifndef PULSE_CORRECTION_MICROS
|
||||
#define PULSE_CORRECTION_MICROS 3
|
||||
#endif
|
||||
/**
|
||||
* If USE_SOFT_SEND_PWM, use spin wait instead of delayMicros().
|
||||
*/
|
||||
//#define USE_SPIN_WAIT
|
||||
/**
|
||||
|
@ -559,8 +555,8 @@ private:
|
|||
int sendPin;
|
||||
|
||||
# if defined(USE_SOFT_SEND_PWM)
|
||||
unsigned int periodTime;
|
||||
unsigned int periodOnTime;
|
||||
unsigned int periodTimeMicros;
|
||||
unsigned int periodOnTimeMicros;
|
||||
|
||||
void sleepMicros(unsigned long us);
|
||||
void sleepUntilMicros(unsigned long targetTime);
|
||||
|
|
|
@ -108,7 +108,7 @@ void IRsend::mark(unsigned int time) {
|
|||
#ifdef USE_SOFT_SEND_PWM
|
||||
unsigned long start = micros();
|
||||
unsigned long stop = start + time;
|
||||
if (stop + periodTime < start) {
|
||||
if (stop + periodTimeMicros < start) {
|
||||
// Counter wrap-around, happens very seldomly, but CAN happen.
|
||||
// Just give up instead of possibly damaging the hardware.
|
||||
return;
|
||||
|
@ -117,9 +117,9 @@ void IRsend::mark(unsigned int time) {
|
|||
unsigned long now = micros();
|
||||
while (now < stop) {
|
||||
SENDPIN_ON(sendPin);
|
||||
sleepMicros (periodOnTime);
|
||||
sleepMicros (periodOnTimeMicros);
|
||||
SENDPIN_OFF(sendPin);
|
||||
nextPeriodEnding += periodTime;
|
||||
nextPeriodEnding += periodTimeMicros;
|
||||
sleepUntilMicros(nextPeriodEnding);
|
||||
now = micros();
|
||||
}
|
||||
|
@ -164,8 +164,8 @@ void IRsend::space(unsigned int time) {
|
|||
//
|
||||
void IRsend::enableIROut(int khz) {
|
||||
#ifdef USE_SOFT_SEND_PWM
|
||||
periodTime = (1000U + khz / 2) / khz; // = 1000/khz + 1/2 = round(1000.0/khz)
|
||||
periodOnTime = periodTime * DUTY_CYCLE / 100U - PULSE_CORRECTION;
|
||||
periodTimeMicros = (1000U + khz / 2) / khz; // = 1000/khz + 1/2 = round(1000.0/khz)
|
||||
periodOnTimeMicros = periodTimeMicros * IR_SEND_DUTY_CYCLE / 100U - PULSE_CORRECTION_MICROS;
|
||||
#endif
|
||||
|
||||
#if defined(USE_NO_SEND_PWM)
|
||||
|
|
|
@ -23,6 +23,14 @@
|
|||
#ifndef IRremoteBoardDefs_h
|
||||
#define IRremoteBoardDefs_h
|
||||
|
||||
#ifdef ARDUINO_ARCH_AVR
|
||||
#include <avr/pgmspace.h>
|
||||
#define HAS_FLASH_READ 1
|
||||
#define STRCPY_PF_CAST(x) (x)
|
||||
#else
|
||||
#define HAS_FLASH_READ 0
|
||||
#endif
|
||||
|
||||
// Define some defaults, that some boards may like to override
|
||||
// (This is to avoid negative logic, ! DONT_... is just awkward.)
|
||||
|
||||
|
@ -47,16 +55,10 @@
|
|||
/**
|
||||
* Duty cycle in percent for sent signals.
|
||||
*/
|
||||
#if ! defined(DUTY_CYCLE)
|
||||
#define DUTY_CYCLE 30 // 30 saves power and is compatible to the old existing code
|
||||
#if ! defined(IR_SEND_DUTY_CYCLE)
|
||||
#define IR_SEND_DUTY_CYCLE 30 // 30 saves power and is compatible to the old existing code
|
||||
#endif
|
||||
|
||||
/**
|
||||
* If USE_SOFT_SEND_PWM or USE_NO_SEND_PWM, this amount (in micro seconds) is subtracted from the
|
||||
* on-time of the pulses.
|
||||
*/
|
||||
#define PULSE_CORRECTION 3
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// This first #ifdef statement contains defines for blinking the LED,
|
||||
// as well as all other board specific information, with the exception of
|
||||
|
@ -154,7 +156,9 @@
|
|||
|
||||
//------------------------------------------------------------------------------
|
||||
// microseconds per clock interrupt tick
|
||||
#if ! defined(MICROS_PER_TICK)
|
||||
#define MICROS_PER_TICK 50
|
||||
#endif
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Define which timer to use
|
||||
|
@ -439,7 +443,7 @@ static void timerConfigForSend(uint16_t frequency) {
|
|||
TCCR2A = _BV(WGM20);
|
||||
TCCR2B = _BV(WGM22) | _BV(CS20);
|
||||
OCR2A = pwmval;
|
||||
OCR2B = pwmval * DUTY_CYCLE / 100;
|
||||
OCR2B = pwmval * IR_SEND_DUTY_CYCLE / 100;
|
||||
}
|
||||
|
||||
#define TIMER_COUNT_TOP (SYSCLOCK * MICROS_PER_TICK / 1000000)
|
||||
|
@ -508,7 +512,7 @@ static void timerConfigForSend(uint16_t frequency) {
|
|||
TCCR1A = _BV(WGM11);
|
||||
TCCR1B = _BV(WGM13) | _BV(CS10);
|
||||
ICR1 = pwmval;
|
||||
OCR1A = pwmval * DUTY_CYCLE / 100;
|
||||
OCR1A = pwmval * IR_SEND_DUTY_CYCLE / 100;
|
||||
}
|
||||
|
||||
static void timerConfigForReceive() {
|
||||
|
@ -560,7 +564,7 @@ static void timerConfigForSend(uint16_t frequency) {
|
|||
TCCR3A = _BV(WGM31);
|
||||
TCCR3B = _BV(WGM33) | _BV(CS30);
|
||||
ICR3 = pwmval;
|
||||
OCR3A = pwmval * DUTY_CYCLE / 100;
|
||||
OCR3A = pwmval * IR_SEND_DUTY_CYCLE / 100;
|
||||
}
|
||||
|
||||
static void timerConfigForReceive() {
|
||||
|
@ -612,8 +616,8 @@ static void timerConfigForSend(uint16_t frequency) {
|
|||
TCCR4E = 0;
|
||||
TC4H = pwmval >> 8;
|
||||
OCR4C = pwmval;
|
||||
TC4H = (pwmval * DUTY_CYCLE / 100) >> 8;
|
||||
OCR4A = (pwmval * DUTY_CYCLE / 100) & 255;
|
||||
TC4H = (pwmval * IR_SEND_DUTY_CYCLE / 100) >> 8;
|
||||
OCR4A = (pwmval * IR_SEND_DUTY_CYCLE / 100) & 255;
|
||||
}
|
||||
|
||||
static void timerConfigForReceive() {
|
||||
|
@ -656,7 +660,7 @@ static void timerConfigForSend(uint16_t frequency) {
|
|||
TCCR4A = _BV(WGM41);
|
||||
TCCR4B = _BV(WGM43) | _BV(CS40);
|
||||
ICR4 = pwmval;
|
||||
OCR4A = pwmval * DUTY_CYCLE / 100;
|
||||
OCR4A = pwmval * IR_SEND_DUTY_CYCLE / 100;
|
||||
}
|
||||
|
||||
static void timerConfigForReceive() {
|
||||
|
@ -692,7 +696,7 @@ static void timerConfigForSend(uint16_t frequency) {
|
|||
TCCR5A = _BV(WGM51);
|
||||
TCCR5B = _BV(WGM53) | _BV(CS50);
|
||||
ICR5 = pwmval;
|
||||
OCR5A = pwmval * DUTY_CYCLE / 100;
|
||||
OCR5A = pwmval * IR_SEND_DUTY_CYCLE / 100;
|
||||
}
|
||||
|
||||
static void timerConfigForReceive() {
|
||||
|
@ -820,7 +824,7 @@ static void timerConfigForSend(uint16_t frequency) {
|
|||
TCCR0A = _BV(WGM00);
|
||||
TCCR0B = _BV(WGM02) | _BV(CS00);
|
||||
OCR0A = pwmval;
|
||||
OCR0B = pwmval * DUTY_CYCLE / 100;
|
||||
OCR0B = pwmval * IR_SEND_DUTY_CYCLE / 100;
|
||||
}
|
||||
|
||||
#define TIMER_COUNT_TOP (SYSCLOCK * MICROS_PER_TICK / 1000000)
|
||||
|
@ -854,7 +858,7 @@ static void timerConfigForSend(uint16_t frequency) {
|
|||
TCCR0A = _BV(WGM00);
|
||||
TCCR0B = _BV(WGM02) | _BV(CS00);
|
||||
OCR0A = pwmval;
|
||||
OCR0B = pwmval * DUTY_CYCLE / 100;
|
||||
OCR0B = pwmval * IR_SEND_DUTY_CYCLE / 100;
|
||||
}
|
||||
|
||||
#define IR_SEND_PIN 1
|
||||
|
@ -872,7 +876,7 @@ static void timerConfigForSend(uint16_t frequency) {
|
|||
const uint32_t pwmval = (SYSCLOCK / 2000) / (frequency);
|
||||
TCB0.CTRLB = TCB_CNTMODE_PWM8_gc;
|
||||
TCB0.CCMPL = pwmval;
|
||||
TCB0.CCMPH = (pwmval * DUTY_CYCLE) / 100;
|
||||
TCB0.CCMPH = (pwmval * IR_SEND_DUTY_CYCLE) / 100;
|
||||
TCB0.CTRLA = (TCB_CLKSEL_CLKDIV2_gc) | (TCB_ENABLE_bm);
|
||||
}
|
||||
|
||||
|
@ -906,7 +910,7 @@ static void timerConfigForReceive() {
|
|||
#endif
|
||||
|
||||
#define TIMER_RESET_INTR_PENDING
|
||||
#define TIMER_ENABLE_SEND_PWM ledcWrite(LED_CHANNEL, DUTY_CYCLE) // we must use channel here not pin number
|
||||
#define TIMER_ENABLE_SEND_PWM ledcWrite(LED_CHANNEL, IR_SEND_DUTY_CYCLE) // we must use channel here not pin number
|
||||
#define TIMER_DISABLE_SEND_PWM ledcWrite(LED_CHANNEL, 0)
|
||||
|
||||
#ifdef ISR
|
||||
|
|
Loading…
Reference in New Issue