mirror of
https://github.com/Theaninova/Arduino-IRremote.git
synced 2025-12-13 01:46:21 +00:00
Added suport for user defined IR reception feedback LED
This commit is contained in:
@@ -168,11 +168,12 @@ class IRrecv
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
IRrecv (int recvpin) ;
|
IRrecv (int recvpin) ;
|
||||||
|
IRrecv (int recvpin, int blinkpin);
|
||||||
|
|
||||||
void blink13 (int blinkflag) ;
|
void blink13 (int blinkflag) ;
|
||||||
int decode (decode_results *results) ;
|
int decode (decode_results *results) ;
|
||||||
void enableIRIn ( ) ;
|
void enableIRIn ( ) ;
|
||||||
bool isIdle ( ) ;
|
bool isIdle ( ) ;
|
||||||
void resume ( ) ;
|
void resume ( ) ;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -47,7 +47,8 @@ typedef
|
|||||||
// 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 blinkflag; // true -> enable blinking of pin 13 on IR processing
|
uint8_t blinkpin;
|
||||||
|
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
|
||||||
@@ -70,6 +71,7 @@ EXTERN volatile irparams_t irparams;
|
|||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// Defines for blinking the LED
|
// Defines for blinking the LED
|
||||||
//
|
//
|
||||||
|
|
||||||
#if defined(CORE_LED0_PIN)
|
#if defined(CORE_LED0_PIN)
|
||||||
# define BLINKLED CORE_LED0_PIN
|
# define BLINKLED CORE_LED0_PIN
|
||||||
# define BLINKLED_ON() (digitalWrite(CORE_LED0_PIN, HIGH))
|
# define BLINKLED_ON() (digitalWrite(CORE_LED0_PIN, HIGH))
|
||||||
|
|||||||
@@ -77,9 +77,12 @@ ISR (TIMER_INTR_NAME)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If requested, flash LED L (D13) while receiving IR data
|
// If requested, flash LED while receiving IR data
|
||||||
if (irparams.blinkflag) {
|
if (irparams.blinkflag) {
|
||||||
if (irdata == MARK) BLINKLED_ON() ; // turn pin 13 LED on
|
if (irdata == MARK)
|
||||||
else BLINKLED_OFF() ; // turn pin 13 LED off
|
if (irparams.blinkpin) digitalWrite(irparams.blinkpin, HIGH); // Turn user defined pin LED on
|
||||||
|
else BLINKLED_ON() ; // if no user defined LED pin, turn default LED pin for the hardware 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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
10
irRecv.cpp
10
irRecv.cpp
@@ -97,6 +97,16 @@ IRrecv::IRrecv (int recvpin)
|
|||||||
irparams.blinkflag = 0;
|
irparams.blinkflag = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IRrecv::IRrecv (int recvpin, int blinkpin)
|
||||||
|
{
|
||||||
|
irparams.recvpin = recvpin;
|
||||||
|
irparams.blinkpin = blinkpin;
|
||||||
|
pinMode(blinkpin, OUTPUT);
|
||||||
|
irparams.blinkflag = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//+=============================================================================
|
//+=============================================================================
|
||||||
// initialization
|
// initialization
|
||||||
//
|
//
|
||||||
|
|||||||
Reference in New Issue
Block a user