Open_drain documented

This commit is contained in:
Armin 2022-08-17 19:29:01 +02:00
parent 922d2c5c81
commit 91df621500
7 changed files with 38 additions and 24 deletions

View File

@ -459,7 +459,7 @@ Click on the receiver while simulation is running to specify individual NEC IR c
# Compile options / macros for this library
To customize the library to different requirements, there are some compile options / macros available.<br/>
These macros must be defined in your program before the line `#include <IRremote.hpp>` to take effect.
These macros must be defined in your program **before** the line `#include <IRremote.hpp>` to take effect.<br/>
Modify them by enabling / disabling them, or change the values if applicable.
| Name | Default value | Description |

View File

@ -32,12 +32,13 @@
#include <Arduino.h>
//#define EXCLUDE_EXOTIC_PROTOCOLS // saves around 240 bytes program memory if IrSender.write is used
//#define SEND_PWM_BY_TIMER
//#define USE_NO_SEND_PWM
//#define NO_LED_FEEDBACK_CODE // saves 566 bytes program memory
//#define EXCLUDE_EXOTIC_PROTOCOLS // Saves around 240 bytes program memory if IrSender.write is used
//#define SEND_PWM_BY_TIMER // Disable carrier PWM generation in software and use (restricted) hardware PWM.
//#define USE_NO_SEND_PWM // Use no carrier PWM, just simulate an active low receiver signal. Overrides SEND_PWM_BY_TIMER definition
//#define NO_LED_FEEDBACK_CODE // Saves 566 bytes program memory
//#define USE_OPEN_DRAIN_OUTPUT_FOR_SEND_PIN // Use or simulate open drain output mode at send pin. Attention, active state of open drain is LOW, so connect the send LED between positive supply and send pin!
#include "PinDefinitionsAndMore.h" //Define macros for input and output pin etc.
#include "PinDefinitionsAndMore.h" //Define macros for input and output pin etc.
#include <IRremote.hpp>
#define DELAY_AFTER_SEND 2000

View File

@ -37,6 +37,11 @@
*/
#include <Arduino.h>
//#define SEND_PWM_BY_TIMER // Disable carrier PWM generation in software and use (restricted) hardware PWM.
//#define USE_NO_SEND_PWM // Use no carrier PWM, just simulate an active low receiver signal. Overrides SEND_PWM_BY_TIMER definition
//#define NO_LED_FEEDBACK_CODE // Saves 566 bytes program memory
//#define USE_OPEN_DRAIN_OUTPUT_FOR_SEND_PIN // Use or simulate open drain output mode at send pin. Attention, active state of open drain is LOW, so connect the send LED between positive supply and send pin!
#include "PinDefinitionsAndMore.h" //Define macros for input and output pin etc.
#include <IRremote.hpp>

View File

@ -13,9 +13,8 @@
*/
#include <Arduino.h>
//#define SEND_PWM_BY_TIMER
//#define USE_NO_SEND_PWM
//#define NO_LED_FEEDBACK_CODE // saves 418 bytes program memory
//#define SEND_PWM_BY_TIMER // Disable carrier PWM generation in software and use (restricted) hardware PWM.
//#define USE_NO_SEND_PWM // Use no carrier PWM, just simulate an active low receiver signal. Overrides SEND_PWM_BY_TIMER definition
#include "PinDefinitionsAndMore.h" //Define macros for input and output pin etc.
#include <IRremote.hpp>

View File

@ -42,11 +42,11 @@
#endif
//#define EXCLUDE_UNIVERSAL_PROTOCOLS // Saves up to 1000 bytes program memory.
//#define EXCLUDE_EXOTIC_PROTOCOLS
//#define SEND_PWM_BY_TIMER
//#define USE_NO_SEND_PWM
#define NO_LED_FEEDBACK_CODE // saves 500 bytes program memory
#define MARK_EXCESS_MICROS 10 // Adapt it to your IR receiver module. See also IRremote.h.
//#define EXCLUDE_EXOTIC_PROTOCOLS // Saves around 240 bytes program memory if IrSender.write is used
//#define SEND_PWM_BY_TIMER // Disable carrier PWM generation in software and use (restricted) hardware PWM.
//#define USE_NO_SEND_PWM // Use no carrier PWM, just simulate an active low receiver signal. Overrides SEND_PWM_BY_TIMER definition
#define NO_LED_FEEDBACK_CODE // Saves 344 bytes program memory
#define MARK_EXCESS_MICROS 10 // Adapt it to your IR receiver module. See also IRremote.h.
//#define TRACE // For internal usage
//#define DEBUG // Activate this for lots of lovely debug output from the decoders.

View File

@ -432,22 +432,27 @@ void IRsend::sendBiphaseData(unsigned int aBiphaseTimeUnit, uint32_t aData, uint
*/
void IRsend::mark(unsigned int aMarkMicros) {
#if defined(SEND_PWM_BY_TIMER)
#if defined(SEND_PWM_BY_TIMER) || defined(USE_NO_SEND_PWM)
# if !defined(NO_LED_FEEDBACK_CODE)
if (FeedbackLEDControl.LedFeedbackEnabled == LED_FEEDBACK_ENABLED_FOR_SEND) {
setFeedbackLED(true);
}
# endif
#endif
#if defined(SEND_PWM_BY_TIMER)
/*
* Generate hardware PWM signal
*/
ENABLE_SEND_PWM_BY_TIMER; // Enable timer or ledcWrite() generated PWM output
customDelayMicroseconds(aMarkMicros);
IRLedOff(); // manages also feedback LED
IRLedOff(); // disables hardware PWM and manages feedback LED
return;
#elif defined(USE_NO_SEND_PWM)
# if !defined(NO_LED_FEEDBACK_CODE)
if (FeedbackLEDControl.LedFeedbackEnabled == LED_FEEDBACK_ENABLED_FOR_SEND) {
setFeedbackLED(true);
}
# endif
/*
* Here we generate no carrier PWM, just simulate an active low receiver signal.
*/
# if defined(USE_OPEN_DRAIN_OUTPUT_FOR_SEND_PIN) && !defined(OUTPUT_OPEN_DRAIN)
pinModeFast(sendPin, OUTPUT); // active state for mimicking open drain
# else
@ -460,9 +465,13 @@ void IRsend::mark(unsigned int aMarkMicros) {
if (FeedbackLEDControl.LedFeedbackEnabled == LED_FEEDBACK_ENABLED_FOR_SEND) {
setFeedbackLED(false);
}
return;
# endif
#else
#else // defined(SEND_PWM_BY_TIMER)
/*
* Generate PWM by bit banging
*/
unsigned long tStartMicros = micros();
unsigned long tNextPeriodEnding = tStartMicros;
unsigned long tMicros;
@ -478,7 +487,7 @@ void IRsend::mark(unsigned int aMarkMicros) {
noInterrupts(); // do not let interrupts extend the short on period
# if defined(USE_OPEN_DRAIN_OUTPUT_FOR_SEND_PIN)
# if defined(OUTPUT_OPEN_DRAIN)
digitalWriteFast(sendPin, LOW); // active state for open drain
digitalWriteFast(sendPin, LOW); // set output with pin mode OUTPUT_OPEN_DRAIN to active low
# else
pinModeFast(sendPin, OUTPUT); // active state for mimicking open drain
# endif

View File

@ -244,7 +244,7 @@
*/
//#define USE_OPEN_DRAIN_OUTPUT_FOR_SEND_PIN
#if defined(USE_OPEN_DRAIN_OUTPUT_FOR_SEND_PIN) && !defined(OUTPUT_OPEN_DRAIN)
#warning Pin mode OUTPUT_OPEN_DRAIN is not supported on this platform -> fall back to mode OUTPUT.
#warning Pin mode OUTPUT_OPEN_DRAIN is not supported on this platform -> mimick open drain mode by switching between INPUT and OUTPUT mode.
#endif
/**
* This amount is subtracted from the on-time of the pulses generated for software PWM generation.