From 3b26203ebb84f4cba495538cca447873a5cb047d Mon Sep 17 00:00:00 2001 From: KLASSENTS Date: Fri, 17 Jan 2025 14:37:51 +0700 Subject: [PATCH] =?UTF-8?q?=D1=83=D0=B4=D0=B0=D0=BB=D0=B8=D0=BB=D0=B0=20?= =?UTF-8?q?=D0=BB=D0=B8=D1=88=D0=BD=D0=B5=D0=B5,=20=D0=BF=D1=80=D0=BE?= =?UTF-8?q?=D1=82=D0=B5=D1=81=D1=82=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BB?= =?UTF-8?q?=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../examples/ControlRelay/ControlRelay.ino | 32 ++--- .../IRDispatcherDemo/IRDispatcherDemo.ino | 43 +----- .../IRremoteExtensionTest.ino | 25 ++-- .../examples/IRremoteInfo/IRremoteInfo.ino | 128 +----------------- .../examples/ReceiveDump/ReceiveDump.ino | 21 +-- .../ReceiverTimingAnalysis.ino | 38 +----- .../SimpleReceiver/SimpleReceiver.ino | 11 +- .../SimpleReceiverForHashCodes.ino | 14 +- .../SimpleReceiverWithCallback.ino | 24 ++-- .../examples/TinyReceiver/TinyReceiver.ino | 28 +--- 10 files changed, 87 insertions(+), 277 deletions(-) diff --git a/libraries/IRremote/examples/ControlRelay/ControlRelay.ino b/libraries/IRremote/examples/ControlRelay/ControlRelay.ino index 346b13b..479e41c 100644 --- a/libraries/IRremote/examples/ControlRelay/ControlRelay.ino +++ b/libraries/IRremote/examples/ControlRelay/ControlRelay.ino @@ -33,33 +33,28 @@ */ #include -#include "PinDefinitionsAndMore.h" // Define macros for input and output pin etc. - -#if FLASHEND <= 0x1FFF || (defined(RAMEND) && RAMEND <= 0x4FF) || (defined(RAMSIZE) && RAMSIZE < 0x4FF) // For 8k flash or 512 bytes RAM or less, like ATtiny85, ATtiny167 -#define EXCLUDE_UNIVERSAL_PROTOCOLS // Saves up to 1000 bytes program memory. -#define EXCLUDE_EXOTIC_PROTOCOLS +//#include "PinDefinitionsAndMore.h" // Define macros for input and output pin etc. +/* + * Helper macro for getting a macro definition as string + */ +#if !defined(STR_HELPER) +#define STR_HELPER(x) #x +#define STR(x) STR_HELPER(x) #endif #include -#if defined(APPLICATION_PIN) -#define RELAY_PIN APPLICATION_PIN -#else -#define RELAY_PIN 5 -#endif +#define RELAY_PIN 5 +#define IR_RECEIVE_PIN 2 void setup() { pinMode(LED_BUILTIN, OUTPUT); pinMode(RELAY_PIN, OUTPUT); - Serial.begin(115200); + Serial.begin(9600); while (!Serial) ; // Wait for Serial to become available. Is optimized away for some cores. -#if defined(__AVR_ATmega32U4__) || defined(SERIAL_PORT_USBVIRTUAL) || defined(SERIAL_USB) /*stm32duino*/|| defined(USBCON) /*STM32_stm32*/ \ - || defined(SERIALUSB_PID) || defined(ARDUINO_ARCH_RP2040) || defined(ARDUINO_attiny3217) - delay(4000); // To be able to connect Serial monitor after reset or power up and before first print out. Do not wait for an attached Serial Monitor! -#endif // Just to know which program is running on my Arduino Serial.println(F("START " __FILE__ " from " __DATE__ "\r\nUsing library version " VERSION_IRREMOTE)); @@ -89,7 +84,6 @@ void loop() { Serial.println(F("off")); } -#if FLASHEND >= 0x3FFF // For 16k flash or more, like ATtiny1604 IrReceiver.printIRResultShort(&Serial); IrReceiver.printIRSendUsage(&Serial); Serial.println(); @@ -98,11 +92,7 @@ void loop() { Serial.println(F("Received noise or an unknown (or not yet enabled) protocol")); IrReceiver.printIRResultRawFormatted(&Serial, true); } -#else - // Print a minimal summary of received data - IrReceiver.printIRResultMinimal(&Serial); - Serial.println(); -#endif // FLASHEND + } last = millis(); IrReceiver.resume(); // Enable receiving of the next value diff --git a/libraries/IRremote/examples/IRDispatcherDemo/IRDispatcherDemo.ino b/libraries/IRremote/examples/IRDispatcherDemo/IRDispatcherDemo.ino index fda2a2c..8af212e 100644 --- a/libraries/IRremote/examples/IRDispatcherDemo/IRDispatcherDemo.ino +++ b/libraries/IRremote/examples/IRDispatcherDemo/IRDispatcherDemo.ino @@ -32,7 +32,11 @@ #define USE_TINY_IR_RECEIVER // Recommended, but only for NEC protocol!!! If disabled and IRMP_INPUT_PIN is defined, the IRMP library is used for decoding //#define TINY_RECEIVER_USE_ARDUINO_ATTACH_INTERRUPT // Requires additional 112 bytes program memory + 4 bytes RAM -#include "PinDefinitionsAndMore.h" // Define macros for input and output pin etc. +//#include "PinDefinitionsAndMore.h" // Define macros for input and output pin etc. + +#define IR_RECEIVE_PIN 2 +#define TONE_PIN 3 + // Some kind of auto detect library if USE_TINY_IR_RECEIVER is deactivated #if !defined(USE_TINY_IR_RECEIVER) # if defined(IR_RECEIVE_PIN) @@ -55,9 +59,6 @@ */ #define IR_RECEIVE_PIN 2 #define IRMP_USE_COMPLETE_CALLBACK 1 // Enable callback functionality. It is required if IRMP library is used. -#if defined(ALTERNATIVE_IR_FEEDBACK_LED_PIN) -#define FEEDBACK_LED_PIN ALTERNATIVE_IR_FEEDBACK_LED_PIN -#endif //#define IRMP_ENABLE_PIN_CHANGE_INTERRUPT // Enable interrupt functionality (not for all protocols) - requires around 376 additional bytes of program memory @@ -66,9 +67,6 @@ #define IRMP_SUPPORT_NEC_PROTOCOL 1 // this enables only one protocol //#define IRMP_SUPPORT_KASEIKYO_PROTOCOL 1 -# if defined(ALTERNATIVE_IR_FEEDBACK_LED_PIN) -#define IRMP_FEEDBACK_LED_PIN ALTERNATIVE_IR_FEEDBACK_LED_PIN -# endif /* * After setting the definitions we can include the code and compile it. */ @@ -108,18 +106,10 @@ void doTone2200(); void setup() { pinMode(LED_BUILTIN, OUTPUT); - Serial.begin(115200); + Serial.begin(9600); while (!Serial) ; // Wait for Serial to become available. Is optimized away for some cores. -#if defined(__AVR_ATmega32U4__) || defined(SERIAL_PORT_USBVIRTUAL) || defined(SERIAL_USB) /*stm32duino*/|| defined(USBCON) /*STM32_stm32*/ \ - || defined(SERIALUSB_PID) || defined(ARDUINO_ARCH_RP2040) || defined(ARDUINO_attiny3217) - delay(4000); // To be able to connect Serial monitor after reset or power up and before first print out. Do not wait for an attached Serial Monitor! -#endif -#if defined(ESP8266) - Serial.println(); // to separate it from the internal boot output -#endif - // Just to know which program is running on my Arduino #if defined(USE_TINY_IR_RECEIVER) Serial.println(F("START " __FILE__ " from " __DATE__ "\r\nUsing TinyIRReceiver")); @@ -144,11 +134,6 @@ void setup() { Serial.print(F("Ready to receive IR signals of protocols: ")); irmp_print_active_protocols(&Serial); Serial.println(F("at pin " STR(IRMP_INPUT_PIN))); - -# if defined(ALTERNATIVE_IR_FEEDBACK_LED_PIN) - irmp_irsnd_LEDFeedback(true); // Enable receive signal feedback at ALTERNATIVE_IR_FEEDBACK_LED_PIN - Serial.println(F("IR feedback pin is " STR(ALTERNATIVE_IR_FEEDBACK_LED_PIN))); -# endif #endif Serial.print(F("Listening to commands of IR remote of type ")); @@ -261,22 +246,6 @@ void doTone2200() { * It currently disables the receiving of repeats */ void irmp_tone(uint8_t _pin, unsigned int frequency, unsigned long duration) { -# if defined(__AVR__) && !defined(IRMP_ENABLE_PIN_CHANGE_INTERRUPT) - storeIRTimer(); - tone(_pin, frequency, 0); - if (duration == 0) { - duration = 100; - } - delay(duration); - noTone(_pin); - restoreIRTimer(); -#elif defined(ESP8266) - // tone() stops timer 1 - (void) _pin; - (void) frequency; - (void) duration; -#else tone(_pin, frequency, duration); -#endif } #endif // #if defined(USE_IRMP_LIBRARY) diff --git a/libraries/IRremote/examples/IRremoteExtensionTest/IRremoteExtensionTest.ino b/libraries/IRremote/examples/IRremoteExtensionTest/IRremoteExtensionTest.ino index 3ec197a..331f98e 100644 --- a/libraries/IRremote/examples/IRremoteExtensionTest/IRremoteExtensionTest.ino +++ b/libraries/IRremote/examples/IRremoteExtensionTest/IRremoteExtensionTest.ino @@ -30,36 +30,37 @@ */ #include -#include "PinDefinitionsAndMore.h" // Define macros for input and output pin etc. +//#include "PinDefinitionsAndMore.h" // Define macros for input and output pin etc. #if !defined(RAW_BUFFER_LENGTH) -// For air condition remotes it requires 750. Default is 200. -# if (defined(RAMEND) && RAMEND <= 0x4FF) || (defined(RAMSIZE) && RAMSIZE < 0x4FF) -#define RAW_BUFFER_LENGTH 360 -# else #define RAW_BUFFER_LENGTH 750 -# endif #endif #include #include "IRremoteExtensionClass.h" +/* + * Helper macro for getting a macro definition as string + */ +#if !defined(STR_HELPER) +#define STR_HELPER(x) #x +#define STR(x) STR_HELPER(x) +#endif + +#define IR_RECEIVE_PIN 2 + /* * Create the class, which itself uses the IRrecv class from IRremote */ IRExtensionClass IRExtension(&IrReceiver); void setup() { - Serial.begin(115200); + Serial.begin(9600); while (!Serial) ; // Wait for Serial to become available. Is optimized away for some cores. -#if defined(__AVR_ATmega32U4__) || defined(SERIAL_PORT_USBVIRTUAL) || defined(SERIAL_USB) /*stm32duino*/|| defined(USBCON) /*STM32_stm32*/ \ - || defined(SERIALUSB_PID) || defined(ARDUINO_ARCH_RP2040) || defined(ARDUINO_attiny3217) - delay(4000); // To be able to connect Serial monitor after reset or power up and before first print out. Do not wait for an attached Serial Monitor! -#endif -// Just to know which program is running on my Arduino + // Just to know which program is running on my Arduino Serial.println(F("START " __FILE__ " from " __DATE__ "\r\nUsing library version " VERSION_IRREMOTE)); // Start the receiver and if not 3. parameter specified, take LED_BUILTIN pin from the internal boards definition as default feedback LED diff --git a/libraries/IRremote/examples/IRremoteInfo/IRremoteInfo.ino b/libraries/IRremote/examples/IRremoteInfo/IRremoteInfo.ino index 31d0376..337f49f 100644 --- a/libraries/IRremote/examples/IRremoteInfo/IRremoteInfo.ino +++ b/libraries/IRremote/examples/IRremoteInfo/IRremoteInfo.ino @@ -33,27 +33,20 @@ void dumpProtocols(); void dumpFooter(); void setup() { - Serial.begin(115200); + Serial.begin(9600); while (!Serial) ; // Wait for Serial to become available. Is optimized away for some cores. -#if defined(__AVR_ATmega32U4__) || defined(SERIAL_PORT_USBVIRTUAL) || defined(SERIAL_USB) /*stm32duino*/|| defined(USBCON) /*STM32_stm32*/ \ - || defined(SERIALUSB_PID) || defined(ARDUINO_ARCH_RP2040) || defined(ARDUINO_attiny3217) - delay(4000); // To be able to connect Serial monitor after reset or power up and before first print out. Do not wait for an attached Serial Monitor! -#endif // Just to know which program is running on my Arduino Serial.println(F("START " __FILE__ " from " __DATE__ "\r\nUsing library version " VERSION_IRREMOTE)); //Runs only once per restart of the Arduino. dumpHeader(); dumpRAW_BUFFER_LENGTH(); - dumpTIMER(); - dumpTimerPin(); dumpClock(); dumpPlatform(); dumpPulseParams(); dumpSignalParams(); - dumpArduinoIDE(); dumpDebugMode(); dumpProtocols(); dumpFooter(); @@ -68,54 +61,6 @@ void dumpRAW_BUFFER_LENGTH() { Serial.println(RAW_BUFFER_LENGTH); } -void dumpTIMER() { - bool flag = false; -#if defined(IR_USE_TIMER1) - Serial.print(F("Timer defined for use: ")); - Serial.println(F("Timer1")); - flag = true; -#endif -#if defined(IR_USE_TIMER2) - Serial.print(F("Timer defined for use: ")); - Serial.println(F("Timer2")); - flag = true; -#endif -#if defined(IR_USE_TIMER3) - Serial.print(F("Timer defined for use: ")); Serial.println(F("Timer3")); flag = true; -#endif -#if defined(IR_USE_TIMER4) - Serial.print(F("Timer defined for use: ")); Serial.println(F("Timer4")); flag = true; -#endif -#if defined(IR_USE_TIMER5) - Serial.print(F("Timer defined for use: ")); Serial.println(F("Timer5")); flag = true; -#endif -#if defined(IR_USE_TIMER4_HS) - Serial.print(F("Timer defined for use: ")); Serial.println(F("Timer4_HS")); flag = true; -#endif -#if defined(IR_USE_TIMER_CMT) - Serial.print(F("Timer defined for use: ")); Serial.println(F("Timer_CMT")); flag = true; -#endif -#if defined(IR_USE_TIMER_TPM1) - Serial.print(F("Timer defined for use: ")); Serial.println(F("Timer_TPM1")); flag = true; -#endif -#if defined(IR_USE_TIMER_TINY0) - Serial.print(F("Timer defined for use: ")); Serial.println(F("Timer_TINY0")); flag = true; -#endif - - if (!flag) { - Serial.print(F("Timer Error: ")); - Serial.println(F("not defined")); - } -} - -void dumpTimerPin() { - Serial.print(F("IR Send Pin: ")); -#if defined(IR_SEND_PIN) - Serial.println(IR_SEND_PIN); -#else - Serial.println(IrSender.sendPin); -#endif -} void dumpClock() { #if defined(F_CPU) @@ -127,63 +72,8 @@ void dumpClock() { void dumpPlatform() { Serial.print(F("MCU Platform: ")); -#if defined(__AVR_ATmega8__) - Serial.println(F("Atmega8")); -#elif defined(__AVR_ATmega16__) - Serial.println(F("ATmega16")); -#elif defined(__AVR_ATmega32__) - Serial.println(F("ATmega32")); -#elif defined(__AVR_ATmega32U4__) - Serial.println(F("Arduino Leonardo / Yun / Teensy 1.0 / ATmega32U4")); -#elif defined(__AVR_ATmega48__) || defined(__AVR_ATmega48P__) - Serial.println(F("ATmega48")); -#elif defined(__AVR_ATmega64__) - Serial.println(F("ATmega64")); -#elif defined(__AVR_ATmega88__) || defined(__AVR_ATmega88P__) - Serial.println(F("ATmega88")); -#elif defined(__AVR_ATmega162__) - Serial.println(F("ATmega162")); -#elif defined(__AVR_ATmega164A__) || defined(__AVR_ATmega164P__) - Serial.println(F("ATmega164")); -#elif defined(__AVR_ATmega324P__) || defined(__AVR_ATmega324A__) || defined(__AVR_ATmega324PA__) - Serial.println(F("ATmega324")); - -#elif defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) - Serial.println(F("ATmega644")); -#elif defined(__AVR_ATmega1280__) - Serial.println(F("Arduino Mega1280")); -#elif defined(__AVR_ATmega1281__) - Serial.println(F("ATmega1281")); -#elif defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) - Serial.println(F("ATmega1284")); -#elif defined(__AVR_ATmega2560__) - Serial.println(F("Arduino Mega2560")); -#elif defined(__AVR_ATmega2561__) - Serial.println(F("ATmega2561")); - -#elif defined(__AVR_ATmega8515__) - Serial.println(F("ATmega8515")); -#elif defined(__AVR_ATmega8535__) - Serial.println(F("ATmega8535")); - -#elif defined(__AVR_AT90USB162__) - Serial.println(F("Teensy 1.0 / AT90USB162")); - // Teensy 2.0 -#elif defined(__MK20DX128__) || defined(__MK20DX256__) - Serial.println(F("Teensy 3.0 / Teensy 3.1 / MK20DX128 / MK20DX256")); -#elif defined(__MKL26Z64__) - Serial.println(F("Teensy-LC / MKL26Z64")); -#elif defined(__AVR_AT90USB646__) - Serial.println(F("Teensy++ 1.0 / AT90USB646")); -#elif defined(__AVR_AT90USB1286__) - Serial.println(F("Teensy++ 2.0 / AT90USB1286")); - -#elif defined(__AVR_ATtiny84__) - Serial.println(F("ATtiny84")); -#elif defined(__AVR_ATtiny85__) - Serial.println(F("ATtiny85")); -#else - Serial.println(F("ATmega328(P) / (Duemilanove, Diecimila, LilyPad, Mini, Micro, Fio, Nano, etc)")); +#if defined(MIK32V2) + Serial.println(F("MIK32 Amur")); #endif } @@ -217,15 +107,6 @@ void dumpDebugMode() { } -void dumpArduinoIDE() { - Serial.print(F("Arduino IDE version: ")); - Serial.print(ARDUINO / 10000); - Serial.write('.'); - Serial.print((ARDUINO % 10000) / 100); - Serial.write('.'); - Serial.println(ARDUINO % 100); -} - void dumpProtocols() { Serial.println(); @@ -360,7 +241,4 @@ void dumpFooter() { Serial.println(F("- IRremote.h")); Serial.println( F("- You can save SRAM by disabling the Decode or Send features for any protocol (Near the top of IRremoteInt.h)")); - Serial.println( - F( - "- Some Timer conflicts, with other libraries, can be easily resolved by configuring a different Timer for your platform")); } diff --git a/libraries/IRremote/examples/ReceiveDump/ReceiveDump.ino b/libraries/IRremote/examples/ReceiveDump/ReceiveDump.ino index d0451ba..b860dcb 100644 --- a/libraries/IRremote/examples/ReceiveDump/ReceiveDump.ino +++ b/libraries/IRremote/examples/ReceiveDump/ReceiveDump.ino @@ -33,13 +33,22 @@ */ #include -#include "PinDefinitionsAndMore.h" // Define macros for input and output pin etc. +// #include "PinDefinitionsAndMore.h" // Define macros for input and output pin etc. +/* + * Helper macro for getting a macro definition as string + */ +#if !defined(STR_HELPER) +#define STR_HELPER(x) #x +#define STR(x) STR_HELPER(x) +#endif + +#define IR_RECEIVE_PIN 2 + #if !defined(RAW_BUFFER_LENGTH) // For air condition remotes it requires 750. Default is 200. -# if !((defined(RAMEND) && RAMEND <= 0x4FF) || (defined(RAMSIZE) && RAMSIZE < 0x4FF)) #define RAW_BUFFER_LENGTH 730 // this allows usage of 16 bit raw buffer, for RECORD_GAP_MICROS > 20000 -# endif + #endif /* @@ -64,14 +73,10 @@ void setup() { pinMode(LED_BUILTIN, OUTPUT); - Serial.begin(115200); // Status message will be sent to PC at 9600 baud + Serial.begin(9600); // Status message will be sent to PC at 9600 baud while (!Serial) ; // Wait for Serial to become available. Is optimized away for some cores. -#if defined(__AVR_ATmega32U4__) || defined(SERIAL_PORT_USBVIRTUAL) || defined(SERIAL_USB) /*stm32duino*/|| defined(USBCON) /*STM32_stm32*/ \ - || defined(SERIALUSB_PID) || defined(ARDUINO_ARCH_RP2040) || defined(ARDUINO_attiny3217) - delay(4000); // To be able to connect Serial monitor after reset or power up and before first print out. Do not wait for an attached Serial Monitor! -#endif // Just to know which program is running on my Arduino Serial.println(F("START " __FILE__ " from " __DATE__ "\r\nUsing library version " VERSION_IRREMOTE)); diff --git a/libraries/IRremote/examples/ReceiverTimingAnalysis/ReceiverTimingAnalysis.ino b/libraries/IRremote/examples/ReceiverTimingAnalysis/ReceiverTimingAnalysis.ino index c0efd28..8d6a8d6 100644 --- a/libraries/IRremote/examples/ReceiverTimingAnalysis/ReceiverTimingAnalysis.ino +++ b/libraries/IRremote/examples/ReceiverTimingAnalysis/ReceiverTimingAnalysis.ino @@ -34,7 +34,6 @@ #include #define IR_RECEIVE_PIN 2 -//#define IR_RECEIVE_PIN 3 /* * Helper macro for getting a macro definition as string @@ -42,36 +41,17 @@ #define STR_HELPER(x) #x #define STR(x) STR_HELPER(x) -#if !(defined(EICRA) && defined(EIFR) && defined(EIMSK)) void measureTimingISR(void); -#endif void setup() { pinMode(LED_BUILTIN, OUTPUT); - Serial.begin(115200); + Serial.begin(9600); while (!Serial) ; // Wait for Serial to become available. Is optimized away for some cores. -#if defined(__AVR_ATmega32U4__) || defined(SERIAL_PORT_USBVIRTUAL) || defined(SERIAL_USB) /*stm32duino*/|| defined(USBCON) /*STM32_stm32*/ \ - || defined(SERIALUSB_PID) || defined(ARDUINO_ARCH_RP2040) || defined(ARDUINO_attiny3217) - delay(4000); // To be able to connect Serial monitor after reset or power up and before first print out. Do not wait for an attached Serial Monitor! -#endif // Just to know which program is running on my Arduino Serial.println(F("START " __FILE__ " from " __DATE__)); - -#if defined(EICRA) && defined(EIFR) && defined(EIMSK) -# if (IR_RECEIVE_PIN == 2) - EICRA |= _BV(ISC00); // interrupt on any logical change - EIFR |= _BV(INTF0); // clear interrupt bit - EIMSK |= _BV(INT0); // enable interrupt on next change -# elif (IR_RECEIVE_PIN == 3) - EICRA |= _BV(ISC10); // enable interrupt on pin3 on both edges for ATmega328 - EIFR |= _BV(INTF1); // clear interrupt bit - EIMSK |= _BV(INT1); // enable interrupt on next change -# endif -#else attachInterrupt(digitalPinToInterrupt(IR_RECEIVE_PIN), measureTimingISR, CHANGE); -#endif Serial.println(F("Ready to analyze NEC IR signal at pin " STR(IR_RECEIVE_PIN))); Serial.println(); } @@ -149,13 +129,9 @@ void loop() { /* * This check enables statistics for longer protocols like Kaseikyo/Panasonics */ -#if !defined(ARDUINO_ARCH_MBED) noInterrupts(); -#endif uint32_t tLastMicros = LastMicros; -#if !defined(ARDUINO_ARCH_MBED) interrupts(); -#endif uint32_t tMicrosDelta = micros() - tLastMicros; if (tMicrosDelta > 10000) { @@ -189,19 +165,7 @@ void loop() { * The interrupt handler. * Just add to the appropriate timing structure. */ -#if defined(ESP8266) || defined(ESP32) -void IRAM_ATTR measureTimingISR() -#else -# if defined(EICRA) && defined(EIFR) && defined(EIMSK) -# if (IR_RECEIVE_PIN == 2) -ISR(INT0_vect) -# elif (IR_RECEIVE_PIN == 3) -ISR(INT1_vect) -# endif -# else void measureTimingISR() -# endif -#endif { uint32_t tMicros = micros(); uint32_t tMicrosDelta = tMicros - LastMicros; diff --git a/libraries/IRremote/examples/SimpleReceiver/SimpleReceiver.ino b/libraries/IRremote/examples/SimpleReceiver/SimpleReceiver.ino index 36d79a6..a24aaa8 100644 --- a/libraries/IRremote/examples/SimpleReceiver/SimpleReceiver.ino +++ b/libraries/IRremote/examples/SimpleReceiver/SimpleReceiver.ino @@ -67,11 +67,18 @@ /* * This include defines the actual pin number for pins like IR_RECEIVE_PIN, IR_SEND_PIN for many different boards and architectures */ -#include "PinDefinitionsAndMore.h" +// #include "PinDefinitionsAndMore.h" #include // include the library +#if !defined(STR_HELPER) +#define STR_HELPER(x) #x +#define STR(x) STR_HELPER(x) +#endif + +#define IR_RECEIVE_PIN 2 + void setup() { - Serial.begin(115200); + Serial.begin(9600); while (!Serial) ; // Wait for Serial to become available. Is optimized away for some cores. diff --git a/libraries/IRremote/examples/SimpleReceiverForHashCodes/SimpleReceiverForHashCodes.ino b/libraries/IRremote/examples/SimpleReceiverForHashCodes/SimpleReceiverForHashCodes.ino index 1766e7c..466d18a 100644 --- a/libraries/IRremote/examples/SimpleReceiverForHashCodes/SimpleReceiverForHashCodes.ino +++ b/libraries/IRremote/examples/SimpleReceiverForHashCodes/SimpleReceiverForHashCodes.ino @@ -43,11 +43,21 @@ /* * This include defines the actual pin number for pins like IR_RECEIVE_PIN, IR_SEND_PIN for many different boards and architectures */ -#include "PinDefinitionsAndMore.h" +// #include "PinDefinitionsAndMore.h" #include // include the library +/* + * Helper macro for getting a macro definition as string + */ +#if !defined(STR_HELPER) +#define STR_HELPER(x) #x +#define STR(x) STR_HELPER(x) +#endif + +#define IR_RECEIVE_PIN 2 + void setup() { - Serial.begin(115200); + Serial.begin(9600); while (!Serial) ; // Wait for Serial to become available. Is optimized away for some cores. diff --git a/libraries/IRremote/examples/SimpleReceiverWithCallback/SimpleReceiverWithCallback.ino b/libraries/IRremote/examples/SimpleReceiverWithCallback/SimpleReceiverWithCallback.ino index a857203..45f7be0 100644 --- a/libraries/IRremote/examples/SimpleReceiverWithCallback/SimpleReceiverWithCallback.ino +++ b/libraries/IRremote/examples/SimpleReceiverWithCallback/SimpleReceiverWithCallback.ino @@ -63,20 +63,30 @@ #include -#include "PinDefinitionsAndMore.h" // Define macros for input and output pin etc. +//#include "PinDefinitionsAndMore.h" // Define macros for input and output pin etc. #include +/* + * Helper macro for getting a macro definition as string + */ +#if !defined(STR_HELPER) +#define STR_HELPER(x) #x +#define STR(x) STR_HELPER(x) +#endif + +#define IR_RECEIVE_PIN 2 + /* * For callback */ -#define PROCESS_IR_RESULT_IN_MAIN_LOOP -#if defined(PROCESS_IR_RESULT_IN_MAIN_LOOP) || defined(ARDUINO_ARCH_MBED) || defined(ESP32) +// #define PROCESS_IR_RESULT_IN_MAIN_LOOP +// #if defined(PROCESS_IR_RESULT_IN_MAIN_LOOP) || defined(ARDUINO_ARCH_MBED) || defined(ESP32) volatile bool sIRDataJustReceived = false; -#endif +// #endif void ReceiveCompleteCallbackHandler(); void setup() { - Serial.begin(115200); + Serial.begin(9600); while (!Serial) ; // Wait for Serial to become available. Is optimized away for some cores. @@ -111,6 +121,7 @@ void loop() { IrReceiver.printIRSendUsage(&Serial); } Serial.println(); + sIRDataJustReceived = false; } } @@ -123,9 +134,6 @@ void loop() { * In order to enable other interrupts you can call sei() (enable interrupt again) after evaluating/copying data. * Good practice, but somewhat more complex, is to copy relevant data and signal receiving to main loop. */ -#if defined(ESP32) || defined(ESP8266) -IRAM_ATTR -# endif void ReceiveCompleteCallbackHandler() { IrReceiver.decode(); // fill IrReceiver.decodedIRData /* diff --git a/libraries/IRremote/examples/TinyReceiver/TinyReceiver.ino b/libraries/IRremote/examples/TinyReceiver/TinyReceiver.ino index d8c440d..9272f4a 100644 --- a/libraries/IRremote/examples/TinyReceiver/TinyReceiver.ino +++ b/libraries/IRremote/examples/TinyReceiver/TinyReceiver.ino @@ -50,10 +50,9 @@ #include -#include "PinDefinitionsAndMore.h" // Set IR_RECEIVE_PIN for different CPU's +//#include "PinDefinitionsAndMore.h" // Set IR_RECEIVE_PIN for different CPU's +#define IR_RECEIVE_PIN 2 -//#define DEBUG // to see if attachInterrupt is used -//#define TRACE // to see the state of the ISR state machine /* * Protocol selection @@ -70,7 +69,6 @@ //#define USE_CALLBACK_FOR_TINY_RECEIVER // Call the fixed function "void handleReceivedTinyIRData()" each time a frame or repeat is received. #include "TinyIRReceiver.hpp" // include the code - /* * Helper macro for getting a macro definition as string */ @@ -80,18 +78,11 @@ #endif void setup() { - Serial.begin(115200); + Serial.begin(9600); while (!Serial) ; // Wait for Serial to become available. Is optimized away for some cores. -#if defined(__AVR_ATmega32U4__) || defined(SERIAL_PORT_USBVIRTUAL) || defined(SERIAL_USB) /*stm32duino*/|| defined(USBCON) /*STM32_stm32*/ \ - || defined(SERIALUSB_PID) || defined(ARDUINO_ARCH_RP2040) || defined(ARDUINO_attiny3217) - delay(4000); // To be able to connect Serial monitor after reset or power up and before first print out. Do not wait for an attached Serial Monitor! -#endif // Just to know which program is running on my Arduino -#if defined(ESP8266) || defined(ESP32) - Serial.println(); -#endif Serial.println(F("START " __FILE__ " from " __DATE__ "\r\nUsing library version " VERSION_TINYIR)); // Enables the interrupt generation on change of IR input signal @@ -147,23 +138,10 @@ void loop() { * This is the function, which is called if a complete frame was received * It runs in an ISR context with interrupts enabled, so functions like delay() etc. should work here */ -# if defined(ESP8266) || defined(ESP32) -IRAM_ATTR -# endif void handleReceivedTinyIRData() { -# if defined(ARDUINO_ARCH_MBED) || defined(ESP32) - /* - * Printing is not allowed in ISR context for any kind of RTOS, so we use the slihjtly more complex, - * but recommended way for handling a callback :-). Copy data for main loop. - * For Mbed we get a kernel panic and "Error Message: Semaphore: 0x0, Not allowed in ISR context" for Serial.print() - * for ESP32 we get a "Guru Meditation Error: Core 1 panic'ed" (we also have an RTOS running!) - */ - // Do something useful here... -# else // As an example, print very short output, since we are in an interrupt context and do not want to miss the next interrupts of the repeats coming soon printTinyReceiverResultMinimal(&Serial); -# endif } #endif