mirror of
https://github.com/Theaninova/Arduino-IRremote.git
synced 2026-01-18 07:12:49 +00:00
Compare commits
14 Commits
feature-re
...
beta
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
742f72fd0a | ||
|
|
3ab30887f4 | ||
|
|
bdb9f1c1f5 | ||
|
|
71f6daca4f | ||
|
|
2b3188e40a | ||
|
|
d719c27f95 | ||
|
|
20a4d97f61 | ||
|
|
d2939e2366 | ||
|
|
1154607b69 | ||
|
|
c6a2fcd8c9 | ||
|
|
e206e122e5 | ||
|
|
5bbd55c650 | ||
|
|
24dd940107 | ||
|
|
7245efd2f5 |
18
README.md
18
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/).
|
Tutorials and more information will be made available on [the official homepage](http://z3t0.github.io/Arduino-IRremote/).
|
||||||
|
|
||||||
## Version - 2.4.0b
|
## Version - 2.5.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.
|
||||||
@@ -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** |
|
| [ATtiny84](https://github.com/SpenceKonde/ATTinyCore) | **6** | **1** |
|
||||||
| [ATtiny85](https://github.com/SpenceKonde/ATTinyCore) | **1** | **TINY0** |
|
| [ATtiny85](https://github.com/SpenceKonde/ATTinyCore) | **1** | **TINY0** |
|
||||||
| [ATmega8](https://github.com/MCUdude/MiniCore) | **9** | **1** |
|
| [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** |
|
| [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 |
|
| [ATmega1284](https://github.com/MCUdude/MightyCore) | 13, 14, 6 | 1, **2**, 3 |
|
||||||
| [ATmega164, ATmega324, ATmega644](https://github.com/MCUdude/MightyCore) | 13, **14** | 1, **2** |
|
| [ATmega164, ATmega324, ATmega644](https://github.com/MCUdude/MightyCore) | 13, **14** | 1, **2** |
|
||||||
@@ -68,6 +68,20 @@ The table above lists the currently supported timers and corresponding send pins
|
|||||||
## Usage
|
## Usage
|
||||||
- TODO (Check examples for now)
|
- 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
|
## Contributing
|
||||||
If you want to contribute to this project:
|
If you want to contribute to this project:
|
||||||
- Report bugs and errors
|
- Report bugs and errors
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
## 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
|
## 2.4.0 - 2017/08/10
|
||||||
- Cleanup of hardware dependencies. Merge in SAM support [PR #437](https://github.com/z3t0/Arduino-IRremote/pull/437)
|
- Cleanup of hardware dependencies. Merge in SAM support [PR #437](https://github.com/z3t0/Arduino-IRremote/pull/437)
|
||||||
|
|
||||||
|
|||||||
@@ -56,7 +56,6 @@ void encoding (decode_results *results)
|
|||||||
case AIWA_RC_T501: Serial.print("AIWA_RC_T501"); break ;
|
case AIWA_RC_T501: Serial.print("AIWA_RC_T501"); break ;
|
||||||
case PANASONIC: Serial.print("PANASONIC"); break ;
|
case PANASONIC: Serial.print("PANASONIC"); break ;
|
||||||
case DENON: Serial.print("Denon"); break ;
|
case DENON: Serial.print("Denon"); break ;
|
||||||
case RECS80: Serial.print("RECS80"); break ;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,16 +0,0 @@
|
|||||||
|
|
||||||
#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,7 +10,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <IRremote.h>
|
#include <IRremote.h>
|
||||||
#include <IRremoteInt.h>
|
|
||||||
|
|
||||||
// Dumps out the decode_results structure.
|
// Dumps out the decode_results structure.
|
||||||
// Call this after IRrecv::decode()
|
// Call this after IRrecv::decode()
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <IRremote.h>
|
#include <IRremote.h>
|
||||||
#include <IRremoteInt.h>
|
|
||||||
|
|
||||||
IRsend irsend;
|
IRsend irsend;
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ version=2.4.0
|
|||||||
author=shirriff, z3t0
|
author=shirriff, z3t0
|
||||||
maintainer=z3t0
|
maintainer=z3t0
|
||||||
sentence=Send and receive infrared signals with multiple protocols
|
sentence=Send and receive infrared signals with multiple protocols
|
||||||
paragraph=See more at https://github.com/z3t0/Arduino-IRremote
|
paragraph=Find more information at https://github.com/z3t0/Arduino-IRremote
|
||||||
category=Communication
|
category=Communication
|
||||||
url=https://github.com/z3t0/Arduino-IRremote
|
url=https://github.com/z3t0/Arduino-IRremote
|
||||||
architectures=*
|
architectures=*
|
||||||
|
|||||||
@@ -20,8 +20,7 @@
|
|||||||
|
|
||||||
// Defining IR_GLOBAL here allows us to declare the instantiation of global variables
|
// Defining IR_GLOBAL here allows us to declare the instantiation of global variables
|
||||||
#define IR_GLOBAL
|
#define IR_GLOBAL
|
||||||
# include "IRremote.h"
|
#include "IRremote.h"
|
||||||
# include "IRremoteInt.h"
|
|
||||||
#undef IR_GLOBAL
|
#undef IR_GLOBAL
|
||||||
|
|
||||||
#ifdef HAS_AVR_INTERRUPT_H
|
#ifdef HAS_AVR_INTERRUPT_H
|
||||||
@@ -52,11 +51,12 @@ int MATCH (int measured, int desired)
|
|||||||
DBG_PRINT(TICKS_HIGH(desired), DEC);
|
DBG_PRINT(TICKS_HIGH(desired), DEC);
|
||||||
|
|
||||||
bool passed = ((measured >= TICKS_LOW(desired)) && (measured <= TICKS_HIGH(desired)));
|
bool passed = ((measured >= TICKS_LOW(desired)) && (measured <= TICKS_HIGH(desired)));
|
||||||
if (passed)
|
if (passed) {
|
||||||
DBG_PRINTLN(F("?; passed"));
|
DBG_PRINTLN(F("?; passed"));
|
||||||
else
|
} else {
|
||||||
DBG_PRINTLN(F("?; FAILED"));
|
DBG_PRINTLN(F("?; FAILED"));
|
||||||
return passed;
|
}
|
||||||
|
return passed;
|
||||||
}
|
}
|
||||||
|
|
||||||
//+========================================================
|
//+========================================================
|
||||||
@@ -78,11 +78,12 @@ int MATCH_MARK (int measured_ticks, int desired_us)
|
|||||||
|
|
||||||
bool passed = ((measured_ticks >= TICKS_LOW (desired_us + MARK_EXCESS))
|
bool passed = ((measured_ticks >= TICKS_LOW (desired_us + MARK_EXCESS))
|
||||||
&& (measured_ticks <= TICKS_HIGH(desired_us + MARK_EXCESS)));
|
&& (measured_ticks <= TICKS_HIGH(desired_us + MARK_EXCESS)));
|
||||||
if (passed)
|
if (passed) {
|
||||||
DBG_PRINTLN(F("?; passed"));
|
DBG_PRINTLN(F("?; passed"));
|
||||||
else
|
} else {
|
||||||
DBG_PRINTLN(F("?; FAILED"));
|
DBG_PRINTLN(F("?; FAILED"));
|
||||||
return passed;
|
}
|
||||||
|
return passed;
|
||||||
}
|
}
|
||||||
|
|
||||||
//+========================================================
|
//+========================================================
|
||||||
@@ -104,11 +105,12 @@ int MATCH_SPACE (int measured_ticks, int desired_us)
|
|||||||
|
|
||||||
bool passed = ((measured_ticks >= TICKS_LOW (desired_us - MARK_EXCESS))
|
bool passed = ((measured_ticks >= TICKS_LOW (desired_us - MARK_EXCESS))
|
||||||
&& (measured_ticks <= TICKS_HIGH(desired_us - MARK_EXCESS)));
|
&& (measured_ticks <= TICKS_HIGH(desired_us - MARK_EXCESS)));
|
||||||
if (passed)
|
if (passed) {
|
||||||
DBG_PRINTLN(F("?; passed"));
|
DBG_PRINTLN(F("?; passed"));
|
||||||
else
|
} else {
|
||||||
DBG_PRINTLN(F("?; FAILED"));
|
DBG_PRINTLN(F("?; FAILED"));
|
||||||
return passed;
|
}
|
||||||
|
return passed;
|
||||||
}
|
}
|
||||||
|
|
||||||
//+=============================================================================
|
//+=============================================================================
|
||||||
|
|||||||
120
src/IRremote.h
120
src/IRremote.h
@@ -1,3 +1,7 @@
|
|||||||
|
/**
|
||||||
|
* @file IRremote.h
|
||||||
|
* @brief Public API to the library.
|
||||||
|
*/
|
||||||
|
|
||||||
//******************************************************************************
|
//******************************************************************************
|
||||||
// IRremote
|
// IRremote
|
||||||
@@ -21,7 +25,7 @@
|
|||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// The ISR header contains several useful macros the user may wish to use
|
// The ISR header contains several useful macros the user may wish to use
|
||||||
//
|
//
|
||||||
#include "IRremoteInt.h"
|
#include "private/IRremoteInt.h"
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// Supported IR protocols
|
// Supported IR protocols
|
||||||
@@ -79,9 +83,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_RECS80 1 // NOT WRITTEN
|
|
||||||
#define SEND_RECS80 1 // Still being tested
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// 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
|
||||||
@@ -97,10 +98,10 @@
|
|||||||
#define PRONTO_FALLBACK true
|
#define PRONTO_FALLBACK true
|
||||||
#define PRONTO_NOFALLBACK false
|
#define PRONTO_NOFALLBACK false
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
/**
|
||||||
// An enumerated list of all supported formats
|
* An enum consisting of all supported formats.
|
||||||
// You do NOT need to remove entries from this list when disabling protocols!
|
* You do NOT need to remove entries from this list when disabling protocols!
|
||||||
//
|
*/
|
||||||
typedef
|
typedef
|
||||||
enum {
|
enum {
|
||||||
UNKNOWN = -1,
|
UNKNOWN = -1,
|
||||||
@@ -122,14 +123,13 @@ typedef
|
|||||||
DENON,
|
DENON,
|
||||||
PRONTO,
|
PRONTO,
|
||||||
LEGO_PF,
|
LEGO_PF,
|
||||||
RECS80,
|
|
||||||
}
|
}
|
||||||
decode_type_t;
|
decode_type_t;
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
/**
|
||||||
// Set DEBUG to 1 for lots of lovely debug output
|
* Set DEBUG to 1 for lots of lovely debug output.
|
||||||
//
|
*/
|
||||||
#define DEBUG 0
|
#define DEBUG 0
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// Debug directives
|
// Debug directives
|
||||||
@@ -138,7 +138,13 @@ decode_type_t;
|
|||||||
# define DBG_PRINT(...) Serial.print(__VA_ARGS__)
|
# define DBG_PRINT(...) Serial.print(__VA_ARGS__)
|
||||||
# define DBG_PRINTLN(...) Serial.println(__VA_ARGS__)
|
# define DBG_PRINTLN(...) Serial.println(__VA_ARGS__)
|
||||||
#else
|
#else
|
||||||
|
/**
|
||||||
|
* If DEBUG, print the arguments, otherwise do nothing.
|
||||||
|
*/
|
||||||
# define DBG_PRINT(...)
|
# define DBG_PRINT(...)
|
||||||
|
/**
|
||||||
|
* If DEBUG, print the arguments as a line, otherwise do nothing.
|
||||||
|
*/
|
||||||
# define DBG_PRINTLN(...)
|
# define DBG_PRINTLN(...)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -149,39 +155,71 @@ int MATCH (int measured, int desired) ;
|
|||||||
int MATCH_MARK (int measured_ticks, int desired_us) ;
|
int MATCH_MARK (int measured_ticks, int desired_us) ;
|
||||||
int MATCH_SPACE (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
|
class decode_results
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
decode_type_t decode_type; // UNKNOWN, NEC, SONY, RC5, ...
|
decode_type_t decode_type; ///< UNKNOWN, NEC, SONY, RC5, ...
|
||||||
unsigned int address; // Used by Panasonic & Sharp [16-bits]
|
unsigned int address; ///< Used by Panasonic & Sharp [16-bits]
|
||||||
unsigned long value; // Decoded value [max 32-bits]
|
unsigned long value; ///< Decoded value [max 32-bits]
|
||||||
int bits; // Number of bits in decoded value
|
int bits; ///< Number of bits in decoded value
|
||||||
volatile unsigned int *rawbuf; // Raw intervals in 50uS ticks
|
volatile unsigned int *rawbuf; ///< Raw intervals in 50uS ticks
|
||||||
int rawlen; // Number of records in rawbuf
|
int rawlen; ///< Number of records in rawbuf
|
||||||
int overflow; // true iff IR raw code too long
|
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
|
#define REPEAT 0xFFFFFFFF
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
/**
|
||||||
// Main class for receiving IR
|
* Main class for receiving IR
|
||||||
//
|
*/
|
||||||
class IRrecv
|
class IRrecv
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
/**
|
||||||
|
* Instantiate the IRrecv class. Multiple instantiation is not supported.
|
||||||
|
* @param recvpin Arduino pin to use. No sanity check is made.
|
||||||
|
*/
|
||||||
IRrecv (int recvpin) ;
|
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);
|
IRrecv (int recvpin, int blinkpin);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO: Why is this public???
|
||||||
|
* @param blinkflag
|
||||||
|
*/
|
||||||
void blink13 (int 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) ;
|
int decode (decode_results *results) ;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enable IR reception.
|
||||||
|
*/
|
||||||
void enableIRIn ( ) ;
|
void enableIRIn ( ) ;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns status of reception
|
||||||
|
* @return true if no reception is on-going.
|
||||||
|
*/
|
||||||
bool isIdle ( ) ;
|
bool isIdle ( ) ;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called to re-enable IR reception.
|
||||||
|
*/
|
||||||
void resume ( ) ;
|
void resume ( ) ;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -190,10 +228,17 @@ class IRrecv
|
|||||||
|
|
||||||
//......................................................................
|
//......................................................................
|
||||||
# if (DECODE_RC5 || DECODE_RC6)
|
# 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) ;
|
int getRClevel (decode_results *results, int *offset, int *used, int t1) ;
|
||||||
# endif
|
# endif
|
||||||
# if DECODE_RC5
|
# 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) ;
|
bool decodeRC5 (decode_results *results) ;
|
||||||
# endif
|
# endif
|
||||||
# if DECODE_RC6
|
# if DECODE_RC6
|
||||||
@@ -255,15 +300,11 @@ class IRrecv
|
|||||||
# if DECODE_LEGO_PF
|
# if DECODE_LEGO_PF
|
||||||
bool decodeLegoPowerFunctions (decode_results *results) ;
|
bool decodeLegoPowerFunctions (decode_results *results) ;
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# if DECODE_RECS80
|
|
||||||
bool decodeRECS80(decode_results *results);
|
|
||||||
# endif
|
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
/**
|
||||||
// Main class for sending IR
|
* Main class for sending IR
|
||||||
//
|
*/
|
||||||
class IRsend
|
class IRsend
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -289,6 +330,7 @@ class IRsend
|
|||||||
//......................................................................
|
//......................................................................
|
||||||
# if SEND_RC5
|
# if SEND_RC5
|
||||||
void sendRC5 (unsigned long data, int nbits) ;
|
void sendRC5 (unsigned long data, int nbits) ;
|
||||||
|
void sendRC5ext (unsigned long addr, unsigned long cmd, boolean toggle);
|
||||||
# endif
|
# endif
|
||||||
# if SEND_RC6
|
# if SEND_RC6
|
||||||
void sendRC6 (unsigned long data, int nbits) ;
|
void sendRC6 (unsigned long data, int nbits) ;
|
||||||
@@ -358,10 +400,6 @@ 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_RECS80
|
|
||||||
void sendRECS80 (uint16_t data) ;
|
|
||||||
# endif
|
|
||||||
|
|
||||||
#ifdef USE_SOFT_CARRIER
|
#ifdef USE_SOFT_CARRIER
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
// This file contains functions specific to the ESP32.
|
// This file contains functions specific to the ESP32.
|
||||||
|
|
||||||
#include "IRremote.h"
|
#include "IRremote.h"
|
||||||
#include "IRremoteInt.h"
|
|
||||||
|
|
||||||
// "Idiot check"
|
// "Idiot check"
|
||||||
#ifdef USE_DEFAULT_ENABLE_IR_IN
|
#ifdef USE_DEFAULT_ENABLE_IR_IN
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
#include "IRremote.h"
|
#include "IRremote.h"
|
||||||
#include "IRremoteInt.h"
|
|
||||||
|
|
||||||
//+=============================================================================
|
//+=============================================================================
|
||||||
// Decodes the received IR message
|
// Decodes the received IR message
|
||||||
@@ -85,11 +84,6 @@ int IRrecv::decode (decode_results *results)
|
|||||||
if (decodeLegoPowerFunctions(results)) return true ;
|
if (decodeLegoPowerFunctions(results)) return true ;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if DECODE_RECS80
|
|
||||||
DBG_PRINTLN("Attempting RECS80 decode");
|
|
||||||
if (decodeRECS80(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.
|
||||||
// If you add any decodes, add them before this.
|
// If you add any decodes, add them before this.
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
#include "IRremote.h"
|
#include "IRremote.h"
|
||||||
#include "IRremoteInt.h"
|
|
||||||
|
|
||||||
#ifdef SENDING_SUPPORTED
|
#ifdef SENDING_SUPPORTED
|
||||||
//+=============================================================================
|
//+=============================================================================
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
#include "IRremote.h"
|
#include "IRremote.h"
|
||||||
#include "IRremoteInt.h"
|
|
||||||
|
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
// AAA IIIII W W AAA
|
// AAA IIIII W W AAA
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
#include "IRremote.h"
|
#include "IRremote.h"
|
||||||
#include "IRremoteInt.h"
|
|
||||||
|
|
||||||
// Reverse Engineered by looking at RAW dumps generated by IRremote
|
// Reverse Engineered by looking at RAW dumps generated by IRremote
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
#include "IRremote.h"
|
#include "IRremote.h"
|
||||||
#include "IRremoteInt.h"
|
|
||||||
|
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
// DDDD IIIII SSSS H H
|
// DDDD IIIII SSSS H H
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
#include "IRremote.h"
|
#include "IRremote.h"
|
||||||
#include "IRremoteInt.h"
|
|
||||||
|
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
// JJJJJ V V CCCC
|
// JJJJJ V V CCCC
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
#include "IRremote.h"
|
#include "IRremote.h"
|
||||||
#include "IRremoteInt.h"
|
|
||||||
|
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
// L GGGG
|
// L GGGG
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
#include "IRremote.h"
|
#include "IRremote.h"
|
||||||
#include "IRremoteInt.h"
|
|
||||||
#include "ir_Lego_PF_BitStreamEncoder.h"
|
#include "ir_Lego_PF_BitStreamEncoder.h"
|
||||||
|
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
#include "IRremote.h"
|
#include "IRremote.h"
|
||||||
#include "IRremoteInt.h"
|
|
||||||
|
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
// MMMMM IIIII TTTTT SSSS U U BBBB IIIII SSSS H H IIIII
|
// MMMMM IIIII TTTTT SSSS U U BBBB IIIII SSSS H H IIIII
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
#include "IRremote.h"
|
#include "IRremote.h"
|
||||||
#include "IRremoteInt.h"
|
|
||||||
|
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
// N N EEEEE CCCC
|
// N N EEEEE CCCC
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
#include "IRremote.h"
|
#include "IRremote.h"
|
||||||
#include "IRremoteInt.h"
|
|
||||||
|
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
// PPPP AAA N N AAA SSSS OOO N N IIIII CCCC
|
// PPPP AAA N N AAA SSSS OOO N N IIIII CCCC
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
#include "IRremote.h"
|
#include "IRremote.h"
|
||||||
#include "IRremoteInt.h"
|
|
||||||
|
|
||||||
//+=============================================================================
|
//+=============================================================================
|
||||||
// Gets one undecoded level at a time from the raw buffer.
|
// Gets one undecoded level at a time from the raw buffer.
|
||||||
@@ -78,6 +77,73 @@ void IRsend::sendRC5 (unsigned long data, int nbits)
|
|||||||
|
|
||||||
space(0); // Always end with the LED off
|
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
|
#endif
|
||||||
|
|
||||||
//+=============================================================================
|
//+=============================================================================
|
||||||
|
|||||||
@@ -1,92 +0,0 @@
|
|||||||
#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,5 +1,4 @@
|
|||||||
#include "IRremote.h"
|
#include "IRremote.h"
|
||||||
#include "IRremoteInt.h"
|
|
||||||
|
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
// SSSS AAA MMM SSSS U U N N GGGG
|
// SSSS AAA MMM SSSS U U N N GGGG
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
#include "IRremote.h"
|
#include "IRremote.h"
|
||||||
#include "IRremoteInt.h"
|
|
||||||
|
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
// SSSS AAA N N Y Y OOO
|
// SSSS AAA N N Y Y OOO
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
#include "IRremote.h"
|
#include "IRremote.h"
|
||||||
#include "IRremoteInt.h"
|
|
||||||
|
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
// SSSS H H AAA RRRR PPPP
|
// SSSS H H AAA RRRR PPPP
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
#include "IRremote.h"
|
#include "IRremote.h"
|
||||||
#include "IRremoteInt.h"
|
|
||||||
|
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
// SSSS OOO N N Y Y
|
// SSSS OOO N N Y Y
|
||||||
|
|||||||
@@ -92,7 +92,6 @@ Regards,
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "IRremote.h"
|
#include "IRremote.h"
|
||||||
#include "IRremoteInt.h"
|
|
||||||
|
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
#include "IRremote.h"
|
#include "IRremote.h"
|
||||||
#include "IRremoteInt.h"
|
|
||||||
|
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
// W W H H Y Y N N TTTTT EEEEE RRRRR
|
// W W H H Y Y N N TTTTT EEEEE RRRRR
|
||||||
|
|||||||
@@ -34,19 +34,22 @@
|
|||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// Information for the Interrupt Service Routine
|
// Information for the Interrupt Service Routine
|
||||||
//
|
//
|
||||||
#define RAWBUF 101 // Maximum length of raw duration buffer
|
#define RAWBUF 101 ///< Maximum length of raw duration buffer. Must be odd.
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This struct is used to communicate with the ISR (interrupt service routine).
|
||||||
|
*/
|
||||||
typedef
|
typedef
|
||||||
struct {
|
struct {
|
||||||
// The fields are ordered to reduce memory over caused by struct-padding
|
// The fields are ordered to reduce memory over caused by struct-padding
|
||||||
uint8_t rcvstate; // State Machine state
|
uint8_t rcvstate; ///< State Machine state
|
||||||
uint8_t recvpin; // Pin connected to IR data from detector
|
uint8_t recvpin; ///< Pin connected to IR data from detector
|
||||||
uint8_t blinkpin;
|
uint8_t blinkpin;
|
||||||
uint8_t blinkflag; // true -> enable blinking of pin on IR processing
|
uint8_t blinkflag; ///< true -> enable blinking of pin on IR processing
|
||||||
uint8_t rawlen; // counter of entries in rawbuf
|
uint8_t rawlen; ///< counter of entries in rawbuf
|
||||||
unsigned int timer; // State timer, counts 50uS ticks.
|
unsigned int timer; ///< State timer, counts 50uS ticks.
|
||||||
unsigned int rawbuf[RAWBUF]; // raw data
|
unsigned int rawbuf[RAWBUF]; ///< raw data
|
||||||
uint8_t overflow; // Raw buffer overflow occurred
|
uint8_t overflow; ///< Raw buffer overflow occurred
|
||||||
}
|
}
|
||||||
irparams_t;
|
irparams_t;
|
||||||
|
|
||||||
@@ -57,9 +60,11 @@ irparams_t;
|
|||||||
#define STATE_STOP 5
|
#define STATE_STOP 5
|
||||||
#define STATE_OVERFLOW 6
|
#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
|
* Allow all parts of the code access to the ISR data
|
||||||
// Therefore we declare it as "volatile" to stop the compiler/CPU caching it
|
* 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;
|
EXTERN volatile irparams_t irparams;
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
@@ -79,8 +84,12 @@ EXTERN volatile irparams_t irparams;
|
|||||||
// Pulse parameters in uSec
|
// Pulse parameters in uSec
|
||||||
//
|
//
|
||||||
|
|
||||||
// Due to sensor lag, when received, Marks tend to be 100us too long and
|
/**
|
||||||
// Spaces tend to be 100us too short
|
* 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.
|
||||||
|
*/
|
||||||
#define MARK_EXCESS 100
|
#define MARK_EXCESS 100
|
||||||
|
|
||||||
// Upper and Lower percentage tolerances in measurements
|
// Upper and Lower percentage tolerances in measurements
|
||||||
@@ -89,7 +98,7 @@ EXTERN volatile irparams_t irparams;
|
|||||||
#define UTOL (1.0 + (TOLERANCE/100.))
|
#define UTOL (1.0 + (TOLERANCE/100.))
|
||||||
|
|
||||||
// Minimum gap between IR transmissions
|
// Minimum gap between IR transmissions
|
||||||
#define _GAP 8000
|
#define _GAP 5000
|
||||||
#define GAP_TICKS (_GAP/USECPERTICK)
|
#define GAP_TICKS (_GAP/USECPERTICK)
|
||||||
|
|
||||||
#define TICKS_LOW(us) ((int)(((us)*LTOL/USECPERTICK)))
|
#define TICKS_LOW(us) ((int)(((us)*LTOL/USECPERTICK)))
|
||||||
@@ -85,7 +85,7 @@
|
|||||||
# undef HAS_AVR_INTERRUPT_H
|
# undef HAS_AVR_INTERRUPT_H
|
||||||
|
|
||||||
// Sending not implemented
|
// Sending not implemented
|
||||||
# undef SENDING_SUPPORTED#
|
# undef SENDING_SUPPORTED
|
||||||
|
|
||||||
// Supply own enbleIRIn
|
// Supply own enbleIRIn
|
||||||
# undef USE_DEFAULT_ENABLE_IR_IN
|
# undef USE_DEFAULT_ENABLE_IR_IN
|
||||||
@@ -131,8 +131,8 @@
|
|||||||
// Teensy 2.0
|
// Teensy 2.0
|
||||||
#elif defined(__AVR_ATmega32U4__)
|
#elif defined(__AVR_ATmega32U4__)
|
||||||
//#define IR_USE_TIMER1 // tx = pin 14
|
//#define IR_USE_TIMER1 // tx = pin 14
|
||||||
//#define IR_USE_TIMER3 // tx = pin 9
|
#define IR_USE_TIMER3 // tx = pin 9
|
||||||
#define IR_USE_TIMER4_HS // tx = pin 10
|
//#define IR_USE_TIMER4_HS // tx = pin 10
|
||||||
|
|
||||||
// Teensy 3.0 / Teensy 3.1
|
// Teensy 3.0 / Teensy 3.1
|
||||||
#elif defined(__MK20DX128__) || defined(__MK20DX256__) || defined(__MK64FX512__) || defined(__MK66FX1M0__)
|
#elif defined(__MK20DX128__) || defined(__MK20DX256__) || defined(__MK64FX512__) || defined(__MK66FX1M0__)
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
// Support routines for SAM processor boards
|
// Support routines for SAM processor boards
|
||||||
|
|
||||||
#include "IRremote.h"
|
#include "IRremote.h"
|
||||||
#include "IRremoteInt.h"
|
|
||||||
|
|
||||||
#if defined(ARDUINO_ARCH_SAM) || defined(ARDUINO_ARCH_SAMD)
|
#if defined(ARDUINO_ARCH_SAM) || defined(ARDUINO_ARCH_SAMD)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user