IRremote
IRFeedbackLED.hpp
Go to the documentation of this file.
1 
32 #ifndef _IR_FEEDBACK_LED_HPP
33 #define _IR_FEEDBACK_LED_HPP
34 
45 };
46 
48 
53 void setLEDFeedbackPin(uint8_t aFeedbackLEDPin) {
54  FeedbackLEDControl.FeedbackLEDPin = aFeedbackLEDPin;
55 }
56 
57 /*
58  * Direct replacement for blink13()
59  */
60 void setLEDFeedback(bool aEnableLEDFeedback) {
61  FeedbackLEDControl.LedFeedbackEnabled = aEnableLEDFeedback;
62 }
63 
64 /*
65  * Historically this only affects receive LED
66  */
69 }
72 }
73 
79 #if defined(ESP32) || defined(ESP8266)
80 IRAM_ATTR
81 #endif
82 void setFeedbackLED(bool aSwitchLedOn) {
83  if (aSwitchLedOn) {
84  // Turn user defined pin LED on
86 #if defined(LED_BUILTIN) // use fast macros here
87 # if defined(FEEDBACK_LED_IS_ACTIVE_LOW)
88  digitalWriteFast(LED_BUILTIN, LOW); // For AVR, this generates a single cbi command
89 # else
90  digitalWriteFast(LED_BUILTIN, HIGH); // For AVR, this generates a single sbi command
91 # endif
92 #endif
93 
94  } else {
95 #if defined(FEEDBACK_LED_IS_ACTIVE_LOW)
96  if (__builtin_constant_p(FeedbackLEDControl.FeedbackLEDPin) ) {
98  } else {
99  digitalWrite(FeedbackLEDControl.FeedbackLEDPin, LOW);
100  }
101 #else
102  if (__builtin_constant_p(FeedbackLEDControl.FeedbackLEDPin)) {
104  } else {
105  digitalWrite(FeedbackLEDControl.FeedbackLEDPin, HIGH);
106  }
107 #endif
108  }
109 
110  } else {
111  // Turn user defined pin LED off
113 #if defined(LED_BUILTIN)
114 # if defined(FEEDBACK_LED_IS_ACTIVE_LOW)
115  digitalWriteFast(LED_BUILTIN, HIGH); // For AVR, this generates a single sbi command
116 # else
117  digitalWriteFast(LED_BUILTIN, LOW); // For AVR, this generates a single cbi command
118 # endif
119 #endif
120  } else {
121 #if defined(FEEDBACK_LED_IS_ACTIVE_LOW)
122  if (__builtin_constant_p(FeedbackLEDControl.FeedbackLEDPin) ) {
124  } else {
125  digitalWrite(FeedbackLEDControl.FeedbackLEDPin, HIGH);
126  }
127 #else
128  if (__builtin_constant_p(FeedbackLEDControl.FeedbackLEDPin)) {
130  } else {
131  digitalWrite(FeedbackLEDControl.FeedbackLEDPin, LOW);
132  }
133 #endif
134  }
135  }
136 }
137 
141 void IRrecv::blink13(uint8_t aEnableLEDFeedback) {
142  setLEDFeedback(aEnableLEDFeedback);
143 }
147 void setBlinkPin(uint8_t aBlinkPin) {
148  setLEDFeedbackPin(aBlinkPin);
149 }
150 
153 #endif // _IR_FEEDBACK_LED_HPP
setLEDFeedbackPin
void setLEDFeedbackPin(uint8_t aFeedbackLEDPin)
Definition: IRFeedbackLED.hpp:53
setFeedbackLED
void setFeedbackLED(bool aSwitchLedOn)
Flash LED while receiving or sending IR data.
Definition: IRFeedbackLED.hpp:82
setBlinkPin
void setBlinkPin(uint8_t aBlinkPin)
Old deprecated function name for setLEDFeedback()
Definition: IRFeedbackLED.hpp:147
enableLEDFeedback
void enableLEDFeedback()
Definition: IRFeedbackLED.hpp:67
digitalWriteFast
#define digitalWriteFast
Definition: digitalWriteFast.h:347
IRrecv::blink13
void blink13(uint8_t aEnableLEDFeedback) __attribute__((deprecated("Please use setLEDFeedback() or enableLEDFeedback() / disableLEDFeedback().")))
Old deprecated function name for setLEDFeedback() or enableLEDFeedback() / disableLEDFeedback()
Definition: IRFeedbackLED.hpp:141
FeedbackLEDControlStruct
Contains pin number and enable status of the feedback LED.
Definition: IRFeedbackLED.hpp:42
FeedbackLEDControlStruct::FeedbackLEDPin
uint8_t FeedbackLEDPin
if USE_DEFAULT_FEEDBACK_LED_PIN / 0, then use digitalWriteFast(LED_BUILTIN,..) otherwise use digitalW...
Definition: IRFeedbackLED.hpp:43
FeedbackLEDControlStruct::LedFeedbackEnabled
bool LedFeedbackEnabled
Disabled for receive at default. Feedback for send is always enabled and can be disabled by NO_LED_SE...
Definition: IRFeedbackLED.hpp:44
disableLEDFeedback
void disableLEDFeedback()
Definition: IRFeedbackLED.hpp:70
DISABLE_LED_FEEDBACK
#define DISABLE_LED_FEEDBACK
Definition: IRremoteInt.h:454
ENABLE_LED_FEEDBACK
#define ENABLE_LED_FEEDBACK
Definition: IRremoteInt.h:455
setLEDFeedback
void setLEDFeedback(bool aEnableLEDFeedback)
Definition: IRFeedbackLED.hpp:60
FeedbackLEDControl
struct FeedbackLEDControlStruct FeedbackLEDControl
The feedback LED control instance.
Definition: IRFeedbackLED.hpp:47
USE_DEFAULT_FEEDBACK_LED_PIN
#define USE_DEFAULT_FEEDBACK_LED_PIN
Main class for receiving IR signals.
Definition: IRremoteInt.h:225