mirror of
https://github.com/Theaninova/Arduino-IRremote.git
synced 2025-12-30 10:12:49 +00:00
Compare commits
4 Commits
beta
...
feature-re
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
222630922f | ||
|
|
9b39a2f7dc | ||
|
|
42b791f9ad | ||
|
|
c43d221a7b |
20
README.md
20
README.md
@@ -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/).
|
||||
|
||||
## Version - 2.5.0b
|
||||
## Version - 2.4.0b
|
||||
|
||||
## Installation
|
||||
1. Navigate to the [Releases](https://github.com/z3t0/Arduino-IRremote/releases) page.
|
||||
@@ -19,7 +19,7 @@ Tutorials and more information will be made available on [the official homepage]
|
||||
|
||||
|
||||
## FAQ
|
||||
- IR does not work right when I use Neopixels (aka WS2811/WS2812/WS2812B)
|
||||
- IR does not work right when I use Neopixels (aka WS2811/WS2812/WS2812B)
|
||||
Whether you use the Adafruit Neopixel lib, or FastLED, interrupts get disabled on many lower end CPUs like the basic arduinos. In turn, this stops the IR interrupt handler from running when it needs to. There are some solutions to this on some processors, [see this page from Marc MERLIN](http://marc.merlins.org/perso/arduino/post_2017-04-03_Arduino-328P-Uno-Teensy3_1-ESP8266-ESP32-IR-and-Neopixels.html)
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ We are open to suggestions for adding support to new boards, however we highly r
|
||||
| [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** |
|
||||
| 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** |
|
||||
@@ -68,20 +68,6 @@ The table above lists the currently supported timers and corresponding send pins
|
||||
## Usage
|
||||
- TODO (Check examples for now)
|
||||
|
||||
## API documentation
|
||||
This project documents the library API using [Doxygen](http://www.doxygen.org).
|
||||
It is planned to make generated and up-to-date API documentation available online.
|
||||
|
||||
To generate the API documentation,
|
||||
Doxygen, as well as [Graphviz](http://www.graphviz.org/) should be installed.
|
||||
(Note that on Windows, it may be necessary to add the Graphviz binary directory
|
||||
(something like `C:\Program Files\Graphviz2.38\bin`)
|
||||
to the `PATH` variable manually.)
|
||||
With Doxygen and Graphviz installed, issue the command
|
||||
`doxygen` from the command line in the main project directory, which will
|
||||
generate the API documentation in HTML format.
|
||||
The just generated `api-doc/index.html` can now be opened in a browser.
|
||||
|
||||
## Contributing
|
||||
If you want to contribute to this project:
|
||||
- Report bugs and errors
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
## 2.5.0
|
||||
- Added Philips Extended RC-5 protocol support [PR #522] (https://github.com/z3t0/Arduino-IRremote/pull/522)
|
||||
|
||||
## 2.4.0 - 2017/08/10
|
||||
- Cleanup of hardware dependencies. Merge in SAM support [PR #437](https://github.com/z3t0/Arduino-IRremote/pull/437)
|
||||
|
||||
|
||||
@@ -56,6 +56,7 @@ void encoding (decode_results *results)
|
||||
case AIWA_RC_T501: Serial.print("AIWA_RC_T501"); break ;
|
||||
case PANASONIC: Serial.print("PANASONIC"); break ;
|
||||
case DENON: Serial.print("Denon"); break ;
|
||||
case RECS80: Serial.print("RECS80"); break ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
16
examples/IRsendRECS80Test/IRsendRECS80Test.ino
Normal file
16
examples/IRsendRECS80Test/IRsendRECS80Test.ino
Normal file
@@ -0,0 +1,16 @@
|
||||
|
||||
#include <IRremote.h>
|
||||
|
||||
IRsend irsend;
|
||||
|
||||
void setup()
|
||||
{
|
||||
delay(2000);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
for (int i = 0; i < 512; i++) {
|
||||
irsend.sendRECS80(i);
|
||||
delay(5000); //5 second delay between each signal burst
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@
|
||||
*/
|
||||
|
||||
#include <IRremote.h>
|
||||
#include <IRremoteInt.h>
|
||||
|
||||
// Dumps out the decode_results structure.
|
||||
// Call this after IRrecv::decode()
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
*/
|
||||
|
||||
#include <IRremote.h>
|
||||
#include <IRremoteInt.h>
|
||||
|
||||
IRsend irsend;
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ version=2.4.0
|
||||
author=shirriff, z3t0
|
||||
maintainer=z3t0
|
||||
sentence=Send and receive infrared signals with multiple protocols
|
||||
paragraph=Find more information at https://github.com/z3t0/Arduino-IRremote
|
||||
paragraph=See more at https://github.com/z3t0/Arduino-IRremote
|
||||
category=Communication
|
||||
url=https://github.com/z3t0/Arduino-IRremote
|
||||
architectures=*
|
||||
|
||||
@@ -20,7 +20,8 @@
|
||||
|
||||
// Defining IR_GLOBAL here allows us to declare the instantiation of global variables
|
||||
#define IR_GLOBAL
|
||||
#include "IRremote.h"
|
||||
# include "IRremote.h"
|
||||
# include "IRremoteInt.h"
|
||||
#undef IR_GLOBAL
|
||||
|
||||
#ifdef HAS_AVR_INTERRUPT_H
|
||||
@@ -51,12 +52,11 @@ int MATCH (int measured, int desired)
|
||||
DBG_PRINT(TICKS_HIGH(desired), DEC);
|
||||
|
||||
bool passed = ((measured >= TICKS_LOW(desired)) && (measured <= TICKS_HIGH(desired)));
|
||||
if (passed) {
|
||||
if (passed)
|
||||
DBG_PRINTLN(F("?; passed"));
|
||||
} else {
|
||||
DBG_PRINTLN(F("?; FAILED"));
|
||||
}
|
||||
return passed;
|
||||
else
|
||||
DBG_PRINTLN(F("?; FAILED"));
|
||||
return passed;
|
||||
}
|
||||
|
||||
//+========================================================
|
||||
@@ -68,7 +68,7 @@ int MATCH_MARK (int measured_ticks, int desired_us)
|
||||
DBG_PRINT(measured_ticks * USECPERTICK, DEC);
|
||||
DBG_PRINT(F("us vs "));
|
||||
DBG_PRINT(desired_us, DEC);
|
||||
DBG_PRINT("us");
|
||||
DBG_PRINT("us");
|
||||
DBG_PRINT(": ");
|
||||
DBG_PRINT(TICKS_LOW(desired_us + MARK_EXCESS) * USECPERTICK, DEC);
|
||||
DBG_PRINT(F(" <= "));
|
||||
@@ -78,12 +78,11 @@ int MATCH_MARK (int measured_ticks, int desired_us)
|
||||
|
||||
bool passed = ((measured_ticks >= TICKS_LOW (desired_us + MARK_EXCESS))
|
||||
&& (measured_ticks <= TICKS_HIGH(desired_us + MARK_EXCESS)));
|
||||
if (passed) {
|
||||
if (passed)
|
||||
DBG_PRINTLN(F("?; passed"));
|
||||
} else {
|
||||
DBG_PRINTLN(F("?; FAILED"));
|
||||
}
|
||||
return passed;
|
||||
else
|
||||
DBG_PRINTLN(F("?; FAILED"));
|
||||
return passed;
|
||||
}
|
||||
|
||||
//+========================================================
|
||||
@@ -95,7 +94,7 @@ int MATCH_SPACE (int measured_ticks, int desired_us)
|
||||
DBG_PRINT(measured_ticks * USECPERTICK, DEC);
|
||||
DBG_PRINT(F("us vs "));
|
||||
DBG_PRINT(desired_us, DEC);
|
||||
DBG_PRINT("us");
|
||||
DBG_PRINT("us");
|
||||
DBG_PRINT(": ");
|
||||
DBG_PRINT(TICKS_LOW(desired_us - MARK_EXCESS) * USECPERTICK, DEC);
|
||||
DBG_PRINT(F(" <= "));
|
||||
@@ -105,12 +104,11 @@ int MATCH_SPACE (int measured_ticks, int desired_us)
|
||||
|
||||
bool passed = ((measured_ticks >= TICKS_LOW (desired_us - MARK_EXCESS))
|
||||
&& (measured_ticks <= TICKS_HIGH(desired_us - MARK_EXCESS)));
|
||||
if (passed) {
|
||||
if (passed)
|
||||
DBG_PRINTLN(F("?; passed"));
|
||||
} else {
|
||||
DBG_PRINTLN(F("?; FAILED"));
|
||||
}
|
||||
return passed;
|
||||
else
|
||||
DBG_PRINTLN(F("?; FAILED"));
|
||||
return passed;
|
||||
}
|
||||
|
||||
//+=============================================================================
|
||||
|
||||
122
src/IRremote.h
122
src/IRremote.h
@@ -1,7 +1,3 @@
|
||||
/**
|
||||
* @file IRremote.h
|
||||
* @brief Public API to the library.
|
||||
*/
|
||||
|
||||
//******************************************************************************
|
||||
// IRremote
|
||||
@@ -25,7 +21,7 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// The ISR header contains several useful macros the user may wish to use
|
||||
//
|
||||
#include "private/IRremoteInt.h"
|
||||
#include "IRremoteInt.h"
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Supported IR protocols
|
||||
@@ -83,6 +79,9 @@
|
||||
#define DECODE_LEGO_PF 0 // NOT WRITTEN
|
||||
#define SEND_LEGO_PF 1
|
||||
|
||||
#define DECODE_RECS80 1 // NOT WRITTEN
|
||||
#define SEND_RECS80 1 // Still being tested
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// When sending a Pronto code we request to send either the "once" code
|
||||
// or the "repeat" code
|
||||
@@ -98,10 +97,10 @@
|
||||
#define PRONTO_FALLBACK true
|
||||
#define PRONTO_NOFALLBACK false
|
||||
|
||||
/**
|
||||
* An enum consisting of all supported formats.
|
||||
* You do NOT need to remove entries from this list when disabling protocols!
|
||||
*/
|
||||
//------------------------------------------------------------------------------
|
||||
// An enumerated list of all supported formats
|
||||
// You do NOT need to remove entries from this list when disabling protocols!
|
||||
//
|
||||
typedef
|
||||
enum {
|
||||
UNKNOWN = -1,
|
||||
@@ -123,13 +122,14 @@ typedef
|
||||
DENON,
|
||||
PRONTO,
|
||||
LEGO_PF,
|
||||
RECS80,
|
||||
}
|
||||
decode_type_t;
|
||||
|
||||
/**
|
||||
* Set DEBUG to 1 for lots of lovely debug output.
|
||||
*/
|
||||
#define DEBUG 0
|
||||
//------------------------------------------------------------------------------
|
||||
// Set DEBUG to 1 for lots of lovely debug output
|
||||
//
|
||||
#define DEBUG 0
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Debug directives
|
||||
@@ -138,13 +138,7 @@ decode_type_t;
|
||||
# define DBG_PRINT(...) Serial.print(__VA_ARGS__)
|
||||
# define DBG_PRINTLN(...) Serial.println(__VA_ARGS__)
|
||||
#else
|
||||
/**
|
||||
* If DEBUG, print the arguments, otherwise do nothing.
|
||||
*/
|
||||
# define DBG_PRINT(...)
|
||||
/**
|
||||
* If DEBUG, print the arguments as a line, otherwise do nothing.
|
||||
*/
|
||||
# define DBG_PRINTLN(...)
|
||||
#endif
|
||||
|
||||
@@ -155,71 +149,39 @@ int MATCH (int measured, int desired) ;
|
||||
int MATCH_MARK (int measured_ticks, int desired_us) ;
|
||||
int MATCH_SPACE (int measured_ticks, int desired_us) ;
|
||||
|
||||
/**
|
||||
* Results returned from the decoder
|
||||
*/
|
||||
//------------------------------------------------------------------------------
|
||||
// Results returned from the decoder
|
||||
//
|
||||
class decode_results
|
||||
{
|
||||
public:
|
||||
decode_type_t decode_type; ///< UNKNOWN, NEC, SONY, RC5, ...
|
||||
unsigned int address; ///< Used by Panasonic & Sharp [16-bits]
|
||||
unsigned long value; ///< Decoded value [max 32-bits]
|
||||
int bits; ///< Number of bits in decoded value
|
||||
volatile unsigned int *rawbuf; ///< Raw intervals in 50uS ticks
|
||||
int rawlen; ///< Number of records in rawbuf
|
||||
int overflow; ///< true iff IR raw code too long
|
||||
decode_type_t decode_type; // UNKNOWN, NEC, SONY, RC5, ...
|
||||
unsigned int address; // Used by Panasonic & Sharp [16-bits]
|
||||
unsigned long value; // Decoded value [max 32-bits]
|
||||
int bits; // Number of bits in decoded value
|
||||
volatile unsigned int *rawbuf; // Raw intervals in 50uS ticks
|
||||
int rawlen; // Number of records in rawbuf
|
||||
int overflow; // true iff IR raw code too long
|
||||
};
|
||||
|
||||
/**
|
||||
* Decoded value for NEC when a repeat code is received
|
||||
*/
|
||||
//------------------------------------------------------------------------------
|
||||
// Decoded value for NEC when a repeat code is received
|
||||
//
|
||||
#define REPEAT 0xFFFFFFFF
|
||||
|
||||
/**
|
||||
* Main class for receiving IR
|
||||
*/
|
||||
//------------------------------------------------------------------------------
|
||||
// Main class for receiving IR
|
||||
//
|
||||
class IRrecv
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Instantiate the IRrecv class. Multiple instantiation is not supported.
|
||||
* @param recvpin Arduino pin to use. No sanity check is made.
|
||||
*/
|
||||
IRrecv (int recvpin) ;
|
||||
/**
|
||||
* Instantiate the IRrecv class. Multiple instantiation is not supported.
|
||||
* @param recvpin Arduino pin to use, where a demodulating IR receiver is connected.
|
||||
* @param blinkpin pin to blink when receiving IR. Not supported by all hardware. No sanity check is made.
|
||||
*/
|
||||
IRrecv (int recvpin, int blinkpin);
|
||||
|
||||
/**
|
||||
* TODO: Why is this public???
|
||||
* @param blinkflag
|
||||
*/
|
||||
void blink13 (int blinkflag) ;
|
||||
|
||||
/**
|
||||
* Attempt to decode the recently receive IR signal
|
||||
* @param results decode_results instance returning the decode, if any.
|
||||
* @return success of operation. TODO: convert to bool
|
||||
*/
|
||||
int decode (decode_results *results) ;
|
||||
|
||||
/**
|
||||
* Enable IR reception.
|
||||
*/
|
||||
void enableIRIn ( ) ;
|
||||
|
||||
/**
|
||||
* Returns status of reception
|
||||
* @return true if no reception is on-going.
|
||||
*/
|
||||
bool isIdle ( ) ;
|
||||
|
||||
/**
|
||||
* Called to re-enable IR reception.
|
||||
*/
|
||||
void resume ( ) ;
|
||||
|
||||
private:
|
||||
@@ -228,17 +190,10 @@ class IRrecv
|
||||
|
||||
//......................................................................
|
||||
# if (DECODE_RC5 || DECODE_RC6)
|
||||
/**
|
||||
* This helper function is shared by RC5 and RC6
|
||||
*/
|
||||
// This helper function is shared by RC5 and RC6
|
||||
int getRClevel (decode_results *results, int *offset, int *used, int t1) ;
|
||||
# endif
|
||||
# if DECODE_RC5
|
||||
/**
|
||||
* Try to decode the recently received IR signal as an RC5 signal-
|
||||
* @param results decode_results instance returning the decode, if any.
|
||||
* @return Success of the operation.
|
||||
*/
|
||||
bool decodeRC5 (decode_results *results) ;
|
||||
# endif
|
||||
# if DECODE_RC6
|
||||
@@ -300,11 +255,15 @@ class IRrecv
|
||||
# if DECODE_LEGO_PF
|
||||
bool decodeLegoPowerFunctions (decode_results *results) ;
|
||||
# endif
|
||||
|
||||
# if DECODE_RECS80
|
||||
bool decodeRECS80(decode_results *results);
|
||||
# endif
|
||||
} ;
|
||||
|
||||
/**
|
||||
* Main class for sending IR
|
||||
*/
|
||||
//------------------------------------------------------------------------------
|
||||
// Main class for sending IR
|
||||
//
|
||||
class IRsend
|
||||
{
|
||||
public:
|
||||
@@ -330,7 +289,6 @@ class IRsend
|
||||
//......................................................................
|
||||
# if SEND_RC5
|
||||
void sendRC5 (unsigned long data, int nbits) ;
|
||||
void sendRC5ext (unsigned long addr, unsigned long cmd, boolean toggle);
|
||||
# endif
|
||||
# if SEND_RC6
|
||||
void sendRC6 (unsigned long data, int nbits) ;
|
||||
@@ -400,6 +358,10 @@ class IRsend
|
||||
# if SEND_LEGO_PF
|
||||
void sendLegoPowerFunctions (uint16_t data, bool repeat = true) ;
|
||||
# endif
|
||||
//......................................................................
|
||||
# if SEND_RECS80
|
||||
void sendRECS80 (uint16_t data) ;
|
||||
# endif
|
||||
|
||||
#ifdef USE_SOFT_CARRIER
|
||||
private:
|
||||
@@ -407,7 +369,7 @@ class IRsend
|
||||
|
||||
unsigned int periodTime;
|
||||
unsigned int periodOnTime;
|
||||
|
||||
|
||||
void sleepMicros(unsigned long us);
|
||||
void sleepUntilMicros(unsigned long targetTime);
|
||||
|
||||
|
||||
@@ -34,22 +34,19 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// Information for the Interrupt Service Routine
|
||||
//
|
||||
#define RAWBUF 101 ///< Maximum length of raw duration buffer. Must be odd.
|
||||
#define RAWBUF 101 // Maximum length of raw duration buffer
|
||||
|
||||
/**
|
||||
* This struct is used to communicate with the ISR (interrupt service routine).
|
||||
*/
|
||||
typedef
|
||||
struct {
|
||||
// The fields are ordered to reduce memory over caused by struct-padding
|
||||
uint8_t rcvstate; ///< State Machine state
|
||||
uint8_t recvpin; ///< Pin connected to IR data from detector
|
||||
uint8_t rcvstate; // State Machine state
|
||||
uint8_t recvpin; // Pin connected to IR data from detector
|
||||
uint8_t blinkpin;
|
||||
uint8_t blinkflag; ///< true -> enable blinking of pin on IR processing
|
||||
uint8_t rawlen; ///< counter of entries in rawbuf
|
||||
unsigned int timer; ///< State timer, counts 50uS ticks.
|
||||
unsigned int rawbuf[RAWBUF]; ///< raw data
|
||||
uint8_t overflow; ///< Raw buffer overflow occurred
|
||||
uint8_t blinkflag; // true -> enable blinking of pin on IR processing
|
||||
uint8_t rawlen; // counter of entries in rawbuf
|
||||
unsigned int timer; // State timer, counts 50uS ticks.
|
||||
unsigned int rawbuf[RAWBUF]; // raw data
|
||||
uint8_t overflow; // Raw buffer overflow occurred
|
||||
}
|
||||
irparams_t;
|
||||
|
||||
@@ -60,11 +57,9 @@ irparams_t;
|
||||
#define STATE_STOP 5
|
||||
#define STATE_OVERFLOW 6
|
||||
|
||||
/**
|
||||
* Allow all parts of the code access to the ISR data
|
||||
* NB. The data can be changed by the ISR at any time, even mid-function
|
||||
* Therefore we declare it as "volatile" to stop the compiler/CPU caching it
|
||||
*/
|
||||
// Allow all parts of the code access to the ISR data
|
||||
// NB. The data can be changed by the ISR at any time, even mid-function
|
||||
// Therefore we declare it as "volatile" to stop the compiler/CPU caching it
|
||||
EXTERN volatile irparams_t irparams;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -84,12 +79,8 @@ EXTERN volatile irparams_t irparams;
|
||||
// Pulse parameters in uSec
|
||||
//
|
||||
|
||||
/**
|
||||
* When received, marks tend to be too long and
|
||||
* spaces tend to be too short.
|
||||
* To compensate for this, MARK_EXCESS is subtracted from all marks,
|
||||
* and added to all spaces.
|
||||
*/
|
||||
// Due to sensor lag, when received, Marks tend to be 100us too long and
|
||||
// Spaces tend to be 100us too short
|
||||
#define MARK_EXCESS 100
|
||||
|
||||
// Upper and Lower percentage tolerances in measurements
|
||||
@@ -98,7 +89,7 @@ EXTERN volatile irparams_t irparams;
|
||||
#define UTOL (1.0 + (TOLERANCE/100.))
|
||||
|
||||
// Minimum gap between IR transmissions
|
||||
#define _GAP 5000
|
||||
#define _GAP 8000
|
||||
#define GAP_TICKS (_GAP/USECPERTICK)
|
||||
|
||||
#define TICKS_LOW(us) ((int)(((us)*LTOL/USECPERTICK)))
|
||||
@@ -85,7 +85,7 @@
|
||||
# undef HAS_AVR_INTERRUPT_H
|
||||
|
||||
// Sending not implemented
|
||||
# undef SENDING_SUPPORTED
|
||||
# undef SENDING_SUPPORTED#
|
||||
|
||||
// Supply own enbleIRIn
|
||||
# undef USE_DEFAULT_ENABLE_IR_IN
|
||||
@@ -131,8 +131,8 @@
|
||||
// Teensy 2.0
|
||||
#elif defined(__AVR_ATmega32U4__)
|
||||
//#define IR_USE_TIMER1 // tx = pin 14
|
||||
#define IR_USE_TIMER3 // tx = pin 9
|
||||
//#define IR_USE_TIMER4_HS // tx = pin 10
|
||||
//#define IR_USE_TIMER3 // tx = pin 9
|
||||
#define IR_USE_TIMER4_HS // tx = pin 10
|
||||
|
||||
// Teensy 3.0 / Teensy 3.1
|
||||
#elif defined(__MK20DX128__) || defined(__MK20DX256__) || defined(__MK64FX512__) || defined(__MK66FX1M0__)
|
||||
@@ -161,7 +161,7 @@
|
||||
|| defined(__AVR_ATmega164P__)
|
||||
//#define IR_USE_TIMER1 // tx = pin 13
|
||||
#define IR_USE_TIMER2 // tx = pin 14
|
||||
|
||||
|
||||
//MegaCore - ATmega64, ATmega128
|
||||
#elif defined(__AVR_ATmega64__) || defined(__AVR_ATmega128__)
|
||||
#define IR_USE_TIMER1 // tx = pin 13
|
||||
@@ -624,7 +624,7 @@
|
||||
#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_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)
|
||||
@@ -645,7 +645,7 @@
|
||||
#ifndef SENDPIN_ON
|
||||
#define SENDPIN_ON(pin) digitalWrite(pin, HIGH)
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef SENDPIN_OFF
|
||||
#define SENDPIN_OFF(pin) digitalWrite(pin, LOW)
|
||||
#endif
|
||||
@@ -3,6 +3,7 @@
|
||||
// This file contains functions specific to the ESP32.
|
||||
|
||||
#include "IRremote.h"
|
||||
#include "IRremoteInt.h"
|
||||
|
||||
// "Idiot check"
|
||||
#ifdef USE_DEFAULT_ENABLE_IR_IN
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "IRremote.h"
|
||||
#include "IRremoteInt.h"
|
||||
|
||||
//+=============================================================================
|
||||
// Decodes the received IR message
|
||||
@@ -84,6 +85,11 @@ int IRrecv::decode (decode_results *results)
|
||||
if (decodeLegoPowerFunctions(results)) return true ;
|
||||
#endif
|
||||
|
||||
#if DECODE_RECS80
|
||||
DBG_PRINTLN("Attempting RECS80 decode");
|
||||
if (decodeRECS80(results)) return true;
|
||||
#endif
|
||||
|
||||
// decodeHash returns a hash on any input.
|
||||
// Thus, it needs to be last in the list.
|
||||
// If you add any decodes, add them before this.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "IRremote.h"
|
||||
#include "IRremoteInt.h"
|
||||
|
||||
#ifdef SENDING_SUPPORTED
|
||||
//+=============================================================================
|
||||
@@ -135,4 +136,4 @@ void IRsend::custom_delay_usec(unsigned long uSecs) {
|
||||
//}
|
||||
}
|
||||
|
||||
#endif // SENDING_SUPPORTED
|
||||
#endif // SENDING_SUPPORTED
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "IRremote.h"
|
||||
#include "IRremoteInt.h"
|
||||
|
||||
//==============================================================================
|
||||
// AAA IIIII W W AAA
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "IRremote.h"
|
||||
#include "IRremoteInt.h"
|
||||
|
||||
// Reverse Engineered by looking at RAW dumps generated by IRremote
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "IRremote.h"
|
||||
#include "IRremoteInt.h"
|
||||
|
||||
//==============================================================================
|
||||
// DDDD IIIII SSSS H H
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "IRremote.h"
|
||||
#include "IRremoteInt.h"
|
||||
|
||||
//==============================================================================
|
||||
// JJJJJ V V CCCC
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "IRremote.h"
|
||||
#include "IRremoteInt.h"
|
||||
|
||||
//==============================================================================
|
||||
// L GGGG
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "IRremote.h"
|
||||
#include "IRremoteInt.h"
|
||||
#include "ir_Lego_PF_BitStreamEncoder.h"
|
||||
|
||||
//==============================================================================
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "IRremote.h"
|
||||
#include "IRremoteInt.h"
|
||||
|
||||
//==============================================================================
|
||||
// MMMMM IIIII TTTTT SSSS U U BBBB IIIII SSSS H H IIIII
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "IRremote.h"
|
||||
#include "IRremoteInt.h"
|
||||
|
||||
//==============================================================================
|
||||
// N N EEEEE CCCC
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "IRremote.h"
|
||||
#include "IRremoteInt.h"
|
||||
|
||||
//==============================================================================
|
||||
// PPPP AAA N N AAA SSSS OOO N N IIIII CCCC
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "IRremote.h"
|
||||
#include "IRremoteInt.h"
|
||||
|
||||
//+=============================================================================
|
||||
// Gets one undecoded level at a time from the raw buffer.
|
||||
@@ -77,73 +78,6 @@ void IRsend::sendRC5 (unsigned long data, int nbits)
|
||||
|
||||
space(0); // Always end with the LED off
|
||||
}
|
||||
|
||||
void IRsend::sendRC5ext (unsigned long addr, unsigned long cmd, boolean toggle)
|
||||
{
|
||||
// Set IR carrier frequency
|
||||
enableIROut(36);
|
||||
|
||||
unsigned long addressBits = 5;
|
||||
unsigned long commandBits = 7;
|
||||
unsigned long nbits = addressBits + commandBits;
|
||||
|
||||
// Start
|
||||
mark(RC5_T1);
|
||||
|
||||
// Bit #6 of the command part, but inverted!
|
||||
unsigned long cmdBit6 = (1UL << (commandBits-1)) & cmd;
|
||||
if (cmdBit6) {
|
||||
// Inverted (1 -> 0 = mark-to-space)
|
||||
mark(RC5_T1);
|
||||
space(RC5_T1);
|
||||
} else {
|
||||
space(RC5_T1);
|
||||
mark(RC5_T1);
|
||||
}
|
||||
commandBits--;
|
||||
|
||||
// Toggle bit
|
||||
static int toggleBit = 1;
|
||||
if (toggle) {
|
||||
if (toggleBit == 0) {
|
||||
toggleBit = 1;
|
||||
} else {
|
||||
toggleBit = 0;
|
||||
}
|
||||
}
|
||||
if (toggleBit) {
|
||||
space(RC5_T1);
|
||||
mark(RC5_T1);
|
||||
} else {
|
||||
mark(RC5_T1);
|
||||
space(RC5_T1);
|
||||
}
|
||||
|
||||
// Address
|
||||
for (unsigned long mask = 1UL << (addressBits - 1); mask; mask >>= 1) {
|
||||
if (addr & mask) {
|
||||
space(RC5_T1); // 1 is space, then mark
|
||||
mark(RC5_T1);
|
||||
} else {
|
||||
mark(RC5_T1);
|
||||
space(RC5_T1);
|
||||
}
|
||||
}
|
||||
|
||||
// Command
|
||||
for (unsigned long mask = 1UL << (commandBits - 1); mask; mask >>= 1) {
|
||||
if (cmd & mask) {
|
||||
space(RC5_T1); // 1 is space, then mark
|
||||
mark(RC5_T1);
|
||||
} else {
|
||||
mark(RC5_T1);
|
||||
space(RC5_T1);
|
||||
}
|
||||
}
|
||||
|
||||
space(0); // Always end with the LED off
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//+=============================================================================
|
||||
|
||||
92
src/ir_RECS80.cpp
Normal file
92
src/ir_RECS80.cpp
Normal file
@@ -0,0 +1,92 @@
|
||||
#include "IRremote.h"
|
||||
#include "IRremoteInt.h"
|
||||
|
||||
// RECS80
|
||||
// Documentation : http://www.sbprojects.com/knowledge/ir/recs80.php
|
||||
|
||||
#define RECS80_MARK 158
|
||||
#define RECS80_ONE_SPACE 7432
|
||||
#define RECS80_ZERO_SPACE 4902
|
||||
#define RECS80_BITS 12
|
||||
#define RECS80_BITS_DATA 9
|
||||
#define RECS80_ADDRESS_BITS 3
|
||||
#define RECS80_COMMAND_BITS 6
|
||||
|
||||
#if SEND_RECS80
|
||||
|
||||
void IRsend::sendRECS80 (uint16_t data) {
|
||||
// Set IR carrier frequency
|
||||
enableIROut(38);
|
||||
|
||||
// Header
|
||||
mark(RECS80_MARK);
|
||||
space(RECS80_ONE_SPACE);
|
||||
|
||||
// Data: address and command
|
||||
for (uint16_t mask = 1 << (RECS80_COMMAND_BITS + RECS80_ADDRESS_BITS - 1); mask; mask >>=1) {
|
||||
mark(RECS80_MARK);
|
||||
|
||||
if (data & mask) {
|
||||
space(RECS80_ONE_SPACE);
|
||||
} else {
|
||||
space(RECS80_ZERO_SPACE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
mark(RECS80_MARK);
|
||||
space(0);
|
||||
}
|
||||
|
||||
|
||||
#endif // SEND_RECS80
|
||||
|
||||
#if DECODE_RECS80
|
||||
|
||||
bool IRrecv::decodeRECS80 (decode_results *results)
|
||||
{
|
||||
long data = 0;
|
||||
long offset = 1;
|
||||
|
||||
// Check that there is enough data
|
||||
if (irparams.rawlen < (2 * RECS80_BITS) - 2) {
|
||||
|
||||
DBG_PRINTLN("Not long enough");
|
||||
DBG_PRINTLN(irparams.rawlen);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Initial mark and space
|
||||
if (!MATCH_MARK(results->rawbuf[offset++], RECS80_MARK)) return false;
|
||||
if (!MATCH_SPACE(results->rawbuf[offset++], RECS80_ONE_SPACE)) return false;
|
||||
|
||||
// Data: Address and command stored as one variable
|
||||
for (int i = 0; i < (RECS80_ADDRESS_BITS + RECS80_COMMAND_BITS); i++) {
|
||||
if (!MATCH_MARK(results->rawbuf[offset++], RECS80_MARK)) return false;
|
||||
|
||||
// One
|
||||
if (MATCH_MARK(results->rawbuf[offset], RECS80_ONE_SPACE))
|
||||
data = (data << 1) | 1;
|
||||
|
||||
// Zero
|
||||
else if (MATCH_MARK(results->rawbuf[offset], RECS80_ZERO_SPACE))
|
||||
data = (data << 1) | 0;
|
||||
|
||||
else return false;
|
||||
offset++;
|
||||
}
|
||||
|
||||
if (!MATCH_MARK(results->rawbuf[offset], RECS80_MARK)) return false;
|
||||
|
||||
// Success
|
||||
results->decode_type = RECS80;
|
||||
results->bits = RECS80_BITS_DATA;
|
||||
results->value = data;
|
||||
|
||||
return true;
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "IRremote.h"
|
||||
#include "IRremoteInt.h"
|
||||
|
||||
//==============================================================================
|
||||
// SSSS AAA MMM SSSS U U N N GGGG
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "IRremote.h"
|
||||
#include "IRremoteInt.h"
|
||||
|
||||
//==============================================================================
|
||||
// SSSS AAA N N Y Y OOO
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "IRremote.h"
|
||||
#include "IRremoteInt.h"
|
||||
|
||||
//==============================================================================
|
||||
// SSSS H H AAA RRRR PPPP
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "IRremote.h"
|
||||
#include "IRremoteInt.h"
|
||||
|
||||
//==============================================================================
|
||||
// SSSS OOO N N Y Y
|
||||
|
||||
@@ -92,6 +92,7 @@ Regards,
|
||||
*/
|
||||
|
||||
#include "IRremote.h"
|
||||
#include "IRremoteInt.h"
|
||||
|
||||
//==============================================================================
|
||||
//
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "IRremote.h"
|
||||
#include "IRremoteInt.h"
|
||||
|
||||
//==============================================================================
|
||||
// W W H H Y Y N N TTTTT EEEEE RRRRR
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// Support routines for SAM processor boards
|
||||
|
||||
#include "IRremote.h"
|
||||
#include "IRremoteInt.h"
|
||||
|
||||
#if defined(ARDUINO_ARCH_SAM) || defined(ARDUINO_ARCH_SAMD)
|
||||
|
||||
@@ -98,4 +99,4 @@ void TC3_Handler(void)
|
||||
}
|
||||
}
|
||||
|
||||
#endif // defined(ARDUINO_ARCH_SAM) || defined(ARDUINO_ARCH_SAMD)
|
||||
#endif // defined(ARDUINO_ARCH_SAM) || defined(ARDUINO_ARCH_SAMD)
|
||||
Reference in New Issue
Block a user