mirror of
https://github.com/Theaninova/Arduino-IRremote.git
synced 2026-01-22 01:02:44 +00:00
Compare commits
2 Commits
176c000cdf
...
v2.4.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e1768b4deb | ||
|
|
679348568d |
@@ -18,5 +18,7 @@ These are the active contributors of this project that you may contact if there
|
|||||||
- [philipphenkel](https://github.com/philipphenkel): Active Contributor
|
- [philipphenkel](https://github.com/philipphenkel): Active Contributor
|
||||||
- [MCUdude](https://github.com/MCUdude): Contributor
|
- [MCUdude](https://github.com/MCUdude): Contributor
|
||||||
- [marcmerlin](https://github.com/marcmerlin): Contributor (ESP32 port)
|
- [marcmerlin](https://github.com/marcmerlin): Contributor (ESP32 port)
|
||||||
|
- [bengtmartensson](https://github.com/bengtmartensson): Active Contributor
|
||||||
|
- [MrBryonMiller](https://github.com/MrBryonMiller): Contributor
|
||||||
|
|
||||||
Note: This list is being updated constantly so please let [z3t0](https://github.com/z3t0) know if you have been missed.
|
Note: This list is being updated constantly so please let [z3t0](https://github.com/z3t0) know if you have been missed.
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
# include "IRremoteInt.h"
|
# include "IRremoteInt.h"
|
||||||
#undef IR_GLOBAL
|
#undef IR_GLOBAL
|
||||||
|
|
||||||
#ifndef IR_TIMER_USE_ESP32
|
#ifdef HAS_AVR_INTERRUPT_H
|
||||||
#include <avr/interrupt.h>
|
#include <avr/interrupt.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -123,11 +123,7 @@ int MATCH_SPACE (int measured_ticks, int desired_us)
|
|||||||
// As soon as first MARK arrives:
|
// As soon as first MARK arrives:
|
||||||
// Gap width is recorded; Ready is cleared; New logging starts
|
// Gap width is recorded; Ready is cleared; New logging starts
|
||||||
//
|
//
|
||||||
#ifdef IR_TIMER_USE_ESP32
|
|
||||||
void IRTimer()
|
|
||||||
#else
|
|
||||||
ISR (TIMER_INTR_NAME)
|
ISR (TIMER_INTR_NAME)
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
TIMER_RESET;
|
TIMER_RESET;
|
||||||
|
|
||||||
@@ -189,6 +185,7 @@ ISR (TIMER_INTR_NAME)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef BLINKLED
|
||||||
// If requested, flash LED while receiving IR data
|
// If requested, flash LED while receiving IR data
|
||||||
if (irparams.blinkflag) {
|
if (irparams.blinkflag) {
|
||||||
if (irdata == MARK)
|
if (irdata == MARK)
|
||||||
@@ -197,4 +194,5 @@ ISR (TIMER_INTR_NAME)
|
|||||||
else if (irparams.blinkpin) digitalWrite(irparams.blinkpin, LOW); // Turn user defined pin LED on
|
else if (irparams.blinkpin) digitalWrite(irparams.blinkpin, LOW); // Turn user defined pin LED on
|
||||||
else BLINKLED_OFF() ; // if no user defined LED pin, turn default LED pin for the hardware on
|
else BLINKLED_OFF() ; // if no user defined LED pin, turn default LED pin for the hardware on
|
||||||
}
|
}
|
||||||
|
#endif // BLINKLED
|
||||||
}
|
}
|
||||||
|
|||||||
39
IRremote.h
39
IRremote.h
@@ -79,9 +79,6 @@
|
|||||||
#define DECODE_LEGO_PF 0 // NOT WRITTEN
|
#define DECODE_LEGO_PF 0 // NOT WRITTEN
|
||||||
#define SEND_LEGO_PF 1
|
#define SEND_LEGO_PF 1
|
||||||
|
|
||||||
#define DECODE_NERF_LOP 0 // NOT WRITTEN
|
|
||||||
#define SEND_NERF_LOP 1
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// When sending a Pronto code we request to send either the "once" code
|
// When sending a Pronto code we request to send either the "once" code
|
||||||
// or the "repeat" code
|
// or the "repeat" code
|
||||||
@@ -122,7 +119,6 @@ typedef
|
|||||||
DENON,
|
DENON,
|
||||||
PRONTO,
|
PRONTO,
|
||||||
LEGO_PF,
|
LEGO_PF,
|
||||||
NERF_LOP,
|
|
||||||
}
|
}
|
||||||
decode_type_t;
|
decode_type_t;
|
||||||
|
|
||||||
@@ -255,10 +251,6 @@ class IRrecv
|
|||||||
# if DECODE_LEGO_PF
|
# if DECODE_LEGO_PF
|
||||||
bool decodeLegoPowerFunctions (decode_results *results) ;
|
bool decodeLegoPowerFunctions (decode_results *results) ;
|
||||||
# endif
|
# endif
|
||||||
//......................................................................
|
|
||||||
# if DECODE_NERF_LOP
|
|
||||||
bool decodeNerfLOP (decode_results *results) ;
|
|
||||||
# endif
|
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
@@ -267,7 +259,18 @@ class IRrecv
|
|||||||
class IRsend
|
class IRsend
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
IRsend () { }
|
#ifdef USE_SOFT_CARRIER
|
||||||
|
|
||||||
|
IRsend(int pin = SEND_PIN)
|
||||||
|
{
|
||||||
|
sendPin = pin;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
|
||||||
|
IRsend()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void custom_delay_usec (unsigned long uSecs);
|
void custom_delay_usec (unsigned long uSecs);
|
||||||
void enableIROut (int khz) ;
|
void enableIROut (int khz) ;
|
||||||
@@ -347,10 +350,20 @@ class IRsend
|
|||||||
# if SEND_LEGO_PF
|
# if SEND_LEGO_PF
|
||||||
void sendLegoPowerFunctions (uint16_t data, bool repeat = true) ;
|
void sendLegoPowerFunctions (uint16_t data, bool repeat = true) ;
|
||||||
# endif
|
# endif
|
||||||
//......................................................................
|
|
||||||
# if SEND_NERF_LOP
|
#ifdef USE_SOFT_CARRIER
|
||||||
void sendNerfLOP (uint16_t data, bool repeat = true) ;
|
private:
|
||||||
# endif
|
int sendPin;
|
||||||
|
|
||||||
|
unsigned int periodTime;
|
||||||
|
unsigned int periodOnTime;
|
||||||
|
|
||||||
|
void sleepMicros(unsigned long us);
|
||||||
|
void sleepUntilMicros(unsigned long targetTime);
|
||||||
|
|
||||||
|
#else
|
||||||
|
const int sendPin = SEND_PIN;
|
||||||
|
#endif
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ This library enables you to send and receive using infra-red signals on an Ardui
|
|||||||
|
|
||||||
Tutorials and more information will be made available on [the official homepage](http://z3t0.github.io/Arduino-IRremote/).
|
Tutorials and more information will be made available on [the official homepage](http://z3t0.github.io/Arduino-IRremote/).
|
||||||
|
|
||||||
## Version - 2.2.3
|
## Version - 2.4.0b
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
1. Navigate to the [Releases](https://github.com/z3t0/Arduino-IRremote/releases) page.
|
1. Navigate to the [Releases](https://github.com/z3t0/Arduino-IRremote/releases) page.
|
||||||
@@ -33,7 +33,6 @@ Whether you use the Adafruit Neopixel lib, or FastLED, interrupts get disabled o
|
|||||||
- ATtiny 84 / 85
|
- ATtiny 84 / 85
|
||||||
- ESP32 (receive only)
|
- ESP32 (receive only)
|
||||||
- ESP8266 is supported in a fork based on an old codebase that isn't as recent, but it works reasonably well given that perfectly timed sub millisecond interrupts are different on that chip. See https://github.com/markszabo/IRremoteESP8266
|
- ESP8266 is supported in a fork based on an old codebase that isn't as recent, but it works reasonably well given that perfectly timed sub millisecond interrupts are different on that chip. See https://github.com/markszabo/IRremoteESP8266
|
||||||
- Sparkfun Pro Micro
|
|
||||||
|
|
||||||
We are open to suggestions for adding support to new boards, however we highly recommend you contact your supplier first and ask them to provide support from their side.
|
We are open to suggestions for adding support to new boards, however we highly recommend you contact your supplier first and ask them to provide support from their side.
|
||||||
|
|
||||||
@@ -52,7 +51,6 @@ We are open to suggestions for adding support to new boards, however we highly r
|
|||||||
| [ATmega64, ATmega128](https://github.com/MCUdude/MegaCore) | **13** | **1** |
|
| [ATmega64, ATmega128](https://github.com/MCUdude/MegaCore) | **13** | **1** |
|
||||||
| ATmega1280, ATmega2560 | 5, 6, **9**, 11, 46 | 1, **2**, 3, 4, 5 |
|
| ATmega1280, ATmega2560 | 5, 6, **9**, 11, 46 | 1, **2**, 3, 4, 5 |
|
||||||
| [ESP32](http://esp32.net/) | N/A (not supported) | **1** |
|
| [ESP32](http://esp32.net/) | N/A (not supported) | **1** |
|
||||||
| [Sparkfun Pro Micro](https://www.sparkfun.com/products/12640) | 9, **5**, 5 | 1, **3**, 4_HS |
|
|
||||||
| [Teensy 1.0](https://www.pjrc.com/teensy/) | **17** | **1** |
|
| [Teensy 1.0](https://www.pjrc.com/teensy/) | **17** | **1** |
|
||||||
| [Teensy 2.0](https://www.pjrc.com/teensy/) | 9, **10**, 14 | 1, 3, **4_HS** |
|
| [Teensy 2.0](https://www.pjrc.com/teensy/) | 9, **10**, 14 | 1, 3, **4_HS** |
|
||||||
| [Teensy++ 1.0 / 2.0](https://www.pjrc.com/teensy/) | **1**, 16, 25 | 1, **2**, 3 |
|
| [Teensy++ 1.0 / 2.0](https://www.pjrc.com/teensy/) | **1**, 16, 25 | 1, **2**, 3 |
|
||||||
|
|||||||
170
boarddefs.h
170
boarddefs.h
@@ -15,13 +15,37 @@
|
|||||||
//
|
//
|
||||||
// JVC and Panasonic protocol added by Kristian Lauszus (Thanks to zenwheel and other people at the original blog post)
|
// JVC and Panasonic protocol added by Kristian Lauszus (Thanks to zenwheel and other people at the original blog post)
|
||||||
// Whynter A/C ARC-110WD added by Francesco Meschia
|
// Whynter A/C ARC-110WD added by Francesco Meschia
|
||||||
|
|
||||||
// Sparkfun Pro Micro support by Alastair McCormack
|
|
||||||
//******************************************************************************
|
//******************************************************************************
|
||||||
|
|
||||||
#ifndef boarddefs_h
|
#ifndef boarddefs_h
|
||||||
#define boarddefs_h
|
#define boarddefs_h
|
||||||
|
|
||||||
|
// Define some defaults, that some boards may like to override
|
||||||
|
// (This is to avoid negative logic, ! DONT_... is just awkward.)
|
||||||
|
|
||||||
|
// This board has/needs the avr/interrupt.h
|
||||||
|
#define HAS_AVR_INTERRUPT_H
|
||||||
|
|
||||||
|
// Define if sending is supported
|
||||||
|
#define SENDING_SUPPORTED
|
||||||
|
|
||||||
|
// If defined, a standard enableIRIn function will be define.
|
||||||
|
// Undefine for boards supplying their own.
|
||||||
|
#define USE_DEFAULT_ENABLE_IR_IN
|
||||||
|
|
||||||
|
// Duty cycle in percent for sent signals. Presently takes effect only with USE_SOFT_CARRIER
|
||||||
|
#define DUTY_CYCLE 50
|
||||||
|
|
||||||
|
// If USE_SOFT_CARRIER, this amount (in micro seconds) is subtracted from the
|
||||||
|
// on-time of the pulses.
|
||||||
|
#define PULSE_CORRECTION 3
|
||||||
|
|
||||||
|
// digitalWrite is supposed to be slow. If this is an issue, define faster,
|
||||||
|
// board-dependent versions of these macros SENDPIN_ON(pin) and SENDPIN_OFF(pin).
|
||||||
|
// Portable, possibly slow, default definitions are given at the end of this file.
|
||||||
|
// If defining new versions, feel free to ignore the pin argument if it
|
||||||
|
// is not configurable on the current board.
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// Defines for blinking the LED
|
// Defines for blinking the LED
|
||||||
//
|
//
|
||||||
@@ -41,11 +65,31 @@
|
|||||||
# define BLINKLED_ON() (PORTD |= B00000001)
|
# define BLINKLED_ON() (PORTD |= B00000001)
|
||||||
# define BLINKLED_OFF() (PORTD &= B11111110)
|
# define BLINKLED_OFF() (PORTD &= B11111110)
|
||||||
|
|
||||||
// No system LED on ESP32, disable blinking
|
#elif defined(ARDUINO_ARCH_SAM) || defined(ARDUINO_ARCH_SAMD)
|
||||||
|
# define BLINKLED LED_BUILTIN
|
||||||
|
# define BLINKLED_ON() (digitalWrite(LED_BUILTIN, HIGH))
|
||||||
|
# define BLINKLED_OFF() (digitalWrite(LED_BUILTIN, LOW))
|
||||||
|
|
||||||
|
# define USE_SOFT_CARRIER
|
||||||
|
// Define to use spin wait instead of delayMicros()
|
||||||
|
//# define USE_SPIN_WAIT
|
||||||
|
# undef USE_DEFAULT_ENABLE_IR_IN
|
||||||
|
|
||||||
|
// The default pin used used for sending.
|
||||||
|
# define SEND_PIN 9
|
||||||
|
|
||||||
#elif defined(ESP32)
|
#elif defined(ESP32)
|
||||||
# define BLINKLED 255
|
// No system LED on ESP32, disable blinking by NOT defining BLINKLED
|
||||||
# define BLINKLED_ON() 1
|
|
||||||
# define BLINKLED_OFF() 1
|
// avr/interrupt.h is not present
|
||||||
|
# undef HAS_AVR_INTERRUPT_H
|
||||||
|
|
||||||
|
// Sending not implemented
|
||||||
|
# undef SENDING_SUPPORTED#
|
||||||
|
|
||||||
|
// Supply own enbleIRIn
|
||||||
|
# undef USE_DEFAULT_ENABLE_IR_IN
|
||||||
|
|
||||||
#else
|
#else
|
||||||
# define BLINKLED 13
|
# define BLINKLED 13
|
||||||
# define BLINKLED_ON() (PORTB |= B00100000)
|
# define BLINKLED_ON() (PORTB |= B00100000)
|
||||||
@@ -72,14 +116,8 @@
|
|||||||
// switch IRremote to use a different timer.
|
// switch IRremote to use a different timer.
|
||||||
//
|
//
|
||||||
|
|
||||||
// Sparkfun Pro Micro
|
|
||||||
#if defined(ARDUINO_AVR_PROMICRO)
|
|
||||||
//#define IR_USE_TIMER1 // tx = pin 9
|
|
||||||
#define IR_USE_TIMER3 // tx = pin 5
|
|
||||||
//#define IR_USE_TIMER4_HS // tx = pin 5
|
|
||||||
|
|
||||||
// Arduino Mega
|
// Arduino Mega
|
||||||
#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
|
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
|
||||||
//#define IR_USE_TIMER1 // tx = pin 11
|
//#define IR_USE_TIMER1 // tx = pin 11
|
||||||
#define IR_USE_TIMER2 // tx = pin 9
|
#define IR_USE_TIMER2 // tx = pin 9
|
||||||
//#define IR_USE_TIMER3 // tx = pin 5
|
//#define IR_USE_TIMER3 // tx = pin 5
|
||||||
@@ -146,6 +184,10 @@
|
|||||||
|
|
||||||
#elif defined(ESP32)
|
#elif defined(ESP32)
|
||||||
#define IR_TIMER_USE_ESP32
|
#define IR_TIMER_USE_ESP32
|
||||||
|
|
||||||
|
#elif defined(ARDUINO_ARCH_SAM) || defined(ARDUINO_ARCH_SAMD)
|
||||||
|
#define TIMER_PRESCALER_DIV 64
|
||||||
|
|
||||||
#else
|
#else
|
||||||
// Arduino Duemilanove, Diecimila, LilyPad, Mini, Fio, Nano, etc
|
// Arduino Duemilanove, Diecimila, LilyPad, Mini, Fio, Nano, etc
|
||||||
// ATmega48, ATmega88, ATmega168, ATmega328
|
// ATmega48, ATmega88, ATmega168, ATmega328
|
||||||
@@ -198,17 +240,17 @@
|
|||||||
|
|
||||||
//-----------------
|
//-----------------
|
||||||
#if defined(CORE_OC2B_PIN)
|
#if defined(CORE_OC2B_PIN)
|
||||||
# define TIMER_PWM_PIN CORE_OC2B_PIN // Teensy
|
# define SEND_PIN CORE_OC2B_PIN // Teensy
|
||||||
#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
|
#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
|
||||||
# define TIMER_PWM_PIN 9 // Arduino Mega
|
# define SEND_PIN 9 // Arduino Mega
|
||||||
#elif defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) \
|
#elif defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) \
|
||||||
|| defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) \
|
|| defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) \
|
||||||
|| defined(__AVR_ATmega324P__) || defined(__AVR_ATmega324A__) \
|
|| defined(__AVR_ATmega324P__) || defined(__AVR_ATmega324A__) \
|
||||||
|| defined(__AVR_ATmega324PA__) || defined(__AVR_ATmega164A__) \
|
|| defined(__AVR_ATmega324PA__) || defined(__AVR_ATmega164A__) \
|
||||||
|| defined(__AVR_ATmega164P__)
|
|| defined(__AVR_ATmega164P__)
|
||||||
# define TIMER_PWM_PIN 14 // MightyCore
|
# define SEND_PIN 14 // MightyCore
|
||||||
#else
|
#else
|
||||||
# define TIMER_PWM_PIN 3 // Arduino Duemilanove, Diecimila, LilyPad, etc
|
# define SEND_PIN 3 // Arduino Duemilanove, Diecimila, LilyPad, etc
|
||||||
#endif // ATmega48, ATmega88, ATmega168, ATmega328
|
#endif // ATmega48, ATmega88, ATmega168, ATmega328
|
||||||
|
|
||||||
//---------------------------------------------------------
|
//---------------------------------------------------------
|
||||||
@@ -251,21 +293,22 @@
|
|||||||
|
|
||||||
//-----------------
|
//-----------------
|
||||||
#if defined(CORE_OC1A_PIN)
|
#if defined(CORE_OC1A_PIN)
|
||||||
# define TIMER_PWM_PIN CORE_OC1A_PIN // Teensy
|
# define SEND_PIN CORE_OC1A_PIN // Teensy
|
||||||
#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
|
#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
|
||||||
# define TIMER_PWM_PIN 11 // Arduino Mega
|
# define SEND_PIN 11 // Arduino Mega
|
||||||
|
#elif defined(__AVR_ATmega64__) || defined(__AVR_ATmega128__)
|
||||||
|
# define SEND_PIN 13 // MegaCore
|
||||||
#elif defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) \
|
#elif defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) \
|
||||||
|| defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) \
|
|| defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) \
|
||||||
|| defined(__AVR_ATmega324P__) || defined(__AVR_ATmega324A__) \
|
|| defined(__AVR_ATmega324P__) || defined(__AVR_ATmega324A__) \
|
||||||
|| defined(__AVR_ATmega324PA__) || defined(__AVR_ATmega164A__) \
|
|| defined(__AVR_ATmega324PA__) || defined(__AVR_ATmega164A__) \
|
||||||
|| defined(__AVR_ATmega164P__) || defined(__AVR_ATmega32__) \
|
|| defined(__AVR_ATmega164P__) || defined(__AVR_ATmega32__) \
|
||||||
|| defined(__AVR_ATmega16__) || defined(__AVR_ATmega8535__) \
|
|| defined(__AVR_ATmega16__) || defined(__AVR_ATmega8535__)
|
||||||
|| defined(__AVR_ATmega64__) || defined(__AVR_ATmega128__)
|
# define SEND_PIN 13 // MightyCore
|
||||||
# define TIMER_PWM_PIN 13 // MightyCore, MegaCore
|
|
||||||
#elif defined(__AVR_ATtiny84__)
|
#elif defined(__AVR_ATtiny84__)
|
||||||
# define TIMER_PWM_PIN 6
|
# define SEND_PIN 6
|
||||||
#else
|
#else
|
||||||
# define TIMER_PWM_PIN 9 // Arduino Duemilanove, Diecimila, LilyPad, Sparkfun Pro Micro etc
|
# define SEND_PIN 9 // Arduino Duemilanove, Diecimila, LilyPad, etc
|
||||||
#endif // ATmega48, ATmega88, ATmega168, ATmega328
|
#endif // ATmega48, ATmega88, ATmega168, ATmega328
|
||||||
|
|
||||||
//---------------------------------------------------------
|
//---------------------------------------------------------
|
||||||
@@ -297,11 +340,11 @@
|
|||||||
|
|
||||||
//-----------------
|
//-----------------
|
||||||
#if defined(CORE_OC3A_PIN)
|
#if defined(CORE_OC3A_PIN)
|
||||||
# define TIMER_PWM_PIN CORE_OC3A_PIN // Teensy
|
# define SEND_PIN CORE_OC3A_PIN // Teensy
|
||||||
#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) || defined(ARDUINO_AVR_PROMICRO)
|
#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
|
||||||
# define TIMER_PWM_PIN 5 // Arduino Mega, Sparkfun Pro Micro
|
# define SEND_PIN 5 // Arduino Mega
|
||||||
#elif defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__)
|
#elif defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__)
|
||||||
# define TIMER_PWM_PIN 6 // MightyCore
|
# define SEND_PIN 6 // MightyCore
|
||||||
#else
|
#else
|
||||||
# error "Please add OC3A pin number here\n"
|
# error "Please add OC3A pin number here\n"
|
||||||
#endif
|
#endif
|
||||||
@@ -312,21 +355,12 @@
|
|||||||
#elif defined(IR_USE_TIMER4_HS)
|
#elif defined(IR_USE_TIMER4_HS)
|
||||||
|
|
||||||
#define TIMER_RESET
|
#define TIMER_RESET
|
||||||
|
#define TIMER_ENABLE_PWM (TCCR4A |= _BV(COM4A1))
|
||||||
#if defined(ARDUINO_AVR_PROMICRO) // Sparkfun Pro Micro
|
#define TIMER_DISABLE_PWM (TCCR4A &= ~(_BV(COM4A1)))
|
||||||
#define TIMER_ENABLE_PWM (TCCR4A |= _BV(COM4A0)) // Use complimentary O̅C̅4̅A̅ output on pin 5
|
|
||||||
#define TIMER_DISABLE_PWM (TCCR4A &= ~(_BV(COM4A0))) // (Pro Micro does not map PC7 (32/ICP3/CLK0/OC4A)
|
|
||||||
// of ATmega32U4 )
|
|
||||||
#else
|
|
||||||
#define TIMER_ENABLE_PWM (TCCR4A |= _BV(COM4A1))
|
|
||||||
#define TIMER_DISABLE_PWM (TCCR4A &= ~(_BV(COM4A1)))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define TIMER_ENABLE_INTR (TIMSK4 = _BV(TOIE4))
|
#define TIMER_ENABLE_INTR (TIMSK4 = _BV(TOIE4))
|
||||||
#define TIMER_DISABLE_INTR (TIMSK4 = 0)
|
#define TIMER_DISABLE_INTR (TIMSK4 = 0)
|
||||||
#define TIMER_INTR_NAME TIMER4_OVF_vect
|
#define TIMER_INTR_NAME TIMER4_OVF_vect
|
||||||
|
|
||||||
|
|
||||||
#define TIMER_CONFIG_KHZ(val) ({ \
|
#define TIMER_CONFIG_KHZ(val) ({ \
|
||||||
const uint16_t pwmval = SYSCLOCK / 2000 / (val); \
|
const uint16_t pwmval = SYSCLOCK / 2000 / (val); \
|
||||||
TCCR4A = (1<<PWM4A); \
|
TCCR4A = (1<<PWM4A); \
|
||||||
@@ -354,11 +388,9 @@
|
|||||||
|
|
||||||
//-----------------
|
//-----------------
|
||||||
#if defined(CORE_OC4A_PIN)
|
#if defined(CORE_OC4A_PIN)
|
||||||
# define TIMER_PWM_PIN CORE_OC4A_PIN // Teensy
|
# define SEND_PIN CORE_OC4A_PIN // Teensy
|
||||||
#elif defined(ARDUINO_AVR_PROMICRO)
|
|
||||||
# define TIMER_PWM_PIN 5 // Sparkfun Pro Micro
|
|
||||||
#elif defined(__AVR_ATmega32U4__)
|
#elif defined(__AVR_ATmega32U4__)
|
||||||
# define TIMER_PWM_PIN 13 // Leonardo
|
# define SEND_PIN 13 // Leonardo
|
||||||
#else
|
#else
|
||||||
# error "Please add OC4A pin number here\n"
|
# error "Please add OC4A pin number here\n"
|
||||||
#endif
|
#endif
|
||||||
@@ -392,9 +424,9 @@
|
|||||||
|
|
||||||
//-----------------
|
//-----------------
|
||||||
#if defined(CORE_OC4A_PIN)
|
#if defined(CORE_OC4A_PIN)
|
||||||
# define TIMER_PWM_PIN CORE_OC4A_PIN
|
# define SEND_PIN CORE_OC4A_PIN
|
||||||
#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
|
#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
|
||||||
# define TIMER_PWM_PIN 6 // Arduino Mega
|
# define SEND_PIN 6 // Arduino Mega
|
||||||
#else
|
#else
|
||||||
# error "Please add OC4A pin number here\n"
|
# error "Please add OC4A pin number here\n"
|
||||||
#endif
|
#endif
|
||||||
@@ -428,9 +460,9 @@
|
|||||||
|
|
||||||
//-----------------
|
//-----------------
|
||||||
#if defined(CORE_OC5A_PIN)
|
#if defined(CORE_OC5A_PIN)
|
||||||
# define TIMER_PWM_PIN CORE_OC5A_PIN
|
# define SEND_PIN CORE_OC5A_PIN
|
||||||
#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
|
#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
|
||||||
# define TIMER_PWM_PIN 46 // Arduino Mega
|
# define SEND_PIN 46 // Arduino Mega
|
||||||
#else
|
#else
|
||||||
# error "Please add OC5A pin number here\n"
|
# error "Please add OC5A pin number here\n"
|
||||||
#endif
|
#endif
|
||||||
@@ -497,7 +529,7 @@
|
|||||||
CMT_MSC = 0x03; \
|
CMT_MSC = 0x03; \
|
||||||
})
|
})
|
||||||
|
|
||||||
#define TIMER_PWM_PIN 5
|
#define SEND_PIN 5
|
||||||
|
|
||||||
// defines for TPM1 timer on Teensy-LC
|
// defines for TPM1 timer on Teensy-LC
|
||||||
#elif defined(IR_USE_TIMER_TPM1)
|
#elif defined(IR_USE_TIMER_TPM1)
|
||||||
@@ -527,7 +559,7 @@
|
|||||||
FTM1_C0V = 0; \
|
FTM1_C0V = 0; \
|
||||||
FTM1_SC = FTM_SC_CLKS(1) | FTM_SC_PS(0) | FTM_SC_TOF | FTM_SC_TOIE; \
|
FTM1_SC = FTM_SC_CLKS(1) | FTM_SC_PS(0) | FTM_SC_TOF | FTM_SC_TOIE; \
|
||||||
})
|
})
|
||||||
#define TIMER_PWM_PIN 16
|
#define SEND_PIN 16
|
||||||
|
|
||||||
// defines for timer_tiny0 (8 bits)
|
// defines for timer_tiny0 (8 bits)
|
||||||
#elif defined(IR_USE_TIMER_TINY0)
|
#elif defined(IR_USE_TIMER_TINY0)
|
||||||
@@ -561,7 +593,7 @@
|
|||||||
})
|
})
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define TIMER_PWM_PIN 1 /* ATtiny85 */
|
#define SEND_PIN 1 /* ATtiny85 */
|
||||||
|
|
||||||
//---------------------------------------------------------
|
//---------------------------------------------------------
|
||||||
// ESP32 (ESP8266 should likely be added here too)
|
// ESP32 (ESP8266 should likely be added here too)
|
||||||
@@ -578,12 +610,29 @@
|
|||||||
// way to do this on ESP32 is using the RMT built in driver like in this incomplete library below
|
// way to do this on ESP32 is using the RMT built in driver like in this incomplete library below
|
||||||
// https://github.com/ExploreEmbedded/ESP32_RMT
|
// https://github.com/ExploreEmbedded/ESP32_RMT
|
||||||
#elif defined(IR_TIMER_USE_ESP32)
|
#elif defined(IR_TIMER_USE_ESP32)
|
||||||
#define TIMER_RESET
|
|
||||||
#define TIMER_ENABLE_PWM
|
#define TIMER_RESET
|
||||||
#define TIMER_DISABLE_PWM Serial.println("IRsend not implemented for ESP32 yet");
|
|
||||||
#define TIMER_ENABLE_INTR
|
#ifdef ISR
|
||||||
#define TIMER_DISABLE_INTR
|
# undef ISR
|
||||||
#define TIMER_INTR_NAME
|
#endif
|
||||||
|
#define ISR(f) void IRTimer()
|
||||||
|
|
||||||
|
#elif defined(ARDUINO_ARCH_SAM) || defined(ARDUINO_ARCH_SAMD)
|
||||||
|
// use timer 3 hardcoded at this time
|
||||||
|
|
||||||
|
#define TIMER_RESET
|
||||||
|
#define TIMER_ENABLE_PWM // Not presently used
|
||||||
|
#define TIMER_DISABLE_PWM
|
||||||
|
#define TIMER_ENABLE_INTR NVIC_EnableIRQ(TC3_IRQn) // Not presently used
|
||||||
|
#define TIMER_DISABLE_INTR NVIC_DisableIRQ(TC3_IRQn)
|
||||||
|
#define TIMER_INTR_NAME TC3_Handler // Not presently used
|
||||||
|
#define TIMER_CONFIG_KHZ(f)
|
||||||
|
|
||||||
|
#ifdef ISR
|
||||||
|
# undef ISR
|
||||||
|
#endif
|
||||||
|
#define ISR(f) void irs()
|
||||||
|
|
||||||
//---------------------------------------------------------
|
//---------------------------------------------------------
|
||||||
// Unknown Timer
|
// Unknown Timer
|
||||||
@@ -592,4 +641,13 @@
|
|||||||
# error "Internal code configuration error, no known IR_USE_TIMER# defined\n"
|
# error "Internal code configuration error, no known IR_USE_TIMER# defined\n"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Provide default definitions, portable but possibly slower than necessary.
|
||||||
|
#ifndef SENDPIN_ON
|
||||||
|
#define SENDPIN_ON(pin) digitalWrite(pin, HIGH)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef SENDPIN_OFF
|
||||||
|
#define SENDPIN_OFF(pin) digitalWrite(pin, LOW)
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif // ! boarddefs_h
|
#endif // ! boarddefs_h
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
## 2.4.0 - 2017/08/10
|
||||||
|
- Cleanup of hardware dependencies. Merge in SAM support [PR #437](https://github.com/z3t0/Arduino-IRremote/pull/437)
|
||||||
|
|
||||||
## 2.3.3 - 2017/03/31
|
## 2.3.3 - 2017/03/31
|
||||||
- Added ESP32 IR receive support [PR #427](https://github.com/z3t0/Arduino-IRremote/pull/425)
|
- Added ESP32 IR receive support [PR #427](https://github.com/z3t0/Arduino-IRremote/pull/425)
|
||||||
|
|
||||||
|
|||||||
39
esp32.cpp
Normal file
39
esp32.cpp
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
#ifdef ESP32
|
||||||
|
|
||||||
|
// This file contains functions specific to the ESP32.
|
||||||
|
|
||||||
|
#include "IRremote.h"
|
||||||
|
#include "IRremoteInt.h"
|
||||||
|
|
||||||
|
// "Idiot check"
|
||||||
|
#ifdef USE_DEFAULT_ENABLE_IR_IN
|
||||||
|
#error Must undef USE_DEFAULT_ENABLE_IR_IN
|
||||||
|
#endif
|
||||||
|
|
||||||
|
hw_timer_t *timer;
|
||||||
|
void IRTimer(); // defined in IRremote.cpp, masqueraded as ISR(TIMER_INTR_NAME)
|
||||||
|
|
||||||
|
//+=============================================================================
|
||||||
|
// initialization
|
||||||
|
//
|
||||||
|
void IRrecv::enableIRIn ( )
|
||||||
|
{
|
||||||
|
// Interrupt Service Routine - Fires every 50uS
|
||||||
|
// ESP32 has a proper API to setup timers, no weird chip macros needed
|
||||||
|
// simply call the readable API versions :)
|
||||||
|
// 3 timers, choose #1, 80 divider nanosecond precision, 1 to count up
|
||||||
|
timer = timerBegin(1, 80, 1);
|
||||||
|
timerAttachInterrupt(timer, &IRTimer, 1);
|
||||||
|
// every 50ns, autoreload = true
|
||||||
|
timerAlarmWrite(timer, 50, true);
|
||||||
|
timerAlarmEnable(timer);
|
||||||
|
|
||||||
|
// Initialize state machine variables
|
||||||
|
irparams.rcvstate = STATE_IDLE;
|
||||||
|
irparams.rawlen = 0;
|
||||||
|
|
||||||
|
// Set pin modes
|
||||||
|
pinMode(irparams.recvpin, INPUT);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // ESP32
|
||||||
@@ -45,7 +45,7 @@ int toggle = 0; // The RC5/6 toggle state
|
|||||||
// Most of this code is just logging
|
// Most of this code is just logging
|
||||||
void storeCode(decode_results *results) {
|
void storeCode(decode_results *results) {
|
||||||
codeType = results->decode_type;
|
codeType = results->decode_type;
|
||||||
//int count = results->rawlen;
|
int count = results->rawlen;
|
||||||
if (codeType == UNKNOWN) {
|
if (codeType == UNKNOWN) {
|
||||||
Serial.println("Received unknown code, saving as raw");
|
Serial.println("Received unknown code, saving as raw");
|
||||||
codeLen = results->rawlen - 1;
|
codeLen = results->rawlen - 1;
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ void dumpTIMER() {
|
|||||||
|
|
||||||
void dumpTimerPin() {
|
void dumpTimerPin() {
|
||||||
Serial.print(F("IR Tx Pin: "));
|
Serial.print(F("IR Tx Pin: "));
|
||||||
Serial.println(TIMER_PWM_PIN);
|
Serial.println(SEND_PIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
void dumpClock() {
|
void dumpClock() {
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ void setup()
|
|||||||
// Wait for the gap between tests, to synchronize with
|
// Wait for the gap between tests, to synchronize with
|
||||||
// the sender.
|
// the sender.
|
||||||
// Specifically, wait for a signal followed by a gap of at last gap ms.
|
// Specifically, wait for a signal followed by a gap of at last gap ms.
|
||||||
void waitForGap(unsigned long gap) {
|
void waitForGap(int gap) {
|
||||||
Serial.println("Waiting for gap");
|
Serial.println("Waiting for gap");
|
||||||
while (1) {
|
while (1) {
|
||||||
while (digitalRead(RECV_PIN) == LOW) {
|
while (digitalRead(RECV_PIN) == LOW) {
|
||||||
@@ -125,7 +125,7 @@ void dump(decode_results *results) {
|
|||||||
// The motivation behind this method is that the sender and the receiver
|
// The motivation behind this method is that the sender and the receiver
|
||||||
// can do the same test calls, and the mode variable indicates whether
|
// can do the same test calls, and the mode variable indicates whether
|
||||||
// to send or receive.
|
// to send or receive.
|
||||||
void test(const char *label, int type, unsigned long value, int bits) {
|
void test(char *label, int type, unsigned long value, int bits) {
|
||||||
if (mode == SENDER) {
|
if (mode == SENDER) {
|
||||||
Serial.println(label);
|
Serial.println(label);
|
||||||
if (type == NEC) {
|
if (type == NEC) {
|
||||||
@@ -175,7 +175,7 @@ void test(const char *label, int type, unsigned long value, int bits) {
|
|||||||
|
|
||||||
// Test raw send or receive. This is similar to the test method,
|
// Test raw send or receive. This is similar to the test method,
|
||||||
// except it send/receives raw data.
|
// except it send/receives raw data.
|
||||||
void testRaw(const char *label, unsigned int *rawbuf, int rawlen) {
|
void testRaw(char *label, unsigned int *rawbuf, int rawlen) {
|
||||||
if (mode == SENDER) {
|
if (mode == SENDER) {
|
||||||
Serial.println(label);
|
Serial.println(label);
|
||||||
irsend.sendRaw(rawbuf, rawlen, 38 /* kHz */);
|
irsend.sendRaw(rawbuf, rawlen, 38 /* kHz */);
|
||||||
|
|||||||
@@ -192,12 +192,12 @@ void loop()
|
|||||||
ac_activate(AC_TEMPERATURE, AC_FLOW);
|
ac_activate(AC_TEMPERATURE, AC_FLOW);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
if ( b == 0 || b == 1 ) {
|
if ( b == 0 | b == 1 ) {
|
||||||
ac_change_air_swing(b);
|
ac_change_air_swing(b);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 3: // 1 : clean on, power on
|
case 3: // 1 : clean on, power on
|
||||||
if ( b == 0 || b == 1 ) {
|
if ( b == 0 | b == 1 ) {
|
||||||
ac_air_clean(b);
|
ac_air_clean(b);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
25
irRecv.cpp
25
irRecv.cpp
@@ -1,11 +1,6 @@
|
|||||||
#include "IRremote.h"
|
#include "IRremote.h"
|
||||||
#include "IRremoteInt.h"
|
#include "IRremoteInt.h"
|
||||||
|
|
||||||
#ifdef IR_TIMER_USE_ESP32
|
|
||||||
hw_timer_t *timer;
|
|
||||||
void IRTimer(); // defined in IRremote.cpp
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//+=============================================================================
|
//+=============================================================================
|
||||||
// Decodes the received IR message
|
// Decodes the received IR message
|
||||||
// Returns 0 if no data ready, 1 if data ready.
|
// Returns 0 if no data ready, 1 if data ready.
|
||||||
@@ -89,11 +84,6 @@ int IRrecv::decode (decode_results *results)
|
|||||||
DBG_PRINTLN("Attempting Lego Power Functions");
|
DBG_PRINTLN("Attempting Lego Power Functions");
|
||||||
if (decodeLegoPowerFunctions(results)) return true ;
|
if (decodeLegoPowerFunctions(results)) return true ;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if DECODE_NERF_LOP
|
|
||||||
DBG_PRINTLN("Attempting Nerf Laser Ops Pro Functions");
|
|
||||||
if (decodeNerfLOP(results)) return true ;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// decodeHash returns a hash on any input.
|
// decodeHash returns a hash on any input.
|
||||||
// Thus, it needs to be last in the list.
|
// Thus, it needs to be last in the list.
|
||||||
@@ -125,19 +115,10 @@ IRrecv::IRrecv (int recvpin, int blinkpin)
|
|||||||
//+=============================================================================
|
//+=============================================================================
|
||||||
// initialization
|
// initialization
|
||||||
//
|
//
|
||||||
|
#ifdef USE_DEFAULT_ENABLE_IR_IN
|
||||||
void IRrecv::enableIRIn ( )
|
void IRrecv::enableIRIn ( )
|
||||||
{
|
{
|
||||||
// Interrupt Service Routine - Fires every 50uS
|
// Interrupt Service Routine - Fires every 50uS
|
||||||
#ifdef ESP32
|
|
||||||
// ESP32 has a proper API to setup timers, no weird chip macros needed
|
|
||||||
// simply call the readable API versions :)
|
|
||||||
// 3 timers, choose #1, 80 divider nanosecond precision, 1 to count up
|
|
||||||
timer = timerBegin(1, 80, 1);
|
|
||||||
timerAttachInterrupt(timer, &IRTimer, 1);
|
|
||||||
// every 50ns, autoreload = true
|
|
||||||
timerAlarmWrite(timer, 50, true);
|
|
||||||
timerAlarmEnable(timer);
|
|
||||||
#else
|
|
||||||
cli();
|
cli();
|
||||||
// Setup pulse clock timer interrupt
|
// Setup pulse clock timer interrupt
|
||||||
// Prescale /8 (16M/8 = 0.5 microseconds per tick)
|
// Prescale /8 (16M/8 = 0.5 microseconds per tick)
|
||||||
@@ -151,7 +132,6 @@ void IRrecv::enableIRIn ( )
|
|||||||
TIMER_RESET;
|
TIMER_RESET;
|
||||||
|
|
||||||
sei(); // enable interrupts
|
sei(); // enable interrupts
|
||||||
#endif
|
|
||||||
|
|
||||||
// Initialize state machine variables
|
// Initialize state machine variables
|
||||||
irparams.rcvstate = STATE_IDLE;
|
irparams.rcvstate = STATE_IDLE;
|
||||||
@@ -160,14 +140,17 @@ void IRrecv::enableIRIn ( )
|
|||||||
// Set pin modes
|
// Set pin modes
|
||||||
pinMode(irparams.recvpin, INPUT);
|
pinMode(irparams.recvpin, INPUT);
|
||||||
}
|
}
|
||||||
|
#endif // USE_DEFAULT_ENABLE_IR_IN
|
||||||
|
|
||||||
//+=============================================================================
|
//+=============================================================================
|
||||||
// Enable/disable blinking of pin 13 on IR processing
|
// Enable/disable blinking of pin 13 on IR processing
|
||||||
//
|
//
|
||||||
void IRrecv::blink13 (int blinkflag)
|
void IRrecv::blink13 (int blinkflag)
|
||||||
{
|
{
|
||||||
|
#ifdef BLINKLED
|
||||||
irparams.blinkflag = blinkflag;
|
irparams.blinkflag = blinkflag;
|
||||||
if (blinkflag) pinMode(BLINKLED, OUTPUT) ;
|
if (blinkflag) pinMode(BLINKLED, OUTPUT) ;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
//+=============================================================================
|
//+=============================================================================
|
||||||
|
|||||||
61
irSend.cpp
61
irSend.cpp
@@ -1,6 +1,7 @@
|
|||||||
#include "IRremote.h"
|
#include "IRremote.h"
|
||||||
#include "IRremoteInt.h"
|
#include "IRremoteInt.h"
|
||||||
|
|
||||||
|
#ifdef SENDING_SUPPORTED
|
||||||
//+=============================================================================
|
//+=============================================================================
|
||||||
void IRsend::sendRaw (const unsigned int buf[], unsigned int len, unsigned int hz)
|
void IRsend::sendRaw (const unsigned int buf[], unsigned int len, unsigned int hz)
|
||||||
{
|
{
|
||||||
@@ -15,14 +16,59 @@ void IRsend::sendRaw (const unsigned int buf[], unsigned int len, unsigned in
|
|||||||
space(0); // Always end with the LED off
|
space(0); // Always end with the LED off
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef USE_SOFT_CARRIER
|
||||||
|
void inline IRsend::sleepMicros(unsigned long us)
|
||||||
|
{
|
||||||
|
#ifdef USE_SPIN_WAIT
|
||||||
|
sleepUntilMicros(micros() + us);
|
||||||
|
#else
|
||||||
|
if (us > 0U) // Is this necessary? (Official docu https://www.arduino.cc/en/Reference/DelayMicroseconds does not tell.)
|
||||||
|
delayMicroseconds((unsigned int) us);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void inline IRsend::sleepUntilMicros(unsigned long targetTime)
|
||||||
|
{
|
||||||
|
#ifdef USE_SPIN_WAIT
|
||||||
|
while (micros() < targetTime)
|
||||||
|
;
|
||||||
|
#else
|
||||||
|
unsigned long now = micros();
|
||||||
|
if (now < targetTime)
|
||||||
|
sleepMicros(targetTime - now);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#endif // USE_SOFT_CARRIER
|
||||||
|
|
||||||
//+=============================================================================
|
//+=============================================================================
|
||||||
// Sends an IR mark for the specified number of microseconds.
|
// Sends an IR mark for the specified number of microseconds.
|
||||||
// The mark output is modulated at the PWM frequency.
|
// The mark output is modulated at the PWM frequency.
|
||||||
//
|
//
|
||||||
void IRsend::mark (unsigned int time)
|
|
||||||
|
void IRsend::mark(unsigned int time)
|
||||||
{
|
{
|
||||||
|
#ifdef USE_SOFT_CARRIER
|
||||||
|
unsigned long start = micros();
|
||||||
|
unsigned long stop = start + time;
|
||||||
|
if (stop + periodTime < start)
|
||||||
|
// Counter wrap-around, happens very seldomly, but CAN happen.
|
||||||
|
// Just give up instead of possibly damaging the hardware.
|
||||||
|
return;
|
||||||
|
|
||||||
|
unsigned long nextPeriodEnding = start;
|
||||||
|
unsigned long now = micros();
|
||||||
|
while (now < stop) {
|
||||||
|
SENDPIN_ON(sendPin);
|
||||||
|
sleepMicros(periodOnTime);
|
||||||
|
SENDPIN_OFF(sendPin);
|
||||||
|
nextPeriodEnding += periodTime;
|
||||||
|
sleepUntilMicros(nextPeriodEnding);
|
||||||
|
now = micros();
|
||||||
|
}
|
||||||
|
#else
|
||||||
TIMER_ENABLE_PWM; // Enable pin 3 PWM output
|
TIMER_ENABLE_PWM; // Enable pin 3 PWM output
|
||||||
if (time > 0) custom_delay_usec(time);
|
if (time > 0) custom_delay_usec(time);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
//+=============================================================================
|
//+=============================================================================
|
||||||
@@ -54,13 +100,16 @@ void IRsend::space (unsigned int time)
|
|||||||
//
|
//
|
||||||
void IRsend::enableIROut (int khz)
|
void IRsend::enableIROut (int khz)
|
||||||
{
|
{
|
||||||
// FIXME: implement ESP32 support, see IR_TIMER_USE_ESP32 in boarddefs.h
|
#ifdef USE_SOFT_CARRIER
|
||||||
#ifndef ESP32
|
periodTime = (1000U + khz/2) / khz; // = 1000/khz + 1/2 = round(1000.0/khz)
|
||||||
|
periodOnTime = periodTime * DUTY_CYCLE / 100U - PULSE_CORRECTION;
|
||||||
|
#endif
|
||||||
|
|
||||||
// Disable the Timer2 Interrupt (which is used for receiving IR)
|
// Disable the Timer2 Interrupt (which is used for receiving IR)
|
||||||
TIMER_DISABLE_INTR; //Timer2 Overflow Interrupt
|
TIMER_DISABLE_INTR; //Timer2 Overflow Interrupt
|
||||||
|
|
||||||
pinMode(TIMER_PWM_PIN, OUTPUT);
|
pinMode(sendPin, OUTPUT);
|
||||||
digitalWrite(TIMER_PWM_PIN, LOW); // When not sending PWM, we want it low
|
SENDPIN_OFF(sendPin); // When not sending, we want it low
|
||||||
|
|
||||||
// COM2A = 00: disconnect OC2A
|
// COM2A = 00: disconnect OC2A
|
||||||
// COM2B = 00: disconnect OC2B; to send signal set to 10: OC2B non-inverted
|
// COM2B = 00: disconnect OC2B; to send signal set to 10: OC2B non-inverted
|
||||||
@@ -68,7 +117,6 @@ void IRsend::enableIROut (int khz)
|
|||||||
// CS2 = 000: no prescaling
|
// CS2 = 000: no prescaling
|
||||||
// The top value for the timer. The modulation frequency will be SYSCLOCK / 2 / OCR2A.
|
// The top value for the timer. The modulation frequency will be SYSCLOCK / 2 / OCR2A.
|
||||||
TIMER_CONFIG_KHZ(khz);
|
TIMER_CONFIG_KHZ(khz);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//+=============================================================================
|
//+=============================================================================
|
||||||
@@ -88,3 +136,4 @@ void IRsend::custom_delay_usec(unsigned long uSecs) {
|
|||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // SENDING_SUPPORTED
|
||||||
@@ -1,89 +0,0 @@
|
|||||||
#include "IRremote.h"
|
|
||||||
#include "IRremoteInt.h"
|
|
||||||
|
|
||||||
//==============================================================================
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// NERF LASER OPS PRO
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//==============================================================================
|
|
||||||
|
|
||||||
#define BITS 15 // The number of bits in the command
|
|
||||||
|
|
||||||
#define HDR_MARK 2800 // The length of the Header:Mark
|
|
||||||
#define HDR_SPACE 6000 // The lenght of the Header:Space
|
|
||||||
|
|
||||||
#define ONE_MARK 1800 // The length of a Bit:Mark for 1's
|
|
||||||
#define ZERO_MARK 800 // The length of a Bit:Mark for 0's
|
|
||||||
#define ALL_SPACE 2100 // The length of a Bit:Space
|
|
||||||
|
|
||||||
#define purpule 0x440
|
|
||||||
#define red 0x400
|
|
||||||
#define blue 0x420
|
|
||||||
|
|
||||||
//+=============================================================================
|
|
||||||
//
|
|
||||||
#if SEND_NERF_LOP
|
|
||||||
void IRsend::sendNerfLOP (unsigned long data, int nbits)
|
|
||||||
{
|
|
||||||
// Set IR carrier frequency
|
|
||||||
enableIROut(40);
|
|
||||||
|
|
||||||
// Header
|
|
||||||
mark (HDR_MARK);
|
|
||||||
space(HDR_SPACE);
|
|
||||||
mark (HDR_MARK);
|
|
||||||
|
|
||||||
// Data
|
|
||||||
for (unsigned long mask = 1UL << (nbits - 1); mask; mask >>= 1) {
|
|
||||||
if (data & mask) {
|
|
||||||
space(ALL_SPACE);
|
|
||||||
mark (ONE_MARK);
|
|
||||||
} else {
|
|
||||||
space(ALL_SPACE);
|
|
||||||
mark (ZERO_MARK);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
space(0); // Always end with the LED off
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//+=============================================================================
|
|
||||||
//
|
|
||||||
#if DECODE_NERF_LOP
|
|
||||||
bool IRrecv::decodeNerfLOP (decode_results *results)
|
|
||||||
{
|
|
||||||
//NOT IMPLEMENTED YET
|
|
||||||
return false;
|
|
||||||
unsigned long data = 0; // Somewhere to build our code
|
|
||||||
int offset = 1; // Skip the Gap reading
|
|
||||||
|
|
||||||
// Check we have the right amount of data
|
|
||||||
if (irparams.rawlen != 1 + 2 + (2 * BITS) + 1) return false ;
|
|
||||||
|
|
||||||
// Check initial Mark+Space match
|
|
||||||
if (!MATCH_MARK (results->rawbuf[offset++], HDR_MARK )) return false ;
|
|
||||||
if (!MATCH_SPACE(results->rawbuf[offset++], HDR_SPACE)) return false ;
|
|
||||||
|
|
||||||
// Read the bits in
|
|
||||||
for (int i = 0; i < SHUZU_BITS; i++) {
|
|
||||||
// Each bit looks like: MARK + SPACE_1 -> 1
|
|
||||||
// or : MARK + SPACE_0 -> 0
|
|
||||||
if (!MATCH_MARK(results->rawbuf[offset++], BIT_MARK)) return false ;
|
|
||||||
|
|
||||||
// IR data is big-endian, so we shuffle it in from the right:
|
|
||||||
if (MATCH_SPACE(results->rawbuf[offset], ONE_SPACE)) data = (data << 1) | 1 ;
|
|
||||||
else if (MATCH_SPACE(results->rawbuf[offset], ZERO_SPACE)) data = (data << 1) | 0 ;
|
|
||||||
else return false ;
|
|
||||||
offset++;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Success
|
|
||||||
results->bits = BITS;
|
|
||||||
results->value = data;
|
|
||||||
results->decode_type = SHUZU;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
@@ -1,97 +0,0 @@
|
|||||||
## IRremote Library
|
|
||||||
|
|
||||||
|
|
||||||
Cette bibliothèque vous permet d'envoyer et de recevoir des signaux infrarouges sur un Arduino.
|
|
||||||
Des tutoriels et plus d'informations seront disponibles sur la page d'accueil officielle.
|
|
||||||
|
|
||||||
## Version - 2.2.3
|
|
||||||
|
|
||||||
## Installation
|
|
||||||
1. Allez à la [Releases](https://github.com/z3t0/Arduino-IRremote/releases) page.
|
|
||||||
2. Téléchargez la dernière version.
|
|
||||||
3. Extraire le fichier zip
|
|
||||||
4. Déplacez le dossier "IRremote" vers vos bibliothèques.
|
|
||||||
5. Assurez-vous de supprimer Arduino_Root / libraries / RobotIRremote. Où Arduino_Root fait référence au répertoire d'installation d'Arduino. La bibliothèque RobotIRremote a des définitions similaires à IRremote et provoque des erreurs.
|
|
||||||
|
|
||||||
|
|
||||||
## FAQ
|
|
||||||
Je ne travaille pas correctement en utilisant Neopixels (aka WS2811 / WS2812 / WS2812B)
|
|
||||||
Que vous utilisiez la librairie Adafruit Neopixel ou FastLED, les interruptions sont désactivées sur de nombreux processeurs bas de gamme comme les arduinos de base. À son tour, cela empêche le gestionnaire IR de s'exécuter quand il le faut. Il y a quelques solutions à ce processus, voir cette page de Marc MERLIN
|
|
||||||
[cette page de Marc MERLIN](http://marc.merlins.org/perso/arduino/post_2017-04-03_Arduino-328P-Uno-Teensy3_1-ESP8266-ESP32-IR-and-Neopixels.html)
|
|
||||||
|
|
||||||
|
|
||||||
## Conseils pris en charge
|
|
||||||
|
|
||||||
- Teensy 1.0 / 1.0++ / 2.0 / 2++ / 3.0 / 3.1 / Teensy-LC; Crédits: @PaulStoffregen (Teensy Team)
|
|
||||||
- Sanguino
|
|
||||||
- ATmega8, 48, 88, 168, 328
|
|
||||||
- ATmega8535, 16, 32, 164, 324, 644, 1284,
|
|
||||||
- ATmega64, 128
|
|
||||||
- ATtiny 84 / 85
|
|
||||||
- ESP32 (recevoir seulement)
|
|
||||||
- ESP8266 est basé sur un ancien code qui n'est pas très récent, mais cela fonctionne raisonnablement bien. Voir https://github.com/markszabo/IRremoteESP8266
|
|
||||||
Sparkfun Pro Micro
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Nous sommes ouverts aux suggestions d'ajout de support pour les nouveaux tableaux, cependant, nous vous recommandons fortement de contacter votre fournisseur et de fournir un soutien de leur côté.
|
|
||||||
|
|
||||||
|
|
||||||
## Spécifications matérielles
|
|
||||||
|
|
||||||
|
|
||||||
| Carte/CPU | Envoyer Pin | Compteurs |
|
|
||||||
|--------------------------------------------------------------------------|---------------------|-------------------|
|
|
||||||
| [ATtiny84](https://github.com/SpenceKonde/ATTinyCore) | **6** | **1** |
|
|
||||||
| [ATtiny85](https://github.com/SpenceKonde/ATTinyCore) | **1** | **TINY0** |
|
|
||||||
| [ATmega8](https://github.com/MCUdude/MiniCore) | **9** | **1** |
|
|
||||||
| Atmega32u4 | 5, 9, **13** | 1, 3, **4** |
|
|
||||||
| [ATmega48, ATmega88, ATmega168, ATmega328](https://github.com/MCUdude/MiniCore) | **3**, 9 | 1, **2** |
|
|
||||||
| [ATmega1284](https://github.com/MCUdude/MightyCore) | 13, 14, 6 | 1, **2**, 3 |
|
|
||||||
| [ATmega164, ATmega324, ATmega644](https://github.com/MCUdude/MightyCore) | 13, **14** | 1, **2** |
|
|
||||||
| [ATmega8535 ATmega16, ATmega32](https://github.com/MCUdude/MightyCore) | **13** | **1** |
|
|
||||||
| [ATmega64, ATmega128](https://github.com/MCUdude/MegaCore) | **13** | **1** |
|
|
||||||
| ATmega1280, ATmega2560 | 5, 6, **9**, 11, 46 | 1, **2**, 3, 4, 5 |
|
|
||||||
| [ESP32](http://esp32.net/) | N/A (insupporté) | **1** |
|
|
||||||
| [Sparkfun Pro Micro](https://www.sparkfun.com/products/12640) | 9, **5**, 5 | 1, **3**, 4_HS |
|
|
||||||
| [Teensy 1.0](https://www.pjrc.com/teensy/) | **17** | **1** |
|
|
||||||
| [Teensy 2.0](https://www.pjrc.com/teensy/) | 9, **10**, 14 | 1, 3, **4_HS** |
|
|
||||||
| [Teensy++ 1.0 / 2.0](https://www.pjrc.com/teensy/) | **1**, 16, 25 | 1, **2**, 3 |
|
|
||||||
| [Teensy 3.0 / 3.1](https://www.pjrc.com/teensy/) | **5** | **CMT** |
|
|
||||||
| [Teensy-LC](https://www.pjrc.com/teensy/) | **16** | **TPM1** |
|
|
||||||
|
|
||||||
|
|
||||||
## Patchs expérimentaux
|
|
||||||
|
|
||||||
Voici les correctifs strictement pris en charge qui n'ont pas encore été intégrés. Si vous avez des questions, n'hésitez pas à demander ici. Si cela fonctionne, faites le nous savoir!
|
|
||||||
|
|
||||||
[Arduino 101](https://github.com/z3t0/Arduino-IRremote/pull/481#issuecomment-311243146)
|
|
||||||
|
|
||||||
Le tableau ci-dessus répertorie les temporisations actuellement supportées et les broches d'envoi correspondantes, beaucoup de ces broches supplémentaires sont ouvertes.
|
|
||||||
|
|
||||||
|
|
||||||
## Utilisation
|
|
||||||
- À faire TODO (Vérifier les exemples pour l'instant)
|
|
||||||
|
|
||||||
|
|
||||||
## Contribution
|
|
||||||
Si vous voulez contribuer à ce projet:
|
|
||||||
- Signaler les bogues et les erreurs
|
|
||||||
- Demander des améliorations
|
|
||||||
- Créer des problèmes et tirer des requêtes
|
|
||||||
- Parlez de cette bibliothèque à d'autres personnes
|
|
||||||
- Contribuer de nouveaux protocoles
|
|
||||||
Vérifiez ici [ici](Contributing.md) pour quelques guidelines
|
|
||||||
|
|
||||||
|
|
||||||
## Contact
|
|
||||||
Email: zetoslab@gmail.com
|
|
||||||
Please only email me if it is more appropriate than creating an Issue / PR. I **will** not respond to requests for adding support for particular boards, unless of course you are the creator of the board and would like to cooperate on the project. I will also **ignore** any emails asking me to tell you how to implement your ideas. However, if you have a private inquiry that you would only apply to you and you would prefer it to be via email, by all means.
|
|
||||||
|
|
||||||
## Contributeurs
|
|
||||||
Check [here](Contributors.md)
|
|
||||||
@Lsuperman735 French translation
|
|
||||||
|
|
||||||
## Copyright
|
|
||||||
Copyright 2009-2012 Ken Shirriff
|
|
||||||
102
sam.cpp
Normal file
102
sam.cpp
Normal file
@@ -0,0 +1,102 @@
|
|||||||
|
// Support routines for SAM processor boards
|
||||||
|
|
||||||
|
#include "IRremote.h"
|
||||||
|
#include "IRremoteInt.h"
|
||||||
|
|
||||||
|
#if defined(ARDUINO_ARCH_SAM) || defined(ARDUINO_ARCH_SAMD)
|
||||||
|
|
||||||
|
// "Idiot check"
|
||||||
|
#ifdef USE_DEFAULT_ENABLE_IR_IN
|
||||||
|
#error Must undef USE_DEFAULT_ENABLE_IR_IN
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//+=============================================================================
|
||||||
|
// ATSAMD Timer setup & IRQ functions
|
||||||
|
//
|
||||||
|
|
||||||
|
// following based on setup from GitHub jdneo/timerInterrupt.ino
|
||||||
|
|
||||||
|
static void setTimerFrequency(int frequencyHz)
|
||||||
|
{
|
||||||
|
int compareValue = (SYSCLOCK / (TIMER_PRESCALER_DIV * frequencyHz)) - 1;
|
||||||
|
//Serial.println(compareValue);
|
||||||
|
TcCount16* TC = (TcCount16*) TC3;
|
||||||
|
// Make sure the count is in a proportional position to where it was
|
||||||
|
// to prevent any jitter or disconnect when changing the compare value.
|
||||||
|
TC->COUNT.reg = map(TC->COUNT.reg, 0, TC->CC[0].reg, 0, compareValue);
|
||||||
|
TC->CC[0].reg = compareValue;
|
||||||
|
//Serial.print("COUNT.reg ");
|
||||||
|
//Serial.println(TC->COUNT.reg);
|
||||||
|
//Serial.print("CC[0].reg ");
|
||||||
|
//Serial.println(TC->CC[0].reg);
|
||||||
|
while (TC->STATUS.bit.SYNCBUSY == 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void startTimer()
|
||||||
|
{
|
||||||
|
REG_GCLK_CLKCTRL = (uint16_t) (GCLK_CLKCTRL_CLKEN | GCLK_CLKCTRL_GEN_GCLK0 | GCLK_CLKCTRL_ID_TCC2_TC3);
|
||||||
|
while (GCLK->STATUS.bit.SYNCBUSY == 1); // wait for sync
|
||||||
|
|
||||||
|
TcCount16* TC = (TcCount16*) TC3;
|
||||||
|
|
||||||
|
TC->CTRLA.reg &= ~TC_CTRLA_ENABLE;
|
||||||
|
while (TC->STATUS.bit.SYNCBUSY == 1); // wait for sync
|
||||||
|
|
||||||
|
// Use the 16-bit timer
|
||||||
|
TC->CTRLA.reg |= TC_CTRLA_MODE_COUNT16;
|
||||||
|
while (TC->STATUS.bit.SYNCBUSY == 1); // wait for sync
|
||||||
|
|
||||||
|
// Use match mode so that the timer counter resets when the count matches the compare register
|
||||||
|
TC->CTRLA.reg |= TC_CTRLA_WAVEGEN_MFRQ;
|
||||||
|
while (TC->STATUS.bit.SYNCBUSY == 1); // wait for sync
|
||||||
|
|
||||||
|
// Set prescaler to 1024
|
||||||
|
//TC->CTRLA.reg |= TC_CTRLA_PRESCALER_DIV1024;
|
||||||
|
TC->CTRLA.reg |= TC_CTRLA_PRESCALER_DIV64;
|
||||||
|
while (TC->STATUS.bit.SYNCBUSY == 1); // wait for sync
|
||||||
|
|
||||||
|
setTimerFrequency(1000000 / USECPERTICK);
|
||||||
|
|
||||||
|
// Enable the compare interrupt
|
||||||
|
TC->INTENSET.reg = 0;
|
||||||
|
TC->INTENSET.bit.MC0 = 1;
|
||||||
|
|
||||||
|
NVIC_EnableIRQ(TC3_IRQn);
|
||||||
|
|
||||||
|
TC->CTRLA.reg |= TC_CTRLA_ENABLE;
|
||||||
|
while (TC->STATUS.bit.SYNCBUSY == 1); // wait for sync
|
||||||
|
}
|
||||||
|
|
||||||
|
//+=============================================================================
|
||||||
|
// initialization
|
||||||
|
//
|
||||||
|
|
||||||
|
void IRrecv::enableIRIn()
|
||||||
|
{
|
||||||
|
// Interrupt Service Routine - Fires every 50uS
|
||||||
|
//Serial.println("Starting timer");
|
||||||
|
startTimer();
|
||||||
|
//Serial.println("Started timer");
|
||||||
|
|
||||||
|
// Initialize state machine variables
|
||||||
|
irparams.rcvstate = STATE_IDLE;
|
||||||
|
irparams.rawlen = 0;
|
||||||
|
|
||||||
|
// Set pin modes
|
||||||
|
pinMode(irparams.recvpin, INPUT);
|
||||||
|
}
|
||||||
|
|
||||||
|
void irs(); // Defined in IRRemote as ISR(TIMER_INTR_NAME)
|
||||||
|
|
||||||
|
void TC3_Handler(void)
|
||||||
|
{
|
||||||
|
TcCount16* TC = (TcCount16*) TC3;
|
||||||
|
// If this interrupt is due to the compare register matching the timer count
|
||||||
|
// we toggle the LED.
|
||||||
|
if (TC->INTFLAG.bit.MC0 == 1) {
|
||||||
|
TC->INTFLAG.bit.MC0 = 1;
|
||||||
|
irs();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // defined(ARDUINO_ARCH_SAM) || defined(ARDUINO_ARCH_SAMD)
|
||||||
Reference in New Issue
Block a user