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 
54 void setLEDFeedbackPin(uint8_t aFeedbackLEDPin) {
55  FeedbackLEDControl.FeedbackLEDPin = aFeedbackLEDPin;
56 
57  // use fast macros here
58  if (aFeedbackLEDPin == USE_DEFAULT_FEEDBACK_LED_PIN) {
59 #if defined(LED_BUILTIN)
60  pinModeFast(LED_BUILTIN, OUTPUT);
61 #endif
62  } else {
63  if (__builtin_constant_p(aFeedbackLEDPin)) {
64  pinModeFast(aFeedbackLEDPin, OUTPUT);
65  } else {
66  pinMode(aFeedbackLEDPin, OUTPUT);
67  }
68  }
69 }
70 
71 /*
72  * Direct replacement for blink13()
73  */
74 void setLEDFeedback(bool aEnableLEDFeedback) {
75  FeedbackLEDControl.LedFeedbackEnabled = aEnableLEDFeedback;
76 }
77 
78 /*
79  * Historically this only affects receive LED
80  */
83 }
86 }
87 
93 #if defined(ESP32) || defined(ESP8266)
94 IRAM_ATTR
95 #endif
96 void setFeedbackLED(bool aSwitchLedOn) {
97  if (aSwitchLedOn) {
98  // Turn user defined pin LED on
100 #if defined(LED_BUILTIN) // use fast macros here
101 # if defined(FEEDBACK_LED_IS_ACTIVE_LOW)
102  digitalWriteFast(LED_BUILTIN, LOW); // For AVR, this generates a single cbi command
103 # else
104  digitalWriteFast(LED_BUILTIN, HIGH); // For AVR, this generates a single sbi command
105 # endif
106 #endif
107 
108  } else {
109 #if defined(FEEDBACK_LED_IS_ACTIVE_LOW)
110  if (__builtin_constant_p(FeedbackLEDControl.FeedbackLEDPin) ) {
112  } else {
113  digitalWrite(FeedbackLEDControl.FeedbackLEDPin, LOW);
114  }
115 #else
116  if (__builtin_constant_p(FeedbackLEDControl.FeedbackLEDPin)) {
118  } else {
119  digitalWrite(FeedbackLEDControl.FeedbackLEDPin, HIGH);
120  }
121 #endif
122  }
123 
124  } else {
125  // Turn user defined pin LED off
127 #if defined(LED_BUILTIN)
128 # if defined(FEEDBACK_LED_IS_ACTIVE_LOW)
129  digitalWriteFast(LED_BUILTIN, HIGH); // For AVR, this generates a single sbi command
130 # else
131  digitalWriteFast(LED_BUILTIN, LOW); // For AVR, this generates a single cbi command
132 # endif
133 #endif
134  } else {
135 #if defined(FEEDBACK_LED_IS_ACTIVE_LOW)
136  if (__builtin_constant_p(FeedbackLEDControl.FeedbackLEDPin) ) {
138  } else {
139  digitalWrite(FeedbackLEDControl.FeedbackLEDPin, HIGH);
140  }
141 #else
142  if (__builtin_constant_p(FeedbackLEDControl.FeedbackLEDPin)) {
144  } else {
145  digitalWrite(FeedbackLEDControl.FeedbackLEDPin, LOW);
146  }
147 #endif
148  }
149  }
150 }
151 
155 void IRrecv::blink13(uint8_t aEnableLEDFeedback) {
156  setLEDFeedback(aEnableLEDFeedback);
157 }
161 void setBlinkPin(uint8_t aBlinkPin) {
162  setLEDFeedbackPin(aBlinkPin);
163 }
164 
167 #endif // _IR_FEEDBACK_LED_HPP
setLEDFeedbackPin
void setLEDFeedbackPin(uint8_t aFeedbackLEDPin)
Definition: IRFeedbackLED.hpp:54
setFeedbackLED
void setFeedbackLED(bool aSwitchLedOn)
Flash LED while receiving or sending IR data.
Definition: IRFeedbackLED.hpp:96
setBlinkPin
void setBlinkPin(uint8_t aBlinkPin)
Old deprecated function name for setLEDFeedback()
Definition: IRFeedbackLED.hpp:161
enableLEDFeedback
void enableLEDFeedback()
Definition: IRFeedbackLED.hpp:81
pinModeFast
#define pinModeFast
Definition: digitalWriteFast.h:383
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:155
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 / 0xFF, then use digitalWriteFast(LED_BUILTIN,..) otherwise use digit...
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:84
DISABLE_LED_FEEDBACK
#define DISABLE_LED_FEEDBACK
Definition: IRremoteInt.h:444
ENABLE_LED_FEEDBACK
#define ENABLE_LED_FEEDBACK
Definition: IRremoteInt.h:445
setLEDFeedback
void setLEDFeedback(bool aEnableLEDFeedback)
Definition: IRFeedbackLED.hpp:74
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:212