IRremote
IRFeedbackLED.hpp
Go to the documentation of this file.
1 
32 #ifndef _IR_FEEDBACK_LED_HPP
33 #define _IR_FEEDBACK_LED_HPP
34 
43  uint8_t FeedbackLEDPin;
45 };
46 
48 
56 void setLEDFeedback(uint8_t aFeedbackLEDPin, uint8_t aEnableLEDFeedback) {
57 
58  FeedbackLEDControl.FeedbackLEDPin = aFeedbackLEDPin; // default is 0 -> use LED_BUILTIN if available, else disable feedback
59 
60  if (aEnableLEDFeedback != DO_NOT_ENABLE_LED_FEEDBACK) {
61  FeedbackLEDControl.LedFeedbackEnabled |= aEnableLEDFeedback;
62  if (aFeedbackLEDPin != USE_DEFAULT_FEEDBACK_LED_PIN) {
63  pinModeFast(aFeedbackLEDPin, OUTPUT);
64 #if defined(LED_BUILTIN)
65  } else {
66  pinModeFast(LED_BUILTIN, OUTPUT);
67 #else
68  FeedbackLEDControl.LedFeedbackEnabled = LED_FEEDBACK_DISABLED_COMPLETELY; // we have no LED_BUILTIN available
69 #endif
70  }
71  }
72 }
73 
74 /*
75  * Direct replacement for blink13()
76  */
77 void setLEDFeedback(bool aEnableLEDFeedback) {
78  bool tEnableLEDFeedback = LED_FEEDBACK_DISABLED_COMPLETELY;
79  if (aEnableLEDFeedback) {
81  }
83 }
84 
87 }
88 
91 }
92 
95 }
96 
99 }
100 
105 #if defined(ESP32) || defined(ESP8266)
106 IRAM_ATTR
107 #endif
108 void setFeedbackLED(bool aSwitchLedOn) {
109  if (aSwitchLedOn) {
111 #if defined(FEEDBACK_LED_IS_ACTIVE_LOW)
112  digitalWriteFast(FeedbackLEDControl.FeedbackLEDPin, LOW); // Turn user defined pin LED on
113 #else
114  digitalWriteFast(FeedbackLEDControl.FeedbackLEDPin, HIGH); // Turn user defined pin LED on
115 #endif
116 #if defined(LED_BUILTIN) // use fast macros here
117  } else {
118 # if defined(FEEDBACK_LED_IS_ACTIVE_LOW)
119  digitalWriteFast(LED_BUILTIN, LOW); // For AVR, this generates a single cbi command
120 # else
121  digitalWriteFast(LED_BUILTIN, HIGH); // For AVR, this generates a single sbi command
122 # endif
123 #endif
124  }
125  } else {
127 #if defined(FEEDBACK_LED_IS_ACTIVE_LOW)
128  digitalWriteFast(FeedbackLEDControl.FeedbackLEDPin, HIGH); // Turn user defined pin LED off
129 #else
130  digitalWriteFast(FeedbackLEDControl.FeedbackLEDPin, LOW); // Turn user defined pin LED off
131 #endif
132 #if defined(LED_BUILTIN)
133  } else {
134 # if defined(FEEDBACK_LED_IS_ACTIVE_LOW)
135  digitalWriteFast(LED_BUILTIN, HIGH); // For AVR, this generates a single sbi command
136 # else
137  digitalWriteFast(LED_BUILTIN, LOW); // For AVR, this generates a single cbi command
138 # endif
139 #endif
140  }
141  }
142 }
143 
147 void IRrecv::blink13(uint8_t aEnableLEDFeedback) {
148  setLEDFeedback(FeedbackLEDControl.FeedbackLEDPin, aEnableLEDFeedback);
149 }
153 void setBlinkPin(uint8_t aBlinkPin) {
155 }
156 
159 #endif // _IR_FEEDBACK_LED_HPP
setFeedbackLED
void setFeedbackLED(bool aSwitchLedOn)
Flash LED while receiving or sending IR data.
Definition: IRFeedbackLED.hpp:108
setBlinkPin
void setBlinkPin(uint8_t aBlinkPin)
Old deprecated function name for setLEDFeedback()
Definition: IRFeedbackLED.hpp:153
enableLEDFeedback
void enableLEDFeedback()
Definition: IRFeedbackLED.hpp:85
pinModeFast
#define pinModeFast
Definition: digitalWriteFast.h:371
digitalWriteFast
#define digitalWriteFast
Definition: digitalWriteFast.h:339
disableLEDFeedbackForSend
void disableLEDFeedbackForSend()
Definition: IRFeedbackLED.hpp:97
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:147
FeedbackLEDControlStruct
Contains pin number and enable status of the feedback LED.
Definition: IRFeedbackLED.hpp:42
FeedbackLEDControlStruct::LedFeedbackEnabled
uint8_t LedFeedbackEnabled
LED_FEEDBACK_ENABLED_FOR_RECEIVE or LED_FEEDBACK_ENABLED_FOR_SEND -> enable blinking of pin on IR pro...
Definition: IRFeedbackLED.hpp:44
FeedbackLEDControlStruct::FeedbackLEDPin
uint8_t FeedbackLEDPin
if 0, then take board specific FEEDBACK_LED_ON() and FEEDBACK_LED_OFF() functions
Definition: IRFeedbackLED.hpp:43
LED_FEEDBACK_ENABLED_FOR_SEND
#define LED_FEEDBACK_ENABLED_FOR_SEND
Definition: IRremoteInt.h:394
disableLEDFeedback
void disableLEDFeedback()
Definition: IRFeedbackLED.hpp:89
DO_NOT_ENABLE_LED_FEEDBACK
#define DO_NOT_ENABLE_LED_FEEDBACK
Definition: IRremoteInt.h:391
LED_FEEDBACK_ENABLED_FOR_RECEIVE
#define LED_FEEDBACK_ENABLED_FOR_RECEIVE
Definition: IRremoteInt.h:393
LED_FEEDBACK_DISABLED_COMPLETELY
#define LED_FEEDBACK_DISABLED_COMPLETELY
Definition: IRremoteInt.h:392
enableLEDFeedbackForSend
void enableLEDFeedbackForSend()
Definition: IRFeedbackLED.hpp:93
FeedbackLEDControl
struct FeedbackLEDControlStruct FeedbackLEDControl
The feedback LED control instance.
Definition: IRFeedbackLED.hpp:47
USE_DEFAULT_FEEDBACK_LED_PIN
#define USE_DEFAULT_FEEDBACK_LED_PIN
Definition: IRremoteInt.h:64
setLEDFeedback
void setLEDFeedback(uint8_t aFeedbackLEDPin, uint8_t aEnableLEDFeedback)
Enable blinking of feedback LED (LED_BUILTIN is taken as default) on IR sending and receiving Cannot ...
Definition: IRFeedbackLED.hpp:56