v0.5.0
- добавлена поддержка платы ELBEAR ACE-NANO; - добавлена поддержка плат ELSOMIK OEM и SE; - добавлена возможность работы в режиме отладки для всех плат, входящих в состав пакета. Доступно для версии ArduinoIDE 2 и выше; - добавлена поддержка библиотеки FreeRTOS; - добавлена поддержка библиотеки IRremote; - добавлена поддержка библиотеки OneWire; - добавлена поддержка аппаратного I2C0 для плат START-MIK32 и ELSOMIK. Для работы с ним доступен экземпляр класса Wire1; - добавлена поддержка аппаратного SPI0 для всех плат, входящих в пакет. Для работы с ним доступен экземпляр класса SPI1; - увеличено быстродействие функций digitalWrite, digitalRead; - исправлены известные ошибки. Co-authored-by: KlassenTS <klassen@elron.tech> Co-committed-by: KlassenTS <klassen@elron.tech>
This commit was merged in pull request #19.
This commit is contained in:
1 parent
de1f0d7fda
commit
1c8e06634c
211 files changed
+97525
-591
No files matched your search
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* ControlRelay.cpp
|
||||
*
|
||||
* Toggles an output pin at each command received
|
||||
* An IR detector/demodulator must be connected to the input RECV_PIN.
|
||||
* Initially coded 2009 Ken Shirriff http://www.righto.com
|
||||
*
|
||||
* This file is part of Arduino-IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
|
||||
*
|
||||
************************************************************************************
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2009-2021 Ken Shirriff, Armin Joachimsmeyer
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is furnished
|
||||
* to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
************************************************************************************
|
||||
*/
|
||||
#include <Arduino.h>
|
||||
|
||||
//#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 <IRremote.hpp>
|
||||
|
||||
#define RELAY_PIN 5 // P0_4
|
||||
#define IR_RECEIVE_PIN 4 // P0_1
|
||||
|
||||
void setup() {
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
pinMode(RELAY_PIN, OUTPUT);
|
||||
|
||||
Serial.begin(9600);
|
||||
while (!Serial)
|
||||
; // Wait for Serial to become available. Is optimized away for some cores.
|
||||
|
||||
// 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
|
||||
IrReceiver.begin(IR_RECEIVE_PIN, ENABLE_LED_FEEDBACK);
|
||||
|
||||
Serial.print(F("Ready to receive IR signals of protocols: "));
|
||||
printActiveIRProtocols(&Serial);
|
||||
Serial.println(F("at pin " STR(IR_RECEIVE_PIN)));
|
||||
}
|
||||
|
||||
int on = 0;
|
||||
unsigned long last = millis();
|
||||
|
||||
void loop() {
|
||||
if (IrReceiver.decode()) {
|
||||
// If it's been at least 1/4 second since the last
|
||||
// IR received, toggle the relay
|
||||
if (millis() - last > 250) {
|
||||
on = !on;
|
||||
Serial.print(F("Switch relay "));
|
||||
if (on) {
|
||||
digitalWrite(RELAY_PIN, HIGH);
|
||||
Serial.println(F("on"));
|
||||
} else {
|
||||
digitalWrite(RELAY_PIN, LOW);
|
||||
Serial.println(F("off"));
|
||||
}
|
||||
|
||||
IrReceiver.printIRResultShort(&Serial);
|
||||
IrReceiver.printIRSendUsage(&Serial);
|
||||
Serial.println();
|
||||
if (IrReceiver.decodedIRData.protocol == UNKNOWN) {
|
||||
// We have an unknown protocol, print more info
|
||||
Serial.println(F("Received noise or an unknown (or not yet enabled) protocol"));
|
||||
IrReceiver.printIRResultRawFormatted(&Serial, true);
|
||||
}
|
||||
|
||||
}
|
||||
last = millis();
|
||||
IrReceiver.resume(); // Enable receiving of the next value
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,349 @@
|
||||
/*
|
||||
* PinDefinitionsAndMore.h
|
||||
*
|
||||
* Contains pin definitions for IRremote examples for various platforms
|
||||
* as well as definitions for feedback LED and tone() and includes
|
||||
*
|
||||
* Copyright (C) 2021-2023 Armin Joachimsmeyer
|
||||
* armin.joachimsmeyer@gmail.com
|
||||
*
|
||||
* This file is part of IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
|
||||
*
|
||||
* Arduino-IRremote is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/gpl.html>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Pin mapping table for different platforms
|
||||
*
|
||||
* Platform IR input IR output Tone Core/Pin schema
|
||||
* --------------------------------------------------------------
|
||||
* DEFAULT/AVR 2 3 4 Arduino
|
||||
* ATtinyX5 0|PB0 4|PB4 3|PB3 ATTinyCore
|
||||
* ATtiny167 3|PA3 2|PA2 7|PA7 ATTinyCore
|
||||
* ATtiny167 9|PA3 8|PA2 5|PA7 Digispark original core
|
||||
* ATtiny84 |PB2 |PA4 |PA3 ATTinyCore
|
||||
* ATtiny88 3|PD3 4|PD4 9|PB1 ATTinyCore
|
||||
* ATtiny3217 18|PA1 19|PA2 20|PA3 MegaTinyCore
|
||||
* ATtiny1604 2 3|PA5 %
|
||||
* ATtiny816 14|PA1 16|PA3 1|PA5 MegaTinyCore
|
||||
* ATtiny1614 8|PA1 10|PA3 1|PA5 MegaTinyCore
|
||||
* SAMD21 3 4 5
|
||||
* ESP8266 14|D5 12|D6 %
|
||||
* ESP32 15 4 27
|
||||
* ESP32-C3 2 3 4
|
||||
* BluePill PA6 PA7 PA3
|
||||
* APOLLO3 11 12 5
|
||||
* RP2040 3|GPIO15 4|GPIO16 5|GPIO17
|
||||
*/
|
||||
//#define _IR_MEASURE_TIMING // For debugging purposes.
|
||||
|
||||
#if defined(__AVR__)
|
||||
#if defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__) // Digispark board. For use with ATTinyCore.
|
||||
#include "ATtinySerialOut.hpp" // TX is at pin 2 - Available as Arduino library "ATtinySerialOut". Saves 700 bytes program memory and 70 bytes RAM for ATtinyCore.
|
||||
#define IR_RECEIVE_PIN PIN_PB0
|
||||
#define IR_SEND_PIN PIN_PB4 // Pin 2 is serial output with ATtinySerialOut. Pin 1 is internal LED and Pin3 is USB+ with pullup on Digispark board.
|
||||
#define TONE_PIN PIN_PB3
|
||||
#define _IR_TIMING_TEST_PIN PIN_PB3
|
||||
|
||||
# elif defined(__AVR_ATtiny87__) || defined(__AVR_ATtiny167__) // Digispark pro board
|
||||
#include "ATtinySerialOut.hpp" // Available as Arduino library "ATtinySerialOut"
|
||||
// For ATtiny167 Pins PB6 and PA3 are usable as interrupt source.
|
||||
# if defined(ARDUINO_AVR_DIGISPARKPRO)
|
||||
// For use with Digispark original core
|
||||
#define IR_RECEIVE_PIN 9 // PA3 - on Digispark board labeled as pin 9
|
||||
//#define IR_RECEIVE_PIN 14 // PB6 / INT0 is connected to USB+ on DigisparkPro boards
|
||||
#define IR_SEND_PIN 8 // PA2 - on Digispark board labeled as pin 8
|
||||
#define TONE_PIN 5 // PA7 - on Digispark board labeled as pin 5
|
||||
#define _IR_TIMING_TEST_PIN 10 // PA4
|
||||
# else
|
||||
// For use with ATTinyCore
|
||||
#define IR_RECEIVE_PIN PIN_PA3 // On Digispark board labeled as pin 9 - INT0 is connected to USB+ on DigisparkPro boards
|
||||
#define IR_SEND_PIN PIN_PA2 // On Digispark board labeled as pin 8
|
||||
#define TONE_PIN PIN_PA7 // On Digispark board labeled as pin 5
|
||||
# endif
|
||||
|
||||
# elif defined(__AVR_ATtiny84__) // For use with ATTinyCore
|
||||
#include "ATtinySerialOut.hpp" // Available as Arduino library "ATtinySerialOut". Saves 128 bytes program memory.
|
||||
#define IR_RECEIVE_PIN PIN_PB2 // INT0
|
||||
#define IR_SEND_PIN PIN_PA4
|
||||
#define TONE_PIN PIN_PA3
|
||||
#define _IR_TIMING_TEST_PIN PIN_PA5
|
||||
|
||||
# elif defined(__AVR_ATtiny88__) // MH-ET Tiny88 board. For use with ATTinyCore.
|
||||
#include "ATtinySerialOut.hpp" // Available as Arduino library "ATtinySerialOut". Saves 128 bytes program memory.
|
||||
// Pin 6 is TX, pin 7 is RX
|
||||
#define IR_RECEIVE_PIN PIN_PD3 // 3 - INT1
|
||||
#define IR_SEND_PIN PIN_PD4 // 4
|
||||
#define TONE_PIN PIN_PB1 // 9
|
||||
#define _IR_TIMING_TEST_PIN PIN_PB0 // 8
|
||||
|
||||
# elif defined(__AVR_ATtiny1616__) || defined(__AVR_ATtiny3216__) || defined(__AVR_ATtiny3217__) // For use with megaTinyCore
|
||||
// Tiny Core Dev board
|
||||
// https://www.tindie.com/products/xkimi/tiny-core-16-dev-board-attiny1616/ - Out of Stock
|
||||
// https://www.tindie.com/products/xkimi/tiny-core-32-dev-board-attiny3217/ - Out of Stock
|
||||
#define IR_RECEIVE_PIN PIN_PA1 // use 18 instead of PIN_PA1 for TinyCore32
|
||||
#define IR_SEND_PIN PIN_PA2 // 19
|
||||
#define TONE_PIN PIN_PA3 // 20
|
||||
#define APPLICATION_PIN PIN_PA0 // 0
|
||||
#undef LED_BUILTIN // No LED available on the TinyCore 32 board, take the one on the programming board which is connected to the DAC output
|
||||
#define LED_BUILTIN PIN_PA6 // use 2 instead of PIN_PA6 for TinyCore32
|
||||
|
||||
# elif defined(__AVR_ATtiny816__) // For use with megaTinyCore
|
||||
#define IR_RECEIVE_PIN PIN_PA1 // 14
|
||||
#define IR_SEND_PIN PIN_PA1 // 16
|
||||
#define TONE_PIN PIN_PA5 // 1
|
||||
#define APPLICATION_PIN PIN_PA4 // 0
|
||||
#undef LED_BUILTIN // No LED available, take the one which is connected to the DAC output
|
||||
#define LED_BUILTIN PIN_PB5 // 4
|
||||
|
||||
# elif defined(__AVR_ATtiny1614__) // For use with megaTinyCore
|
||||
#define IR_RECEIVE_PIN PIN_PA1 // 8
|
||||
#define IR_SEND_PIN PIN_PA3 // 10
|
||||
#define TONE_PIN PIN_PA5 // 1
|
||||
#define APPLICATION_PIN PIN_PA4 // 0
|
||||
|
||||
# elif defined(__AVR_ATtiny1604__) // For use with megaTinyCore
|
||||
#define IR_RECEIVE_PIN PIN_PA6 // 2 - To be compatible with interrupt example, pin 2 is chosen here.
|
||||
#define IR_SEND_PIN PIN_PA7 // 3
|
||||
#define APPLICATION_PIN PIN_PB2 // 5
|
||||
|
||||
#define tone(...) void() // Define as void, since TCB0_INT_vect is also used by tone()
|
||||
#define noTone(a) void()
|
||||
#define TONE_PIN 42 // Dummy for examples using it
|
||||
|
||||
# elif defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) \
|
||||
|| defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) \
|
||||
|| defined(__AVR_ATmega324P__) || defined(__AVR_ATmega324A__) \
|
||||
|| defined(__AVR_ATmega324PA__) || defined(__AVR_ATmega164A__) \
|
||||
|| defined(__AVR_ATmega164P__) || defined(__AVR_ATmega32__) \
|
||||
|| defined(__AVR_ATmega16__) || defined(__AVR_ATmega8535__) \
|
||||
|| defined(__AVR_ATmega64__) || defined(__AVR_ATmega128__) \
|
||||
|| defined(__AVR_ATmega1281__) || defined(__AVR_ATmega2561__) \
|
||||
|| defined(__AVR_ATmega8515__) || defined(__AVR_ATmega162__)
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 13
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
# else // Default as for ATmega328 like on Uno, Nano, Leonardo, Teensy 2.0 etc.
|
||||
#define IR_RECEIVE_PIN 2 // To be compatible with interrupt example, pin 2 is chosen here.
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
# if defined(ARDUINO_AVR_PROMICRO) // Sparkfun Pro Micro is __AVR_ATmega32U4__ but has different external circuit
|
||||
// We have no built in LED at pin 13 -> reuse RX LED
|
||||
#undef LED_BUILTIN
|
||||
#define LED_BUILTIN LED_BUILTIN_RX
|
||||
# endif
|
||||
# endif // defined(__AVR_ATtiny25__)...
|
||||
|
||||
#elif defined(ARDUINO_ARCH_RENESAS_UNO) // Uno R4
|
||||
// To be compatible with Uno R3.
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
#elif defined(ESP8266)
|
||||
#define FEEDBACK_LED_IS_ACTIVE_LOW // The LED on my board (D4) is active LOW
|
||||
#define IR_RECEIVE_PIN 14 // D5
|
||||
#define IR_SEND_PIN 12 // D6 - D4/pin 2 is internal LED
|
||||
#define _IR_TIMING_TEST_PIN 2 // D4
|
||||
#define APPLICATION_PIN 13 // D7
|
||||
|
||||
#define tone(...) void() // tone() inhibits receive timer
|
||||
#define noTone(a) void()
|
||||
#define TONE_PIN 42 // Dummy for examples using it#
|
||||
|
||||
#elif defined(ARDUINO_NOLOGO_ESP32C3_SUPER_MINI)
|
||||
#define FEEDBACK_LED_IS_ACTIVE_LOW // The LED on my board (D8) is active LOW
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 10
|
||||
|
||||
#elif defined(CONFIG_IDF_TARGET_ESP32C3) || defined(ARDUINO_ESP32C3_DEV)
|
||||
#define NO_LED_FEEDBACK_CODE // The WS2812 on pin 8 of AI-C3 board crashes if used as receive feedback LED, other I/O pins are working...
|
||||
#define IR_RECEIVE_PIN 6
|
||||
#define IR_SEND_PIN 7
|
||||
#define TONE_PIN 10
|
||||
#define APPLICATION_PIN 18
|
||||
|
||||
#elif defined(ESP32)
|
||||
#include <Arduino.h>
|
||||
|
||||
// tone() is included in ESP32 core since 2.0.2
|
||||
#if !defined(ESP_ARDUINO_VERSION_VAL)
|
||||
#define ESP_ARDUINO_VERSION_VAL(major, minor, patch) 12345678
|
||||
#endif
|
||||
#if ESP_ARDUINO_VERSION <= ESP_ARDUINO_VERSION_VAL(2, 0, 2)
|
||||
#define TONE_LEDC_CHANNEL 1 // Using channel 1 makes tone() independent of receiving timer -> No need to stop receiving timer.
|
||||
void tone(uint8_t aPinNumber, unsigned int aFrequency){
|
||||
ledcAttachPin(aPinNumber, TONE_LEDC_CHANNEL);
|
||||
ledcWriteTone(TONE_LEDC_CHANNEL, aFrequency);
|
||||
}
|
||||
void tone(uint8_t aPinNumber, unsigned int aFrequency, unsigned long aDuration){
|
||||
ledcAttachPin(aPinNumber, TONE_LEDC_CHANNEL);
|
||||
ledcWriteTone(TONE_LEDC_CHANNEL, aFrequency);
|
||||
delay(aDuration);
|
||||
ledcWriteTone(TONE_LEDC_CHANNEL, 0);
|
||||
}
|
||||
void noTone(uint8_t aPinNumber){
|
||||
ledcWriteTone(TONE_LEDC_CHANNEL, 0);
|
||||
}
|
||||
#endif // ESP_ARDUINO_VERSION <= ESP_ARDUINO_VERSION_VAL(2, 0, 2)
|
||||
|
||||
#define IR_RECEIVE_PIN 15 // D15
|
||||
#define IR_SEND_PIN 4 // D4
|
||||
#define TONE_PIN 27 // D27 25 & 26 are DAC0 and 1
|
||||
#define APPLICATION_PIN 16 // RX2 pin
|
||||
|
||||
#elif defined(ARDUINO_ARCH_STM32) || defined(ARDUINO_ARCH_STM32F1) // BluePill
|
||||
// Timer 3 blocks PA6, PA7, PB0, PB1 for use by Servo or tone()
|
||||
#define IR_RECEIVE_PIN PA6
|
||||
#define IR_RECEIVE_PIN_STRING "PA6"
|
||||
#define IR_SEND_PIN PA7
|
||||
#define IR_SEND_PIN_STRING "PA7"
|
||||
#define TONE_PIN PA3
|
||||
#define _IR_TIMING_TEST_PIN PA5
|
||||
#define APPLICATION_PIN PA2
|
||||
#define APPLICATION_PIN_STRING "PA2"
|
||||
# if defined(ARDUINO_GENERIC_STM32F103C) || defined(ARDUINO_BLUEPILL_F103C8)
|
||||
// BluePill LED is active low
|
||||
#define FEEDBACK_LED_IS_ACTIVE_LOW
|
||||
# endif
|
||||
|
||||
#elif defined(ARDUINO_ARCH_APOLLO3) // Sparkfun Apollo boards
|
||||
#define IR_RECEIVE_PIN 11
|
||||
#define IR_SEND_PIN 12
|
||||
#define TONE_PIN 5
|
||||
|
||||
#elif defined(ARDUINO_ARCH_MBED) && defined(ARDUINO_ARCH_MBED_NANO) // Arduino Nano 33 BLE and Arduino Nano Connect layout for MBED
|
||||
// Must be before ARDUINO_ARCH_RP2040, since it is the layout for the MBED core of Arduino Nano Connect
|
||||
#define IR_RECEIVE_PIN 3 // GPIO15 Start with pin 3 since pin 2|GPIO25 is connected to LED on Pi pico
|
||||
#define IR_SEND_PIN 4 // GPIO16
|
||||
#define TONE_PIN 5
|
||||
#define APPLICATION_PIN 6
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 7 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 8
|
||||
|
||||
#elif defined(ARDUINO_ARCH_RP2040) // Arduino Nano Connect, Pi Pico with arduino-pico core https://github.com/earlephilhower/arduino-pico
|
||||
#define IR_RECEIVE_PIN 15 // GPIO15 to be compatible with the Arduino Nano RP2040 Connect (pin3)
|
||||
#define IR_SEND_PIN 16 // GPIO16
|
||||
#define TONE_PIN 17
|
||||
#define APPLICATION_PIN 18
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 19 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 20
|
||||
|
||||
// If you program the Nano RP2040 Connect with this core, then you must redefine LED_BUILTIN
|
||||
// and use the external reset with 1 kOhm to ground to enter UF2 mode
|
||||
#undef LED_BUILTIN
|
||||
#define LED_BUILTIN 6
|
||||
|
||||
#elif defined(PARTICLE) // !!!UNTESTED!!!
|
||||
#define IR_RECEIVE_PIN A4
|
||||
#define IR_SEND_PIN A5 // Particle supports multiple pins
|
||||
|
||||
#define LED_BUILTIN D7
|
||||
|
||||
/*
|
||||
* 4 times the same (default) layout for easy adaption in the future
|
||||
*/
|
||||
#elif defined(TEENSYDUINO) // Teensy 2.0 is handled at default for ATmega328 like on Uno, Nano, Leonardo etc.
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
#elif defined(ARDUINO_ARCH_MBED) // Arduino Nano 33 BLE
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
#elif defined(ARDUINO_ARCH_SAMD) || defined(ARDUINO_ARCH_SAM)
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
#if !defined(ARDUINO_SAMD_ADAFRUIT) && !defined(ARDUINO_SEEED_XIAO_M0)
|
||||
// On the Zero and others we switch explicitly to SerialUSB
|
||||
#define Serial SerialUSB
|
||||
#endif
|
||||
|
||||
// Definitions for the Chinese SAMD21 M0-Mini clone, which has no led connected to D13/PA17.
|
||||
// Attention!!! D2 and D4 are swapped on these boards!!!
|
||||
// If you connect the LED, it is on pin 24/PB11. In this case activate the next two lines.
|
||||
//#undef LED_BUILTIN
|
||||
//#define LED_BUILTIN 24 // PB11
|
||||
// As an alternative you can choose pin 25, it is the RX-LED pin (PB03), but active low.In this case activate the next 3 lines.
|
||||
//#undef LED_BUILTIN
|
||||
//#define LED_BUILTIN 25 // PB03
|
||||
//#define FEEDBACK_LED_IS_ACTIVE_LOW // The RX LED on the M0-Mini is active LOW
|
||||
|
||||
#elif defined (NRF51) // BBC micro:bit
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define APPLICATION_PIN 1
|
||||
#define _IR_TIMING_TEST_PIN 4
|
||||
|
||||
#define tone(...) void() // no tone() available
|
||||
#define noTone(a) void()
|
||||
#define TONE_PIN 42 // Dummy for examples using it
|
||||
|
||||
#else
|
||||
#warning Board / CPU is not detected using pre-processor symbols -> using default values, which may not fit. Please extend PinDefinitionsAndMore.h.
|
||||
// Default valued for unidentified boards
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
#endif // defined(ESP8266)
|
||||
|
||||
#if defined(ESP32) || defined(ARDUINO_ARCH_RP2040) || defined(PARTICLE) || defined(ARDUINO_ARCH_MBED)
|
||||
#define SEND_PWM_BY_TIMER // We do not have pin restrictions for this CPU's, so lets use the hardware PWM for send carrier signal generation
|
||||
#else
|
||||
# if defined(SEND_PWM_BY_TIMER)
|
||||
#undef IR_SEND_PIN // SendPin is determined by timer! This avoids warnings in IRremote.hpp and IRTimer.hpp
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if !defined (FLASHEND)
|
||||
#define FLASHEND 0xFFFF // Dummy value for platforms where FLASHEND is not defined
|
||||
#endif
|
||||
|
||||
/*
|
||||
* 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
|
||||
@@ -0,0 +1,193 @@
|
||||
/*
|
||||
* DemoIRCommandMapping.h
|
||||
*
|
||||
* IR remote button codes, strings, and functions to call
|
||||
*
|
||||
* Copyright (C) 2019-2022 Armin Joachimsmeyer
|
||||
* armin.joachimsmeyer@gmail.com
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _IR_COMMAND_MAPPING_H
|
||||
#define _IR_COMMAND_MAPPING_H
|
||||
|
||||
#include <Arduino.h>
|
||||
//#include "Commands.h" // includes all the commands used in the mapping arrays below
|
||||
|
||||
/*
|
||||
* !!! Choose your remote !!!
|
||||
*/
|
||||
//#define USE_KEYES_REMOTE_CLONE With number pad and direction control switched, will be taken as default
|
||||
//#define USE_KEYES_REMOTE
|
||||
#if !defined(USE_KEYES_REMOTE) && !defined(USE_KEYES_REMOTE_CLONE)
|
||||
#define USE_KEYES_REMOTE_CLONE // the one you can buy at aliexpress
|
||||
#endif
|
||||
|
||||
#if (defined(USE_KEYES_REMOTE) && defined(USE_KEYES_REMOTE_CLONE))
|
||||
#error "Please choose only one remote for compile"
|
||||
#endif
|
||||
|
||||
#if defined(USE_KEYES_REMOTE_CLONE)
|
||||
#define IR_REMOTE_NAME "KEYES_CLONE"
|
||||
// Codes for the KEYES CLONE remote control with 17 keys with number pad above direction control
|
||||
#if defined(USE_IRMP_LIBRARY)
|
||||
#define IR_ADDRESS 0xFF00 // IRMP interprets NEC addresses always as 16 bit
|
||||
#else
|
||||
#define IR_ADDRESS 0x00
|
||||
#endif
|
||||
|
||||
#define IR_UP 0x18
|
||||
#define IR_DOWN 0x52
|
||||
#define IR_RIGHT 0x5A
|
||||
#define IR_LEFT 0x08
|
||||
#define IR_OK 0x1C
|
||||
|
||||
#define IR_1 0x45
|
||||
#define IR_2 0x46
|
||||
#define IR_3 0x47
|
||||
#define IR_4 0x44
|
||||
#define IR_5 0x40
|
||||
#define IR_6 0x43
|
||||
#define IR_7 0x07
|
||||
#define IR_8 0x15
|
||||
#define IR_9 0x09
|
||||
#define IR_0 0x19
|
||||
|
||||
#define IR_STAR 0x16
|
||||
#define IR_HASH 0x0D
|
||||
/*
|
||||
* SECOND:
|
||||
* IR button to command mapping for better reading. IR buttons should only referenced here.
|
||||
*/
|
||||
#define COMMAND_ON IR_UP
|
||||
#define COMMAND_OFF IR_DOWN
|
||||
#define COMMAND_INCREASE_BLINK IR_RIGHT
|
||||
#define COMMAND_DECREASE_BLINK IR_LEFT
|
||||
|
||||
#define COMMAND_START IR_OK
|
||||
#define COMMAND_STOP IR_HASH
|
||||
#define COMMAND_RESET IR_STAR
|
||||
#define COMMAND_BLINK IR_0
|
||||
#define COMMAND_TONE1 IR_1
|
||||
|
||||
#define COMMAND_TONE2 IR_2
|
||||
#define COMMAND_TONE3 IR_3
|
||||
//#define IR_4
|
||||
//#define IR_5
|
||||
//#define IR_6
|
||||
//#define IR_7
|
||||
//#define IR_8
|
||||
//#define IR_9
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(USE_KEYES_REMOTE)
|
||||
#define IR_REMOTE_NAME "KEYES"
|
||||
/*
|
||||
* FIRST:
|
||||
* IR code to button mapping for better reading. IR codes should only referenced here.
|
||||
*/
|
||||
// Codes for the KEYES remote control with 17 keys and direction control above number pad
|
||||
#if defined(USE_IRMP_LIBRARY)
|
||||
#define IR_ADDRESS 0xFF00 // IRMP interprets NEC addresses always as 16 bit
|
||||
#else
|
||||
#define IR_ADDRESS 0x00
|
||||
#endif
|
||||
|
||||
#define IR_UP 0x46
|
||||
#define IR_DOWN 0x15
|
||||
#define IR_RIGHT 0x43
|
||||
#define IR_LEFT 0x44
|
||||
#define IR_OK 0x40
|
||||
|
||||
#define IR_1 0x16
|
||||
#define IR_2 0x19
|
||||
#define IR_3 0x0D
|
||||
#define IR_4 0x0C
|
||||
#define IR_5 0x18
|
||||
#define IR_6 0x5E
|
||||
#define IR_7 0x08
|
||||
#define IR_8 0x1C
|
||||
#define IR_9 0x5A
|
||||
#define IR_0 0x52
|
||||
|
||||
#define IR_STAR 0x42
|
||||
#define IR_HASH 0x4A
|
||||
|
||||
/*
|
||||
* SECOND:
|
||||
* IR button to command mapping for better reading. IR buttons should only referenced here.
|
||||
*/
|
||||
#define COMMAND_ON IR_UP
|
||||
#define COMMAND_OFF IR_DOWN
|
||||
#define COMMAND_INCREASE_BLINK IR_RIGHT
|
||||
#define COMMAND_DECREASE_BLINK IR_LEFT
|
||||
|
||||
#define COMMAND_RESET IR_OK
|
||||
#define COMMAND_STOP IR_HASH
|
||||
#define COMMAND_STOP IR_STAR
|
||||
#define COMMAND_BLINK IR_0
|
||||
#define COMMAND_TONE2 IR_1
|
||||
|
||||
#define COMMAND_TONE1 IR_2
|
||||
#define COMMAND_TONE2 IR_3
|
||||
#define COMMAND_TONE2 IR_4
|
||||
#define COMMAND_TONE2 IR_5
|
||||
#define COMMAND_TONE2 IR_6
|
||||
#define COMMAND_TONE2 IR_7
|
||||
#define COMMAND_TONE2 IR_8
|
||||
#define COMMAND_TONE2 IR_9
|
||||
#endif
|
||||
|
||||
/*
|
||||
* THIRD:
|
||||
* Main mapping of commands to C functions
|
||||
*/
|
||||
|
||||
// IR strings of functions for output
|
||||
static const char LEDon[] PROGMEM ="LED on";
|
||||
static const char LEDoff[] PROGMEM ="LED off";
|
||||
|
||||
static const char blink20times[] PROGMEM ="blink 20 times";
|
||||
static const char blinkStart[] PROGMEM ="blink start";
|
||||
|
||||
static const char increaseBlink[] PROGMEM ="increase blink frequency";
|
||||
static const char decreaseBlink[] PROGMEM ="decrease blink frequency";
|
||||
|
||||
static const char tone2200[] PROGMEM ="tone 2200";
|
||||
static const char tone1800[] PROGMEM ="tone 1800";
|
||||
static const char printMenu[] PROGMEM ="printMenu";
|
||||
|
||||
static const char reset[] PROGMEM ="reset";
|
||||
static const char stop[] PROGMEM ="stop";
|
||||
|
||||
// not used yet
|
||||
static const char test[] PROGMEM ="test";
|
||||
static const char pattern[] PROGMEM ="pattern";
|
||||
static const char unknown[] PROGMEM ="unknown";
|
||||
|
||||
/*
|
||||
* Main mapping array of commands to C functions and command strings
|
||||
*/
|
||||
const struct IRToCommandMappingStruct IRMapping[] = { /**/
|
||||
{ COMMAND_BLINK, IR_COMMAND_FLAG_BLOCKING, &doLedBlink20times, blink20times }, /**/
|
||||
{ COMMAND_STOP, IR_COMMAND_FLAG_BLOCKING, &doStop, stop },
|
||||
|
||||
/*
|
||||
* Short commands, which can be executed always
|
||||
*/
|
||||
{ COMMAND_TONE1, IR_COMMAND_FLAG_BLOCKING, &doTone1800, tone1800 }, /**/
|
||||
{ COMMAND_TONE3, IR_COMMAND_FLAG_BLOCKING, &doPrintMenu, printMenu }, /**/
|
||||
{ COMMAND_ON, IR_COMMAND_FLAG_NON_BLOCKING, &doLedOn, LEDon }, /**/
|
||||
{ COMMAND_OFF, IR_COMMAND_FLAG_NON_BLOCKING, &doLedOff, LEDoff }, /**/
|
||||
{ COMMAND_START, IR_COMMAND_FLAG_NON_BLOCKING, &doLedBlinkStart, blinkStart }, /**/
|
||||
{ COMMAND_RESET, IR_COMMAND_FLAG_NON_BLOCKING, &doResetBlinkFrequency, reset },
|
||||
|
||||
/*
|
||||
* Repeatable short commands
|
||||
*/
|
||||
{ COMMAND_TONE2, IR_COMMAND_FLAG_REPEATABLE_NON_BLOCKING, &doTone2200, tone2200 }, /**/
|
||||
{ COMMAND_INCREASE_BLINK, IR_COMMAND_FLAG_REPEATABLE_NON_BLOCKING, &doIncreaseBlinkFrequency, increaseBlink }, /**/
|
||||
{ COMMAND_DECREASE_BLINK, IR_COMMAND_FLAG_REPEATABLE_NON_BLOCKING, &doDecreaseBlinkFrequency, decreaseBlink } };
|
||||
|
||||
#endif // _IR_COMMAND_MAPPING_H
|
||||
@@ -0,0 +1,138 @@
|
||||
/*
|
||||
* IRCommandDispatcher.h
|
||||
*
|
||||
* Library to process IR commands by calling functions specified in a mapping array.
|
||||
*
|
||||
* To run this example you need to install the "IRremote" or "IRMP" library under "Tools -> Manage Libraries..." or "Ctrl+Shift+I"
|
||||
*
|
||||
* Copyright (C) 2019-2024 Armin Joachimsmeyer
|
||||
* armin.joachimsmeyer@gmail.com
|
||||
*
|
||||
* This file is part of ServoEasing https://github.com/ArminJo/ServoEasing.
|
||||
* This file is part of IRMP https://github.com/IRMP-org/IRMP.
|
||||
* This file is part of Arduino-IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
|
||||
*
|
||||
* IRCommandDispatcher is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/gpl.html>.
|
||||
*/
|
||||
|
||||
#ifndef _IR_COMMAND_DISPATCHER_H
|
||||
#define _IR_COMMAND_DISPATCHER_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/*
|
||||
* For command mapping file
|
||||
*/
|
||||
#define IR_COMMAND_FLAG_BLOCKING 0x00 // default - blocking command, repeat not accepted, only one command at a time. Stops an already running command.
|
||||
#define IR_COMMAND_FLAG_REPEATABLE 0x01 // repeat accepted
|
||||
#define IR_COMMAND_FLAG_NON_BLOCKING 0x02 // Non blocking (short) command that can be processed any time and may interrupt other IR commands - used for stop, set direction etc.
|
||||
#define IR_COMMAND_FLAG_REPEATABLE_NON_BLOCKING (IR_COMMAND_FLAG_REPEATABLE | IR_COMMAND_FLAG_NON_BLOCKING)
|
||||
#define IR_COMMAND_FLAG_BEEP 0x04 // Do a single short beep before executing command. May not be useful for short or repeating commands.
|
||||
#define IR_COMMAND_FLAG_BLOCKING_BEEP (IR_COMMAND_FLAG_BLOCKING | IR_COMMAND_FLAG_BEEP)
|
||||
|
||||
|
||||
#if !defined(IS_STOP_REQUESTED)
|
||||
#define IS_STOP_REQUESTED IRDispatcher.requestToStopReceived
|
||||
#endif
|
||||
#if !defined(RETURN_IF_STOP)
|
||||
#define RETURN_IF_STOP if (IRDispatcher.requestToStopReceived) return
|
||||
#endif
|
||||
#if !defined(BREAK_IF_STOP)
|
||||
#define BREAK_IF_STOP if (IRDispatcher.requestToStopReceived) break
|
||||
#endif
|
||||
#if !defined(DELAY_AND_RETURN_IF_STOP)
|
||||
#define DELAY_AND_RETURN_IF_STOP(aDurationMillis) if (IRDispatcher.delayAndCheckForStop(aDurationMillis)) return
|
||||
#endif
|
||||
|
||||
// Basic mapping structure
|
||||
struct IRToCommandMappingStruct {
|
||||
#if defined(IR_COMMAND_HAS_MORE_THAN_8_BIT)
|
||||
uint16_t IRCode;
|
||||
#else
|
||||
uint8_t IRCode;
|
||||
#endif
|
||||
uint8_t Flags;
|
||||
void (*CommandToCall)();
|
||||
const char *CommandString;
|
||||
};
|
||||
|
||||
struct IRDataForCommandDispatcherStruct {
|
||||
uint16_t address; // to distinguish between multiple senders
|
||||
#if defined(IR_COMMAND_HAS_MORE_THAN_8_BIT)
|
||||
uint16_t command;
|
||||
#else
|
||||
uint8_t command;
|
||||
#endif
|
||||
bool isRepeat;
|
||||
uint32_t MillisOfLastCode; // millis() of last IR command -including repeats!- received - for timeouts etc.
|
||||
volatile bool isAvailable; // flag for a polling interpreting function, that a new command has arrived. Is set true by library and set false by main loop.
|
||||
};
|
||||
|
||||
/*
|
||||
* Special codes (hopefully) not sent by the remote - otherwise please redefine it here
|
||||
*/
|
||||
#if defined(IR_COMMAND_HAS_MORE_THAN_8_BIT)
|
||||
#define COMMAND_EMPTY 0xFFFF // code no command
|
||||
#else
|
||||
#define COMMAND_EMPTY 0xFF // code no command
|
||||
#endif
|
||||
|
||||
class IRCommandDispatcher {
|
||||
public:
|
||||
void init();
|
||||
void printIRInfo(Print *aSerial);
|
||||
|
||||
bool checkAndRunNonBlockingCommands();
|
||||
bool checkAndRunSuspendedBlockingCommands();
|
||||
#if defined(IR_COMMAND_HAS_MORE_THAN_8_BIT)
|
||||
void setNextBlockingCommand(uint16_t aBlockingCommandToRunNext);
|
||||
#else
|
||||
void setNextBlockingCommand(uint8_t aBlockingCommandToRunNext);
|
||||
#endif
|
||||
bool delayAndCheckForStop(uint16_t aDelayMillis);
|
||||
|
||||
// The main dispatcher function
|
||||
void checkAndCallCommand(bool aCallBlockingCommandImmediately);
|
||||
|
||||
void printIRCommandString(Print *aSerial);
|
||||
void setRequestToStopReceived(bool aRequestToStopReceived = true);
|
||||
|
||||
#if defined(IR_COMMAND_HAS_MORE_THAN_8_BIT)
|
||||
uint16_t currentBlockingCommandCalled = COMMAND_EMPTY; // The code for the current called command
|
||||
uint16_t lastBlockingCommandCalled = COMMAND_EMPTY; // The code for the last called command. Can be evaluated by main loop
|
||||
uint16_t BlockingCommandToRunNext = COMMAND_EMPTY; // Storage for command currently suspended to allow the current command to end, before it is called by main loop
|
||||
#else
|
||||
uint8_t currentBlockingCommandCalled = COMMAND_EMPTY; // The code for the current called command
|
||||
uint8_t lastBlockingCommandCalled = COMMAND_EMPTY; // The code for the last called command. Can be evaluated by main loop
|
||||
uint8_t BlockingCommandToRunNext = COMMAND_EMPTY; // Storage for command currently suspended to allow the current command to end, before it is called by main loop
|
||||
#endif
|
||||
bool justCalledBlockingCommand = false; // Flag that a blocking command was received and called - is set before call of command
|
||||
/*
|
||||
* Flag for running blocking commands to terminate. To check, you can use "if (IRDispatcher.requestToStopReceived) return;" (available as macro RETURN_IF_STOP).
|
||||
* It is set if a blocking IR command received, which cannot be executed directly. Can be reset by main loop, if command has stopped.
|
||||
* It is reset before executing a blocking command.
|
||||
*/
|
||||
volatile bool requestToStopReceived;
|
||||
/*
|
||||
* This flag must be true, if we have a function, which want to interpret the IR codes by itself e.g. the calibrate function of QuadrupedControl
|
||||
*/
|
||||
bool doNotUseDispatcher = false;
|
||||
|
||||
struct IRDataForCommandDispatcherStruct IRReceivedData;
|
||||
|
||||
};
|
||||
|
||||
extern IRCommandDispatcher IRDispatcher;
|
||||
|
||||
#endif // _IR_COMMAND_DISPATCHER_H
|
||||
@@ -0,0 +1,366 @@
|
||||
/*
|
||||
* IRCommandDispatcher.hpp
|
||||
*
|
||||
* Library to process IR commands by calling functions specified in a mapping array.
|
||||
* Commands can be tagged as blocking or non blocking.
|
||||
*
|
||||
* To run this example you need to install the "IRremote" or "IRMP" library.
|
||||
* Install it under "Tools -> Manage Libraries..." or "Ctrl+Shift+I"
|
||||
*
|
||||
* The IR library calls a callback function, which executes a non blocking command directly in ISR (Interrupt Service Routine) context!
|
||||
* A blocking command is stored and sets a stop flag for an already running blocking function to terminate.
|
||||
* The blocking command can in turn be executed by main loop by calling IRDispatcher.checkAndRunSuspendedBlockingCommands().
|
||||
*
|
||||
* Copyright (C) 2019-2024 Armin Joachimsmeyer
|
||||
* armin.joachimsmeyer@gmail.com
|
||||
*
|
||||
* This file is part of ServoEasing https://github.com/ArminJo/ServoEasing.
|
||||
* This file is part of IRMP https://github.com/IRMP-org/IRMP.
|
||||
* This file is part of Arduino-IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
|
||||
*
|
||||
* IRCommandDispatcher is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/gpl.html>.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Program behavior is modified by the following macros
|
||||
* USE_TINY_IR_RECEIVER
|
||||
* USE_IRMP_LIBRARY
|
||||
* IR_COMMAND_HAS_MORE_THAN_8_BIT
|
||||
*/
|
||||
|
||||
#ifndef _IR_COMMAND_DISPATCHER_HPP
|
||||
#define _IR_COMMAND_DISPATCHER_HPP
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
#include "IRCommandDispatcher.h"
|
||||
|
||||
#if !defined(STR_HELPER)
|
||||
#define STR_HELPER(x) #x
|
||||
#define STR(x) STR_HELPER(x)
|
||||
#endif
|
||||
/*
|
||||
* Enable this to see information on each call.
|
||||
* Since there should be no library which uses Serial, it should only be enabled for development purposes.
|
||||
*/
|
||||
#if defined(INFO) && !defined(LOCAL_INFO)
|
||||
#define LOCAL_INFO
|
||||
#else
|
||||
//#define LOCAL_INFO // This enables info output only for this file
|
||||
#endif
|
||||
#if defined(DEBUG) && !defined(LOCAL_DEBUG)
|
||||
#define LOCAL_DEBUG
|
||||
// Propagate debug level
|
||||
#define LOCAL_INFO
|
||||
#else
|
||||
//#define LOCAL_DEBUG // This enables debug output only for this file
|
||||
#endif
|
||||
|
||||
IRCommandDispatcher IRDispatcher;
|
||||
|
||||
#if defined(LOCAL_INFO)
|
||||
#define CD_INFO_PRINT(...) Serial.print(__VA_ARGS__);
|
||||
#define CD_INFO_PRINTLN(...) Serial.println(__VA_ARGS__);
|
||||
#else
|
||||
#define CD_INFO_PRINT(...) void();
|
||||
#define CD_INFO_PRINTLN(...) void();
|
||||
#endif
|
||||
|
||||
#if defined(USE_TINY_IR_RECEIVER)
|
||||
#define USE_CALLBACK_FOR_TINY_RECEIVER // Call the fixed function "void handleReceivedTinyIRData()" each time a frame or repeat is received.
|
||||
#include "TinyIRReceiver.hpp" // included in "IRremote" library
|
||||
|
||||
void IRCommandDispatcher::init() {
|
||||
initPCIInterruptForTinyReceiver();
|
||||
}
|
||||
|
||||
/*
|
||||
* @return true, if IR Receiver is attached
|
||||
*/
|
||||
void IRCommandDispatcher::printIRInfo(Print *aSerial) {
|
||||
aSerial->println();
|
||||
// For available IR commands see IRCommandMapping.h https://github.com/ArminJo/PWMMotorControl/blob/master/examples/SmartCarFollower/IRCommandMapping.h
|
||||
aSerial->print(F("Listening to IR remote of type "));
|
||||
aSerial->print(IR_REMOTE_NAME);
|
||||
aSerial->println(F(" at pin " STR(IR_RECEIVE_PIN)));
|
||||
}
|
||||
|
||||
/*
|
||||
* This is the TinyReceiver callback function, which is called if a complete command was received
|
||||
* It checks for right address and then call the dispatcher
|
||||
*/
|
||||
# if defined(ESP8266) || defined(ESP32)
|
||||
IRAM_ATTR
|
||||
# endif
|
||||
void handleReceivedTinyIRData() {
|
||||
IRDispatcher.IRReceivedData.address = TinyIRReceiverData.Address;
|
||||
IRDispatcher.IRReceivedData.command = TinyIRReceiverData.Command;
|
||||
IRDispatcher.IRReceivedData.isRepeat = TinyIRReceiverData.Flags & IRDATA_FLAGS_IS_REPEAT;
|
||||
IRDispatcher.IRReceivedData.MillisOfLastCode = millis();
|
||||
|
||||
# if defined(LOCAL_INFO)
|
||||
printTinyReceiverResultMinimal(&Serial);
|
||||
# endif
|
||||
|
||||
if (TinyIRReceiverData.Address == IR_ADDRESS) { // IR_ADDRESS is defined in *IRCommandMapping.h
|
||||
IRDispatcher.IRReceivedData.isAvailable = true;
|
||||
if(!IRDispatcher.doNotUseDispatcher) {
|
||||
/*
|
||||
* Only short (non blocking) commands are executed directly in ISR (Interrupt Service Routine) context,
|
||||
* others are stored for main loop which calls checkAndRunSuspendedBlockingCommands()
|
||||
*/
|
||||
IRDispatcher.checkAndCallCommand(false);
|
||||
}
|
||||
|
||||
} else {
|
||||
CD_INFO_PRINT(F("Wrong address. Expected 0x"));
|
||||
CD_INFO_PRINTLN(IR_ADDRESS, HEX);
|
||||
}
|
||||
}
|
||||
|
||||
#elif defined(USE_IRMP_LIBRARY)
|
||||
# if !defined(IRMP_USE_COMPLETE_CALLBACK)
|
||||
# error IRMP_USE_COMPLETE_CALLBACK must be activated for IRMP library
|
||||
# endif
|
||||
|
||||
void IRCommandDispatcher::init() {
|
||||
irmp_init();
|
||||
}
|
||||
|
||||
/*
|
||||
* This is the callback function, which is called if a complete command was received
|
||||
*/
|
||||
#if defined(ESP8266) || defined(ESP32)
|
||||
IRAM_ATTR
|
||||
#endif
|
||||
void handleReceivedIRData() {
|
||||
IRMP_DATA tTeporaryData;
|
||||
irmp_get_data(&tTeporaryData);
|
||||
IRDispatcher.IRReceivedData.address = tTeporaryData.address;
|
||||
IRDispatcher.IRReceivedData.command = tTeporaryData.command;
|
||||
IRDispatcher.IRReceivedData.isRepeat = tTeporaryData.flags & IRMP_FLAG_REPETITION;
|
||||
IRDispatcher.IRReceivedData.MillisOfLastCode = millis();
|
||||
|
||||
CD_INFO_PRINT(F("A=0x"));
|
||||
CD_INFO_PRINT(IRDispatcher.IRReceivedData.address, HEX);
|
||||
CD_INFO_PRINT(F(" C=0x"));
|
||||
CD_INFO_PRINT(IRDispatcher.IRReceivedData.command, HEX);
|
||||
if (IRDispatcher.IRReceivedData.isRepeat) {
|
||||
CD_INFO_PRINT(F("R"));
|
||||
}
|
||||
CD_INFO_PRINTLN();
|
||||
|
||||
// To enable delay() for commands
|
||||
# if !defined(ARDUINO_ARCH_MBED)
|
||||
interrupts(); // be careful with always executable commands which lasts longer than the IR repeat duration.
|
||||
# endif
|
||||
|
||||
if (IRDispatcher.IRReceivedData.address == IR_ADDRESS) {
|
||||
IRDispatcher.checkAndCallCommand(true);
|
||||
} else {
|
||||
CD_INFO_PRINT(F("Wrong address. Expected 0x"));
|
||||
CD_INFO_PRINTLN(IR_ADDRESS, HEX);
|
||||
}
|
||||
}
|
||||
#endif // elif defined(USE_IRMP_LIBRARY)
|
||||
|
||||
/*
|
||||
* The main dispatcher function called by IR-ISR, main loop and checkAndRunSuspendedBlockingCommands()
|
||||
* Non blocking commands are executed directly, blocking commands are executed if enabled by parameter and no other command is just running.
|
||||
* Otherwise request to stop (requestToStopReceived) is set and command is stored for main loop to be later execute by checkAndRunSuspendedBlockingCommands().
|
||||
* Sets flags justCalledRegularIRCommand, executingBlockingCommand, requestToStopReceived
|
||||
* @param aCallBlockingCommandImmediately Run blocking command directly, if no other command is just running. Should be false if called by ISR in order not to block ISR.
|
||||
*/
|
||||
void IRCommandDispatcher::checkAndCallCommand(bool aCallBlockingCommandImmediately) {
|
||||
if (IRReceivedData.command == COMMAND_EMPTY) {
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Search for command in Array of IRToCommandMappingStruct
|
||||
*/
|
||||
for (uint_fast8_t i = 0; i < sizeof(IRMapping) / sizeof(struct IRToCommandMappingStruct); ++i) {
|
||||
if (IRReceivedData.command == IRMapping[i].IRCode) {
|
||||
/*
|
||||
* Command found
|
||||
*/
|
||||
#if defined(LOCAL_INFO)
|
||||
const __FlashStringHelper *tCommandName = reinterpret_cast<const __FlashStringHelper*>(IRMapping[i].CommandString);
|
||||
#endif
|
||||
/*
|
||||
* Check for repeat and if repeat is allowed for the current command
|
||||
*/
|
||||
if (IRReceivedData.isRepeat && !(IRMapping[i].Flags & IR_COMMAND_FLAG_REPEATABLE)) {
|
||||
#if defined(LOCAL_DEBUG)
|
||||
Serial.print(F("Repeats of command \""));
|
||||
Serial.print(tCommandName);
|
||||
Serial.println("\" not accepted");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Do not accept recursive call of the same command
|
||||
*/
|
||||
if (currentBlockingCommandCalled == IRReceivedData.command) {
|
||||
#if defined(LOCAL_DEBUG)
|
||||
Serial.print(F("Recursive command \""));
|
||||
Serial.print(tCommandName);
|
||||
Serial.println("\" not accepted");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Execute commands
|
||||
*/
|
||||
bool tIsNonBlockingCommand = (IRMapping[i].Flags & IR_COMMAND_FLAG_NON_BLOCKING);
|
||||
if (tIsNonBlockingCommand) {
|
||||
// short command here, just call
|
||||
CD_INFO_PRINT(F("Run non blocking command: "));
|
||||
CD_INFO_PRINTLN(tCommandName);
|
||||
#if defined(BUZZER_PIN) && defined(USE_TINY_IR_RECEIVER)
|
||||
/*
|
||||
* Do (non blocking) buzzer feedback before command is executed
|
||||
*/
|
||||
if(IRMapping[i].Flags & IR_COMMAND_FLAG_BEEP) {
|
||||
tone(BUZZER_PIN, 2200, 50);
|
||||
}
|
||||
#endif
|
||||
IRMapping[i].CommandToCall();
|
||||
} else {
|
||||
/*
|
||||
* Blocking command here
|
||||
*/
|
||||
if (aCallBlockingCommandImmediately && currentBlockingCommandCalled == COMMAND_EMPTY) {
|
||||
/*
|
||||
* Here no blocking command was running and we are called from main loop
|
||||
*/
|
||||
requestToStopReceived = false; // Do not stop the command executed now
|
||||
justCalledBlockingCommand = true;
|
||||
currentBlockingCommandCalled = IRReceivedData.command; // set lock for recursive calls
|
||||
lastBlockingCommandCalled = IRReceivedData.command; // set history, can be evaluated by main loop
|
||||
/*
|
||||
* This call is blocking!!!
|
||||
*/
|
||||
CD_INFO_PRINT(F("Run blocking command: "));
|
||||
CD_INFO_PRINTLN(tCommandName);
|
||||
|
||||
#if defined(BUZZER_PIN) && defined(USE_TINY_IR_RECEIVER)
|
||||
/*
|
||||
* Do (non blocking) buzzer feedback before command is executed
|
||||
*/
|
||||
if(IRMapping[i].Flags & IR_COMMAND_FLAG_BEEP) {
|
||||
tone(BUZZER_PIN, 2200, 50);
|
||||
}
|
||||
#endif
|
||||
|
||||
IRMapping[i].CommandToCall();
|
||||
#if defined(TRACE)
|
||||
Serial.println(F("End of blocking command"));
|
||||
#endif
|
||||
currentBlockingCommandCalled = COMMAND_EMPTY;
|
||||
} else {
|
||||
/*
|
||||
* Called by ISR or another command still running.
|
||||
* Do not run command directly, but set request to stop to true and store command
|
||||
* for main loop to execute by checkAndRunSuspendedBlockingCommands()
|
||||
*/
|
||||
BlockingCommandToRunNext = IRReceivedData.command;
|
||||
requestToStopReceived = true; // to stop running command
|
||||
CD_INFO_PRINT(F("Requested stop and stored blocking command "));
|
||||
CD_INFO_PRINT(tCommandName);
|
||||
CD_INFO_PRINTLN(F(" as next command to run."));
|
||||
}
|
||||
}
|
||||
break; // command found
|
||||
} // if (IRReceivedData.command == IRMapping[i].IRCode)
|
||||
} // for loop
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Intended to be called from main loop
|
||||
* @return true, if command was called
|
||||
*/
|
||||
bool IRCommandDispatcher::checkAndRunSuspendedBlockingCommands() {
|
||||
/*
|
||||
* Take last rejected command and call associated function
|
||||
*/
|
||||
if (BlockingCommandToRunNext != COMMAND_EMPTY) {
|
||||
|
||||
CD_INFO_PRINT(F("Run stored command=0x"));
|
||||
CD_INFO_PRINTLN(BlockingCommandToRunNext, HEX);
|
||||
|
||||
IRReceivedData.command = BlockingCommandToRunNext;
|
||||
BlockingCommandToRunNext = COMMAND_EMPTY;
|
||||
IRReceivedData.isRepeat = false;
|
||||
requestToStopReceived = false; // Do not stop the command executed now
|
||||
checkAndCallCommand(true);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Not used internally
|
||||
*/
|
||||
#if defined(IR_COMMAND_HAS_MORE_THAN_8_BIT)
|
||||
void IRCommandDispatcher::setNextBlockingCommand(uint16_t aBlockingCommandToRunNext)
|
||||
#else
|
||||
void IRCommandDispatcher::setNextBlockingCommand(uint8_t aBlockingCommandToRunNext)
|
||||
#endif
|
||||
{
|
||||
CD_INFO_PRINT(F("Set next command to run to 0x"));
|
||||
CD_INFO_PRINTLN(aBlockingCommandToRunNext, HEX);
|
||||
BlockingCommandToRunNext = aBlockingCommandToRunNext;
|
||||
requestToStopReceived = true;
|
||||
}
|
||||
|
||||
/*
|
||||
* Special delay function for the IRCommandDispatcher. Returns prematurely if requestToStopReceived is set.
|
||||
* To be used in blocking functions as delay
|
||||
* @return true - as soon as stop received
|
||||
*/
|
||||
bool IRCommandDispatcher::delayAndCheckForStop(uint16_t aDelayMillis) {
|
||||
uint32_t tStartMillis = millis();
|
||||
do {
|
||||
if (requestToStopReceived) {
|
||||
return true;
|
||||
}
|
||||
} while (millis() - tStartMillis < aDelayMillis);
|
||||
return false;
|
||||
}
|
||||
|
||||
void IRCommandDispatcher::printIRCommandString(Print *aSerial) {
|
||||
for (uint_fast8_t i = 0; i < sizeof(IRMapping) / sizeof(struct IRToCommandMappingStruct); ++i) {
|
||||
if (IRReceivedData.command == IRMapping[i].IRCode) {
|
||||
aSerial->println(reinterpret_cast<const __FlashStringHelper*>(IRMapping[i].CommandString));
|
||||
return;
|
||||
}
|
||||
}
|
||||
aSerial->println(reinterpret_cast<const __FlashStringHelper*>(unknown));
|
||||
}
|
||||
|
||||
void IRCommandDispatcher::setRequestToStopReceived(bool aRequestToStopReceived) {
|
||||
requestToStopReceived = aRequestToStopReceived;
|
||||
}
|
||||
|
||||
#if defined(LOCAL_DEBUG)
|
||||
#undef LOCAL_DEBUG
|
||||
#endif
|
||||
#if defined(LOCAL_INFO)
|
||||
#undef LOCAL_INFO
|
||||
#endif
|
||||
#endif // _IR_COMMAND_DISPATCHER_HPP
|
||||
@@ -0,0 +1,249 @@
|
||||
/*
|
||||
* IRDispatcherDemo.cpp
|
||||
*
|
||||
* Receives NEC IR commands and maps them to different actions by means of a mapping array.
|
||||
*
|
||||
* Copyright (C) 2020-2021 Armin Joachimsmeyer
|
||||
* armin.joachimsmeyer@gmail.com
|
||||
*
|
||||
* This file is part of IRMP https://github.com/IRMP-org/IRMP.
|
||||
* This file is part of Arduino-IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
|
||||
*
|
||||
* IRMP is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/gpl.html>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
/*
|
||||
* Choose the library to be used for IR receiving
|
||||
*/
|
||||
#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.
|
||||
|
||||
#define IR_RECEIVE_PIN 4 // P0_1
|
||||
#define TONE_PIN 5 // P0_2
|
||||
|
||||
// Some kind of auto detect library if USE_TINY_IR_RECEIVER is deactivated
|
||||
#if !defined(USE_TINY_IR_RECEIVER)
|
||||
# if defined(IR_RECEIVE_PIN)
|
||||
#define USE_TINY_IR_RECEIVER
|
||||
# elif !defined(USE_IRMP_LIBRARY) && defined(IRMP_INPUT_PIN)
|
||||
#define USE_IRMP_LIBRARY
|
||||
# else
|
||||
#error No IR library selected
|
||||
# endif
|
||||
#endif
|
||||
|
||||
//#define NO_LED_FEEDBACK_CODE // You can set it here, before the include of IRCommandDispatcher below
|
||||
|
||||
#if defined(USE_TINY_IR_RECEIVER)
|
||||
//#define NO_LED_FEEDBACK_CODE // Activate this if you want to suppress LED feedback or if you do not have a LED. This saves 14 bytes code and 2 clock cycles per interrupt.
|
||||
|
||||
#elif defined(USE_IRMP_LIBRARY)
|
||||
/*
|
||||
* IRMP version
|
||||
*/
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IRMP_USE_COMPLETE_CALLBACK 1 // Enable callback functionality. It is required if IRMP library is used.
|
||||
|
||||
//#define IRMP_ENABLE_PIN_CHANGE_INTERRUPT // Enable interrupt functionality (not for all protocols) - requires around 376 additional bytes of program memory
|
||||
|
||||
#define IRMP_PROTOCOL_NAMES 1 // Enable protocol number mapping to protocol strings - requires some program memory. Must before #include <irmp*>
|
||||
|
||||
#define IRMP_SUPPORT_NEC_PROTOCOL 1 // this enables only one protocol
|
||||
//#define IRMP_SUPPORT_KASEIKYO_PROTOCOL 1
|
||||
|
||||
/*
|
||||
* After setting the definitions we can include the code and compile it.
|
||||
*/
|
||||
#include <irmp.hpp>
|
||||
void handleReceivedIRData();
|
||||
void irmp_tone(uint8_t _pin, unsigned int frequency, unsigned long duration);
|
||||
#endif // #if defined(USE_IRMP_LIBRARY)
|
||||
|
||||
bool doBlink = false;
|
||||
uint16_t sBlinkDelay = 200;
|
||||
|
||||
void doPrintMenu();
|
||||
void doLedOn();
|
||||
void doLedOff();
|
||||
void doIncreaseBlinkFrequency();
|
||||
void doDecreaseBlinkFrequency();
|
||||
void doStop();
|
||||
void doResetBlinkFrequency();
|
||||
void doLedBlinkStart();
|
||||
void doLedBlink20times();
|
||||
void doTone1800();
|
||||
void doTone2200();
|
||||
|
||||
/*
|
||||
* Set definitions and include IRCommandDispatcher library after the declaration of all commands to map
|
||||
*/
|
||||
#define INFO // to see some informative output
|
||||
#include "IRCommandDispatcher.h" // Only for required declarations, the library itself is included below after the definitions of the commands
|
||||
#include "DemoIRCommandMapping.h" // must be included before IRCommandDispatcher.hpp to define IR_ADDRESS and IRMapping and string "unknown".
|
||||
#include "IRCommandDispatcher.hpp"
|
||||
|
||||
/*
|
||||
* Helper macro for getting a macro definition as string
|
||||
*/
|
||||
#define STR_HELPER(x) #x
|
||||
#define STR(x) STR_HELPER(x)
|
||||
|
||||
void setup() {
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
Serial.begin(9600);
|
||||
while (!Serial)
|
||||
; // Wait for Serial to become available. Is optimized away for some cores.
|
||||
|
||||
// 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"));
|
||||
#elif defined(USE_IRREMOTE_LIBRARY)
|
||||
Serial.println(F("START " __FILE__ " from " __DATE__ "\r\nUsing IRremote library version " VERSION_IRREMOTE));
|
||||
#elif defined(USE_IRMP_LIBRARY)
|
||||
Serial.println(F("START " __FILE__ " from " __DATE__ "\r\nUsing IRMP library version " VERSION_IRMP));
|
||||
#endif
|
||||
|
||||
// play feedback tone before setup, since it kills the IR timer settings
|
||||
tone(TONE_PIN, 1000, 50);
|
||||
delay(50);
|
||||
|
||||
IRDispatcher.init(); // This just calls irmp_init()
|
||||
#if defined(USE_TINY_IR_RECEIVER)
|
||||
Serial.println(F("Ready to receive NEC IR signals at pin " STR(IR_RECEIVE_PIN)));
|
||||
#else
|
||||
irmp_register_complete_callback_function(&handleReceivedIRData); // fixed function in IRCommandDispatcher.hpp
|
||||
|
||||
Serial.print(F("Ready to receive IR signals of protocols: "));
|
||||
irmp_print_active_protocols(&Serial);
|
||||
Serial.println(F("at pin " STR(IRMP_INPUT_PIN)));
|
||||
#endif
|
||||
|
||||
Serial.print(F("Listening to commands of IR remote of type "));
|
||||
Serial.println(IR_REMOTE_NAME);
|
||||
doPrintMenu();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
IRDispatcher.checkAndRunSuspendedBlockingCommands();
|
||||
|
||||
if (doBlink) {
|
||||
digitalWrite(LED_BUILTIN, HIGH);
|
||||
DELAY_AND_RETURN_IF_STOP(sBlinkDelay);
|
||||
digitalWrite(LED_BUILTIN, LOW);
|
||||
DELAY_AND_RETURN_IF_STOP(sBlinkDelay);
|
||||
}
|
||||
|
||||
if (millis() - IRDispatcher.IRReceivedData.MillisOfLastCode > 120000) {
|
||||
//Short beep as remainder, if we did not receive any command in the last 2 minutes
|
||||
IRDispatcher.IRReceivedData.MillisOfLastCode += 120000;
|
||||
doTone1800();
|
||||
}
|
||||
|
||||
// delay(10);
|
||||
}
|
||||
|
||||
void doPrintMenu() {
|
||||
Serial.println();
|
||||
Serial.println(F("Press 1 for tone 1800 Hz"));
|
||||
Serial.println(F("Press 2 for tone 2200 Hz"));
|
||||
Serial.println(F("Press 3 for this Menu"));
|
||||
Serial.println(F("Press 0 for LED blink 20 times"));
|
||||
Serial.println(F("Press UP for LED on"));
|
||||
Serial.println(F("Press DOWN for LED off"));
|
||||
Serial.println(F("Press OK for LED blink start"));
|
||||
Serial.println(F("Press RIGHT for LED increase blink frequency"));
|
||||
Serial.println(F("Press LEFT for LED decrease blink frequency"));
|
||||
Serial.println(F("Press STAR for reset blink frequency"));
|
||||
Serial.println(F("Press HASH for stop"));
|
||||
Serial.println();
|
||||
}
|
||||
/*
|
||||
* Here the actions that are matched to IR keys
|
||||
*/
|
||||
void doLedOn() {
|
||||
digitalWrite(LED_BUILTIN, HIGH);
|
||||
doBlink = false;
|
||||
}
|
||||
void doLedOff() {
|
||||
digitalWrite(LED_BUILTIN, LOW);
|
||||
doBlink = false;
|
||||
}
|
||||
void doIncreaseBlinkFrequency() {
|
||||
doBlink = true;
|
||||
if (sBlinkDelay > 5) {
|
||||
sBlinkDelay -= sBlinkDelay / 4;
|
||||
}
|
||||
}
|
||||
void doDecreaseBlinkFrequency() {
|
||||
doBlink = true;
|
||||
sBlinkDelay += sBlinkDelay / 4;
|
||||
}
|
||||
void doStop() {
|
||||
doBlink = false;
|
||||
}
|
||||
void doResetBlinkFrequency() {
|
||||
sBlinkDelay = 200;
|
||||
digitalWrite(LED_BUILTIN, LOW);
|
||||
}
|
||||
void doLedBlinkStart() {
|
||||
doBlink = true;
|
||||
}
|
||||
/*
|
||||
* This is a blocking function and checks periodically for stop
|
||||
*/
|
||||
void doLedBlink20times() {
|
||||
for (int i = 0; i < 20; ++i) {
|
||||
digitalWrite(LED_BUILTIN, HIGH);
|
||||
DELAY_AND_RETURN_IF_STOP(200);
|
||||
digitalWrite(LED_BUILTIN, LOW);
|
||||
DELAY_AND_RETURN_IF_STOP(200);
|
||||
}
|
||||
}
|
||||
|
||||
void doTone1800() {
|
||||
#if defined(USE_IRMP_LIBRARY) && !defined(IRMP_ENABLE_PIN_CHANGE_INTERRUPT)
|
||||
irmp_tone(TONE_PIN, 1800, 200);
|
||||
#else
|
||||
# if !defined(ESP8266) && !defined(NRF5) // tone() stops timer 1 for ESP8266
|
||||
tone(TONE_PIN, 1800, 200);
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void doTone2200() {
|
||||
#if defined(USE_IRMP_LIBRARY) && !defined(IRMP_ENABLE_PIN_CHANGE_INTERRUPT)
|
||||
// use IRMP compatible function for tone()
|
||||
irmp_tone(TONE_PIN, 2200, 50);
|
||||
#else
|
||||
# if !defined(ESP8266) && !defined(NRF5) // tone() stops timer 1 for ESP8266
|
||||
tone(TONE_PIN, 2200, 50);
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(USE_IRMP_LIBRARY)
|
||||
/*
|
||||
* Convenience IRMP compatible wrapper function for Arduino tone() if IRMP_ENABLE_PIN_CHANGE_INTERRUPT is NOT activated
|
||||
* It currently disables the receiving of repeats
|
||||
*/
|
||||
void irmp_tone(uint8_t _pin, unsigned int frequency, unsigned long duration) {
|
||||
tone(_pin, frequency, duration);
|
||||
}
|
||||
#endif // #if defined(USE_IRMP_LIBRARY)
|
||||
@@ -0,0 +1,349 @@
|
||||
/*
|
||||
* PinDefinitionsAndMore.h
|
||||
*
|
||||
* Contains pin definitions for IRremote examples for various platforms
|
||||
* as well as definitions for feedback LED and tone() and includes
|
||||
*
|
||||
* Copyright (C) 2021-2023 Armin Joachimsmeyer
|
||||
* armin.joachimsmeyer@gmail.com
|
||||
*
|
||||
* This file is part of IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
|
||||
*
|
||||
* Arduino-IRremote is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/gpl.html>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Pin mapping table for different platforms
|
||||
*
|
||||
* Platform IR input IR output Tone Core/Pin schema
|
||||
* --------------------------------------------------------------
|
||||
* DEFAULT/AVR 2 3 4 Arduino
|
||||
* ATtinyX5 0|PB0 4|PB4 3|PB3 ATTinyCore
|
||||
* ATtiny167 3|PA3 2|PA2 7|PA7 ATTinyCore
|
||||
* ATtiny167 9|PA3 8|PA2 5|PA7 Digispark original core
|
||||
* ATtiny84 |PB2 |PA4 |PA3 ATTinyCore
|
||||
* ATtiny88 3|PD3 4|PD4 9|PB1 ATTinyCore
|
||||
* ATtiny3217 18|PA1 19|PA2 20|PA3 MegaTinyCore
|
||||
* ATtiny1604 2 3|PA5 %
|
||||
* ATtiny816 14|PA1 16|PA3 1|PA5 MegaTinyCore
|
||||
* ATtiny1614 8|PA1 10|PA3 1|PA5 MegaTinyCore
|
||||
* SAMD21 3 4 5
|
||||
* ESP8266 14|D5 12|D6 %
|
||||
* ESP32 15 4 27
|
||||
* ESP32-C3 2 3 4
|
||||
* BluePill PA6 PA7 PA3
|
||||
* APOLLO3 11 12 5
|
||||
* RP2040 3|GPIO15 4|GPIO16 5|GPIO17
|
||||
*/
|
||||
//#define _IR_MEASURE_TIMING // For debugging purposes.
|
||||
|
||||
#if defined(__AVR__)
|
||||
#if defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__) // Digispark board. For use with ATTinyCore.
|
||||
#include "ATtinySerialOut.hpp" // TX is at pin 2 - Available as Arduino library "ATtinySerialOut". Saves 700 bytes program memory and 70 bytes RAM for ATtinyCore.
|
||||
#define IR_RECEIVE_PIN PIN_PB0
|
||||
#define IR_SEND_PIN PIN_PB4 // Pin 2 is serial output with ATtinySerialOut. Pin 1 is internal LED and Pin3 is USB+ with pullup on Digispark board.
|
||||
#define TONE_PIN PIN_PB3
|
||||
#define _IR_TIMING_TEST_PIN PIN_PB3
|
||||
|
||||
# elif defined(__AVR_ATtiny87__) || defined(__AVR_ATtiny167__) // Digispark pro board
|
||||
#include "ATtinySerialOut.hpp" // Available as Arduino library "ATtinySerialOut"
|
||||
// For ATtiny167 Pins PB6 and PA3 are usable as interrupt source.
|
||||
# if defined(ARDUINO_AVR_DIGISPARKPRO)
|
||||
// For use with Digispark original core
|
||||
#define IR_RECEIVE_PIN 9 // PA3 - on Digispark board labeled as pin 9
|
||||
//#define IR_RECEIVE_PIN 14 // PB6 / INT0 is connected to USB+ on DigisparkPro boards
|
||||
#define IR_SEND_PIN 8 // PA2 - on Digispark board labeled as pin 8
|
||||
#define TONE_PIN 5 // PA7 - on Digispark board labeled as pin 5
|
||||
#define _IR_TIMING_TEST_PIN 10 // PA4
|
||||
# else
|
||||
// For use with ATTinyCore
|
||||
#define IR_RECEIVE_PIN PIN_PA3 // On Digispark board labeled as pin 9 - INT0 is connected to USB+ on DigisparkPro boards
|
||||
#define IR_SEND_PIN PIN_PA2 // On Digispark board labeled as pin 8
|
||||
#define TONE_PIN PIN_PA7 // On Digispark board labeled as pin 5
|
||||
# endif
|
||||
|
||||
# elif defined(__AVR_ATtiny84__) // For use with ATTinyCore
|
||||
#include "ATtinySerialOut.hpp" // Available as Arduino library "ATtinySerialOut". Saves 128 bytes program memory.
|
||||
#define IR_RECEIVE_PIN PIN_PB2 // INT0
|
||||
#define IR_SEND_PIN PIN_PA4
|
||||
#define TONE_PIN PIN_PA3
|
||||
#define _IR_TIMING_TEST_PIN PIN_PA5
|
||||
|
||||
# elif defined(__AVR_ATtiny88__) // MH-ET Tiny88 board. For use with ATTinyCore.
|
||||
#include "ATtinySerialOut.hpp" // Available as Arduino library "ATtinySerialOut". Saves 128 bytes program memory.
|
||||
// Pin 6 is TX, pin 7 is RX
|
||||
#define IR_RECEIVE_PIN PIN_PD3 // 3 - INT1
|
||||
#define IR_SEND_PIN PIN_PD4 // 4
|
||||
#define TONE_PIN PIN_PB1 // 9
|
||||
#define _IR_TIMING_TEST_PIN PIN_PB0 // 8
|
||||
|
||||
# elif defined(__AVR_ATtiny1616__) || defined(__AVR_ATtiny3216__) || defined(__AVR_ATtiny3217__) // For use with megaTinyCore
|
||||
// Tiny Core Dev board
|
||||
// https://www.tindie.com/products/xkimi/tiny-core-16-dev-board-attiny1616/ - Out of Stock
|
||||
// https://www.tindie.com/products/xkimi/tiny-core-32-dev-board-attiny3217/ - Out of Stock
|
||||
#define IR_RECEIVE_PIN PIN_PA1 // use 18 instead of PIN_PA1 for TinyCore32
|
||||
#define IR_SEND_PIN PIN_PA2 // 19
|
||||
#define TONE_PIN PIN_PA3 // 20
|
||||
#define APPLICATION_PIN PIN_PA0 // 0
|
||||
#undef LED_BUILTIN // No LED available on the TinyCore 32 board, take the one on the programming board which is connected to the DAC output
|
||||
#define LED_BUILTIN PIN_PA6 // use 2 instead of PIN_PA6 for TinyCore32
|
||||
|
||||
# elif defined(__AVR_ATtiny816__) // For use with megaTinyCore
|
||||
#define IR_RECEIVE_PIN PIN_PA1 // 14
|
||||
#define IR_SEND_PIN PIN_PA1 // 16
|
||||
#define TONE_PIN PIN_PA5 // 1
|
||||
#define APPLICATION_PIN PIN_PA4 // 0
|
||||
#undef LED_BUILTIN // No LED available, take the one which is connected to the DAC output
|
||||
#define LED_BUILTIN PIN_PB5 // 4
|
||||
|
||||
# elif defined(__AVR_ATtiny1614__) // For use with megaTinyCore
|
||||
#define IR_RECEIVE_PIN PIN_PA1 // 8
|
||||
#define IR_SEND_PIN PIN_PA3 // 10
|
||||
#define TONE_PIN PIN_PA5 // 1
|
||||
#define APPLICATION_PIN PIN_PA4 // 0
|
||||
|
||||
# elif defined(__AVR_ATtiny1604__) // For use with megaTinyCore
|
||||
#define IR_RECEIVE_PIN PIN_PA6 // 2 - To be compatible with interrupt example, pin 2 is chosen here.
|
||||
#define IR_SEND_PIN PIN_PA7 // 3
|
||||
#define APPLICATION_PIN PIN_PB2 // 5
|
||||
|
||||
#define tone(...) void() // Define as void, since TCB0_INT_vect is also used by tone()
|
||||
#define noTone(a) void()
|
||||
#define TONE_PIN 42 // Dummy for examples using it
|
||||
|
||||
# elif defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) \
|
||||
|| defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) \
|
||||
|| defined(__AVR_ATmega324P__) || defined(__AVR_ATmega324A__) \
|
||||
|| defined(__AVR_ATmega324PA__) || defined(__AVR_ATmega164A__) \
|
||||
|| defined(__AVR_ATmega164P__) || defined(__AVR_ATmega32__) \
|
||||
|| defined(__AVR_ATmega16__) || defined(__AVR_ATmega8535__) \
|
||||
|| defined(__AVR_ATmega64__) || defined(__AVR_ATmega128__) \
|
||||
|| defined(__AVR_ATmega1281__) || defined(__AVR_ATmega2561__) \
|
||||
|| defined(__AVR_ATmega8515__) || defined(__AVR_ATmega162__)
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 13
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
# else // Default as for ATmega328 like on Uno, Nano, Leonardo, Teensy 2.0 etc.
|
||||
#define IR_RECEIVE_PIN 2 // To be compatible with interrupt example, pin 2 is chosen here.
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
# if defined(ARDUINO_AVR_PROMICRO) // Sparkfun Pro Micro is __AVR_ATmega32U4__ but has different external circuit
|
||||
// We have no built in LED at pin 13 -> reuse RX LED
|
||||
#undef LED_BUILTIN
|
||||
#define LED_BUILTIN LED_BUILTIN_RX
|
||||
# endif
|
||||
# endif // defined(__AVR_ATtiny25__)...
|
||||
|
||||
#elif defined(ARDUINO_ARCH_RENESAS_UNO) // Uno R4
|
||||
// To be compatible with Uno R3.
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
#elif defined(ESP8266)
|
||||
#define FEEDBACK_LED_IS_ACTIVE_LOW // The LED on my board (D4) is active LOW
|
||||
#define IR_RECEIVE_PIN 14 // D5
|
||||
#define IR_SEND_PIN 12 // D6 - D4/pin 2 is internal LED
|
||||
#define _IR_TIMING_TEST_PIN 2 // D4
|
||||
#define APPLICATION_PIN 13 // D7
|
||||
|
||||
#define tone(...) void() // tone() inhibits receive timer
|
||||
#define noTone(a) void()
|
||||
#define TONE_PIN 42 // Dummy for examples using it#
|
||||
|
||||
#elif defined(ARDUINO_NOLOGO_ESP32C3_SUPER_MINI)
|
||||
#define FEEDBACK_LED_IS_ACTIVE_LOW // The LED on my board (D8) is active LOW
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 10
|
||||
|
||||
#elif defined(CONFIG_IDF_TARGET_ESP32C3) || defined(ARDUINO_ESP32C3_DEV)
|
||||
#define NO_LED_FEEDBACK_CODE // The WS2812 on pin 8 of AI-C3 board crashes if used as receive feedback LED, other I/O pins are working...
|
||||
#define IR_RECEIVE_PIN 6
|
||||
#define IR_SEND_PIN 7
|
||||
#define TONE_PIN 10
|
||||
#define APPLICATION_PIN 18
|
||||
|
||||
#elif defined(ESP32)
|
||||
#include <Arduino.h>
|
||||
|
||||
// tone() is included in ESP32 core since 2.0.2
|
||||
#if !defined(ESP_ARDUINO_VERSION_VAL)
|
||||
#define ESP_ARDUINO_VERSION_VAL(major, minor, patch) 12345678
|
||||
#endif
|
||||
#if ESP_ARDUINO_VERSION <= ESP_ARDUINO_VERSION_VAL(2, 0, 2)
|
||||
#define TONE_LEDC_CHANNEL 1 // Using channel 1 makes tone() independent of receiving timer -> No need to stop receiving timer.
|
||||
void tone(uint8_t aPinNumber, unsigned int aFrequency){
|
||||
ledcAttachPin(aPinNumber, TONE_LEDC_CHANNEL);
|
||||
ledcWriteTone(TONE_LEDC_CHANNEL, aFrequency);
|
||||
}
|
||||
void tone(uint8_t aPinNumber, unsigned int aFrequency, unsigned long aDuration){
|
||||
ledcAttachPin(aPinNumber, TONE_LEDC_CHANNEL);
|
||||
ledcWriteTone(TONE_LEDC_CHANNEL, aFrequency);
|
||||
delay(aDuration);
|
||||
ledcWriteTone(TONE_LEDC_CHANNEL, 0);
|
||||
}
|
||||
void noTone(uint8_t aPinNumber){
|
||||
ledcWriteTone(TONE_LEDC_CHANNEL, 0);
|
||||
}
|
||||
#endif // ESP_ARDUINO_VERSION <= ESP_ARDUINO_VERSION_VAL(2, 0, 2)
|
||||
|
||||
#define IR_RECEIVE_PIN 15 // D15
|
||||
#define IR_SEND_PIN 4 // D4
|
||||
#define TONE_PIN 27 // D27 25 & 26 are DAC0 and 1
|
||||
#define APPLICATION_PIN 16 // RX2 pin
|
||||
|
||||
#elif defined(ARDUINO_ARCH_STM32) || defined(ARDUINO_ARCH_STM32F1) // BluePill
|
||||
// Timer 3 blocks PA6, PA7, PB0, PB1 for use by Servo or tone()
|
||||
#define IR_RECEIVE_PIN PA6
|
||||
#define IR_RECEIVE_PIN_STRING "PA6"
|
||||
#define IR_SEND_PIN PA7
|
||||
#define IR_SEND_PIN_STRING "PA7"
|
||||
#define TONE_PIN PA3
|
||||
#define _IR_TIMING_TEST_PIN PA5
|
||||
#define APPLICATION_PIN PA2
|
||||
#define APPLICATION_PIN_STRING "PA2"
|
||||
# if defined(ARDUINO_GENERIC_STM32F103C) || defined(ARDUINO_BLUEPILL_F103C8)
|
||||
// BluePill LED is active low
|
||||
#define FEEDBACK_LED_IS_ACTIVE_LOW
|
||||
# endif
|
||||
|
||||
#elif defined(ARDUINO_ARCH_APOLLO3) // Sparkfun Apollo boards
|
||||
#define IR_RECEIVE_PIN 11
|
||||
#define IR_SEND_PIN 12
|
||||
#define TONE_PIN 5
|
||||
|
||||
#elif defined(ARDUINO_ARCH_MBED) && defined(ARDUINO_ARCH_MBED_NANO) // Arduino Nano 33 BLE and Arduino Nano Connect layout for MBED
|
||||
// Must be before ARDUINO_ARCH_RP2040, since it is the layout for the MBED core of Arduino Nano Connect
|
||||
#define IR_RECEIVE_PIN 3 // GPIO15 Start with pin 3 since pin 2|GPIO25 is connected to LED on Pi pico
|
||||
#define IR_SEND_PIN 4 // GPIO16
|
||||
#define TONE_PIN 5
|
||||
#define APPLICATION_PIN 6
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 7 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 8
|
||||
|
||||
#elif defined(ARDUINO_ARCH_RP2040) // Arduino Nano Connect, Pi Pico with arduino-pico core https://github.com/earlephilhower/arduino-pico
|
||||
#define IR_RECEIVE_PIN 15 // GPIO15 to be compatible with the Arduino Nano RP2040 Connect (pin3)
|
||||
#define IR_SEND_PIN 16 // GPIO16
|
||||
#define TONE_PIN 17
|
||||
#define APPLICATION_PIN 18
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 19 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 20
|
||||
|
||||
// If you program the Nano RP2040 Connect with this core, then you must redefine LED_BUILTIN
|
||||
// and use the external reset with 1 kOhm to ground to enter UF2 mode
|
||||
#undef LED_BUILTIN
|
||||
#define LED_BUILTIN 6
|
||||
|
||||
#elif defined(PARTICLE) // !!!UNTESTED!!!
|
||||
#define IR_RECEIVE_PIN A4
|
||||
#define IR_SEND_PIN A5 // Particle supports multiple pins
|
||||
|
||||
#define LED_BUILTIN D7
|
||||
|
||||
/*
|
||||
* 4 times the same (default) layout for easy adaption in the future
|
||||
*/
|
||||
#elif defined(TEENSYDUINO) // Teensy 2.0 is handled at default for ATmega328 like on Uno, Nano, Leonardo etc.
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
#elif defined(ARDUINO_ARCH_MBED) // Arduino Nano 33 BLE
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
#elif defined(ARDUINO_ARCH_SAMD) || defined(ARDUINO_ARCH_SAM)
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
#if !defined(ARDUINO_SAMD_ADAFRUIT) && !defined(ARDUINO_SEEED_XIAO_M0)
|
||||
// On the Zero and others we switch explicitly to SerialUSB
|
||||
#define Serial SerialUSB
|
||||
#endif
|
||||
|
||||
// Definitions for the Chinese SAMD21 M0-Mini clone, which has no led connected to D13/PA17.
|
||||
// Attention!!! D2 and D4 are swapped on these boards!!!
|
||||
// If you connect the LED, it is on pin 24/PB11. In this case activate the next two lines.
|
||||
//#undef LED_BUILTIN
|
||||
//#define LED_BUILTIN 24 // PB11
|
||||
// As an alternative you can choose pin 25, it is the RX-LED pin (PB03), but active low.In this case activate the next 3 lines.
|
||||
//#undef LED_BUILTIN
|
||||
//#define LED_BUILTIN 25 // PB03
|
||||
//#define FEEDBACK_LED_IS_ACTIVE_LOW // The RX LED on the M0-Mini is active LOW
|
||||
|
||||
#elif defined (NRF51) // BBC micro:bit
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define APPLICATION_PIN 1
|
||||
#define _IR_TIMING_TEST_PIN 4
|
||||
|
||||
#define tone(...) void() // no tone() available
|
||||
#define noTone(a) void()
|
||||
#define TONE_PIN 42 // Dummy for examples using it
|
||||
|
||||
#else
|
||||
#warning Board / CPU is not detected using pre-processor symbols -> using default values, which may not fit. Please extend PinDefinitionsAndMore.h.
|
||||
// Default valued for unidentified boards
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
#endif // defined(ESP8266)
|
||||
|
||||
#if defined(ESP32) || defined(ARDUINO_ARCH_RP2040) || defined(PARTICLE) || defined(ARDUINO_ARCH_MBED)
|
||||
#define SEND_PWM_BY_TIMER // We do not have pin restrictions for this CPU's, so lets use the hardware PWM for send carrier signal generation
|
||||
#else
|
||||
# if defined(SEND_PWM_BY_TIMER)
|
||||
#undef IR_SEND_PIN // SendPin is determined by timer! This avoids warnings in IRremote.hpp and IRTimer.hpp
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if !defined (FLASHEND)
|
||||
#define FLASHEND 0xFFFF // Dummy value for platforms where FLASHEND is not defined
|
||||
#endif
|
||||
|
||||
/*
|
||||
* 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
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* IRremoteExtensionClass.cpp
|
||||
*
|
||||
* Example for a class which itself uses the IRrecv class from IRremote
|
||||
*
|
||||
* This file is part of Arduino-IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
|
||||
*
|
||||
************************************************************************************
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2021-2024 Armin Joachimsmeyer
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is furnished
|
||||
* to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
************************************************************************************
|
||||
*/
|
||||
#include <Arduino.h>
|
||||
|
||||
/*
|
||||
* !!! The value of RAW_BUFFER_LENGTH (and some other macros) must be the same in all compile units !!!
|
||||
* Otherwise you may get warnings like "type 'struct IRData' itself violates the C++ One Definition Rule"
|
||||
*/
|
||||
#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
|
||||
# elif (defined(RAMEND) && RAMEND <= 0x8FF) || (defined(RAMSIZE) && RAMSIZE < 0x8FF)
|
||||
#define RAW_BUFFER_LENGTH 750
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include "IRremoteExtensionClass.h"
|
||||
|
||||
IRExtensionClass::IRExtensionClass(IRrecv *aIrReceiver) {
|
||||
MyIrReceiver = aIrReceiver;
|
||||
}
|
||||
bool IRExtensionClass::decode() {
|
||||
return MyIrReceiver->decode();
|
||||
}
|
||||
|
||||
bool IRExtensionClass::printIRResultShort(Print *aSerial, bool aPrintRepeatGap, bool aCheckForRecordGapsMicros) {
|
||||
return MyIrReceiver->printIRResultShort(aSerial, aPrintRepeatGap, aCheckForRecordGapsMicros);
|
||||
}
|
||||
|
||||
void IRExtensionClass::resume() {
|
||||
Serial.println(F("Call resume()"));
|
||||
MyIrReceiver->resume();
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* IRremoteExtensionClass.h
|
||||
*
|
||||
* Example for a class which itself uses the IRrecv class from IRremote
|
||||
*
|
||||
* This file is part of Arduino-IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
|
||||
*
|
||||
************************************************************************************
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2021-2024 Armin Joachimsmeyer
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is furnished
|
||||
* to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
************************************************************************************
|
||||
*/
|
||||
#include <Arduino.h>
|
||||
|
||||
#define USE_IRREMOTE_HPP_AS_PLAIN_INCLUDE
|
||||
#include <IRremote.hpp>
|
||||
|
||||
class IRExtensionClass
|
||||
{
|
||||
public:
|
||||
IRrecv * MyIrReceiver;
|
||||
IRExtensionClass(IRrecv * aIrReceiver);
|
||||
bool decode();
|
||||
bool printIRResultShort(Print *aSerial, bool aPrintRepeatGap = true, bool aCheckForRecordGapsMicros = true);
|
||||
void resume();
|
||||
};
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* IRremoteExtensionTest.cpp
|
||||
* Simple test using the IRremoteExtensionClass.
|
||||
*
|
||||
* This file is part of Arduino-IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
|
||||
*
|
||||
************************************************************************************
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2022 Armin Joachimsmeyer
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is furnished
|
||||
* to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
************************************************************************************
|
||||
*/
|
||||
#include <Arduino.h>
|
||||
|
||||
#if !defined(RAW_BUFFER_LENGTH)
|
||||
#define RAW_BUFFER_LENGTH 750
|
||||
#endif
|
||||
|
||||
#include <IRremote.hpp>
|
||||
|
||||
#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 4 // 4 P1_9
|
||||
|
||||
/*
|
||||
* Create the class, which itself uses the IRrecv class from IRremote
|
||||
*/
|
||||
IRExtensionClass IRExtension(&IrReceiver);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
while (!Serial)
|
||||
; // Wait for Serial to become available. Is optimized away for some cores.
|
||||
|
||||
// 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
|
||||
IrReceiver.begin(IR_RECEIVE_PIN, ENABLE_LED_FEEDBACK);
|
||||
|
||||
Serial.print(F("Ready to receive IR signals of protocols: "));
|
||||
printActiveIRProtocols(&Serial);
|
||||
Serial.println(F("at pin " STR(IR_RECEIVE_PIN)));
|
||||
|
||||
}
|
||||
|
||||
void loop() {
|
||||
if (IRExtension.decode()) {
|
||||
IRExtension.printIRResultShort(&Serial);
|
||||
IrReceiver.printIRSendUsage(&Serial);
|
||||
IRExtension.resume(); // Use the extended function provided by IRExtension class
|
||||
}
|
||||
delay(100);
|
||||
}
|
||||
@@ -0,0 +1,349 @@
|
||||
/*
|
||||
* PinDefinitionsAndMore.h
|
||||
*
|
||||
* Contains pin definitions for IRremote examples for various platforms
|
||||
* as well as definitions for feedback LED and tone() and includes
|
||||
*
|
||||
* Copyright (C) 2021-2023 Armin Joachimsmeyer
|
||||
* armin.joachimsmeyer@gmail.com
|
||||
*
|
||||
* This file is part of IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
|
||||
*
|
||||
* Arduino-IRremote is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/gpl.html>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Pin mapping table for different platforms
|
||||
*
|
||||
* Platform IR input IR output Tone Core/Pin schema
|
||||
* --------------------------------------------------------------
|
||||
* DEFAULT/AVR 2 3 4 Arduino
|
||||
* ATtinyX5 0|PB0 4|PB4 3|PB3 ATTinyCore
|
||||
* ATtiny167 3|PA3 2|PA2 7|PA7 ATTinyCore
|
||||
* ATtiny167 9|PA3 8|PA2 5|PA7 Digispark original core
|
||||
* ATtiny84 |PB2 |PA4 |PA3 ATTinyCore
|
||||
* ATtiny88 3|PD3 4|PD4 9|PB1 ATTinyCore
|
||||
* ATtiny3217 18|PA1 19|PA2 20|PA3 MegaTinyCore
|
||||
* ATtiny1604 2 3|PA5 %
|
||||
* ATtiny816 14|PA1 16|PA3 1|PA5 MegaTinyCore
|
||||
* ATtiny1614 8|PA1 10|PA3 1|PA5 MegaTinyCore
|
||||
* SAMD21 3 4 5
|
||||
* ESP8266 14|D5 12|D6 %
|
||||
* ESP32 15 4 27
|
||||
* ESP32-C3 2 3 4
|
||||
* BluePill PA6 PA7 PA3
|
||||
* APOLLO3 11 12 5
|
||||
* RP2040 3|GPIO15 4|GPIO16 5|GPIO17
|
||||
*/
|
||||
//#define _IR_MEASURE_TIMING // For debugging purposes.
|
||||
|
||||
#if defined(__AVR__)
|
||||
#if defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__) // Digispark board. For use with ATTinyCore.
|
||||
#include "ATtinySerialOut.hpp" // TX is at pin 2 - Available as Arduino library "ATtinySerialOut". Saves 700 bytes program memory and 70 bytes RAM for ATtinyCore.
|
||||
#define IR_RECEIVE_PIN PIN_PB0
|
||||
#define IR_SEND_PIN PIN_PB4 // Pin 2 is serial output with ATtinySerialOut. Pin 1 is internal LED and Pin3 is USB+ with pullup on Digispark board.
|
||||
#define TONE_PIN PIN_PB3
|
||||
#define _IR_TIMING_TEST_PIN PIN_PB3
|
||||
|
||||
# elif defined(__AVR_ATtiny87__) || defined(__AVR_ATtiny167__) // Digispark pro board
|
||||
#include "ATtinySerialOut.hpp" // Available as Arduino library "ATtinySerialOut"
|
||||
// For ATtiny167 Pins PB6 and PA3 are usable as interrupt source.
|
||||
# if defined(ARDUINO_AVR_DIGISPARKPRO)
|
||||
// For use with Digispark original core
|
||||
#define IR_RECEIVE_PIN 9 // PA3 - on Digispark board labeled as pin 9
|
||||
//#define IR_RECEIVE_PIN 14 // PB6 / INT0 is connected to USB+ on DigisparkPro boards
|
||||
#define IR_SEND_PIN 8 // PA2 - on Digispark board labeled as pin 8
|
||||
#define TONE_PIN 5 // PA7 - on Digispark board labeled as pin 5
|
||||
#define _IR_TIMING_TEST_PIN 10 // PA4
|
||||
# else
|
||||
// For use with ATTinyCore
|
||||
#define IR_RECEIVE_PIN PIN_PA3 // On Digispark board labeled as pin 9 - INT0 is connected to USB+ on DigisparkPro boards
|
||||
#define IR_SEND_PIN PIN_PA2 // On Digispark board labeled as pin 8
|
||||
#define TONE_PIN PIN_PA7 // On Digispark board labeled as pin 5
|
||||
# endif
|
||||
|
||||
# elif defined(__AVR_ATtiny84__) // For use with ATTinyCore
|
||||
#include "ATtinySerialOut.hpp" // Available as Arduino library "ATtinySerialOut". Saves 128 bytes program memory.
|
||||
#define IR_RECEIVE_PIN PIN_PB2 // INT0
|
||||
#define IR_SEND_PIN PIN_PA4
|
||||
#define TONE_PIN PIN_PA3
|
||||
#define _IR_TIMING_TEST_PIN PIN_PA5
|
||||
|
||||
# elif defined(__AVR_ATtiny88__) // MH-ET Tiny88 board. For use with ATTinyCore.
|
||||
#include "ATtinySerialOut.hpp" // Available as Arduino library "ATtinySerialOut". Saves 128 bytes program memory.
|
||||
// Pin 6 is TX, pin 7 is RX
|
||||
#define IR_RECEIVE_PIN PIN_PD3 // 3 - INT1
|
||||
#define IR_SEND_PIN PIN_PD4 // 4
|
||||
#define TONE_PIN PIN_PB1 // 9
|
||||
#define _IR_TIMING_TEST_PIN PIN_PB0 // 8
|
||||
|
||||
# elif defined(__AVR_ATtiny1616__) || defined(__AVR_ATtiny3216__) || defined(__AVR_ATtiny3217__) // For use with megaTinyCore
|
||||
// Tiny Core Dev board
|
||||
// https://www.tindie.com/products/xkimi/tiny-core-16-dev-board-attiny1616/ - Out of Stock
|
||||
// https://www.tindie.com/products/xkimi/tiny-core-32-dev-board-attiny3217/ - Out of Stock
|
||||
#define IR_RECEIVE_PIN PIN_PA1 // use 18 instead of PIN_PA1 for TinyCore32
|
||||
#define IR_SEND_PIN PIN_PA2 // 19
|
||||
#define TONE_PIN PIN_PA3 // 20
|
||||
#define APPLICATION_PIN PIN_PA0 // 0
|
||||
#undef LED_BUILTIN // No LED available on the TinyCore 32 board, take the one on the programming board which is connected to the DAC output
|
||||
#define LED_BUILTIN PIN_PA6 // use 2 instead of PIN_PA6 for TinyCore32
|
||||
|
||||
# elif defined(__AVR_ATtiny816__) // For use with megaTinyCore
|
||||
#define IR_RECEIVE_PIN PIN_PA1 // 14
|
||||
#define IR_SEND_PIN PIN_PA1 // 16
|
||||
#define TONE_PIN PIN_PA5 // 1
|
||||
#define APPLICATION_PIN PIN_PA4 // 0
|
||||
#undef LED_BUILTIN // No LED available, take the one which is connected to the DAC output
|
||||
#define LED_BUILTIN PIN_PB5 // 4
|
||||
|
||||
# elif defined(__AVR_ATtiny1614__) // For use with megaTinyCore
|
||||
#define IR_RECEIVE_PIN PIN_PA1 // 8
|
||||
#define IR_SEND_PIN PIN_PA3 // 10
|
||||
#define TONE_PIN PIN_PA5 // 1
|
||||
#define APPLICATION_PIN PIN_PA4 // 0
|
||||
|
||||
# elif defined(__AVR_ATtiny1604__) // For use with megaTinyCore
|
||||
#define IR_RECEIVE_PIN PIN_PA6 // 2 - To be compatible with interrupt example, pin 2 is chosen here.
|
||||
#define IR_SEND_PIN PIN_PA7 // 3
|
||||
#define APPLICATION_PIN PIN_PB2 // 5
|
||||
|
||||
#define tone(...) void() // Define as void, since TCB0_INT_vect is also used by tone()
|
||||
#define noTone(a) void()
|
||||
#define TONE_PIN 42 // Dummy for examples using it
|
||||
|
||||
# elif defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) \
|
||||
|| defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) \
|
||||
|| defined(__AVR_ATmega324P__) || defined(__AVR_ATmega324A__) \
|
||||
|| defined(__AVR_ATmega324PA__) || defined(__AVR_ATmega164A__) \
|
||||
|| defined(__AVR_ATmega164P__) || defined(__AVR_ATmega32__) \
|
||||
|| defined(__AVR_ATmega16__) || defined(__AVR_ATmega8535__) \
|
||||
|| defined(__AVR_ATmega64__) || defined(__AVR_ATmega128__) \
|
||||
|| defined(__AVR_ATmega1281__) || defined(__AVR_ATmega2561__) \
|
||||
|| defined(__AVR_ATmega8515__) || defined(__AVR_ATmega162__)
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 13
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
# else // Default as for ATmega328 like on Uno, Nano, Leonardo, Teensy 2.0 etc.
|
||||
#define IR_RECEIVE_PIN 2 // To be compatible with interrupt example, pin 2 is chosen here.
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
# if defined(ARDUINO_AVR_PROMICRO) // Sparkfun Pro Micro is __AVR_ATmega32U4__ but has different external circuit
|
||||
// We have no built in LED at pin 13 -> reuse RX LED
|
||||
#undef LED_BUILTIN
|
||||
#define LED_BUILTIN LED_BUILTIN_RX
|
||||
# endif
|
||||
# endif // defined(__AVR_ATtiny25__)...
|
||||
|
||||
#elif defined(ARDUINO_ARCH_RENESAS_UNO) // Uno R4
|
||||
// To be compatible with Uno R3.
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
#elif defined(ESP8266)
|
||||
#define FEEDBACK_LED_IS_ACTIVE_LOW // The LED on my board (D4) is active LOW
|
||||
#define IR_RECEIVE_PIN 14 // D5
|
||||
#define IR_SEND_PIN 12 // D6 - D4/pin 2 is internal LED
|
||||
#define _IR_TIMING_TEST_PIN 2 // D4
|
||||
#define APPLICATION_PIN 13 // D7
|
||||
|
||||
#define tone(...) void() // tone() inhibits receive timer
|
||||
#define noTone(a) void()
|
||||
#define TONE_PIN 42 // Dummy for examples using it#
|
||||
|
||||
#elif defined(ARDUINO_NOLOGO_ESP32C3_SUPER_MINI)
|
||||
#define FEEDBACK_LED_IS_ACTIVE_LOW // The LED on my board (D8) is active LOW
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 10
|
||||
|
||||
#elif defined(CONFIG_IDF_TARGET_ESP32C3) || defined(ARDUINO_ESP32C3_DEV)
|
||||
#define NO_LED_FEEDBACK_CODE // The WS2812 on pin 8 of AI-C3 board crashes if used as receive feedback LED, other I/O pins are working...
|
||||
#define IR_RECEIVE_PIN 6
|
||||
#define IR_SEND_PIN 7
|
||||
#define TONE_PIN 10
|
||||
#define APPLICATION_PIN 18
|
||||
|
||||
#elif defined(ESP32)
|
||||
#include <Arduino.h>
|
||||
|
||||
// tone() is included in ESP32 core since 2.0.2
|
||||
#if !defined(ESP_ARDUINO_VERSION_VAL)
|
||||
#define ESP_ARDUINO_VERSION_VAL(major, minor, patch) 12345678
|
||||
#endif
|
||||
#if ESP_ARDUINO_VERSION <= ESP_ARDUINO_VERSION_VAL(2, 0, 2)
|
||||
#define TONE_LEDC_CHANNEL 1 // Using channel 1 makes tone() independent of receiving timer -> No need to stop receiving timer.
|
||||
void tone(uint8_t aPinNumber, unsigned int aFrequency){
|
||||
ledcAttachPin(aPinNumber, TONE_LEDC_CHANNEL);
|
||||
ledcWriteTone(TONE_LEDC_CHANNEL, aFrequency);
|
||||
}
|
||||
void tone(uint8_t aPinNumber, unsigned int aFrequency, unsigned long aDuration){
|
||||
ledcAttachPin(aPinNumber, TONE_LEDC_CHANNEL);
|
||||
ledcWriteTone(TONE_LEDC_CHANNEL, aFrequency);
|
||||
delay(aDuration);
|
||||
ledcWriteTone(TONE_LEDC_CHANNEL, 0);
|
||||
}
|
||||
void noTone(uint8_t aPinNumber){
|
||||
ledcWriteTone(TONE_LEDC_CHANNEL, 0);
|
||||
}
|
||||
#endif // ESP_ARDUINO_VERSION <= ESP_ARDUINO_VERSION_VAL(2, 0, 2)
|
||||
|
||||
#define IR_RECEIVE_PIN 15 // D15
|
||||
#define IR_SEND_PIN 4 // D4
|
||||
#define TONE_PIN 27 // D27 25 & 26 are DAC0 and 1
|
||||
#define APPLICATION_PIN 16 // RX2 pin
|
||||
|
||||
#elif defined(ARDUINO_ARCH_STM32) || defined(ARDUINO_ARCH_STM32F1) // BluePill
|
||||
// Timer 3 blocks PA6, PA7, PB0, PB1 for use by Servo or tone()
|
||||
#define IR_RECEIVE_PIN PA6
|
||||
#define IR_RECEIVE_PIN_STRING "PA6"
|
||||
#define IR_SEND_PIN PA7
|
||||
#define IR_SEND_PIN_STRING "PA7"
|
||||
#define TONE_PIN PA3
|
||||
#define _IR_TIMING_TEST_PIN PA5
|
||||
#define APPLICATION_PIN PA2
|
||||
#define APPLICATION_PIN_STRING "PA2"
|
||||
# if defined(ARDUINO_GENERIC_STM32F103C) || defined(ARDUINO_BLUEPILL_F103C8)
|
||||
// BluePill LED is active low
|
||||
#define FEEDBACK_LED_IS_ACTIVE_LOW
|
||||
# endif
|
||||
|
||||
#elif defined(ARDUINO_ARCH_APOLLO3) // Sparkfun Apollo boards
|
||||
#define IR_RECEIVE_PIN 11
|
||||
#define IR_SEND_PIN 12
|
||||
#define TONE_PIN 5
|
||||
|
||||
#elif defined(ARDUINO_ARCH_MBED) && defined(ARDUINO_ARCH_MBED_NANO) // Arduino Nano 33 BLE and Arduino Nano Connect layout for MBED
|
||||
// Must be before ARDUINO_ARCH_RP2040, since it is the layout for the MBED core of Arduino Nano Connect
|
||||
#define IR_RECEIVE_PIN 3 // GPIO15 Start with pin 3 since pin 2|GPIO25 is connected to LED on Pi pico
|
||||
#define IR_SEND_PIN 4 // GPIO16
|
||||
#define TONE_PIN 5
|
||||
#define APPLICATION_PIN 6
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 7 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 8
|
||||
|
||||
#elif defined(ARDUINO_ARCH_RP2040) // Arduino Nano Connect, Pi Pico with arduino-pico core https://github.com/earlephilhower/arduino-pico
|
||||
#define IR_RECEIVE_PIN 15 // GPIO15 to be compatible with the Arduino Nano RP2040 Connect (pin3)
|
||||
#define IR_SEND_PIN 16 // GPIO16
|
||||
#define TONE_PIN 17
|
||||
#define APPLICATION_PIN 18
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 19 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 20
|
||||
|
||||
// If you program the Nano RP2040 Connect with this core, then you must redefine LED_BUILTIN
|
||||
// and use the external reset with 1 kOhm to ground to enter UF2 mode
|
||||
#undef LED_BUILTIN
|
||||
#define LED_BUILTIN 6
|
||||
|
||||
#elif defined(PARTICLE) // !!!UNTESTED!!!
|
||||
#define IR_RECEIVE_PIN A4
|
||||
#define IR_SEND_PIN A5 // Particle supports multiple pins
|
||||
|
||||
#define LED_BUILTIN D7
|
||||
|
||||
/*
|
||||
* 4 times the same (default) layout for easy adaption in the future
|
||||
*/
|
||||
#elif defined(TEENSYDUINO) // Teensy 2.0 is handled at default for ATmega328 like on Uno, Nano, Leonardo etc.
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
#elif defined(ARDUINO_ARCH_MBED) // Arduino Nano 33 BLE
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
#elif defined(ARDUINO_ARCH_SAMD) || defined(ARDUINO_ARCH_SAM)
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
#if !defined(ARDUINO_SAMD_ADAFRUIT) && !defined(ARDUINO_SEEED_XIAO_M0)
|
||||
// On the Zero and others we switch explicitly to SerialUSB
|
||||
#define Serial SerialUSB
|
||||
#endif
|
||||
|
||||
// Definitions for the Chinese SAMD21 M0-Mini clone, which has no led connected to D13/PA17.
|
||||
// Attention!!! D2 and D4 are swapped on these boards!!!
|
||||
// If you connect the LED, it is on pin 24/PB11. In this case activate the next two lines.
|
||||
//#undef LED_BUILTIN
|
||||
//#define LED_BUILTIN 24 // PB11
|
||||
// As an alternative you can choose pin 25, it is the RX-LED pin (PB03), but active low.In this case activate the next 3 lines.
|
||||
//#undef LED_BUILTIN
|
||||
//#define LED_BUILTIN 25 // PB03
|
||||
//#define FEEDBACK_LED_IS_ACTIVE_LOW // The RX LED on the M0-Mini is active LOW
|
||||
|
||||
#elif defined (NRF51) // BBC micro:bit
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define APPLICATION_PIN 1
|
||||
#define _IR_TIMING_TEST_PIN 4
|
||||
|
||||
#define tone(...) void() // no tone() available
|
||||
#define noTone(a) void()
|
||||
#define TONE_PIN 42 // Dummy for examples using it
|
||||
|
||||
#else
|
||||
#warning Board / CPU is not detected using pre-processor symbols -> using default values, which may not fit. Please extend PinDefinitionsAndMore.h.
|
||||
// Default valued for unidentified boards
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
#endif // defined(ESP8266)
|
||||
|
||||
#if defined(ESP32) || defined(ARDUINO_ARCH_RP2040) || defined(PARTICLE) || defined(ARDUINO_ARCH_MBED)
|
||||
#define SEND_PWM_BY_TIMER // We do not have pin restrictions for this CPU's, so lets use the hardware PWM for send carrier signal generation
|
||||
#else
|
||||
# if defined(SEND_PWM_BY_TIMER)
|
||||
#undef IR_SEND_PIN // SendPin is determined by timer! This avoids warnings in IRremote.hpp and IRTimer.hpp
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if !defined (FLASHEND)
|
||||
#define FLASHEND 0xFFFF // Dummy value for platforms where FLASHEND is not defined
|
||||
#endif
|
||||
|
||||
/*
|
||||
* 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
|
||||
@@ -0,0 +1,244 @@
|
||||
/*
|
||||
* IRremote: IRremoteInfo - prints relevant config info & settings for IRremote over serial
|
||||
* Intended to help identify & troubleshoot the various settings of IRremote
|
||||
* For example, sometimes users are unsure of which pin is used for Tx or the RAW_BUFFER_LENGTH value
|
||||
* This example can be used to assist the user directly or with support.
|
||||
* Intended to help identify & troubleshoot the various settings of IRremote
|
||||
* Hopefully this utility will be a useful tool for support & troubleshooting for IRremote
|
||||
* Check out the blog post describing the sketch via http://www.analysir.com/blog/2015/11/28/helper-utility-for-troubleshooting-irremote/
|
||||
* Version 1.0 November 2015
|
||||
* Original Author: AnalysIR - IR software & modules for Makers & Pros, visit http://www.AnalysIR.com
|
||||
*/
|
||||
#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
|
||||
|
||||
#include <IRremote.hpp>
|
||||
|
||||
// Function declarations for non Arduino IDE's
|
||||
void dumpHeader();
|
||||
void dumpRAW_BUFFER_LENGTH();
|
||||
void dumpTIMER();
|
||||
void dumpTimerPin();
|
||||
void dumpClock();
|
||||
void dumpPlatform();
|
||||
void dumpPulseParams();
|
||||
void dumpSignalParams();
|
||||
void dumpArduinoIDE();
|
||||
void dumpDebugMode();
|
||||
void dumpProtocols();
|
||||
void dumpFooter();
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
while (!Serial)
|
||||
; // Wait for Serial to become available. Is optimized away for some cores.
|
||||
|
||||
// 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();
|
||||
dumpClock();
|
||||
dumpPlatform();
|
||||
dumpPulseParams();
|
||||
dumpSignalParams();
|
||||
dumpDebugMode();
|
||||
dumpProtocols();
|
||||
dumpFooter();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
//nothing to do!
|
||||
}
|
||||
|
||||
void dumpRAW_BUFFER_LENGTH() {
|
||||
Serial.print(F("RAW_BUFFER_LENGTH: "));
|
||||
Serial.println(RAW_BUFFER_LENGTH);
|
||||
}
|
||||
|
||||
|
||||
void dumpClock() {
|
||||
#if defined(F_CPU)
|
||||
Serial.print(F("MCU Clock: "));
|
||||
Serial.println(F_CPU);
|
||||
#endif
|
||||
}
|
||||
|
||||
void dumpPlatform() {
|
||||
Serial.print(F("MCU Platform: "));
|
||||
|
||||
#if defined(MIK32V2)
|
||||
Serial.println(F("MIK32 Amur"));
|
||||
#endif
|
||||
}
|
||||
|
||||
void dumpPulseParams() {
|
||||
Serial.print(F("Mark Excess: "));
|
||||
Serial.print(MARK_EXCESS_MICROS);
|
||||
;
|
||||
Serial.println(F(" uSecs"));
|
||||
Serial.print(F("Microseconds per tick: "));
|
||||
Serial.print(MICROS_PER_TICK);
|
||||
;
|
||||
Serial.println(F(" uSecs"));
|
||||
Serial.print(F("Measurement tolerance: "));
|
||||
Serial.print(TOLERANCE_FOR_DECODERS_MARK_OR_SPACE_MATCHING_PERCENT);
|
||||
Serial.println(F("%"));
|
||||
}
|
||||
|
||||
void dumpSignalParams() {
|
||||
Serial.print(F("Minimum Gap between IR Signals: "));
|
||||
Serial.print(RECORD_GAP_MICROS);
|
||||
Serial.println(F(" uSecs"));
|
||||
}
|
||||
|
||||
void dumpDebugMode() {
|
||||
Serial.print(F("Debug Mode: "));
|
||||
#if DEBUG
|
||||
Serial.println(F("ON"));
|
||||
#else
|
||||
Serial.println(F("OFF (Normal)"));
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void dumpProtocols() {
|
||||
|
||||
Serial.println();
|
||||
Serial.print(F("IR PROTOCOLS "));
|
||||
Serial.print(F("SEND "));
|
||||
Serial.println(F("DECODE"));
|
||||
Serial.print(F("============= "));
|
||||
Serial.print(F("======== "));
|
||||
Serial.println(F("========"));
|
||||
Serial.print(F("RC5: "));
|
||||
#if defined(DECODE_RC5)
|
||||
Serial.println(F("Enabled"));
|
||||
#else
|
||||
Serial.println(F("Disabled"));
|
||||
#endif
|
||||
|
||||
Serial.print(F("RC6: "));
|
||||
#if defined(DECODE_RC6)
|
||||
Serial.println(F("Enabled"));
|
||||
#else
|
||||
Serial.println(F("Disabled"));
|
||||
#endif
|
||||
|
||||
Serial.print(F("NEC: "));
|
||||
#if defined(DECODE_NEC)
|
||||
Serial.println(F("Enabled"));
|
||||
#else
|
||||
Serial.println(F("Disabled"));
|
||||
#endif
|
||||
|
||||
Serial.print(F("SONY: "));
|
||||
#if defined(DECODE_SONY)
|
||||
Serial.println(F("Enabled"));
|
||||
#else
|
||||
Serial.println(F("Disabled"));
|
||||
#endif
|
||||
|
||||
Serial.print(F("PANASONIC: "));
|
||||
#if defined(DECODE_PANASONIC)
|
||||
Serial.println(F("Enabled"));
|
||||
#else
|
||||
Serial.println(F("Disabled"));
|
||||
#endif
|
||||
|
||||
Serial.print(F("JVC: "));
|
||||
#if defined(DECODE_JVC)
|
||||
Serial.println(F("Enabled"));
|
||||
#else
|
||||
Serial.println(F("Disabled"));
|
||||
#endif
|
||||
|
||||
Serial.print(F("SAMSUNG: "));
|
||||
#if defined(DECODE_SAMSUNG)
|
||||
Serial.println(F("Enabled"));
|
||||
#else
|
||||
Serial.println(F("Disabled"));
|
||||
#endif
|
||||
|
||||
Serial.print(F("LG: "));
|
||||
#if defined(DECODE_LG)
|
||||
Serial.println(F("Enabled"));
|
||||
#else
|
||||
Serial.println(F("Disabled"));
|
||||
#endif
|
||||
|
||||
Serial.print(F("DENON: "));
|
||||
#if defined(DECODE_DENON)
|
||||
Serial.println(F("Enabled"));
|
||||
#else
|
||||
Serial.println(F("Disabled"));
|
||||
#endif
|
||||
|
||||
#if !defined(EXCLUDE_EXOTIC_PROTOCOLS) // saves around 2000 bytes program memory
|
||||
|
||||
Serial.print(F("BANG_OLUFSEN: "));
|
||||
#if defined(DECODE_BEO)
|
||||
Serial.println(F("Enabled"));
|
||||
#else
|
||||
Serial.println(F("Disabled"));
|
||||
#endif
|
||||
|
||||
Serial.print(F("BOSEWAVE: "));
|
||||
#if defined(DECODE_BOSEWAVE)
|
||||
Serial.println(F("Enabled"));
|
||||
#else
|
||||
Serial.println(F("Disabled"));
|
||||
#endif
|
||||
|
||||
Serial.print(F("WHYNTER: "));
|
||||
#if defined(DECODE_WHYNTER)
|
||||
Serial.println(F("Enabled"));
|
||||
#else
|
||||
Serial.println(F("Disabled"));
|
||||
#endif
|
||||
|
||||
Serial.print(F("FAST: "));
|
||||
#if defined(DECODE_FAST)
|
||||
Serial.println(F("Enabled"));
|
||||
#else
|
||||
Serial.println(F("Disabled"));
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void printDecodeEnabled(int flag) {
|
||||
if (flag) {
|
||||
Serial.println(F("Enabled"));
|
||||
} else {
|
||||
Serial.println(F("Disabled"));
|
||||
}
|
||||
}
|
||||
|
||||
void dumpHeader() {
|
||||
Serial.println(F("IRremoteInfo - by AnalysIR (http://www.AnalysIR.com/)"));
|
||||
Serial.println(
|
||||
F(
|
||||
"- A helper sketch to assist in troubleshooting issues with the library by reviewing the settings within the IRremote library"));
|
||||
Serial.println(
|
||||
F(
|
||||
"- Prints out the important settings within the library, which can be configured to suit the many supported platforms"));
|
||||
Serial.println(F("- When seeking on-line support, please post or upload the output of this sketch, where appropriate"));
|
||||
Serial.println();
|
||||
Serial.println(F("IRremote Library Settings"));
|
||||
Serial.println(F("========================="));
|
||||
}
|
||||
|
||||
void dumpFooter() {
|
||||
Serial.println();
|
||||
Serial.println(F("Notes: "));
|
||||
Serial.println(F("- Most of the settings above can be configured in the following files included as part of the library"));
|
||||
Serial.println(F("- IRremoteInt.h"));
|
||||
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)"));
|
||||
}
|
||||
@@ -0,0 +1,349 @@
|
||||
/*
|
||||
* PinDefinitionsAndMore.h
|
||||
*
|
||||
* Contains pin definitions for IRremote examples for various platforms
|
||||
* as well as definitions for feedback LED and tone() and includes
|
||||
*
|
||||
* Copyright (C) 2021-2023 Armin Joachimsmeyer
|
||||
* armin.joachimsmeyer@gmail.com
|
||||
*
|
||||
* This file is part of IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
|
||||
*
|
||||
* Arduino-IRremote is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/gpl.html>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Pin mapping table for different platforms
|
||||
*
|
||||
* Platform IR input IR output Tone Core/Pin schema
|
||||
* --------------------------------------------------------------
|
||||
* DEFAULT/AVR 2 3 4 Arduino
|
||||
* ATtinyX5 0|PB0 4|PB4 3|PB3 ATTinyCore
|
||||
* ATtiny167 3|PA3 2|PA2 7|PA7 ATTinyCore
|
||||
* ATtiny167 9|PA3 8|PA2 5|PA7 Digispark original core
|
||||
* ATtiny84 |PB2 |PA4 |PA3 ATTinyCore
|
||||
* ATtiny88 3|PD3 4|PD4 9|PB1 ATTinyCore
|
||||
* ATtiny3217 18|PA1 19|PA2 20|PA3 MegaTinyCore
|
||||
* ATtiny1604 2 3|PA5 %
|
||||
* ATtiny816 14|PA1 16|PA3 1|PA5 MegaTinyCore
|
||||
* ATtiny1614 8|PA1 10|PA3 1|PA5 MegaTinyCore
|
||||
* SAMD21 3 4 5
|
||||
* ESP8266 14|D5 12|D6 %
|
||||
* ESP32 15 4 27
|
||||
* ESP32-C3 2 3 4
|
||||
* BluePill PA6 PA7 PA3
|
||||
* APOLLO3 11 12 5
|
||||
* RP2040 3|GPIO15 4|GPIO16 5|GPIO17
|
||||
*/
|
||||
//#define _IR_MEASURE_TIMING // For debugging purposes.
|
||||
|
||||
#if defined(__AVR__)
|
||||
#if defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__) // Digispark board. For use with ATTinyCore.
|
||||
#include "ATtinySerialOut.hpp" // TX is at pin 2 - Available as Arduino library "ATtinySerialOut". Saves 700 bytes program memory and 70 bytes RAM for ATtinyCore.
|
||||
#define IR_RECEIVE_PIN PIN_PB0
|
||||
#define IR_SEND_PIN PIN_PB4 // Pin 2 is serial output with ATtinySerialOut. Pin 1 is internal LED and Pin3 is USB+ with pullup on Digispark board.
|
||||
#define TONE_PIN PIN_PB3
|
||||
#define _IR_TIMING_TEST_PIN PIN_PB3
|
||||
|
||||
# elif defined(__AVR_ATtiny87__) || defined(__AVR_ATtiny167__) // Digispark pro board
|
||||
#include "ATtinySerialOut.hpp" // Available as Arduino library "ATtinySerialOut"
|
||||
// For ATtiny167 Pins PB6 and PA3 are usable as interrupt source.
|
||||
# if defined(ARDUINO_AVR_DIGISPARKPRO)
|
||||
// For use with Digispark original core
|
||||
#define IR_RECEIVE_PIN 9 // PA3 - on Digispark board labeled as pin 9
|
||||
//#define IR_RECEIVE_PIN 14 // PB6 / INT0 is connected to USB+ on DigisparkPro boards
|
||||
#define IR_SEND_PIN 8 // PA2 - on Digispark board labeled as pin 8
|
||||
#define TONE_PIN 5 // PA7 - on Digispark board labeled as pin 5
|
||||
#define _IR_TIMING_TEST_PIN 10 // PA4
|
||||
# else
|
||||
// For use with ATTinyCore
|
||||
#define IR_RECEIVE_PIN PIN_PA3 // On Digispark board labeled as pin 9 - INT0 is connected to USB+ on DigisparkPro boards
|
||||
#define IR_SEND_PIN PIN_PA2 // On Digispark board labeled as pin 8
|
||||
#define TONE_PIN PIN_PA7 // On Digispark board labeled as pin 5
|
||||
# endif
|
||||
|
||||
# elif defined(__AVR_ATtiny84__) // For use with ATTinyCore
|
||||
#include "ATtinySerialOut.hpp" // Available as Arduino library "ATtinySerialOut". Saves 128 bytes program memory.
|
||||
#define IR_RECEIVE_PIN PIN_PB2 // INT0
|
||||
#define IR_SEND_PIN PIN_PA4
|
||||
#define TONE_PIN PIN_PA3
|
||||
#define _IR_TIMING_TEST_PIN PIN_PA5
|
||||
|
||||
# elif defined(__AVR_ATtiny88__) // MH-ET Tiny88 board. For use with ATTinyCore.
|
||||
#include "ATtinySerialOut.hpp" // Available as Arduino library "ATtinySerialOut". Saves 128 bytes program memory.
|
||||
// Pin 6 is TX, pin 7 is RX
|
||||
#define IR_RECEIVE_PIN PIN_PD3 // 3 - INT1
|
||||
#define IR_SEND_PIN PIN_PD4 // 4
|
||||
#define TONE_PIN PIN_PB1 // 9
|
||||
#define _IR_TIMING_TEST_PIN PIN_PB0 // 8
|
||||
|
||||
# elif defined(__AVR_ATtiny1616__) || defined(__AVR_ATtiny3216__) || defined(__AVR_ATtiny3217__) // For use with megaTinyCore
|
||||
// Tiny Core Dev board
|
||||
// https://www.tindie.com/products/xkimi/tiny-core-16-dev-board-attiny1616/ - Out of Stock
|
||||
// https://www.tindie.com/products/xkimi/tiny-core-32-dev-board-attiny3217/ - Out of Stock
|
||||
#define IR_RECEIVE_PIN PIN_PA1 // use 18 instead of PIN_PA1 for TinyCore32
|
||||
#define IR_SEND_PIN PIN_PA2 // 19
|
||||
#define TONE_PIN PIN_PA3 // 20
|
||||
#define APPLICATION_PIN PIN_PA0 // 0
|
||||
#undef LED_BUILTIN // No LED available on the TinyCore 32 board, take the one on the programming board which is connected to the DAC output
|
||||
#define LED_BUILTIN PIN_PA6 // use 2 instead of PIN_PA6 for TinyCore32
|
||||
|
||||
# elif defined(__AVR_ATtiny816__) // For use with megaTinyCore
|
||||
#define IR_RECEIVE_PIN PIN_PA1 // 14
|
||||
#define IR_SEND_PIN PIN_PA1 // 16
|
||||
#define TONE_PIN PIN_PA5 // 1
|
||||
#define APPLICATION_PIN PIN_PA4 // 0
|
||||
#undef LED_BUILTIN // No LED available, take the one which is connected to the DAC output
|
||||
#define LED_BUILTIN PIN_PB5 // 4
|
||||
|
||||
# elif defined(__AVR_ATtiny1614__) // For use with megaTinyCore
|
||||
#define IR_RECEIVE_PIN PIN_PA1 // 8
|
||||
#define IR_SEND_PIN PIN_PA3 // 10
|
||||
#define TONE_PIN PIN_PA5 // 1
|
||||
#define APPLICATION_PIN PIN_PA4 // 0
|
||||
|
||||
# elif defined(__AVR_ATtiny1604__) // For use with megaTinyCore
|
||||
#define IR_RECEIVE_PIN PIN_PA6 // 2 - To be compatible with interrupt example, pin 2 is chosen here.
|
||||
#define IR_SEND_PIN PIN_PA7 // 3
|
||||
#define APPLICATION_PIN PIN_PB2 // 5
|
||||
|
||||
#define tone(...) void() // Define as void, since TCB0_INT_vect is also used by tone()
|
||||
#define noTone(a) void()
|
||||
#define TONE_PIN 42 // Dummy for examples using it
|
||||
|
||||
# elif defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) \
|
||||
|| defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) \
|
||||
|| defined(__AVR_ATmega324P__) || defined(__AVR_ATmega324A__) \
|
||||
|| defined(__AVR_ATmega324PA__) || defined(__AVR_ATmega164A__) \
|
||||
|| defined(__AVR_ATmega164P__) || defined(__AVR_ATmega32__) \
|
||||
|| defined(__AVR_ATmega16__) || defined(__AVR_ATmega8535__) \
|
||||
|| defined(__AVR_ATmega64__) || defined(__AVR_ATmega128__) \
|
||||
|| defined(__AVR_ATmega1281__) || defined(__AVR_ATmega2561__) \
|
||||
|| defined(__AVR_ATmega8515__) || defined(__AVR_ATmega162__)
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 13
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
# else // Default as for ATmega328 like on Uno, Nano, Leonardo, Teensy 2.0 etc.
|
||||
#define IR_RECEIVE_PIN 2 // To be compatible with interrupt example, pin 2 is chosen here.
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
# if defined(ARDUINO_AVR_PROMICRO) // Sparkfun Pro Micro is __AVR_ATmega32U4__ but has different external circuit
|
||||
// We have no built in LED at pin 13 -> reuse RX LED
|
||||
#undef LED_BUILTIN
|
||||
#define LED_BUILTIN LED_BUILTIN_RX
|
||||
# endif
|
||||
# endif // defined(__AVR_ATtiny25__)...
|
||||
|
||||
#elif defined(ARDUINO_ARCH_RENESAS_UNO) // Uno R4
|
||||
// To be compatible with Uno R3.
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
#elif defined(ESP8266)
|
||||
#define FEEDBACK_LED_IS_ACTIVE_LOW // The LED on my board (D4) is active LOW
|
||||
#define IR_RECEIVE_PIN 14 // D5
|
||||
#define IR_SEND_PIN 12 // D6 - D4/pin 2 is internal LED
|
||||
#define _IR_TIMING_TEST_PIN 2 // D4
|
||||
#define APPLICATION_PIN 13 // D7
|
||||
|
||||
#define tone(...) void() // tone() inhibits receive timer
|
||||
#define noTone(a) void()
|
||||
#define TONE_PIN 42 // Dummy for examples using it#
|
||||
|
||||
#elif defined(ARDUINO_NOLOGO_ESP32C3_SUPER_MINI)
|
||||
#define FEEDBACK_LED_IS_ACTIVE_LOW // The LED on my board (D8) is active LOW
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 10
|
||||
|
||||
#elif defined(CONFIG_IDF_TARGET_ESP32C3) || defined(ARDUINO_ESP32C3_DEV)
|
||||
#define NO_LED_FEEDBACK_CODE // The WS2812 on pin 8 of AI-C3 board crashes if used as receive feedback LED, other I/O pins are working...
|
||||
#define IR_RECEIVE_PIN 6
|
||||
#define IR_SEND_PIN 7
|
||||
#define TONE_PIN 10
|
||||
#define APPLICATION_PIN 18
|
||||
|
||||
#elif defined(ESP32)
|
||||
#include <Arduino.h>
|
||||
|
||||
// tone() is included in ESP32 core since 2.0.2
|
||||
#if !defined(ESP_ARDUINO_VERSION_VAL)
|
||||
#define ESP_ARDUINO_VERSION_VAL(major, minor, patch) 12345678
|
||||
#endif
|
||||
#if ESP_ARDUINO_VERSION <= ESP_ARDUINO_VERSION_VAL(2, 0, 2)
|
||||
#define TONE_LEDC_CHANNEL 1 // Using channel 1 makes tone() independent of receiving timer -> No need to stop receiving timer.
|
||||
void tone(uint8_t aPinNumber, unsigned int aFrequency){
|
||||
ledcAttachPin(aPinNumber, TONE_LEDC_CHANNEL);
|
||||
ledcWriteTone(TONE_LEDC_CHANNEL, aFrequency);
|
||||
}
|
||||
void tone(uint8_t aPinNumber, unsigned int aFrequency, unsigned long aDuration){
|
||||
ledcAttachPin(aPinNumber, TONE_LEDC_CHANNEL);
|
||||
ledcWriteTone(TONE_LEDC_CHANNEL, aFrequency);
|
||||
delay(aDuration);
|
||||
ledcWriteTone(TONE_LEDC_CHANNEL, 0);
|
||||
}
|
||||
void noTone(uint8_t aPinNumber){
|
||||
ledcWriteTone(TONE_LEDC_CHANNEL, 0);
|
||||
}
|
||||
#endif // ESP_ARDUINO_VERSION <= ESP_ARDUINO_VERSION_VAL(2, 0, 2)
|
||||
|
||||
#define IR_RECEIVE_PIN 15 // D15
|
||||
#define IR_SEND_PIN 4 // D4
|
||||
#define TONE_PIN 27 // D27 25 & 26 are DAC0 and 1
|
||||
#define APPLICATION_PIN 16 // RX2 pin
|
||||
|
||||
#elif defined(ARDUINO_ARCH_STM32) || defined(ARDUINO_ARCH_STM32F1) // BluePill
|
||||
// Timer 3 blocks PA6, PA7, PB0, PB1 for use by Servo or tone()
|
||||
#define IR_RECEIVE_PIN PA6
|
||||
#define IR_RECEIVE_PIN_STRING "PA6"
|
||||
#define IR_SEND_PIN PA7
|
||||
#define IR_SEND_PIN_STRING "PA7"
|
||||
#define TONE_PIN PA3
|
||||
#define _IR_TIMING_TEST_PIN PA5
|
||||
#define APPLICATION_PIN PA2
|
||||
#define APPLICATION_PIN_STRING "PA2"
|
||||
# if defined(ARDUINO_GENERIC_STM32F103C) || defined(ARDUINO_BLUEPILL_F103C8)
|
||||
// BluePill LED is active low
|
||||
#define FEEDBACK_LED_IS_ACTIVE_LOW
|
||||
# endif
|
||||
|
||||
#elif defined(ARDUINO_ARCH_APOLLO3) // Sparkfun Apollo boards
|
||||
#define IR_RECEIVE_PIN 11
|
||||
#define IR_SEND_PIN 12
|
||||
#define TONE_PIN 5
|
||||
|
||||
#elif defined(ARDUINO_ARCH_MBED) && defined(ARDUINO_ARCH_MBED_NANO) // Arduino Nano 33 BLE and Arduino Nano Connect layout for MBED
|
||||
// Must be before ARDUINO_ARCH_RP2040, since it is the layout for the MBED core of Arduino Nano Connect
|
||||
#define IR_RECEIVE_PIN 3 // GPIO15 Start with pin 3 since pin 2|GPIO25 is connected to LED on Pi pico
|
||||
#define IR_SEND_PIN 4 // GPIO16
|
||||
#define TONE_PIN 5
|
||||
#define APPLICATION_PIN 6
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 7 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 8
|
||||
|
||||
#elif defined(ARDUINO_ARCH_RP2040) // Arduino Nano Connect, Pi Pico with arduino-pico core https://github.com/earlephilhower/arduino-pico
|
||||
#define IR_RECEIVE_PIN 15 // GPIO15 to be compatible with the Arduino Nano RP2040 Connect (pin3)
|
||||
#define IR_SEND_PIN 16 // GPIO16
|
||||
#define TONE_PIN 17
|
||||
#define APPLICATION_PIN 18
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 19 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 20
|
||||
|
||||
// If you program the Nano RP2040 Connect with this core, then you must redefine LED_BUILTIN
|
||||
// and use the external reset with 1 kOhm to ground to enter UF2 mode
|
||||
#undef LED_BUILTIN
|
||||
#define LED_BUILTIN 6
|
||||
|
||||
#elif defined(PARTICLE) // !!!UNTESTED!!!
|
||||
#define IR_RECEIVE_PIN A4
|
||||
#define IR_SEND_PIN A5 // Particle supports multiple pins
|
||||
|
||||
#define LED_BUILTIN D7
|
||||
|
||||
/*
|
||||
* 4 times the same (default) layout for easy adaption in the future
|
||||
*/
|
||||
#elif defined(TEENSYDUINO) // Teensy 2.0 is handled at default for ATmega328 like on Uno, Nano, Leonardo etc.
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
#elif defined(ARDUINO_ARCH_MBED) // Arduino Nano 33 BLE
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
#elif defined(ARDUINO_ARCH_SAMD) || defined(ARDUINO_ARCH_SAM)
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
#if !defined(ARDUINO_SAMD_ADAFRUIT) && !defined(ARDUINO_SEEED_XIAO_M0)
|
||||
// On the Zero and others we switch explicitly to SerialUSB
|
||||
#define Serial SerialUSB
|
||||
#endif
|
||||
|
||||
// Definitions for the Chinese SAMD21 M0-Mini clone, which has no led connected to D13/PA17.
|
||||
// Attention!!! D2 and D4 are swapped on these boards!!!
|
||||
// If you connect the LED, it is on pin 24/PB11. In this case activate the next two lines.
|
||||
//#undef LED_BUILTIN
|
||||
//#define LED_BUILTIN 24 // PB11
|
||||
// As an alternative you can choose pin 25, it is the RX-LED pin (PB03), but active low.In this case activate the next 3 lines.
|
||||
//#undef LED_BUILTIN
|
||||
//#define LED_BUILTIN 25 // PB03
|
||||
//#define FEEDBACK_LED_IS_ACTIVE_LOW // The RX LED on the M0-Mini is active LOW
|
||||
|
||||
#elif defined (NRF51) // BBC micro:bit
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define APPLICATION_PIN 1
|
||||
#define _IR_TIMING_TEST_PIN 4
|
||||
|
||||
#define tone(...) void() // no tone() available
|
||||
#define noTone(a) void()
|
||||
#define TONE_PIN 42 // Dummy for examples using it
|
||||
|
||||
#else
|
||||
#warning Board / CPU is not detected using pre-processor symbols -> using default values, which may not fit. Please extend PinDefinitionsAndMore.h.
|
||||
// Default valued for unidentified boards
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
#endif // defined(ESP8266)
|
||||
|
||||
#if defined(ESP32) || defined(ARDUINO_ARCH_RP2040) || defined(PARTICLE) || defined(ARDUINO_ARCH_MBED)
|
||||
#define SEND_PWM_BY_TIMER // We do not have pin restrictions for this CPU's, so lets use the hardware PWM for send carrier signal generation
|
||||
#else
|
||||
# if defined(SEND_PWM_BY_TIMER)
|
||||
#undef IR_SEND_PIN // SendPin is determined by timer! This avoids warnings in IRremote.hpp and IRTimer.hpp
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if !defined (FLASHEND)
|
||||
#define FLASHEND 0xFFFF // Dummy value for platforms where FLASHEND is not defined
|
||||
#endif
|
||||
|
||||
/*
|
||||
* 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
|
||||
@@ -0,0 +1,248 @@
|
||||
/*
|
||||
* ReceiveAndSend.cpp
|
||||
*
|
||||
* Record and play back last received IR signal at button press.
|
||||
* The logic is:
|
||||
* If the button is pressed, send the IR code.
|
||||
* If an IR code is received, record it.
|
||||
* If the protocol is unknown or not enabled, store it as raw data for later sending.
|
||||
*
|
||||
* An example for simultaneous receiving and sending is in the UnitTest example.
|
||||
*
|
||||
* An IR detector/demodulator must be connected to the input IR_RECEIVE_PIN.
|
||||
*
|
||||
* A button must be connected between the input SEND_BUTTON_PIN and ground.
|
||||
* A visible LED can be connected to STATUS_PIN to provide status.
|
||||
*
|
||||
* See also https://dronebotworkshop.com/ir-remotes/#ReceiveAndSend_Code
|
||||
*
|
||||
* Initially coded 2009 Ken Shirriff http://www.righto.com
|
||||
*
|
||||
* This file is part of Arduino-IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
|
||||
*
|
||||
************************************************************************************
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2009-2024 Ken Shirriff, Armin Joachimsmeyer
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is furnished
|
||||
* to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
************************************************************************************
|
||||
*/
|
||||
#include <Arduino.h>
|
||||
|
||||
|
||||
/*
|
||||
* Specify which protocol(s) should be used for decoding.
|
||||
* If no protocol is defined, all protocols (except Bang&Olufsen) are active.
|
||||
* This must be done before the #include <IRremote.hpp>
|
||||
*/
|
||||
//#define DECODE_DENON // Includes Sharp
|
||||
//#define DECODE_JVC
|
||||
//#define DECODE_KASEIKYO
|
||||
//#define DECODE_PANASONIC // alias for DECODE_KASEIKYO
|
||||
//#define DECODE_LG
|
||||
#define DECODE_NEC // Includes Apple and Onkyo
|
||||
//#define DECODE_SAMSUNG
|
||||
//#define DECODE_SONY
|
||||
//#define DECODE_RC5
|
||||
//#define DECODE_RC6
|
||||
|
||||
//#define DECODE_BOSEWAVE
|
||||
//#define DECODE_LEGO_PF
|
||||
//#define DECODE_MAGIQUEST
|
||||
//#define DECODE_WHYNTER
|
||||
//#define DECODE_FAST
|
||||
//
|
||||
|
||||
#if !defined(RAW_BUFFER_LENGTH)
|
||||
#define RAW_BUFFER_LENGTH 750
|
||||
#endif
|
||||
|
||||
//#define EXCLUDE_UNIVERSAL_PROTOCOLS // Saves up to 1000 bytes program memory.
|
||||
//#define EXCLUDE_EXOTIC_PROTOCOLS // saves around 650 bytes program memory if all other protocols are active
|
||||
//#define NO_LED_FEEDBACK_CODE // saves 92 bytes program memory
|
||||
//#define RECORD_GAP_MICROS 12000 // Default is 8000. Activate it for some LG air conditioner protocols
|
||||
//#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
|
||||
|
||||
// MARK_EXCESS_MICROS is subtracted from all marks and added to all spaces before decoding,
|
||||
// to compensate for the signal forming of different IR receiver modules. See also IRremote.hpp line 142.
|
||||
#define MARK_EXCESS_MICROS 20 // Adapt it to your IR receiver module. 20 is recommended for the cheap VS1838 modules.
|
||||
|
||||
//#define DEBUG // Activate this for lots of lovely debug output from the decoders.
|
||||
|
||||
#define IR_RECEIVE_PIN 4 // P0_1
|
||||
#define IR_SEND_PIN 3 // P0_0
|
||||
|
||||
int SEND_BUTTON_PIN = BTN_BUILTIN;
|
||||
int BTN_ACTIVE_STATE = LOW; // HIGH for Elbear boards, LOW for start board
|
||||
|
||||
/*
|
||||
* 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 <IRremote.hpp>
|
||||
|
||||
int DELAY_BETWEEN_REPEAT = 50;
|
||||
|
||||
// Storage for the recorded code
|
||||
struct storedIRDataStruct {
|
||||
IRData receivedIRData;
|
||||
// extensions for sendRaw
|
||||
uint8_t rawCode[RAW_BUFFER_LENGTH]; // The durations if raw
|
||||
uint8_t rawCodeLength; // The length of the code
|
||||
} sStoredIRData;
|
||||
|
||||
bool sSendButtonWasActive;
|
||||
|
||||
void storeCode();
|
||||
void sendCode(storedIRDataStruct *aIRDataToSend);
|
||||
|
||||
void setup() {
|
||||
pinMode(SEND_BUTTON_PIN, INPUT);
|
||||
|
||||
Serial.begin(9600);
|
||||
while (!Serial)
|
||||
; // Wait for Serial to become available. Is optimized away for some cores.
|
||||
|
||||
// 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
|
||||
IrReceiver.begin(IR_RECEIVE_PIN, ENABLE_LED_FEEDBACK);
|
||||
Serial.print(F("Ready to receive IR signals of protocols: "));
|
||||
printActiveIRProtocols(&Serial);
|
||||
Serial.println(F("at pin " STR(IR_RECEIVE_PIN)));
|
||||
|
||||
IrSender.begin(); // Start with IR_SEND_PIN as send pin and enable feedback LED at default feedback LED pin
|
||||
Serial.print(F("Ready to send IR signals at pin " STR(IR_SEND_PIN) " on press of button at pin "));
|
||||
Serial.println(SEND_BUTTON_PIN);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
// If button pressed, send the code.
|
||||
bool tSendButtonIsActive = (digitalRead(SEND_BUTTON_PIN) == BTN_ACTIVE_STATE); // Button pin is active LOW
|
||||
/*
|
||||
* Check for current button state
|
||||
*/
|
||||
if (tSendButtonIsActive) {
|
||||
if (!sSendButtonWasActive) {
|
||||
Serial.println(F("Stop receiving"));
|
||||
IrReceiver.stop();
|
||||
}
|
||||
/*
|
||||
* Button pressed -> send stored data
|
||||
*/
|
||||
Serial.print(F("Button pressed, now sending "));
|
||||
if (sSendButtonWasActive == tSendButtonIsActive) {
|
||||
Serial.print(F("repeat "));
|
||||
sStoredIRData.receivedIRData.flags = IRDATA_FLAGS_IS_REPEAT;
|
||||
} else {
|
||||
sStoredIRData.receivedIRData.flags = IRDATA_FLAGS_EMPTY;
|
||||
}
|
||||
Serial.flush(); // To avoid disturbing the software PWM generation by serial output interrupts
|
||||
sendCode(&sStoredIRData);
|
||||
delay(DELAY_BETWEEN_REPEAT); // Wait a bit between retransmissions
|
||||
|
||||
} else if (sSendButtonWasActive) {
|
||||
/*
|
||||
* Button is just released -> activate receiving
|
||||
*/
|
||||
// Restart receiver
|
||||
Serial.println(F("Button released -> start receiving"));
|
||||
IrReceiver.start();
|
||||
|
||||
} else if (IrReceiver.decode()) {
|
||||
/*
|
||||
* Button is not pressed and data available -> store received data and resume
|
||||
*/
|
||||
storeCode();
|
||||
IrReceiver.resume(); // resume receiver
|
||||
}
|
||||
|
||||
sSendButtonWasActive = tSendButtonIsActive;
|
||||
delay(100);
|
||||
}
|
||||
|
||||
// Stores the code for later playback in sStoredIRData
|
||||
// Most of this code is just logging
|
||||
void storeCode() {
|
||||
if (IrReceiver.decodedIRData.rawDataPtr->rawlen < 4) {
|
||||
Serial.print(F("Ignore data with rawlen="));
|
||||
Serial.println(IrReceiver.decodedIRData.rawDataPtr->rawlen);
|
||||
return;
|
||||
}
|
||||
if (IrReceiver.decodedIRData.flags & IRDATA_FLAGS_IS_REPEAT) {
|
||||
Serial.println(F("Ignore repeat"));
|
||||
return;
|
||||
}
|
||||
if (IrReceiver.decodedIRData.flags & IRDATA_FLAGS_IS_AUTO_REPEAT) {
|
||||
Serial.println(F("Ignore autorepeat"));
|
||||
return;
|
||||
}
|
||||
if (IrReceiver.decodedIRData.flags & IRDATA_FLAGS_PARITY_FAILED) {
|
||||
Serial.println(F("Ignore parity error"));
|
||||
return;
|
||||
}
|
||||
/*
|
||||
* Copy decoded data
|
||||
*/
|
||||
sStoredIRData.receivedIRData = IrReceiver.decodedIRData;
|
||||
|
||||
if (sStoredIRData.receivedIRData.protocol == UNKNOWN) {
|
||||
Serial.print(F("Received unknown code and store "));
|
||||
Serial.print(IrReceiver.decodedIRData.rawDataPtr->rawlen - 1);
|
||||
Serial.println(F(" timing entries as raw "));
|
||||
IrReceiver.printIRResultRawFormatted(&Serial, true); // Output the results in RAW format
|
||||
sStoredIRData.rawCodeLength = IrReceiver.decodedIRData.rawDataPtr->rawlen - 1;
|
||||
/*
|
||||
* Store the current raw data in a dedicated array for later usage
|
||||
*/
|
||||
IrReceiver.compensateAndStoreIRResultInArray(sStoredIRData.rawCode);
|
||||
} else {
|
||||
IrReceiver.printIRResultShort(&Serial);
|
||||
IrReceiver.printIRSendUsage(&Serial);
|
||||
sStoredIRData.receivedIRData.flags = 0; // clear flags -esp. repeat- for later sending
|
||||
Serial.println();
|
||||
}
|
||||
}
|
||||
|
||||
void sendCode(storedIRDataStruct *aIRDataToSend) {
|
||||
if (aIRDataToSend->receivedIRData.protocol == UNKNOWN /* i.e. raw */) {
|
||||
// Assume 38 KHz
|
||||
IrSender.sendRaw(aIRDataToSend->rawCode, aIRDataToSend->rawCodeLength, 38);
|
||||
|
||||
Serial.print(F("raw "));
|
||||
Serial.print(aIRDataToSend->rawCodeLength);
|
||||
Serial.println(F(" marks or spaces"));
|
||||
} else {
|
||||
|
||||
/*
|
||||
* Use the write function, which does the switch for different protocols
|
||||
*/
|
||||
IrSender.write(&aIRDataToSend->receivedIRData);
|
||||
printIRResultShort(&Serial, &aIRDataToSend->receivedIRData, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,349 @@
|
||||
/*
|
||||
* PinDefinitionsAndMore.h
|
||||
*
|
||||
* Contains pin definitions for IRremote examples for various platforms
|
||||
* as well as definitions for feedback LED and tone() and includes
|
||||
*
|
||||
* Copyright (C) 2021-2023 Armin Joachimsmeyer
|
||||
* armin.joachimsmeyer@gmail.com
|
||||
*
|
||||
* This file is part of IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
|
||||
*
|
||||
* Arduino-IRremote is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/gpl.html>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Pin mapping table for different platforms
|
||||
*
|
||||
* Platform IR input IR output Tone Core/Pin schema
|
||||
* --------------------------------------------------------------
|
||||
* DEFAULT/AVR 2 3 4 Arduino
|
||||
* ATtinyX5 0|PB0 4|PB4 3|PB3 ATTinyCore
|
||||
* ATtiny167 3|PA3 2|PA2 7|PA7 ATTinyCore
|
||||
* ATtiny167 9|PA3 8|PA2 5|PA7 Digispark original core
|
||||
* ATtiny84 |PB2 |PA4 |PA3 ATTinyCore
|
||||
* ATtiny88 3|PD3 4|PD4 9|PB1 ATTinyCore
|
||||
* ATtiny3217 18|PA1 19|PA2 20|PA3 MegaTinyCore
|
||||
* ATtiny1604 2 3|PA5 %
|
||||
* ATtiny816 14|PA1 16|PA3 1|PA5 MegaTinyCore
|
||||
* ATtiny1614 8|PA1 10|PA3 1|PA5 MegaTinyCore
|
||||
* SAMD21 3 4 5
|
||||
* ESP8266 14|D5 12|D6 %
|
||||
* ESP32 15 4 27
|
||||
* ESP32-C3 2 3 4
|
||||
* BluePill PA6 PA7 PA3
|
||||
* APOLLO3 11 12 5
|
||||
* RP2040 3|GPIO15 4|GPIO16 5|GPIO17
|
||||
*/
|
||||
//#define _IR_MEASURE_TIMING // For debugging purposes.
|
||||
|
||||
#if defined(__AVR__)
|
||||
#if defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__) // Digispark board. For use with ATTinyCore.
|
||||
#include "ATtinySerialOut.hpp" // TX is at pin 2 - Available as Arduino library "ATtinySerialOut". Saves 700 bytes program memory and 70 bytes RAM for ATtinyCore.
|
||||
#define IR_RECEIVE_PIN PIN_PB0
|
||||
#define IR_SEND_PIN PIN_PB4 // Pin 2 is serial output with ATtinySerialOut. Pin 1 is internal LED and Pin3 is USB+ with pullup on Digispark board.
|
||||
#define TONE_PIN PIN_PB3
|
||||
#define _IR_TIMING_TEST_PIN PIN_PB3
|
||||
|
||||
# elif defined(__AVR_ATtiny87__) || defined(__AVR_ATtiny167__) // Digispark pro board
|
||||
#include "ATtinySerialOut.hpp" // Available as Arduino library "ATtinySerialOut"
|
||||
// For ATtiny167 Pins PB6 and PA3 are usable as interrupt source.
|
||||
# if defined(ARDUINO_AVR_DIGISPARKPRO)
|
||||
// For use with Digispark original core
|
||||
#define IR_RECEIVE_PIN 9 // PA3 - on Digispark board labeled as pin 9
|
||||
//#define IR_RECEIVE_PIN 14 // PB6 / INT0 is connected to USB+ on DigisparkPro boards
|
||||
#define IR_SEND_PIN 8 // PA2 - on Digispark board labeled as pin 8
|
||||
#define TONE_PIN 5 // PA7 - on Digispark board labeled as pin 5
|
||||
#define _IR_TIMING_TEST_PIN 10 // PA4
|
||||
# else
|
||||
// For use with ATTinyCore
|
||||
#define IR_RECEIVE_PIN PIN_PA3 // On Digispark board labeled as pin 9 - INT0 is connected to USB+ on DigisparkPro boards
|
||||
#define IR_SEND_PIN PIN_PA2 // On Digispark board labeled as pin 8
|
||||
#define TONE_PIN PIN_PA7 // On Digispark board labeled as pin 5
|
||||
# endif
|
||||
|
||||
# elif defined(__AVR_ATtiny84__) // For use with ATTinyCore
|
||||
#include "ATtinySerialOut.hpp" // Available as Arduino library "ATtinySerialOut". Saves 128 bytes program memory.
|
||||
#define IR_RECEIVE_PIN PIN_PB2 // INT0
|
||||
#define IR_SEND_PIN PIN_PA4
|
||||
#define TONE_PIN PIN_PA3
|
||||
#define _IR_TIMING_TEST_PIN PIN_PA5
|
||||
|
||||
# elif defined(__AVR_ATtiny88__) // MH-ET Tiny88 board. For use with ATTinyCore.
|
||||
#include "ATtinySerialOut.hpp" // Available as Arduino library "ATtinySerialOut". Saves 128 bytes program memory.
|
||||
// Pin 6 is TX, pin 7 is RX
|
||||
#define IR_RECEIVE_PIN PIN_PD3 // 3 - INT1
|
||||
#define IR_SEND_PIN PIN_PD4 // 4
|
||||
#define TONE_PIN PIN_PB1 // 9
|
||||
#define _IR_TIMING_TEST_PIN PIN_PB0 // 8
|
||||
|
||||
# elif defined(__AVR_ATtiny1616__) || defined(__AVR_ATtiny3216__) || defined(__AVR_ATtiny3217__) // For use with megaTinyCore
|
||||
// Tiny Core Dev board
|
||||
// https://www.tindie.com/products/xkimi/tiny-core-16-dev-board-attiny1616/ - Out of Stock
|
||||
// https://www.tindie.com/products/xkimi/tiny-core-32-dev-board-attiny3217/ - Out of Stock
|
||||
#define IR_RECEIVE_PIN PIN_PA1 // use 18 instead of PIN_PA1 for TinyCore32
|
||||
#define IR_SEND_PIN PIN_PA2 // 19
|
||||
#define TONE_PIN PIN_PA3 // 20
|
||||
#define APPLICATION_PIN PIN_PA0 // 0
|
||||
#undef LED_BUILTIN // No LED available on the TinyCore 32 board, take the one on the programming board which is connected to the DAC output
|
||||
#define LED_BUILTIN PIN_PA6 // use 2 instead of PIN_PA6 for TinyCore32
|
||||
|
||||
# elif defined(__AVR_ATtiny816__) // For use with megaTinyCore
|
||||
#define IR_RECEIVE_PIN PIN_PA1 // 14
|
||||
#define IR_SEND_PIN PIN_PA1 // 16
|
||||
#define TONE_PIN PIN_PA5 // 1
|
||||
#define APPLICATION_PIN PIN_PA4 // 0
|
||||
#undef LED_BUILTIN // No LED available, take the one which is connected to the DAC output
|
||||
#define LED_BUILTIN PIN_PB5 // 4
|
||||
|
||||
# elif defined(__AVR_ATtiny1614__) // For use with megaTinyCore
|
||||
#define IR_RECEIVE_PIN PIN_PA1 // 8
|
||||
#define IR_SEND_PIN PIN_PA3 // 10
|
||||
#define TONE_PIN PIN_PA5 // 1
|
||||
#define APPLICATION_PIN PIN_PA4 // 0
|
||||
|
||||
# elif defined(__AVR_ATtiny1604__) // For use with megaTinyCore
|
||||
#define IR_RECEIVE_PIN PIN_PA6 // 2 - To be compatible with interrupt example, pin 2 is chosen here.
|
||||
#define IR_SEND_PIN PIN_PA7 // 3
|
||||
#define APPLICATION_PIN PIN_PB2 // 5
|
||||
|
||||
#define tone(...) void() // Define as void, since TCB0_INT_vect is also used by tone()
|
||||
#define noTone(a) void()
|
||||
#define TONE_PIN 42 // Dummy for examples using it
|
||||
|
||||
# elif defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) \
|
||||
|| defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) \
|
||||
|| defined(__AVR_ATmega324P__) || defined(__AVR_ATmega324A__) \
|
||||
|| defined(__AVR_ATmega324PA__) || defined(__AVR_ATmega164A__) \
|
||||
|| defined(__AVR_ATmega164P__) || defined(__AVR_ATmega32__) \
|
||||
|| defined(__AVR_ATmega16__) || defined(__AVR_ATmega8535__) \
|
||||
|| defined(__AVR_ATmega64__) || defined(__AVR_ATmega128__) \
|
||||
|| defined(__AVR_ATmega1281__) || defined(__AVR_ATmega2561__) \
|
||||
|| defined(__AVR_ATmega8515__) || defined(__AVR_ATmega162__)
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 13
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
# else // Default as for ATmega328 like on Uno, Nano, Leonardo, Teensy 2.0 etc.
|
||||
#define IR_RECEIVE_PIN 2 // To be compatible with interrupt example, pin 2 is chosen here.
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
# if defined(ARDUINO_AVR_PROMICRO) // Sparkfun Pro Micro is __AVR_ATmega32U4__ but has different external circuit
|
||||
// We have no built in LED at pin 13 -> reuse RX LED
|
||||
#undef LED_BUILTIN
|
||||
#define LED_BUILTIN LED_BUILTIN_RX
|
||||
# endif
|
||||
# endif // defined(__AVR_ATtiny25__)...
|
||||
|
||||
#elif defined(ARDUINO_ARCH_RENESAS_UNO) // Uno R4
|
||||
// To be compatible with Uno R3.
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
#elif defined(ESP8266)
|
||||
#define FEEDBACK_LED_IS_ACTIVE_LOW // The LED on my board (D4) is active LOW
|
||||
#define IR_RECEIVE_PIN 14 // D5
|
||||
#define IR_SEND_PIN 12 // D6 - D4/pin 2 is internal LED
|
||||
#define _IR_TIMING_TEST_PIN 2 // D4
|
||||
#define APPLICATION_PIN 13 // D7
|
||||
|
||||
#define tone(...) void() // tone() inhibits receive timer
|
||||
#define noTone(a) void()
|
||||
#define TONE_PIN 42 // Dummy for examples using it#
|
||||
|
||||
#elif defined(ARDUINO_NOLOGO_ESP32C3_SUPER_MINI)
|
||||
#define FEEDBACK_LED_IS_ACTIVE_LOW // The LED on my board (D8) is active LOW
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 10
|
||||
|
||||
#elif defined(CONFIG_IDF_TARGET_ESP32C3) || defined(ARDUINO_ESP32C3_DEV)
|
||||
#define NO_LED_FEEDBACK_CODE // The WS2812 on pin 8 of AI-C3 board crashes if used as receive feedback LED, other I/O pins are working...
|
||||
#define IR_RECEIVE_PIN 6
|
||||
#define IR_SEND_PIN 7
|
||||
#define TONE_PIN 10
|
||||
#define APPLICATION_PIN 18
|
||||
|
||||
#elif defined(ESP32)
|
||||
#include <Arduino.h>
|
||||
|
||||
// tone() is included in ESP32 core since 2.0.2
|
||||
#if !defined(ESP_ARDUINO_VERSION_VAL)
|
||||
#define ESP_ARDUINO_VERSION_VAL(major, minor, patch) 12345678
|
||||
#endif
|
||||
#if ESP_ARDUINO_VERSION <= ESP_ARDUINO_VERSION_VAL(2, 0, 2)
|
||||
#define TONE_LEDC_CHANNEL 1 // Using channel 1 makes tone() independent of receiving timer -> No need to stop receiving timer.
|
||||
void tone(uint8_t aPinNumber, unsigned int aFrequency){
|
||||
ledcAttachPin(aPinNumber, TONE_LEDC_CHANNEL);
|
||||
ledcWriteTone(TONE_LEDC_CHANNEL, aFrequency);
|
||||
}
|
||||
void tone(uint8_t aPinNumber, unsigned int aFrequency, unsigned long aDuration){
|
||||
ledcAttachPin(aPinNumber, TONE_LEDC_CHANNEL);
|
||||
ledcWriteTone(TONE_LEDC_CHANNEL, aFrequency);
|
||||
delay(aDuration);
|
||||
ledcWriteTone(TONE_LEDC_CHANNEL, 0);
|
||||
}
|
||||
void noTone(uint8_t aPinNumber){
|
||||
ledcWriteTone(TONE_LEDC_CHANNEL, 0);
|
||||
}
|
||||
#endif // ESP_ARDUINO_VERSION <= ESP_ARDUINO_VERSION_VAL(2, 0, 2)
|
||||
|
||||
#define IR_RECEIVE_PIN 15 // D15
|
||||
#define IR_SEND_PIN 4 // D4
|
||||
#define TONE_PIN 27 // D27 25 & 26 are DAC0 and 1
|
||||
#define APPLICATION_PIN 16 // RX2 pin
|
||||
|
||||
#elif defined(ARDUINO_ARCH_STM32) || defined(ARDUINO_ARCH_STM32F1) // BluePill
|
||||
// Timer 3 blocks PA6, PA7, PB0, PB1 for use by Servo or tone()
|
||||
#define IR_RECEIVE_PIN PA6
|
||||
#define IR_RECEIVE_PIN_STRING "PA6"
|
||||
#define IR_SEND_PIN PA7
|
||||
#define IR_SEND_PIN_STRING "PA7"
|
||||
#define TONE_PIN PA3
|
||||
#define _IR_TIMING_TEST_PIN PA5
|
||||
#define APPLICATION_PIN PA2
|
||||
#define APPLICATION_PIN_STRING "PA2"
|
||||
# if defined(ARDUINO_GENERIC_STM32F103C) || defined(ARDUINO_BLUEPILL_F103C8)
|
||||
// BluePill LED is active low
|
||||
#define FEEDBACK_LED_IS_ACTIVE_LOW
|
||||
# endif
|
||||
|
||||
#elif defined(ARDUINO_ARCH_APOLLO3) // Sparkfun Apollo boards
|
||||
#define IR_RECEIVE_PIN 11
|
||||
#define IR_SEND_PIN 12
|
||||
#define TONE_PIN 5
|
||||
|
||||
#elif defined(ARDUINO_ARCH_MBED) && defined(ARDUINO_ARCH_MBED_NANO) // Arduino Nano 33 BLE and Arduino Nano Connect layout for MBED
|
||||
// Must be before ARDUINO_ARCH_RP2040, since it is the layout for the MBED core of Arduino Nano Connect
|
||||
#define IR_RECEIVE_PIN 3 // GPIO15 Start with pin 3 since pin 2|GPIO25 is connected to LED on Pi pico
|
||||
#define IR_SEND_PIN 4 // GPIO16
|
||||
#define TONE_PIN 5
|
||||
#define APPLICATION_PIN 6
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 7 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 8
|
||||
|
||||
#elif defined(ARDUINO_ARCH_RP2040) // Arduino Nano Connect, Pi Pico with arduino-pico core https://github.com/earlephilhower/arduino-pico
|
||||
#define IR_RECEIVE_PIN 15 // GPIO15 to be compatible with the Arduino Nano RP2040 Connect (pin3)
|
||||
#define IR_SEND_PIN 16 // GPIO16
|
||||
#define TONE_PIN 17
|
||||
#define APPLICATION_PIN 18
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 19 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 20
|
||||
|
||||
// If you program the Nano RP2040 Connect with this core, then you must redefine LED_BUILTIN
|
||||
// and use the external reset with 1 kOhm to ground to enter UF2 mode
|
||||
#undef LED_BUILTIN
|
||||
#define LED_BUILTIN 6
|
||||
|
||||
#elif defined(PARTICLE) // !!!UNTESTED!!!
|
||||
#define IR_RECEIVE_PIN A4
|
||||
#define IR_SEND_PIN A5 // Particle supports multiple pins
|
||||
|
||||
#define LED_BUILTIN D7
|
||||
|
||||
/*
|
||||
* 4 times the same (default) layout for easy adaption in the future
|
||||
*/
|
||||
#elif defined(TEENSYDUINO) // Teensy 2.0 is handled at default for ATmega328 like on Uno, Nano, Leonardo etc.
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
#elif defined(ARDUINO_ARCH_MBED) // Arduino Nano 33 BLE
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
#elif defined(ARDUINO_ARCH_SAMD) || defined(ARDUINO_ARCH_SAM)
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
#if !defined(ARDUINO_SAMD_ADAFRUIT) && !defined(ARDUINO_SEEED_XIAO_M0)
|
||||
// On the Zero and others we switch explicitly to SerialUSB
|
||||
#define Serial SerialUSB
|
||||
#endif
|
||||
|
||||
// Definitions for the Chinese SAMD21 M0-Mini clone, which has no led connected to D13/PA17.
|
||||
// Attention!!! D2 and D4 are swapped on these boards!!!
|
||||
// If you connect the LED, it is on pin 24/PB11. In this case activate the next two lines.
|
||||
//#undef LED_BUILTIN
|
||||
//#define LED_BUILTIN 24 // PB11
|
||||
// As an alternative you can choose pin 25, it is the RX-LED pin (PB03), but active low.In this case activate the next 3 lines.
|
||||
//#undef LED_BUILTIN
|
||||
//#define LED_BUILTIN 25 // PB03
|
||||
//#define FEEDBACK_LED_IS_ACTIVE_LOW // The RX LED on the M0-Mini is active LOW
|
||||
|
||||
#elif defined (NRF51) // BBC micro:bit
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define APPLICATION_PIN 1
|
||||
#define _IR_TIMING_TEST_PIN 4
|
||||
|
||||
#define tone(...) void() // no tone() available
|
||||
#define noTone(a) void()
|
||||
#define TONE_PIN 42 // Dummy for examples using it
|
||||
|
||||
#else
|
||||
#warning Board / CPU is not detected using pre-processor symbols -> using default values, which may not fit. Please extend PinDefinitionsAndMore.h.
|
||||
// Default valued for unidentified boards
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
#endif // defined(ESP8266)
|
||||
|
||||
#if defined(ESP32) || defined(ARDUINO_ARCH_RP2040) || defined(PARTICLE) || defined(ARDUINO_ARCH_MBED)
|
||||
#define SEND_PWM_BY_TIMER // We do not have pin restrictions for this CPU's, so lets use the hardware PWM for send carrier signal generation
|
||||
#else
|
||||
# if defined(SEND_PWM_BY_TIMER)
|
||||
#undef IR_SEND_PIN // SendPin is determined by timer! This avoids warnings in IRremote.hpp and IRTimer.hpp
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if !defined (FLASHEND)
|
||||
#define FLASHEND 0xFFFF // Dummy value for platforms where FLASHEND is not defined
|
||||
#endif
|
||||
|
||||
/*
|
||||
* 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
|
||||
+191
@@ -0,0 +1,191 @@
|
||||
/*
|
||||
* ReceiveAndSendDistanceWidth.cpp
|
||||
*
|
||||
* Record and play back last received distance width IR signal at button press.
|
||||
* Using DistanceWidthProtocol covers a lot of known and unknown IR protocols,
|
||||
* and requires less memory than raw protocol.
|
||||
*
|
||||
* The logic is:
|
||||
* If the button is pressed, send the IR code.
|
||||
* If an IR code is received, record it.
|
||||
*
|
||||
* An example for simultaneous receiving and sending is in the UnitTest example.
|
||||
*
|
||||
* An IR detector/demodulator must be connected to the input IR_RECEIVE_PIN.
|
||||
*
|
||||
* A button must be connected between the input SEND_BUTTON_PIN and ground.
|
||||
* A visible LED can be connected to STATUS_PIN to provide status.
|
||||
*
|
||||
* See also https://dronebotworkshop.com/ir-remotes/#ReceiveAndSendDistanceWidth_Code
|
||||
*
|
||||
* This file is part of Arduino-IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
|
||||
*
|
||||
************************************************************************************
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2023 Armin Joachimsmeyer
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is furnished
|
||||
* to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
************************************************************************************
|
||||
*/
|
||||
#include <Arduino.h>
|
||||
|
||||
#if !defined(IR_SEND_PIN)
|
||||
#define IR_SEND_PIN 3 // P0_0
|
||||
#endif
|
||||
|
||||
#define IR_RECEIVE_PIN 4 // P0_1
|
||||
|
||||
#define SEND_BUTTON_PIN BTN_BUILTIN
|
||||
#define BTN_ACTIVE_STATE HIGH // HIGH for Elbear boards, LOW for Start board
|
||||
|
||||
/*
|
||||
* 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
|
||||
|
||||
|
||||
/*
|
||||
* Specify DistanceWidthProtocol for decoding. This must be done before the #include <IRremote.hpp>
|
||||
*/
|
||||
#define DECODE_DISTANCE_WIDTH // Universal decoder for pulse distance width protocols
|
||||
//
|
||||
#if !defined(RAW_BUFFER_LENGTH)
|
||||
#define RAW_BUFFER_LENGTH 750
|
||||
#endif
|
||||
|
||||
//#define NO_LED_FEEDBACK_CODE // saves 92 bytes program memory
|
||||
//#define RECORD_GAP_MICROS 12000 // Default is 8000. Activate it for some LG air conditioner protocols
|
||||
//#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 DEBUG // Activate this for lots of lovely debug output from the decoders.
|
||||
|
||||
#include <IRremote.hpp>
|
||||
|
||||
#define DELAY_BETWEEN_REPEATS_MILLIS 70
|
||||
|
||||
// Storage for the recorded code, pre-filled with NEC data
|
||||
IRRawDataType sDecodedRawDataArray[RAW_DATA_ARRAY_SIZE] = { 0x7B34ED12 }; // Initialize with NEC address 0x12 and command 0x34
|
||||
DistanceWidthTimingInfoStruct sDistanceWidthTimingInfo = { 9000, 4500, 560, 1690, 560, 560 }; // Initialize with NEC timing
|
||||
uint8_t sNumberOfBits = 32;
|
||||
|
||||
bool sSendButtonWasActive;
|
||||
|
||||
void setup() {
|
||||
pinMode(SEND_BUTTON_PIN, INPUT);
|
||||
|
||||
Serial.begin(9600);
|
||||
while (!Serial)
|
||||
; // Wait for Serial to become available. Is optimized away for some cores.
|
||||
|
||||
// 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
|
||||
IrReceiver.begin(IR_RECEIVE_PIN, ENABLE_LED_FEEDBACK);
|
||||
Serial.println(F("Ready to receive pulse distance/width coded IR signals at pin " STR(IR_RECEIVE_PIN)));
|
||||
|
||||
IrSender.begin(); // Start with IR_SEND_PIN as send pin and enable feedback LED at default feedback LED pin
|
||||
Serial.print(F("Ready to send IR signals at pin " STR(IR_SEND_PIN) " on press of button at pin "));
|
||||
Serial.println(SEND_BUTTON_PIN);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
// If button pressed, send the code.
|
||||
bool tSendButtonIsActive = (digitalRead(SEND_BUTTON_PIN) == BTN_ACTIVE_STATE);
|
||||
|
||||
/*
|
||||
* Check for current button state
|
||||
*/
|
||||
if (tSendButtonIsActive) {
|
||||
if (!sSendButtonWasActive) {
|
||||
Serial.println(F("Stop receiving"));
|
||||
IrReceiver.stop();
|
||||
}
|
||||
/*
|
||||
* Button pressed -> send stored data
|
||||
*/
|
||||
Serial.print(F("Button pressed, now sending "));
|
||||
Serial.print(sNumberOfBits);
|
||||
Serial.print(F(" bits 0x"));
|
||||
Serial.print(sDecodedRawDataArray[0], HEX);
|
||||
Serial.print(F(" with sendPulseDistanceWidthFromArray timing="));
|
||||
IrReceiver.printDistanceWidthTimingInfo(&Serial, &sDistanceWidthTimingInfo);
|
||||
Serial.println();
|
||||
Serial.flush(); // To avoid disturbing the software PWM generation by serial output interrupts
|
||||
|
||||
IrSender.sendPulseDistanceWidthFromArray(38, &sDistanceWidthTimingInfo, &sDecodedRawDataArray[0], sNumberOfBits,
|
||||
#if defined(USE_MSB_DECODING_FOR_DISTANCE_DECODER)
|
||||
PROTOCOL_IS_MSB_FIRST
|
||||
#else
|
||||
PROTOCOL_IS_LSB_FIRST
|
||||
#endif
|
||||
, 100, 0);
|
||||
|
||||
delay(DELAY_BETWEEN_REPEATS_MILLIS); // Wait a bit between retransmissions
|
||||
|
||||
} else if (sSendButtonWasActive) {
|
||||
/*
|
||||
* Button is just released -> activate receiving
|
||||
*/
|
||||
// Restart receiver
|
||||
Serial.println(F("Button released -> start receiving"));
|
||||
IrReceiver.start();
|
||||
|
||||
} else if (IrReceiver.decode()) {
|
||||
/*
|
||||
* Button is not pressed and data available -> store received data and resume
|
||||
* DistanceWidthTimingInfo and sNumberOfBits should be constant for all keys of the same IR remote / protocol
|
||||
*/
|
||||
IrReceiver.printIRResultShort(&Serial);
|
||||
if (IrReceiver.decodedIRData.protocol != UNKNOWN) {
|
||||
IrReceiver.printIRSendUsage(&Serial);
|
||||
|
||||
if (memcmp(&sDistanceWidthTimingInfo, &IrReceiver.decodedIRData.DistanceWidthTimingInfo,
|
||||
sizeof(sDistanceWidthTimingInfo)) != 0) {
|
||||
Serial.print(F("Store new timing info data="));
|
||||
IrReceiver.printDistanceWidthTimingInfo(&Serial, &IrReceiver.decodedIRData.DistanceWidthTimingInfo);
|
||||
Serial.println();
|
||||
sDistanceWidthTimingInfo = IrReceiver.decodedIRData.DistanceWidthTimingInfo; // copy content here
|
||||
} else {
|
||||
Serial.print(F("Timing did not change, so we can reuse already stored timing info."));
|
||||
}
|
||||
if (sNumberOfBits != IrReceiver.decodedIRData.numberOfBits) {
|
||||
Serial.print(F("Store new numberOfBits="));
|
||||
sNumberOfBits = IrReceiver.decodedIRData.numberOfBits;
|
||||
Serial.println(IrReceiver.decodedIRData.numberOfBits);
|
||||
}
|
||||
if (sDecodedRawDataArray[0] != IrReceiver.decodedIRData.decodedRawDataArray[0]) {
|
||||
*sDecodedRawDataArray = *IrReceiver.decodedIRData.decodedRawDataArray; // copy content here
|
||||
Serial.print(F("Store new sDecodedRawDataArray[0]=0x"));
|
||||
Serial.println(IrReceiver.decodedIRData.decodedRawDataArray[0], HEX);
|
||||
}
|
||||
}
|
||||
IrReceiver.resume(); // resume receiver
|
||||
Serial.println();
|
||||
}
|
||||
|
||||
sSendButtonWasActive = tSendButtonIsActive;
|
||||
delay(100);
|
||||
}
|
||||
@@ -0,0 +1,178 @@
|
||||
START ../src/ReceiveDemo.cpp from Feb 24 2023
|
||||
Using library version 4.1.0
|
||||
Enabling IRin...
|
||||
Ready to receive IR signals of protocols: NEC/NEC2/Onkyo/Apple, Panasonic/Kaseikyo, Denon/Sharp, Sony, RC5, RC6, LG, JVC, Samsung, FAST, Whynter, Lego Power Functions, Bosewave , MagiQuest, Universal Pulse Distance Width, Hash at pin 2
|
||||
|
||||
If you connect debug pin 5 to ground, raw data is always printed
|
||||
5000 us is the (minimum) gap, after which the start of a new IR packet is assumed
|
||||
20 us are subtracted from all marks and added to all spaces for decoding
|
||||
|
||||
Protocol=NEC Address=0x2 Command=0x34 Raw-Data=0xCB34FD02 32 bits LSB first
|
||||
Send with: IrSender.sendNEC(0x2, 0x34, <numberOfRepeats>);
|
||||
|
||||
Protocol=NEC Address=0x102 Command=0x34 Raw-Data=0xCB340102 32 bits LSB first
|
||||
Send with: IrSender.sendNEC(0x102, 0x34, <numberOfRepeats>);
|
||||
|
||||
Protocol=NEC Address=0x102 Command=0x34 Raw-Data=0xCB340102 32 bits LSB first
|
||||
Send with: IrSender.sendNEC(0x102, 0x34, <numberOfRepeats>);
|
||||
|
||||
Protocol=NEC Address=0x80 Command=0x45 Raw-Data=0xBA457F80 32 bits LSB first
|
||||
Send with: IrSender.sendNEC(0x80, 0x45, <numberOfRepeats>);
|
||||
|
||||
Protocol=NEC Address=0x4 Command=0x8 Raw-Data=0xF708FB04 32 bits LSB first
|
||||
Send with: IrSender.sendNEC(0x4, 0x8, <numberOfRepeats>);
|
||||
|
||||
Protocol=Onkyo Address=0x102 Command=0x304 Raw-Data=0x3040102 32 bits LSB first
|
||||
Send with: IrSender.sendOnkyo(0x102, 0x304, <numberOfRepeats>);
|
||||
|
||||
Protocol=NEC Address=0x102 Command=0x34 Raw-Data=0xCB340102 32 bits LSB first
|
||||
Send with: IrSender.sendNEC(0x102, 0x34, <numberOfRepeats>);
|
||||
|
||||
Protocol=Panasonic Address=0xB Command=0x10 Raw-Data=0xA01000B0 48 bits LSB first
|
||||
Send with: IrSender.sendPanasonic(0xB, 0x10, <numberOfRepeats>);
|
||||
|
||||
Protocol=Panasonic Address=0xB Command=0x10 Raw-Data=0xA01000B0 48 bits LSB first
|
||||
Send with: IrSender.sendPanasonic(0xB, 0x10, <numberOfRepeats>);
|
||||
|
||||
Protocol=Panasonic Address=0xB Command=0x10 Raw-Data=0xA01000B0 48 bits LSB first
|
||||
Send with: IrSender.sendPanasonic(0xB, 0x10, <numberOfRepeats>);
|
||||
|
||||
Protocol=PulseDistance Raw-Data=0x5A 72 bits LSB first
|
||||
Send with:
|
||||
uint32_t tRawData[]={0x87654321, 0xAFEDCBA9, 0x5A};
|
||||
IrSender.sendPulseDistanceWidthFromArray(38, 8850, 4400, 550, 1700, 550, 600, &tRawData[0], 72, PROTOCOL_IS_LSB_FIRST, <RepeatPeriodMillis>, <numberOfRepeats>);
|
||||
|
||||
Protocol=PulseWidth Raw-Data=0xDCBA9 52 bits LSB first
|
||||
Send with:
|
||||
uint32_t tRawData[]={0x87654321, 0xDCBA9};
|
||||
IrSender.sendPulseDistanceWidthFromArray(38, 300, 600, 600, 300, 350, 600, &tRawData[0], 52, PROTOCOL_IS_LSB_FIRST, <RepeatPeriodMillis>, <numberOfRepeats>);
|
||||
|
||||
Protocol=PulseWidth Raw-Data=0x87654321 32 bits LSB first
|
||||
Send with: IrSender.sendPulseDistanceWidth(38, 1000, 500, 600, 300, 350, 300, 0x87654321, 32, PROTOCOL_IS_LSB_FIRST, <RepeatPeriodMillis>, <numberOfRepeats>);
|
||||
|
||||
Protocol=Onkyo Address=0x102 Command=0x5634 Raw-Data=0x56340102 32 bits LSB first
|
||||
Send with: IrSender.sendOnkyo(0x102, 0x5634, <numberOfRepeats>);
|
||||
|
||||
Protocol=Apple Address=0x2 Command=0x34 Raw-Data=0x23487EE 32 bits LSB first
|
||||
Send with: IrSender.sendApple(0x2, 0x34, <numberOfRepeats>);
|
||||
|
||||
Protocol=Panasonic Address=0x102 Command=0x34 Raw-Data=0x4341020 48 bits LSB first
|
||||
Send with: IrSender.sendPanasonic(0x102, 0x34, <numberOfRepeats>);
|
||||
|
||||
Protocol=Kaseikyo Address=0x102 Command=0x34 Extra=0x4711 Raw-Data=0x7341023 48 bits LSB first
|
||||
Send with: IrSender.sendKaseikyo(0x102, 0x34, <numberOfRepeats>, 0x4711);
|
||||
|
||||
Protocol=Kaseikyo_Denon Address=0x102 Command=0x34 Raw-Data=0x4341020 48 bits LSB first
|
||||
Send with: IrSender.sendKaseikyo_Denon(0x102, 0x34, <numberOfRepeats>);
|
||||
|
||||
Protocol=Denon Address=0x2 Command=0x34 Raw-Data=0x682 15 bits LSB first
|
||||
Send with: IrSender.sendDenon(0x2, 0x34, <numberOfRepeats>);
|
||||
|
||||
Protocol=Denon Address=0x2 Command=0x34 Auto-Repeat gap=45650us Raw-Data=0x7962 15 bits LSB first
|
||||
|
||||
Protocol=Sharp Address=0x2 Command=0x34 Raw-Data=0x4682 15 bits LSB first
|
||||
Send with: IrSender.sendSharp(0x2, 0x34, <numberOfRepeats>);
|
||||
|
||||
Protocol=Sharp Address=0x2 Command=0x34 Auto-Repeat gap=46400us Raw-Data=0x3962 15 bits LSB first
|
||||
|
||||
Protocol=Sony Address=0x2 Command=0x34 Raw-Data=0x134 12 bits LSB first
|
||||
Send with: IrSender.sendSony(0x2, 0x34, 2, 12);
|
||||
|
||||
Protocol=Sony Address=0x2 Command=0x34 Raw-Data=0x134 15 bits LSB first
|
||||
Send with: IrSender.sendSony(0x2, 0x34, 2, 15);
|
||||
|
||||
Protocol=Sony Address=0x102 Command=0x34 Raw-Data=0x8134 20 bits LSB first
|
||||
Send with: IrSender.sendSony(0x102, 0x34, 2, 20);
|
||||
|
||||
Protocol=Samsung Address=0x102 Command=0x34 Raw-Data=0xCB340102 32 bits LSB first
|
||||
Send with: IrSender.sendSamsung(0x102, 0x34, <numberOfRepeats>);
|
||||
|
||||
Protocol=Samsung Address=0x102 Command=0x5634 Raw-Data=0x56340102 32 bits LSB first
|
||||
Send with: IrSender.sendSamsung(0x102, 0x5634, <numberOfRepeats>);
|
||||
|
||||
Protocol=Samsung48 Address=0x102 Command=0x5634 Raw-Data=0xA956 48 bits LSB first
|
||||
Send with: IrSender.sendSamsung48(0x102, 0x5634, <numberOfRepeats>);
|
||||
|
||||
Protocol=RC5 Address=0x2 Command=0x34 Raw-Data=0x10B4 13 bits MSB first
|
||||
Send with: IrSender.sendRC5(0x2, 0x34, <numberOfRepeats>);
|
||||
|
||||
Protocol=RC5 Address=0x2 Command=0x74 Toggle=1 Raw-Data=0x8B4 13 bits MSB first
|
||||
Send with: IrSender.sendRC5(0x2, 0x74, <numberOfRepeats>);
|
||||
|
||||
Protocol=RC6 Address=0x2 Command=0x34 Raw-Data=0x234 20 bits MSB first
|
||||
Send with: IrSender.sendRC6(0x2, 0x34, <numberOfRepeats>);
|
||||
|
||||
Protocol=Samsung Address=0x102 Command=0x34 Raw-Data=0xCB340102 32 bits LSB first
|
||||
Send with: IrSender.sendSamsung(0x102, 0x34, <numberOfRepeats>);
|
||||
|
||||
Protocol=JVC Address=0x2 Command=0x34 Raw-Data=0x3402 16 bits LSB first
|
||||
Send with: IrSender.sendJVC(0x2, 0x34, <numberOfRepeats>);
|
||||
|
||||
Protocol=Samsung Address=0x102 Command=0x5634 Raw-Data=0x56340102 32 bits LSB first
|
||||
Send with: IrSender.sendSamsung(0x102, 0x5634, <numberOfRepeats>);
|
||||
|
||||
Protocol=LG Address=0x2 Command=0x5634 Raw-Data=0x256342 28 bits MSB first
|
||||
Send with: IrSender.sendLG(0x2, 0x5634, <numberOfRepeats>);
|
||||
|
||||
Protocol=MagiQuest Address=0x102 Command=0x34 Raw-Data=0x6BCD0102 56 bits MSB first
|
||||
Send with: IrSender.sendMagiQuest(0x6BCD0102, 0x34, <numberOfRepeats>);
|
||||
|
||||
Protocol=BoseWave Address=0x0 Command=0x34 Raw-Data=0xCB34 16 bits LSB first
|
||||
Send with: IrSender.sendBoseWave(0x0, 0x34, <numberOfRepeats>);
|
||||
|
||||
Protocol=FAST Address=0x0 Command=0x34 Raw-Data=0xCB34 16 bits LSB first
|
||||
Send with: IrSender.sendFAST(0x0, 0x34, <numberOfRepeats>);
|
||||
|
||||
Protocol=Lego Address=0x2 Command=0x14 Raw-Data=0x2148 16 bits MSB first
|
||||
Send with: IrSender.sendLego(0x2, 0x14, <numberOfRepeats>);
|
||||
|
||||
Protocol=Lego Address=0x2 Command=0x14 Auto-Repeat gap=180450us Raw-Data=0x2148 16 bits MSB first
|
||||
|
||||
Protocol=Lego Address=0x2 Command=0x14 Auto-Repeat gap=179350us Raw-Data=0x2148 16 bits MSB first
|
||||
|
||||
Protocol=Lego Address=0x2 Command=0x14 Auto-Repeat gap=179200us Raw-Data=0x2148 16 bits MSB first
|
||||
|
||||
Protocol=Lego Address=0x2 Command=0x14 Auto-Repeat gap=179150us Raw-Data=0x2148 16 bits MSB first
|
||||
|
||||
Overflow detected
|
||||
Try to increase the "RAW_BUFFER_LENGTH" value of 600 in ../src/ReceiveDemo.cpp
|
||||
|
||||
Protocol=NEC Address=0x3 Command=0x45 Raw-Data=0xBA45FC03 32 bits LSB first
|
||||
Send with: IrSender.sendNEC(0x3, 0x45, <numberOfRepeats>);
|
||||
|
||||
Protocol=NEC Address=0x3 Command=0x45 Repeat gap=43250us
|
||||
|
||||
Protocol=NEC Address=0x203 Command=0x45 Raw-Data=0xBA450203 32 bits LSB first
|
||||
Send with: IrSender.sendNEC(0x203, 0x45, <numberOfRepeats>);
|
||||
|
||||
Protocol=NEC Address=0x203 Command=0x45 Repeat gap=47550us
|
||||
|
||||
Protocol=NEC Address=0x203 Command=0x45 Raw-Data=0xBA450203 32 bits LSB first
|
||||
Send with: IrSender.sendNEC(0x203, 0x45, <numberOfRepeats>);
|
||||
|
||||
Protocol=NEC2 Address=0x203 Command=0x45 Repeat gap=46500us Raw-Data=0xBA450203 32 bits LSB first
|
||||
|
||||
Protocol=Onkyo Address=0x203 Command=0x6745 Raw-Data=0x67450203 32 bits LSB first
|
||||
Send with: IrSender.sendOnkyo(0x203, 0x6745, <numberOfRepeats>);
|
||||
|
||||
Protocol=Onkyo Address=0x203 Command=0x6745 Repeat gap=46550us
|
||||
|
||||
Protocol=Apple Address=0x3 Command=0x45 Raw-Data=0x34587EE 32 bits LSB first
|
||||
Send with: IrSender.sendApple(0x3, 0x45, <numberOfRepeats>);
|
||||
|
||||
Protocol=Apple Address=0x3 Command=0x45 Repeat gap=31550us
|
||||
|
||||
Protocol=Panasonic Address=0x203 Command=0x45 Raw-Data=0x55452030 48 bits LSB first
|
||||
Send with: IrSender.sendPanasonic(0x203, 0x45, <numberOfRepeats>);
|
||||
|
||||
Protocol=Panasonic Address=0x203 Command=0x45 Repeat gap=72550us Raw-Data=0x55452030 48 bits LSB first
|
||||
|
||||
Protocol=Kaseikyo Address=0x203 Command=0x45 Extra=0x4711 Raw-Data=0x56452033 48 bits LSB first
|
||||
Send with: IrSender.sendKaseikyo(0x203, 0x45, <numberOfRepeats>, 0x4711);
|
||||
|
||||
Protocol=Kaseikyo Address=0x203 Command=0x45 Extra=0x4711 Repeat gap=66750us Raw-Data=0x56452033 48 bits LSB first
|
||||
|
||||
Protocol=Kaseikyo_Denon Address=0x203 Command=0x45 Raw-Data=0x55452030 48 bits LSB first
|
||||
Send with: IrSender.sendKaseikyo_Denon(0x203, 0x45, <numberOfRepeats>);
|
||||
|
||||
Protocol=Kaseikyo_Denon Address=0x203 Command=0x45 Repeat gap=68300us Raw-Data=0x55452030 48 bits LSB first
|
||||
@@ -0,0 +1,349 @@
|
||||
/*
|
||||
* PinDefinitionsAndMore.h
|
||||
*
|
||||
* Contains pin definitions for IRremote examples for various platforms
|
||||
* as well as definitions for feedback LED and tone() and includes
|
||||
*
|
||||
* Copyright (C) 2021-2023 Armin Joachimsmeyer
|
||||
* armin.joachimsmeyer@gmail.com
|
||||
*
|
||||
* This file is part of IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
|
||||
*
|
||||
* Arduino-IRremote is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/gpl.html>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Pin mapping table for different platforms
|
||||
*
|
||||
* Platform IR input IR output Tone Core/Pin schema
|
||||
* --------------------------------------------------------------
|
||||
* DEFAULT/AVR 2 3 4 Arduino
|
||||
* ATtinyX5 0|PB0 4|PB4 3|PB3 ATTinyCore
|
||||
* ATtiny167 3|PA3 2|PA2 7|PA7 ATTinyCore
|
||||
* ATtiny167 9|PA3 8|PA2 5|PA7 Digispark original core
|
||||
* ATtiny84 |PB2 |PA4 |PA3 ATTinyCore
|
||||
* ATtiny88 3|PD3 4|PD4 9|PB1 ATTinyCore
|
||||
* ATtiny3217 18|PA1 19|PA2 20|PA3 MegaTinyCore
|
||||
* ATtiny1604 2 3|PA5 %
|
||||
* ATtiny816 14|PA1 16|PA3 1|PA5 MegaTinyCore
|
||||
* ATtiny1614 8|PA1 10|PA3 1|PA5 MegaTinyCore
|
||||
* SAMD21 3 4 5
|
||||
* ESP8266 14|D5 12|D6 %
|
||||
* ESP32 15 4 27
|
||||
* ESP32-C3 2 3 4
|
||||
* BluePill PA6 PA7 PA3
|
||||
* APOLLO3 11 12 5
|
||||
* RP2040 3|GPIO15 4|GPIO16 5|GPIO17
|
||||
*/
|
||||
//#define _IR_MEASURE_TIMING // For debugging purposes.
|
||||
|
||||
#if defined(__AVR__)
|
||||
#if defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__) // Digispark board. For use with ATTinyCore.
|
||||
#include "ATtinySerialOut.hpp" // TX is at pin 2 - Available as Arduino library "ATtinySerialOut". Saves 700 bytes program memory and 70 bytes RAM for ATtinyCore.
|
||||
#define IR_RECEIVE_PIN PIN_PB0
|
||||
#define IR_SEND_PIN PIN_PB4 // Pin 2 is serial output with ATtinySerialOut. Pin 1 is internal LED and Pin3 is USB+ with pullup on Digispark board.
|
||||
#define TONE_PIN PIN_PB3
|
||||
#define _IR_TIMING_TEST_PIN PIN_PB3
|
||||
|
||||
# elif defined(__AVR_ATtiny87__) || defined(__AVR_ATtiny167__) // Digispark pro board
|
||||
#include "ATtinySerialOut.hpp" // Available as Arduino library "ATtinySerialOut"
|
||||
// For ATtiny167 Pins PB6 and PA3 are usable as interrupt source.
|
||||
# if defined(ARDUINO_AVR_DIGISPARKPRO)
|
||||
// For use with Digispark original core
|
||||
#define IR_RECEIVE_PIN 9 // PA3 - on Digispark board labeled as pin 9
|
||||
//#define IR_RECEIVE_PIN 14 // PB6 / INT0 is connected to USB+ on DigisparkPro boards
|
||||
#define IR_SEND_PIN 8 // PA2 - on Digispark board labeled as pin 8
|
||||
#define TONE_PIN 5 // PA7 - on Digispark board labeled as pin 5
|
||||
#define _IR_TIMING_TEST_PIN 10 // PA4
|
||||
# else
|
||||
// For use with ATTinyCore
|
||||
#define IR_RECEIVE_PIN PIN_PA3 // On Digispark board labeled as pin 9 - INT0 is connected to USB+ on DigisparkPro boards
|
||||
#define IR_SEND_PIN PIN_PA2 // On Digispark board labeled as pin 8
|
||||
#define TONE_PIN PIN_PA7 // On Digispark board labeled as pin 5
|
||||
# endif
|
||||
|
||||
# elif defined(__AVR_ATtiny84__) // For use with ATTinyCore
|
||||
#include "ATtinySerialOut.hpp" // Available as Arduino library "ATtinySerialOut". Saves 128 bytes program memory.
|
||||
#define IR_RECEIVE_PIN PIN_PB2 // INT0
|
||||
#define IR_SEND_PIN PIN_PA4
|
||||
#define TONE_PIN PIN_PA3
|
||||
#define _IR_TIMING_TEST_PIN PIN_PA5
|
||||
|
||||
# elif defined(__AVR_ATtiny88__) // MH-ET Tiny88 board. For use with ATTinyCore.
|
||||
#include "ATtinySerialOut.hpp" // Available as Arduino library "ATtinySerialOut". Saves 128 bytes program memory.
|
||||
// Pin 6 is TX, pin 7 is RX
|
||||
#define IR_RECEIVE_PIN PIN_PD3 // 3 - INT1
|
||||
#define IR_SEND_PIN PIN_PD4 // 4
|
||||
#define TONE_PIN PIN_PB1 // 9
|
||||
#define _IR_TIMING_TEST_PIN PIN_PB0 // 8
|
||||
|
||||
# elif defined(__AVR_ATtiny1616__) || defined(__AVR_ATtiny3216__) || defined(__AVR_ATtiny3217__) // For use with megaTinyCore
|
||||
// Tiny Core Dev board
|
||||
// https://www.tindie.com/products/xkimi/tiny-core-16-dev-board-attiny1616/ - Out of Stock
|
||||
// https://www.tindie.com/products/xkimi/tiny-core-32-dev-board-attiny3217/ - Out of Stock
|
||||
#define IR_RECEIVE_PIN PIN_PA1 // use 18 instead of PIN_PA1 for TinyCore32
|
||||
#define IR_SEND_PIN PIN_PA2 // 19
|
||||
#define TONE_PIN PIN_PA3 // 20
|
||||
#define APPLICATION_PIN PIN_PA0 // 0
|
||||
#undef LED_BUILTIN // No LED available on the TinyCore 32 board, take the one on the programming board which is connected to the DAC output
|
||||
#define LED_BUILTIN PIN_PA6 // use 2 instead of PIN_PA6 for TinyCore32
|
||||
|
||||
# elif defined(__AVR_ATtiny816__) // For use with megaTinyCore
|
||||
#define IR_RECEIVE_PIN PIN_PA1 // 14
|
||||
#define IR_SEND_PIN PIN_PA1 // 16
|
||||
#define TONE_PIN PIN_PA5 // 1
|
||||
#define APPLICATION_PIN PIN_PA4 // 0
|
||||
#undef LED_BUILTIN // No LED available, take the one which is connected to the DAC output
|
||||
#define LED_BUILTIN PIN_PB5 // 4
|
||||
|
||||
# elif defined(__AVR_ATtiny1614__) // For use with megaTinyCore
|
||||
#define IR_RECEIVE_PIN PIN_PA1 // 8
|
||||
#define IR_SEND_PIN PIN_PA3 // 10
|
||||
#define TONE_PIN PIN_PA5 // 1
|
||||
#define APPLICATION_PIN PIN_PA4 // 0
|
||||
|
||||
# elif defined(__AVR_ATtiny1604__) // For use with megaTinyCore
|
||||
#define IR_RECEIVE_PIN PIN_PA6 // 2 - To be compatible with interrupt example, pin 2 is chosen here.
|
||||
#define IR_SEND_PIN PIN_PA7 // 3
|
||||
#define APPLICATION_PIN PIN_PB2 // 5
|
||||
|
||||
#define tone(...) void() // Define as void, since TCB0_INT_vect is also used by tone()
|
||||
#define noTone(a) void()
|
||||
#define TONE_PIN 42 // Dummy for examples using it
|
||||
|
||||
# elif defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) \
|
||||
|| defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) \
|
||||
|| defined(__AVR_ATmega324P__) || defined(__AVR_ATmega324A__) \
|
||||
|| defined(__AVR_ATmega324PA__) || defined(__AVR_ATmega164A__) \
|
||||
|| defined(__AVR_ATmega164P__) || defined(__AVR_ATmega32__) \
|
||||
|| defined(__AVR_ATmega16__) || defined(__AVR_ATmega8535__) \
|
||||
|| defined(__AVR_ATmega64__) || defined(__AVR_ATmega128__) \
|
||||
|| defined(__AVR_ATmega1281__) || defined(__AVR_ATmega2561__) \
|
||||
|| defined(__AVR_ATmega8515__) || defined(__AVR_ATmega162__)
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 13
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
# else // Default as for ATmega328 like on Uno, Nano, Leonardo, Teensy 2.0 etc.
|
||||
#define IR_RECEIVE_PIN 2 // To be compatible with interrupt example, pin 2 is chosen here.
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
# if defined(ARDUINO_AVR_PROMICRO) // Sparkfun Pro Micro is __AVR_ATmega32U4__ but has different external circuit
|
||||
// We have no built in LED at pin 13 -> reuse RX LED
|
||||
#undef LED_BUILTIN
|
||||
#define LED_BUILTIN LED_BUILTIN_RX
|
||||
# endif
|
||||
# endif // defined(__AVR_ATtiny25__)...
|
||||
|
||||
#elif defined(ARDUINO_ARCH_RENESAS_UNO) // Uno R4
|
||||
// To be compatible with Uno R3.
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
#elif defined(ESP8266)
|
||||
#define FEEDBACK_LED_IS_ACTIVE_LOW // The LED on my board (D4) is active LOW
|
||||
#define IR_RECEIVE_PIN 14 // D5
|
||||
#define IR_SEND_PIN 12 // D6 - D4/pin 2 is internal LED
|
||||
#define _IR_TIMING_TEST_PIN 2 // D4
|
||||
#define APPLICATION_PIN 13 // D7
|
||||
|
||||
#define tone(...) void() // tone() inhibits receive timer
|
||||
#define noTone(a) void()
|
||||
#define TONE_PIN 42 // Dummy for examples using it#
|
||||
|
||||
#elif defined(ARDUINO_NOLOGO_ESP32C3_SUPER_MINI)
|
||||
#define FEEDBACK_LED_IS_ACTIVE_LOW // The LED on my board (D8) is active LOW
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 10
|
||||
|
||||
#elif defined(CONFIG_IDF_TARGET_ESP32C3) || defined(ARDUINO_ESP32C3_DEV)
|
||||
#define NO_LED_FEEDBACK_CODE // The WS2812 on pin 8 of AI-C3 board crashes if used as receive feedback LED, other I/O pins are working...
|
||||
#define IR_RECEIVE_PIN 6
|
||||
#define IR_SEND_PIN 7
|
||||
#define TONE_PIN 10
|
||||
#define APPLICATION_PIN 18
|
||||
|
||||
#elif defined(ESP32)
|
||||
#include <Arduino.h>
|
||||
|
||||
// tone() is included in ESP32 core since 2.0.2
|
||||
#if !defined(ESP_ARDUINO_VERSION_VAL)
|
||||
#define ESP_ARDUINO_VERSION_VAL(major, minor, patch) 12345678
|
||||
#endif
|
||||
#if ESP_ARDUINO_VERSION <= ESP_ARDUINO_VERSION_VAL(2, 0, 2)
|
||||
#define TONE_LEDC_CHANNEL 1 // Using channel 1 makes tone() independent of receiving timer -> No need to stop receiving timer.
|
||||
void tone(uint8_t aPinNumber, unsigned int aFrequency){
|
||||
ledcAttachPin(aPinNumber, TONE_LEDC_CHANNEL);
|
||||
ledcWriteTone(TONE_LEDC_CHANNEL, aFrequency);
|
||||
}
|
||||
void tone(uint8_t aPinNumber, unsigned int aFrequency, unsigned long aDuration){
|
||||
ledcAttachPin(aPinNumber, TONE_LEDC_CHANNEL);
|
||||
ledcWriteTone(TONE_LEDC_CHANNEL, aFrequency);
|
||||
delay(aDuration);
|
||||
ledcWriteTone(TONE_LEDC_CHANNEL, 0);
|
||||
}
|
||||
void noTone(uint8_t aPinNumber){
|
||||
ledcWriteTone(TONE_LEDC_CHANNEL, 0);
|
||||
}
|
||||
#endif // ESP_ARDUINO_VERSION <= ESP_ARDUINO_VERSION_VAL(2, 0, 2)
|
||||
|
||||
#define IR_RECEIVE_PIN 15 // D15
|
||||
#define IR_SEND_PIN 4 // D4
|
||||
#define TONE_PIN 27 // D27 25 & 26 are DAC0 and 1
|
||||
#define APPLICATION_PIN 16 // RX2 pin
|
||||
|
||||
#elif defined(ARDUINO_ARCH_STM32) || defined(ARDUINO_ARCH_STM32F1) // BluePill
|
||||
// Timer 3 blocks PA6, PA7, PB0, PB1 for use by Servo or tone()
|
||||
#define IR_RECEIVE_PIN PA6
|
||||
#define IR_RECEIVE_PIN_STRING "PA6"
|
||||
#define IR_SEND_PIN PA7
|
||||
#define IR_SEND_PIN_STRING "PA7"
|
||||
#define TONE_PIN PA3
|
||||
#define _IR_TIMING_TEST_PIN PA5
|
||||
#define APPLICATION_PIN PA2
|
||||
#define APPLICATION_PIN_STRING "PA2"
|
||||
# if defined(ARDUINO_GENERIC_STM32F103C) || defined(ARDUINO_BLUEPILL_F103C8)
|
||||
// BluePill LED is active low
|
||||
#define FEEDBACK_LED_IS_ACTIVE_LOW
|
||||
# endif
|
||||
|
||||
#elif defined(ARDUINO_ARCH_APOLLO3) // Sparkfun Apollo boards
|
||||
#define IR_RECEIVE_PIN 11
|
||||
#define IR_SEND_PIN 12
|
||||
#define TONE_PIN 5
|
||||
|
||||
#elif defined(ARDUINO_ARCH_MBED) && defined(ARDUINO_ARCH_MBED_NANO) // Arduino Nano 33 BLE and Arduino Nano Connect layout for MBED
|
||||
// Must be before ARDUINO_ARCH_RP2040, since it is the layout for the MBED core of Arduino Nano Connect
|
||||
#define IR_RECEIVE_PIN 3 // GPIO15 Start with pin 3 since pin 2|GPIO25 is connected to LED on Pi pico
|
||||
#define IR_SEND_PIN 4 // GPIO16
|
||||
#define TONE_PIN 5
|
||||
#define APPLICATION_PIN 6
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 7 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 8
|
||||
|
||||
#elif defined(ARDUINO_ARCH_RP2040) // Arduino Nano Connect, Pi Pico with arduino-pico core https://github.com/earlephilhower/arduino-pico
|
||||
#define IR_RECEIVE_PIN 15 // GPIO15 to be compatible with the Arduino Nano RP2040 Connect (pin3)
|
||||
#define IR_SEND_PIN 16 // GPIO16
|
||||
#define TONE_PIN 17
|
||||
#define APPLICATION_PIN 18
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 19 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 20
|
||||
|
||||
// If you program the Nano RP2040 Connect with this core, then you must redefine LED_BUILTIN
|
||||
// and use the external reset with 1 kOhm to ground to enter UF2 mode
|
||||
#undef LED_BUILTIN
|
||||
#define LED_BUILTIN 6
|
||||
|
||||
#elif defined(PARTICLE) // !!!UNTESTED!!!
|
||||
#define IR_RECEIVE_PIN A4
|
||||
#define IR_SEND_PIN A5 // Particle supports multiple pins
|
||||
|
||||
#define LED_BUILTIN D7
|
||||
|
||||
/*
|
||||
* 4 times the same (default) layout for easy adaption in the future
|
||||
*/
|
||||
#elif defined(TEENSYDUINO) // Teensy 2.0 is handled at default for ATmega328 like on Uno, Nano, Leonardo etc.
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
#elif defined(ARDUINO_ARCH_MBED) // Arduino Nano 33 BLE
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
#elif defined(ARDUINO_ARCH_SAMD) || defined(ARDUINO_ARCH_SAM)
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
#if !defined(ARDUINO_SAMD_ADAFRUIT) && !defined(ARDUINO_SEEED_XIAO_M0)
|
||||
// On the Zero and others we switch explicitly to SerialUSB
|
||||
#define Serial SerialUSB
|
||||
#endif
|
||||
|
||||
// Definitions for the Chinese SAMD21 M0-Mini clone, which has no led connected to D13/PA17.
|
||||
// Attention!!! D2 and D4 are swapped on these boards!!!
|
||||
// If you connect the LED, it is on pin 24/PB11. In this case activate the next two lines.
|
||||
//#undef LED_BUILTIN
|
||||
//#define LED_BUILTIN 24 // PB11
|
||||
// As an alternative you can choose pin 25, it is the RX-LED pin (PB03), but active low.In this case activate the next 3 lines.
|
||||
//#undef LED_BUILTIN
|
||||
//#define LED_BUILTIN 25 // PB03
|
||||
//#define FEEDBACK_LED_IS_ACTIVE_LOW // The RX LED on the M0-Mini is active LOW
|
||||
|
||||
#elif defined (NRF51) // BBC micro:bit
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define APPLICATION_PIN 1
|
||||
#define _IR_TIMING_TEST_PIN 4
|
||||
|
||||
#define tone(...) void() // no tone() available
|
||||
#define noTone(a) void()
|
||||
#define TONE_PIN 42 // Dummy for examples using it
|
||||
|
||||
#else
|
||||
#warning Board / CPU is not detected using pre-processor symbols -> using default values, which may not fit. Please extend PinDefinitionsAndMore.h.
|
||||
// Default valued for unidentified boards
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
#endif // defined(ESP8266)
|
||||
|
||||
#if defined(ESP32) || defined(ARDUINO_ARCH_RP2040) || defined(PARTICLE) || defined(ARDUINO_ARCH_MBED)
|
||||
#define SEND_PWM_BY_TIMER // We do not have pin restrictions for this CPU's, so lets use the hardware PWM for send carrier signal generation
|
||||
#else
|
||||
# if defined(SEND_PWM_BY_TIMER)
|
||||
#undef IR_SEND_PIN // SendPin is determined by timer! This avoids warnings in IRremote.hpp and IRTimer.hpp
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if !defined (FLASHEND)
|
||||
#define FLASHEND 0xFFFF // Dummy value for platforms where FLASHEND is not defined
|
||||
#endif
|
||||
|
||||
/*
|
||||
* 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
|
||||
@@ -0,0 +1,230 @@
|
||||
/*
|
||||
* ReceiveDemo.cpp
|
||||
*
|
||||
* Demonstrates receiving IR codes with the IRremote library and the use of the Arduino tone() function with this library.
|
||||
* Long press of one IR button (receiving of multiple repeats for one command) is detected.
|
||||
* If debug button is pressed (pin connected to ground) a long output is generated, which may disturb detecting of repeats.
|
||||
*
|
||||
* This file is part of Arduino-IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
|
||||
*
|
||||
************************************************************************************
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2020-2024 Armin Joachimsmeyer
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is furnished
|
||||
* to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
************************************************************************************
|
||||
*/
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
/*
|
||||
* Specify which protocol(s) should be used for decoding.
|
||||
* If no protocol is defined, all protocols (except Bang&Olufsen) are active.
|
||||
* This must be done before the #include <IRremote.hpp>
|
||||
*/
|
||||
//#define DECODE_DENON // Includes Sharp
|
||||
//#define DECODE_JVC
|
||||
//#define DECODE_KASEIKYO
|
||||
//#define DECODE_PANASONIC // alias for DECODE_KASEIKYO
|
||||
//#define DECODE_LG
|
||||
//#define DECODE_ONKYO // Decodes only Onkyo and not NEC or Apple
|
||||
//#define DECODE_NEC // Includes Apple and Onkyo
|
||||
//#define DECODE_SAMSUNG
|
||||
//#define DECODE_SONY
|
||||
//#define DECODE_RC5
|
||||
//#define DECODE_RC6
|
||||
//#define DECODE_BOSEWAVE
|
||||
//#define DECODE_LEGO_PF
|
||||
//#define DECODE_MAGIQUEST
|
||||
//#define DECODE_WHYNTER
|
||||
//#define DECODE_FAST
|
||||
//#define DECODE_DISTANCE_WIDTH // Universal decoder for pulse distance width protocols
|
||||
//#define DECODE_HASH // special decoder for all protocols
|
||||
//#define DECODE_BEO // This protocol must always be enabled manually, i.e. it is NOT enabled if no protocol is defined. It prevents decoding of SONY!
|
||||
// etc. see IRremote.hpp
|
||||
//
|
||||
|
||||
|
||||
//#define NO_LED_FEEDBACK_CODE // saves 92 bytes program memory
|
||||
//#define EXCLUDE_UNIVERSAL_PROTOCOLS // Saves up to 1000 bytes program memory.
|
||||
//#define EXCLUDE_EXOTIC_PROTOCOLS // saves around 650 bytes program memory if all other protocols are active
|
||||
//#define IR_REMOTE_DISABLE_RECEIVE_COMPLETE_CALLBACK // saves 32 bytes program memory
|
||||
|
||||
// MARK_EXCESS_MICROS is subtracted from all marks and added to all spaces before decoding,
|
||||
// to compensate for the signal forming of different IR receiver modules. See also IRremote.hpp line 142.
|
||||
//#define MARK_EXCESS_MICROS 20 // Adapt it to your IR receiver module. 40 is taken for the cheap VS1838 module her, since we have high intensity.
|
||||
|
||||
#if defined(DECODE_BEO)
|
||||
#define RECORD_GAP_MICROS 16000 // always get the complete frame in the receive buffer, but this prevents decoding of SONY!
|
||||
#endif
|
||||
//#define RECORD_GAP_MICROS 12000 // Default is 8000. Activate it for some LG air conditioner protocols
|
||||
|
||||
//#define DEBUG // Activate this for lots of lovely debug output from the decoders.
|
||||
|
||||
#include <IRremote.hpp>
|
||||
|
||||
#define STR_HELPER(x) #x
|
||||
#define STR(x) STR_HELPER(x)
|
||||
|
||||
#define IR_RECEIVE_PIN 4 // P0_1
|
||||
|
||||
|
||||
void handleOverflow();
|
||||
bool detectLongPress(uint16_t aLongPressDurationMillis);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
while (!Serial)
|
||||
; // Wait for Serial to become available. Is optimized away for some cores.
|
||||
|
||||
// Just to know which program is running on my Arduino
|
||||
Serial.println(F("START " __FILE__ " from " __DATE__ "\r\nUsing library version " VERSION_IRREMOTE));
|
||||
|
||||
// In case the interrupt driver crashes on setup, give a clue
|
||||
// to the user what's going on.
|
||||
Serial.println(F("Enabling IRin..."));
|
||||
|
||||
// Start the receiver and if not 3. parameter specified, take LED_BUILTIN pin from the internal boards definition as default feedback LED
|
||||
IrReceiver.begin(IR_RECEIVE_PIN, ENABLE_LED_FEEDBACK);
|
||||
|
||||
Serial.print(F("Ready to receive IR signals of protocols: "));
|
||||
printActiveIRProtocols(&Serial);
|
||||
Serial.println(F("at pin " STR(IR_RECEIVE_PIN)));
|
||||
|
||||
Serial.print(F("FeedbackLED at pin "));
|
||||
Serial.println(LED_BUILTIN); // Works also for ESP32: static const uint8_t LED_BUILTIN = 8; #define LED_BUILTIN LED_BUILTIN
|
||||
|
||||
// infos for receive
|
||||
Serial.print(RECORD_GAP_MICROS);
|
||||
Serial.println(F(" us is the (minimum) gap, after which the start of a new IR packet is assumed"));
|
||||
Serial.print(MARK_EXCESS_MICROS);
|
||||
Serial.println(F(" us are subtracted from all marks and added to all spaces for decoding"));
|
||||
}
|
||||
|
||||
void loop() {
|
||||
/*
|
||||
* Check if received data is available and if yes, try to decode it.
|
||||
* Decoded result is in the IrReceiver.decodedIRData structure.
|
||||
*
|
||||
* E.g. command is in IrReceiver.decodedIRData.command
|
||||
* address is in command is in IrReceiver.decodedIRData.address
|
||||
* and up to 32 bit raw data in IrReceiver.decodedIRData.decodedRawData
|
||||
*/
|
||||
if (IrReceiver.decode()) {
|
||||
Serial.println();
|
||||
|
||||
if (IrReceiver.decodedIRData.flags & IRDATA_FLAGS_WAS_OVERFLOW) {
|
||||
handleOverflow();
|
||||
} else {
|
||||
/*
|
||||
* No overflow here.
|
||||
* Stop receiver, print short info and send usage and start receiver again
|
||||
*/
|
||||
|
||||
if (IrReceiver.decodedIRData.protocol == UNKNOWN)
|
||||
{
|
||||
// We have debug enabled or an unknown protocol, print extended info
|
||||
if (IrReceiver.decodedIRData.protocol == UNKNOWN) {
|
||||
Serial.println(F("Received noise or an unknown (or not yet enabled) protocol"));
|
||||
}
|
||||
IrReceiver.printIRResultRawFormatted(&Serial, true);
|
||||
}
|
||||
if (IrReceiver.decodedIRData.protocol != UNKNOWN)
|
||||
{
|
||||
/*
|
||||
* The info output for a successful receive
|
||||
*/
|
||||
IrReceiver.printIRResultShort(&Serial);
|
||||
IrReceiver.printIRSendUsage(&Serial);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* !!!Important!!! Enable receiving of the next value, because receiving
|
||||
* has stopped after the end of the current received data packet.
|
||||
* Do it here, to preserve raw data for printing with printIRResultRawFormatted()
|
||||
*/
|
||||
IrReceiver.resume();
|
||||
|
||||
/*
|
||||
* Finally check the received data and perform actions according to the received address and commands
|
||||
*/
|
||||
if (IrReceiver.decodedIRData.address == 0) {
|
||||
if (IrReceiver.decodedIRData.command == 0x10) {
|
||||
// do something
|
||||
} else if (IrReceiver.decodedIRData.command == 0x11) {
|
||||
// do something else
|
||||
}
|
||||
}
|
||||
|
||||
// Check if repeats of the IR command was sent for more than 1000 ms
|
||||
if (detectLongPress(1000)) {
|
||||
Serial.print(F("Command 0x"));
|
||||
Serial.print(IrReceiver.decodedIRData.command, HEX);
|
||||
Serial.println(F(" was repeated for more than 2 seconds"));
|
||||
}
|
||||
} // if (IrReceiver.decode())
|
||||
|
||||
/*
|
||||
* Your code here
|
||||
* For all users of the FastLed library, use this code for strip.show() to improve receiving performance (which is still not 100%):
|
||||
* if (IrReceiver.isIdle()) {
|
||||
* strip.show();
|
||||
* }
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
void handleOverflow() {
|
||||
Serial.println(F("Overflow detected"));
|
||||
Serial.println(F("Try to increase the \"RAW_BUFFER_LENGTH\" value of " STR(RAW_BUFFER_LENGTH) " in " __FILE__));
|
||||
// see also https://github.com/Arduino-IRremote/Arduino-IRremote#compile-options--macros-for-this-library
|
||||
|
||||
IrReceiver.stopTimer();
|
||||
// tone(TONE_PIN, 1100, 10);
|
||||
// delay(50);
|
||||
// tone(TONE_PIN, 1100, 10);
|
||||
delay(50);
|
||||
IrReceiver.restartTimer();
|
||||
}
|
||||
|
||||
unsigned long sMillisOfFirstReceive;
|
||||
bool sLongPressJustDetected;
|
||||
/**
|
||||
* True once we received the consecutive repeats for more than aLongPressDurationMillis milliseconds.
|
||||
* The first frame, which is no repeat, is NOT counted for the duration!
|
||||
* @return true once after the repeated IR command was received for longer than aLongPressDurationMillis milliseconds, false otherwise.
|
||||
*/
|
||||
bool detectLongPress(uint16_t aLongPressDurationMillis) {
|
||||
if (!sLongPressJustDetected && (IrReceiver.decodedIRData.flags & IRDATA_FLAGS_IS_REPEAT)) {
|
||||
/*
|
||||
* Here the repeat flag is set (which implies, that command is the same as the previous one)
|
||||
*/
|
||||
if (millis() - aLongPressDurationMillis > sMillisOfFirstReceive) {
|
||||
sLongPressJustDetected = true; // Long press here
|
||||
}
|
||||
} else {
|
||||
// No repeat here
|
||||
sMillisOfFirstReceive = millis();
|
||||
sLongPressJustDetected = false;
|
||||
}
|
||||
return sLongPressJustDetected; // No long press here
|
||||
}
|
||||
|
||||
@@ -0,0 +1,349 @@
|
||||
/*
|
||||
* PinDefinitionsAndMore.h
|
||||
*
|
||||
* Contains pin definitions for IRremote examples for various platforms
|
||||
* as well as definitions for feedback LED and tone() and includes
|
||||
*
|
||||
* Copyright (C) 2021-2023 Armin Joachimsmeyer
|
||||
* armin.joachimsmeyer@gmail.com
|
||||
*
|
||||
* This file is part of IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
|
||||
*
|
||||
* Arduino-IRremote is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/gpl.html>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Pin mapping table for different platforms
|
||||
*
|
||||
* Platform IR input IR output Tone Core/Pin schema
|
||||
* --------------------------------------------------------------
|
||||
* DEFAULT/AVR 2 3 4 Arduino
|
||||
* ATtinyX5 0|PB0 4|PB4 3|PB3 ATTinyCore
|
||||
* ATtiny167 3|PA3 2|PA2 7|PA7 ATTinyCore
|
||||
* ATtiny167 9|PA3 8|PA2 5|PA7 Digispark original core
|
||||
* ATtiny84 |PB2 |PA4 |PA3 ATTinyCore
|
||||
* ATtiny88 3|PD3 4|PD4 9|PB1 ATTinyCore
|
||||
* ATtiny3217 18|PA1 19|PA2 20|PA3 MegaTinyCore
|
||||
* ATtiny1604 2 3|PA5 %
|
||||
* ATtiny816 14|PA1 16|PA3 1|PA5 MegaTinyCore
|
||||
* ATtiny1614 8|PA1 10|PA3 1|PA5 MegaTinyCore
|
||||
* SAMD21 3 4 5
|
||||
* ESP8266 14|D5 12|D6 %
|
||||
* ESP32 15 4 27
|
||||
* ESP32-C3 2 3 4
|
||||
* BluePill PA6 PA7 PA3
|
||||
* APOLLO3 11 12 5
|
||||
* RP2040 3|GPIO15 4|GPIO16 5|GPIO17
|
||||
*/
|
||||
//#define _IR_MEASURE_TIMING // For debugging purposes.
|
||||
|
||||
#if defined(__AVR__)
|
||||
#if defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__) // Digispark board. For use with ATTinyCore.
|
||||
#include "ATtinySerialOut.hpp" // TX is at pin 2 - Available as Arduino library "ATtinySerialOut". Saves 700 bytes program memory and 70 bytes RAM for ATtinyCore.
|
||||
#define IR_RECEIVE_PIN PIN_PB0
|
||||
#define IR_SEND_PIN PIN_PB4 // Pin 2 is serial output with ATtinySerialOut. Pin 1 is internal LED and Pin3 is USB+ with pullup on Digispark board.
|
||||
#define TONE_PIN PIN_PB3
|
||||
#define _IR_TIMING_TEST_PIN PIN_PB3
|
||||
|
||||
# elif defined(__AVR_ATtiny87__) || defined(__AVR_ATtiny167__) // Digispark pro board
|
||||
#include "ATtinySerialOut.hpp" // Available as Arduino library "ATtinySerialOut"
|
||||
// For ATtiny167 Pins PB6 and PA3 are usable as interrupt source.
|
||||
# if defined(ARDUINO_AVR_DIGISPARKPRO)
|
||||
// For use with Digispark original core
|
||||
#define IR_RECEIVE_PIN 9 // PA3 - on Digispark board labeled as pin 9
|
||||
//#define IR_RECEIVE_PIN 14 // PB6 / INT0 is connected to USB+ on DigisparkPro boards
|
||||
#define IR_SEND_PIN 8 // PA2 - on Digispark board labeled as pin 8
|
||||
#define TONE_PIN 5 // PA7 - on Digispark board labeled as pin 5
|
||||
#define _IR_TIMING_TEST_PIN 10 // PA4
|
||||
# else
|
||||
// For use with ATTinyCore
|
||||
#define IR_RECEIVE_PIN PIN_PA3 // On Digispark board labeled as pin 9 - INT0 is connected to USB+ on DigisparkPro boards
|
||||
#define IR_SEND_PIN PIN_PA2 // On Digispark board labeled as pin 8
|
||||
#define TONE_PIN PIN_PA7 // On Digispark board labeled as pin 5
|
||||
# endif
|
||||
|
||||
# elif defined(__AVR_ATtiny84__) // For use with ATTinyCore
|
||||
#include "ATtinySerialOut.hpp" // Available as Arduino library "ATtinySerialOut". Saves 128 bytes program memory.
|
||||
#define IR_RECEIVE_PIN PIN_PB2 // INT0
|
||||
#define IR_SEND_PIN PIN_PA4
|
||||
#define TONE_PIN PIN_PA3
|
||||
#define _IR_TIMING_TEST_PIN PIN_PA5
|
||||
|
||||
# elif defined(__AVR_ATtiny88__) // MH-ET Tiny88 board. For use with ATTinyCore.
|
||||
#include "ATtinySerialOut.hpp" // Available as Arduino library "ATtinySerialOut". Saves 128 bytes program memory.
|
||||
// Pin 6 is TX, pin 7 is RX
|
||||
#define IR_RECEIVE_PIN PIN_PD3 // 3 - INT1
|
||||
#define IR_SEND_PIN PIN_PD4 // 4
|
||||
#define TONE_PIN PIN_PB1 // 9
|
||||
#define _IR_TIMING_TEST_PIN PIN_PB0 // 8
|
||||
|
||||
# elif defined(__AVR_ATtiny1616__) || defined(__AVR_ATtiny3216__) || defined(__AVR_ATtiny3217__) // For use with megaTinyCore
|
||||
// Tiny Core Dev board
|
||||
// https://www.tindie.com/products/xkimi/tiny-core-16-dev-board-attiny1616/ - Out of Stock
|
||||
// https://www.tindie.com/products/xkimi/tiny-core-32-dev-board-attiny3217/ - Out of Stock
|
||||
#define IR_RECEIVE_PIN PIN_PA1 // use 18 instead of PIN_PA1 for TinyCore32
|
||||
#define IR_SEND_PIN PIN_PA2 // 19
|
||||
#define TONE_PIN PIN_PA3 // 20
|
||||
#define APPLICATION_PIN PIN_PA0 // 0
|
||||
#undef LED_BUILTIN // No LED available on the TinyCore 32 board, take the one on the programming board which is connected to the DAC output
|
||||
#define LED_BUILTIN PIN_PA6 // use 2 instead of PIN_PA6 for TinyCore32
|
||||
|
||||
# elif defined(__AVR_ATtiny816__) // For use with megaTinyCore
|
||||
#define IR_RECEIVE_PIN PIN_PA1 // 14
|
||||
#define IR_SEND_PIN PIN_PA1 // 16
|
||||
#define TONE_PIN PIN_PA5 // 1
|
||||
#define APPLICATION_PIN PIN_PA4 // 0
|
||||
#undef LED_BUILTIN // No LED available, take the one which is connected to the DAC output
|
||||
#define LED_BUILTIN PIN_PB5 // 4
|
||||
|
||||
# elif defined(__AVR_ATtiny1614__) // For use with megaTinyCore
|
||||
#define IR_RECEIVE_PIN PIN_PA1 // 8
|
||||
#define IR_SEND_PIN PIN_PA3 // 10
|
||||
#define TONE_PIN PIN_PA5 // 1
|
||||
#define APPLICATION_PIN PIN_PA4 // 0
|
||||
|
||||
# elif defined(__AVR_ATtiny1604__) // For use with megaTinyCore
|
||||
#define IR_RECEIVE_PIN PIN_PA6 // 2 - To be compatible with interrupt example, pin 2 is chosen here.
|
||||
#define IR_SEND_PIN PIN_PA7 // 3
|
||||
#define APPLICATION_PIN PIN_PB2 // 5
|
||||
|
||||
#define tone(...) void() // Define as void, since TCB0_INT_vect is also used by tone()
|
||||
#define noTone(a) void()
|
||||
#define TONE_PIN 42 // Dummy for examples using it
|
||||
|
||||
# elif defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) \
|
||||
|| defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) \
|
||||
|| defined(__AVR_ATmega324P__) || defined(__AVR_ATmega324A__) \
|
||||
|| defined(__AVR_ATmega324PA__) || defined(__AVR_ATmega164A__) \
|
||||
|| defined(__AVR_ATmega164P__) || defined(__AVR_ATmega32__) \
|
||||
|| defined(__AVR_ATmega16__) || defined(__AVR_ATmega8535__) \
|
||||
|| defined(__AVR_ATmega64__) || defined(__AVR_ATmega128__) \
|
||||
|| defined(__AVR_ATmega1281__) || defined(__AVR_ATmega2561__) \
|
||||
|| defined(__AVR_ATmega8515__) || defined(__AVR_ATmega162__)
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 13
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
# else // Default as for ATmega328 like on Uno, Nano, Leonardo, Teensy 2.0 etc.
|
||||
#define IR_RECEIVE_PIN 2 // To be compatible with interrupt example, pin 2 is chosen here.
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
# if defined(ARDUINO_AVR_PROMICRO) // Sparkfun Pro Micro is __AVR_ATmega32U4__ but has different external circuit
|
||||
// We have no built in LED at pin 13 -> reuse RX LED
|
||||
#undef LED_BUILTIN
|
||||
#define LED_BUILTIN LED_BUILTIN_RX
|
||||
# endif
|
||||
# endif // defined(__AVR_ATtiny25__)...
|
||||
|
||||
#elif defined(ARDUINO_ARCH_RENESAS_UNO) // Uno R4
|
||||
// To be compatible with Uno R3.
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
#elif defined(ESP8266)
|
||||
#define FEEDBACK_LED_IS_ACTIVE_LOW // The LED on my board (D4) is active LOW
|
||||
#define IR_RECEIVE_PIN 14 // D5
|
||||
#define IR_SEND_PIN 12 // D6 - D4/pin 2 is internal LED
|
||||
#define _IR_TIMING_TEST_PIN 2 // D4
|
||||
#define APPLICATION_PIN 13 // D7
|
||||
|
||||
#define tone(...) void() // tone() inhibits receive timer
|
||||
#define noTone(a) void()
|
||||
#define TONE_PIN 42 // Dummy for examples using it#
|
||||
|
||||
#elif defined(ARDUINO_NOLOGO_ESP32C3_SUPER_MINI)
|
||||
#define FEEDBACK_LED_IS_ACTIVE_LOW // The LED on my board (D8) is active LOW
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 10
|
||||
|
||||
#elif defined(CONFIG_IDF_TARGET_ESP32C3) || defined(ARDUINO_ESP32C3_DEV)
|
||||
#define NO_LED_FEEDBACK_CODE // The WS2812 on pin 8 of AI-C3 board crashes if used as receive feedback LED, other I/O pins are working...
|
||||
#define IR_RECEIVE_PIN 6
|
||||
#define IR_SEND_PIN 7
|
||||
#define TONE_PIN 10
|
||||
#define APPLICATION_PIN 18
|
||||
|
||||
#elif defined(ESP32)
|
||||
#include <Arduino.h>
|
||||
|
||||
// tone() is included in ESP32 core since 2.0.2
|
||||
#if !defined(ESP_ARDUINO_VERSION_VAL)
|
||||
#define ESP_ARDUINO_VERSION_VAL(major, minor, patch) 12345678
|
||||
#endif
|
||||
#if ESP_ARDUINO_VERSION <= ESP_ARDUINO_VERSION_VAL(2, 0, 2)
|
||||
#define TONE_LEDC_CHANNEL 1 // Using channel 1 makes tone() independent of receiving timer -> No need to stop receiving timer.
|
||||
void tone(uint8_t aPinNumber, unsigned int aFrequency){
|
||||
ledcAttachPin(aPinNumber, TONE_LEDC_CHANNEL);
|
||||
ledcWriteTone(TONE_LEDC_CHANNEL, aFrequency);
|
||||
}
|
||||
void tone(uint8_t aPinNumber, unsigned int aFrequency, unsigned long aDuration){
|
||||
ledcAttachPin(aPinNumber, TONE_LEDC_CHANNEL);
|
||||
ledcWriteTone(TONE_LEDC_CHANNEL, aFrequency);
|
||||
delay(aDuration);
|
||||
ledcWriteTone(TONE_LEDC_CHANNEL, 0);
|
||||
}
|
||||
void noTone(uint8_t aPinNumber){
|
||||
ledcWriteTone(TONE_LEDC_CHANNEL, 0);
|
||||
}
|
||||
#endif // ESP_ARDUINO_VERSION <= ESP_ARDUINO_VERSION_VAL(2, 0, 2)
|
||||
|
||||
#define IR_RECEIVE_PIN 15 // D15
|
||||
#define IR_SEND_PIN 4 // D4
|
||||
#define TONE_PIN 27 // D27 25 & 26 are DAC0 and 1
|
||||
#define APPLICATION_PIN 16 // RX2 pin
|
||||
|
||||
#elif defined(ARDUINO_ARCH_STM32) || defined(ARDUINO_ARCH_STM32F1) // BluePill
|
||||
// Timer 3 blocks PA6, PA7, PB0, PB1 for use by Servo or tone()
|
||||
#define IR_RECEIVE_PIN PA6
|
||||
#define IR_RECEIVE_PIN_STRING "PA6"
|
||||
#define IR_SEND_PIN PA7
|
||||
#define IR_SEND_PIN_STRING "PA7"
|
||||
#define TONE_PIN PA3
|
||||
#define _IR_TIMING_TEST_PIN PA5
|
||||
#define APPLICATION_PIN PA2
|
||||
#define APPLICATION_PIN_STRING "PA2"
|
||||
# if defined(ARDUINO_GENERIC_STM32F103C) || defined(ARDUINO_BLUEPILL_F103C8)
|
||||
// BluePill LED is active low
|
||||
#define FEEDBACK_LED_IS_ACTIVE_LOW
|
||||
# endif
|
||||
|
||||
#elif defined(ARDUINO_ARCH_APOLLO3) // Sparkfun Apollo boards
|
||||
#define IR_RECEIVE_PIN 11
|
||||
#define IR_SEND_PIN 12
|
||||
#define TONE_PIN 5
|
||||
|
||||
#elif defined(ARDUINO_ARCH_MBED) && defined(ARDUINO_ARCH_MBED_NANO) // Arduino Nano 33 BLE and Arduino Nano Connect layout for MBED
|
||||
// Must be before ARDUINO_ARCH_RP2040, since it is the layout for the MBED core of Arduino Nano Connect
|
||||
#define IR_RECEIVE_PIN 3 // GPIO15 Start with pin 3 since pin 2|GPIO25 is connected to LED on Pi pico
|
||||
#define IR_SEND_PIN 4 // GPIO16
|
||||
#define TONE_PIN 5
|
||||
#define APPLICATION_PIN 6
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 7 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 8
|
||||
|
||||
#elif defined(ARDUINO_ARCH_RP2040) // Arduino Nano Connect, Pi Pico with arduino-pico core https://github.com/earlephilhower/arduino-pico
|
||||
#define IR_RECEIVE_PIN 15 // GPIO15 to be compatible with the Arduino Nano RP2040 Connect (pin3)
|
||||
#define IR_SEND_PIN 16 // GPIO16
|
||||
#define TONE_PIN 17
|
||||
#define APPLICATION_PIN 18
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 19 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 20
|
||||
|
||||
// If you program the Nano RP2040 Connect with this core, then you must redefine LED_BUILTIN
|
||||
// and use the external reset with 1 kOhm to ground to enter UF2 mode
|
||||
#undef LED_BUILTIN
|
||||
#define LED_BUILTIN 6
|
||||
|
||||
#elif defined(PARTICLE) // !!!UNTESTED!!!
|
||||
#define IR_RECEIVE_PIN A4
|
||||
#define IR_SEND_PIN A5 // Particle supports multiple pins
|
||||
|
||||
#define LED_BUILTIN D7
|
||||
|
||||
/*
|
||||
* 4 times the same (default) layout for easy adaption in the future
|
||||
*/
|
||||
#elif defined(TEENSYDUINO) // Teensy 2.0 is handled at default for ATmega328 like on Uno, Nano, Leonardo etc.
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
#elif defined(ARDUINO_ARCH_MBED) // Arduino Nano 33 BLE
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
#elif defined(ARDUINO_ARCH_SAMD) || defined(ARDUINO_ARCH_SAM)
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
#if !defined(ARDUINO_SAMD_ADAFRUIT) && !defined(ARDUINO_SEEED_XIAO_M0)
|
||||
// On the Zero and others we switch explicitly to SerialUSB
|
||||
#define Serial SerialUSB
|
||||
#endif
|
||||
|
||||
// Definitions for the Chinese SAMD21 M0-Mini clone, which has no led connected to D13/PA17.
|
||||
// Attention!!! D2 and D4 are swapped on these boards!!!
|
||||
// If you connect the LED, it is on pin 24/PB11. In this case activate the next two lines.
|
||||
//#undef LED_BUILTIN
|
||||
//#define LED_BUILTIN 24 // PB11
|
||||
// As an alternative you can choose pin 25, it is the RX-LED pin (PB03), but active low.In this case activate the next 3 lines.
|
||||
//#undef LED_BUILTIN
|
||||
//#define LED_BUILTIN 25 // PB03
|
||||
//#define FEEDBACK_LED_IS_ACTIVE_LOW // The RX LED on the M0-Mini is active LOW
|
||||
|
||||
#elif defined (NRF51) // BBC micro:bit
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define APPLICATION_PIN 1
|
||||
#define _IR_TIMING_TEST_PIN 4
|
||||
|
||||
#define tone(...) void() // no tone() available
|
||||
#define noTone(a) void()
|
||||
#define TONE_PIN 42 // Dummy for examples using it
|
||||
|
||||
#else
|
||||
#warning Board / CPU is not detected using pre-processor symbols -> using default values, which may not fit. Please extend PinDefinitionsAndMore.h.
|
||||
// Default valued for unidentified boards
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
#endif // defined(ESP8266)
|
||||
|
||||
#if defined(ESP32) || defined(ARDUINO_ARCH_RP2040) || defined(PARTICLE) || defined(ARDUINO_ARCH_MBED)
|
||||
#define SEND_PWM_BY_TIMER // We do not have pin restrictions for this CPU's, so lets use the hardware PWM for send carrier signal generation
|
||||
#else
|
||||
# if defined(SEND_PWM_BY_TIMER)
|
||||
#undef IR_SEND_PIN // SendPin is determined by timer! This avoids warnings in IRremote.hpp and IRTimer.hpp
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if !defined (FLASHEND)
|
||||
#define FLASHEND 0xFFFF // Dummy value for platforms where FLASHEND is not defined
|
||||
#endif
|
||||
|
||||
/*
|
||||
* 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
|
||||
@@ -0,0 +1,161 @@
|
||||
/*
|
||||
* ReceiveDump.cpp
|
||||
*
|
||||
* Dumps the received signal in different flavors.
|
||||
* Since the printing takes so much time (200 ms @115200 for NEC protocol, 70ms for NEC repeat),
|
||||
* repeat signals may be skipped or interpreted as UNKNOWN.
|
||||
*
|
||||
* This file is part of Arduino-IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
|
||||
*
|
||||
************************************************************************************
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2020-2024 Armin Joachimsmeyer
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is furnished
|
||||
* to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
************************************************************************************
|
||||
*/
|
||||
#include <Arduino.h>
|
||||
|
||||
// #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 4 // P0_1
|
||||
|
||||
|
||||
#if !defined(RAW_BUFFER_LENGTH)
|
||||
// For air condition remotes it requires 750. Default is 200.
|
||||
#define RAW_BUFFER_LENGTH 730 // this allows usage of 16 bit raw buffer, for RECORD_GAP_MICROS > 20000
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* MARK_EXCESS_MICROS is subtracted from all marks and added to all spaces before decoding,
|
||||
* to compensate for the signal forming of different IR receiver modules. See also IRremote.hpp line 142.
|
||||
*
|
||||
* You can change this value accordingly to the receiver module you use.
|
||||
* The required value can be derived from the timings printed here.
|
||||
* Keep in mind that the timings may change with the distance
|
||||
* between sender and receiver as well as with the ambient light intensity.
|
||||
*/
|
||||
#define MARK_EXCESS_MICROS 20 // Adapt it to your IR receiver module. 20 is recommended for the cheap VS1838 modules.
|
||||
|
||||
//#define RECORD_GAP_MICROS 12000 // Default is 8000. Activate it for some LG air conditioner protocols
|
||||
//#define DEBUG // Activate this for lots of lovely debug output from the decoders.
|
||||
|
||||
#include <IRremote.hpp>
|
||||
|
||||
//+=============================================================================
|
||||
// Configure the Arduino
|
||||
//
|
||||
void setup() {
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
|
||||
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.
|
||||
|
||||
// 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
|
||||
IrReceiver.begin(IR_RECEIVE_PIN, ENABLE_LED_FEEDBACK);
|
||||
|
||||
Serial.print(F("Ready to receive IR signals of protocols: "));
|
||||
printActiveIRProtocols(&Serial);
|
||||
Serial.println(F("at pin " STR(IR_RECEIVE_PIN)));
|
||||
|
||||
// infos for receive
|
||||
Serial.print(RECORD_GAP_MICROS);
|
||||
Serial.println(F(" us is the (minimum) gap, after which the start of a new IR packet is assumed"));
|
||||
Serial.print(MARK_EXCESS_MICROS);
|
||||
Serial.println();
|
||||
Serial.println(F("Because of the verbose output (>200 ms at 115200 baud), repeats are not dumped correctly!"));
|
||||
Serial.println();
|
||||
Serial.println(
|
||||
F(
|
||||
"If you receive protocol NEC, Samsung or LG, run also ReceiveDemo to check if your actual protocol is eventually NEC2 or SamsungLG, which is determined by the repeats"));
|
||||
Serial.println();
|
||||
|
||||
}
|
||||
|
||||
//+=============================================================================
|
||||
// The repeating section of the code
|
||||
//
|
||||
void loop() {
|
||||
if (IrReceiver.decode()) { // Grab an IR code
|
||||
// At 115200 baud, printing takes 200 ms for NEC protocol and 70 ms for NEC repeat
|
||||
Serial.println(); // blank line between entries
|
||||
Serial.println(); // 2 blank lines between entries
|
||||
IrReceiver.printIRResultShort(&Serial);
|
||||
// Check if the buffer overflowed
|
||||
if (IrReceiver.decodedIRData.flags & IRDATA_FLAGS_WAS_OVERFLOW) {
|
||||
Serial.println(F("Try to increase the \"RAW_BUFFER_LENGTH\" value of " STR(RAW_BUFFER_LENGTH) " in " __FILE__));
|
||||
// see also https://github.com/Arduino-IRremote/Arduino-IRremote#compile-options--macros-for-this-library
|
||||
} else {
|
||||
if (IrReceiver.decodedIRData.protocol == UNKNOWN) {
|
||||
Serial.println(F("Received noise or an unknown (or not yet enabled) protocol"));
|
||||
}
|
||||
Serial.println();
|
||||
IrReceiver.printIRSendUsage(&Serial);
|
||||
Serial.println();
|
||||
Serial.println(F("Raw result in internal ticks (50 us) - with leading gap"));
|
||||
IrReceiver.printIRResultRawFormatted(&Serial, false); // Output the results in RAW format
|
||||
Serial.println(F("Raw result in microseconds - with leading gap"));
|
||||
IrReceiver.printIRResultRawFormatted(&Serial, true); // Output the results in RAW format
|
||||
Serial.println(); // blank line between entries
|
||||
Serial.print(F("Result as internal 8bit ticks (50 us) array - compensated with MARK_EXCESS_MICROS="));
|
||||
Serial.println(MARK_EXCESS_MICROS);
|
||||
IrReceiver.compensateAndPrintIRResultAsCArray(&Serial, false); // Output the results as uint8_t source code array of ticks
|
||||
Serial.print(F("Result as microseconds array - compensated with MARK_EXCESS_MICROS="));
|
||||
Serial.println(MARK_EXCESS_MICROS);
|
||||
IrReceiver.compensateAndPrintIRResultAsCArray(&Serial, true); // Output the results as uint16_t source code array of micros
|
||||
IrReceiver.printIRResultAsCVariables(&Serial); // Output address and data as source code variables
|
||||
Serial.println(); // blank line between entries
|
||||
|
||||
IrReceiver.compensateAndPrintIRResultAsPronto(&Serial);
|
||||
|
||||
/*
|
||||
* Example for using the compensateAndStorePronto() function.
|
||||
* Creating this String requires 2210 bytes program memory and 10 bytes RAM for the String class.
|
||||
* The String object itself requires additional 440 bytes RAM from the heap.
|
||||
* This values are for an Arduino Uno.
|
||||
*/
|
||||
// Serial.println(); // blank line between entries
|
||||
// String ProntoHEX = F("Pronto HEX contains: "); // Assign string to ProtoHex string object
|
||||
// if (int size = IrReceiver.compensateAndStorePronto(&ProntoHEX)) { // Dump the content of the IReceiver Pronto HEX to the String object
|
||||
// // Append compensateAndStorePronto() size information to the String object (requires 50 bytes heap)
|
||||
// ProntoHEX += F("\r\nProntoHEX is "); // Add codes size information to the String object
|
||||
// ProntoHEX += size;
|
||||
// ProntoHEX += F(" characters long and contains "); // Add codes count information to the String object
|
||||
// ProntoHEX += size / 5;
|
||||
// ProntoHEX += F(" codes");
|
||||
// Serial.println(ProntoHEX.c_str()); // Print to the serial console the whole String object
|
||||
// Serial.println(); // blank line between entries
|
||||
// }
|
||||
}
|
||||
IrReceiver.resume(); // Prepare for the next IR frame
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
START ../src/ReceiveDump.cpp from Nov 12 2022
|
||||
Using library version 4.0.0
|
||||
Ready to receive IR signals of protocols: NEC/NEC2/Onkyo/Apple, Panasonic/Kaseikyo, Denon/Sharp, Sony, RC5, RC6, LG, JVC, Samsung, Whynter, Lego Power Functions, Bosewave , MagiQuest, Universal Pulse Distance Width, Hash at pin 2
|
||||
5000 us is the (minimum) gap, after which the start of a new IR packet is assumed
|
||||
20 us are subtracted from all marks and added to all spaces for decoding
|
||||
|
||||
|
||||
Protocol=Samsung Address=0x707 Command=0x4 Raw-Data=0xFB040707 32 bits LSB first
|
||||
|
||||
Send with: IrSender.sendSamsung(0x707, 0x4, <numberOfRepeats>);
|
||||
|
||||
Raw result in internal ticks (50 us) - with leading gap
|
||||
rawData[68]:
|
||||
-27948
|
||||
+90,-84
|
||||
+12,-32 +12,-32 +12,-32 +12,-11
|
||||
+11,-11 +11,-11 +11,-11 +11,-11
|
||||
+12,-32 +12,-32 +12,-32 +12,-10
|
||||
+12,-10 +12,-10 +12,-10 +12,-11
|
||||
+11,-11 +11,-11 +11,-33 +11,-11
|
||||
+11,-11 +11,-11 +11,-11 +11,-11
|
||||
+12,-32 +12,-32 +12,-10 +12,-32
|
||||
+12,-32 +12,-32 +12,-32 +12,-32
|
||||
+12
|
||||
Sum: 1200
|
||||
Raw result in microseconds - with leading gap
|
||||
rawData[68]:
|
||||
-1397400
|
||||
+4500,-4200
|
||||
+ 600,-1600 + 600,-1600 + 600,-1600 + 600,- 550
|
||||
+ 550,- 550 + 550,- 550 + 550,- 550 + 550,- 550
|
||||
+ 600,-1600 + 600,-1600 + 600,-1600 + 600,- 500
|
||||
+ 600,- 500 + 600,- 500 + 600,- 500 + 600,- 550
|
||||
+ 550,- 550 + 550,- 550 + 550,-1650 + 550,- 550
|
||||
+ 550,- 550 + 550,- 550 + 550,- 550 + 550,- 550
|
||||
+ 600,-1600 + 600,-1600 + 600,- 500 + 600,-1600
|
||||
+ 600,-1600 + 600,-1600 + 600,-1600 + 600,-1600
|
||||
+ 600
|
||||
Sum: 60000
|
||||
|
||||
Result as internal ticks (50 us) array - compensated with MARK_EXCESS_MICROS=20
|
||||
uint8_t rawTicks[67] = {90,84, 12,32, 12,32, 12,32, 12,11, 11,11, 11,11, 11,11, 11,11, 12,32, 12,32, 12,32, 12,10, 12,10, 12,10, 12,10, 12,11, 11,11, 11,11, 11,33, 11,11, 11,11, 11,11, 11,11, 11,11, 12,32, 12,32, 12,10, 12,32, 12,32, 12,32, 12,32, 12,32, 12}; // Protocol=Samsung Address=0x707 Command=0x4 Raw-Data=0xFB040707 32 bits LSB first
|
||||
|
||||
Result as microseconds array - compensated with MARK_EXCESS_MICROS=20
|
||||
uint16_t rawData[67] = {4480,4220, 580,1620, 580,1620, 580,1620, 580,570, 530,570, 530,570, 530,570, 530,570, 580,1620, 580,1620, 580,1620, 580,520, 580,520, 580,520, 580,520, 580,570, 530,570, 530,570, 530,1670, 530,570, 530,570, 530,570, 530,570, 530,570, 580,1620, 580,1620, 580,520, 580,1620, 580,1620, 580,1620, 580,1620, 580,1620, 580}; // Protocol=Samsung Address=0x707 Command=0x4 Raw-Data=0xFB040707 32 bits LSB first
|
||||
|
||||
uint16_t address = 0x707;
|
||||
uint16_t command = 0x4;
|
||||
uint32_t data = 0xFB040707;
|
||||
|
||||
Pronto Hex as string
|
||||
char prontoData[] = "0000 006D 0022 0000 00AE 00A1 0018 003D 0018 003D 0018 003D 0018 0014 0016 0014 0016 0014 0016 0014 0016 0014 0018 003D 0018 003D 0018 003D 0018 0012 0018 0012 0018 0012 0018 0012 0018 0014 0016 0014 0016 0014 0016 003F 0016 0014 0016 0014 0016 0014 0016 0014 0016 0014 0018 003D 0018 003D 0018 0012 0018 003D 0018 003D 0018 003D 0018 003D 0018 003D 0018 06C3 ";
|
||||
@@ -0,0 +1,349 @@
|
||||
/*
|
||||
* PinDefinitionsAndMore.h
|
||||
*
|
||||
* Contains pin definitions for IRremote examples for various platforms
|
||||
* as well as definitions for feedback LED and tone() and includes
|
||||
*
|
||||
* Copyright (C) 2021-2023 Armin Joachimsmeyer
|
||||
* armin.joachimsmeyer@gmail.com
|
||||
*
|
||||
* This file is part of IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
|
||||
*
|
||||
* Arduino-IRremote is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/gpl.html>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Pin mapping table for different platforms
|
||||
*
|
||||
* Platform IR input IR output Tone Core/Pin schema
|
||||
* --------------------------------------------------------------
|
||||
* DEFAULT/AVR 2 3 4 Arduino
|
||||
* ATtinyX5 0|PB0 4|PB4 3|PB3 ATTinyCore
|
||||
* ATtiny167 3|PA3 2|PA2 7|PA7 ATTinyCore
|
||||
* ATtiny167 9|PA3 8|PA2 5|PA7 Digispark original core
|
||||
* ATtiny84 |PB2 |PA4 |PA3 ATTinyCore
|
||||
* ATtiny88 3|PD3 4|PD4 9|PB1 ATTinyCore
|
||||
* ATtiny3217 18|PA1 19|PA2 20|PA3 MegaTinyCore
|
||||
* ATtiny1604 2 3|PA5 %
|
||||
* ATtiny816 14|PA1 16|PA3 1|PA5 MegaTinyCore
|
||||
* ATtiny1614 8|PA1 10|PA3 1|PA5 MegaTinyCore
|
||||
* SAMD21 3 4 5
|
||||
* ESP8266 14|D5 12|D6 %
|
||||
* ESP32 15 4 27
|
||||
* ESP32-C3 2 3 4
|
||||
* BluePill PA6 PA7 PA3
|
||||
* APOLLO3 11 12 5
|
||||
* RP2040 3|GPIO15 4|GPIO16 5|GPIO17
|
||||
*/
|
||||
//#define _IR_MEASURE_TIMING // For debugging purposes.
|
||||
|
||||
#if defined(__AVR__)
|
||||
#if defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__) // Digispark board. For use with ATTinyCore.
|
||||
#include "ATtinySerialOut.hpp" // TX is at pin 2 - Available as Arduino library "ATtinySerialOut". Saves 700 bytes program memory and 70 bytes RAM for ATtinyCore.
|
||||
#define IR_RECEIVE_PIN PIN_PB0
|
||||
#define IR_SEND_PIN PIN_PB4 // Pin 2 is serial output with ATtinySerialOut. Pin 1 is internal LED and Pin3 is USB+ with pullup on Digispark board.
|
||||
#define TONE_PIN PIN_PB3
|
||||
#define _IR_TIMING_TEST_PIN PIN_PB3
|
||||
|
||||
# elif defined(__AVR_ATtiny87__) || defined(__AVR_ATtiny167__) // Digispark pro board
|
||||
#include "ATtinySerialOut.hpp" // Available as Arduino library "ATtinySerialOut"
|
||||
// For ATtiny167 Pins PB6 and PA3 are usable as interrupt source.
|
||||
# if defined(ARDUINO_AVR_DIGISPARKPRO)
|
||||
// For use with Digispark original core
|
||||
#define IR_RECEIVE_PIN 9 // PA3 - on Digispark board labeled as pin 9
|
||||
//#define IR_RECEIVE_PIN 14 // PB6 / INT0 is connected to USB+ on DigisparkPro boards
|
||||
#define IR_SEND_PIN 8 // PA2 - on Digispark board labeled as pin 8
|
||||
#define TONE_PIN 5 // PA7 - on Digispark board labeled as pin 5
|
||||
#define _IR_TIMING_TEST_PIN 10 // PA4
|
||||
# else
|
||||
// For use with ATTinyCore
|
||||
#define IR_RECEIVE_PIN PIN_PA3 // On Digispark board labeled as pin 9 - INT0 is connected to USB+ on DigisparkPro boards
|
||||
#define IR_SEND_PIN PIN_PA2 // On Digispark board labeled as pin 8
|
||||
#define TONE_PIN PIN_PA7 // On Digispark board labeled as pin 5
|
||||
# endif
|
||||
|
||||
# elif defined(__AVR_ATtiny84__) // For use with ATTinyCore
|
||||
#include "ATtinySerialOut.hpp" // Available as Arduino library "ATtinySerialOut". Saves 128 bytes program memory.
|
||||
#define IR_RECEIVE_PIN PIN_PB2 // INT0
|
||||
#define IR_SEND_PIN PIN_PA4
|
||||
#define TONE_PIN PIN_PA3
|
||||
#define _IR_TIMING_TEST_PIN PIN_PA5
|
||||
|
||||
# elif defined(__AVR_ATtiny88__) // MH-ET Tiny88 board. For use with ATTinyCore.
|
||||
#include "ATtinySerialOut.hpp" // Available as Arduino library "ATtinySerialOut". Saves 128 bytes program memory.
|
||||
// Pin 6 is TX, pin 7 is RX
|
||||
#define IR_RECEIVE_PIN PIN_PD3 // 3 - INT1
|
||||
#define IR_SEND_PIN PIN_PD4 // 4
|
||||
#define TONE_PIN PIN_PB1 // 9
|
||||
#define _IR_TIMING_TEST_PIN PIN_PB0 // 8
|
||||
|
||||
# elif defined(__AVR_ATtiny1616__) || defined(__AVR_ATtiny3216__) || defined(__AVR_ATtiny3217__) // For use with megaTinyCore
|
||||
// Tiny Core Dev board
|
||||
// https://www.tindie.com/products/xkimi/tiny-core-16-dev-board-attiny1616/ - Out of Stock
|
||||
// https://www.tindie.com/products/xkimi/tiny-core-32-dev-board-attiny3217/ - Out of Stock
|
||||
#define IR_RECEIVE_PIN PIN_PA1 // use 18 instead of PIN_PA1 for TinyCore32
|
||||
#define IR_SEND_PIN PIN_PA2 // 19
|
||||
#define TONE_PIN PIN_PA3 // 20
|
||||
#define APPLICATION_PIN PIN_PA0 // 0
|
||||
#undef LED_BUILTIN // No LED available on the TinyCore 32 board, take the one on the programming board which is connected to the DAC output
|
||||
#define LED_BUILTIN PIN_PA6 // use 2 instead of PIN_PA6 for TinyCore32
|
||||
|
||||
# elif defined(__AVR_ATtiny816__) // For use with megaTinyCore
|
||||
#define IR_RECEIVE_PIN PIN_PA1 // 14
|
||||
#define IR_SEND_PIN PIN_PA1 // 16
|
||||
#define TONE_PIN PIN_PA5 // 1
|
||||
#define APPLICATION_PIN PIN_PA4 // 0
|
||||
#undef LED_BUILTIN // No LED available, take the one which is connected to the DAC output
|
||||
#define LED_BUILTIN PIN_PB5 // 4
|
||||
|
||||
# elif defined(__AVR_ATtiny1614__) // For use with megaTinyCore
|
||||
#define IR_RECEIVE_PIN PIN_PA1 // 8
|
||||
#define IR_SEND_PIN PIN_PA3 // 10
|
||||
#define TONE_PIN PIN_PA5 // 1
|
||||
#define APPLICATION_PIN PIN_PA4 // 0
|
||||
|
||||
# elif defined(__AVR_ATtiny1604__) // For use with megaTinyCore
|
||||
#define IR_RECEIVE_PIN PIN_PA6 // 2 - To be compatible with interrupt example, pin 2 is chosen here.
|
||||
#define IR_SEND_PIN PIN_PA7 // 3
|
||||
#define APPLICATION_PIN PIN_PB2 // 5
|
||||
|
||||
#define tone(...) void() // Define as void, since TCB0_INT_vect is also used by tone()
|
||||
#define noTone(a) void()
|
||||
#define TONE_PIN 42 // Dummy for examples using it
|
||||
|
||||
# elif defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) \
|
||||
|| defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) \
|
||||
|| defined(__AVR_ATmega324P__) || defined(__AVR_ATmega324A__) \
|
||||
|| defined(__AVR_ATmega324PA__) || defined(__AVR_ATmega164A__) \
|
||||
|| defined(__AVR_ATmega164P__) || defined(__AVR_ATmega32__) \
|
||||
|| defined(__AVR_ATmega16__) || defined(__AVR_ATmega8535__) \
|
||||
|| defined(__AVR_ATmega64__) || defined(__AVR_ATmega128__) \
|
||||
|| defined(__AVR_ATmega1281__) || defined(__AVR_ATmega2561__) \
|
||||
|| defined(__AVR_ATmega8515__) || defined(__AVR_ATmega162__)
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 13
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
# else // Default as for ATmega328 like on Uno, Nano, Leonardo, Teensy 2.0 etc.
|
||||
#define IR_RECEIVE_PIN 2 // To be compatible with interrupt example, pin 2 is chosen here.
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
# if defined(ARDUINO_AVR_PROMICRO) // Sparkfun Pro Micro is __AVR_ATmega32U4__ but has different external circuit
|
||||
// We have no built in LED at pin 13 -> reuse RX LED
|
||||
#undef LED_BUILTIN
|
||||
#define LED_BUILTIN LED_BUILTIN_RX
|
||||
# endif
|
||||
# endif // defined(__AVR_ATtiny25__)...
|
||||
|
||||
#elif defined(ARDUINO_ARCH_RENESAS_UNO) // Uno R4
|
||||
// To be compatible with Uno R3.
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
#elif defined(ESP8266)
|
||||
#define FEEDBACK_LED_IS_ACTIVE_LOW // The LED on my board (D4) is active LOW
|
||||
#define IR_RECEIVE_PIN 14 // D5
|
||||
#define IR_SEND_PIN 12 // D6 - D4/pin 2 is internal LED
|
||||
#define _IR_TIMING_TEST_PIN 2 // D4
|
||||
#define APPLICATION_PIN 13 // D7
|
||||
|
||||
#define tone(...) void() // tone() inhibits receive timer
|
||||
#define noTone(a) void()
|
||||
#define TONE_PIN 42 // Dummy for examples using it#
|
||||
|
||||
#elif defined(ARDUINO_NOLOGO_ESP32C3_SUPER_MINI)
|
||||
#define FEEDBACK_LED_IS_ACTIVE_LOW // The LED on my board (D8) is active LOW
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 10
|
||||
|
||||
#elif defined(CONFIG_IDF_TARGET_ESP32C3) || defined(ARDUINO_ESP32C3_DEV)
|
||||
#define NO_LED_FEEDBACK_CODE // The WS2812 on pin 8 of AI-C3 board crashes if used as receive feedback LED, other I/O pins are working...
|
||||
#define IR_RECEIVE_PIN 6
|
||||
#define IR_SEND_PIN 7
|
||||
#define TONE_PIN 10
|
||||
#define APPLICATION_PIN 18
|
||||
|
||||
#elif defined(ESP32)
|
||||
#include <Arduino.h>
|
||||
|
||||
// tone() is included in ESP32 core since 2.0.2
|
||||
#if !defined(ESP_ARDUINO_VERSION_VAL)
|
||||
#define ESP_ARDUINO_VERSION_VAL(major, minor, patch) 12345678
|
||||
#endif
|
||||
#if ESP_ARDUINO_VERSION <= ESP_ARDUINO_VERSION_VAL(2, 0, 2)
|
||||
#define TONE_LEDC_CHANNEL 1 // Using channel 1 makes tone() independent of receiving timer -> No need to stop receiving timer.
|
||||
void tone(uint8_t aPinNumber, unsigned int aFrequency){
|
||||
ledcAttachPin(aPinNumber, TONE_LEDC_CHANNEL);
|
||||
ledcWriteTone(TONE_LEDC_CHANNEL, aFrequency);
|
||||
}
|
||||
void tone(uint8_t aPinNumber, unsigned int aFrequency, unsigned long aDuration){
|
||||
ledcAttachPin(aPinNumber, TONE_LEDC_CHANNEL);
|
||||
ledcWriteTone(TONE_LEDC_CHANNEL, aFrequency);
|
||||
delay(aDuration);
|
||||
ledcWriteTone(TONE_LEDC_CHANNEL, 0);
|
||||
}
|
||||
void noTone(uint8_t aPinNumber){
|
||||
ledcWriteTone(TONE_LEDC_CHANNEL, 0);
|
||||
}
|
||||
#endif // ESP_ARDUINO_VERSION <= ESP_ARDUINO_VERSION_VAL(2, 0, 2)
|
||||
|
||||
#define IR_RECEIVE_PIN 15 // D15
|
||||
#define IR_SEND_PIN 4 // D4
|
||||
#define TONE_PIN 27 // D27 25 & 26 are DAC0 and 1
|
||||
#define APPLICATION_PIN 16 // RX2 pin
|
||||
|
||||
#elif defined(ARDUINO_ARCH_STM32) || defined(ARDUINO_ARCH_STM32F1) // BluePill
|
||||
// Timer 3 blocks PA6, PA7, PB0, PB1 for use by Servo or tone()
|
||||
#define IR_RECEIVE_PIN PA6
|
||||
#define IR_RECEIVE_PIN_STRING "PA6"
|
||||
#define IR_SEND_PIN PA7
|
||||
#define IR_SEND_PIN_STRING "PA7"
|
||||
#define TONE_PIN PA3
|
||||
#define _IR_TIMING_TEST_PIN PA5
|
||||
#define APPLICATION_PIN PA2
|
||||
#define APPLICATION_PIN_STRING "PA2"
|
||||
# if defined(ARDUINO_GENERIC_STM32F103C) || defined(ARDUINO_BLUEPILL_F103C8)
|
||||
// BluePill LED is active low
|
||||
#define FEEDBACK_LED_IS_ACTIVE_LOW
|
||||
# endif
|
||||
|
||||
#elif defined(ARDUINO_ARCH_APOLLO3) // Sparkfun Apollo boards
|
||||
#define IR_RECEIVE_PIN 11
|
||||
#define IR_SEND_PIN 12
|
||||
#define TONE_PIN 5
|
||||
|
||||
#elif defined(ARDUINO_ARCH_MBED) && defined(ARDUINO_ARCH_MBED_NANO) // Arduino Nano 33 BLE and Arduino Nano Connect layout for MBED
|
||||
// Must be before ARDUINO_ARCH_RP2040, since it is the layout for the MBED core of Arduino Nano Connect
|
||||
#define IR_RECEIVE_PIN 3 // GPIO15 Start with pin 3 since pin 2|GPIO25 is connected to LED on Pi pico
|
||||
#define IR_SEND_PIN 4 // GPIO16
|
||||
#define TONE_PIN 5
|
||||
#define APPLICATION_PIN 6
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 7 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 8
|
||||
|
||||
#elif defined(ARDUINO_ARCH_RP2040) // Arduino Nano Connect, Pi Pico with arduino-pico core https://github.com/earlephilhower/arduino-pico
|
||||
#define IR_RECEIVE_PIN 15 // GPIO15 to be compatible with the Arduino Nano RP2040 Connect (pin3)
|
||||
#define IR_SEND_PIN 16 // GPIO16
|
||||
#define TONE_PIN 17
|
||||
#define APPLICATION_PIN 18
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 19 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 20
|
||||
|
||||
// If you program the Nano RP2040 Connect with this core, then you must redefine LED_BUILTIN
|
||||
// and use the external reset with 1 kOhm to ground to enter UF2 mode
|
||||
#undef LED_BUILTIN
|
||||
#define LED_BUILTIN 6
|
||||
|
||||
#elif defined(PARTICLE) // !!!UNTESTED!!!
|
||||
#define IR_RECEIVE_PIN A4
|
||||
#define IR_SEND_PIN A5 // Particle supports multiple pins
|
||||
|
||||
#define LED_BUILTIN D7
|
||||
|
||||
/*
|
||||
* 4 times the same (default) layout for easy adaption in the future
|
||||
*/
|
||||
#elif defined(TEENSYDUINO) // Teensy 2.0 is handled at default for ATmega328 like on Uno, Nano, Leonardo etc.
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
#elif defined(ARDUINO_ARCH_MBED) // Arduino Nano 33 BLE
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
#elif defined(ARDUINO_ARCH_SAMD) || defined(ARDUINO_ARCH_SAM)
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
#if !defined(ARDUINO_SAMD_ADAFRUIT) && !defined(ARDUINO_SEEED_XIAO_M0)
|
||||
// On the Zero and others we switch explicitly to SerialUSB
|
||||
#define Serial SerialUSB
|
||||
#endif
|
||||
|
||||
// Definitions for the Chinese SAMD21 M0-Mini clone, which has no led connected to D13/PA17.
|
||||
// Attention!!! D2 and D4 are swapped on these boards!!!
|
||||
// If you connect the LED, it is on pin 24/PB11. In this case activate the next two lines.
|
||||
//#undef LED_BUILTIN
|
||||
//#define LED_BUILTIN 24 // PB11
|
||||
// As an alternative you can choose pin 25, it is the RX-LED pin (PB03), but active low.In this case activate the next 3 lines.
|
||||
//#undef LED_BUILTIN
|
||||
//#define LED_BUILTIN 25 // PB03
|
||||
//#define FEEDBACK_LED_IS_ACTIVE_LOW // The RX LED on the M0-Mini is active LOW
|
||||
|
||||
#elif defined (NRF51) // BBC micro:bit
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define APPLICATION_PIN 1
|
||||
#define _IR_TIMING_TEST_PIN 4
|
||||
|
||||
#define tone(...) void() // no tone() available
|
||||
#define noTone(a) void()
|
||||
#define TONE_PIN 42 // Dummy for examples using it
|
||||
|
||||
#else
|
||||
#warning Board / CPU is not detected using pre-processor symbols -> using default values, which may not fit. Please extend PinDefinitionsAndMore.h.
|
||||
// Default valued for unidentified boards
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
#endif // defined(ESP8266)
|
||||
|
||||
#if defined(ESP32) || defined(ARDUINO_ARCH_RP2040) || defined(PARTICLE) || defined(ARDUINO_ARCH_MBED)
|
||||
#define SEND_PWM_BY_TIMER // We do not have pin restrictions for this CPU's, so lets use the hardware PWM for send carrier signal generation
|
||||
#else
|
||||
# if defined(SEND_PWM_BY_TIMER)
|
||||
#undef IR_SEND_PIN // SendPin is determined by timer! This avoids warnings in IRremote.hpp and IRTimer.hpp
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if !defined (FLASHEND)
|
||||
#define FLASHEND 0xFFFF // Dummy value for platforms where FLASHEND is not defined
|
||||
#endif
|
||||
|
||||
/*
|
||||
* 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
|
||||
@@ -0,0 +1,264 @@
|
||||
/*
|
||||
* ReceiveOneAndSendMultiple.cpp
|
||||
*
|
||||
* Serves as a IR remote macro expander
|
||||
* Receives Samsung32 protocol and on receiving a specified input frame,
|
||||
* it sends multiple Samsung32 frames with appropriate delays in between.
|
||||
* This serves as a Netflix-key emulation for my old Samsung H5273 TV.
|
||||
*
|
||||
* Tested on a digispark ATTiny85 board using AttinyCore https://github.com/SpenceKonde/ATTinyCore
|
||||
*
|
||||
* This file is part of Arduino-IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
|
||||
*
|
||||
************************************************************************************
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2020-2024 Armin Joachimsmeyer
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is furnished
|
||||
* to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
************************************************************************************
|
||||
*/
|
||||
|
||||
// Digispark ATMEL ATTINY85
|
||||
// Piezo speaker must have a 270 ohm resistor in series for USB programming and running at the Samsung TV.
|
||||
// IR LED has a 270 ohm resistor in series.
|
||||
// +-\/-+
|
||||
// !RESET (5) PB5 1| |8 Vcc
|
||||
// USB+ 3.6V Z-Diode, 1.5kOhm to VCC Piezo (3) PB3 2| |7 PB2 (2) TX Debug output
|
||||
// USB- 3.6V Z-Diode IR Output (4) PB4 3| |6 PB1 (1) Feedback LED
|
||||
// GND 4| |5 PB0 (0) IR Input
|
||||
// +----+
|
||||
/* SAUMSUMG REMOTE CODES (Model: BN59-01180A) - Address is 0x07
|
||||
* Power Button - 0x2
|
||||
* Power Off - 0x98
|
||||
* 1 - 0x4
|
||||
* 2 - 0x5
|
||||
* 3 - 0x6
|
||||
* 4 - 0x8
|
||||
* 5 - 0x9
|
||||
* 6 - 0xa
|
||||
* 7 - 0xc
|
||||
* 8 - 0xd
|
||||
* 9 - 0xe
|
||||
* CH List - 0x6b
|
||||
* Vol + - 0x7
|
||||
* Vol - - 0xb
|
||||
* Mute - 0xf
|
||||
* Source - 0x1
|
||||
* Ch + - 0x12
|
||||
* Ch - - 0x10
|
||||
* Menu - 0x1a
|
||||
* Home - 0x79
|
||||
* MagicInfo Player - 0x30
|
||||
* Tools - 0x4b
|
||||
* Info - 0x1f
|
||||
* Up arrow - 0x60
|
||||
* Left arrow - 0x65
|
||||
* Right arrow - 0x62
|
||||
* Down arrow - 0x61
|
||||
* Return - 0x58
|
||||
* Exit - 0x2d
|
||||
* A - 0x6c
|
||||
* B - 0x14
|
||||
* C - 0x15
|
||||
* D - 0x16
|
||||
* Set - 0xab
|
||||
* Unset - 0xac
|
||||
* Lock - 0x77
|
||||
* Stop (square) - 0x46
|
||||
* Rewind (arrows) - 0x45
|
||||
* Play (triangle) - 0x47
|
||||
* Pause (bars) - 0x4a
|
||||
* Fast Forward (arrows) - 0x48
|
||||
*/
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
// select only Samsung protocol for sending and receiving
|
||||
#define DECODE_SAMSUNG
|
||||
#define ADDRESS_OF_SAMSUNG_REMOTE 0x07 // The value you see as address in printIRResultShort()
|
||||
|
||||
#define TONE_PIN 5 // P0_2
|
||||
#define IR_RECEIVE_PIN 4 // P0_1
|
||||
#define IR_SEND_PIN 3 // P0_0
|
||||
|
||||
/*
|
||||
* 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 <IRremote.hpp>
|
||||
|
||||
void sendSamsungSmartHubMacro(bool aDoSelect);
|
||||
void IRSendWithDelay(uint8_t aCommand, uint16_t aDelayMillis);
|
||||
|
||||
void setup() {
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
|
||||
Serial.begin(9600);
|
||||
while (!Serial)
|
||||
; // Wait for Serial to become available. Is optimized away for some cores.
|
||||
|
||||
// Just to know which program is running on my Arduino
|
||||
Serial.println(F("START " __FILE__ " from " __DATE__ "\r\nUsing library version " VERSION_IRREMOTE));
|
||||
|
||||
// tone before IR setup, since it kills the IR timer settings
|
||||
tone(TONE_PIN, 2200, 400);
|
||||
digitalWrite(LED_BUILTIN, HIGH);
|
||||
delay(400);
|
||||
digitalWrite(LED_BUILTIN, LOW);
|
||||
|
||||
// Start the receiver and if not 3. parameter specified, take LED_BUILTIN pin from the internal boards definition as default feedback LED
|
||||
IrReceiver.begin(IR_RECEIVE_PIN, ENABLE_LED_FEEDBACK);
|
||||
|
||||
Serial.print(F("Ready to receive IR signals of protocols: "));
|
||||
printActiveIRProtocols(&Serial);
|
||||
Serial.println(F("at pin " STR(IR_RECEIVE_PIN)));
|
||||
|
||||
IrSender.begin(); // Start with IR_SEND_PIN -which is defined in PinDefinitionsAndMore.h- as send pin and enable feedback LED at default feedback LED pin
|
||||
Serial.println(F("Ready to send IR signals at pin " STR(IR_SEND_PIN)));
|
||||
}
|
||||
|
||||
void loop() {
|
||||
/*
|
||||
* Check if new data available and get them
|
||||
*/
|
||||
if (IrReceiver.decode()) {
|
||||
// Print a short summary of received data
|
||||
IrReceiver.printIRResultShort(&Serial);
|
||||
IrReceiver.printIRSendUsage(&Serial);
|
||||
Serial.println();
|
||||
|
||||
/*
|
||||
* Here data is available -> evaluate IR command
|
||||
*/
|
||||
switch (IrReceiver.decodedIRData.command) {
|
||||
case 0x47: // The play key on the bottom of my Samsung remote
|
||||
Serial.println(F("Play key detected, open Netflix"));
|
||||
sendSamsungSmartHubMacro(true);
|
||||
break;
|
||||
|
||||
case 0x4A: // The pause key on the bottom of my Samsung remote
|
||||
Serial.println(F("Pause key detected, open SmartHub"));
|
||||
sendSamsungSmartHubMacro(false);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
* !!!Important!!! Enable receiving of the next value,
|
||||
* since receiving has stopped after the end of the current received data packet.
|
||||
*/
|
||||
IrReceiver.restartAfterSend(); // Is a NOP if sending does not require a timer.
|
||||
IrReceiver.resume(); // Enable receiving of the next value
|
||||
}
|
||||
}
|
||||
|
||||
void IRSendWithDelay(uint8_t aCommand, uint16_t aDelayMillis) {
|
||||
IrSender.sendSamsung(ADDRESS_OF_SAMSUNG_REMOTE, aCommand, 1); // send with one repeat
|
||||
Serial.print(F("Send Samsung command 0x"));
|
||||
Serial.println(aCommand);
|
||||
delay(aDelayMillis);
|
||||
}
|
||||
|
||||
bool sMacroWasCalledBefore = false;
|
||||
#define INITIAL_WAIT_TIME_APPS_READY_MILLIS 70000 // Time to let the TV load all software before Netflix can be started without an error
|
||||
#define INITIAL_WAIT_TIME_SMARTHUB_READY_MILLIS 20000 // Time to let the TV load all software before SmartHub manu can be displayed
|
||||
|
||||
/*
|
||||
* This macro calls the last SmartHub application you selected manually
|
||||
*
|
||||
* @param aDoSelect - if true select the current app (needs longer initial wait time) else show smarthub menu
|
||||
*
|
||||
*/
|
||||
void sendSamsungSmartHubMacro(bool aDoSelect) {
|
||||
uint32_t tWaitTimeAfterBoot;
|
||||
if (aDoSelect) {
|
||||
tWaitTimeAfterBoot = INITIAL_WAIT_TIME_APPS_READY_MILLIS;
|
||||
} else {
|
||||
tWaitTimeAfterBoot = INITIAL_WAIT_TIME_SMARTHUB_READY_MILLIS;
|
||||
}
|
||||
|
||||
IrReceiver.stopTimer();
|
||||
if (millis() < tWaitTimeAfterBoot) {
|
||||
// division by 1000 and printing requires much (8%) program memory
|
||||
Serial.print(F("It is "));
|
||||
Serial.print(millis() / 1000);
|
||||
Serial.print(F(" seconds after boot, Samsung H5273 TV requires "));
|
||||
Serial.print(tWaitTimeAfterBoot / 1000);
|
||||
Serial.println(F(" seconds after boot to be ready for the command"));
|
||||
|
||||
tone(TONE_PIN, 2200, 100);
|
||||
delay(200);
|
||||
tone(TONE_PIN, 2200, 100);
|
||||
delay(100);
|
||||
|
||||
if (millis() < tWaitTimeAfterBoot) {
|
||||
Serial.print(F("Now do a blocking wait for "));
|
||||
Serial.print(tWaitTimeAfterBoot - millis());
|
||||
Serial.println(F(" milliseconds"));
|
||||
delay(tWaitTimeAfterBoot - millis());
|
||||
}
|
||||
}
|
||||
|
||||
// Do beep feedback for special key to be received
|
||||
tone(TONE_PIN, 2200, 200);
|
||||
delay(200);
|
||||
|
||||
IrReceiver.restartTimer(); // Restart IR timer.
|
||||
|
||||
Serial.println(F("Wait for \"not supported\" to disappear"));
|
||||
delay(2000);
|
||||
|
||||
Serial.println(F("Start sending of Samsung IR macro"));
|
||||
|
||||
IRSendWithDelay(0x1A, 2000); // Menu and wait for the Menu to pop up
|
||||
|
||||
Serial.println(F("Wait for the menu to pop up"));
|
||||
if (!sMacroWasCalledBefore) {
|
||||
delay(2000); // wait additional time for the Menu load
|
||||
}
|
||||
|
||||
for (uint_fast8_t i = 0; i < 4; ++i) {
|
||||
IRSendWithDelay(0x61, 250); // Down arrow. For my Samsung, the high byte of the command is the inverse of the low byte
|
||||
}
|
||||
|
||||
IRSendWithDelay(0x62, 400); // Right arrow
|
||||
for (uint_fast8_t i = 0; i < 2; ++i) {
|
||||
IRSendWithDelay(0x61, 250); // Down arrow
|
||||
}
|
||||
|
||||
delay(250);
|
||||
IRSendWithDelay(0x68, 1); // Enter for SmartHub
|
||||
|
||||
if (aDoSelect) {
|
||||
Serial.println(F("Wait for SmartHub to show up, before entering current application"));
|
||||
delay(10000); // Wait not longer than 12 seconds, because smarthub menu then disappears
|
||||
IRSendWithDelay(0x68, 1); // Enter for last application (e.g. Netflix or Amazon)
|
||||
}
|
||||
|
||||
sMacroWasCalledBefore = true;
|
||||
Serial.println(F("Done"));
|
||||
|
||||
}
|
||||
@@ -0,0 +1,210 @@
|
||||
/*
|
||||
* ReceiverTimingAnalysis.cpp
|
||||
*
|
||||
* This program enables the pin change interrupt at pin 3 and waits for NEC (or other Pulse-Distance-Coding) IR Signal.
|
||||
* It measures the pulse and pause times of the incoming signal and computes some statistics for it.
|
||||
*
|
||||
* Observed values:
|
||||
* Delta of each signal type is around 50 up to 100 and at low signals up to 200. TSOP is better, especially at low IR signal level.
|
||||
* VS1838 Mark Excess -50 to +50 us
|
||||
* TSOP31238 Mark Excess 0 to +50
|
||||
*
|
||||
*
|
||||
* Copyright (C) 2019-2020 Armin Joachimsmeyer
|
||||
* armin.joachimsmeyer@gmail.com
|
||||
*
|
||||
* This file is part of IRMP https://github.com/IRMP-org/IRMP.
|
||||
* This file is part of Arduino-IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
|
||||
*
|
||||
* IRMP is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/gpl.html>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
#define IR_RECEIVE_PIN 4 // P0_1
|
||||
|
||||
/*
|
||||
* Helper macro for getting a macro definition as string
|
||||
*/
|
||||
#define STR_HELPER(x) #x
|
||||
#define STR(x) STR_HELPER(x)
|
||||
|
||||
void measureTimingISR(void);
|
||||
|
||||
void setup() {
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
Serial.begin(9600);
|
||||
while (!Serial)
|
||||
; // Wait for Serial to become available. Is optimized away for some cores.
|
||||
|
||||
// Just to know which program is running on my Arduino
|
||||
Serial.println(F("START " __FILE__ " from " __DATE__));
|
||||
attachInterrupt(digitalPinToInterrupt(IR_RECEIVE_PIN), measureTimingISR, CHANGE);
|
||||
Serial.println(F("Ready to analyze NEC IR signal at pin " STR(IR_RECEIVE_PIN)));
|
||||
Serial.println();
|
||||
}
|
||||
|
||||
uint8_t ISREdgeCounter = 0;
|
||||
volatile uint32_t LastMicros;
|
||||
struct timingStruct {
|
||||
uint16_t minimum;
|
||||
uint8_t indexOfMinimum;
|
||||
uint16_t maximum;
|
||||
uint8_t indexOfMaximum;
|
||||
uint16_t average;
|
||||
|
||||
uint16_t SumForAverage;
|
||||
uint8_t SampleCount;
|
||||
// uint8_t LastPrintedCount;
|
||||
};
|
||||
|
||||
struct timingStruct Mark;
|
||||
struct timingStruct ShortSpace;
|
||||
struct timingStruct LongSpace;
|
||||
|
||||
/*
|
||||
* Compute minimum, maximum and average
|
||||
*/
|
||||
void processTmingValue(struct timingStruct *aTimingStruct, uint16_t aValue) {
|
||||
if (aTimingStruct->SampleCount == 0) {
|
||||
// initialize values
|
||||
aTimingStruct->minimum = UINT16_MAX;
|
||||
aTimingStruct->maximum = 0;
|
||||
aTimingStruct->SumForAverage = 0;
|
||||
}
|
||||
|
||||
if (aTimingStruct->minimum > aValue) {
|
||||
aTimingStruct->minimum = aValue;
|
||||
aTimingStruct->indexOfMinimum = aTimingStruct->SampleCount;
|
||||
}
|
||||
if (aTimingStruct->maximum < aValue) {
|
||||
aTimingStruct->maximum = aValue;
|
||||
aTimingStruct->indexOfMaximum = aTimingStruct->SampleCount;
|
||||
}
|
||||
|
||||
aTimingStruct->SampleCount++;
|
||||
aTimingStruct->SumForAverage += aValue;
|
||||
aTimingStruct->average = (aTimingStruct->SumForAverage + (aTimingStruct->SampleCount / 2)) / aTimingStruct->SampleCount;
|
||||
|
||||
}
|
||||
|
||||
void printTimingValues(struct timingStruct *aTimingStruct, const char *aCaption) {
|
||||
// if (aTimingStruct->LastPrintedCount != aTimingStruct->SampleCount)
|
||||
// {
|
||||
// aTimingStruct->LastPrintedCount = aTimingStruct->SampleCount;
|
||||
Serial.print(aCaption);
|
||||
Serial.print(F(": SampleCount="));
|
||||
Serial.print(aTimingStruct->SampleCount);
|
||||
Serial.print(F(" Minimum="));
|
||||
Serial.print(aTimingStruct->minimum);
|
||||
Serial.print(F(" @"));
|
||||
Serial.print(aTimingStruct->indexOfMinimum);
|
||||
Serial.print(F(" Maximum="));
|
||||
Serial.print(aTimingStruct->maximum);
|
||||
Serial.print(F(" @"));
|
||||
Serial.print(aTimingStruct->indexOfMaximum);
|
||||
Serial.print(F(" Delta="));
|
||||
Serial.print(aTimingStruct->maximum - aTimingStruct->minimum);
|
||||
Serial.print(F(" Average="));
|
||||
Serial.print(aTimingStruct->average);
|
||||
|
||||
Serial.println();
|
||||
// }
|
||||
}
|
||||
|
||||
void loop() {
|
||||
if (Mark.SampleCount >= 32) {
|
||||
/*
|
||||
* This check enables statistics for longer protocols like Kaseikyo/Panasonics
|
||||
*/
|
||||
noInterrupts();
|
||||
uint32_t tLastMicros = LastMicros;
|
||||
interrupts();
|
||||
uint32_t tMicrosDelta = micros() - tLastMicros;
|
||||
|
||||
if (tMicrosDelta > 10000) {
|
||||
// NEC signal ended just now
|
||||
Serial.println();
|
||||
printTimingValues(&Mark, "Mark ");
|
||||
printTimingValues(&ShortSpace, "ShortSpace");
|
||||
printTimingValues(&LongSpace, "LongSpace ");
|
||||
|
||||
/*
|
||||
* Print analysis of mark and short spaces
|
||||
*/
|
||||
Serial.println(F("Analysis :"));
|
||||
Serial.print(F(" (Average of mark + short space)/2 = "));
|
||||
int16_t MarkAndShortSpaceAverage = (Mark.average + ShortSpace.average) / 2;
|
||||
Serial.print(MarkAndShortSpaceAverage);
|
||||
Serial.print(F(" us\r\n Delta (to NEC standard 560) = "));
|
||||
Serial.print(MarkAndShortSpaceAverage - 560);
|
||||
Serial.print(F("us\r\n MARK_EXCESS_MICROS = (Average of mark - Average of mark and short space) = "));
|
||||
Serial.print((int16_t) Mark.average - MarkAndShortSpaceAverage);
|
||||
Serial.print(F("us"));
|
||||
Serial.println();
|
||||
Serial.println();
|
||||
|
||||
Mark.SampleCount = 0; // used as flag for not printing the results more than once
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* The interrupt handler.
|
||||
* Just add to the appropriate timing structure.
|
||||
*/
|
||||
void measureTimingISR()
|
||||
{
|
||||
uint32_t tMicros = micros();
|
||||
uint32_t tMicrosDelta = tMicros - LastMicros;
|
||||
LastMicros = tMicros;
|
||||
/*
|
||||
* read level and give feedback
|
||||
*/
|
||||
uint8_t tInputLevel = digitalRead(IR_RECEIVE_PIN);
|
||||
digitalWrite(LED_BUILTIN, !tInputLevel);
|
||||
|
||||
if (tMicrosDelta > 10000) {
|
||||
// gap > 10 ms detected, reset counter to first detected edge and initialize timing structures
|
||||
ISREdgeCounter = 1;
|
||||
LongSpace.SampleCount = 0;
|
||||
ShortSpace.SampleCount = 0;
|
||||
Mark.SampleCount = 0;
|
||||
} else {
|
||||
ISREdgeCounter++;
|
||||
}
|
||||
|
||||
/*
|
||||
* Skip header mark and space and first bit mark and space
|
||||
*/
|
||||
if (ISREdgeCounter > 4) {
|
||||
if (tInputLevel != LOW) {
|
||||
// Mark ended
|
||||
processTmingValue(&Mark, tMicrosDelta);
|
||||
// Serial.print('M');
|
||||
} else {
|
||||
// Space ended
|
||||
if (tMicrosDelta > 1000) {
|
||||
// long space - logical 1
|
||||
processTmingValue(&LongSpace, tMicrosDelta);
|
||||
Serial.print('1');
|
||||
} else {
|
||||
// short space - logical 0
|
||||
processTmingValue(&ShortSpace, tMicrosDelta);
|
||||
Serial.print('0');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,349 @@
|
||||
/*
|
||||
* PinDefinitionsAndMore.h
|
||||
*
|
||||
* Contains pin definitions for IRremote examples for various platforms
|
||||
* as well as definitions for feedback LED and tone() and includes
|
||||
*
|
||||
* Copyright (C) 2021-2023 Armin Joachimsmeyer
|
||||
* armin.joachimsmeyer@gmail.com
|
||||
*
|
||||
* This file is part of IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
|
||||
*
|
||||
* Arduino-IRremote is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/gpl.html>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Pin mapping table for different platforms
|
||||
*
|
||||
* Platform IR input IR output Tone Core/Pin schema
|
||||
* --------------------------------------------------------------
|
||||
* DEFAULT/AVR 2 3 4 Arduino
|
||||
* ATtinyX5 0|PB0 4|PB4 3|PB3 ATTinyCore
|
||||
* ATtiny167 3|PA3 2|PA2 7|PA7 ATTinyCore
|
||||
* ATtiny167 9|PA3 8|PA2 5|PA7 Digispark original core
|
||||
* ATtiny84 |PB2 |PA4 |PA3 ATTinyCore
|
||||
* ATtiny88 3|PD3 4|PD4 9|PB1 ATTinyCore
|
||||
* ATtiny3217 18|PA1 19|PA2 20|PA3 MegaTinyCore
|
||||
* ATtiny1604 2 3|PA5 %
|
||||
* ATtiny816 14|PA1 16|PA3 1|PA5 MegaTinyCore
|
||||
* ATtiny1614 8|PA1 10|PA3 1|PA5 MegaTinyCore
|
||||
* SAMD21 3 4 5
|
||||
* ESP8266 14|D5 12|D6 %
|
||||
* ESP32 15 4 27
|
||||
* ESP32-C3 2 3 4
|
||||
* BluePill PA6 PA7 PA3
|
||||
* APOLLO3 11 12 5
|
||||
* RP2040 3|GPIO15 4|GPIO16 5|GPIO17
|
||||
*/
|
||||
//#define _IR_MEASURE_TIMING // For debugging purposes.
|
||||
|
||||
#if defined(__AVR__)
|
||||
#if defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__) // Digispark board. For use with ATTinyCore.
|
||||
#include "ATtinySerialOut.hpp" // TX is at pin 2 - Available as Arduino library "ATtinySerialOut". Saves 700 bytes program memory and 70 bytes RAM for ATtinyCore.
|
||||
#define IR_RECEIVE_PIN PIN_PB0
|
||||
#define IR_SEND_PIN PIN_PB4 // Pin 2 is serial output with ATtinySerialOut. Pin 1 is internal LED and Pin3 is USB+ with pullup on Digispark board.
|
||||
#define TONE_PIN PIN_PB3
|
||||
#define _IR_TIMING_TEST_PIN PIN_PB3
|
||||
|
||||
# elif defined(__AVR_ATtiny87__) || defined(__AVR_ATtiny167__) // Digispark pro board
|
||||
#include "ATtinySerialOut.hpp" // Available as Arduino library "ATtinySerialOut"
|
||||
// For ATtiny167 Pins PB6 and PA3 are usable as interrupt source.
|
||||
# if defined(ARDUINO_AVR_DIGISPARKPRO)
|
||||
// For use with Digispark original core
|
||||
#define IR_RECEIVE_PIN 9 // PA3 - on Digispark board labeled as pin 9
|
||||
//#define IR_RECEIVE_PIN 14 // PB6 / INT0 is connected to USB+ on DigisparkPro boards
|
||||
#define IR_SEND_PIN 8 // PA2 - on Digispark board labeled as pin 8
|
||||
#define TONE_PIN 5 // PA7 - on Digispark board labeled as pin 5
|
||||
#define _IR_TIMING_TEST_PIN 10 // PA4
|
||||
# else
|
||||
// For use with ATTinyCore
|
||||
#define IR_RECEIVE_PIN PIN_PA3 // On Digispark board labeled as pin 9 - INT0 is connected to USB+ on DigisparkPro boards
|
||||
#define IR_SEND_PIN PIN_PA2 // On Digispark board labeled as pin 8
|
||||
#define TONE_PIN PIN_PA7 // On Digispark board labeled as pin 5
|
||||
# endif
|
||||
|
||||
# elif defined(__AVR_ATtiny84__) // For use with ATTinyCore
|
||||
#include "ATtinySerialOut.hpp" // Available as Arduino library "ATtinySerialOut". Saves 128 bytes program memory.
|
||||
#define IR_RECEIVE_PIN PIN_PB2 // INT0
|
||||
#define IR_SEND_PIN PIN_PA4
|
||||
#define TONE_PIN PIN_PA3
|
||||
#define _IR_TIMING_TEST_PIN PIN_PA5
|
||||
|
||||
# elif defined(__AVR_ATtiny88__) // MH-ET Tiny88 board. For use with ATTinyCore.
|
||||
#include "ATtinySerialOut.hpp" // Available as Arduino library "ATtinySerialOut". Saves 128 bytes program memory.
|
||||
// Pin 6 is TX, pin 7 is RX
|
||||
#define IR_RECEIVE_PIN PIN_PD3 // 3 - INT1
|
||||
#define IR_SEND_PIN PIN_PD4 // 4
|
||||
#define TONE_PIN PIN_PB1 // 9
|
||||
#define _IR_TIMING_TEST_PIN PIN_PB0 // 8
|
||||
|
||||
# elif defined(__AVR_ATtiny1616__) || defined(__AVR_ATtiny3216__) || defined(__AVR_ATtiny3217__) // For use with megaTinyCore
|
||||
// Tiny Core Dev board
|
||||
// https://www.tindie.com/products/xkimi/tiny-core-16-dev-board-attiny1616/ - Out of Stock
|
||||
// https://www.tindie.com/products/xkimi/tiny-core-32-dev-board-attiny3217/ - Out of Stock
|
||||
#define IR_RECEIVE_PIN PIN_PA1 // use 18 instead of PIN_PA1 for TinyCore32
|
||||
#define IR_SEND_PIN PIN_PA2 // 19
|
||||
#define TONE_PIN PIN_PA3 // 20
|
||||
#define APPLICATION_PIN PIN_PA0 // 0
|
||||
#undef LED_BUILTIN // No LED available on the TinyCore 32 board, take the one on the programming board which is connected to the DAC output
|
||||
#define LED_BUILTIN PIN_PA6 // use 2 instead of PIN_PA6 for TinyCore32
|
||||
|
||||
# elif defined(__AVR_ATtiny816__) // For use with megaTinyCore
|
||||
#define IR_RECEIVE_PIN PIN_PA1 // 14
|
||||
#define IR_SEND_PIN PIN_PA1 // 16
|
||||
#define TONE_PIN PIN_PA5 // 1
|
||||
#define APPLICATION_PIN PIN_PA4 // 0
|
||||
#undef LED_BUILTIN // No LED available, take the one which is connected to the DAC output
|
||||
#define LED_BUILTIN PIN_PB5 // 4
|
||||
|
||||
# elif defined(__AVR_ATtiny1614__) // For use with megaTinyCore
|
||||
#define IR_RECEIVE_PIN PIN_PA1 // 8
|
||||
#define IR_SEND_PIN PIN_PA3 // 10
|
||||
#define TONE_PIN PIN_PA5 // 1
|
||||
#define APPLICATION_PIN PIN_PA4 // 0
|
||||
|
||||
# elif defined(__AVR_ATtiny1604__) // For use with megaTinyCore
|
||||
#define IR_RECEIVE_PIN PIN_PA6 // 2 - To be compatible with interrupt example, pin 2 is chosen here.
|
||||
#define IR_SEND_PIN PIN_PA7 // 3
|
||||
#define APPLICATION_PIN PIN_PB2 // 5
|
||||
|
||||
#define tone(...) void() // Define as void, since TCB0_INT_vect is also used by tone()
|
||||
#define noTone(a) void()
|
||||
#define TONE_PIN 42 // Dummy for examples using it
|
||||
|
||||
# elif defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) \
|
||||
|| defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) \
|
||||
|| defined(__AVR_ATmega324P__) || defined(__AVR_ATmega324A__) \
|
||||
|| defined(__AVR_ATmega324PA__) || defined(__AVR_ATmega164A__) \
|
||||
|| defined(__AVR_ATmega164P__) || defined(__AVR_ATmega32__) \
|
||||
|| defined(__AVR_ATmega16__) || defined(__AVR_ATmega8535__) \
|
||||
|| defined(__AVR_ATmega64__) || defined(__AVR_ATmega128__) \
|
||||
|| defined(__AVR_ATmega1281__) || defined(__AVR_ATmega2561__) \
|
||||
|| defined(__AVR_ATmega8515__) || defined(__AVR_ATmega162__)
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 13
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
# else // Default as for ATmega328 like on Uno, Nano, Leonardo, Teensy 2.0 etc.
|
||||
#define IR_RECEIVE_PIN 2 // To be compatible with interrupt example, pin 2 is chosen here.
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
# if defined(ARDUINO_AVR_PROMICRO) // Sparkfun Pro Micro is __AVR_ATmega32U4__ but has different external circuit
|
||||
// We have no built in LED at pin 13 -> reuse RX LED
|
||||
#undef LED_BUILTIN
|
||||
#define LED_BUILTIN LED_BUILTIN_RX
|
||||
# endif
|
||||
# endif // defined(__AVR_ATtiny25__)...
|
||||
|
||||
#elif defined(ARDUINO_ARCH_RENESAS_UNO) // Uno R4
|
||||
// To be compatible with Uno R3.
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
#elif defined(ESP8266)
|
||||
#define FEEDBACK_LED_IS_ACTIVE_LOW // The LED on my board (D4) is active LOW
|
||||
#define IR_RECEIVE_PIN 14 // D5
|
||||
#define IR_SEND_PIN 12 // D6 - D4/pin 2 is internal LED
|
||||
#define _IR_TIMING_TEST_PIN 2 // D4
|
||||
#define APPLICATION_PIN 13 // D7
|
||||
|
||||
#define tone(...) void() // tone() inhibits receive timer
|
||||
#define noTone(a) void()
|
||||
#define TONE_PIN 42 // Dummy for examples using it#
|
||||
|
||||
#elif defined(ARDUINO_NOLOGO_ESP32C3_SUPER_MINI)
|
||||
#define FEEDBACK_LED_IS_ACTIVE_LOW // The LED on my board (D8) is active LOW
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 10
|
||||
|
||||
#elif defined(CONFIG_IDF_TARGET_ESP32C3) || defined(ARDUINO_ESP32C3_DEV)
|
||||
#define NO_LED_FEEDBACK_CODE // The WS2812 on pin 8 of AI-C3 board crashes if used as receive feedback LED, other I/O pins are working...
|
||||
#define IR_RECEIVE_PIN 6
|
||||
#define IR_SEND_PIN 7
|
||||
#define TONE_PIN 10
|
||||
#define APPLICATION_PIN 18
|
||||
|
||||
#elif defined(ESP32)
|
||||
#include <Arduino.h>
|
||||
|
||||
// tone() is included in ESP32 core since 2.0.2
|
||||
#if !defined(ESP_ARDUINO_VERSION_VAL)
|
||||
#define ESP_ARDUINO_VERSION_VAL(major, minor, patch) 12345678
|
||||
#endif
|
||||
#if ESP_ARDUINO_VERSION <= ESP_ARDUINO_VERSION_VAL(2, 0, 2)
|
||||
#define TONE_LEDC_CHANNEL 1 // Using channel 1 makes tone() independent of receiving timer -> No need to stop receiving timer.
|
||||
void tone(uint8_t aPinNumber, unsigned int aFrequency){
|
||||
ledcAttachPin(aPinNumber, TONE_LEDC_CHANNEL);
|
||||
ledcWriteTone(TONE_LEDC_CHANNEL, aFrequency);
|
||||
}
|
||||
void tone(uint8_t aPinNumber, unsigned int aFrequency, unsigned long aDuration){
|
||||
ledcAttachPin(aPinNumber, TONE_LEDC_CHANNEL);
|
||||
ledcWriteTone(TONE_LEDC_CHANNEL, aFrequency);
|
||||
delay(aDuration);
|
||||
ledcWriteTone(TONE_LEDC_CHANNEL, 0);
|
||||
}
|
||||
void noTone(uint8_t aPinNumber){
|
||||
ledcWriteTone(TONE_LEDC_CHANNEL, 0);
|
||||
}
|
||||
#endif // ESP_ARDUINO_VERSION <= ESP_ARDUINO_VERSION_VAL(2, 0, 2)
|
||||
|
||||
#define IR_RECEIVE_PIN 15 // D15
|
||||
#define IR_SEND_PIN 4 // D4
|
||||
#define TONE_PIN 27 // D27 25 & 26 are DAC0 and 1
|
||||
#define APPLICATION_PIN 16 // RX2 pin
|
||||
|
||||
#elif defined(ARDUINO_ARCH_STM32) || defined(ARDUINO_ARCH_STM32F1) // BluePill
|
||||
// Timer 3 blocks PA6, PA7, PB0, PB1 for use by Servo or tone()
|
||||
#define IR_RECEIVE_PIN PA6
|
||||
#define IR_RECEIVE_PIN_STRING "PA6"
|
||||
#define IR_SEND_PIN PA7
|
||||
#define IR_SEND_PIN_STRING "PA7"
|
||||
#define TONE_PIN PA3
|
||||
#define _IR_TIMING_TEST_PIN PA5
|
||||
#define APPLICATION_PIN PA2
|
||||
#define APPLICATION_PIN_STRING "PA2"
|
||||
# if defined(ARDUINO_GENERIC_STM32F103C) || defined(ARDUINO_BLUEPILL_F103C8)
|
||||
// BluePill LED is active low
|
||||
#define FEEDBACK_LED_IS_ACTIVE_LOW
|
||||
# endif
|
||||
|
||||
#elif defined(ARDUINO_ARCH_APOLLO3) // Sparkfun Apollo boards
|
||||
#define IR_RECEIVE_PIN 11
|
||||
#define IR_SEND_PIN 12
|
||||
#define TONE_PIN 5
|
||||
|
||||
#elif defined(ARDUINO_ARCH_MBED) && defined(ARDUINO_ARCH_MBED_NANO) // Arduino Nano 33 BLE and Arduino Nano Connect layout for MBED
|
||||
// Must be before ARDUINO_ARCH_RP2040, since it is the layout for the MBED core of Arduino Nano Connect
|
||||
#define IR_RECEIVE_PIN 3 // GPIO15 Start with pin 3 since pin 2|GPIO25 is connected to LED on Pi pico
|
||||
#define IR_SEND_PIN 4 // GPIO16
|
||||
#define TONE_PIN 5
|
||||
#define APPLICATION_PIN 6
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 7 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 8
|
||||
|
||||
#elif defined(ARDUINO_ARCH_RP2040) // Arduino Nano Connect, Pi Pico with arduino-pico core https://github.com/earlephilhower/arduino-pico
|
||||
#define IR_RECEIVE_PIN 15 // GPIO15 to be compatible with the Arduino Nano RP2040 Connect (pin3)
|
||||
#define IR_SEND_PIN 16 // GPIO16
|
||||
#define TONE_PIN 17
|
||||
#define APPLICATION_PIN 18
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 19 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 20
|
||||
|
||||
// If you program the Nano RP2040 Connect with this core, then you must redefine LED_BUILTIN
|
||||
// and use the external reset with 1 kOhm to ground to enter UF2 mode
|
||||
#undef LED_BUILTIN
|
||||
#define LED_BUILTIN 6
|
||||
|
||||
#elif defined(PARTICLE) // !!!UNTESTED!!!
|
||||
#define IR_RECEIVE_PIN A4
|
||||
#define IR_SEND_PIN A5 // Particle supports multiple pins
|
||||
|
||||
#define LED_BUILTIN D7
|
||||
|
||||
/*
|
||||
* 4 times the same (default) layout for easy adaption in the future
|
||||
*/
|
||||
#elif defined(TEENSYDUINO) // Teensy 2.0 is handled at default for ATmega328 like on Uno, Nano, Leonardo etc.
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
#elif defined(ARDUINO_ARCH_MBED) // Arduino Nano 33 BLE
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
#elif defined(ARDUINO_ARCH_SAMD) || defined(ARDUINO_ARCH_SAM)
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
#if !defined(ARDUINO_SAMD_ADAFRUIT) && !defined(ARDUINO_SEEED_XIAO_M0)
|
||||
// On the Zero and others we switch explicitly to SerialUSB
|
||||
#define Serial SerialUSB
|
||||
#endif
|
||||
|
||||
// Definitions for the Chinese SAMD21 M0-Mini clone, which has no led connected to D13/PA17.
|
||||
// Attention!!! D2 and D4 are swapped on these boards!!!
|
||||
// If you connect the LED, it is on pin 24/PB11. In this case activate the next two lines.
|
||||
//#undef LED_BUILTIN
|
||||
//#define LED_BUILTIN 24 // PB11
|
||||
// As an alternative you can choose pin 25, it is the RX-LED pin (PB03), but active low.In this case activate the next 3 lines.
|
||||
//#undef LED_BUILTIN
|
||||
//#define LED_BUILTIN 25 // PB03
|
||||
//#define FEEDBACK_LED_IS_ACTIVE_LOW // The RX LED on the M0-Mini is active LOW
|
||||
|
||||
#elif defined (NRF51) // BBC micro:bit
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define APPLICATION_PIN 1
|
||||
#define _IR_TIMING_TEST_PIN 4
|
||||
|
||||
#define tone(...) void() // no tone() available
|
||||
#define noTone(a) void()
|
||||
#define TONE_PIN 42 // Dummy for examples using it
|
||||
|
||||
#else
|
||||
#warning Board / CPU is not detected using pre-processor symbols -> using default values, which may not fit. Please extend PinDefinitionsAndMore.h.
|
||||
// Default valued for unidentified boards
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
#endif // defined(ESP8266)
|
||||
|
||||
#if defined(ESP32) || defined(ARDUINO_ARCH_RP2040) || defined(PARTICLE) || defined(ARDUINO_ARCH_MBED)
|
||||
#define SEND_PWM_BY_TIMER // We do not have pin restrictions for this CPU's, so lets use the hardware PWM for send carrier signal generation
|
||||
#else
|
||||
# if defined(SEND_PWM_BY_TIMER)
|
||||
#undef IR_SEND_PIN // SendPin is determined by timer! This avoids warnings in IRremote.hpp and IRTimer.hpp
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if !defined (FLASHEND)
|
||||
#define FLASHEND 0xFFFF // Dummy value for platforms where FLASHEND is not defined
|
||||
#endif
|
||||
|
||||
/*
|
||||
* 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
|
||||
@@ -0,0 +1,166 @@
|
||||
/*
|
||||
* SendAndReceive.cpp
|
||||
*
|
||||
* Demonstrates sending IR codes and receiving it simultaneously
|
||||
*
|
||||
* This file is part of Arduino-IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
|
||||
*
|
||||
************************************************************************************
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2021-2023 Armin Joachimsmeyer
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is furnished
|
||||
* to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
************************************************************************************
|
||||
*/
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
// select only NEC and the universal decoder for pulse distance protocols
|
||||
#define DECODE_NEC // Includes Apple and Onkyo
|
||||
#define DECODE_DISTANCE_WIDTH // In case NEC is not received correctly. Universal decoder for pulse distance width protocols
|
||||
|
||||
//#define EXCLUDE_UNIVERSAL_PROTOCOLS // Saves up to 1000 bytes program memory.
|
||||
//#define EXCLUDE_EXOTIC_PROTOCOLS // saves around 650 bytes program memory if all other protocols are active
|
||||
//#define NO_LED_FEEDBACK_CODE // saves 92 bytes program memory
|
||||
//#define RECORD_GAP_MICROS 12000 // Default is 8000. Activate it for some LG air conditioner protocols
|
||||
#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 DEBUG // Activate this for lots of lovely debug output from the decoders.
|
||||
|
||||
#define IR_RECEIVE_PIN 4
|
||||
#ifndef IR_SEND_PIN
|
||||
#define IR_SEND_PIN 3 // P0_0
|
||||
#endif
|
||||
|
||||
/*
|
||||
* 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 <IRremote.hpp>
|
||||
|
||||
#define DELAY_AFTER_SEND 2000
|
||||
#define DELAY_AFTER_LOOP 5000
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
while (!Serial)
|
||||
; // Wait for Serial to become available. Is optimized away for some cores.
|
||||
|
||||
// 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
|
||||
IrReceiver.begin(IR_RECEIVE_PIN, ENABLE_LED_FEEDBACK);
|
||||
|
||||
Serial.print(F("Ready to receive IR signals of protocols: "));
|
||||
printActiveIRProtocols(&Serial);
|
||||
Serial.println(F("at pin " STR(IR_RECEIVE_PIN)));
|
||||
IrSender.begin(); // Start with IR_SEND_PIN as send pin and enable feedback LED at default feedback LED pin
|
||||
Serial.println(F("Send IR signals at pin " STR(IR_SEND_PIN)));
|
||||
|
||||
# if !defined(SEND_PWM_BY_TIMER) && !defined(USE_NO_SEND_PWM)
|
||||
/*
|
||||
* Print internal software PWM generation info
|
||||
*/
|
||||
IrSender.enableIROut(38); // Call it with 38 kHz to initialize the values printed below
|
||||
Serial.print(F("Send signal mark duration is "));
|
||||
Serial.print(IrSender.periodOnTimeMicros);
|
||||
Serial.print(F(" us, pulse correction is "));
|
||||
Serial.print(IrSender.getPulseCorrectionNanos());
|
||||
Serial.print(F(" ns, total period is "));
|
||||
Serial.print(IrSender.periodTimeMicros);
|
||||
Serial.println(F(" us"));
|
||||
# endif
|
||||
|
||||
// infos for receive
|
||||
Serial.print(RECORD_GAP_MICROS);
|
||||
Serial.println(F(" us is the (minimum) gap, after which the start of a new IR packet is assumed"));
|
||||
Serial.print(MARK_EXCESS_MICROS);
|
||||
Serial.println(F(" us are subtracted from all marks and added to all spaces for decoding"));
|
||||
}
|
||||
|
||||
uint16_t sAddress = 0x0102;
|
||||
uint8_t sCommand = 0x34;
|
||||
uint8_t sRepeats = 1;
|
||||
|
||||
/*
|
||||
* Send NEC IR protocol
|
||||
*/
|
||||
void send_ir_data() {
|
||||
Serial.print(F("Sending: 0x"));
|
||||
Serial.print(sAddress, HEX);
|
||||
Serial.print(sCommand, HEX);
|
||||
Serial.println(sRepeats, HEX);
|
||||
Serial.flush(); // To avoid disturbing the software PWM generation by serial output interrupts
|
||||
|
||||
// clip repeats at 4
|
||||
if (sRepeats > 4) {
|
||||
sRepeats = 4;
|
||||
}
|
||||
// Results for the first loop to: Protocol=NEC Address=0x102 Command=0x34 Raw-Data=0xCB340102 (32 bits)
|
||||
IrSender.sendNEC(sAddress, sCommand, sRepeats);
|
||||
}
|
||||
|
||||
void receive_ir_data() {
|
||||
if (IrReceiver.decode()) {
|
||||
Serial.print(F("Decoded protocol: "));
|
||||
Serial.print(getProtocolString(IrReceiver.decodedIRData.protocol));
|
||||
Serial.print(F(", decoded raw data: "));
|
||||
Serial.print(IrReceiver.decodedIRData.decodedRawData, HEX);
|
||||
Serial.print(F(", decoded address: "));
|
||||
Serial.print(IrReceiver.decodedIRData.address, HEX);
|
||||
Serial.print(F(", decoded command: "));
|
||||
Serial.println(IrReceiver.decodedIRData.command, HEX);
|
||||
IrReceiver.resume();
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
/*
|
||||
* Print loop values
|
||||
*/
|
||||
Serial.println();
|
||||
Serial.print(F("address=0x"));
|
||||
Serial.print(sAddress, HEX);
|
||||
Serial.print(F(" command=0x"));
|
||||
Serial.print(sCommand, HEX);
|
||||
Serial.print(F(" repeats="));
|
||||
Serial.println(sRepeats);
|
||||
Serial.flush();
|
||||
|
||||
send_ir_data();
|
||||
IrReceiver.restartAfterSend(); // Is a NOP if sending does not require a timer.
|
||||
|
||||
// wait for the receiver state machine to detect the end of a protocol
|
||||
delay((RECORD_GAP_MICROS / 1000) + 5);
|
||||
receive_ir_data();
|
||||
|
||||
// Prepare data for next loop
|
||||
sAddress += 0x0101;
|
||||
sCommand += 0x11;
|
||||
sRepeats++;
|
||||
|
||||
delay(500); // Loop delay
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
START ../src/SendAndReceive.cpp from Feb 24 2023
|
||||
Using library version 4.1.0
|
||||
Ready to receive IR signals of protocols: NEC/NEC2/Onkyo/Apple, Universal Pulse Distance Width, at pin 2
|
||||
Send IR signals at pin 3
|
||||
Send signal mark duration is 8 us, pulse correction is 3000 ns, total period is 26 us
|
||||
5000 us is the (minimum) gap, after which the start of a new IR packet is assumed
|
||||
20 us are subtracted from all marks and added to all spaces for decoding
|
||||
|
||||
address=0x102 command=0x34 repeats=1
|
||||
Sending: 0x102341
|
||||
Decoded protocol: NEC2, decoded raw data: CB340102, decoded address: 102, decoded command: 34
|
||||
|
||||
address=0x203 command=0x45 repeats=2
|
||||
Sending: 0x203452
|
||||
Decoded protocol: NEC, decoded raw data: BA450203, decoded address: 203, decoded command: 45
|
||||
|
||||
address=0x304 command=0x56 repeats=3
|
||||
Sending: 0x304563
|
||||
Decoded protocol: NEC, decoded raw data: A9560304, decoded address: 304, decoded command: 56
|
||||
|
||||
address=0x405 command=0x67 repeats=4
|
||||
Sending: 0x405674
|
||||
Decoded protocol: NEC, decoded raw data: 98670405, decoded address: 405, decoded command: 67
|
||||
|
||||
address=0x506 command=0x78 repeats=5
|
||||
Sending: 0x506785
|
||||
Decoded protocol: NEC, decoded raw data: 87780506, decoded address: 506, decoded command: 78
|
||||
|
||||
address=0x607 command=0x89 repeats=5
|
||||
Sending: 0x607895
|
||||
Decoded protocol: NEC, decoded raw data: 76890607, decoded address: 607, decoded command: 89
|
||||
|
||||
address=0x708 command=0x9A repeats=5
|
||||
Sending: 0x7089A5
|
||||
Decoded protocol: NEC, decoded raw data: 659A0708, decoded address: 708, decoded command: 9A
|
||||
|
||||
address=0x809 command=0xAB repeats=5
|
||||
Sending: 0x809AB5
|
||||
Decoded protocol: NEC, decoded raw data: 54AB0809, decoded address: 809, decoded command: AB
|
||||
@@ -0,0 +1,349 @@
|
||||
/*
|
||||
* PinDefinitionsAndMore.h
|
||||
*
|
||||
* Contains pin definitions for IRremote examples for various platforms
|
||||
* as well as definitions for feedback LED and tone() and includes
|
||||
*
|
||||
* Copyright (C) 2021-2023 Armin Joachimsmeyer
|
||||
* armin.joachimsmeyer@gmail.com
|
||||
*
|
||||
* This file is part of IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
|
||||
*
|
||||
* Arduino-IRremote is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/gpl.html>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Pin mapping table for different platforms
|
||||
*
|
||||
* Platform IR input IR output Tone Core/Pin schema
|
||||
* --------------------------------------------------------------
|
||||
* DEFAULT/AVR 2 3 4 Arduino
|
||||
* ATtinyX5 0|PB0 4|PB4 3|PB3 ATTinyCore
|
||||
* ATtiny167 3|PA3 2|PA2 7|PA7 ATTinyCore
|
||||
* ATtiny167 9|PA3 8|PA2 5|PA7 Digispark original core
|
||||
* ATtiny84 |PB2 |PA4 |PA3 ATTinyCore
|
||||
* ATtiny88 3|PD3 4|PD4 9|PB1 ATTinyCore
|
||||
* ATtiny3217 18|PA1 19|PA2 20|PA3 MegaTinyCore
|
||||
* ATtiny1604 2 3|PA5 %
|
||||
* ATtiny816 14|PA1 16|PA3 1|PA5 MegaTinyCore
|
||||
* ATtiny1614 8|PA1 10|PA3 1|PA5 MegaTinyCore
|
||||
* SAMD21 3 4 5
|
||||
* ESP8266 14|D5 12|D6 %
|
||||
* ESP32 15 4 27
|
||||
* ESP32-C3 2 3 4
|
||||
* BluePill PA6 PA7 PA3
|
||||
* APOLLO3 11 12 5
|
||||
* RP2040 3|GPIO15 4|GPIO16 5|GPIO17
|
||||
*/
|
||||
//#define _IR_MEASURE_TIMING // For debugging purposes.
|
||||
|
||||
#if defined(__AVR__)
|
||||
#if defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__) // Digispark board. For use with ATTinyCore.
|
||||
#include "ATtinySerialOut.hpp" // TX is at pin 2 - Available as Arduino library "ATtinySerialOut". Saves 700 bytes program memory and 70 bytes RAM for ATtinyCore.
|
||||
#define IR_RECEIVE_PIN PIN_PB0
|
||||
#define IR_SEND_PIN PIN_PB4 // Pin 2 is serial output with ATtinySerialOut. Pin 1 is internal LED and Pin3 is USB+ with pullup on Digispark board.
|
||||
#define TONE_PIN PIN_PB3
|
||||
#define _IR_TIMING_TEST_PIN PIN_PB3
|
||||
|
||||
# elif defined(__AVR_ATtiny87__) || defined(__AVR_ATtiny167__) // Digispark pro board
|
||||
#include "ATtinySerialOut.hpp" // Available as Arduino library "ATtinySerialOut"
|
||||
// For ATtiny167 Pins PB6 and PA3 are usable as interrupt source.
|
||||
# if defined(ARDUINO_AVR_DIGISPARKPRO)
|
||||
// For use with Digispark original core
|
||||
#define IR_RECEIVE_PIN 9 // PA3 - on Digispark board labeled as pin 9
|
||||
//#define IR_RECEIVE_PIN 14 // PB6 / INT0 is connected to USB+ on DigisparkPro boards
|
||||
#define IR_SEND_PIN 8 // PA2 - on Digispark board labeled as pin 8
|
||||
#define TONE_PIN 5 // PA7 - on Digispark board labeled as pin 5
|
||||
#define _IR_TIMING_TEST_PIN 10 // PA4
|
||||
# else
|
||||
// For use with ATTinyCore
|
||||
#define IR_RECEIVE_PIN PIN_PA3 // On Digispark board labeled as pin 9 - INT0 is connected to USB+ on DigisparkPro boards
|
||||
#define IR_SEND_PIN PIN_PA2 // On Digispark board labeled as pin 8
|
||||
#define TONE_PIN PIN_PA7 // On Digispark board labeled as pin 5
|
||||
# endif
|
||||
|
||||
# elif defined(__AVR_ATtiny84__) // For use with ATTinyCore
|
||||
#include "ATtinySerialOut.hpp" // Available as Arduino library "ATtinySerialOut". Saves 128 bytes program memory.
|
||||
#define IR_RECEIVE_PIN PIN_PB2 // INT0
|
||||
#define IR_SEND_PIN PIN_PA4
|
||||
#define TONE_PIN PIN_PA3
|
||||
#define _IR_TIMING_TEST_PIN PIN_PA5
|
||||
|
||||
# elif defined(__AVR_ATtiny88__) // MH-ET Tiny88 board. For use with ATTinyCore.
|
||||
#include "ATtinySerialOut.hpp" // Available as Arduino library "ATtinySerialOut". Saves 128 bytes program memory.
|
||||
// Pin 6 is TX, pin 7 is RX
|
||||
#define IR_RECEIVE_PIN PIN_PD3 // 3 - INT1
|
||||
#define IR_SEND_PIN PIN_PD4 // 4
|
||||
#define TONE_PIN PIN_PB1 // 9
|
||||
#define _IR_TIMING_TEST_PIN PIN_PB0 // 8
|
||||
|
||||
# elif defined(__AVR_ATtiny1616__) || defined(__AVR_ATtiny3216__) || defined(__AVR_ATtiny3217__) // For use with megaTinyCore
|
||||
// Tiny Core Dev board
|
||||
// https://www.tindie.com/products/xkimi/tiny-core-16-dev-board-attiny1616/ - Out of Stock
|
||||
// https://www.tindie.com/products/xkimi/tiny-core-32-dev-board-attiny3217/ - Out of Stock
|
||||
#define IR_RECEIVE_PIN PIN_PA1 // use 18 instead of PIN_PA1 for TinyCore32
|
||||
#define IR_SEND_PIN PIN_PA2 // 19
|
||||
#define TONE_PIN PIN_PA3 // 20
|
||||
#define APPLICATION_PIN PIN_PA0 // 0
|
||||
#undef LED_BUILTIN // No LED available on the TinyCore 32 board, take the one on the programming board which is connected to the DAC output
|
||||
#define LED_BUILTIN PIN_PA6 // use 2 instead of PIN_PA6 for TinyCore32
|
||||
|
||||
# elif defined(__AVR_ATtiny816__) // For use with megaTinyCore
|
||||
#define IR_RECEIVE_PIN PIN_PA1 // 14
|
||||
#define IR_SEND_PIN PIN_PA1 // 16
|
||||
#define TONE_PIN PIN_PA5 // 1
|
||||
#define APPLICATION_PIN PIN_PA4 // 0
|
||||
#undef LED_BUILTIN // No LED available, take the one which is connected to the DAC output
|
||||
#define LED_BUILTIN PIN_PB5 // 4
|
||||
|
||||
# elif defined(__AVR_ATtiny1614__) // For use with megaTinyCore
|
||||
#define IR_RECEIVE_PIN PIN_PA1 // 8
|
||||
#define IR_SEND_PIN PIN_PA3 // 10
|
||||
#define TONE_PIN PIN_PA5 // 1
|
||||
#define APPLICATION_PIN PIN_PA4 // 0
|
||||
|
||||
# elif defined(__AVR_ATtiny1604__) // For use with megaTinyCore
|
||||
#define IR_RECEIVE_PIN PIN_PA6 // 2 - To be compatible with interrupt example, pin 2 is chosen here.
|
||||
#define IR_SEND_PIN PIN_PA7 // 3
|
||||
#define APPLICATION_PIN PIN_PB2 // 5
|
||||
|
||||
#define tone(...) void() // Define as void, since TCB0_INT_vect is also used by tone()
|
||||
#define noTone(a) void()
|
||||
#define TONE_PIN 42 // Dummy for examples using it
|
||||
|
||||
# elif defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) \
|
||||
|| defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) \
|
||||
|| defined(__AVR_ATmega324P__) || defined(__AVR_ATmega324A__) \
|
||||
|| defined(__AVR_ATmega324PA__) || defined(__AVR_ATmega164A__) \
|
||||
|| defined(__AVR_ATmega164P__) || defined(__AVR_ATmega32__) \
|
||||
|| defined(__AVR_ATmega16__) || defined(__AVR_ATmega8535__) \
|
||||
|| defined(__AVR_ATmega64__) || defined(__AVR_ATmega128__) \
|
||||
|| defined(__AVR_ATmega1281__) || defined(__AVR_ATmega2561__) \
|
||||
|| defined(__AVR_ATmega8515__) || defined(__AVR_ATmega162__)
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 13
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
# else // Default as for ATmega328 like on Uno, Nano, Leonardo, Teensy 2.0 etc.
|
||||
#define IR_RECEIVE_PIN 2 // To be compatible with interrupt example, pin 2 is chosen here.
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
# if defined(ARDUINO_AVR_PROMICRO) // Sparkfun Pro Micro is __AVR_ATmega32U4__ but has different external circuit
|
||||
// We have no built in LED at pin 13 -> reuse RX LED
|
||||
#undef LED_BUILTIN
|
||||
#define LED_BUILTIN LED_BUILTIN_RX
|
||||
# endif
|
||||
# endif // defined(__AVR_ATtiny25__)...
|
||||
|
||||
#elif defined(ARDUINO_ARCH_RENESAS_UNO) // Uno R4
|
||||
// To be compatible with Uno R3.
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
#elif defined(ESP8266)
|
||||
#define FEEDBACK_LED_IS_ACTIVE_LOW // The LED on my board (D4) is active LOW
|
||||
#define IR_RECEIVE_PIN 14 // D5
|
||||
#define IR_SEND_PIN 12 // D6 - D4/pin 2 is internal LED
|
||||
#define _IR_TIMING_TEST_PIN 2 // D4
|
||||
#define APPLICATION_PIN 13 // D7
|
||||
|
||||
#define tone(...) void() // tone() inhibits receive timer
|
||||
#define noTone(a) void()
|
||||
#define TONE_PIN 42 // Dummy for examples using it#
|
||||
|
||||
#elif defined(ARDUINO_NOLOGO_ESP32C3_SUPER_MINI)
|
||||
#define FEEDBACK_LED_IS_ACTIVE_LOW // The LED on my board (D8) is active LOW
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 10
|
||||
|
||||
#elif defined(CONFIG_IDF_TARGET_ESP32C3) || defined(ARDUINO_ESP32C3_DEV)
|
||||
#define NO_LED_FEEDBACK_CODE // The WS2812 on pin 8 of AI-C3 board crashes if used as receive feedback LED, other I/O pins are working...
|
||||
#define IR_RECEIVE_PIN 6
|
||||
#define IR_SEND_PIN 7
|
||||
#define TONE_PIN 10
|
||||
#define APPLICATION_PIN 18
|
||||
|
||||
#elif defined(ESP32)
|
||||
#include <Arduino.h>
|
||||
|
||||
// tone() is included in ESP32 core since 2.0.2
|
||||
#if !defined(ESP_ARDUINO_VERSION_VAL)
|
||||
#define ESP_ARDUINO_VERSION_VAL(major, minor, patch) 12345678
|
||||
#endif
|
||||
#if ESP_ARDUINO_VERSION <= ESP_ARDUINO_VERSION_VAL(2, 0, 2)
|
||||
#define TONE_LEDC_CHANNEL 1 // Using channel 1 makes tone() independent of receiving timer -> No need to stop receiving timer.
|
||||
void tone(uint8_t aPinNumber, unsigned int aFrequency){
|
||||
ledcAttachPin(aPinNumber, TONE_LEDC_CHANNEL);
|
||||
ledcWriteTone(TONE_LEDC_CHANNEL, aFrequency);
|
||||
}
|
||||
void tone(uint8_t aPinNumber, unsigned int aFrequency, unsigned long aDuration){
|
||||
ledcAttachPin(aPinNumber, TONE_LEDC_CHANNEL);
|
||||
ledcWriteTone(TONE_LEDC_CHANNEL, aFrequency);
|
||||
delay(aDuration);
|
||||
ledcWriteTone(TONE_LEDC_CHANNEL, 0);
|
||||
}
|
||||
void noTone(uint8_t aPinNumber){
|
||||
ledcWriteTone(TONE_LEDC_CHANNEL, 0);
|
||||
}
|
||||
#endif // ESP_ARDUINO_VERSION <= ESP_ARDUINO_VERSION_VAL(2, 0, 2)
|
||||
|
||||
#define IR_RECEIVE_PIN 15 // D15
|
||||
#define IR_SEND_PIN 4 // D4
|
||||
#define TONE_PIN 27 // D27 25 & 26 are DAC0 and 1
|
||||
#define APPLICATION_PIN 16 // RX2 pin
|
||||
|
||||
#elif defined(ARDUINO_ARCH_STM32) || defined(ARDUINO_ARCH_STM32F1) // BluePill
|
||||
// Timer 3 blocks PA6, PA7, PB0, PB1 for use by Servo or tone()
|
||||
#define IR_RECEIVE_PIN PA6
|
||||
#define IR_RECEIVE_PIN_STRING "PA6"
|
||||
#define IR_SEND_PIN PA7
|
||||
#define IR_SEND_PIN_STRING "PA7"
|
||||
#define TONE_PIN PA3
|
||||
#define _IR_TIMING_TEST_PIN PA5
|
||||
#define APPLICATION_PIN PA2
|
||||
#define APPLICATION_PIN_STRING "PA2"
|
||||
# if defined(ARDUINO_GENERIC_STM32F103C) || defined(ARDUINO_BLUEPILL_F103C8)
|
||||
// BluePill LED is active low
|
||||
#define FEEDBACK_LED_IS_ACTIVE_LOW
|
||||
# endif
|
||||
|
||||
#elif defined(ARDUINO_ARCH_APOLLO3) // Sparkfun Apollo boards
|
||||
#define IR_RECEIVE_PIN 11
|
||||
#define IR_SEND_PIN 12
|
||||
#define TONE_PIN 5
|
||||
|
||||
#elif defined(ARDUINO_ARCH_MBED) && defined(ARDUINO_ARCH_MBED_NANO) // Arduino Nano 33 BLE and Arduino Nano Connect layout for MBED
|
||||
// Must be before ARDUINO_ARCH_RP2040, since it is the layout for the MBED core of Arduino Nano Connect
|
||||
#define IR_RECEIVE_PIN 3 // GPIO15 Start with pin 3 since pin 2|GPIO25 is connected to LED on Pi pico
|
||||
#define IR_SEND_PIN 4 // GPIO16
|
||||
#define TONE_PIN 5
|
||||
#define APPLICATION_PIN 6
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 7 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 8
|
||||
|
||||
#elif defined(ARDUINO_ARCH_RP2040) // Arduino Nano Connect, Pi Pico with arduino-pico core https://github.com/earlephilhower/arduino-pico
|
||||
#define IR_RECEIVE_PIN 15 // GPIO15 to be compatible with the Arduino Nano RP2040 Connect (pin3)
|
||||
#define IR_SEND_PIN 16 // GPIO16
|
||||
#define TONE_PIN 17
|
||||
#define APPLICATION_PIN 18
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 19 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 20
|
||||
|
||||
// If you program the Nano RP2040 Connect with this core, then you must redefine LED_BUILTIN
|
||||
// and use the external reset with 1 kOhm to ground to enter UF2 mode
|
||||
#undef LED_BUILTIN
|
||||
#define LED_BUILTIN 6
|
||||
|
||||
#elif defined(PARTICLE) // !!!UNTESTED!!!
|
||||
#define IR_RECEIVE_PIN A4
|
||||
#define IR_SEND_PIN A5 // Particle supports multiple pins
|
||||
|
||||
#define LED_BUILTIN D7
|
||||
|
||||
/*
|
||||
* 4 times the same (default) layout for easy adaption in the future
|
||||
*/
|
||||
#elif defined(TEENSYDUINO) // Teensy 2.0 is handled at default for ATmega328 like on Uno, Nano, Leonardo etc.
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
#elif defined(ARDUINO_ARCH_MBED) // Arduino Nano 33 BLE
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
#elif defined(ARDUINO_ARCH_SAMD) || defined(ARDUINO_ARCH_SAM)
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
#if !defined(ARDUINO_SAMD_ADAFRUIT) && !defined(ARDUINO_SEEED_XIAO_M0)
|
||||
// On the Zero and others we switch explicitly to SerialUSB
|
||||
#define Serial SerialUSB
|
||||
#endif
|
||||
|
||||
// Definitions for the Chinese SAMD21 M0-Mini clone, which has no led connected to D13/PA17.
|
||||
// Attention!!! D2 and D4 are swapped on these boards!!!
|
||||
// If you connect the LED, it is on pin 24/PB11. In this case activate the next two lines.
|
||||
//#undef LED_BUILTIN
|
||||
//#define LED_BUILTIN 24 // PB11
|
||||
// As an alternative you can choose pin 25, it is the RX-LED pin (PB03), but active low.In this case activate the next 3 lines.
|
||||
//#undef LED_BUILTIN
|
||||
//#define LED_BUILTIN 25 // PB03
|
||||
//#define FEEDBACK_LED_IS_ACTIVE_LOW // The RX LED on the M0-Mini is active LOW
|
||||
|
||||
#elif defined (NRF51) // BBC micro:bit
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define APPLICATION_PIN 1
|
||||
#define _IR_TIMING_TEST_PIN 4
|
||||
|
||||
#define tone(...) void() // no tone() available
|
||||
#define noTone(a) void()
|
||||
#define TONE_PIN 42 // Dummy for examples using it
|
||||
|
||||
#else
|
||||
#warning Board / CPU is not detected using pre-processor symbols -> using default values, which may not fit. Please extend PinDefinitionsAndMore.h.
|
||||
// Default valued for unidentified boards
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
#endif // defined(ESP8266)
|
||||
|
||||
#if defined(ESP32) || defined(ARDUINO_ARCH_RP2040) || defined(PARTICLE) || defined(ARDUINO_ARCH_MBED)
|
||||
#define SEND_PWM_BY_TIMER // We do not have pin restrictions for this CPU's, so lets use the hardware PWM for send carrier signal generation
|
||||
#else
|
||||
# if defined(SEND_PWM_BY_TIMER)
|
||||
#undef IR_SEND_PIN // SendPin is determined by timer! This avoids warnings in IRremote.hpp and IRTimer.hpp
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if !defined (FLASHEND)
|
||||
#define FLASHEND 0xFFFF // Dummy value for platforms where FLASHEND is not defined
|
||||
#endif
|
||||
|
||||
/*
|
||||
* 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
|
||||
@@ -0,0 +1,217 @@
|
||||
/*
|
||||
* SendBoseWaveDemo.cpp
|
||||
*
|
||||
* Prompt user for a code to send. Make sure your 940-950nm IR LED is
|
||||
* connected to the default digital output. Place your Bose Wave Radio
|
||||
* CD in the line of sight of your LED, and send commands!
|
||||
*
|
||||
* This file is part of Arduino-IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
|
||||
*
|
||||
************************************************************************************
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2020 Thomas Koch - 2022 AJ converted to inverted bits
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is furnished
|
||||
* to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
************************************************************************************
|
||||
*/
|
||||
#include <Arduino.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
|
||||
|
||||
#if !defined(IR_SEND_PIN)
|
||||
#define IR_SEND_PIN 3 // P0_0
|
||||
#endif
|
||||
|
||||
#include <IRremote.hpp>
|
||||
|
||||
|
||||
|
||||
//......................................................................
|
||||
//
|
||||
// Bose Wave Radio CD Remote Control
|
||||
// |-------------------------------------|
|
||||
// | On/Off Sleep VolUp |
|
||||
// | Play/Pause Stop VolDown |
|
||||
// | FM AM Aux |
|
||||
// | Tune Down Tune Up Mute |
|
||||
// | 1 2 3 |
|
||||
// | 4 5 6 |
|
||||
// |-------------------------------------|
|
||||
#define BOSE_CMD_ON_OFF 0x00
|
||||
#define BOSE_CMD_MUTE 0x01
|
||||
#define BOSE_CMD_VOL_UP 0x02
|
||||
#define BOSE_CMD_VOL_DOWN 0x03
|
||||
#define BOSE_CMD_PRESET_6 0x04
|
||||
#define BOSE_CMD_SLEEP 0x05
|
||||
#define BOSE_CMD_FM 0x06
|
||||
#define BOSE_CMD_AUX 0x07
|
||||
#define BOSE_CMD_AM 0x08
|
||||
#define BOSE_CMD_PLAY_PAUSE 0x09
|
||||
#define BOSE_CMD_STOP 0x0A
|
||||
#define BOSE_CMD_TUNE_UP 0x0B
|
||||
#define BOSE_CMD_TUNE_DOWN 0x0C
|
||||
#define BOSE_CMD_PRESET_1 0x0D
|
||||
#define BOSE_CMD_PRESET_2 0x0E
|
||||
#define BOSE_CMD_PRESET_3 0x0F
|
||||
#define BOSE_CMD_PRESET_4 0x10
|
||||
#define BOSE_CMD_PRESET_5 0x11
|
||||
|
||||
// Codes for Wave Music System
|
||||
// https://github.com/Arduino-IRremote/Arduino-IRremote/blob/master/pictures/BoseWaveMusicSystem.jpg)
|
||||
//#define BOSE_CMD_ON_OFF 0x4C
|
||||
//#define BOSE_CMD_MUTE 0x01
|
||||
//#define BOSE_CMD_VOL_UP 0x03
|
||||
//#define BOSE_CMD_VOL_DOWN 0x02
|
||||
//#define BOSE_CMD_SLEEP 0x54
|
||||
//#define BOSE_CMD_FM_AM 0x06
|
||||
//#define BOSE_CMD_CD 0x53
|
||||
//#define BOSE_CMD_AUX 0x0F
|
||||
//#define BOSE_CMD_TRACK_BW 0x18
|
||||
//#define BOSE_CMD_TRACK_FW 0x19
|
||||
//#define BOSE_CMD_PLAY_PAUSE 0x1B
|
||||
//#define BOSE_CMD_STOP_EJECT 0x1A
|
||||
//#define BOSE_CMD_TUNE_UP 0x58
|
||||
//#define BOSE_CMD_TUNE_DOWN 0x57
|
||||
//#define BOSE_CMD_PRESET_1 0x07
|
||||
//#define BOSE_CMD_PRESET_2 0x08
|
||||
//#define BOSE_CMD_PRESET_3 0x09
|
||||
//#define BOSE_CMD_PRESET_4 0x0A
|
||||
//#define BOSE_CMD_PRESET_5 0x0B
|
||||
//#define BOSE_CMD_PRESET_6 0x0C
|
||||
//#define BOSE_CMD_TIME_MINUS 0x9E
|
||||
//#define BOSE_CMD_TIME_PLUS 0x24
|
||||
//#define BOSE_CMD_PLAY_MODE 0x21
|
||||
//#define BOSE_CMD_ALARM_ON_OFF 0x22
|
||||
//#define BOSE_CMD_ALARM_WAKE_TO 0x70
|
||||
//#define BOSE_CMD_ALARM_TIME 0x23
|
||||
// Different last 3 codes for Wave Sound Touch IV
|
||||
//#define BOSE_CMD_ALARM_1 0x22
|
||||
//#define BOSE_CMD_ALARM_2 0x62
|
||||
//#define BOSE_CMD_ALARM_SETUP 0xA2
|
||||
|
||||
bool sPrintMenu;
|
||||
void printMenu();
|
||||
|
||||
void setup() {
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
|
||||
Serial.begin(9600);
|
||||
while (!Serial)
|
||||
; // Wait for Serial to become available. Is optimized away for some cores.
|
||||
|
||||
// Just to know which program is running on my Arduino
|
||||
Serial.println(F("START " __FILE__ " from " __DATE__ "\r\nUsing library version " VERSION_IRREMOTE));
|
||||
|
||||
#if defined(IR_SEND_PIN)
|
||||
IrSender.begin(); // Start with IR_SEND_PIN as send pin and enable feedback LED at default feedback LED pin
|
||||
Serial.println(F("Send IR signals at pin " STR(IR_SEND_PIN)));
|
||||
#else
|
||||
uint8_t tSendPin = 3;
|
||||
IrSender.begin(tSendPin, ENABLE_LED_FEEDBACK, USE_DEFAULT_FEEDBACK_LED_PIN); // Specify send pin and enable feedback LED at default feedback LED pin
|
||||
// You can change send pin later with IrSender.setSendPin();
|
||||
|
||||
Serial.print(F("Send IR signals at pin "));
|
||||
Serial.println(tSendPin);
|
||||
#endif
|
||||
|
||||
sPrintMenu = true;
|
||||
}
|
||||
|
||||
void loop() {
|
||||
if (sPrintMenu) {
|
||||
sPrintMenu = false;
|
||||
printMenu();
|
||||
}
|
||||
int tSerialCommandCharacter;
|
||||
|
||||
if (Serial.available()) {
|
||||
tSerialCommandCharacter = Serial.read();
|
||||
sPrintMenu = true;
|
||||
if (tSerialCommandCharacter == -1) {
|
||||
Serial.print(F("available() was true, but no character read")); // should not happen
|
||||
} else if (tSerialCommandCharacter == 48) { // 0
|
||||
IrSender.sendBoseWave(BOSE_CMD_ON_OFF); // On/Off
|
||||
} else if (tSerialCommandCharacter == 49) { // 1
|
||||
IrSender.sendBoseWave(BOSE_CMD_VOL_UP); // Volume Up
|
||||
} else if (tSerialCommandCharacter == 50) { // 2
|
||||
IrSender.sendBoseWave(BOSE_CMD_VOL_DOWN); // Volume Down
|
||||
} else if (tSerialCommandCharacter == 51) { // 3
|
||||
IrSender.sendBoseWave(BOSE_CMD_TUNE_UP); // Tune Up
|
||||
} else if (tSerialCommandCharacter == 52) { // 4
|
||||
IrSender.sendBoseWave(BOSE_CMD_TUNE_DOWN); // Tune Down
|
||||
} else if (tSerialCommandCharacter == 53) { // 5
|
||||
IrSender.sendBoseWave(BOSE_CMD_AM); // AM
|
||||
} else if (tSerialCommandCharacter == 54) { // 6
|
||||
IrSender.sendBoseWave(BOSE_CMD_FM); // FM
|
||||
} else if (tSerialCommandCharacter == 55) { // 7
|
||||
IrSender.sendBoseWave(BOSE_CMD_PRESET_1); // Preset 1
|
||||
} else if (tSerialCommandCharacter == 56) { // 8
|
||||
IrSender.sendBoseWave(BOSE_CMD_PRESET_2); // Preset 2
|
||||
} else if (tSerialCommandCharacter == 57) { // 9
|
||||
IrSender.sendBoseWave(BOSE_CMD_PRESET_3); // Preset 3
|
||||
} else if (tSerialCommandCharacter == 97) { // a
|
||||
IrSender.sendBoseWave(BOSE_CMD_PRESET_4); // Preset 4
|
||||
} else if (tSerialCommandCharacter == 98) { // b
|
||||
IrSender.sendBoseWave(BOSE_CMD_PRESET_5); // Preset 5
|
||||
} else if (tSerialCommandCharacter == 99) { // c
|
||||
IrSender.sendBoseWave(BOSE_CMD_PRESET_6); // Preset 6
|
||||
} else if (tSerialCommandCharacter == 100) { // d
|
||||
IrSender.sendBoseWave(BOSE_CMD_MUTE); // Mute
|
||||
} else if (tSerialCommandCharacter == 101) { // e
|
||||
IrSender.sendBoseWave(BOSE_CMD_PLAY_PAUSE); // Pause
|
||||
} else if (tSerialCommandCharacter == 102) { // f
|
||||
IrSender.sendBoseWave(BOSE_CMD_STOP); // Stop
|
||||
} else if (tSerialCommandCharacter == 103) { // g
|
||||
IrSender.sendBoseWave(BOSE_CMD_AUX); // Aux
|
||||
} else if (tSerialCommandCharacter == 104) { // h
|
||||
IrSender.sendBoseWave(BOSE_CMD_SLEEP); // Sleep
|
||||
} else {
|
||||
sPrintMenu = false;
|
||||
}
|
||||
delay(300);
|
||||
}
|
||||
}
|
||||
|
||||
void printMenu() {
|
||||
Serial.println("0: On / Off");
|
||||
Serial.println("1: Volume Up");
|
||||
Serial.println("2: Volume Down");
|
||||
Serial.println("3: Tune Up");
|
||||
Serial.println("4: Tune Down");
|
||||
Serial.println("5: AM");
|
||||
Serial.println("6: FM");
|
||||
Serial.println("7: Preset 1");
|
||||
Serial.println("8: Preset 2");
|
||||
Serial.println("9: Preset 3");
|
||||
Serial.println("a: Preset 4");
|
||||
Serial.println("b: Preset 5");
|
||||
Serial.println("c: Preset 6");
|
||||
Serial.println("d: Mute");
|
||||
Serial.println("e: Play/Pause");
|
||||
Serial.println("f: Stop");
|
||||
Serial.println("g: Aux");
|
||||
Serial.println("h: Sleep");
|
||||
}
|
||||
@@ -0,0 +1,178 @@
|
||||
START ../src/ReceiveDemo.cpp from Feb 24 2023
|
||||
Using library version 4.1.0
|
||||
Enabling IRin...
|
||||
Ready to receive IR signals of protocols: NEC/NEC2/Onkyo/Apple, Panasonic/Kaseikyo, Denon/Sharp, Sony, RC5, RC6, LG, JVC, Samsung, FAST, Whynter, Lego Power Functions, Bosewave , MagiQuest, Universal Pulse Distance Width, Hash at pin 2
|
||||
|
||||
If you connect debug pin 5 to ground, raw data is always printed
|
||||
5000 us is the (minimum) gap, after which the start of a new IR packet is assumed
|
||||
20 us are subtracted from all marks and added to all spaces for decoding
|
||||
|
||||
Protocol=NEC Address=0x2 Command=0x34 Raw-Data=0xCB34FD02 32 bits LSB first
|
||||
Send with: IrSender.sendNEC(0x2, 0x34, <numberOfRepeats>);
|
||||
|
||||
Protocol=NEC Address=0x102 Command=0x34 Raw-Data=0xCB340102 32 bits LSB first
|
||||
Send with: IrSender.sendNEC(0x102, 0x34, <numberOfRepeats>);
|
||||
|
||||
Protocol=NEC Address=0x102 Command=0x34 Raw-Data=0xCB340102 32 bits LSB first
|
||||
Send with: IrSender.sendNEC(0x102, 0x34, <numberOfRepeats>);
|
||||
|
||||
Protocol=NEC Address=0x80 Command=0x45 Raw-Data=0xBA457F80 32 bits LSB first
|
||||
Send with: IrSender.sendNEC(0x80, 0x45, <numberOfRepeats>);
|
||||
|
||||
Protocol=NEC Address=0x4 Command=0x8 Raw-Data=0xF708FB04 32 bits LSB first
|
||||
Send with: IrSender.sendNEC(0x4, 0x8, <numberOfRepeats>);
|
||||
|
||||
Protocol=Onkyo Address=0x102 Command=0x304 Raw-Data=0x3040102 32 bits LSB first
|
||||
Send with: IrSender.sendOnkyo(0x102, 0x304, <numberOfRepeats>);
|
||||
|
||||
Protocol=NEC Address=0x102 Command=0x34 Raw-Data=0xCB340102 32 bits LSB first
|
||||
Send with: IrSender.sendNEC(0x102, 0x34, <numberOfRepeats>);
|
||||
|
||||
Protocol=Panasonic Address=0xB Command=0x10 Raw-Data=0xA01000B0 48 bits LSB first
|
||||
Send with: IrSender.sendPanasonic(0xB, 0x10, <numberOfRepeats>);
|
||||
|
||||
Protocol=Panasonic Address=0xB Command=0x10 Raw-Data=0xA01000B0 48 bits LSB first
|
||||
Send with: IrSender.sendPanasonic(0xB, 0x10, <numberOfRepeats>);
|
||||
|
||||
Protocol=Panasonic Address=0xB Command=0x10 Raw-Data=0xA01000B0 48 bits LSB first
|
||||
Send with: IrSender.sendPanasonic(0xB, 0x10, <numberOfRepeats>);
|
||||
|
||||
Protocol=PulseDistance Raw-Data=0x5A 72 bits LSB first
|
||||
Send with:
|
||||
uint32_t tRawData[]={0x87654321, 0xAFEDCBA9, 0x5A};
|
||||
IrSender.sendPulseDistanceWidthFromArray(38, 8850, 4400, 550, 1700, 550, 600, &tRawData[0], 72, PROTOCOL_IS_LSB_FIRST, <RepeatPeriodMillis>, <numberOfRepeats>);
|
||||
|
||||
Protocol=PulseWidth Raw-Data=0xDCBA9 52 bits LSB first
|
||||
Send with:
|
||||
uint32_t tRawData[]={0x87654321, 0xDCBA9};
|
||||
IrSender.sendPulseDistanceWidthFromArray(38, 300, 600, 600, 300, 350, 600, &tRawData[0], 52, PROTOCOL_IS_LSB_FIRST, <RepeatPeriodMillis>, <numberOfRepeats>);
|
||||
|
||||
Protocol=PulseWidth Raw-Data=0x87654321 32 bits LSB first
|
||||
Send with: IrSender.sendPulseDistanceWidth(38, 1000, 500, 600, 300, 350, 300, 0x87654321, 32, PROTOCOL_IS_LSB_FIRST, <RepeatPeriodMillis>, <numberOfRepeats>);
|
||||
|
||||
Protocol=Onkyo Address=0x102 Command=0x5634 Raw-Data=0x56340102 32 bits LSB first
|
||||
Send with: IrSender.sendOnkyo(0x102, 0x5634, <numberOfRepeats>);
|
||||
|
||||
Protocol=Apple Address=0x2 Command=0x34 Raw-Data=0x23487EE 32 bits LSB first
|
||||
Send with: IrSender.sendApple(0x2, 0x34, <numberOfRepeats>);
|
||||
|
||||
Protocol=Panasonic Address=0x102 Command=0x34 Raw-Data=0x4341020 48 bits LSB first
|
||||
Send with: IrSender.sendPanasonic(0x102, 0x34, <numberOfRepeats>);
|
||||
|
||||
Protocol=Kaseikyo Address=0x102 Command=0x34 Extra=0x4711 Raw-Data=0x7341023 48 bits LSB first
|
||||
Send with: IrSender.sendKaseikyo(0x102, 0x34, <numberOfRepeats>, 0x4711);
|
||||
|
||||
Protocol=Kaseikyo_Denon Address=0x102 Command=0x34 Raw-Data=0x4341020 48 bits LSB first
|
||||
Send with: IrSender.sendKaseikyo_Denon(0x102, 0x34, <numberOfRepeats>);
|
||||
|
||||
Protocol=Denon Address=0x2 Command=0x34 Raw-Data=0x682 15 bits LSB first
|
||||
Send with: IrSender.sendDenon(0x2, 0x34, <numberOfRepeats>);
|
||||
|
||||
Protocol=Denon Address=0x2 Command=0x34 Auto-Repeat gap=45650us Raw-Data=0x7962 15 bits LSB first
|
||||
|
||||
Protocol=Sharp Address=0x2 Command=0x34 Raw-Data=0x4682 15 bits LSB first
|
||||
Send with: IrSender.sendSharp(0x2, 0x34, <numberOfRepeats>);
|
||||
|
||||
Protocol=Sharp Address=0x2 Command=0x34 Auto-Repeat gap=46400us Raw-Data=0x3962 15 bits LSB first
|
||||
|
||||
Protocol=Sony Address=0x2 Command=0x34 Raw-Data=0x134 12 bits LSB first
|
||||
Send with: IrSender.sendSony(0x2, 0x34, 2, 12);
|
||||
|
||||
Protocol=Sony Address=0x2 Command=0x34 Raw-Data=0x134 15 bits LSB first
|
||||
Send with: IrSender.sendSony(0x2, 0x34, 2, 15);
|
||||
|
||||
Protocol=Sony Address=0x102 Command=0x34 Raw-Data=0x8134 20 bits LSB first
|
||||
Send with: IrSender.sendSony(0x102, 0x34, 2, 20);
|
||||
|
||||
Protocol=Samsung Address=0x102 Command=0x34 Raw-Data=0xCB340102 32 bits LSB first
|
||||
Send with: IrSender.sendSamsung(0x102, 0x34, <numberOfRepeats>);
|
||||
|
||||
Protocol=Samsung Address=0x102 Command=0x5634 Raw-Data=0x56340102 32 bits LSB first
|
||||
Send with: IrSender.sendSamsung(0x102, 0x5634, <numberOfRepeats>);
|
||||
|
||||
Protocol=Samsung48 Address=0x102 Command=0x5634 Raw-Data=0xA956 48 bits LSB first
|
||||
Send with: IrSender.sendSamsung48(0x102, 0x5634, <numberOfRepeats>);
|
||||
|
||||
Protocol=RC5 Address=0x2 Command=0x34 Raw-Data=0x10B4 13 bits MSB first
|
||||
Send with: IrSender.sendRC5(0x2, 0x34, <numberOfRepeats>);
|
||||
|
||||
Protocol=RC5 Address=0x2 Command=0x74 Toggle=1 Raw-Data=0x8B4 13 bits MSB first
|
||||
Send with: IrSender.sendRC5(0x2, 0x74, <numberOfRepeats>);
|
||||
|
||||
Protocol=RC6 Address=0x2 Command=0x34 Raw-Data=0x234 20 bits MSB first
|
||||
Send with: IrSender.sendRC6(0x2, 0x34, <numberOfRepeats>);
|
||||
|
||||
Protocol=Samsung Address=0x102 Command=0x34 Raw-Data=0xCB340102 32 bits LSB first
|
||||
Send with: IrSender.sendSamsung(0x102, 0x34, <numberOfRepeats>);
|
||||
|
||||
Protocol=JVC Address=0x2 Command=0x34 Raw-Data=0x3402 16 bits LSB first
|
||||
Send with: IrSender.sendJVC(0x2, 0x34, <numberOfRepeats>);
|
||||
|
||||
Protocol=Samsung Address=0x102 Command=0x5634 Raw-Data=0x56340102 32 bits LSB first
|
||||
Send with: IrSender.sendSamsung(0x102, 0x5634, <numberOfRepeats>);
|
||||
|
||||
Protocol=LG Address=0x2 Command=0x5634 Raw-Data=0x256342 28 bits MSB first
|
||||
Send with: IrSender.sendLG(0x2, 0x5634, <numberOfRepeats>);
|
||||
|
||||
Protocol=MagiQuest Address=0x102 Command=0x34 Raw-Data=0x6BCD0102 56 bits MSB first
|
||||
Send with: IrSender.sendMagiQuest(0x6BCD0102, 0x34, <numberOfRepeats>);
|
||||
|
||||
Protocol=BoseWave Address=0x0 Command=0x34 Raw-Data=0xCB34 16 bits LSB first
|
||||
Send with: IrSender.sendBoseWave(0x0, 0x34, <numberOfRepeats>);
|
||||
|
||||
Protocol=FAST Address=0x0 Command=0x34 Raw-Data=0xCB34 16 bits LSB first
|
||||
Send with: IrSender.sendFAST(0x0, 0x34, <numberOfRepeats>);
|
||||
|
||||
Protocol=Lego Address=0x2 Command=0x14 Raw-Data=0x2148 16 bits MSB first
|
||||
Send with: IrSender.sendLego(0x2, 0x14, <numberOfRepeats>);
|
||||
|
||||
Protocol=Lego Address=0x2 Command=0x14 Auto-Repeat gap=180450us Raw-Data=0x2148 16 bits MSB first
|
||||
|
||||
Protocol=Lego Address=0x2 Command=0x14 Auto-Repeat gap=179350us Raw-Data=0x2148 16 bits MSB first
|
||||
|
||||
Protocol=Lego Address=0x2 Command=0x14 Auto-Repeat gap=179200us Raw-Data=0x2148 16 bits MSB first
|
||||
|
||||
Protocol=Lego Address=0x2 Command=0x14 Auto-Repeat gap=179150us Raw-Data=0x2148 16 bits MSB first
|
||||
|
||||
Overflow detected
|
||||
Try to increase the "RAW_BUFFER_LENGTH" value of 600 in ../src/ReceiveDemo.cpp
|
||||
|
||||
Protocol=NEC Address=0x3 Command=0x45 Raw-Data=0xBA45FC03 32 bits LSB first
|
||||
Send with: IrSender.sendNEC(0x3, 0x45, <numberOfRepeats>);
|
||||
|
||||
Protocol=NEC Address=0x3 Command=0x45 Repeat gap=43250us
|
||||
|
||||
Protocol=NEC Address=0x203 Command=0x45 Raw-Data=0xBA450203 32 bits LSB first
|
||||
Send with: IrSender.sendNEC(0x203, 0x45, <numberOfRepeats>);
|
||||
|
||||
Protocol=NEC Address=0x203 Command=0x45 Repeat gap=47550us
|
||||
|
||||
Protocol=NEC Address=0x203 Command=0x45 Raw-Data=0xBA450203 32 bits LSB first
|
||||
Send with: IrSender.sendNEC(0x203, 0x45, <numberOfRepeats>);
|
||||
|
||||
Protocol=NEC2 Address=0x203 Command=0x45 Repeat gap=46500us Raw-Data=0xBA450203 32 bits LSB first
|
||||
|
||||
Protocol=Onkyo Address=0x203 Command=0x6745 Raw-Data=0x67450203 32 bits LSB first
|
||||
Send with: IrSender.sendOnkyo(0x203, 0x6745, <numberOfRepeats>);
|
||||
|
||||
Protocol=Onkyo Address=0x203 Command=0x6745 Repeat gap=46550us
|
||||
|
||||
Protocol=Apple Address=0x3 Command=0x45 Raw-Data=0x34587EE 32 bits LSB first
|
||||
Send with: IrSender.sendApple(0x3, 0x45, <numberOfRepeats>);
|
||||
|
||||
Protocol=Apple Address=0x3 Command=0x45 Repeat gap=31550us
|
||||
|
||||
Protocol=Panasonic Address=0x203 Command=0x45 Raw-Data=0x55452030 48 bits LSB first
|
||||
Send with: IrSender.sendPanasonic(0x203, 0x45, <numberOfRepeats>);
|
||||
|
||||
Protocol=Panasonic Address=0x203 Command=0x45 Repeat gap=72550us Raw-Data=0x55452030 48 bits LSB first
|
||||
|
||||
Protocol=Kaseikyo Address=0x203 Command=0x45 Extra=0x4711 Raw-Data=0x56452033 48 bits LSB first
|
||||
Send with: IrSender.sendKaseikyo(0x203, 0x45, <numberOfRepeats>, 0x4711);
|
||||
|
||||
Protocol=Kaseikyo Address=0x203 Command=0x45 Extra=0x4711 Repeat gap=66750us Raw-Data=0x56452033 48 bits LSB first
|
||||
|
||||
Protocol=Kaseikyo_Denon Address=0x203 Command=0x45 Raw-Data=0x55452030 48 bits LSB first
|
||||
Send with: IrSender.sendKaseikyo_Denon(0x203, 0x45, <numberOfRepeats>);
|
||||
|
||||
Protocol=Kaseikyo_Denon Address=0x203 Command=0x45 Repeat gap=68300us Raw-Data=0x55452030 48 bits LSB first
|
||||
@@ -0,0 +1,349 @@
|
||||
/*
|
||||
* PinDefinitionsAndMore.h
|
||||
*
|
||||
* Contains pin definitions for IRremote examples for various platforms
|
||||
* as well as definitions for feedback LED and tone() and includes
|
||||
*
|
||||
* Copyright (C) 2021-2023 Armin Joachimsmeyer
|
||||
* armin.joachimsmeyer@gmail.com
|
||||
*
|
||||
* This file is part of IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
|
||||
*
|
||||
* Arduino-IRremote is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/gpl.html>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Pin mapping table for different platforms
|
||||
*
|
||||
* Platform IR input IR output Tone Core/Pin schema
|
||||
* --------------------------------------------------------------
|
||||
* DEFAULT/AVR 2 3 4 Arduino
|
||||
* ATtinyX5 0|PB0 4|PB4 3|PB3 ATTinyCore
|
||||
* ATtiny167 3|PA3 2|PA2 7|PA7 ATTinyCore
|
||||
* ATtiny167 9|PA3 8|PA2 5|PA7 Digispark original core
|
||||
* ATtiny84 |PB2 |PA4 |PA3 ATTinyCore
|
||||
* ATtiny88 3|PD3 4|PD4 9|PB1 ATTinyCore
|
||||
* ATtiny3217 18|PA1 19|PA2 20|PA3 MegaTinyCore
|
||||
* ATtiny1604 2 3|PA5 %
|
||||
* ATtiny816 14|PA1 16|PA3 1|PA5 MegaTinyCore
|
||||
* ATtiny1614 8|PA1 10|PA3 1|PA5 MegaTinyCore
|
||||
* SAMD21 3 4 5
|
||||
* ESP8266 14|D5 12|D6 %
|
||||
* ESP32 15 4 27
|
||||
* ESP32-C3 2 3 4
|
||||
* BluePill PA6 PA7 PA3
|
||||
* APOLLO3 11 12 5
|
||||
* RP2040 3|GPIO15 4|GPIO16 5|GPIO17
|
||||
*/
|
||||
//#define _IR_MEASURE_TIMING // For debugging purposes.
|
||||
|
||||
#if defined(__AVR__)
|
||||
#if defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__) // Digispark board. For use with ATTinyCore.
|
||||
#include "ATtinySerialOut.hpp" // TX is at pin 2 - Available as Arduino library "ATtinySerialOut". Saves 700 bytes program memory and 70 bytes RAM for ATtinyCore.
|
||||
#define IR_RECEIVE_PIN PIN_PB0
|
||||
#define IR_SEND_PIN PIN_PB4 // Pin 2 is serial output with ATtinySerialOut. Pin 1 is internal LED and Pin3 is USB+ with pullup on Digispark board.
|
||||
#define TONE_PIN PIN_PB3
|
||||
#define _IR_TIMING_TEST_PIN PIN_PB3
|
||||
|
||||
# elif defined(__AVR_ATtiny87__) || defined(__AVR_ATtiny167__) // Digispark pro board
|
||||
#include "ATtinySerialOut.hpp" // Available as Arduino library "ATtinySerialOut"
|
||||
// For ATtiny167 Pins PB6 and PA3 are usable as interrupt source.
|
||||
# if defined(ARDUINO_AVR_DIGISPARKPRO)
|
||||
// For use with Digispark original core
|
||||
#define IR_RECEIVE_PIN 9 // PA3 - on Digispark board labeled as pin 9
|
||||
//#define IR_RECEIVE_PIN 14 // PB6 / INT0 is connected to USB+ on DigisparkPro boards
|
||||
#define IR_SEND_PIN 8 // PA2 - on Digispark board labeled as pin 8
|
||||
#define TONE_PIN 5 // PA7 - on Digispark board labeled as pin 5
|
||||
#define _IR_TIMING_TEST_PIN 10 // PA4
|
||||
# else
|
||||
// For use with ATTinyCore
|
||||
#define IR_RECEIVE_PIN PIN_PA3 // On Digispark board labeled as pin 9 - INT0 is connected to USB+ on DigisparkPro boards
|
||||
#define IR_SEND_PIN PIN_PA2 // On Digispark board labeled as pin 8
|
||||
#define TONE_PIN PIN_PA7 // On Digispark board labeled as pin 5
|
||||
# endif
|
||||
|
||||
# elif defined(__AVR_ATtiny84__) // For use with ATTinyCore
|
||||
#include "ATtinySerialOut.hpp" // Available as Arduino library "ATtinySerialOut". Saves 128 bytes program memory.
|
||||
#define IR_RECEIVE_PIN PIN_PB2 // INT0
|
||||
#define IR_SEND_PIN PIN_PA4
|
||||
#define TONE_PIN PIN_PA3
|
||||
#define _IR_TIMING_TEST_PIN PIN_PA5
|
||||
|
||||
# elif defined(__AVR_ATtiny88__) // MH-ET Tiny88 board. For use with ATTinyCore.
|
||||
#include "ATtinySerialOut.hpp" // Available as Arduino library "ATtinySerialOut". Saves 128 bytes program memory.
|
||||
// Pin 6 is TX, pin 7 is RX
|
||||
#define IR_RECEIVE_PIN PIN_PD3 // 3 - INT1
|
||||
#define IR_SEND_PIN PIN_PD4 // 4
|
||||
#define TONE_PIN PIN_PB1 // 9
|
||||
#define _IR_TIMING_TEST_PIN PIN_PB0 // 8
|
||||
|
||||
# elif defined(__AVR_ATtiny1616__) || defined(__AVR_ATtiny3216__) || defined(__AVR_ATtiny3217__) // For use with megaTinyCore
|
||||
// Tiny Core Dev board
|
||||
// https://www.tindie.com/products/xkimi/tiny-core-16-dev-board-attiny1616/ - Out of Stock
|
||||
// https://www.tindie.com/products/xkimi/tiny-core-32-dev-board-attiny3217/ - Out of Stock
|
||||
#define IR_RECEIVE_PIN PIN_PA1 // use 18 instead of PIN_PA1 for TinyCore32
|
||||
#define IR_SEND_PIN PIN_PA2 // 19
|
||||
#define TONE_PIN PIN_PA3 // 20
|
||||
#define APPLICATION_PIN PIN_PA0 // 0
|
||||
#undef LED_BUILTIN // No LED available on the TinyCore 32 board, take the one on the programming board which is connected to the DAC output
|
||||
#define LED_BUILTIN PIN_PA6 // use 2 instead of PIN_PA6 for TinyCore32
|
||||
|
||||
# elif defined(__AVR_ATtiny816__) // For use with megaTinyCore
|
||||
#define IR_RECEIVE_PIN PIN_PA1 // 14
|
||||
#define IR_SEND_PIN PIN_PA1 // 16
|
||||
#define TONE_PIN PIN_PA5 // 1
|
||||
#define APPLICATION_PIN PIN_PA4 // 0
|
||||
#undef LED_BUILTIN // No LED available, take the one which is connected to the DAC output
|
||||
#define LED_BUILTIN PIN_PB5 // 4
|
||||
|
||||
# elif defined(__AVR_ATtiny1614__) // For use with megaTinyCore
|
||||
#define IR_RECEIVE_PIN PIN_PA1 // 8
|
||||
#define IR_SEND_PIN PIN_PA3 // 10
|
||||
#define TONE_PIN PIN_PA5 // 1
|
||||
#define APPLICATION_PIN PIN_PA4 // 0
|
||||
|
||||
# elif defined(__AVR_ATtiny1604__) // For use with megaTinyCore
|
||||
#define IR_RECEIVE_PIN PIN_PA6 // 2 - To be compatible with interrupt example, pin 2 is chosen here.
|
||||
#define IR_SEND_PIN PIN_PA7 // 3
|
||||
#define APPLICATION_PIN PIN_PB2 // 5
|
||||
|
||||
#define tone(...) void() // Define as void, since TCB0_INT_vect is also used by tone()
|
||||
#define noTone(a) void()
|
||||
#define TONE_PIN 42 // Dummy for examples using it
|
||||
|
||||
# elif defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) \
|
||||
|| defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) \
|
||||
|| defined(__AVR_ATmega324P__) || defined(__AVR_ATmega324A__) \
|
||||
|| defined(__AVR_ATmega324PA__) || defined(__AVR_ATmega164A__) \
|
||||
|| defined(__AVR_ATmega164P__) || defined(__AVR_ATmega32__) \
|
||||
|| defined(__AVR_ATmega16__) || defined(__AVR_ATmega8535__) \
|
||||
|| defined(__AVR_ATmega64__) || defined(__AVR_ATmega128__) \
|
||||
|| defined(__AVR_ATmega1281__) || defined(__AVR_ATmega2561__) \
|
||||
|| defined(__AVR_ATmega8515__) || defined(__AVR_ATmega162__)
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 13
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
# else // Default as for ATmega328 like on Uno, Nano, Leonardo, Teensy 2.0 etc.
|
||||
#define IR_RECEIVE_PIN 2 // To be compatible with interrupt example, pin 2 is chosen here.
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
# if defined(ARDUINO_AVR_PROMICRO) // Sparkfun Pro Micro is __AVR_ATmega32U4__ but has different external circuit
|
||||
// We have no built in LED at pin 13 -> reuse RX LED
|
||||
#undef LED_BUILTIN
|
||||
#define LED_BUILTIN LED_BUILTIN_RX
|
||||
# endif
|
||||
# endif // defined(__AVR_ATtiny25__)...
|
||||
|
||||
#elif defined(ARDUINO_ARCH_RENESAS_UNO) // Uno R4
|
||||
// To be compatible with Uno R3.
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
#elif defined(ESP8266)
|
||||
#define FEEDBACK_LED_IS_ACTIVE_LOW // The LED on my board (D4) is active LOW
|
||||
#define IR_RECEIVE_PIN 14 // D5
|
||||
#define IR_SEND_PIN 12 // D6 - D4/pin 2 is internal LED
|
||||
#define _IR_TIMING_TEST_PIN 2 // D4
|
||||
#define APPLICATION_PIN 13 // D7
|
||||
|
||||
#define tone(...) void() // tone() inhibits receive timer
|
||||
#define noTone(a) void()
|
||||
#define TONE_PIN 42 // Dummy for examples using it#
|
||||
|
||||
#elif defined(ARDUINO_NOLOGO_ESP32C3_SUPER_MINI)
|
||||
#define FEEDBACK_LED_IS_ACTIVE_LOW // The LED on my board (D8) is active LOW
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 10
|
||||
|
||||
#elif defined(CONFIG_IDF_TARGET_ESP32C3) || defined(ARDUINO_ESP32C3_DEV)
|
||||
#define NO_LED_FEEDBACK_CODE // The WS2812 on pin 8 of AI-C3 board crashes if used as receive feedback LED, other I/O pins are working...
|
||||
#define IR_RECEIVE_PIN 6
|
||||
#define IR_SEND_PIN 7
|
||||
#define TONE_PIN 10
|
||||
#define APPLICATION_PIN 18
|
||||
|
||||
#elif defined(ESP32)
|
||||
#include <Arduino.h>
|
||||
|
||||
// tone() is included in ESP32 core since 2.0.2
|
||||
#if !defined(ESP_ARDUINO_VERSION_VAL)
|
||||
#define ESP_ARDUINO_VERSION_VAL(major, minor, patch) 12345678
|
||||
#endif
|
||||
#if ESP_ARDUINO_VERSION <= ESP_ARDUINO_VERSION_VAL(2, 0, 2)
|
||||
#define TONE_LEDC_CHANNEL 1 // Using channel 1 makes tone() independent of receiving timer -> No need to stop receiving timer.
|
||||
void tone(uint8_t aPinNumber, unsigned int aFrequency){
|
||||
ledcAttachPin(aPinNumber, TONE_LEDC_CHANNEL);
|
||||
ledcWriteTone(TONE_LEDC_CHANNEL, aFrequency);
|
||||
}
|
||||
void tone(uint8_t aPinNumber, unsigned int aFrequency, unsigned long aDuration){
|
||||
ledcAttachPin(aPinNumber, TONE_LEDC_CHANNEL);
|
||||
ledcWriteTone(TONE_LEDC_CHANNEL, aFrequency);
|
||||
delay(aDuration);
|
||||
ledcWriteTone(TONE_LEDC_CHANNEL, 0);
|
||||
}
|
||||
void noTone(uint8_t aPinNumber){
|
||||
ledcWriteTone(TONE_LEDC_CHANNEL, 0);
|
||||
}
|
||||
#endif // ESP_ARDUINO_VERSION <= ESP_ARDUINO_VERSION_VAL(2, 0, 2)
|
||||
|
||||
#define IR_RECEIVE_PIN 15 // D15
|
||||
#define IR_SEND_PIN 4 // D4
|
||||
#define TONE_PIN 27 // D27 25 & 26 are DAC0 and 1
|
||||
#define APPLICATION_PIN 16 // RX2 pin
|
||||
|
||||
#elif defined(ARDUINO_ARCH_STM32) || defined(ARDUINO_ARCH_STM32F1) // BluePill
|
||||
// Timer 3 blocks PA6, PA7, PB0, PB1 for use by Servo or tone()
|
||||
#define IR_RECEIVE_PIN PA6
|
||||
#define IR_RECEIVE_PIN_STRING "PA6"
|
||||
#define IR_SEND_PIN PA7
|
||||
#define IR_SEND_PIN_STRING "PA7"
|
||||
#define TONE_PIN PA3
|
||||
#define _IR_TIMING_TEST_PIN PA5
|
||||
#define APPLICATION_PIN PA2
|
||||
#define APPLICATION_PIN_STRING "PA2"
|
||||
# if defined(ARDUINO_GENERIC_STM32F103C) || defined(ARDUINO_BLUEPILL_F103C8)
|
||||
// BluePill LED is active low
|
||||
#define FEEDBACK_LED_IS_ACTIVE_LOW
|
||||
# endif
|
||||
|
||||
#elif defined(ARDUINO_ARCH_APOLLO3) // Sparkfun Apollo boards
|
||||
#define IR_RECEIVE_PIN 11
|
||||
#define IR_SEND_PIN 12
|
||||
#define TONE_PIN 5
|
||||
|
||||
#elif defined(ARDUINO_ARCH_MBED) && defined(ARDUINO_ARCH_MBED_NANO) // Arduino Nano 33 BLE and Arduino Nano Connect layout for MBED
|
||||
// Must be before ARDUINO_ARCH_RP2040, since it is the layout for the MBED core of Arduino Nano Connect
|
||||
#define IR_RECEIVE_PIN 3 // GPIO15 Start with pin 3 since pin 2|GPIO25 is connected to LED on Pi pico
|
||||
#define IR_SEND_PIN 4 // GPIO16
|
||||
#define TONE_PIN 5
|
||||
#define APPLICATION_PIN 6
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 7 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 8
|
||||
|
||||
#elif defined(ARDUINO_ARCH_RP2040) // Arduino Nano Connect, Pi Pico with arduino-pico core https://github.com/earlephilhower/arduino-pico
|
||||
#define IR_RECEIVE_PIN 15 // GPIO15 to be compatible with the Arduino Nano RP2040 Connect (pin3)
|
||||
#define IR_SEND_PIN 16 // GPIO16
|
||||
#define TONE_PIN 17
|
||||
#define APPLICATION_PIN 18
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 19 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 20
|
||||
|
||||
// If you program the Nano RP2040 Connect with this core, then you must redefine LED_BUILTIN
|
||||
// and use the external reset with 1 kOhm to ground to enter UF2 mode
|
||||
#undef LED_BUILTIN
|
||||
#define LED_BUILTIN 6
|
||||
|
||||
#elif defined(PARTICLE) // !!!UNTESTED!!!
|
||||
#define IR_RECEIVE_PIN A4
|
||||
#define IR_SEND_PIN A5 // Particle supports multiple pins
|
||||
|
||||
#define LED_BUILTIN D7
|
||||
|
||||
/*
|
||||
* 4 times the same (default) layout for easy adaption in the future
|
||||
*/
|
||||
#elif defined(TEENSYDUINO) // Teensy 2.0 is handled at default for ATmega328 like on Uno, Nano, Leonardo etc.
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
#elif defined(ARDUINO_ARCH_MBED) // Arduino Nano 33 BLE
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
#elif defined(ARDUINO_ARCH_SAMD) || defined(ARDUINO_ARCH_SAM)
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
#if !defined(ARDUINO_SAMD_ADAFRUIT) && !defined(ARDUINO_SEEED_XIAO_M0)
|
||||
// On the Zero and others we switch explicitly to SerialUSB
|
||||
#define Serial SerialUSB
|
||||
#endif
|
||||
|
||||
// Definitions for the Chinese SAMD21 M0-Mini clone, which has no led connected to D13/PA17.
|
||||
// Attention!!! D2 and D4 are swapped on these boards!!!
|
||||
// If you connect the LED, it is on pin 24/PB11. In this case activate the next two lines.
|
||||
//#undef LED_BUILTIN
|
||||
//#define LED_BUILTIN 24 // PB11
|
||||
// As an alternative you can choose pin 25, it is the RX-LED pin (PB03), but active low.In this case activate the next 3 lines.
|
||||
//#undef LED_BUILTIN
|
||||
//#define LED_BUILTIN 25 // PB03
|
||||
//#define FEEDBACK_LED_IS_ACTIVE_LOW // The RX LED on the M0-Mini is active LOW
|
||||
|
||||
#elif defined (NRF51) // BBC micro:bit
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define APPLICATION_PIN 1
|
||||
#define _IR_TIMING_TEST_PIN 4
|
||||
|
||||
#define tone(...) void() // no tone() available
|
||||
#define noTone(a) void()
|
||||
#define TONE_PIN 42 // Dummy for examples using it
|
||||
|
||||
#else
|
||||
#warning Board / CPU is not detected using pre-processor symbols -> using default values, which may not fit. Please extend PinDefinitionsAndMore.h.
|
||||
// Default valued for unidentified boards
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
#endif // defined(ESP8266)
|
||||
|
||||
#if defined(ESP32) || defined(ARDUINO_ARCH_RP2040) || defined(PARTICLE) || defined(ARDUINO_ARCH_MBED)
|
||||
#define SEND_PWM_BY_TIMER // We do not have pin restrictions for this CPU's, so lets use the hardware PWM for send carrier signal generation
|
||||
#else
|
||||
# if defined(SEND_PWM_BY_TIMER)
|
||||
#undef IR_SEND_PIN // SendPin is determined by timer! This avoids warnings in IRremote.hpp and IRTimer.hpp
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if !defined (FLASHEND)
|
||||
#define FLASHEND 0xFFFF // Dummy value for platforms where FLASHEND is not defined
|
||||
#endif
|
||||
|
||||
/*
|
||||
* 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
|
||||
@@ -0,0 +1,424 @@
|
||||
/*
|
||||
* SendDemo.cpp
|
||||
*
|
||||
* Demonstrates sending IR codes in standard format with address and command
|
||||
*
|
||||
* This file is part of Arduino-IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
|
||||
*
|
||||
************************************************************************************
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2020-2023 Armin Joachimsmeyer
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is furnished
|
||||
* to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
************************************************************************************
|
||||
*/
|
||||
#include <Arduino.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 USE_ACTIVE_HIGH_OUTPUT_FOR_SEND_PIN // Simulate an active high receiver signal instead of an active low signal.
|
||||
//#define NO_LED_FEEDBACK_CODE // Saves 566 bytes program memory
|
||||
|
||||
/*
|
||||
* 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
|
||||
|
||||
#ifndef IR_SEND_PIN
|
||||
#define IR_SEND_PIN 3 // P0_0
|
||||
#endif
|
||||
|
||||
#include <IRremote.hpp>
|
||||
|
||||
// #undef IR_SEND_PIN // to use tSendPin
|
||||
|
||||
#define DELAY_AFTER_SEND 2000
|
||||
#define DELAY_AFTER_LOOP 5000
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
while (!Serial)
|
||||
; // Wait for Serial to become available. Is optimized away for some cores.
|
||||
|
||||
// Just to know which program is running on my Arduino
|
||||
Serial.println(F("START " __FILE__ " from " __DATE__ "\r\nUsing library version " VERSION_IRREMOTE));
|
||||
|
||||
#if defined(IR_SEND_PIN)
|
||||
IrSender.begin(); // Start with IR_SEND_PIN as send pin and enable feedback LED at default feedback LED pin
|
||||
// disableLEDFeedback(); // Disable feedback LED at default feedback LED pin
|
||||
Serial.println(F("Send IR signals at pin " STR(IR_SEND_PIN)));
|
||||
#else
|
||||
// Here the macro IR_SEND_PIN is not defined or undefined above with #undef IR_SEND_PIN
|
||||
uint8_t tSendPin = 3;
|
||||
IrSender.begin(tSendPin, ENABLE_LED_FEEDBACK, USE_DEFAULT_FEEDBACK_LED_PIN); // Specify send pin and enable feedback LED at default feedback LED pin
|
||||
// You can change send pin later with IrSender.setSendPin();
|
||||
|
||||
Serial.print(F("Send IR signals at pin "));
|
||||
Serial.println(tSendPin);
|
||||
#endif
|
||||
|
||||
#if !defined(SEND_PWM_BY_TIMER)
|
||||
/*
|
||||
* Print internal software PWM signal generation info
|
||||
*/
|
||||
IrSender.enableIROut(38); // Call it with 38 kHz just to initialize the values printed below
|
||||
Serial.print(F("Send signal mark duration is "));
|
||||
Serial.print(IrSender.periodOnTimeMicros);
|
||||
Serial.print(F(" us, pulse narrowing correction is "));
|
||||
Serial.print(IrSender.getPulseCorrectionNanos());
|
||||
Serial.print(F(" ns, total period is "));
|
||||
Serial.print(IrSender.periodTimeMicros);
|
||||
Serial.println(F(" us"));
|
||||
#endif
|
||||
|
||||
#if defined(LED_BUILTIN) && !defined(NO_LED_FEEDBACK_CODE)
|
||||
# if defined(FEEDBACK_LED_IS_ACTIVE_LOW)
|
||||
Serial.print(F("Active low "));
|
||||
# endif
|
||||
Serial.print(F("FeedbackLED at pin "));
|
||||
Serial.println(LED_BUILTIN); // Works also for ESP32: static const uint8_t LED_BUILTIN = 8; #define LED_BUILTIN LED_BUILTIN
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Set up the data to be sent.
|
||||
* For most protocols, the data is build up with a constant 8 (or 16 byte) address
|
||||
* and a variable 8 bit command.
|
||||
* There are exceptions like Sony and Denon, which have 5 bit address.
|
||||
*/
|
||||
uint16_t sAddress = 0x0132;
|
||||
uint8_t sCommand = 0x34;
|
||||
uint16_t s16BitCommand = 0x5634;
|
||||
uint8_t sRepeats = 0;
|
||||
|
||||
void loop() {
|
||||
/*
|
||||
* Print values
|
||||
*/
|
||||
Serial.println();
|
||||
Serial.print(F("address=0x"));
|
||||
Serial.print(sAddress, HEX);
|
||||
Serial.print(F(" command=0x"));
|
||||
Serial.print(sCommand, HEX);
|
||||
Serial.print(F(" repeats="));
|
||||
Serial.println(sRepeats);
|
||||
Serial.println();
|
||||
Serial.println();
|
||||
Serial.flush();
|
||||
|
||||
Serial.println(F("Send NEC with 8 bit address"));
|
||||
Serial.flush();
|
||||
IrSender.sendNEC(sAddress & 0xFF, sCommand, sRepeats);
|
||||
delay(DELAY_AFTER_SEND); // delay must be greater than 5 ms (RECORD_GAP_MICROS), otherwise the receiver sees it as one long signal
|
||||
|
||||
Serial.println(F("Send NEC with 16 bit address"));
|
||||
Serial.flush();
|
||||
IrSender.sendNEC(sAddress, sCommand, sRepeats);
|
||||
delay(DELAY_AFTER_SEND);
|
||||
|
||||
Serial.println(F("Send NEC2 with 16 bit address"));
|
||||
Serial.flush();
|
||||
IrSender.sendNEC2(sAddress, sCommand, sRepeats);
|
||||
delay(DELAY_AFTER_SEND);
|
||||
|
||||
if (sRepeats == 0) {
|
||||
/*
|
||||
* Send constant values only once in this demo
|
||||
*/
|
||||
Serial.println(F("Sending NEC Pronto data with 8 bit address 0x80 and command 0x45 and no repeats"));
|
||||
Serial.flush();
|
||||
IrSender.sendPronto(F("0000 006D 0022 0000 015E 00AB " /* Pronto header + start bit */
|
||||
"0017 0015 0017 0015 0017 0017 0015 0017 0017 0015 0017 0015 0017 0015 0017 003F " /* Lower address byte */
|
||||
"0017 003F 0017 003E 0017 003F 0015 003F 0017 003E 0017 003F 0017 003E 0017 0015 " /* Upper address byte (inverted at 8 bit mode) */
|
||||
"0017 003E 0017 0015 0017 003F 0017 0015 0017 0015 0017 0015 0017 003F 0017 0015 " /* command byte */
|
||||
"0019 0013 0019 003C 0017 0015 0017 003F 0017 003E 0017 003F 0017 0015 0017 003E " /* inverted command byte */
|
||||
"0017 0806"), 0); //stop bit, no repeat possible, because of missing repeat pattern
|
||||
delay(DELAY_AFTER_SEND);
|
||||
|
||||
/*
|
||||
* !!! The next data occupies 136 bytes RAM !!!
|
||||
*/
|
||||
Serial.println(
|
||||
F("Send NEC sendRaw data with 8 bit address=0xFB04 and command 0x08 and exact timing (16 bit array format)"));
|
||||
Serial.flush();
|
||||
const uint16_t irSignal[] = { 9000, 4500/*Start bit*/, 560, 560, 560, 560, 560, 1690, 560,
|
||||
560/*0010 0x4 of 16 bit address LSB first*/, 560, 560, 560, 560, 560, 560, 560, 560/*0000*/, 560, 1690, 560, 1690,
|
||||
560, 560, 560, 1690/*1101 0xB*/, 560, 1690, 560, 1690, 560, 1690, 560, 1690/*1111*/, 560, 560, 560, 560, 560, 560,
|
||||
560, 1690/*0001 0x08 of command LSB first*/, 560, 560, 560, 560, 560, 560, 560, 560/*0000 0x00*/, 560, 1690, 560,
|
||||
1690, 560, 1690, 560, 560/*1110 Inverted 8 of command*/, 560, 1690, 560, 1690, 560, 1690, 560,
|
||||
1690/*1111 inverted 0 of command*/, 560 /*stop bit*/}; // Using exact NEC timing
|
||||
IrSender.sendRaw(irSignal, sizeof(irSignal) / sizeof(irSignal[0]), NEC_KHZ); // Note the approach used to automatically calculate the size of the array.
|
||||
delay(DELAY_AFTER_SEND);
|
||||
|
||||
/*
|
||||
* With sendNECRaw() you can send 32 bit combined codes
|
||||
*/
|
||||
Serial.println(F("Send ONKYO with 16 bit address 0x0102 and 16 bit command 0x0304 with NECRaw(0x03040102)"));
|
||||
Serial.flush();
|
||||
IrSender.sendNECRaw(0x03040102, sRepeats);
|
||||
delay(DELAY_AFTER_SEND);
|
||||
|
||||
/*
|
||||
* With Send sendNECMSB() you can send your old 32 bit codes.
|
||||
* To convert one into the other, you must reverse the byte positions and then reverse all positions of each byte.
|
||||
* Use bitreverse32Bit().
|
||||
* Example:
|
||||
* 0xCB340102 byte reverse -> 0x020134CB bit reverse-> 40802CD3
|
||||
*/
|
||||
Serial.println(F("Send ONKYO with 16 bit address 0x0102 and command 0x34 with old 32 bit format MSB first (0x40802CD3)"));
|
||||
Serial.flush();
|
||||
IrSender.sendNECMSB(0x40802CD3, 32, false);
|
||||
delay(DELAY_AFTER_SEND);
|
||||
|
||||
Serial.println(F("Send Panasonic 0xB, 0x10 as 48 bit PulseDistance using ProtocolConstants"));
|
||||
Serial.flush();
|
||||
|
||||
IrSender.sendPulseDistanceWidth(&KaseikyoProtocolConstants, 0xA010B02002, 48, NO_REPEATS); // Panasonic is a Kaseikyo variant
|
||||
|
||||
delay(DELAY_AFTER_SEND);
|
||||
|
||||
/*
|
||||
* Send 2 Panasonic 48 bit codes as Pulse Distance data, once with LSB and once with MSB first
|
||||
*/
|
||||
Serial.println(F("Send Panasonic 0xB, 0x10 as 48 bit PulseDistance"));
|
||||
Serial.println(F(" LSB first"));
|
||||
Serial.flush();
|
||||
|
||||
IrSender.sendPulseDistanceWidth(38, 3450, 1700, 450, 1250, 450, 400, 0xA010B02002, 48, PROTOCOL_IS_LSB_FIRST,
|
||||
0, NO_REPEATS);
|
||||
delay(DELAY_AFTER_SEND);
|
||||
|
||||
// The same with MSB first. Use bit reversed raw data of LSB first part
|
||||
Serial.println(F(" MSB first"));
|
||||
IrSender.sendPulseDistanceWidth(38, 3450, 1700, 450, 1250, 450, 400, 0x40040D000805, 48, PROTOCOL_IS_MSB_FIRST,
|
||||
0, NO_REPEATS);
|
||||
delay(DELAY_AFTER_SEND);
|
||||
|
||||
Serial.println(F("Send 72 bit PulseDistance 0x5A AFEDCBA9 87654321 LSB first"));
|
||||
Serial.flush();
|
||||
IRRawDataType tRawData[] = { 0xAFEDCBA987654321, 0x5A }; // LSB of tRawData[0] is sent first
|
||||
IrSender.sendPulseDistanceWidthFromArray(38, 8900, 4450, 550, 1700, 550, 600, &tRawData[0], 72, PROTOCOL_IS_LSB_FIRST, 0, NO_REPEATS);
|
||||
delay(DELAY_AFTER_SEND);
|
||||
|
||||
Serial.println(F("Send 52 bit PulseDistanceWidth 0xDCBA9 87654321 LSB first"));
|
||||
Serial.flush();
|
||||
// Real PulseDistanceWidth (constant bit length) does not require a stop bit
|
||||
IrSender.sendPulseDistanceWidth(38, 300, 600, 600, 300, 300, 600, 0xDCBA987654321, 52, PROTOCOL_IS_LSB_FIRST,
|
||||
0, 0);
|
||||
delay(DELAY_AFTER_SEND);
|
||||
|
||||
Serial.println(F("Send ASCII 7 bit PulseDistanceWidth LSB first"));
|
||||
Serial.flush();
|
||||
// Real PulseDistanceWidth (constant bit length) does theoretically not require a stop bit, but we know the stop bit from serial transmission
|
||||
IrSender.sendPulseDistanceWidth(38, 6000, 500, 500, 1500, 1500, 500, sCommand, 7, PROTOCOL_IS_LSB_FIRST, 0, 0);
|
||||
delay(DELAY_AFTER_SEND);
|
||||
|
||||
Serial.println(F("Send Sony12 as PulseWidth LSB first"));
|
||||
Serial.flush();
|
||||
uint32_t tData = (uint32_t) sAddress << 7 | (sCommand & 0x7F);
|
||||
IrSender.sendPulseDistanceWidth(38, 2400, 600, 1200, 600, 600, 600, tData, SIRCS_12_PROTOCOL, PROTOCOL_IS_LSB_FIRST, 0, 0);
|
||||
delay(DELAY_AFTER_SEND);
|
||||
|
||||
Serial.println(F("Send 32 bit PulseWidth 0x87654321 LSB first"));
|
||||
Serial.flush();
|
||||
// Real PulseDistanceWidth (constant bit length) does not require a stop bit
|
||||
IrSender.sendPulseDistanceWidth(38, 1000, 500, 600, 300, 300, 300, 0x87654321, 32, PROTOCOL_IS_LSB_FIRST, 0, 0);
|
||||
delay(DELAY_AFTER_SEND);
|
||||
}
|
||||
|
||||
Serial.println(F("Send Onkyo (NEC with 16 bit command)"));
|
||||
Serial.flush();
|
||||
IrSender.sendOnkyo(sAddress, s16BitCommand, sRepeats);
|
||||
delay(DELAY_AFTER_SEND);
|
||||
|
||||
Serial.println(F("Send Apple"));
|
||||
Serial.flush();
|
||||
IrSender.sendApple(sAddress & 0xFF, sCommand, sRepeats);
|
||||
delay(DELAY_AFTER_SEND);
|
||||
|
||||
Serial.println(F("Send Panasonic"));
|
||||
Serial.flush();
|
||||
IrSender.sendPanasonic(sAddress & 0xFFF, sCommand, sRepeats);
|
||||
delay(DELAY_AFTER_SEND);
|
||||
|
||||
Serial.println(F("Send Kaseikyo with 0x4711 as Vendor ID"));
|
||||
Serial.flush();
|
||||
IrSender.sendKaseikyo(sAddress & 0xFFF, sCommand, sRepeats, 0x4711);
|
||||
delay(DELAY_AFTER_SEND);
|
||||
|
||||
Serial.println(F("Send Kaseikyo_Denon variant"));
|
||||
Serial.flush();
|
||||
IrSender.sendKaseikyo_Denon(sAddress & 0xFFF, sCommand, sRepeats);
|
||||
delay(DELAY_AFTER_SEND);
|
||||
|
||||
Serial.println(F("Send Denon"));
|
||||
Serial.flush();
|
||||
IrSender.sendDenon(sAddress & 0x1F, sCommand, sRepeats);
|
||||
delay(DELAY_AFTER_SEND);
|
||||
|
||||
Serial.println(F("Send Denon/Sharp variant"));
|
||||
Serial.flush();
|
||||
IrSender.sendSharp(sAddress & 0x1F, sCommand, sRepeats);
|
||||
delay(DELAY_AFTER_SEND);
|
||||
|
||||
Serial.println(F("Send Sony/SIRCS with 7 command and 5 address bits"));
|
||||
Serial.flush();
|
||||
IrSender.sendSony(sAddress & 0x1F, sCommand & 0x7F, sRepeats);
|
||||
delay(DELAY_AFTER_SEND);
|
||||
|
||||
Serial.println(F("Send Sony/SIRCS with 7 command and 8 address bits"));
|
||||
Serial.flush();
|
||||
IrSender.sendSony(sAddress & 0xFF, sCommand, sRepeats, SIRCS_15_PROTOCOL);
|
||||
delay(DELAY_AFTER_SEND);
|
||||
|
||||
Serial.println(F("Send Sony/SIRCS with 7 command and 13 address bits"));
|
||||
Serial.flush();
|
||||
IrSender.sendSony(sAddress & 0x1FFF, sCommand & 0x7F, sRepeats, SIRCS_20_PROTOCOL);
|
||||
delay(DELAY_AFTER_SEND);
|
||||
|
||||
Serial.println(F("Send Samsung 8 bit command"));
|
||||
Serial.flush();
|
||||
IrSender.sendSamsung(sAddress, sCommand, sRepeats);
|
||||
delay(DELAY_AFTER_SEND);
|
||||
|
||||
Serial.println(F("Send Samsung 16 bit command"));
|
||||
Serial.flush();
|
||||
IrSender.sendSamsung(sAddress, s16BitCommand, sRepeats);
|
||||
delay(DELAY_AFTER_SEND);
|
||||
|
||||
Serial.println(F("Send Samsung48 16 bit command"));
|
||||
Serial.flush();
|
||||
IrSender.sendSamsung48(sAddress, s16BitCommand, sRepeats);
|
||||
delay(DELAY_AFTER_SEND);
|
||||
|
||||
Serial.println(F("Send RC5"));
|
||||
Serial.flush();
|
||||
IrSender.sendRC5(sAddress & 0x1F, sCommand & 0x3F, sRepeats, true); // 5 address, 6 command bits
|
||||
delay(DELAY_AFTER_SEND);
|
||||
|
||||
Serial.println(F("Send RC5X with 7.th MSB of command set"));
|
||||
Serial.flush();
|
||||
IrSender.sendRC5(sAddress & 0x1F, (sCommand & 0x3F) + 0x40, sRepeats, true); // 5 address, 7 command bits
|
||||
delay(DELAY_AFTER_SEND);
|
||||
|
||||
Serial.println(F("Send RC6"));
|
||||
Serial.flush();
|
||||
IrSender.sendRC6(sAddress, sCommand, sRepeats, true);
|
||||
delay(DELAY_AFTER_SEND);
|
||||
|
||||
Serial.println(F("Send RC6A with 14 bit 0x2711 as extra"));
|
||||
Serial.flush();
|
||||
IrSender.sendRC6A(sAddress & 0xFF, sCommand, sRepeats, 0x2711, true);
|
||||
delay(DELAY_AFTER_SEND);
|
||||
|
||||
Serial.println(F("Send MagiQuest"));
|
||||
Serial.flush();
|
||||
IrSender.sendMagiQuest(0x6BCD0000 | (uint32_t) sAddress, s16BitCommand); // we have 31 bit address
|
||||
delay(DELAY_AFTER_SEND);
|
||||
|
||||
/*
|
||||
* Next example how to use the IrSender.write function
|
||||
*/
|
||||
IRData IRSendData;
|
||||
// prepare data
|
||||
IRSendData.address = sAddress;
|
||||
IRSendData.command = sCommand;
|
||||
IRSendData.flags = IRDATA_FLAGS_EMPTY;
|
||||
|
||||
Serial.println(F("Send next protocols with IrSender.write"));
|
||||
Serial.flush();
|
||||
|
||||
IRSendData.protocol = JVC; // switch protocol
|
||||
Serial.print(F("Send "));
|
||||
Serial.println(getProtocolString(IRSendData.protocol));
|
||||
Serial.flush();
|
||||
IrSender.write(&IRSendData, sRepeats);
|
||||
delay(DELAY_AFTER_SEND);
|
||||
|
||||
IRSendData.command = s16BitCommand; // LG support more than 8 bit command
|
||||
|
||||
IRSendData.protocol = SAMSUNG;
|
||||
Serial.print(F("Send "));
|
||||
Serial.println(getProtocolString(IRSendData.protocol));
|
||||
Serial.flush();
|
||||
IrSender.write(&IRSendData, sRepeats);
|
||||
delay(DELAY_AFTER_SEND);
|
||||
|
||||
IRSendData.protocol = LG;
|
||||
Serial.print(F("Send "));
|
||||
Serial.println(getProtocolString(IRSendData.protocol));
|
||||
Serial.flush();
|
||||
IrSender.write(&IRSendData, sRepeats);
|
||||
delay(DELAY_AFTER_SEND);
|
||||
|
||||
IRSendData.protocol = BOSEWAVE;
|
||||
Serial.println(F("Send Bosewave with no address and 8 command bits"));
|
||||
Serial.flush();
|
||||
IrSender.write(&IRSendData, sRepeats);
|
||||
delay(DELAY_AFTER_SEND);
|
||||
|
||||
IRSendData.protocol = FAST;
|
||||
Serial.print(F("Send "));
|
||||
Serial.println(getProtocolString(IRSendData.protocol));
|
||||
Serial.flush();
|
||||
IrSender.write(&IRSendData, sRepeats);
|
||||
delay(DELAY_AFTER_SEND);
|
||||
|
||||
/*
|
||||
* LEGO is difficult to receive because of its short marks and spaces
|
||||
*/
|
||||
Serial.println(F("Send Lego with 2 channel and with 4 command bits"));
|
||||
Serial.flush();
|
||||
IrSender.sendLegoPowerFunctions(sAddress, sCommand, LEGO_MODE_COMBO, true);
|
||||
delay(DELAY_AFTER_SEND);
|
||||
|
||||
|
||||
/*
|
||||
* Force buffer overflow
|
||||
*/
|
||||
Serial.println(F("Force buffer overflow by sending 700 marks and spaces"));
|
||||
for (unsigned int i = 0; i < 350; ++i) {
|
||||
// 400 + 400 should be received as 8/8 and sometimes as 9/7 or 7/9 if compensation by MARK_EXCESS_MICROS is optimal.
|
||||
// 210 + 540 = 750 should be received as 5/10 or 4/11 if compensation by MARK_EXCESS_MICROS is optimal.
|
||||
IrSender.mark(210); // 8 pulses at 38 kHz
|
||||
IrSender.space(540); // to fill up to 750 us
|
||||
}
|
||||
delay(DELAY_AFTER_SEND);
|
||||
|
||||
/*
|
||||
* Increment values
|
||||
* Also increment address just for demonstration, which normally makes no sense
|
||||
*/
|
||||
sAddress += 0x0101;
|
||||
sCommand += 0x11;
|
||||
s16BitCommand += 0x1111;
|
||||
sRepeats++;
|
||||
// clip repeats at 4
|
||||
if (sRepeats > 4) {
|
||||
sRepeats = 4;
|
||||
}
|
||||
|
||||
delay(DELAY_AFTER_LOOP); // additional delay at the end of each loop
|
||||
}
|
||||
|
||||
@@ -0,0 +1,349 @@
|
||||
/*
|
||||
* PinDefinitionsAndMore.h
|
||||
*
|
||||
* Contains pin definitions for IRremote examples for various platforms
|
||||
* as well as definitions for feedback LED and tone() and includes
|
||||
*
|
||||
* Copyright (C) 2021-2023 Armin Joachimsmeyer
|
||||
* armin.joachimsmeyer@gmail.com
|
||||
*
|
||||
* This file is part of IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
|
||||
*
|
||||
* Arduino-IRremote is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/gpl.html>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Pin mapping table for different platforms
|
||||
*
|
||||
* Platform IR input IR output Tone Core/Pin schema
|
||||
* --------------------------------------------------------------
|
||||
* DEFAULT/AVR 2 3 4 Arduino
|
||||
* ATtinyX5 0|PB0 4|PB4 3|PB3 ATTinyCore
|
||||
* ATtiny167 3|PA3 2|PA2 7|PA7 ATTinyCore
|
||||
* ATtiny167 9|PA3 8|PA2 5|PA7 Digispark original core
|
||||
* ATtiny84 |PB2 |PA4 |PA3 ATTinyCore
|
||||
* ATtiny88 3|PD3 4|PD4 9|PB1 ATTinyCore
|
||||
* ATtiny3217 18|PA1 19|PA2 20|PA3 MegaTinyCore
|
||||
* ATtiny1604 2 3|PA5 %
|
||||
* ATtiny816 14|PA1 16|PA3 1|PA5 MegaTinyCore
|
||||
* ATtiny1614 8|PA1 10|PA3 1|PA5 MegaTinyCore
|
||||
* SAMD21 3 4 5
|
||||
* ESP8266 14|D5 12|D6 %
|
||||
* ESP32 15 4 27
|
||||
* ESP32-C3 2 3 4
|
||||
* BluePill PA6 PA7 PA3
|
||||
* APOLLO3 11 12 5
|
||||
* RP2040 3|GPIO15 4|GPIO16 5|GPIO17
|
||||
*/
|
||||
//#define _IR_MEASURE_TIMING // For debugging purposes.
|
||||
|
||||
#if defined(__AVR__)
|
||||
#if defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__) // Digispark board. For use with ATTinyCore.
|
||||
#include "ATtinySerialOut.hpp" // TX is at pin 2 - Available as Arduino library "ATtinySerialOut". Saves 700 bytes program memory and 70 bytes RAM for ATtinyCore.
|
||||
#define IR_RECEIVE_PIN PIN_PB0
|
||||
#define IR_SEND_PIN PIN_PB4 // Pin 2 is serial output with ATtinySerialOut. Pin 1 is internal LED and Pin3 is USB+ with pullup on Digispark board.
|
||||
#define TONE_PIN PIN_PB3
|
||||
#define _IR_TIMING_TEST_PIN PIN_PB3
|
||||
|
||||
# elif defined(__AVR_ATtiny87__) || defined(__AVR_ATtiny167__) // Digispark pro board
|
||||
#include "ATtinySerialOut.hpp" // Available as Arduino library "ATtinySerialOut"
|
||||
// For ATtiny167 Pins PB6 and PA3 are usable as interrupt source.
|
||||
# if defined(ARDUINO_AVR_DIGISPARKPRO)
|
||||
// For use with Digispark original core
|
||||
#define IR_RECEIVE_PIN 9 // PA3 - on Digispark board labeled as pin 9
|
||||
//#define IR_RECEIVE_PIN 14 // PB6 / INT0 is connected to USB+ on DigisparkPro boards
|
||||
#define IR_SEND_PIN 8 // PA2 - on Digispark board labeled as pin 8
|
||||
#define TONE_PIN 5 // PA7 - on Digispark board labeled as pin 5
|
||||
#define _IR_TIMING_TEST_PIN 10 // PA4
|
||||
# else
|
||||
// For use with ATTinyCore
|
||||
#define IR_RECEIVE_PIN PIN_PA3 // On Digispark board labeled as pin 9 - INT0 is connected to USB+ on DigisparkPro boards
|
||||
#define IR_SEND_PIN PIN_PA2 // On Digispark board labeled as pin 8
|
||||
#define TONE_PIN PIN_PA7 // On Digispark board labeled as pin 5
|
||||
# endif
|
||||
|
||||
# elif defined(__AVR_ATtiny84__) // For use with ATTinyCore
|
||||
#include "ATtinySerialOut.hpp" // Available as Arduino library "ATtinySerialOut". Saves 128 bytes program memory.
|
||||
#define IR_RECEIVE_PIN PIN_PB2 // INT0
|
||||
#define IR_SEND_PIN PIN_PA4
|
||||
#define TONE_PIN PIN_PA3
|
||||
#define _IR_TIMING_TEST_PIN PIN_PA5
|
||||
|
||||
# elif defined(__AVR_ATtiny88__) // MH-ET Tiny88 board. For use with ATTinyCore.
|
||||
#include "ATtinySerialOut.hpp" // Available as Arduino library "ATtinySerialOut". Saves 128 bytes program memory.
|
||||
// Pin 6 is TX, pin 7 is RX
|
||||
#define IR_RECEIVE_PIN PIN_PD3 // 3 - INT1
|
||||
#define IR_SEND_PIN PIN_PD4 // 4
|
||||
#define TONE_PIN PIN_PB1 // 9
|
||||
#define _IR_TIMING_TEST_PIN PIN_PB0 // 8
|
||||
|
||||
# elif defined(__AVR_ATtiny1616__) || defined(__AVR_ATtiny3216__) || defined(__AVR_ATtiny3217__) // For use with megaTinyCore
|
||||
// Tiny Core Dev board
|
||||
// https://www.tindie.com/products/xkimi/tiny-core-16-dev-board-attiny1616/ - Out of Stock
|
||||
// https://www.tindie.com/products/xkimi/tiny-core-32-dev-board-attiny3217/ - Out of Stock
|
||||
#define IR_RECEIVE_PIN PIN_PA1 // use 18 instead of PIN_PA1 for TinyCore32
|
||||
#define IR_SEND_PIN PIN_PA2 // 19
|
||||
#define TONE_PIN PIN_PA3 // 20
|
||||
#define APPLICATION_PIN PIN_PA0 // 0
|
||||
#undef LED_BUILTIN // No LED available on the TinyCore 32 board, take the one on the programming board which is connected to the DAC output
|
||||
#define LED_BUILTIN PIN_PA6 // use 2 instead of PIN_PA6 for TinyCore32
|
||||
|
||||
# elif defined(__AVR_ATtiny816__) // For use with megaTinyCore
|
||||
#define IR_RECEIVE_PIN PIN_PA1 // 14
|
||||
#define IR_SEND_PIN PIN_PA1 // 16
|
||||
#define TONE_PIN PIN_PA5 // 1
|
||||
#define APPLICATION_PIN PIN_PA4 // 0
|
||||
#undef LED_BUILTIN // No LED available, take the one which is connected to the DAC output
|
||||
#define LED_BUILTIN PIN_PB5 // 4
|
||||
|
||||
# elif defined(__AVR_ATtiny1614__) // For use with megaTinyCore
|
||||
#define IR_RECEIVE_PIN PIN_PA1 // 8
|
||||
#define IR_SEND_PIN PIN_PA3 // 10
|
||||
#define TONE_PIN PIN_PA5 // 1
|
||||
#define APPLICATION_PIN PIN_PA4 // 0
|
||||
|
||||
# elif defined(__AVR_ATtiny1604__) // For use with megaTinyCore
|
||||
#define IR_RECEIVE_PIN PIN_PA6 // 2 - To be compatible with interrupt example, pin 2 is chosen here.
|
||||
#define IR_SEND_PIN PIN_PA7 // 3
|
||||
#define APPLICATION_PIN PIN_PB2 // 5
|
||||
|
||||
#define tone(...) void() // Define as void, since TCB0_INT_vect is also used by tone()
|
||||
#define noTone(a) void()
|
||||
#define TONE_PIN 42 // Dummy for examples using it
|
||||
|
||||
# elif defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) \
|
||||
|| defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) \
|
||||
|| defined(__AVR_ATmega324P__) || defined(__AVR_ATmega324A__) \
|
||||
|| defined(__AVR_ATmega324PA__) || defined(__AVR_ATmega164A__) \
|
||||
|| defined(__AVR_ATmega164P__) || defined(__AVR_ATmega32__) \
|
||||
|| defined(__AVR_ATmega16__) || defined(__AVR_ATmega8535__) \
|
||||
|| defined(__AVR_ATmega64__) || defined(__AVR_ATmega128__) \
|
||||
|| defined(__AVR_ATmega1281__) || defined(__AVR_ATmega2561__) \
|
||||
|| defined(__AVR_ATmega8515__) || defined(__AVR_ATmega162__)
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 13
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
# else // Default as for ATmega328 like on Uno, Nano, Leonardo, Teensy 2.0 etc.
|
||||
#define IR_RECEIVE_PIN 2 // To be compatible with interrupt example, pin 2 is chosen here.
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
# if defined(ARDUINO_AVR_PROMICRO) // Sparkfun Pro Micro is __AVR_ATmega32U4__ but has different external circuit
|
||||
// We have no built in LED at pin 13 -> reuse RX LED
|
||||
#undef LED_BUILTIN
|
||||
#define LED_BUILTIN LED_BUILTIN_RX
|
||||
# endif
|
||||
# endif // defined(__AVR_ATtiny25__)...
|
||||
|
||||
#elif defined(ARDUINO_ARCH_RENESAS_UNO) // Uno R4
|
||||
// To be compatible with Uno R3.
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
#elif defined(ESP8266)
|
||||
#define FEEDBACK_LED_IS_ACTIVE_LOW // The LED on my board (D4) is active LOW
|
||||
#define IR_RECEIVE_PIN 14 // D5
|
||||
#define IR_SEND_PIN 12 // D6 - D4/pin 2 is internal LED
|
||||
#define _IR_TIMING_TEST_PIN 2 // D4
|
||||
#define APPLICATION_PIN 13 // D7
|
||||
|
||||
#define tone(...) void() // tone() inhibits receive timer
|
||||
#define noTone(a) void()
|
||||
#define TONE_PIN 42 // Dummy for examples using it#
|
||||
|
||||
#elif defined(ARDUINO_NOLOGO_ESP32C3_SUPER_MINI)
|
||||
#define FEEDBACK_LED_IS_ACTIVE_LOW // The LED on my board (D8) is active LOW
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 10
|
||||
|
||||
#elif defined(CONFIG_IDF_TARGET_ESP32C3) || defined(ARDUINO_ESP32C3_DEV)
|
||||
#define NO_LED_FEEDBACK_CODE // The WS2812 on pin 8 of AI-C3 board crashes if used as receive feedback LED, other I/O pins are working...
|
||||
#define IR_RECEIVE_PIN 6
|
||||
#define IR_SEND_PIN 7
|
||||
#define TONE_PIN 10
|
||||
#define APPLICATION_PIN 18
|
||||
|
||||
#elif defined(ESP32)
|
||||
#include <Arduino.h>
|
||||
|
||||
// tone() is included in ESP32 core since 2.0.2
|
||||
#if !defined(ESP_ARDUINO_VERSION_VAL)
|
||||
#define ESP_ARDUINO_VERSION_VAL(major, minor, patch) 12345678
|
||||
#endif
|
||||
#if ESP_ARDUINO_VERSION <= ESP_ARDUINO_VERSION_VAL(2, 0, 2)
|
||||
#define TONE_LEDC_CHANNEL 1 // Using channel 1 makes tone() independent of receiving timer -> No need to stop receiving timer.
|
||||
void tone(uint8_t aPinNumber, unsigned int aFrequency){
|
||||
ledcAttachPin(aPinNumber, TONE_LEDC_CHANNEL);
|
||||
ledcWriteTone(TONE_LEDC_CHANNEL, aFrequency);
|
||||
}
|
||||
void tone(uint8_t aPinNumber, unsigned int aFrequency, unsigned long aDuration){
|
||||
ledcAttachPin(aPinNumber, TONE_LEDC_CHANNEL);
|
||||
ledcWriteTone(TONE_LEDC_CHANNEL, aFrequency);
|
||||
delay(aDuration);
|
||||
ledcWriteTone(TONE_LEDC_CHANNEL, 0);
|
||||
}
|
||||
void noTone(uint8_t aPinNumber){
|
||||
ledcWriteTone(TONE_LEDC_CHANNEL, 0);
|
||||
}
|
||||
#endif // ESP_ARDUINO_VERSION <= ESP_ARDUINO_VERSION_VAL(2, 0, 2)
|
||||
|
||||
#define IR_RECEIVE_PIN 15 // D15
|
||||
#define IR_SEND_PIN 4 // D4
|
||||
#define TONE_PIN 27 // D27 25 & 26 are DAC0 and 1
|
||||
#define APPLICATION_PIN 16 // RX2 pin
|
||||
|
||||
#elif defined(ARDUINO_ARCH_STM32) || defined(ARDUINO_ARCH_STM32F1) // BluePill
|
||||
// Timer 3 blocks PA6, PA7, PB0, PB1 for use by Servo or tone()
|
||||
#define IR_RECEIVE_PIN PA6
|
||||
#define IR_RECEIVE_PIN_STRING "PA6"
|
||||
#define IR_SEND_PIN PA7
|
||||
#define IR_SEND_PIN_STRING "PA7"
|
||||
#define TONE_PIN PA3
|
||||
#define _IR_TIMING_TEST_PIN PA5
|
||||
#define APPLICATION_PIN PA2
|
||||
#define APPLICATION_PIN_STRING "PA2"
|
||||
# if defined(ARDUINO_GENERIC_STM32F103C) || defined(ARDUINO_BLUEPILL_F103C8)
|
||||
// BluePill LED is active low
|
||||
#define FEEDBACK_LED_IS_ACTIVE_LOW
|
||||
# endif
|
||||
|
||||
#elif defined(ARDUINO_ARCH_APOLLO3) // Sparkfun Apollo boards
|
||||
#define IR_RECEIVE_PIN 11
|
||||
#define IR_SEND_PIN 12
|
||||
#define TONE_PIN 5
|
||||
|
||||
#elif defined(ARDUINO_ARCH_MBED) && defined(ARDUINO_ARCH_MBED_NANO) // Arduino Nano 33 BLE and Arduino Nano Connect layout for MBED
|
||||
// Must be before ARDUINO_ARCH_RP2040, since it is the layout for the MBED core of Arduino Nano Connect
|
||||
#define IR_RECEIVE_PIN 3 // GPIO15 Start with pin 3 since pin 2|GPIO25 is connected to LED on Pi pico
|
||||
#define IR_SEND_PIN 4 // GPIO16
|
||||
#define TONE_PIN 5
|
||||
#define APPLICATION_PIN 6
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 7 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 8
|
||||
|
||||
#elif defined(ARDUINO_ARCH_RP2040) // Arduino Nano Connect, Pi Pico with arduino-pico core https://github.com/earlephilhower/arduino-pico
|
||||
#define IR_RECEIVE_PIN 15 // GPIO15 to be compatible with the Arduino Nano RP2040 Connect (pin3)
|
||||
#define IR_SEND_PIN 16 // GPIO16
|
||||
#define TONE_PIN 17
|
||||
#define APPLICATION_PIN 18
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 19 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 20
|
||||
|
||||
// If you program the Nano RP2040 Connect with this core, then you must redefine LED_BUILTIN
|
||||
// and use the external reset with 1 kOhm to ground to enter UF2 mode
|
||||
#undef LED_BUILTIN
|
||||
#define LED_BUILTIN 6
|
||||
|
||||
#elif defined(PARTICLE) // !!!UNTESTED!!!
|
||||
#define IR_RECEIVE_PIN A4
|
||||
#define IR_SEND_PIN A5 // Particle supports multiple pins
|
||||
|
||||
#define LED_BUILTIN D7
|
||||
|
||||
/*
|
||||
* 4 times the same (default) layout for easy adaption in the future
|
||||
*/
|
||||
#elif defined(TEENSYDUINO) // Teensy 2.0 is handled at default for ATmega328 like on Uno, Nano, Leonardo etc.
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
#elif defined(ARDUINO_ARCH_MBED) // Arduino Nano 33 BLE
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
#elif defined(ARDUINO_ARCH_SAMD) || defined(ARDUINO_ARCH_SAM)
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
#if !defined(ARDUINO_SAMD_ADAFRUIT) && !defined(ARDUINO_SEEED_XIAO_M0)
|
||||
// On the Zero and others we switch explicitly to SerialUSB
|
||||
#define Serial SerialUSB
|
||||
#endif
|
||||
|
||||
// Definitions for the Chinese SAMD21 M0-Mini clone, which has no led connected to D13/PA17.
|
||||
// Attention!!! D2 and D4 are swapped on these boards!!!
|
||||
// If you connect the LED, it is on pin 24/PB11. In this case activate the next two lines.
|
||||
//#undef LED_BUILTIN
|
||||
//#define LED_BUILTIN 24 // PB11
|
||||
// As an alternative you can choose pin 25, it is the RX-LED pin (PB03), but active low.In this case activate the next 3 lines.
|
||||
//#undef LED_BUILTIN
|
||||
//#define LED_BUILTIN 25 // PB03
|
||||
//#define FEEDBACK_LED_IS_ACTIVE_LOW // The RX LED on the M0-Mini is active LOW
|
||||
|
||||
#elif defined (NRF51) // BBC micro:bit
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define APPLICATION_PIN 1
|
||||
#define _IR_TIMING_TEST_PIN 4
|
||||
|
||||
#define tone(...) void() // no tone() available
|
||||
#define noTone(a) void()
|
||||
#define TONE_PIN 42 // Dummy for examples using it
|
||||
|
||||
#else
|
||||
#warning Board / CPU is not detected using pre-processor symbols -> using default values, which may not fit. Please extend PinDefinitionsAndMore.h.
|
||||
// Default valued for unidentified boards
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
#endif // defined(ESP8266)
|
||||
|
||||
#if defined(ESP32) || defined(ARDUINO_ARCH_RP2040) || defined(PARTICLE) || defined(ARDUINO_ARCH_MBED)
|
||||
#define SEND_PWM_BY_TIMER // We do not have pin restrictions for this CPU's, so lets use the hardware PWM for send carrier signal generation
|
||||
#else
|
||||
# if defined(SEND_PWM_BY_TIMER)
|
||||
#undef IR_SEND_PIN // SendPin is determined by timer! This avoids warnings in IRremote.hpp and IRTimer.hpp
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if !defined (FLASHEND)
|
||||
#define FLASHEND 0xFFFF // Dummy value for platforms where FLASHEND is not defined
|
||||
#endif
|
||||
|
||||
/*
|
||||
* 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
|
||||
@@ -0,0 +1,93 @@
|
||||
=== decoding for LG A/C ====
|
||||
- 1) remote of LG AC has two type of HDR mark/space, 8000/4000 and 3100/10000
|
||||
- 2) HDR 8000/4000 is decoded using decodeLG(IRrecvDumpV2) without problem
|
||||
- 3) for HDR 3100/10000, use AnalysIR's code : http://www.analysir.com/blog/2014/03/19/air-conditioners-problems-recording-long-infrared-remote-control-signals-arduino/
|
||||
- 4) for bin output based on AnalysIR's code : https://gist.github.com/chaeplin/a3a4b4b6b887c663bfe8
|
||||
- 5) remove first two byte(11)
|
||||
- 6) sample rawcode with bin output : https://gist.github.com/chaeplin/134d232e0b8cfb898860
|
||||
|
||||
|
||||
=== *** ===
|
||||
- 1) Sample raw code : https://gist.github.com/chaeplin/ab2a7ad1533c41260f0d
|
||||
- 2) send raw code : https://gist.github.com/chaeplin/7c800d3166463bb51be4
|
||||
|
||||
|
||||
=== *** ===
|
||||
- (0) : Cooling or Heating
|
||||
- (1) : fixed address
|
||||
- (2) : fixed address
|
||||
- (3) : special(power, swing, air clean)
|
||||
- (4) : change air flow, temperature, cooling(0)/heating(4)
|
||||
- (5) : temperature ( 15 + (5) = )
|
||||
- (6) : air flow
|
||||
- (7) : checksum ( 3 + 4 + 5 + 6 ) & B00001111
|
||||
|
||||
|
||||
°F = °C × 1.8 + 32<br/>
|
||||
°C = (°F - 32) / 1.8
|
||||
|
||||
|
||||
=== *** ===
|
||||
* remote / Korea / without heating
|
||||
|
||||
| status |(0)| (1)| (2)| (3)| (4)| (5)| (6)| (7)
|
||||
|----------------|---|----|----|----|----|----|----|----
|
||||
| on / 25 / mid | C |1000|1000|0000|0000|1010|0010|1100
|
||||
| on / 26 / mid | C |1000|1000|0000|0000|1011|0010|1101
|
||||
| on / 27 / mid | C |1000|1000|0000|0000|1100|0010|1110
|
||||
| on / 28 / mid | C |1000|1000|0000|0000|1101|0010|1111
|
||||
| on / 25 / high | C |1000|1000|0000|0000|1010|0100|1110
|
||||
| on / 26 / high | C |1000|1000|0000|0000|1011|0100|1111
|
||||
| on / 27 / high | C |1000|1000|0000|0000|1100|0100|0000
|
||||
| on / 28 / high | C |1000|1000|0000|0000|1101|0100|0001
|
||||
|----------------|---|----|----|----|----|----|----|----
|
||||
| 1 up | C |1000|1000|0000|1000|1101|0100|1001
|
||||
|----------------|---|----|----|----|----|----|----|----
|
||||
| Cool power | C |1000|1000|0001|0000|0000|1100|1101
|
||||
| energy saving | C |1000|1000|0001|0000|0000|0100|0101
|
||||
| power | C |1000|1000|0001|0000|0000|1000|1001
|
||||
| flow/up/down | C |1000|1000|0001|0011|0001|0100|1001
|
||||
| up/down off | C |1000|1000|0001|0011|0001|0101|1010
|
||||
| flow/left/right| C |1000|1000|0001|0011|0001|0110|1011
|
||||
| left/right off | C |1000|1000|0001|0011|0001|0111|1100
|
||||
|----------------|---|----|----|----|----|----|----|----
|
||||
| Air clean | C |1000|1000|1100|0000|0000|0000|1100
|
||||
|----------------|---|----|----|----|----|----|----|----
|
||||
| off | C |1000|1000|1100|0000|0000|0101|0001
|
||||
|
||||
|
||||
|
||||
* remote / with heating
|
||||
* converted using raw code at https://github.com/chaeplin/RaspAC/blob/master/lircd.conf
|
||||
|
||||
| status |(0)| (1)| (2)| (3)| (4)| (5)| (6)| (7)
|
||||
|----------------|---|----|----|----|----|----|----|----
|
||||
| on | C |1000|1000|0000|0000|1011|0010|1101
|
||||
|----------------|---|----|----|----|----|----|----|----
|
||||
| off | C |1000|1000|1100|0000|0000|0101|0001
|
||||
|----------------|---|----|----|----|----|----|----|----
|
||||
| 64 / 18 | C |1000|1000|0000|0000|0011|0100|0111
|
||||
| 66 / 19 | C |1000|1000|0000|0000|0100|0100|1000
|
||||
| 68 / 20 | C |1000|1000|0000|0000|0101|0100|1001
|
||||
| 70 / 21 | C |1000|1000|0000|0000|0110|0100|1010
|
||||
| 72 / 22 | C |1000|1000|0000|0000|0111|0100|1011
|
||||
| 74 / 23 | C |1000|1000|0000|0000|1000|0100|1100
|
||||
| 76 / 25 | C |1000|1000|0000|0000|1010|0100|1110
|
||||
| 78 / 26 | C |1000|1000|0000|0000|1011|0100|1111
|
||||
| 80 / 27 | C |1000|1000|0000|0000|1100|0100|0000
|
||||
| 82 / 28 | C |1000|1000|0000|0000|1101|0100|0001
|
||||
| 84 / 29 | C |1000|1000|0000|0000|1110|0100|0010
|
||||
| 86 / 30 | C |1000|1000|0000|0000|1111|0100|0011
|
||||
|----------------|---|----|----|----|----|----|----|----
|
||||
| heat64 | H |1000|1000|0000|0100|0011|0100|1011
|
||||
| heat66 | H |1000|1000|0000|0100|0100|0100|1100
|
||||
| heat68 | H |1000|1000|0000|0100|0101|0100|1101
|
||||
| heat70 | H |1000|1000|0000|0100|0110|0100|1110
|
||||
| heat72 | H |1000|1000|0000|0100|0111|0100|1111
|
||||
| heat74 | H |1000|1000|0000|0100|1000|0100|0000
|
||||
| heat76 | H |1000|1000|0000|0100|1001|0100|0001
|
||||
| heat78 | H |1000|1000|0000|0100|1011|0100|0011
|
||||
| heat80 | H |1000|1000|0000|0100|1100|0100|0100
|
||||
| heat82 | H |1000|1000|0000|0100|1101|0100|0101
|
||||
| heat84 | H |1000|1000|0000|0100|1110|0100|0110
|
||||
| heat86 | H |1000|1000|0000|0100|1111|0100|0111
|
||||
@@ -0,0 +1,153 @@
|
||||
/*
|
||||
* SendLGAirConditionerDemo.cpp
|
||||
*
|
||||
* Sending LG air conditioner IR codes controlled by Serial input
|
||||
* Based on he old IRremote source from https://github.com/chaeplin
|
||||
*
|
||||
* This file is part of Arduino-IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
|
||||
*
|
||||
************************************************************************************
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2020-2022 Armin Joachimsmeyer
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is furnished
|
||||
* to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
************************************************************************************
|
||||
*/
|
||||
#include <Arduino.h>
|
||||
|
||||
/*
|
||||
* LG2 has different header timing and a shorter bit time
|
||||
* Known LG remote controls, which uses LG2 protocol are:
|
||||
* AKB75215403
|
||||
* AKB74955603
|
||||
* AKB73757604:
|
||||
*/
|
||||
//#define USE_LG2_PROTOCOL // Try it if you do not have success with the default LG protocol
|
||||
#define NUMBER_OF_COMMANDS_BETWEEN_PRINT_OF_MENU 5
|
||||
|
||||
#define INFO // Deactivate this to save program memory and suppress info output from the LG-AC driver.
|
||||
//#define DEBUG // Activate this for more output from the LG-AC driver.
|
||||
|
||||
/*
|
||||
* 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_SEND_PIN 3 // P0_0
|
||||
|
||||
#include <IRremote.hpp>
|
||||
|
||||
|
||||
#include "ac_LG.hpp"
|
||||
|
||||
#define SIZE_OF_RECEIVE_BUFFER 10
|
||||
char sRequestString[SIZE_OF_RECEIVE_BUFFER];
|
||||
|
||||
Aircondition_LG MyLG_Aircondition;
|
||||
|
||||
void setup() {
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
|
||||
Serial.begin(9600);
|
||||
while (!Serial)
|
||||
; // Wait for Serial to become available. Is optimized away for some cores.
|
||||
|
||||
|
||||
// Just to know which program is running on my Arduino
|
||||
Serial.println(F("START " __FILE__ " from " __DATE__ "\r\nUsing library version " VERSION_IRREMOTE));
|
||||
Serial.println(F("Send IR signals at pin " STR(IR_SEND_PIN)));
|
||||
|
||||
/*
|
||||
* The IR library setup. That's all!
|
||||
*/
|
||||
IrSender.begin(); // Start with IR_SEND_PIN as send pin and enable feedback LED at default feedback LED pin
|
||||
|
||||
Serial.println();
|
||||
MyLG_Aircondition.setType(LG_IS_WALL_TYPE);
|
||||
MyLG_Aircondition.printMenu(&Serial);
|
||||
|
||||
delay(1000);
|
||||
|
||||
// test
|
||||
// MyLG_Aircondition.sendCommandAndParameter('j', 1);
|
||||
// delay(5000);
|
||||
// MyLG_Aircondition.sendCommandAndParameter('f', 3);
|
||||
// delay(5000);
|
||||
|
||||
}
|
||||
|
||||
void loop() {
|
||||
static uint8_t sShowmenuConter = 0;
|
||||
|
||||
if (Serial.available()) {
|
||||
/*
|
||||
* Get parameters from serial
|
||||
*/
|
||||
uint8_t tNumberOfBytesReceived = Serial.readBytesUntil('\n', sRequestString, SIZE_OF_RECEIVE_BUFFER - 1);
|
||||
// handle CR LF
|
||||
if (sRequestString[tNumberOfBytesReceived - 1] == '\r') {
|
||||
tNumberOfBytesReceived--;
|
||||
}
|
||||
sRequestString[tNumberOfBytesReceived] = '\0'; // terminate as string
|
||||
char tCommand = sRequestString[0];
|
||||
|
||||
/*
|
||||
* Handle parameter numbers which can be greater 9
|
||||
*/
|
||||
int tParameter = 0;
|
||||
if (tNumberOfBytesReceived >= 2) {
|
||||
tParameter = sRequestString[1] - '0';
|
||||
if (tCommand == LG_COMMAND_TEMPERATURE || tCommand == LG_COMMAND_SWING || tCommand == LG_COMMAND_SLEEP
|
||||
|| tCommand == LG_COMMAND_TIMER_ON || tCommand == LG_COMMAND_TIMER_OFF) {
|
||||
tParameter = atoi(&sRequestString[1]);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Print command to send
|
||||
*/
|
||||
Serial.println();
|
||||
Serial.print(F("Command="));
|
||||
Serial.print(tCommand);
|
||||
if (tParameter != 0) {
|
||||
Serial.print(F(" Parameter="));
|
||||
Serial.print(tParameter);
|
||||
}
|
||||
Serial.println();
|
||||
|
||||
if (!MyLG_Aircondition.sendCommandAndParameter(tCommand, tParameter)) {
|
||||
Serial.print(F("Error: unknown command or invalid parameter in \""));
|
||||
Serial.print(sRequestString);
|
||||
Serial.println('\"');
|
||||
}
|
||||
|
||||
if (sShowmenuConter == 0) {
|
||||
MyLG_Aircondition.printMenu(&Serial);
|
||||
sShowmenuConter = NUMBER_OF_COMMANDS_BETWEEN_PRINT_OF_MENU;
|
||||
} else {
|
||||
sShowmenuConter--;
|
||||
}
|
||||
}
|
||||
delay(100);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,349 @@
|
||||
/*
|
||||
* PinDefinitionsAndMore.h
|
||||
*
|
||||
* Contains pin definitions for IRremote examples for various platforms
|
||||
* as well as definitions for feedback LED and tone() and includes
|
||||
*
|
||||
* Copyright (C) 2021-2023 Armin Joachimsmeyer
|
||||
* armin.joachimsmeyer@gmail.com
|
||||
*
|
||||
* This file is part of IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
|
||||
*
|
||||
* Arduino-IRremote is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/gpl.html>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Pin mapping table for different platforms
|
||||
*
|
||||
* Platform IR input IR output Tone Core/Pin schema
|
||||
* --------------------------------------------------------------
|
||||
* DEFAULT/AVR 2 3 4 Arduino
|
||||
* ATtinyX5 0|PB0 4|PB4 3|PB3 ATTinyCore
|
||||
* ATtiny167 3|PA3 2|PA2 7|PA7 ATTinyCore
|
||||
* ATtiny167 9|PA3 8|PA2 5|PA7 Digispark original core
|
||||
* ATtiny84 |PB2 |PA4 |PA3 ATTinyCore
|
||||
* ATtiny88 3|PD3 4|PD4 9|PB1 ATTinyCore
|
||||
* ATtiny3217 18|PA1 19|PA2 20|PA3 MegaTinyCore
|
||||
* ATtiny1604 2 3|PA5 %
|
||||
* ATtiny816 14|PA1 16|PA3 1|PA5 MegaTinyCore
|
||||
* ATtiny1614 8|PA1 10|PA3 1|PA5 MegaTinyCore
|
||||
* SAMD21 3 4 5
|
||||
* ESP8266 14|D5 12|D6 %
|
||||
* ESP32 15 4 27
|
||||
* ESP32-C3 2 3 4
|
||||
* BluePill PA6 PA7 PA3
|
||||
* APOLLO3 11 12 5
|
||||
* RP2040 3|GPIO15 4|GPIO16 5|GPIO17
|
||||
*/
|
||||
//#define _IR_MEASURE_TIMING // For debugging purposes.
|
||||
|
||||
#if defined(__AVR__)
|
||||
#if defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__) // Digispark board. For use with ATTinyCore.
|
||||
#include "ATtinySerialOut.hpp" // TX is at pin 2 - Available as Arduino library "ATtinySerialOut". Saves 700 bytes program memory and 70 bytes RAM for ATtinyCore.
|
||||
#define IR_RECEIVE_PIN PIN_PB0
|
||||
#define IR_SEND_PIN PIN_PB4 // Pin 2 is serial output with ATtinySerialOut. Pin 1 is internal LED and Pin3 is USB+ with pullup on Digispark board.
|
||||
#define TONE_PIN PIN_PB3
|
||||
#define _IR_TIMING_TEST_PIN PIN_PB3
|
||||
|
||||
# elif defined(__AVR_ATtiny87__) || defined(__AVR_ATtiny167__) // Digispark pro board
|
||||
#include "ATtinySerialOut.hpp" // Available as Arduino library "ATtinySerialOut"
|
||||
// For ATtiny167 Pins PB6 and PA3 are usable as interrupt source.
|
||||
# if defined(ARDUINO_AVR_DIGISPARKPRO)
|
||||
// For use with Digispark original core
|
||||
#define IR_RECEIVE_PIN 9 // PA3 - on Digispark board labeled as pin 9
|
||||
//#define IR_RECEIVE_PIN 14 // PB6 / INT0 is connected to USB+ on DigisparkPro boards
|
||||
#define IR_SEND_PIN 8 // PA2 - on Digispark board labeled as pin 8
|
||||
#define TONE_PIN 5 // PA7 - on Digispark board labeled as pin 5
|
||||
#define _IR_TIMING_TEST_PIN 10 // PA4
|
||||
# else
|
||||
// For use with ATTinyCore
|
||||
#define IR_RECEIVE_PIN PIN_PA3 // On Digispark board labeled as pin 9 - INT0 is connected to USB+ on DigisparkPro boards
|
||||
#define IR_SEND_PIN PIN_PA2 // On Digispark board labeled as pin 8
|
||||
#define TONE_PIN PIN_PA7 // On Digispark board labeled as pin 5
|
||||
# endif
|
||||
|
||||
# elif defined(__AVR_ATtiny84__) // For use with ATTinyCore
|
||||
#include "ATtinySerialOut.hpp" // Available as Arduino library "ATtinySerialOut". Saves 128 bytes program memory.
|
||||
#define IR_RECEIVE_PIN PIN_PB2 // INT0
|
||||
#define IR_SEND_PIN PIN_PA4
|
||||
#define TONE_PIN PIN_PA3
|
||||
#define _IR_TIMING_TEST_PIN PIN_PA5
|
||||
|
||||
# elif defined(__AVR_ATtiny88__) // MH-ET Tiny88 board. For use with ATTinyCore.
|
||||
#include "ATtinySerialOut.hpp" // Available as Arduino library "ATtinySerialOut". Saves 128 bytes program memory.
|
||||
// Pin 6 is TX, pin 7 is RX
|
||||
#define IR_RECEIVE_PIN PIN_PD3 // 3 - INT1
|
||||
#define IR_SEND_PIN PIN_PD4 // 4
|
||||
#define TONE_PIN PIN_PB1 // 9
|
||||
#define _IR_TIMING_TEST_PIN PIN_PB0 // 8
|
||||
|
||||
# elif defined(__AVR_ATtiny1616__) || defined(__AVR_ATtiny3216__) || defined(__AVR_ATtiny3217__) // For use with megaTinyCore
|
||||
// Tiny Core Dev board
|
||||
// https://www.tindie.com/products/xkimi/tiny-core-16-dev-board-attiny1616/ - Out of Stock
|
||||
// https://www.tindie.com/products/xkimi/tiny-core-32-dev-board-attiny3217/ - Out of Stock
|
||||
#define IR_RECEIVE_PIN PIN_PA1 // use 18 instead of PIN_PA1 for TinyCore32
|
||||
#define IR_SEND_PIN PIN_PA2 // 19
|
||||
#define TONE_PIN PIN_PA3 // 20
|
||||
#define APPLICATION_PIN PIN_PA0 // 0
|
||||
#undef LED_BUILTIN // No LED available on the TinyCore 32 board, take the one on the programming board which is connected to the DAC output
|
||||
#define LED_BUILTIN PIN_PA6 // use 2 instead of PIN_PA6 for TinyCore32
|
||||
|
||||
# elif defined(__AVR_ATtiny816__) // For use with megaTinyCore
|
||||
#define IR_RECEIVE_PIN PIN_PA1 // 14
|
||||
#define IR_SEND_PIN PIN_PA1 // 16
|
||||
#define TONE_PIN PIN_PA5 // 1
|
||||
#define APPLICATION_PIN PIN_PA4 // 0
|
||||
#undef LED_BUILTIN // No LED available, take the one which is connected to the DAC output
|
||||
#define LED_BUILTIN PIN_PB5 // 4
|
||||
|
||||
# elif defined(__AVR_ATtiny1614__) // For use with megaTinyCore
|
||||
#define IR_RECEIVE_PIN PIN_PA1 // 8
|
||||
#define IR_SEND_PIN PIN_PA3 // 10
|
||||
#define TONE_PIN PIN_PA5 // 1
|
||||
#define APPLICATION_PIN PIN_PA4 // 0
|
||||
|
||||
# elif defined(__AVR_ATtiny1604__) // For use with megaTinyCore
|
||||
#define IR_RECEIVE_PIN PIN_PA6 // 2 - To be compatible with interrupt example, pin 2 is chosen here.
|
||||
#define IR_SEND_PIN PIN_PA7 // 3
|
||||
#define APPLICATION_PIN PIN_PB2 // 5
|
||||
|
||||
#define tone(...) void() // Define as void, since TCB0_INT_vect is also used by tone()
|
||||
#define noTone(a) void()
|
||||
#define TONE_PIN 42 // Dummy for examples using it
|
||||
|
||||
# elif defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) \
|
||||
|| defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) \
|
||||
|| defined(__AVR_ATmega324P__) || defined(__AVR_ATmega324A__) \
|
||||
|| defined(__AVR_ATmega324PA__) || defined(__AVR_ATmega164A__) \
|
||||
|| defined(__AVR_ATmega164P__) || defined(__AVR_ATmega32__) \
|
||||
|| defined(__AVR_ATmega16__) || defined(__AVR_ATmega8535__) \
|
||||
|| defined(__AVR_ATmega64__) || defined(__AVR_ATmega128__) \
|
||||
|| defined(__AVR_ATmega1281__) || defined(__AVR_ATmega2561__) \
|
||||
|| defined(__AVR_ATmega8515__) || defined(__AVR_ATmega162__)
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 13
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
# else // Default as for ATmega328 like on Uno, Nano, Leonardo, Teensy 2.0 etc.
|
||||
#define IR_RECEIVE_PIN 2 // To be compatible with interrupt example, pin 2 is chosen here.
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
# if defined(ARDUINO_AVR_PROMICRO) // Sparkfun Pro Micro is __AVR_ATmega32U4__ but has different external circuit
|
||||
// We have no built in LED at pin 13 -> reuse RX LED
|
||||
#undef LED_BUILTIN
|
||||
#define LED_BUILTIN LED_BUILTIN_RX
|
||||
# endif
|
||||
# endif // defined(__AVR_ATtiny25__)...
|
||||
|
||||
#elif defined(ARDUINO_ARCH_RENESAS_UNO) // Uno R4
|
||||
// To be compatible with Uno R3.
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
#elif defined(ESP8266)
|
||||
#define FEEDBACK_LED_IS_ACTIVE_LOW // The LED on my board (D4) is active LOW
|
||||
#define IR_RECEIVE_PIN 14 // D5
|
||||
#define IR_SEND_PIN 12 // D6 - D4/pin 2 is internal LED
|
||||
#define _IR_TIMING_TEST_PIN 2 // D4
|
||||
#define APPLICATION_PIN 13 // D7
|
||||
|
||||
#define tone(...) void() // tone() inhibits receive timer
|
||||
#define noTone(a) void()
|
||||
#define TONE_PIN 42 // Dummy for examples using it#
|
||||
|
||||
#elif defined(ARDUINO_NOLOGO_ESP32C3_SUPER_MINI)
|
||||
#define FEEDBACK_LED_IS_ACTIVE_LOW // The LED on my board (D8) is active LOW
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 10
|
||||
|
||||
#elif defined(CONFIG_IDF_TARGET_ESP32C3) || defined(ARDUINO_ESP32C3_DEV)
|
||||
#define NO_LED_FEEDBACK_CODE // The WS2812 on pin 8 of AI-C3 board crashes if used as receive feedback LED, other I/O pins are working...
|
||||
#define IR_RECEIVE_PIN 6
|
||||
#define IR_SEND_PIN 7
|
||||
#define TONE_PIN 10
|
||||
#define APPLICATION_PIN 18
|
||||
|
||||
#elif defined(ESP32)
|
||||
#include <Arduino.h>
|
||||
|
||||
// tone() is included in ESP32 core since 2.0.2
|
||||
#if !defined(ESP_ARDUINO_VERSION_VAL)
|
||||
#define ESP_ARDUINO_VERSION_VAL(major, minor, patch) 12345678
|
||||
#endif
|
||||
#if ESP_ARDUINO_VERSION <= ESP_ARDUINO_VERSION_VAL(2, 0, 2)
|
||||
#define TONE_LEDC_CHANNEL 1 // Using channel 1 makes tone() independent of receiving timer -> No need to stop receiving timer.
|
||||
void tone(uint8_t aPinNumber, unsigned int aFrequency){
|
||||
ledcAttachPin(aPinNumber, TONE_LEDC_CHANNEL);
|
||||
ledcWriteTone(TONE_LEDC_CHANNEL, aFrequency);
|
||||
}
|
||||
void tone(uint8_t aPinNumber, unsigned int aFrequency, unsigned long aDuration){
|
||||
ledcAttachPin(aPinNumber, TONE_LEDC_CHANNEL);
|
||||
ledcWriteTone(TONE_LEDC_CHANNEL, aFrequency);
|
||||
delay(aDuration);
|
||||
ledcWriteTone(TONE_LEDC_CHANNEL, 0);
|
||||
}
|
||||
void noTone(uint8_t aPinNumber){
|
||||
ledcWriteTone(TONE_LEDC_CHANNEL, 0);
|
||||
}
|
||||
#endif // ESP_ARDUINO_VERSION <= ESP_ARDUINO_VERSION_VAL(2, 0, 2)
|
||||
|
||||
#define IR_RECEIVE_PIN 15 // D15
|
||||
#define IR_SEND_PIN 4 // D4
|
||||
#define TONE_PIN 27 // D27 25 & 26 are DAC0 and 1
|
||||
#define APPLICATION_PIN 16 // RX2 pin
|
||||
|
||||
#elif defined(ARDUINO_ARCH_STM32) || defined(ARDUINO_ARCH_STM32F1) // BluePill
|
||||
// Timer 3 blocks PA6, PA7, PB0, PB1 for use by Servo or tone()
|
||||
#define IR_RECEIVE_PIN PA6
|
||||
#define IR_RECEIVE_PIN_STRING "PA6"
|
||||
#define IR_SEND_PIN PA7
|
||||
#define IR_SEND_PIN_STRING "PA7"
|
||||
#define TONE_PIN PA3
|
||||
#define _IR_TIMING_TEST_PIN PA5
|
||||
#define APPLICATION_PIN PA2
|
||||
#define APPLICATION_PIN_STRING "PA2"
|
||||
# if defined(ARDUINO_GENERIC_STM32F103C) || defined(ARDUINO_BLUEPILL_F103C8)
|
||||
// BluePill LED is active low
|
||||
#define FEEDBACK_LED_IS_ACTIVE_LOW
|
||||
# endif
|
||||
|
||||
#elif defined(ARDUINO_ARCH_APOLLO3) // Sparkfun Apollo boards
|
||||
#define IR_RECEIVE_PIN 11
|
||||
#define IR_SEND_PIN 12
|
||||
#define TONE_PIN 5
|
||||
|
||||
#elif defined(ARDUINO_ARCH_MBED) && defined(ARDUINO_ARCH_MBED_NANO) // Arduino Nano 33 BLE and Arduino Nano Connect layout for MBED
|
||||
// Must be before ARDUINO_ARCH_RP2040, since it is the layout for the MBED core of Arduino Nano Connect
|
||||
#define IR_RECEIVE_PIN 3 // GPIO15 Start with pin 3 since pin 2|GPIO25 is connected to LED on Pi pico
|
||||
#define IR_SEND_PIN 4 // GPIO16
|
||||
#define TONE_PIN 5
|
||||
#define APPLICATION_PIN 6
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 7 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 8
|
||||
|
||||
#elif defined(ARDUINO_ARCH_RP2040) // Arduino Nano Connect, Pi Pico with arduino-pico core https://github.com/earlephilhower/arduino-pico
|
||||
#define IR_RECEIVE_PIN 15 // GPIO15 to be compatible with the Arduino Nano RP2040 Connect (pin3)
|
||||
#define IR_SEND_PIN 16 // GPIO16
|
||||
#define TONE_PIN 17
|
||||
#define APPLICATION_PIN 18
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 19 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 20
|
||||
|
||||
// If you program the Nano RP2040 Connect with this core, then you must redefine LED_BUILTIN
|
||||
// and use the external reset with 1 kOhm to ground to enter UF2 mode
|
||||
#undef LED_BUILTIN
|
||||
#define LED_BUILTIN 6
|
||||
|
||||
#elif defined(PARTICLE) // !!!UNTESTED!!!
|
||||
#define IR_RECEIVE_PIN A4
|
||||
#define IR_SEND_PIN A5 // Particle supports multiple pins
|
||||
|
||||
#define LED_BUILTIN D7
|
||||
|
||||
/*
|
||||
* 4 times the same (default) layout for easy adaption in the future
|
||||
*/
|
||||
#elif defined(TEENSYDUINO) // Teensy 2.0 is handled at default for ATmega328 like on Uno, Nano, Leonardo etc.
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
#elif defined(ARDUINO_ARCH_MBED) // Arduino Nano 33 BLE
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
#elif defined(ARDUINO_ARCH_SAMD) || defined(ARDUINO_ARCH_SAM)
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
#if !defined(ARDUINO_SAMD_ADAFRUIT) && !defined(ARDUINO_SEEED_XIAO_M0)
|
||||
// On the Zero and others we switch explicitly to SerialUSB
|
||||
#define Serial SerialUSB
|
||||
#endif
|
||||
|
||||
// Definitions for the Chinese SAMD21 M0-Mini clone, which has no led connected to D13/PA17.
|
||||
// Attention!!! D2 and D4 are swapped on these boards!!!
|
||||
// If you connect the LED, it is on pin 24/PB11. In this case activate the next two lines.
|
||||
//#undef LED_BUILTIN
|
||||
//#define LED_BUILTIN 24 // PB11
|
||||
// As an alternative you can choose pin 25, it is the RX-LED pin (PB03), but active low.In this case activate the next 3 lines.
|
||||
//#undef LED_BUILTIN
|
||||
//#define LED_BUILTIN 25 // PB03
|
||||
//#define FEEDBACK_LED_IS_ACTIVE_LOW // The RX LED on the M0-Mini is active LOW
|
||||
|
||||
#elif defined (NRF51) // BBC micro:bit
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define APPLICATION_PIN 1
|
||||
#define _IR_TIMING_TEST_PIN 4
|
||||
|
||||
#define tone(...) void() // no tone() available
|
||||
#define noTone(a) void()
|
||||
#define TONE_PIN 42 // Dummy for examples using it
|
||||
|
||||
#else
|
||||
#warning Board / CPU is not detected using pre-processor symbols -> using default values, which may not fit. Please extend PinDefinitionsAndMore.h.
|
||||
// Default valued for unidentified boards
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
#endif // defined(ESP8266)
|
||||
|
||||
#if defined(ESP32) || defined(ARDUINO_ARCH_RP2040) || defined(PARTICLE) || defined(ARDUINO_ARCH_MBED)
|
||||
#define SEND_PWM_BY_TIMER // We do not have pin restrictions for this CPU's, so lets use the hardware PWM for send carrier signal generation
|
||||
#else
|
||||
# if defined(SEND_PWM_BY_TIMER)
|
||||
#undef IR_SEND_PIN // SendPin is determined by timer! This avoids warnings in IRremote.hpp and IRTimer.hpp
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if !defined (FLASHEND)
|
||||
#define FLASHEND 0xFFFF // Dummy value for platforms where FLASHEND is not defined
|
||||
#endif
|
||||
|
||||
/*
|
||||
* 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
|
||||
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* SendProntoDemo.cpp
|
||||
*
|
||||
* Example for sending pronto codes with the IRremote library.
|
||||
* The code used here, sends NEC protocol data.
|
||||
*
|
||||
* This file is part of Arduino-IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
|
||||
*
|
||||
************************************************************************************
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2020-2022 Armin Joachimsmeyer
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is furnished
|
||||
* to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
************************************************************************************
|
||||
*/
|
||||
#include <Arduino.h>
|
||||
|
||||
#define IR_SEND_PIN 3 // P0_0
|
||||
|
||||
/*
|
||||
* 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 <IRremote.hpp>
|
||||
|
||||
#define NUMBER_OF_REPEATS 3U
|
||||
|
||||
// The first number, here 0000, denotes the type of the signal. 0000 denotes a raw IR signal with modulation.
|
||||
// The second number, here 006C, denotes a frequency code. 006C corresponds to 1000000/(0x006c * 0.241246) = 38381 Hertz.
|
||||
// The third and the forth number denote the number of pairs (= half the number of durations) in the start- and the repeat sequence respectively.
|
||||
const char yamahaVolDown[]
|
||||
= "0000 006C 0022 0002 015B 00AD " /* Pronto header + start bit */
|
||||
"0016 0016 0016 0041 0016 0016 0016 0041 0016 0041 0016 0041 0016 0041 0016 0016 " /* Lower address byte */
|
||||
"0016 0041 0016 0016 0016 0041 0016 0016 0016 0016 0016 0016 0016 0016 0016 0041 " /* Upper address byte (inverted at 8 bit mode) */
|
||||
"0016 0041 0016 0041 0016 0016 0016 0041 0016 0041 0016 0016 0016 0016 0016 0016 " /* command byte */
|
||||
"0016 0016 0016 0016 0016 0041 0016 0016 0016 0016 0016 0041 0016 0041 0016 0041 0016 05F7 " /* inverted command byte + stop bit */
|
||||
"015B 0057 0016 0E6C"; /* NEC repeat pattern*/
|
||||
|
||||
IRsend irsend;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
while (!Serial)
|
||||
; // Wait for Serial to become available. Is optimized away for some cores.
|
||||
|
||||
// Just to know which program is running on my Arduino
|
||||
Serial.println(F("START " __FILE__ " from " __DATE__ "\r\nUsing library version " VERSION_IRREMOTE));
|
||||
Serial.println(F("Send IR signals at pin " STR(IR_SEND_PIN)));
|
||||
|
||||
IrSender.begin(); // Start with IR_SEND_PIN as send pin and enable feedback LED at default feedback LED pin
|
||||
}
|
||||
|
||||
void loop() {
|
||||
Serial.println(F("Sending from normal memory"));
|
||||
irsend.sendPronto(yamahaVolDown, NUMBER_OF_REPEATS);
|
||||
|
||||
delay(2000);
|
||||
Serial.println(F("Sending the NEC using the F()-form: address 0x5, data 0x1A"));
|
||||
irsend.sendPronto(F("0000 006C 0022 0002 015B 00AD " /* Pronto header + start bit */
|
||||
"0016 0016 0016 0041 0016 0016 0016 0041 0016 0041 0016 0041 0016 0041 0016 0041 " /* Lower address byte */
|
||||
"0016 0041 0016 0016 0016 0041 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 " /* Upper address byte (inverted at 8 bit mode) */
|
||||
"0016 0016 0016 0041 0016 0016 0016 0041 0016 0041 0016 0016 0016 0016 0016 0016 " /* command byte */
|
||||
"0016 0041 0016 0016 0016 0041 0016 0016 0016 0016 0016 0041 0016 0041 0016 0041 0016 05F7 " /* inverted command byte + stop bit */
|
||||
"015B 0057 0016 0E6C"), /* NEC repeat pattern*/
|
||||
NUMBER_OF_REPEATS);
|
||||
delay(2000);
|
||||
|
||||
// send Nec code acquired by IRreceiveDump.cpp
|
||||
Serial.println(F("Sending NEC from RAM: address 0xFF00, data 0x15"));
|
||||
// 006D -> 38029 Hz
|
||||
irsend.sendPronto("0000 006D 0022 0000 015C 00AB " /* Pronto header + start bit */
|
||||
"0017 0015 0017 0015 0017 0015 0017 0015 0017 0015 0017 0015 0017 0015 0017 0015 " /* Lower address byte */
|
||||
"0017 003F 0017 003E 0017 003F 0017 003E 0017 003F 0015 003F 0017 003F 0015 003F " /* Upper address byte (inverted at 8 bit mode) */
|
||||
"0017 003E 0017 0015 0017 003F 0017 0015 0017 003E 0017 0015 0017 0017 0015 0017 " /* command byte */
|
||||
"0017 0015 0017 003E 0017 0015 0017 003F 0015 0017 0017 003E 0017 003F 0015 003F 0017 0806" /* inverted command byte + stop bit */
|
||||
, 0); // No repeat possible, because of missing repeat pattern
|
||||
|
||||
delay(5000);
|
||||
}
|
||||
@@ -0,0 +1,349 @@
|
||||
/*
|
||||
* PinDefinitionsAndMore.h
|
||||
*
|
||||
* Contains pin definitions for IRremote examples for various platforms
|
||||
* as well as definitions for feedback LED and tone() and includes
|
||||
*
|
||||
* Copyright (C) 2021-2023 Armin Joachimsmeyer
|
||||
* armin.joachimsmeyer@gmail.com
|
||||
*
|
||||
* This file is part of IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
|
||||
*
|
||||
* Arduino-IRremote is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/gpl.html>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Pin mapping table for different platforms
|
||||
*
|
||||
* Platform IR input IR output Tone Core/Pin schema
|
||||
* --------------------------------------------------------------
|
||||
* DEFAULT/AVR 2 3 4 Arduino
|
||||
* ATtinyX5 0|PB0 4|PB4 3|PB3 ATTinyCore
|
||||
* ATtiny167 3|PA3 2|PA2 7|PA7 ATTinyCore
|
||||
* ATtiny167 9|PA3 8|PA2 5|PA7 Digispark original core
|
||||
* ATtiny84 |PB2 |PA4 |PA3 ATTinyCore
|
||||
* ATtiny88 3|PD3 4|PD4 9|PB1 ATTinyCore
|
||||
* ATtiny3217 18|PA1 19|PA2 20|PA3 MegaTinyCore
|
||||
* ATtiny1604 2 3|PA5 %
|
||||
* ATtiny816 14|PA1 16|PA3 1|PA5 MegaTinyCore
|
||||
* ATtiny1614 8|PA1 10|PA3 1|PA5 MegaTinyCore
|
||||
* SAMD21 3 4 5
|
||||
* ESP8266 14|D5 12|D6 %
|
||||
* ESP32 15 4 27
|
||||
* ESP32-C3 2 3 4
|
||||
* BluePill PA6 PA7 PA3
|
||||
* APOLLO3 11 12 5
|
||||
* RP2040 3|GPIO15 4|GPIO16 5|GPIO17
|
||||
*/
|
||||
//#define _IR_MEASURE_TIMING // For debugging purposes.
|
||||
|
||||
#if defined(__AVR__)
|
||||
#if defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__) // Digispark board. For use with ATTinyCore.
|
||||
#include "ATtinySerialOut.hpp" // TX is at pin 2 - Available as Arduino library "ATtinySerialOut". Saves 700 bytes program memory and 70 bytes RAM for ATtinyCore.
|
||||
#define IR_RECEIVE_PIN PIN_PB0
|
||||
#define IR_SEND_PIN PIN_PB4 // Pin 2 is serial output with ATtinySerialOut. Pin 1 is internal LED and Pin3 is USB+ with pullup on Digispark board.
|
||||
#define TONE_PIN PIN_PB3
|
||||
#define _IR_TIMING_TEST_PIN PIN_PB3
|
||||
|
||||
# elif defined(__AVR_ATtiny87__) || defined(__AVR_ATtiny167__) // Digispark pro board
|
||||
#include "ATtinySerialOut.hpp" // Available as Arduino library "ATtinySerialOut"
|
||||
// For ATtiny167 Pins PB6 and PA3 are usable as interrupt source.
|
||||
# if defined(ARDUINO_AVR_DIGISPARKPRO)
|
||||
// For use with Digispark original core
|
||||
#define IR_RECEIVE_PIN 9 // PA3 - on Digispark board labeled as pin 9
|
||||
//#define IR_RECEIVE_PIN 14 // PB6 / INT0 is connected to USB+ on DigisparkPro boards
|
||||
#define IR_SEND_PIN 8 // PA2 - on Digispark board labeled as pin 8
|
||||
#define TONE_PIN 5 // PA7 - on Digispark board labeled as pin 5
|
||||
#define _IR_TIMING_TEST_PIN 10 // PA4
|
||||
# else
|
||||
// For use with ATTinyCore
|
||||
#define IR_RECEIVE_PIN PIN_PA3 // On Digispark board labeled as pin 9 - INT0 is connected to USB+ on DigisparkPro boards
|
||||
#define IR_SEND_PIN PIN_PA2 // On Digispark board labeled as pin 8
|
||||
#define TONE_PIN PIN_PA7 // On Digispark board labeled as pin 5
|
||||
# endif
|
||||
|
||||
# elif defined(__AVR_ATtiny84__) // For use with ATTinyCore
|
||||
#include "ATtinySerialOut.hpp" // Available as Arduino library "ATtinySerialOut". Saves 128 bytes program memory.
|
||||
#define IR_RECEIVE_PIN PIN_PB2 // INT0
|
||||
#define IR_SEND_PIN PIN_PA4
|
||||
#define TONE_PIN PIN_PA3
|
||||
#define _IR_TIMING_TEST_PIN PIN_PA5
|
||||
|
||||
# elif defined(__AVR_ATtiny88__) // MH-ET Tiny88 board. For use with ATTinyCore.
|
||||
#include "ATtinySerialOut.hpp" // Available as Arduino library "ATtinySerialOut". Saves 128 bytes program memory.
|
||||
// Pin 6 is TX, pin 7 is RX
|
||||
#define IR_RECEIVE_PIN PIN_PD3 // 3 - INT1
|
||||
#define IR_SEND_PIN PIN_PD4 // 4
|
||||
#define TONE_PIN PIN_PB1 // 9
|
||||
#define _IR_TIMING_TEST_PIN PIN_PB0 // 8
|
||||
|
||||
# elif defined(__AVR_ATtiny1616__) || defined(__AVR_ATtiny3216__) || defined(__AVR_ATtiny3217__) // For use with megaTinyCore
|
||||
// Tiny Core Dev board
|
||||
// https://www.tindie.com/products/xkimi/tiny-core-16-dev-board-attiny1616/ - Out of Stock
|
||||
// https://www.tindie.com/products/xkimi/tiny-core-32-dev-board-attiny3217/ - Out of Stock
|
||||
#define IR_RECEIVE_PIN PIN_PA1 // use 18 instead of PIN_PA1 for TinyCore32
|
||||
#define IR_SEND_PIN PIN_PA2 // 19
|
||||
#define TONE_PIN PIN_PA3 // 20
|
||||
#define APPLICATION_PIN PIN_PA0 // 0
|
||||
#undef LED_BUILTIN // No LED available on the TinyCore 32 board, take the one on the programming board which is connected to the DAC output
|
||||
#define LED_BUILTIN PIN_PA6 // use 2 instead of PIN_PA6 for TinyCore32
|
||||
|
||||
# elif defined(__AVR_ATtiny816__) // For use with megaTinyCore
|
||||
#define IR_RECEIVE_PIN PIN_PA1 // 14
|
||||
#define IR_SEND_PIN PIN_PA1 // 16
|
||||
#define TONE_PIN PIN_PA5 // 1
|
||||
#define APPLICATION_PIN PIN_PA4 // 0
|
||||
#undef LED_BUILTIN // No LED available, take the one which is connected to the DAC output
|
||||
#define LED_BUILTIN PIN_PB5 // 4
|
||||
|
||||
# elif defined(__AVR_ATtiny1614__) // For use with megaTinyCore
|
||||
#define IR_RECEIVE_PIN PIN_PA1 // 8
|
||||
#define IR_SEND_PIN PIN_PA3 // 10
|
||||
#define TONE_PIN PIN_PA5 // 1
|
||||
#define APPLICATION_PIN PIN_PA4 // 0
|
||||
|
||||
# elif defined(__AVR_ATtiny1604__) // For use with megaTinyCore
|
||||
#define IR_RECEIVE_PIN PIN_PA6 // 2 - To be compatible with interrupt example, pin 2 is chosen here.
|
||||
#define IR_SEND_PIN PIN_PA7 // 3
|
||||
#define APPLICATION_PIN PIN_PB2 // 5
|
||||
|
||||
#define tone(...) void() // Define as void, since TCB0_INT_vect is also used by tone()
|
||||
#define noTone(a) void()
|
||||
#define TONE_PIN 42 // Dummy for examples using it
|
||||
|
||||
# elif defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) \
|
||||
|| defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) \
|
||||
|| defined(__AVR_ATmega324P__) || defined(__AVR_ATmega324A__) \
|
||||
|| defined(__AVR_ATmega324PA__) || defined(__AVR_ATmega164A__) \
|
||||
|| defined(__AVR_ATmega164P__) || defined(__AVR_ATmega32__) \
|
||||
|| defined(__AVR_ATmega16__) || defined(__AVR_ATmega8535__) \
|
||||
|| defined(__AVR_ATmega64__) || defined(__AVR_ATmega128__) \
|
||||
|| defined(__AVR_ATmega1281__) || defined(__AVR_ATmega2561__) \
|
||||
|| defined(__AVR_ATmega8515__) || defined(__AVR_ATmega162__)
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 13
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
# else // Default as for ATmega328 like on Uno, Nano, Leonardo, Teensy 2.0 etc.
|
||||
#define IR_RECEIVE_PIN 2 // To be compatible with interrupt example, pin 2 is chosen here.
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
# if defined(ARDUINO_AVR_PROMICRO) // Sparkfun Pro Micro is __AVR_ATmega32U4__ but has different external circuit
|
||||
// We have no built in LED at pin 13 -> reuse RX LED
|
||||
#undef LED_BUILTIN
|
||||
#define LED_BUILTIN LED_BUILTIN_RX
|
||||
# endif
|
||||
# endif // defined(__AVR_ATtiny25__)...
|
||||
|
||||
#elif defined(ARDUINO_ARCH_RENESAS_UNO) // Uno R4
|
||||
// To be compatible with Uno R3.
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
#elif defined(ESP8266)
|
||||
#define FEEDBACK_LED_IS_ACTIVE_LOW // The LED on my board (D4) is active LOW
|
||||
#define IR_RECEIVE_PIN 14 // D5
|
||||
#define IR_SEND_PIN 12 // D6 - D4/pin 2 is internal LED
|
||||
#define _IR_TIMING_TEST_PIN 2 // D4
|
||||
#define APPLICATION_PIN 13 // D7
|
||||
|
||||
#define tone(...) void() // tone() inhibits receive timer
|
||||
#define noTone(a) void()
|
||||
#define TONE_PIN 42 // Dummy for examples using it#
|
||||
|
||||
#elif defined(ARDUINO_NOLOGO_ESP32C3_SUPER_MINI)
|
||||
#define FEEDBACK_LED_IS_ACTIVE_LOW // The LED on my board (D8) is active LOW
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 10
|
||||
|
||||
#elif defined(CONFIG_IDF_TARGET_ESP32C3) || defined(ARDUINO_ESP32C3_DEV)
|
||||
#define NO_LED_FEEDBACK_CODE // The WS2812 on pin 8 of AI-C3 board crashes if used as receive feedback LED, other I/O pins are working...
|
||||
#define IR_RECEIVE_PIN 6
|
||||
#define IR_SEND_PIN 7
|
||||
#define TONE_PIN 10
|
||||
#define APPLICATION_PIN 18
|
||||
|
||||
#elif defined(ESP32)
|
||||
#include <Arduino.h>
|
||||
|
||||
// tone() is included in ESP32 core since 2.0.2
|
||||
#if !defined(ESP_ARDUINO_VERSION_VAL)
|
||||
#define ESP_ARDUINO_VERSION_VAL(major, minor, patch) 12345678
|
||||
#endif
|
||||
#if ESP_ARDUINO_VERSION <= ESP_ARDUINO_VERSION_VAL(2, 0, 2)
|
||||
#define TONE_LEDC_CHANNEL 1 // Using channel 1 makes tone() independent of receiving timer -> No need to stop receiving timer.
|
||||
void tone(uint8_t aPinNumber, unsigned int aFrequency){
|
||||
ledcAttachPin(aPinNumber, TONE_LEDC_CHANNEL);
|
||||
ledcWriteTone(TONE_LEDC_CHANNEL, aFrequency);
|
||||
}
|
||||
void tone(uint8_t aPinNumber, unsigned int aFrequency, unsigned long aDuration){
|
||||
ledcAttachPin(aPinNumber, TONE_LEDC_CHANNEL);
|
||||
ledcWriteTone(TONE_LEDC_CHANNEL, aFrequency);
|
||||
delay(aDuration);
|
||||
ledcWriteTone(TONE_LEDC_CHANNEL, 0);
|
||||
}
|
||||
void noTone(uint8_t aPinNumber){
|
||||
ledcWriteTone(TONE_LEDC_CHANNEL, 0);
|
||||
}
|
||||
#endif // ESP_ARDUINO_VERSION <= ESP_ARDUINO_VERSION_VAL(2, 0, 2)
|
||||
|
||||
#define IR_RECEIVE_PIN 15 // D15
|
||||
#define IR_SEND_PIN 4 // D4
|
||||
#define TONE_PIN 27 // D27 25 & 26 are DAC0 and 1
|
||||
#define APPLICATION_PIN 16 // RX2 pin
|
||||
|
||||
#elif defined(ARDUINO_ARCH_STM32) || defined(ARDUINO_ARCH_STM32F1) // BluePill
|
||||
// Timer 3 blocks PA6, PA7, PB0, PB1 for use by Servo or tone()
|
||||
#define IR_RECEIVE_PIN PA6
|
||||
#define IR_RECEIVE_PIN_STRING "PA6"
|
||||
#define IR_SEND_PIN PA7
|
||||
#define IR_SEND_PIN_STRING "PA7"
|
||||
#define TONE_PIN PA3
|
||||
#define _IR_TIMING_TEST_PIN PA5
|
||||
#define APPLICATION_PIN PA2
|
||||
#define APPLICATION_PIN_STRING "PA2"
|
||||
# if defined(ARDUINO_GENERIC_STM32F103C) || defined(ARDUINO_BLUEPILL_F103C8)
|
||||
// BluePill LED is active low
|
||||
#define FEEDBACK_LED_IS_ACTIVE_LOW
|
||||
# endif
|
||||
|
||||
#elif defined(ARDUINO_ARCH_APOLLO3) // Sparkfun Apollo boards
|
||||
#define IR_RECEIVE_PIN 11
|
||||
#define IR_SEND_PIN 12
|
||||
#define TONE_PIN 5
|
||||
|
||||
#elif defined(ARDUINO_ARCH_MBED) && defined(ARDUINO_ARCH_MBED_NANO) // Arduino Nano 33 BLE and Arduino Nano Connect layout for MBED
|
||||
// Must be before ARDUINO_ARCH_RP2040, since it is the layout for the MBED core of Arduino Nano Connect
|
||||
#define IR_RECEIVE_PIN 3 // GPIO15 Start with pin 3 since pin 2|GPIO25 is connected to LED on Pi pico
|
||||
#define IR_SEND_PIN 4 // GPIO16
|
||||
#define TONE_PIN 5
|
||||
#define APPLICATION_PIN 6
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 7 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 8
|
||||
|
||||
#elif defined(ARDUINO_ARCH_RP2040) // Arduino Nano Connect, Pi Pico with arduino-pico core https://github.com/earlephilhower/arduino-pico
|
||||
#define IR_RECEIVE_PIN 15 // GPIO15 to be compatible with the Arduino Nano RP2040 Connect (pin3)
|
||||
#define IR_SEND_PIN 16 // GPIO16
|
||||
#define TONE_PIN 17
|
||||
#define APPLICATION_PIN 18
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 19 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 20
|
||||
|
||||
// If you program the Nano RP2040 Connect with this core, then you must redefine LED_BUILTIN
|
||||
// and use the external reset with 1 kOhm to ground to enter UF2 mode
|
||||
#undef LED_BUILTIN
|
||||
#define LED_BUILTIN 6
|
||||
|
||||
#elif defined(PARTICLE) // !!!UNTESTED!!!
|
||||
#define IR_RECEIVE_PIN A4
|
||||
#define IR_SEND_PIN A5 // Particle supports multiple pins
|
||||
|
||||
#define LED_BUILTIN D7
|
||||
|
||||
/*
|
||||
* 4 times the same (default) layout for easy adaption in the future
|
||||
*/
|
||||
#elif defined(TEENSYDUINO) // Teensy 2.0 is handled at default for ATmega328 like on Uno, Nano, Leonardo etc.
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
#elif defined(ARDUINO_ARCH_MBED) // Arduino Nano 33 BLE
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
#elif defined(ARDUINO_ARCH_SAMD) || defined(ARDUINO_ARCH_SAM)
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
#if !defined(ARDUINO_SAMD_ADAFRUIT) && !defined(ARDUINO_SEEED_XIAO_M0)
|
||||
// On the Zero and others we switch explicitly to SerialUSB
|
||||
#define Serial SerialUSB
|
||||
#endif
|
||||
|
||||
// Definitions for the Chinese SAMD21 M0-Mini clone, which has no led connected to D13/PA17.
|
||||
// Attention!!! D2 and D4 are swapped on these boards!!!
|
||||
// If you connect the LED, it is on pin 24/PB11. In this case activate the next two lines.
|
||||
//#undef LED_BUILTIN
|
||||
//#define LED_BUILTIN 24 // PB11
|
||||
// As an alternative you can choose pin 25, it is the RX-LED pin (PB03), but active low.In this case activate the next 3 lines.
|
||||
//#undef LED_BUILTIN
|
||||
//#define LED_BUILTIN 25 // PB03
|
||||
//#define FEEDBACK_LED_IS_ACTIVE_LOW // The RX LED on the M0-Mini is active LOW
|
||||
|
||||
#elif defined (NRF51) // BBC micro:bit
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define APPLICATION_PIN 1
|
||||
#define _IR_TIMING_TEST_PIN 4
|
||||
|
||||
#define tone(...) void() // no tone() available
|
||||
#define noTone(a) void()
|
||||
#define TONE_PIN 42 // Dummy for examples using it
|
||||
|
||||
#else
|
||||
#warning Board / CPU is not detected using pre-processor symbols -> using default values, which may not fit. Please extend PinDefinitionsAndMore.h.
|
||||
// Default valued for unidentified boards
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
#endif // defined(ESP8266)
|
||||
|
||||
#if defined(ESP32) || defined(ARDUINO_ARCH_RP2040) || defined(PARTICLE) || defined(ARDUINO_ARCH_MBED)
|
||||
#define SEND_PWM_BY_TIMER // We do not have pin restrictions for this CPU's, so lets use the hardware PWM for send carrier signal generation
|
||||
#else
|
||||
# if defined(SEND_PWM_BY_TIMER)
|
||||
#undef IR_SEND_PIN // SendPin is determined by timer! This avoids warnings in IRremote.hpp and IRTimer.hpp
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if !defined (FLASHEND)
|
||||
#define FLASHEND 0xFFFF // Dummy value for platforms where FLASHEND is not defined
|
||||
#endif
|
||||
|
||||
/*
|
||||
* 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
|
||||
@@ -0,0 +1,124 @@
|
||||
/*
|
||||
* SendRawDemo.cpp - demonstrates sending IR codes with sendRaw
|
||||
*
|
||||
* This example shows how to send a RAW signal using the IRremote library.
|
||||
* The example signal is actually a 32 bit NEC signal.
|
||||
* Protocol=NEC Address=0x4 Command=0x18 Raw-Data=0xE718FB04 32 bits LSB first
|
||||
*
|
||||
* If it is a supported protocol, it is more efficient to use the protocol send function
|
||||
* (here sendNEC) to send the signal.
|
||||
*
|
||||
* This file is part of Arduino-IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
|
||||
*
|
||||
************************************************************************************
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2020-2024 Armin Joachimsmeyer
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is furnished
|
||||
* to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
************************************************************************************
|
||||
*/
|
||||
#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 IR_SEND_PIN 3 // P0_0
|
||||
/*
|
||||
* 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 <IRremote.hpp>
|
||||
|
||||
void setup() {
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
|
||||
Serial.begin(9600);
|
||||
while (!Serial)
|
||||
; // Wait for Serial to become available. Is optimized away for some cores.
|
||||
|
||||
// Just to know which program is running on my Arduino
|
||||
Serial.println(F("START " __FILE__ " from " __DATE__ "\r\nUsing library version " VERSION_IRREMOTE));
|
||||
Serial.println(F("Send IR signals at pin " STR(IR_SEND_PIN)));
|
||||
|
||||
IrSender.begin(); // Start with IR_SEND_PIN as send pin and enable feedback LED at default feedback LED pin
|
||||
}
|
||||
|
||||
/*
|
||||
* NEC address=0x04 (0xFB04), command=0x18 (0xE718)
|
||||
*
|
||||
* This is the raw data array in byte format.
|
||||
* The uint8_t/byte elements contain the number of ticks in 50 us.
|
||||
* The uint16_t format contains the (number of ticks * 50) if generated by IRremote,
|
||||
* so the uint16_t format has exact the same resolution but requires double space.
|
||||
* With the uint16_t format, you are able to modify the timings to meet the standards,
|
||||
* e.g. use 560 (instead of 11 * 50) for NEC or use 432 for Panasonic. But in this cases,
|
||||
* you better use the timing generation functions e.g. sendNEC() directly.
|
||||
*/
|
||||
const uint8_t rawDataP[] =
|
||||
{ 180, 90 /*Start bit*/, 11, 11, 11, 11, 11, 34, 11, 11/*0010 0x4 of 8 bit address LSB first*/, 11, 11, 11, 11, 11, 11, 11,
|
||||
11/*0000*/, 11, 34, 11, 34, 11, 11, 11, 34/*1101 0xB*/, 11, 34, 11, 34, 11, 34, 11, 34/*1111*/, 11, 11, 11, 11, 11, 11, 11,
|
||||
34/*0001 0x08 of command LSB first*/, 11, 34, 11, 11, 11, 11, 11, 11/*1000 0x01*/, 11, 34, 11, 34, 11, 34, 11,
|
||||
11/*1110 Inverted 8 of command*/, 11, 11, 11, 34, 11, 34, 11, 34/*0111 inverted 1 of command*/, 11 /*stop bit*/};
|
||||
|
||||
/*
|
||||
* The same frame as above. Values are NOT multiple of 50, but are taken from the NEC timing definitions
|
||||
*/
|
||||
const uint16_t rawData[] = { 9000, 4500/*Start bit*/, 560, 560, 560, 560, 560, 1690, 560,
|
||||
560/*0010 0x4 of 8 bit address LSB first*/, 560, 560, 560, 560, 560, 560, 560, 560/*0000*/, 560, 1690, 560, 1690, 560, 560,
|
||||
560, 1690/*1101 0xB - inverted 0x04*/, 560, 1690, 560, 1690, 560, 1690, 560, 1690/*1111 - inverted 0*/, 560, 560, 560, 560,
|
||||
560, 560, 560, 1690/*0001 0x08 of command LSB first*/, 560, 1690, 560, 560, 560, 560, 560, 560/*1000 0x01*/, 560, 1690, 560,
|
||||
1690, 560, 1690, 560, 560/*1110 Inverted 8 of command*/, 560, 560, 560, 1690, 560, 1690, 560,
|
||||
1690/*1111 inverted 0 of command*/, 560 /*stop bit*/}; // Using exact NEC timing
|
||||
|
||||
void loop() {
|
||||
/*
|
||||
* Send hand crafted data from RAM
|
||||
*/
|
||||
Serial.println(F("Send NEC 8 bit address=0x04 (0xFB04) and command 0x18 (0xE718) with exact timing (16 bit array format)"));
|
||||
Serial.flush();
|
||||
IrSender.sendRaw(rawData, sizeof(rawData) / sizeof(rawData[0]), NEC_KHZ); // Note the approach used to automatically calculate the size of the array.
|
||||
|
||||
delay(1000); // delay must be greater than 8 ms (RECORD_GAP_MICROS), otherwise the receiver sees it as one long signal
|
||||
|
||||
/*
|
||||
* Send byte data direct from FLASH
|
||||
* Note the approach used to automatically calculate the size of the array.
|
||||
*/
|
||||
Serial.println(F("Send NEC 8 bit address 0x04 and command 0x18 with (50 us) tick resolution timing (8 bit array format) "));
|
||||
Serial.flush();
|
||||
IrSender.sendRaw_P(rawDataP, sizeof(rawDataP) / sizeof(rawDataP[0]), NEC_KHZ);
|
||||
|
||||
delay(1000); // delay must be greater than 8 ms (RECORD_GAP_MICROS), otherwise the receiver sees it as one long signal
|
||||
|
||||
/*
|
||||
* Send the same frame using NEC encoder
|
||||
*/
|
||||
Serial.println(F("Send NEC 16 bit address 0x04, 8 bit command 0x18 with NEC encoder"));
|
||||
Serial.flush();
|
||||
IrSender.sendNEC(0x04, 0x18, 0);
|
||||
|
||||
delay(3000);
|
||||
}
|
||||
@@ -0,0 +1,349 @@
|
||||
/*
|
||||
* PinDefinitionsAndMore.h
|
||||
*
|
||||
* Contains pin definitions for IRremote examples for various platforms
|
||||
* as well as definitions for feedback LED and tone() and includes
|
||||
*
|
||||
* Copyright (C) 2021-2023 Armin Joachimsmeyer
|
||||
* armin.joachimsmeyer@gmail.com
|
||||
*
|
||||
* This file is part of IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
|
||||
*
|
||||
* Arduino-IRremote is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/gpl.html>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Pin mapping table for different platforms
|
||||
*
|
||||
* Platform IR input IR output Tone Core/Pin schema
|
||||
* --------------------------------------------------------------
|
||||
* DEFAULT/AVR 2 3 4 Arduino
|
||||
* ATtinyX5 0|PB0 4|PB4 3|PB3 ATTinyCore
|
||||
* ATtiny167 3|PA3 2|PA2 7|PA7 ATTinyCore
|
||||
* ATtiny167 9|PA3 8|PA2 5|PA7 Digispark original core
|
||||
* ATtiny84 |PB2 |PA4 |PA3 ATTinyCore
|
||||
* ATtiny88 3|PD3 4|PD4 9|PB1 ATTinyCore
|
||||
* ATtiny3217 18|PA1 19|PA2 20|PA3 MegaTinyCore
|
||||
* ATtiny1604 2 3|PA5 %
|
||||
* ATtiny816 14|PA1 16|PA3 1|PA5 MegaTinyCore
|
||||
* ATtiny1614 8|PA1 10|PA3 1|PA5 MegaTinyCore
|
||||
* SAMD21 3 4 5
|
||||
* ESP8266 14|D5 12|D6 %
|
||||
* ESP32 15 4 27
|
||||
* ESP32-C3 2 3 4
|
||||
* BluePill PA6 PA7 PA3
|
||||
* APOLLO3 11 12 5
|
||||
* RP2040 3|GPIO15 4|GPIO16 5|GPIO17
|
||||
*/
|
||||
//#define _IR_MEASURE_TIMING // For debugging purposes.
|
||||
|
||||
#if defined(__AVR__)
|
||||
#if defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__) // Digispark board. For use with ATTinyCore.
|
||||
#include "ATtinySerialOut.hpp" // TX is at pin 2 - Available as Arduino library "ATtinySerialOut". Saves 700 bytes program memory and 70 bytes RAM for ATtinyCore.
|
||||
#define IR_RECEIVE_PIN PIN_PB0
|
||||
#define IR_SEND_PIN PIN_PB4 // Pin 2 is serial output with ATtinySerialOut. Pin 1 is internal LED and Pin3 is USB+ with pullup on Digispark board.
|
||||
#define TONE_PIN PIN_PB3
|
||||
#define _IR_TIMING_TEST_PIN PIN_PB3
|
||||
|
||||
# elif defined(__AVR_ATtiny87__) || defined(__AVR_ATtiny167__) // Digispark pro board
|
||||
#include "ATtinySerialOut.hpp" // Available as Arduino library "ATtinySerialOut"
|
||||
// For ATtiny167 Pins PB6 and PA3 are usable as interrupt source.
|
||||
# if defined(ARDUINO_AVR_DIGISPARKPRO)
|
||||
// For use with Digispark original core
|
||||
#define IR_RECEIVE_PIN 9 // PA3 - on Digispark board labeled as pin 9
|
||||
//#define IR_RECEIVE_PIN 14 // PB6 / INT0 is connected to USB+ on DigisparkPro boards
|
||||
#define IR_SEND_PIN 8 // PA2 - on Digispark board labeled as pin 8
|
||||
#define TONE_PIN 5 // PA7 - on Digispark board labeled as pin 5
|
||||
#define _IR_TIMING_TEST_PIN 10 // PA4
|
||||
# else
|
||||
// For use with ATTinyCore
|
||||
#define IR_RECEIVE_PIN PIN_PA3 // On Digispark board labeled as pin 9 - INT0 is connected to USB+ on DigisparkPro boards
|
||||
#define IR_SEND_PIN PIN_PA2 // On Digispark board labeled as pin 8
|
||||
#define TONE_PIN PIN_PA7 // On Digispark board labeled as pin 5
|
||||
# endif
|
||||
|
||||
# elif defined(__AVR_ATtiny84__) // For use with ATTinyCore
|
||||
#include "ATtinySerialOut.hpp" // Available as Arduino library "ATtinySerialOut". Saves 128 bytes program memory.
|
||||
#define IR_RECEIVE_PIN PIN_PB2 // INT0
|
||||
#define IR_SEND_PIN PIN_PA4
|
||||
#define TONE_PIN PIN_PA3
|
||||
#define _IR_TIMING_TEST_PIN PIN_PA5
|
||||
|
||||
# elif defined(__AVR_ATtiny88__) // MH-ET Tiny88 board. For use with ATTinyCore.
|
||||
#include "ATtinySerialOut.hpp" // Available as Arduino library "ATtinySerialOut". Saves 128 bytes program memory.
|
||||
// Pin 6 is TX, pin 7 is RX
|
||||
#define IR_RECEIVE_PIN PIN_PD3 // 3 - INT1
|
||||
#define IR_SEND_PIN PIN_PD4 // 4
|
||||
#define TONE_PIN PIN_PB1 // 9
|
||||
#define _IR_TIMING_TEST_PIN PIN_PB0 // 8
|
||||
|
||||
# elif defined(__AVR_ATtiny1616__) || defined(__AVR_ATtiny3216__) || defined(__AVR_ATtiny3217__) // For use with megaTinyCore
|
||||
// Tiny Core Dev board
|
||||
// https://www.tindie.com/products/xkimi/tiny-core-16-dev-board-attiny1616/ - Out of Stock
|
||||
// https://www.tindie.com/products/xkimi/tiny-core-32-dev-board-attiny3217/ - Out of Stock
|
||||
#define IR_RECEIVE_PIN PIN_PA1 // use 18 instead of PIN_PA1 for TinyCore32
|
||||
#define IR_SEND_PIN PIN_PA2 // 19
|
||||
#define TONE_PIN PIN_PA3 // 20
|
||||
#define APPLICATION_PIN PIN_PA0 // 0
|
||||
#undef LED_BUILTIN // No LED available on the TinyCore 32 board, take the one on the programming board which is connected to the DAC output
|
||||
#define LED_BUILTIN PIN_PA6 // use 2 instead of PIN_PA6 for TinyCore32
|
||||
|
||||
# elif defined(__AVR_ATtiny816__) // For use with megaTinyCore
|
||||
#define IR_RECEIVE_PIN PIN_PA1 // 14
|
||||
#define IR_SEND_PIN PIN_PA1 // 16
|
||||
#define TONE_PIN PIN_PA5 // 1
|
||||
#define APPLICATION_PIN PIN_PA4 // 0
|
||||
#undef LED_BUILTIN // No LED available, take the one which is connected to the DAC output
|
||||
#define LED_BUILTIN PIN_PB5 // 4
|
||||
|
||||
# elif defined(__AVR_ATtiny1614__) // For use with megaTinyCore
|
||||
#define IR_RECEIVE_PIN PIN_PA1 // 8
|
||||
#define IR_SEND_PIN PIN_PA3 // 10
|
||||
#define TONE_PIN PIN_PA5 // 1
|
||||
#define APPLICATION_PIN PIN_PA4 // 0
|
||||
|
||||
# elif defined(__AVR_ATtiny1604__) // For use with megaTinyCore
|
||||
#define IR_RECEIVE_PIN PIN_PA6 // 2 - To be compatible with interrupt example, pin 2 is chosen here.
|
||||
#define IR_SEND_PIN PIN_PA7 // 3
|
||||
#define APPLICATION_PIN PIN_PB2 // 5
|
||||
|
||||
#define tone(...) void() // Define as void, since TCB0_INT_vect is also used by tone()
|
||||
#define noTone(a) void()
|
||||
#define TONE_PIN 42 // Dummy for examples using it
|
||||
|
||||
# elif defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) \
|
||||
|| defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) \
|
||||
|| defined(__AVR_ATmega324P__) || defined(__AVR_ATmega324A__) \
|
||||
|| defined(__AVR_ATmega324PA__) || defined(__AVR_ATmega164A__) \
|
||||
|| defined(__AVR_ATmega164P__) || defined(__AVR_ATmega32__) \
|
||||
|| defined(__AVR_ATmega16__) || defined(__AVR_ATmega8535__) \
|
||||
|| defined(__AVR_ATmega64__) || defined(__AVR_ATmega128__) \
|
||||
|| defined(__AVR_ATmega1281__) || defined(__AVR_ATmega2561__) \
|
||||
|| defined(__AVR_ATmega8515__) || defined(__AVR_ATmega162__)
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 13
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
# else // Default as for ATmega328 like on Uno, Nano, Leonardo, Teensy 2.0 etc.
|
||||
#define IR_RECEIVE_PIN 2 // To be compatible with interrupt example, pin 2 is chosen here.
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
# if defined(ARDUINO_AVR_PROMICRO) // Sparkfun Pro Micro is __AVR_ATmega32U4__ but has different external circuit
|
||||
// We have no built in LED at pin 13 -> reuse RX LED
|
||||
#undef LED_BUILTIN
|
||||
#define LED_BUILTIN LED_BUILTIN_RX
|
||||
# endif
|
||||
# endif // defined(__AVR_ATtiny25__)...
|
||||
|
||||
#elif defined(ARDUINO_ARCH_RENESAS_UNO) // Uno R4
|
||||
// To be compatible with Uno R3.
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
#elif defined(ESP8266)
|
||||
#define FEEDBACK_LED_IS_ACTIVE_LOW // The LED on my board (D4) is active LOW
|
||||
#define IR_RECEIVE_PIN 14 // D5
|
||||
#define IR_SEND_PIN 12 // D6 - D4/pin 2 is internal LED
|
||||
#define _IR_TIMING_TEST_PIN 2 // D4
|
||||
#define APPLICATION_PIN 13 // D7
|
||||
|
||||
#define tone(...) void() // tone() inhibits receive timer
|
||||
#define noTone(a) void()
|
||||
#define TONE_PIN 42 // Dummy for examples using it#
|
||||
|
||||
#elif defined(ARDUINO_NOLOGO_ESP32C3_SUPER_MINI)
|
||||
#define FEEDBACK_LED_IS_ACTIVE_LOW // The LED on my board (D8) is active LOW
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 10
|
||||
|
||||
#elif defined(CONFIG_IDF_TARGET_ESP32C3) || defined(ARDUINO_ESP32C3_DEV)
|
||||
#define NO_LED_FEEDBACK_CODE // The WS2812 on pin 8 of AI-C3 board crashes if used as receive feedback LED, other I/O pins are working...
|
||||
#define IR_RECEIVE_PIN 6
|
||||
#define IR_SEND_PIN 7
|
||||
#define TONE_PIN 10
|
||||
#define APPLICATION_PIN 18
|
||||
|
||||
#elif defined(ESP32)
|
||||
#include <Arduino.h>
|
||||
|
||||
// tone() is included in ESP32 core since 2.0.2
|
||||
#if !defined(ESP_ARDUINO_VERSION_VAL)
|
||||
#define ESP_ARDUINO_VERSION_VAL(major, minor, patch) 12345678
|
||||
#endif
|
||||
#if ESP_ARDUINO_VERSION <= ESP_ARDUINO_VERSION_VAL(2, 0, 2)
|
||||
#define TONE_LEDC_CHANNEL 1 // Using channel 1 makes tone() independent of receiving timer -> No need to stop receiving timer.
|
||||
void tone(uint8_t aPinNumber, unsigned int aFrequency){
|
||||
ledcAttachPin(aPinNumber, TONE_LEDC_CHANNEL);
|
||||
ledcWriteTone(TONE_LEDC_CHANNEL, aFrequency);
|
||||
}
|
||||
void tone(uint8_t aPinNumber, unsigned int aFrequency, unsigned long aDuration){
|
||||
ledcAttachPin(aPinNumber, TONE_LEDC_CHANNEL);
|
||||
ledcWriteTone(TONE_LEDC_CHANNEL, aFrequency);
|
||||
delay(aDuration);
|
||||
ledcWriteTone(TONE_LEDC_CHANNEL, 0);
|
||||
}
|
||||
void noTone(uint8_t aPinNumber){
|
||||
ledcWriteTone(TONE_LEDC_CHANNEL, 0);
|
||||
}
|
||||
#endif // ESP_ARDUINO_VERSION <= ESP_ARDUINO_VERSION_VAL(2, 0, 2)
|
||||
|
||||
#define IR_RECEIVE_PIN 15 // D15
|
||||
#define IR_SEND_PIN 4 // D4
|
||||
#define TONE_PIN 27 // D27 25 & 26 are DAC0 and 1
|
||||
#define APPLICATION_PIN 16 // RX2 pin
|
||||
|
||||
#elif defined(ARDUINO_ARCH_STM32) || defined(ARDUINO_ARCH_STM32F1) // BluePill
|
||||
// Timer 3 blocks PA6, PA7, PB0, PB1 for use by Servo or tone()
|
||||
#define IR_RECEIVE_PIN PA6
|
||||
#define IR_RECEIVE_PIN_STRING "PA6"
|
||||
#define IR_SEND_PIN PA7
|
||||
#define IR_SEND_PIN_STRING "PA7"
|
||||
#define TONE_PIN PA3
|
||||
#define _IR_TIMING_TEST_PIN PA5
|
||||
#define APPLICATION_PIN PA2
|
||||
#define APPLICATION_PIN_STRING "PA2"
|
||||
# if defined(ARDUINO_GENERIC_STM32F103C) || defined(ARDUINO_BLUEPILL_F103C8)
|
||||
// BluePill LED is active low
|
||||
#define FEEDBACK_LED_IS_ACTIVE_LOW
|
||||
# endif
|
||||
|
||||
#elif defined(ARDUINO_ARCH_APOLLO3) // Sparkfun Apollo boards
|
||||
#define IR_RECEIVE_PIN 11
|
||||
#define IR_SEND_PIN 12
|
||||
#define TONE_PIN 5
|
||||
|
||||
#elif defined(ARDUINO_ARCH_MBED) && defined(ARDUINO_ARCH_MBED_NANO) // Arduino Nano 33 BLE and Arduino Nano Connect layout for MBED
|
||||
// Must be before ARDUINO_ARCH_RP2040, since it is the layout for the MBED core of Arduino Nano Connect
|
||||
#define IR_RECEIVE_PIN 3 // GPIO15 Start with pin 3 since pin 2|GPIO25 is connected to LED on Pi pico
|
||||
#define IR_SEND_PIN 4 // GPIO16
|
||||
#define TONE_PIN 5
|
||||
#define APPLICATION_PIN 6
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 7 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 8
|
||||
|
||||
#elif defined(ARDUINO_ARCH_RP2040) // Arduino Nano Connect, Pi Pico with arduino-pico core https://github.com/earlephilhower/arduino-pico
|
||||
#define IR_RECEIVE_PIN 15 // GPIO15 to be compatible with the Arduino Nano RP2040 Connect (pin3)
|
||||
#define IR_SEND_PIN 16 // GPIO16
|
||||
#define TONE_PIN 17
|
||||
#define APPLICATION_PIN 18
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 19 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 20
|
||||
|
||||
// If you program the Nano RP2040 Connect with this core, then you must redefine LED_BUILTIN
|
||||
// and use the external reset with 1 kOhm to ground to enter UF2 mode
|
||||
#undef LED_BUILTIN
|
||||
#define LED_BUILTIN 6
|
||||
|
||||
#elif defined(PARTICLE) // !!!UNTESTED!!!
|
||||
#define IR_RECEIVE_PIN A4
|
||||
#define IR_SEND_PIN A5 // Particle supports multiple pins
|
||||
|
||||
#define LED_BUILTIN D7
|
||||
|
||||
/*
|
||||
* 4 times the same (default) layout for easy adaption in the future
|
||||
*/
|
||||
#elif defined(TEENSYDUINO) // Teensy 2.0 is handled at default for ATmega328 like on Uno, Nano, Leonardo etc.
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
#elif defined(ARDUINO_ARCH_MBED) // Arduino Nano 33 BLE
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
#elif defined(ARDUINO_ARCH_SAMD) || defined(ARDUINO_ARCH_SAM)
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
#if !defined(ARDUINO_SAMD_ADAFRUIT) && !defined(ARDUINO_SEEED_XIAO_M0)
|
||||
// On the Zero and others we switch explicitly to SerialUSB
|
||||
#define Serial SerialUSB
|
||||
#endif
|
||||
|
||||
// Definitions for the Chinese SAMD21 M0-Mini clone, which has no led connected to D13/PA17.
|
||||
// Attention!!! D2 and D4 are swapped on these boards!!!
|
||||
// If you connect the LED, it is on pin 24/PB11. In this case activate the next two lines.
|
||||
//#undef LED_BUILTIN
|
||||
//#define LED_BUILTIN 24 // PB11
|
||||
// As an alternative you can choose pin 25, it is the RX-LED pin (PB03), but active low.In this case activate the next 3 lines.
|
||||
//#undef LED_BUILTIN
|
||||
//#define LED_BUILTIN 25 // PB03
|
||||
//#define FEEDBACK_LED_IS_ACTIVE_LOW // The RX LED on the M0-Mini is active LOW
|
||||
|
||||
#elif defined (NRF51) // BBC micro:bit
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define APPLICATION_PIN 1
|
||||
#define _IR_TIMING_TEST_PIN 4
|
||||
|
||||
#define tone(...) void() // no tone() available
|
||||
#define noTone(a) void()
|
||||
#define TONE_PIN 42 // Dummy for examples using it
|
||||
|
||||
#else
|
||||
#warning Board / CPU is not detected using pre-processor symbols -> using default values, which may not fit. Please extend PinDefinitionsAndMore.h.
|
||||
// Default valued for unidentified boards
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
#endif // defined(ESP8266)
|
||||
|
||||
#if defined(ESP32) || defined(ARDUINO_ARCH_RP2040) || defined(PARTICLE) || defined(ARDUINO_ARCH_MBED)
|
||||
#define SEND_PWM_BY_TIMER // We do not have pin restrictions for this CPU's, so lets use the hardware PWM for send carrier signal generation
|
||||
#else
|
||||
# if defined(SEND_PWM_BY_TIMER)
|
||||
#undef IR_SEND_PIN // SendPin is determined by timer! This avoids warnings in IRremote.hpp and IRTimer.hpp
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if !defined (FLASHEND)
|
||||
#define FLASHEND 0xFFFF // Dummy value for platforms where FLASHEND is not defined
|
||||
#endif
|
||||
|
||||
/*
|
||||
* 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
|
||||
@@ -0,0 +1,131 @@
|
||||
/*
|
||||
* SimpleReceiver.cpp
|
||||
*
|
||||
* Demonstrates receiving ONLY NEC protocol IR codes with IRremote
|
||||
* If no protocol is defined, all protocols (except Bang&Olufsen) are active.
|
||||
*
|
||||
* This file is part of Arduino-IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
|
||||
*
|
||||
************************************************************************************
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2020-2023 Armin Joachimsmeyer
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is furnished
|
||||
* to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
************************************************************************************
|
||||
*/
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
/*
|
||||
* Specify which protocol(s) should be used for decoding.
|
||||
* If no protocol is defined, all protocols (except Bang&Olufsen) are active.
|
||||
* This must be done before the #include <IRremote.hpp>
|
||||
*/
|
||||
//#define DECODE_DENON // Includes Sharp
|
||||
//#define DECODE_JVC
|
||||
//#define DECODE_KASEIKYO
|
||||
//#define DECODE_PANASONIC // alias for DECODE_KASEIKYO
|
||||
//#define DECODE_LG
|
||||
#define DECODE_NEC // Includes Apple and Onkyo. To enable all protocols , just comment/disable this line.
|
||||
//#define DECODE_SAMSUNG
|
||||
//#define DECODE_SONY
|
||||
//#define DECODE_RC5
|
||||
//#define DECODE_RC6
|
||||
|
||||
//#define DECODE_BOSEWAVE
|
||||
//#define DECODE_LEGO_PF
|
||||
//#define DECODE_MAGIQUEST
|
||||
//#define DECODE_WHYNTER
|
||||
//#define DECODE_FAST
|
||||
|
||||
//#define DECODE_DISTANCE_WIDTH // Universal decoder for pulse distance width protocols
|
||||
//#define DECODE_HASH // special decoder for all protocols
|
||||
|
||||
//#define DECODE_BEO // This protocol must always be enabled manually, i.e. it is NOT enabled if no protocol is defined. It prevents decoding of SONY!
|
||||
|
||||
//#define DEBUG // Activate this for lots of lovely debug output from the decoders.
|
||||
|
||||
//#define RAW_BUFFER_LENGTH 750 // For air condition remotes it requires 750. Default is 200.
|
||||
|
||||
/*
|
||||
* 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 <IRremote.hpp> // include the library
|
||||
|
||||
#if !defined(STR_HELPER)
|
||||
#define STR_HELPER(x) #x
|
||||
#define STR(x) STR_HELPER(x)
|
||||
#endif
|
||||
|
||||
#define IR_RECEIVE_PIN 4 // P0_1
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
while (!Serial)
|
||||
; // Wait for Serial to become available. Is optimized away for some cores.
|
||||
|
||||
// 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
|
||||
IrReceiver.begin(IR_RECEIVE_PIN, ENABLE_LED_FEEDBACK);
|
||||
|
||||
Serial.print(F("Ready to receive IR signals of protocols: "));
|
||||
printActiveIRProtocols(&Serial);
|
||||
Serial.println(F("at pin " STR(IR_RECEIVE_PIN)));
|
||||
}
|
||||
|
||||
void loop() {
|
||||
/*
|
||||
* Check if received data is available and if yes, try to decode it.
|
||||
* Decoded result is in the IrReceiver.decodedIRData structure.
|
||||
*
|
||||
* E.g. command is in IrReceiver.decodedIRData.command
|
||||
* address is in command is in IrReceiver.decodedIRData.address
|
||||
* and up to 32 bit raw data in IrReceiver.decodedIRData.decodedRawData
|
||||
*/
|
||||
if (IrReceiver.decode()) {
|
||||
|
||||
/*
|
||||
* Print a summary of received data
|
||||
*/
|
||||
if (IrReceiver.decodedIRData.protocol == UNKNOWN) {
|
||||
Serial.println(F("Received noise or an unknown (or not yet enabled) protocol"));
|
||||
// We have an unknown protocol here, print extended info
|
||||
IrReceiver.printIRResultRawFormatted(&Serial, true);
|
||||
IrReceiver.resume(); // Do it here, to preserve raw data for printing with printIRResultRawFormatted()
|
||||
} else {
|
||||
IrReceiver.resume(); // Early enable receiving of the next IR frame
|
||||
IrReceiver.printIRResultShort(&Serial);
|
||||
IrReceiver.printIRSendUsage(&Serial);
|
||||
}
|
||||
Serial.println();
|
||||
|
||||
/*
|
||||
* Finally, check the received data and perform actions according to the received command
|
||||
*/
|
||||
if (IrReceiver.decodedIRData.command == 0x10) {
|
||||
// do something
|
||||
} else if (IrReceiver.decodedIRData.command == 0x11) {
|
||||
// do something else
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,349 @@
|
||||
/*
|
||||
* PinDefinitionsAndMore.h
|
||||
*
|
||||
* Contains pin definitions for IRremote examples for various platforms
|
||||
* as well as definitions for feedback LED and tone() and includes
|
||||
*
|
||||
* Copyright (C) 2021-2023 Armin Joachimsmeyer
|
||||
* armin.joachimsmeyer@gmail.com
|
||||
*
|
||||
* This file is part of IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
|
||||
*
|
||||
* Arduino-IRremote is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/gpl.html>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Pin mapping table for different platforms
|
||||
*
|
||||
* Platform IR input IR output Tone Core/Pin schema
|
||||
* --------------------------------------------------------------
|
||||
* DEFAULT/AVR 2 3 4 Arduino
|
||||
* ATtinyX5 0|PB0 4|PB4 3|PB3 ATTinyCore
|
||||
* ATtiny167 3|PA3 2|PA2 7|PA7 ATTinyCore
|
||||
* ATtiny167 9|PA3 8|PA2 5|PA7 Digispark original core
|
||||
* ATtiny84 |PB2 |PA4 |PA3 ATTinyCore
|
||||
* ATtiny88 3|PD3 4|PD4 9|PB1 ATTinyCore
|
||||
* ATtiny3217 18|PA1 19|PA2 20|PA3 MegaTinyCore
|
||||
* ATtiny1604 2 3|PA5 %
|
||||
* ATtiny816 14|PA1 16|PA3 1|PA5 MegaTinyCore
|
||||
* ATtiny1614 8|PA1 10|PA3 1|PA5 MegaTinyCore
|
||||
* SAMD21 3 4 5
|
||||
* ESP8266 14|D5 12|D6 %
|
||||
* ESP32 15 4 27
|
||||
* ESP32-C3 2 3 4
|
||||
* BluePill PA6 PA7 PA3
|
||||
* APOLLO3 11 12 5
|
||||
* RP2040 3|GPIO15 4|GPIO16 5|GPIO17
|
||||
*/
|
||||
//#define _IR_MEASURE_TIMING // For debugging purposes.
|
||||
|
||||
#if defined(__AVR__)
|
||||
#if defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__) // Digispark board. For use with ATTinyCore.
|
||||
#include "ATtinySerialOut.hpp" // TX is at pin 2 - Available as Arduino library "ATtinySerialOut". Saves 700 bytes program memory and 70 bytes RAM for ATtinyCore.
|
||||
#define IR_RECEIVE_PIN PIN_PB0
|
||||
#define IR_SEND_PIN PIN_PB4 // Pin 2 is serial output with ATtinySerialOut. Pin 1 is internal LED and Pin3 is USB+ with pullup on Digispark board.
|
||||
#define TONE_PIN PIN_PB3
|
||||
#define _IR_TIMING_TEST_PIN PIN_PB3
|
||||
|
||||
# elif defined(__AVR_ATtiny87__) || defined(__AVR_ATtiny167__) // Digispark pro board
|
||||
#include "ATtinySerialOut.hpp" // Available as Arduino library "ATtinySerialOut"
|
||||
// For ATtiny167 Pins PB6 and PA3 are usable as interrupt source.
|
||||
# if defined(ARDUINO_AVR_DIGISPARKPRO)
|
||||
// For use with Digispark original core
|
||||
#define IR_RECEIVE_PIN 9 // PA3 - on Digispark board labeled as pin 9
|
||||
//#define IR_RECEIVE_PIN 14 // PB6 / INT0 is connected to USB+ on DigisparkPro boards
|
||||
#define IR_SEND_PIN 8 // PA2 - on Digispark board labeled as pin 8
|
||||
#define TONE_PIN 5 // PA7 - on Digispark board labeled as pin 5
|
||||
#define _IR_TIMING_TEST_PIN 10 // PA4
|
||||
# else
|
||||
// For use with ATTinyCore
|
||||
#define IR_RECEIVE_PIN PIN_PA3 // On Digispark board labeled as pin 9 - INT0 is connected to USB+ on DigisparkPro boards
|
||||
#define IR_SEND_PIN PIN_PA2 // On Digispark board labeled as pin 8
|
||||
#define TONE_PIN PIN_PA7 // On Digispark board labeled as pin 5
|
||||
# endif
|
||||
|
||||
# elif defined(__AVR_ATtiny84__) // For use with ATTinyCore
|
||||
#include "ATtinySerialOut.hpp" // Available as Arduino library "ATtinySerialOut". Saves 128 bytes program memory.
|
||||
#define IR_RECEIVE_PIN PIN_PB2 // INT0
|
||||
#define IR_SEND_PIN PIN_PA4
|
||||
#define TONE_PIN PIN_PA3
|
||||
#define _IR_TIMING_TEST_PIN PIN_PA5
|
||||
|
||||
# elif defined(__AVR_ATtiny88__) // MH-ET Tiny88 board. For use with ATTinyCore.
|
||||
#include "ATtinySerialOut.hpp" // Available as Arduino library "ATtinySerialOut". Saves 128 bytes program memory.
|
||||
// Pin 6 is TX, pin 7 is RX
|
||||
#define IR_RECEIVE_PIN PIN_PD3 // 3 - INT1
|
||||
#define IR_SEND_PIN PIN_PD4 // 4
|
||||
#define TONE_PIN PIN_PB1 // 9
|
||||
#define _IR_TIMING_TEST_PIN PIN_PB0 // 8
|
||||
|
||||
# elif defined(__AVR_ATtiny1616__) || defined(__AVR_ATtiny3216__) || defined(__AVR_ATtiny3217__) // For use with megaTinyCore
|
||||
// Tiny Core Dev board
|
||||
// https://www.tindie.com/products/xkimi/tiny-core-16-dev-board-attiny1616/ - Out of Stock
|
||||
// https://www.tindie.com/products/xkimi/tiny-core-32-dev-board-attiny3217/ - Out of Stock
|
||||
#define IR_RECEIVE_PIN PIN_PA1 // use 18 instead of PIN_PA1 for TinyCore32
|
||||
#define IR_SEND_PIN PIN_PA2 // 19
|
||||
#define TONE_PIN PIN_PA3 // 20
|
||||
#define APPLICATION_PIN PIN_PA0 // 0
|
||||
#undef LED_BUILTIN // No LED available on the TinyCore 32 board, take the one on the programming board which is connected to the DAC output
|
||||
#define LED_BUILTIN PIN_PA6 // use 2 instead of PIN_PA6 for TinyCore32
|
||||
|
||||
# elif defined(__AVR_ATtiny816__) // For use with megaTinyCore
|
||||
#define IR_RECEIVE_PIN PIN_PA1 // 14
|
||||
#define IR_SEND_PIN PIN_PA1 // 16
|
||||
#define TONE_PIN PIN_PA5 // 1
|
||||
#define APPLICATION_PIN PIN_PA4 // 0
|
||||
#undef LED_BUILTIN // No LED available, take the one which is connected to the DAC output
|
||||
#define LED_BUILTIN PIN_PB5 // 4
|
||||
|
||||
# elif defined(__AVR_ATtiny1614__) // For use with megaTinyCore
|
||||
#define IR_RECEIVE_PIN PIN_PA1 // 8
|
||||
#define IR_SEND_PIN PIN_PA3 // 10
|
||||
#define TONE_PIN PIN_PA5 // 1
|
||||
#define APPLICATION_PIN PIN_PA4 // 0
|
||||
|
||||
# elif defined(__AVR_ATtiny1604__) // For use with megaTinyCore
|
||||
#define IR_RECEIVE_PIN PIN_PA6 // 2 - To be compatible with interrupt example, pin 2 is chosen here.
|
||||
#define IR_SEND_PIN PIN_PA7 // 3
|
||||
#define APPLICATION_PIN PIN_PB2 // 5
|
||||
|
||||
#define tone(...) void() // Define as void, since TCB0_INT_vect is also used by tone()
|
||||
#define noTone(a) void()
|
||||
#define TONE_PIN 42 // Dummy for examples using it
|
||||
|
||||
# elif defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) \
|
||||
|| defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) \
|
||||
|| defined(__AVR_ATmega324P__) || defined(__AVR_ATmega324A__) \
|
||||
|| defined(__AVR_ATmega324PA__) || defined(__AVR_ATmega164A__) \
|
||||
|| defined(__AVR_ATmega164P__) || defined(__AVR_ATmega32__) \
|
||||
|| defined(__AVR_ATmega16__) || defined(__AVR_ATmega8535__) \
|
||||
|| defined(__AVR_ATmega64__) || defined(__AVR_ATmega128__) \
|
||||
|| defined(__AVR_ATmega1281__) || defined(__AVR_ATmega2561__) \
|
||||
|| defined(__AVR_ATmega8515__) || defined(__AVR_ATmega162__)
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 13
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
# else // Default as for ATmega328 like on Uno, Nano, Leonardo, Teensy 2.0 etc.
|
||||
#define IR_RECEIVE_PIN 2 // To be compatible with interrupt example, pin 2 is chosen here.
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
# if defined(ARDUINO_AVR_PROMICRO) // Sparkfun Pro Micro is __AVR_ATmega32U4__ but has different external circuit
|
||||
// We have no built in LED at pin 13 -> reuse RX LED
|
||||
#undef LED_BUILTIN
|
||||
#define LED_BUILTIN LED_BUILTIN_RX
|
||||
# endif
|
||||
# endif // defined(__AVR_ATtiny25__)...
|
||||
|
||||
#elif defined(ARDUINO_ARCH_RENESAS_UNO) // Uno R4
|
||||
// To be compatible with Uno R3.
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
#elif defined(ESP8266)
|
||||
#define FEEDBACK_LED_IS_ACTIVE_LOW // The LED on my board (D4) is active LOW
|
||||
#define IR_RECEIVE_PIN 14 // D5
|
||||
#define IR_SEND_PIN 12 // D6 - D4/pin 2 is internal LED
|
||||
#define _IR_TIMING_TEST_PIN 2 // D4
|
||||
#define APPLICATION_PIN 13 // D7
|
||||
|
||||
#define tone(...) void() // tone() inhibits receive timer
|
||||
#define noTone(a) void()
|
||||
#define TONE_PIN 42 // Dummy for examples using it#
|
||||
|
||||
#elif defined(ARDUINO_NOLOGO_ESP32C3_SUPER_MINI)
|
||||
#define FEEDBACK_LED_IS_ACTIVE_LOW // The LED on my board (D8) is active LOW
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 10
|
||||
|
||||
#elif defined(CONFIG_IDF_TARGET_ESP32C3) || defined(ARDUINO_ESP32C3_DEV)
|
||||
#define NO_LED_FEEDBACK_CODE // The WS2812 on pin 8 of AI-C3 board crashes if used as receive feedback LED, other I/O pins are working...
|
||||
#define IR_RECEIVE_PIN 6
|
||||
#define IR_SEND_PIN 7
|
||||
#define TONE_PIN 10
|
||||
#define APPLICATION_PIN 18
|
||||
|
||||
#elif defined(ESP32)
|
||||
#include <Arduino.h>
|
||||
|
||||
// tone() is included in ESP32 core since 2.0.2
|
||||
#if !defined(ESP_ARDUINO_VERSION_VAL)
|
||||
#define ESP_ARDUINO_VERSION_VAL(major, minor, patch) 12345678
|
||||
#endif
|
||||
#if ESP_ARDUINO_VERSION <= ESP_ARDUINO_VERSION_VAL(2, 0, 2)
|
||||
#define TONE_LEDC_CHANNEL 1 // Using channel 1 makes tone() independent of receiving timer -> No need to stop receiving timer.
|
||||
void tone(uint8_t aPinNumber, unsigned int aFrequency){
|
||||
ledcAttachPin(aPinNumber, TONE_LEDC_CHANNEL);
|
||||
ledcWriteTone(TONE_LEDC_CHANNEL, aFrequency);
|
||||
}
|
||||
void tone(uint8_t aPinNumber, unsigned int aFrequency, unsigned long aDuration){
|
||||
ledcAttachPin(aPinNumber, TONE_LEDC_CHANNEL);
|
||||
ledcWriteTone(TONE_LEDC_CHANNEL, aFrequency);
|
||||
delay(aDuration);
|
||||
ledcWriteTone(TONE_LEDC_CHANNEL, 0);
|
||||
}
|
||||
void noTone(uint8_t aPinNumber){
|
||||
ledcWriteTone(TONE_LEDC_CHANNEL, 0);
|
||||
}
|
||||
#endif // ESP_ARDUINO_VERSION <= ESP_ARDUINO_VERSION_VAL(2, 0, 2)
|
||||
|
||||
#define IR_RECEIVE_PIN 15 // D15
|
||||
#define IR_SEND_PIN 4 // D4
|
||||
#define TONE_PIN 27 // D27 25 & 26 are DAC0 and 1
|
||||
#define APPLICATION_PIN 16 // RX2 pin
|
||||
|
||||
#elif defined(ARDUINO_ARCH_STM32) || defined(ARDUINO_ARCH_STM32F1) // BluePill
|
||||
// Timer 3 blocks PA6, PA7, PB0, PB1 for use by Servo or tone()
|
||||
#define IR_RECEIVE_PIN PA6
|
||||
#define IR_RECEIVE_PIN_STRING "PA6"
|
||||
#define IR_SEND_PIN PA7
|
||||
#define IR_SEND_PIN_STRING "PA7"
|
||||
#define TONE_PIN PA3
|
||||
#define _IR_TIMING_TEST_PIN PA5
|
||||
#define APPLICATION_PIN PA2
|
||||
#define APPLICATION_PIN_STRING "PA2"
|
||||
# if defined(ARDUINO_GENERIC_STM32F103C) || defined(ARDUINO_BLUEPILL_F103C8)
|
||||
// BluePill LED is active low
|
||||
#define FEEDBACK_LED_IS_ACTIVE_LOW
|
||||
# endif
|
||||
|
||||
#elif defined(ARDUINO_ARCH_APOLLO3) // Sparkfun Apollo boards
|
||||
#define IR_RECEIVE_PIN 11
|
||||
#define IR_SEND_PIN 12
|
||||
#define TONE_PIN 5
|
||||
|
||||
#elif defined(ARDUINO_ARCH_MBED) && defined(ARDUINO_ARCH_MBED_NANO) // Arduino Nano 33 BLE and Arduino Nano Connect layout for MBED
|
||||
// Must be before ARDUINO_ARCH_RP2040, since it is the layout for the MBED core of Arduino Nano Connect
|
||||
#define IR_RECEIVE_PIN 3 // GPIO15 Start with pin 3 since pin 2|GPIO25 is connected to LED on Pi pico
|
||||
#define IR_SEND_PIN 4 // GPIO16
|
||||
#define TONE_PIN 5
|
||||
#define APPLICATION_PIN 6
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 7 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 8
|
||||
|
||||
#elif defined(ARDUINO_ARCH_RP2040) // Arduino Nano Connect, Pi Pico with arduino-pico core https://github.com/earlephilhower/arduino-pico
|
||||
#define IR_RECEIVE_PIN 15 // GPIO15 to be compatible with the Arduino Nano RP2040 Connect (pin3)
|
||||
#define IR_SEND_PIN 16 // GPIO16
|
||||
#define TONE_PIN 17
|
||||
#define APPLICATION_PIN 18
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 19 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 20
|
||||
|
||||
// If you program the Nano RP2040 Connect with this core, then you must redefine LED_BUILTIN
|
||||
// and use the external reset with 1 kOhm to ground to enter UF2 mode
|
||||
#undef LED_BUILTIN
|
||||
#define LED_BUILTIN 6
|
||||
|
||||
#elif defined(PARTICLE) // !!!UNTESTED!!!
|
||||
#define IR_RECEIVE_PIN A4
|
||||
#define IR_SEND_PIN A5 // Particle supports multiple pins
|
||||
|
||||
#define LED_BUILTIN D7
|
||||
|
||||
/*
|
||||
* 4 times the same (default) layout for easy adaption in the future
|
||||
*/
|
||||
#elif defined(TEENSYDUINO) // Teensy 2.0 is handled at default for ATmega328 like on Uno, Nano, Leonardo etc.
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
#elif defined(ARDUINO_ARCH_MBED) // Arduino Nano 33 BLE
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
#elif defined(ARDUINO_ARCH_SAMD) || defined(ARDUINO_ARCH_SAM)
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
#if !defined(ARDUINO_SAMD_ADAFRUIT) && !defined(ARDUINO_SEEED_XIAO_M0)
|
||||
// On the Zero and others we switch explicitly to SerialUSB
|
||||
#define Serial SerialUSB
|
||||
#endif
|
||||
|
||||
// Definitions for the Chinese SAMD21 M0-Mini clone, which has no led connected to D13/PA17.
|
||||
// Attention!!! D2 and D4 are swapped on these boards!!!
|
||||
// If you connect the LED, it is on pin 24/PB11. In this case activate the next two lines.
|
||||
//#undef LED_BUILTIN
|
||||
//#define LED_BUILTIN 24 // PB11
|
||||
// As an alternative you can choose pin 25, it is the RX-LED pin (PB03), but active low.In this case activate the next 3 lines.
|
||||
//#undef LED_BUILTIN
|
||||
//#define LED_BUILTIN 25 // PB03
|
||||
//#define FEEDBACK_LED_IS_ACTIVE_LOW // The RX LED on the M0-Mini is active LOW
|
||||
|
||||
#elif defined (NRF51) // BBC micro:bit
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define APPLICATION_PIN 1
|
||||
#define _IR_TIMING_TEST_PIN 4
|
||||
|
||||
#define tone(...) void() // no tone() available
|
||||
#define noTone(a) void()
|
||||
#define TONE_PIN 42 // Dummy for examples using it
|
||||
|
||||
#else
|
||||
#warning Board / CPU is not detected using pre-processor symbols -> using default values, which may not fit. Please extend PinDefinitionsAndMore.h.
|
||||
// Default valued for unidentified boards
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
#endif // defined(ESP8266)
|
||||
|
||||
#if defined(ESP32) || defined(ARDUINO_ARCH_RP2040) || defined(PARTICLE) || defined(ARDUINO_ARCH_MBED)
|
||||
#define SEND_PWM_BY_TIMER // We do not have pin restrictions for this CPU's, so lets use the hardware PWM for send carrier signal generation
|
||||
#else
|
||||
# if defined(SEND_PWM_BY_TIMER)
|
||||
#undef IR_SEND_PIN // SendPin is determined by timer! This avoids warnings in IRremote.hpp and IRTimer.hpp
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if !defined (FLASHEND)
|
||||
#define FLASHEND 0xFFFF // Dummy value for platforms where FLASHEND is not defined
|
||||
#endif
|
||||
|
||||
/*
|
||||
* 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
|
||||
+100
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* SimpleReceiverForHashCodes.cpp
|
||||
*
|
||||
* Demonstrates receiving hash codes of unknown protocols with IRremote
|
||||
*
|
||||
* This file is part of Arduino-IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
|
||||
*
|
||||
************************************************************************************
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2024 Armin Joachimsmeyer
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is furnished
|
||||
* to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
************************************************************************************
|
||||
*/
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
/*
|
||||
* Specify which protocol(s) should be used for decoding.
|
||||
* This must be done before the #include <IRremote.hpp>
|
||||
*/
|
||||
#define DECODE_HASH // special decoder for all protocols
|
||||
#define RAW_BUFFER_LENGTH 1000 // Especially useful for unknown and probably long protocols
|
||||
//#define DEBUG // Activate this for lots of lovely debug output from the decoders.
|
||||
|
||||
/*
|
||||
* 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 <IRremote.hpp> // 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 4 // P0_1
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
while (!Serial)
|
||||
; // Wait for Serial to become available. Is optimized away for some cores.
|
||||
|
||||
// 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
|
||||
IrReceiver.begin(IR_RECEIVE_PIN, ENABLE_LED_FEEDBACK);
|
||||
|
||||
Serial.println(F("Ready to receive unknown IR signals at pin " STR(IR_RECEIVE_PIN) " and decode it with hash decoder."));
|
||||
}
|
||||
|
||||
void loop() {
|
||||
/*
|
||||
* Check if received data is available and if yes, try to decode it.
|
||||
* Decoded hash result is in IrReceiver.decodedIRData.decodedRawData
|
||||
*/
|
||||
if (IrReceiver.available()) {
|
||||
IrReceiver.initDecodedIRData(); // is required, if we do not call decode();
|
||||
IrReceiver.decodeHash();
|
||||
IrReceiver.resume(); // Early enable receiving of the next IR frame
|
||||
/*
|
||||
* Print a summary and then timing of received data
|
||||
*/
|
||||
IrReceiver.printIRResultShort(&Serial);
|
||||
IrReceiver.printIRResultRawFormatted(&Serial, true);
|
||||
|
||||
Serial.println();
|
||||
|
||||
/*
|
||||
* Finally, check the received data and perform actions according to the received command
|
||||
*/
|
||||
auto tDecodedRawData = IrReceiver.decodedIRData.decodedRawData; // uint32_t on 8 and 16 bit CPUs and uint64_t on 32 and 64 bit CPUs
|
||||
if (tDecodedRawData == 0x4F7BE2FB) {
|
||||
// do something
|
||||
} else if (tDecodedRawData == 0x97483BFB) {
|
||||
// do something else
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,349 @@
|
||||
/*
|
||||
* PinDefinitionsAndMore.h
|
||||
*
|
||||
* Contains pin definitions for IRremote examples for various platforms
|
||||
* as well as definitions for feedback LED and tone() and includes
|
||||
*
|
||||
* Copyright (C) 2021-2023 Armin Joachimsmeyer
|
||||
* armin.joachimsmeyer@gmail.com
|
||||
*
|
||||
* This file is part of IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
|
||||
*
|
||||
* Arduino-IRremote is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/gpl.html>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Pin mapping table for different platforms
|
||||
*
|
||||
* Platform IR input IR output Tone Core/Pin schema
|
||||
* --------------------------------------------------------------
|
||||
* DEFAULT/AVR 2 3 4 Arduino
|
||||
* ATtinyX5 0|PB0 4|PB4 3|PB3 ATTinyCore
|
||||
* ATtiny167 3|PA3 2|PA2 7|PA7 ATTinyCore
|
||||
* ATtiny167 9|PA3 8|PA2 5|PA7 Digispark original core
|
||||
* ATtiny84 |PB2 |PA4 |PA3 ATTinyCore
|
||||
* ATtiny88 3|PD3 4|PD4 9|PB1 ATTinyCore
|
||||
* ATtiny3217 18|PA1 19|PA2 20|PA3 MegaTinyCore
|
||||
* ATtiny1604 2 3|PA5 %
|
||||
* ATtiny816 14|PA1 16|PA3 1|PA5 MegaTinyCore
|
||||
* ATtiny1614 8|PA1 10|PA3 1|PA5 MegaTinyCore
|
||||
* SAMD21 3 4 5
|
||||
* ESP8266 14|D5 12|D6 %
|
||||
* ESP32 15 4 27
|
||||
* ESP32-C3 2 3 4
|
||||
* BluePill PA6 PA7 PA3
|
||||
* APOLLO3 11 12 5
|
||||
* RP2040 3|GPIO15 4|GPIO16 5|GPIO17
|
||||
*/
|
||||
//#define _IR_MEASURE_TIMING // For debugging purposes.
|
||||
|
||||
#if defined(__AVR__)
|
||||
#if defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__) // Digispark board. For use with ATTinyCore.
|
||||
#include "ATtinySerialOut.hpp" // TX is at pin 2 - Available as Arduino library "ATtinySerialOut". Saves 700 bytes program memory and 70 bytes RAM for ATtinyCore.
|
||||
#define IR_RECEIVE_PIN PIN_PB0
|
||||
#define IR_SEND_PIN PIN_PB4 // Pin 2 is serial output with ATtinySerialOut. Pin 1 is internal LED and Pin3 is USB+ with pullup on Digispark board.
|
||||
#define TONE_PIN PIN_PB3
|
||||
#define _IR_TIMING_TEST_PIN PIN_PB3
|
||||
|
||||
# elif defined(__AVR_ATtiny87__) || defined(__AVR_ATtiny167__) // Digispark pro board
|
||||
#include "ATtinySerialOut.hpp" // Available as Arduino library "ATtinySerialOut"
|
||||
// For ATtiny167 Pins PB6 and PA3 are usable as interrupt source.
|
||||
# if defined(ARDUINO_AVR_DIGISPARKPRO)
|
||||
// For use with Digispark original core
|
||||
#define IR_RECEIVE_PIN 9 // PA3 - on Digispark board labeled as pin 9
|
||||
//#define IR_RECEIVE_PIN 14 // PB6 / INT0 is connected to USB+ on DigisparkPro boards
|
||||
#define IR_SEND_PIN 8 // PA2 - on Digispark board labeled as pin 8
|
||||
#define TONE_PIN 5 // PA7 - on Digispark board labeled as pin 5
|
||||
#define _IR_TIMING_TEST_PIN 10 // PA4
|
||||
# else
|
||||
// For use with ATTinyCore
|
||||
#define IR_RECEIVE_PIN PIN_PA3 // On Digispark board labeled as pin 9 - INT0 is connected to USB+ on DigisparkPro boards
|
||||
#define IR_SEND_PIN PIN_PA2 // On Digispark board labeled as pin 8
|
||||
#define TONE_PIN PIN_PA7 // On Digispark board labeled as pin 5
|
||||
# endif
|
||||
|
||||
# elif defined(__AVR_ATtiny84__) // For use with ATTinyCore
|
||||
#include "ATtinySerialOut.hpp" // Available as Arduino library "ATtinySerialOut". Saves 128 bytes program memory.
|
||||
#define IR_RECEIVE_PIN PIN_PB2 // INT0
|
||||
#define IR_SEND_PIN PIN_PA4
|
||||
#define TONE_PIN PIN_PA3
|
||||
#define _IR_TIMING_TEST_PIN PIN_PA5
|
||||
|
||||
# elif defined(__AVR_ATtiny88__) // MH-ET Tiny88 board. For use with ATTinyCore.
|
||||
#include "ATtinySerialOut.hpp" // Available as Arduino library "ATtinySerialOut". Saves 128 bytes program memory.
|
||||
// Pin 6 is TX, pin 7 is RX
|
||||
#define IR_RECEIVE_PIN PIN_PD3 // 3 - INT1
|
||||
#define IR_SEND_PIN PIN_PD4 // 4
|
||||
#define TONE_PIN PIN_PB1 // 9
|
||||
#define _IR_TIMING_TEST_PIN PIN_PB0 // 8
|
||||
|
||||
# elif defined(__AVR_ATtiny1616__) || defined(__AVR_ATtiny3216__) || defined(__AVR_ATtiny3217__) // For use with megaTinyCore
|
||||
// Tiny Core Dev board
|
||||
// https://www.tindie.com/products/xkimi/tiny-core-16-dev-board-attiny1616/ - Out of Stock
|
||||
// https://www.tindie.com/products/xkimi/tiny-core-32-dev-board-attiny3217/ - Out of Stock
|
||||
#define IR_RECEIVE_PIN PIN_PA1 // use 18 instead of PIN_PA1 for TinyCore32
|
||||
#define IR_SEND_PIN PIN_PA2 // 19
|
||||
#define TONE_PIN PIN_PA3 // 20
|
||||
#define APPLICATION_PIN PIN_PA0 // 0
|
||||
#undef LED_BUILTIN // No LED available on the TinyCore 32 board, take the one on the programming board which is connected to the DAC output
|
||||
#define LED_BUILTIN PIN_PA6 // use 2 instead of PIN_PA6 for TinyCore32
|
||||
|
||||
# elif defined(__AVR_ATtiny816__) // For use with megaTinyCore
|
||||
#define IR_RECEIVE_PIN PIN_PA1 // 14
|
||||
#define IR_SEND_PIN PIN_PA1 // 16
|
||||
#define TONE_PIN PIN_PA5 // 1
|
||||
#define APPLICATION_PIN PIN_PA4 // 0
|
||||
#undef LED_BUILTIN // No LED available, take the one which is connected to the DAC output
|
||||
#define LED_BUILTIN PIN_PB5 // 4
|
||||
|
||||
# elif defined(__AVR_ATtiny1614__) // For use with megaTinyCore
|
||||
#define IR_RECEIVE_PIN PIN_PA1 // 8
|
||||
#define IR_SEND_PIN PIN_PA3 // 10
|
||||
#define TONE_PIN PIN_PA5 // 1
|
||||
#define APPLICATION_PIN PIN_PA4 // 0
|
||||
|
||||
# elif defined(__AVR_ATtiny1604__) // For use with megaTinyCore
|
||||
#define IR_RECEIVE_PIN PIN_PA6 // 2 - To be compatible with interrupt example, pin 2 is chosen here.
|
||||
#define IR_SEND_PIN PIN_PA7 // 3
|
||||
#define APPLICATION_PIN PIN_PB2 // 5
|
||||
|
||||
#define tone(...) void() // Define as void, since TCB0_INT_vect is also used by tone()
|
||||
#define noTone(a) void()
|
||||
#define TONE_PIN 42 // Dummy for examples using it
|
||||
|
||||
# elif defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) \
|
||||
|| defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) \
|
||||
|| defined(__AVR_ATmega324P__) || defined(__AVR_ATmega324A__) \
|
||||
|| defined(__AVR_ATmega324PA__) || defined(__AVR_ATmega164A__) \
|
||||
|| defined(__AVR_ATmega164P__) || defined(__AVR_ATmega32__) \
|
||||
|| defined(__AVR_ATmega16__) || defined(__AVR_ATmega8535__) \
|
||||
|| defined(__AVR_ATmega64__) || defined(__AVR_ATmega128__) \
|
||||
|| defined(__AVR_ATmega1281__) || defined(__AVR_ATmega2561__) \
|
||||
|| defined(__AVR_ATmega8515__) || defined(__AVR_ATmega162__)
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 13
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
# else // Default as for ATmega328 like on Uno, Nano, Leonardo, Teensy 2.0 etc.
|
||||
#define IR_RECEIVE_PIN 2 // To be compatible with interrupt example, pin 2 is chosen here.
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
# if defined(ARDUINO_AVR_PROMICRO) // Sparkfun Pro Micro is __AVR_ATmega32U4__ but has different external circuit
|
||||
// We have no built in LED at pin 13 -> reuse RX LED
|
||||
#undef LED_BUILTIN
|
||||
#define LED_BUILTIN LED_BUILTIN_RX
|
||||
# endif
|
||||
# endif // defined(__AVR_ATtiny25__)...
|
||||
|
||||
#elif defined(ARDUINO_ARCH_RENESAS_UNO) // Uno R4
|
||||
// To be compatible with Uno R3.
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
#elif defined(ESP8266)
|
||||
#define FEEDBACK_LED_IS_ACTIVE_LOW // The LED on my board (D4) is active LOW
|
||||
#define IR_RECEIVE_PIN 14 // D5
|
||||
#define IR_SEND_PIN 12 // D6 - D4/pin 2 is internal LED
|
||||
#define _IR_TIMING_TEST_PIN 2 // D4
|
||||
#define APPLICATION_PIN 13 // D7
|
||||
|
||||
#define tone(...) void() // tone() inhibits receive timer
|
||||
#define noTone(a) void()
|
||||
#define TONE_PIN 42 // Dummy for examples using it#
|
||||
|
||||
#elif defined(ARDUINO_NOLOGO_ESP32C3_SUPER_MINI)
|
||||
#define FEEDBACK_LED_IS_ACTIVE_LOW // The LED on my board (D8) is active LOW
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 10
|
||||
|
||||
#elif defined(CONFIG_IDF_TARGET_ESP32C3) || defined(ARDUINO_ESP32C3_DEV)
|
||||
#define NO_LED_FEEDBACK_CODE // The WS2812 on pin 8 of AI-C3 board crashes if used as receive feedback LED, other I/O pins are working...
|
||||
#define IR_RECEIVE_PIN 6
|
||||
#define IR_SEND_PIN 7
|
||||
#define TONE_PIN 10
|
||||
#define APPLICATION_PIN 18
|
||||
|
||||
#elif defined(ESP32)
|
||||
#include <Arduino.h>
|
||||
|
||||
// tone() is included in ESP32 core since 2.0.2
|
||||
#if !defined(ESP_ARDUINO_VERSION_VAL)
|
||||
#define ESP_ARDUINO_VERSION_VAL(major, minor, patch) 12345678
|
||||
#endif
|
||||
#if ESP_ARDUINO_VERSION <= ESP_ARDUINO_VERSION_VAL(2, 0, 2)
|
||||
#define TONE_LEDC_CHANNEL 1 // Using channel 1 makes tone() independent of receiving timer -> No need to stop receiving timer.
|
||||
void tone(uint8_t aPinNumber, unsigned int aFrequency){
|
||||
ledcAttachPin(aPinNumber, TONE_LEDC_CHANNEL);
|
||||
ledcWriteTone(TONE_LEDC_CHANNEL, aFrequency);
|
||||
}
|
||||
void tone(uint8_t aPinNumber, unsigned int aFrequency, unsigned long aDuration){
|
||||
ledcAttachPin(aPinNumber, TONE_LEDC_CHANNEL);
|
||||
ledcWriteTone(TONE_LEDC_CHANNEL, aFrequency);
|
||||
delay(aDuration);
|
||||
ledcWriteTone(TONE_LEDC_CHANNEL, 0);
|
||||
}
|
||||
void noTone(uint8_t aPinNumber){
|
||||
ledcWriteTone(TONE_LEDC_CHANNEL, 0);
|
||||
}
|
||||
#endif // ESP_ARDUINO_VERSION <= ESP_ARDUINO_VERSION_VAL(2, 0, 2)
|
||||
|
||||
#define IR_RECEIVE_PIN 15 // D15
|
||||
#define IR_SEND_PIN 4 // D4
|
||||
#define TONE_PIN 27 // D27 25 & 26 are DAC0 and 1
|
||||
#define APPLICATION_PIN 16 // RX2 pin
|
||||
|
||||
#elif defined(ARDUINO_ARCH_STM32) || defined(ARDUINO_ARCH_STM32F1) // BluePill
|
||||
// Timer 3 blocks PA6, PA7, PB0, PB1 for use by Servo or tone()
|
||||
#define IR_RECEIVE_PIN PA6
|
||||
#define IR_RECEIVE_PIN_STRING "PA6"
|
||||
#define IR_SEND_PIN PA7
|
||||
#define IR_SEND_PIN_STRING "PA7"
|
||||
#define TONE_PIN PA3
|
||||
#define _IR_TIMING_TEST_PIN PA5
|
||||
#define APPLICATION_PIN PA2
|
||||
#define APPLICATION_PIN_STRING "PA2"
|
||||
# if defined(ARDUINO_GENERIC_STM32F103C) || defined(ARDUINO_BLUEPILL_F103C8)
|
||||
// BluePill LED is active low
|
||||
#define FEEDBACK_LED_IS_ACTIVE_LOW
|
||||
# endif
|
||||
|
||||
#elif defined(ARDUINO_ARCH_APOLLO3) // Sparkfun Apollo boards
|
||||
#define IR_RECEIVE_PIN 11
|
||||
#define IR_SEND_PIN 12
|
||||
#define TONE_PIN 5
|
||||
|
||||
#elif defined(ARDUINO_ARCH_MBED) && defined(ARDUINO_ARCH_MBED_NANO) // Arduino Nano 33 BLE and Arduino Nano Connect layout for MBED
|
||||
// Must be before ARDUINO_ARCH_RP2040, since it is the layout for the MBED core of Arduino Nano Connect
|
||||
#define IR_RECEIVE_PIN 3 // GPIO15 Start with pin 3 since pin 2|GPIO25 is connected to LED on Pi pico
|
||||
#define IR_SEND_PIN 4 // GPIO16
|
||||
#define TONE_PIN 5
|
||||
#define APPLICATION_PIN 6
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 7 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 8
|
||||
|
||||
#elif defined(ARDUINO_ARCH_RP2040) // Arduino Nano Connect, Pi Pico with arduino-pico core https://github.com/earlephilhower/arduino-pico
|
||||
#define IR_RECEIVE_PIN 15 // GPIO15 to be compatible with the Arduino Nano RP2040 Connect (pin3)
|
||||
#define IR_SEND_PIN 16 // GPIO16
|
||||
#define TONE_PIN 17
|
||||
#define APPLICATION_PIN 18
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 19 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 20
|
||||
|
||||
// If you program the Nano RP2040 Connect with this core, then you must redefine LED_BUILTIN
|
||||
// and use the external reset with 1 kOhm to ground to enter UF2 mode
|
||||
#undef LED_BUILTIN
|
||||
#define LED_BUILTIN 6
|
||||
|
||||
#elif defined(PARTICLE) // !!!UNTESTED!!!
|
||||
#define IR_RECEIVE_PIN A4
|
||||
#define IR_SEND_PIN A5 // Particle supports multiple pins
|
||||
|
||||
#define LED_BUILTIN D7
|
||||
|
||||
/*
|
||||
* 4 times the same (default) layout for easy adaption in the future
|
||||
*/
|
||||
#elif defined(TEENSYDUINO) // Teensy 2.0 is handled at default for ATmega328 like on Uno, Nano, Leonardo etc.
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
#elif defined(ARDUINO_ARCH_MBED) // Arduino Nano 33 BLE
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
#elif defined(ARDUINO_ARCH_SAMD) || defined(ARDUINO_ARCH_SAM)
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
#if !defined(ARDUINO_SAMD_ADAFRUIT) && !defined(ARDUINO_SEEED_XIAO_M0)
|
||||
// On the Zero and others we switch explicitly to SerialUSB
|
||||
#define Serial SerialUSB
|
||||
#endif
|
||||
|
||||
// Definitions for the Chinese SAMD21 M0-Mini clone, which has no led connected to D13/PA17.
|
||||
// Attention!!! D2 and D4 are swapped on these boards!!!
|
||||
// If you connect the LED, it is on pin 24/PB11. In this case activate the next two lines.
|
||||
//#undef LED_BUILTIN
|
||||
//#define LED_BUILTIN 24 // PB11
|
||||
// As an alternative you can choose pin 25, it is the RX-LED pin (PB03), but active low.In this case activate the next 3 lines.
|
||||
//#undef LED_BUILTIN
|
||||
//#define LED_BUILTIN 25 // PB03
|
||||
//#define FEEDBACK_LED_IS_ACTIVE_LOW // The RX LED on the M0-Mini is active LOW
|
||||
|
||||
#elif defined (NRF51) // BBC micro:bit
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define APPLICATION_PIN 1
|
||||
#define _IR_TIMING_TEST_PIN 4
|
||||
|
||||
#define tone(...) void() // no tone() available
|
||||
#define noTone(a) void()
|
||||
#define TONE_PIN 42 // Dummy for examples using it
|
||||
|
||||
#else
|
||||
#warning Board / CPU is not detected using pre-processor symbols -> using default values, which may not fit. Please extend PinDefinitionsAndMore.h.
|
||||
// Default valued for unidentified boards
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
#endif // defined(ESP8266)
|
||||
|
||||
#if defined(ESP32) || defined(ARDUINO_ARCH_RP2040) || defined(PARTICLE) || defined(ARDUINO_ARCH_MBED)
|
||||
#define SEND_PWM_BY_TIMER // We do not have pin restrictions for this CPU's, so lets use the hardware PWM for send carrier signal generation
|
||||
#else
|
||||
# if defined(SEND_PWM_BY_TIMER)
|
||||
#undef IR_SEND_PIN // SendPin is determined by timer! This avoids warnings in IRremote.hpp and IRTimer.hpp
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if !defined (FLASHEND)
|
||||
#define FLASHEND 0xFFFF // Dummy value for platforms where FLASHEND is not defined
|
||||
#endif
|
||||
|
||||
/*
|
||||
* 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
|
||||
+165
@@ -0,0 +1,165 @@
|
||||
/*
|
||||
* SimpleReceiverWithCallback.cpp
|
||||
*
|
||||
* Demonstrates receiving NEC IR codes with IRrecv
|
||||
*
|
||||
* This file is part of Arduino-IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
|
||||
*
|
||||
************************************************************************************
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2022 Armin Joachimsmeyer
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is furnished
|
||||
* to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
************************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
* Specify which protocol(s) should be used for decoding.
|
||||
* If no protocol is defined, all protocols (except Bang&Olufsen) are active.
|
||||
* This must be done before the #include <IRremote.hpp>
|
||||
*/
|
||||
//#define DECODE_DENON // Includes Sharp
|
||||
//#define DECODE_JVC
|
||||
//#define DECODE_KASEIKYO
|
||||
//#define DECODE_PANASONIC // alias for DECODE_KASEIKYO
|
||||
//#define DECODE_LG
|
||||
#define DECODE_NEC // Includes Apple and Onkyo
|
||||
//#define DECODE_SAMSUNG
|
||||
//#define DECODE_SONY
|
||||
//#define DECODE_RC5
|
||||
//#define DECODE_RC6
|
||||
|
||||
//#define DECODE_BOSEWAVE
|
||||
//#define DECODE_LEGO_PF
|
||||
//#define DECODE_MAGIQUEST
|
||||
//#define DECODE_WHYNTER
|
||||
//#define DECODE_FAST
|
||||
|
||||
//#define DECODE_DISTANCE_WIDTH // Universal decoder for pulse distance width protocols
|
||||
//#define DECODE_HASH // special decoder for all protocols
|
||||
|
||||
//#define DECODE_BEO // This protocol must always be enabled manually, i.e. it is NOT enabled if no protocol is defined. It prevents decoding of SONY!
|
||||
|
||||
//#define DEBUG // Activate this for lots of lovely debug output from the decoders.
|
||||
|
||||
//#define RAW_BUFFER_LENGTH 750 // For air condition remotes it requires 750. Default is 200.
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
//#include "PinDefinitionsAndMore.h" // Define macros for input and output pin etc.
|
||||
#include <IRremote.hpp>
|
||||
|
||||
/*
|
||||
* 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 4 // P0_1
|
||||
|
||||
/*
|
||||
* For callback
|
||||
*/
|
||||
// #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
|
||||
void ReceiveCompleteCallbackHandler();
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
while (!Serial)
|
||||
; // Wait for Serial to become available. Is optimized away for some cores.
|
||||
|
||||
// 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
|
||||
IrReceiver.begin(IR_RECEIVE_PIN, ENABLE_LED_FEEDBACK);
|
||||
IrReceiver.registerReceiveCompleteCallback(ReceiveCompleteCallbackHandler);
|
||||
|
||||
Serial.print(F("Ready to receive IR signals of protocols: "));
|
||||
printActiveIRProtocols(&Serial);
|
||||
Serial.println(F("at pin " STR(IR_RECEIVE_PIN)));
|
||||
}
|
||||
|
||||
void loop() {
|
||||
/*
|
||||
* Print in loop (interrupts are enabled here) if received data is available.
|
||||
*/
|
||||
if (sIRDataJustReceived) {
|
||||
// Print a summary of received data
|
||||
if (IrReceiver.decodedIRData.protocol == UNKNOWN) {
|
||||
Serial.println(F("Received noise or an unknown (or not yet enabled) protocol"));
|
||||
/*
|
||||
* We have an unknown protocol here, print more info.
|
||||
* !!!Attention!!! This prints incorrect values, if we are late (not in this simple example :-))
|
||||
* and the the first mark of the next (repeat) data was yet received
|
||||
*/
|
||||
IrReceiver.printIRResultRawFormatted(&Serial, true); //
|
||||
} else {
|
||||
IrReceiver.printIRResultShort(&Serial);
|
||||
IrReceiver.printIRSendUsage(&Serial);
|
||||
}
|
||||
Serial.println();
|
||||
sIRDataJustReceived = false;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Callback function
|
||||
* Here we know, that data is available.
|
||||
* This function is executed in ISR (Interrupt Service Routine) context (interrupts are blocked here).
|
||||
* Make it short and fast and keep in mind, that you can not use delay(), prints longer than print buffer size etc.,
|
||||
* because they require interrupts enabled to return.
|
||||
* 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.
|
||||
*/
|
||||
void ReceiveCompleteCallbackHandler() {
|
||||
IrReceiver.decode(); // fill IrReceiver.decodedIRData
|
||||
/*
|
||||
* Enable receiving of the next value.
|
||||
*/
|
||||
IrReceiver.resume();
|
||||
|
||||
/*
|
||||
* Check the received data and perform actions according to the received command
|
||||
* Decoded result is in the IrReceiver.decodedIRData structure.
|
||||
*
|
||||
* E.g. command is in IrReceiver.decodedIRData.command,
|
||||
* address is in command is in IrReceiver.decodedIRData.address
|
||||
* and up to 32 bit raw data in IrReceiver.decodedIRData.decodedRawData
|
||||
*/
|
||||
if (IrReceiver.decodedIRData.command == 0x10) {
|
||||
// do something SHORT here
|
||||
} else if (IrReceiver.decodedIRData.command == 0x11) {
|
||||
// do something SHORT here too
|
||||
}
|
||||
|
||||
/*
|
||||
* Set flag to trigger printing of results in main loop,
|
||||
* since printing should not be done in a callback function
|
||||
* running in ISR (Interrupt Service Routine) context where interrupts are disabled.
|
||||
*/
|
||||
sIRDataJustReceived = true;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,349 @@
|
||||
/*
|
||||
* PinDefinitionsAndMore.h
|
||||
*
|
||||
* Contains pin definitions for IRremote examples for various platforms
|
||||
* as well as definitions for feedback LED and tone() and includes
|
||||
*
|
||||
* Copyright (C) 2021-2023 Armin Joachimsmeyer
|
||||
* armin.joachimsmeyer@gmail.com
|
||||
*
|
||||
* This file is part of IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
|
||||
*
|
||||
* Arduino-IRremote is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/gpl.html>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Pin mapping table for different platforms
|
||||
*
|
||||
* Platform IR input IR output Tone Core/Pin schema
|
||||
* --------------------------------------------------------------
|
||||
* DEFAULT/AVR 2 3 4 Arduino
|
||||
* ATtinyX5 0|PB0 4|PB4 3|PB3 ATTinyCore
|
||||
* ATtiny167 3|PA3 2|PA2 7|PA7 ATTinyCore
|
||||
* ATtiny167 9|PA3 8|PA2 5|PA7 Digispark original core
|
||||
* ATtiny84 |PB2 |PA4 |PA3 ATTinyCore
|
||||
* ATtiny88 3|PD3 4|PD4 9|PB1 ATTinyCore
|
||||
* ATtiny3217 18|PA1 19|PA2 20|PA3 MegaTinyCore
|
||||
* ATtiny1604 2 3|PA5 %
|
||||
* ATtiny816 14|PA1 16|PA3 1|PA5 MegaTinyCore
|
||||
* ATtiny1614 8|PA1 10|PA3 1|PA5 MegaTinyCore
|
||||
* SAMD21 3 4 5
|
||||
* ESP8266 14|D5 12|D6 %
|
||||
* ESP32 15 4 27
|
||||
* ESP32-C3 2 3 4
|
||||
* BluePill PA6 PA7 PA3
|
||||
* APOLLO3 11 12 5
|
||||
* RP2040 3|GPIO15 4|GPIO16 5|GPIO17
|
||||
*/
|
||||
//#define _IR_MEASURE_TIMING // For debugging purposes.
|
||||
|
||||
#if defined(__AVR__)
|
||||
#if defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__) // Digispark board. For use with ATTinyCore.
|
||||
#include "ATtinySerialOut.hpp" // TX is at pin 2 - Available as Arduino library "ATtinySerialOut". Saves 700 bytes program memory and 70 bytes RAM for ATtinyCore.
|
||||
#define IR_RECEIVE_PIN PIN_PB0
|
||||
#define IR_SEND_PIN PIN_PB4 // Pin 2 is serial output with ATtinySerialOut. Pin 1 is internal LED and Pin3 is USB+ with pullup on Digispark board.
|
||||
#define TONE_PIN PIN_PB3
|
||||
#define _IR_TIMING_TEST_PIN PIN_PB3
|
||||
|
||||
# elif defined(__AVR_ATtiny87__) || defined(__AVR_ATtiny167__) // Digispark pro board
|
||||
#include "ATtinySerialOut.hpp" // Available as Arduino library "ATtinySerialOut"
|
||||
// For ATtiny167 Pins PB6 and PA3 are usable as interrupt source.
|
||||
# if defined(ARDUINO_AVR_DIGISPARKPRO)
|
||||
// For use with Digispark original core
|
||||
#define IR_RECEIVE_PIN 9 // PA3 - on Digispark board labeled as pin 9
|
||||
//#define IR_RECEIVE_PIN 14 // PB6 / INT0 is connected to USB+ on DigisparkPro boards
|
||||
#define IR_SEND_PIN 8 // PA2 - on Digispark board labeled as pin 8
|
||||
#define TONE_PIN 5 // PA7 - on Digispark board labeled as pin 5
|
||||
#define _IR_TIMING_TEST_PIN 10 // PA4
|
||||
# else
|
||||
// For use with ATTinyCore
|
||||
#define IR_RECEIVE_PIN PIN_PA3 // On Digispark board labeled as pin 9 - INT0 is connected to USB+ on DigisparkPro boards
|
||||
#define IR_SEND_PIN PIN_PA2 // On Digispark board labeled as pin 8
|
||||
#define TONE_PIN PIN_PA7 // On Digispark board labeled as pin 5
|
||||
# endif
|
||||
|
||||
# elif defined(__AVR_ATtiny84__) // For use with ATTinyCore
|
||||
#include "ATtinySerialOut.hpp" // Available as Arduino library "ATtinySerialOut". Saves 128 bytes program memory.
|
||||
#define IR_RECEIVE_PIN PIN_PB2 // INT0
|
||||
#define IR_SEND_PIN PIN_PA4
|
||||
#define TONE_PIN PIN_PA3
|
||||
#define _IR_TIMING_TEST_PIN PIN_PA5
|
||||
|
||||
# elif defined(__AVR_ATtiny88__) // MH-ET Tiny88 board. For use with ATTinyCore.
|
||||
#include "ATtinySerialOut.hpp" // Available as Arduino library "ATtinySerialOut". Saves 128 bytes program memory.
|
||||
// Pin 6 is TX, pin 7 is RX
|
||||
#define IR_RECEIVE_PIN PIN_PD3 // 3 - INT1
|
||||
#define IR_SEND_PIN PIN_PD4 // 4
|
||||
#define TONE_PIN PIN_PB1 // 9
|
||||
#define _IR_TIMING_TEST_PIN PIN_PB0 // 8
|
||||
|
||||
# elif defined(__AVR_ATtiny1616__) || defined(__AVR_ATtiny3216__) || defined(__AVR_ATtiny3217__) // For use with megaTinyCore
|
||||
// Tiny Core Dev board
|
||||
// https://www.tindie.com/products/xkimi/tiny-core-16-dev-board-attiny1616/ - Out of Stock
|
||||
// https://www.tindie.com/products/xkimi/tiny-core-32-dev-board-attiny3217/ - Out of Stock
|
||||
#define IR_RECEIVE_PIN PIN_PA1 // use 18 instead of PIN_PA1 for TinyCore32
|
||||
#define IR_SEND_PIN PIN_PA2 // 19
|
||||
#define TONE_PIN PIN_PA3 // 20
|
||||
#define APPLICATION_PIN PIN_PA0 // 0
|
||||
#undef LED_BUILTIN // No LED available on the TinyCore 32 board, take the one on the programming board which is connected to the DAC output
|
||||
#define LED_BUILTIN PIN_PA6 // use 2 instead of PIN_PA6 for TinyCore32
|
||||
|
||||
# elif defined(__AVR_ATtiny816__) // For use with megaTinyCore
|
||||
#define IR_RECEIVE_PIN PIN_PA1 // 14
|
||||
#define IR_SEND_PIN PIN_PA1 // 16
|
||||
#define TONE_PIN PIN_PA5 // 1
|
||||
#define APPLICATION_PIN PIN_PA4 // 0
|
||||
#undef LED_BUILTIN // No LED available, take the one which is connected to the DAC output
|
||||
#define LED_BUILTIN PIN_PB5 // 4
|
||||
|
||||
# elif defined(__AVR_ATtiny1614__) // For use with megaTinyCore
|
||||
#define IR_RECEIVE_PIN PIN_PA1 // 8
|
||||
#define IR_SEND_PIN PIN_PA3 // 10
|
||||
#define TONE_PIN PIN_PA5 // 1
|
||||
#define APPLICATION_PIN PIN_PA4 // 0
|
||||
|
||||
# elif defined(__AVR_ATtiny1604__) // For use with megaTinyCore
|
||||
#define IR_RECEIVE_PIN PIN_PA6 // 2 - To be compatible with interrupt example, pin 2 is chosen here.
|
||||
#define IR_SEND_PIN PIN_PA7 // 3
|
||||
#define APPLICATION_PIN PIN_PB2 // 5
|
||||
|
||||
#define tone(...) void() // Define as void, since TCB0_INT_vect is also used by tone()
|
||||
#define noTone(a) void()
|
||||
#define TONE_PIN 42 // Dummy for examples using it
|
||||
|
||||
# elif defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) \
|
||||
|| defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) \
|
||||
|| defined(__AVR_ATmega324P__) || defined(__AVR_ATmega324A__) \
|
||||
|| defined(__AVR_ATmega324PA__) || defined(__AVR_ATmega164A__) \
|
||||
|| defined(__AVR_ATmega164P__) || defined(__AVR_ATmega32__) \
|
||||
|| defined(__AVR_ATmega16__) || defined(__AVR_ATmega8535__) \
|
||||
|| defined(__AVR_ATmega64__) || defined(__AVR_ATmega128__) \
|
||||
|| defined(__AVR_ATmega1281__) || defined(__AVR_ATmega2561__) \
|
||||
|| defined(__AVR_ATmega8515__) || defined(__AVR_ATmega162__)
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 13
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
# else // Default as for ATmega328 like on Uno, Nano, Leonardo, Teensy 2.0 etc.
|
||||
#define IR_RECEIVE_PIN 2 // To be compatible with interrupt example, pin 2 is chosen here.
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
# if defined(ARDUINO_AVR_PROMICRO) // Sparkfun Pro Micro is __AVR_ATmega32U4__ but has different external circuit
|
||||
// We have no built in LED at pin 13 -> reuse RX LED
|
||||
#undef LED_BUILTIN
|
||||
#define LED_BUILTIN LED_BUILTIN_RX
|
||||
# endif
|
||||
# endif // defined(__AVR_ATtiny25__)...
|
||||
|
||||
#elif defined(ARDUINO_ARCH_RENESAS_UNO) // Uno R4
|
||||
// To be compatible with Uno R3.
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
#elif defined(ESP8266)
|
||||
#define FEEDBACK_LED_IS_ACTIVE_LOW // The LED on my board (D4) is active LOW
|
||||
#define IR_RECEIVE_PIN 14 // D5
|
||||
#define IR_SEND_PIN 12 // D6 - D4/pin 2 is internal LED
|
||||
#define _IR_TIMING_TEST_PIN 2 // D4
|
||||
#define APPLICATION_PIN 13 // D7
|
||||
|
||||
#define tone(...) void() // tone() inhibits receive timer
|
||||
#define noTone(a) void()
|
||||
#define TONE_PIN 42 // Dummy for examples using it#
|
||||
|
||||
#elif defined(ARDUINO_NOLOGO_ESP32C3_SUPER_MINI)
|
||||
#define FEEDBACK_LED_IS_ACTIVE_LOW // The LED on my board (D8) is active LOW
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 10
|
||||
|
||||
#elif defined(CONFIG_IDF_TARGET_ESP32C3) || defined(ARDUINO_ESP32C3_DEV)
|
||||
#define NO_LED_FEEDBACK_CODE // The WS2812 on pin 8 of AI-C3 board crashes if used as receive feedback LED, other I/O pins are working...
|
||||
#define IR_RECEIVE_PIN 6
|
||||
#define IR_SEND_PIN 7
|
||||
#define TONE_PIN 10
|
||||
#define APPLICATION_PIN 18
|
||||
|
||||
#elif defined(ESP32)
|
||||
#include <Arduino.h>
|
||||
|
||||
// tone() is included in ESP32 core since 2.0.2
|
||||
#if !defined(ESP_ARDUINO_VERSION_VAL)
|
||||
#define ESP_ARDUINO_VERSION_VAL(major, minor, patch) 12345678
|
||||
#endif
|
||||
#if ESP_ARDUINO_VERSION <= ESP_ARDUINO_VERSION_VAL(2, 0, 2)
|
||||
#define TONE_LEDC_CHANNEL 1 // Using channel 1 makes tone() independent of receiving timer -> No need to stop receiving timer.
|
||||
void tone(uint8_t aPinNumber, unsigned int aFrequency){
|
||||
ledcAttachPin(aPinNumber, TONE_LEDC_CHANNEL);
|
||||
ledcWriteTone(TONE_LEDC_CHANNEL, aFrequency);
|
||||
}
|
||||
void tone(uint8_t aPinNumber, unsigned int aFrequency, unsigned long aDuration){
|
||||
ledcAttachPin(aPinNumber, TONE_LEDC_CHANNEL);
|
||||
ledcWriteTone(TONE_LEDC_CHANNEL, aFrequency);
|
||||
delay(aDuration);
|
||||
ledcWriteTone(TONE_LEDC_CHANNEL, 0);
|
||||
}
|
||||
void noTone(uint8_t aPinNumber){
|
||||
ledcWriteTone(TONE_LEDC_CHANNEL, 0);
|
||||
}
|
||||
#endif // ESP_ARDUINO_VERSION <= ESP_ARDUINO_VERSION_VAL(2, 0, 2)
|
||||
|
||||
#define IR_RECEIVE_PIN 15 // D15
|
||||
#define IR_SEND_PIN 4 // D4
|
||||
#define TONE_PIN 27 // D27 25 & 26 are DAC0 and 1
|
||||
#define APPLICATION_PIN 16 // RX2 pin
|
||||
|
||||
#elif defined(ARDUINO_ARCH_STM32) || defined(ARDUINO_ARCH_STM32F1) // BluePill
|
||||
// Timer 3 blocks PA6, PA7, PB0, PB1 for use by Servo or tone()
|
||||
#define IR_RECEIVE_PIN PA6
|
||||
#define IR_RECEIVE_PIN_STRING "PA6"
|
||||
#define IR_SEND_PIN PA7
|
||||
#define IR_SEND_PIN_STRING "PA7"
|
||||
#define TONE_PIN PA3
|
||||
#define _IR_TIMING_TEST_PIN PA5
|
||||
#define APPLICATION_PIN PA2
|
||||
#define APPLICATION_PIN_STRING "PA2"
|
||||
# if defined(ARDUINO_GENERIC_STM32F103C) || defined(ARDUINO_BLUEPILL_F103C8)
|
||||
// BluePill LED is active low
|
||||
#define FEEDBACK_LED_IS_ACTIVE_LOW
|
||||
# endif
|
||||
|
||||
#elif defined(ARDUINO_ARCH_APOLLO3) // Sparkfun Apollo boards
|
||||
#define IR_RECEIVE_PIN 11
|
||||
#define IR_SEND_PIN 12
|
||||
#define TONE_PIN 5
|
||||
|
||||
#elif defined(ARDUINO_ARCH_MBED) && defined(ARDUINO_ARCH_MBED_NANO) // Arduino Nano 33 BLE and Arduino Nano Connect layout for MBED
|
||||
// Must be before ARDUINO_ARCH_RP2040, since it is the layout for the MBED core of Arduino Nano Connect
|
||||
#define IR_RECEIVE_PIN 3 // GPIO15 Start with pin 3 since pin 2|GPIO25 is connected to LED on Pi pico
|
||||
#define IR_SEND_PIN 4 // GPIO16
|
||||
#define TONE_PIN 5
|
||||
#define APPLICATION_PIN 6
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 7 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 8
|
||||
|
||||
#elif defined(ARDUINO_ARCH_RP2040) // Arduino Nano Connect, Pi Pico with arduino-pico core https://github.com/earlephilhower/arduino-pico
|
||||
#define IR_RECEIVE_PIN 15 // GPIO15 to be compatible with the Arduino Nano RP2040 Connect (pin3)
|
||||
#define IR_SEND_PIN 16 // GPIO16
|
||||
#define TONE_PIN 17
|
||||
#define APPLICATION_PIN 18
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 19 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 20
|
||||
|
||||
// If you program the Nano RP2040 Connect with this core, then you must redefine LED_BUILTIN
|
||||
// and use the external reset with 1 kOhm to ground to enter UF2 mode
|
||||
#undef LED_BUILTIN
|
||||
#define LED_BUILTIN 6
|
||||
|
||||
#elif defined(PARTICLE) // !!!UNTESTED!!!
|
||||
#define IR_RECEIVE_PIN A4
|
||||
#define IR_SEND_PIN A5 // Particle supports multiple pins
|
||||
|
||||
#define LED_BUILTIN D7
|
||||
|
||||
/*
|
||||
* 4 times the same (default) layout for easy adaption in the future
|
||||
*/
|
||||
#elif defined(TEENSYDUINO) // Teensy 2.0 is handled at default for ATmega328 like on Uno, Nano, Leonardo etc.
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
#elif defined(ARDUINO_ARCH_MBED) // Arduino Nano 33 BLE
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
#elif defined(ARDUINO_ARCH_SAMD) || defined(ARDUINO_ARCH_SAM)
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
#if !defined(ARDUINO_SAMD_ADAFRUIT) && !defined(ARDUINO_SEEED_XIAO_M0)
|
||||
// On the Zero and others we switch explicitly to SerialUSB
|
||||
#define Serial SerialUSB
|
||||
#endif
|
||||
|
||||
// Definitions for the Chinese SAMD21 M0-Mini clone, which has no led connected to D13/PA17.
|
||||
// Attention!!! D2 and D4 are swapped on these boards!!!
|
||||
// If you connect the LED, it is on pin 24/PB11. In this case activate the next two lines.
|
||||
//#undef LED_BUILTIN
|
||||
//#define LED_BUILTIN 24 // PB11
|
||||
// As an alternative you can choose pin 25, it is the RX-LED pin (PB03), but active low.In this case activate the next 3 lines.
|
||||
//#undef LED_BUILTIN
|
||||
//#define LED_BUILTIN 25 // PB03
|
||||
//#define FEEDBACK_LED_IS_ACTIVE_LOW // The RX LED on the M0-Mini is active LOW
|
||||
|
||||
#elif defined (NRF51) // BBC micro:bit
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define APPLICATION_PIN 1
|
||||
#define _IR_TIMING_TEST_PIN 4
|
||||
|
||||
#define tone(...) void() // no tone() available
|
||||
#define noTone(a) void()
|
||||
#define TONE_PIN 42 // Dummy for examples using it
|
||||
|
||||
#else
|
||||
#warning Board / CPU is not detected using pre-processor symbols -> using default values, which may not fit. Please extend PinDefinitionsAndMore.h.
|
||||
// Default valued for unidentified boards
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
#endif // defined(ESP8266)
|
||||
|
||||
#if defined(ESP32) || defined(ARDUINO_ARCH_RP2040) || defined(PARTICLE) || defined(ARDUINO_ARCH_MBED)
|
||||
#define SEND_PWM_BY_TIMER // We do not have pin restrictions for this CPU's, so lets use the hardware PWM for send carrier signal generation
|
||||
#else
|
||||
# if defined(SEND_PWM_BY_TIMER)
|
||||
#undef IR_SEND_PIN // SendPin is determined by timer! This avoids warnings in IRremote.hpp and IRTimer.hpp
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if !defined (FLASHEND)
|
||||
#define FLASHEND 0xFFFF // Dummy value for platforms where FLASHEND is not defined
|
||||
#endif
|
||||
|
||||
/*
|
||||
* 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
|
||||
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
* SimpleSender.cpp
|
||||
*
|
||||
* Demonstrates sending IR codes in standard format with address and command
|
||||
* An extended example for sending can be found as SendDemo.
|
||||
*
|
||||
* Copyright (C) 2020-2022 Armin Joachimsmeyer
|
||||
* armin.joachimsmeyer@gmail.com
|
||||
*
|
||||
* This file is part of Arduino-IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
|
||||
*
|
||||
* MIT License
|
||||
*/
|
||||
#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 IR_SEND_PIN 3 // P0_0
|
||||
|
||||
#include <IRremote.hpp> // include the library
|
||||
|
||||
void setup() {
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
|
||||
Serial.begin(9600);
|
||||
while (!Serial)
|
||||
; // Wait for Serial to become available. Is optimized away for some cores.
|
||||
|
||||
// Just to know which program is running on my Arduino
|
||||
Serial.println(F("START " __FILE__ " from " __DATE__ "\r\nUsing library version " VERSION_IRREMOTE));
|
||||
Serial.print(F("Send IR signals at pin "));
|
||||
Serial.println(IR_SEND_PIN);
|
||||
|
||||
/*
|
||||
* The IR library setup. That's all!
|
||||
*/
|
||||
IrSender.begin(); // Start with IR_SEND_PIN -which is defined in PinDefinitionsAndMore.h- as send pin and enable feedback LED at default feedback LED pin
|
||||
disableLEDFeedback(); // Disable feedback LED at default feedback LED pin
|
||||
}
|
||||
|
||||
/*
|
||||
* Set up the data to be sent.
|
||||
* For most protocols, the data is build up with a constant 8 (or 16 byte) address
|
||||
* and a variable 8 bit command.
|
||||
* There are exceptions like Sony and Denon, which have 5 bit address.
|
||||
*/
|
||||
uint8_t sCommand = 0x34;
|
||||
uint8_t sRepeats = 0;
|
||||
|
||||
void loop() {
|
||||
/*
|
||||
* Print current send values
|
||||
*/
|
||||
Serial.println();
|
||||
Serial.print(F("Send now: address=0x00, command=0x"));
|
||||
Serial.print(sCommand, HEX);
|
||||
Serial.print(F(", repeats="));
|
||||
Serial.print(sRepeats);
|
||||
Serial.println();
|
||||
|
||||
Serial.println(F("Send standard NEC with 8 bit address"));
|
||||
Serial.flush();
|
||||
|
||||
// Receiver output for the first loop must be: Protocol=NEC Address=0x102 Command=0x34 Raw-Data=0xCB340102 (32 bits)
|
||||
IrSender.sendNEC(0x00, sCommand, sRepeats);
|
||||
|
||||
/*
|
||||
* If you want to send a raw HEX value directly like e.g. 0xCB340102 you must use sendNECRaw()
|
||||
*/
|
||||
// Serial.println(F("Send 32 bit LSB 0xCB340102 with NECRaw()"));
|
||||
// IrSender.sendNECRaw(0xCB340102, sRepeats);
|
||||
|
||||
/*
|
||||
* If you want to send an "old" MSB HEX value used by IRremote versions before 3.0 like e.g. 0x40802CD3 you must use sendNECMSB()
|
||||
*/
|
||||
// Serial.println(F("Send old 32 bit MSB 0x40802CD3 with sendNECMSB()"));
|
||||
// IrSender.sendNECMSB(0x40802CD3, 32, sRepeats);
|
||||
|
||||
/*
|
||||
* Increment send values
|
||||
*/
|
||||
sCommand += 0x11;
|
||||
sRepeats++;
|
||||
// clip repeats at 4
|
||||
if (sRepeats > 4) {
|
||||
sRepeats = 4;
|
||||
}
|
||||
|
||||
delay(1000); // delay must be greater than 5 ms (RECORD_GAP_MICROS), otherwise the receiver sees it as one long signal
|
||||
}
|
||||
@@ -0,0 +1,349 @@
|
||||
/*
|
||||
* PinDefinitionsAndMore.h
|
||||
*
|
||||
* Contains pin definitions for IRremote examples for various platforms
|
||||
* as well as definitions for feedback LED and tone() and includes
|
||||
*
|
||||
* Copyright (C) 2021-2023 Armin Joachimsmeyer
|
||||
* armin.joachimsmeyer@gmail.com
|
||||
*
|
||||
* This file is part of IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
|
||||
*
|
||||
* Arduino-IRremote is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/gpl.html>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Pin mapping table for different platforms
|
||||
*
|
||||
* Platform IR input IR output Tone Core/Pin schema
|
||||
* --------------------------------------------------------------
|
||||
* DEFAULT/AVR 2 3 4 Arduino
|
||||
* ATtinyX5 0|PB0 4|PB4 3|PB3 ATTinyCore
|
||||
* ATtiny167 3|PA3 2|PA2 7|PA7 ATTinyCore
|
||||
* ATtiny167 9|PA3 8|PA2 5|PA7 Digispark original core
|
||||
* ATtiny84 |PB2 |PA4 |PA3 ATTinyCore
|
||||
* ATtiny88 3|PD3 4|PD4 9|PB1 ATTinyCore
|
||||
* ATtiny3217 18|PA1 19|PA2 20|PA3 MegaTinyCore
|
||||
* ATtiny1604 2 3|PA5 %
|
||||
* ATtiny816 14|PA1 16|PA3 1|PA5 MegaTinyCore
|
||||
* ATtiny1614 8|PA1 10|PA3 1|PA5 MegaTinyCore
|
||||
* SAMD21 3 4 5
|
||||
* ESP8266 14|D5 12|D6 %
|
||||
* ESP32 15 4 27
|
||||
* ESP32-C3 2 3 4
|
||||
* BluePill PA6 PA7 PA3
|
||||
* APOLLO3 11 12 5
|
||||
* RP2040 3|GPIO15 4|GPIO16 5|GPIO17
|
||||
*/
|
||||
//#define _IR_MEASURE_TIMING // For debugging purposes.
|
||||
|
||||
#if defined(__AVR__)
|
||||
#if defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__) // Digispark board. For use with ATTinyCore.
|
||||
#include "ATtinySerialOut.hpp" // TX is at pin 2 - Available as Arduino library "ATtinySerialOut". Saves 700 bytes program memory and 70 bytes RAM for ATtinyCore.
|
||||
#define IR_RECEIVE_PIN PIN_PB0
|
||||
#define IR_SEND_PIN PIN_PB4 // Pin 2 is serial output with ATtinySerialOut. Pin 1 is internal LED and Pin3 is USB+ with pullup on Digispark board.
|
||||
#define TONE_PIN PIN_PB3
|
||||
#define _IR_TIMING_TEST_PIN PIN_PB3
|
||||
|
||||
# elif defined(__AVR_ATtiny87__) || defined(__AVR_ATtiny167__) // Digispark pro board
|
||||
#include "ATtinySerialOut.hpp" // Available as Arduino library "ATtinySerialOut"
|
||||
// For ATtiny167 Pins PB6 and PA3 are usable as interrupt source.
|
||||
# if defined(ARDUINO_AVR_DIGISPARKPRO)
|
||||
// For use with Digispark original core
|
||||
#define IR_RECEIVE_PIN 9 // PA3 - on Digispark board labeled as pin 9
|
||||
//#define IR_RECEIVE_PIN 14 // PB6 / INT0 is connected to USB+ on DigisparkPro boards
|
||||
#define IR_SEND_PIN 8 // PA2 - on Digispark board labeled as pin 8
|
||||
#define TONE_PIN 5 // PA7 - on Digispark board labeled as pin 5
|
||||
#define _IR_TIMING_TEST_PIN 10 // PA4
|
||||
# else
|
||||
// For use with ATTinyCore
|
||||
#define IR_RECEIVE_PIN PIN_PA3 // On Digispark board labeled as pin 9 - INT0 is connected to USB+ on DigisparkPro boards
|
||||
#define IR_SEND_PIN PIN_PA2 // On Digispark board labeled as pin 8
|
||||
#define TONE_PIN PIN_PA7 // On Digispark board labeled as pin 5
|
||||
# endif
|
||||
|
||||
# elif defined(__AVR_ATtiny84__) // For use with ATTinyCore
|
||||
#include "ATtinySerialOut.hpp" // Available as Arduino library "ATtinySerialOut". Saves 128 bytes program memory.
|
||||
#define IR_RECEIVE_PIN PIN_PB2 // INT0
|
||||
#define IR_SEND_PIN PIN_PA4
|
||||
#define TONE_PIN PIN_PA3
|
||||
#define _IR_TIMING_TEST_PIN PIN_PA5
|
||||
|
||||
# elif defined(__AVR_ATtiny88__) // MH-ET Tiny88 board. For use with ATTinyCore.
|
||||
#include "ATtinySerialOut.hpp" // Available as Arduino library "ATtinySerialOut". Saves 128 bytes program memory.
|
||||
// Pin 6 is TX, pin 7 is RX
|
||||
#define IR_RECEIVE_PIN PIN_PD3 // 3 - INT1
|
||||
#define IR_SEND_PIN PIN_PD4 // 4
|
||||
#define TONE_PIN PIN_PB1 // 9
|
||||
#define _IR_TIMING_TEST_PIN PIN_PB0 // 8
|
||||
|
||||
# elif defined(__AVR_ATtiny1616__) || defined(__AVR_ATtiny3216__) || defined(__AVR_ATtiny3217__) // For use with megaTinyCore
|
||||
// Tiny Core Dev board
|
||||
// https://www.tindie.com/products/xkimi/tiny-core-16-dev-board-attiny1616/ - Out of Stock
|
||||
// https://www.tindie.com/products/xkimi/tiny-core-32-dev-board-attiny3217/ - Out of Stock
|
||||
#define IR_RECEIVE_PIN PIN_PA1 // use 18 instead of PIN_PA1 for TinyCore32
|
||||
#define IR_SEND_PIN PIN_PA2 // 19
|
||||
#define TONE_PIN PIN_PA3 // 20
|
||||
#define APPLICATION_PIN PIN_PA0 // 0
|
||||
#undef LED_BUILTIN // No LED available on the TinyCore 32 board, take the one on the programming board which is connected to the DAC output
|
||||
#define LED_BUILTIN PIN_PA6 // use 2 instead of PIN_PA6 for TinyCore32
|
||||
|
||||
# elif defined(__AVR_ATtiny816__) // For use with megaTinyCore
|
||||
#define IR_RECEIVE_PIN PIN_PA1 // 14
|
||||
#define IR_SEND_PIN PIN_PA1 // 16
|
||||
#define TONE_PIN PIN_PA5 // 1
|
||||
#define APPLICATION_PIN PIN_PA4 // 0
|
||||
#undef LED_BUILTIN // No LED available, take the one which is connected to the DAC output
|
||||
#define LED_BUILTIN PIN_PB5 // 4
|
||||
|
||||
# elif defined(__AVR_ATtiny1614__) // For use with megaTinyCore
|
||||
#define IR_RECEIVE_PIN PIN_PA1 // 8
|
||||
#define IR_SEND_PIN PIN_PA3 // 10
|
||||
#define TONE_PIN PIN_PA5 // 1
|
||||
#define APPLICATION_PIN PIN_PA4 // 0
|
||||
|
||||
# elif defined(__AVR_ATtiny1604__) // For use with megaTinyCore
|
||||
#define IR_RECEIVE_PIN PIN_PA6 // 2 - To be compatible with interrupt example, pin 2 is chosen here.
|
||||
#define IR_SEND_PIN PIN_PA7 // 3
|
||||
#define APPLICATION_PIN PIN_PB2 // 5
|
||||
|
||||
#define tone(...) void() // Define as void, since TCB0_INT_vect is also used by tone()
|
||||
#define noTone(a) void()
|
||||
#define TONE_PIN 42 // Dummy for examples using it
|
||||
|
||||
# elif defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) \
|
||||
|| defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) \
|
||||
|| defined(__AVR_ATmega324P__) || defined(__AVR_ATmega324A__) \
|
||||
|| defined(__AVR_ATmega324PA__) || defined(__AVR_ATmega164A__) \
|
||||
|| defined(__AVR_ATmega164P__) || defined(__AVR_ATmega32__) \
|
||||
|| defined(__AVR_ATmega16__) || defined(__AVR_ATmega8535__) \
|
||||
|| defined(__AVR_ATmega64__) || defined(__AVR_ATmega128__) \
|
||||
|| defined(__AVR_ATmega1281__) || defined(__AVR_ATmega2561__) \
|
||||
|| defined(__AVR_ATmega8515__) || defined(__AVR_ATmega162__)
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 13
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
# else // Default as for ATmega328 like on Uno, Nano, Leonardo, Teensy 2.0 etc.
|
||||
#define IR_RECEIVE_PIN 2 // To be compatible with interrupt example, pin 2 is chosen here.
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
# if defined(ARDUINO_AVR_PROMICRO) // Sparkfun Pro Micro is __AVR_ATmega32U4__ but has different external circuit
|
||||
// We have no built in LED at pin 13 -> reuse RX LED
|
||||
#undef LED_BUILTIN
|
||||
#define LED_BUILTIN LED_BUILTIN_RX
|
||||
# endif
|
||||
# endif // defined(__AVR_ATtiny25__)...
|
||||
|
||||
#elif defined(ARDUINO_ARCH_RENESAS_UNO) // Uno R4
|
||||
// To be compatible with Uno R3.
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
#elif defined(ESP8266)
|
||||
#define FEEDBACK_LED_IS_ACTIVE_LOW // The LED on my board (D4) is active LOW
|
||||
#define IR_RECEIVE_PIN 14 // D5
|
||||
#define IR_SEND_PIN 12 // D6 - D4/pin 2 is internal LED
|
||||
#define _IR_TIMING_TEST_PIN 2 // D4
|
||||
#define APPLICATION_PIN 13 // D7
|
||||
|
||||
#define tone(...) void() // tone() inhibits receive timer
|
||||
#define noTone(a) void()
|
||||
#define TONE_PIN 42 // Dummy for examples using it#
|
||||
|
||||
#elif defined(ARDUINO_NOLOGO_ESP32C3_SUPER_MINI)
|
||||
#define FEEDBACK_LED_IS_ACTIVE_LOW // The LED on my board (D8) is active LOW
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 10
|
||||
|
||||
#elif defined(CONFIG_IDF_TARGET_ESP32C3) || defined(ARDUINO_ESP32C3_DEV)
|
||||
#define NO_LED_FEEDBACK_CODE // The WS2812 on pin 8 of AI-C3 board crashes if used as receive feedback LED, other I/O pins are working...
|
||||
#define IR_RECEIVE_PIN 6
|
||||
#define IR_SEND_PIN 7
|
||||
#define TONE_PIN 10
|
||||
#define APPLICATION_PIN 18
|
||||
|
||||
#elif defined(ESP32)
|
||||
#include <Arduino.h>
|
||||
|
||||
// tone() is included in ESP32 core since 2.0.2
|
||||
#if !defined(ESP_ARDUINO_VERSION_VAL)
|
||||
#define ESP_ARDUINO_VERSION_VAL(major, minor, patch) 12345678
|
||||
#endif
|
||||
#if ESP_ARDUINO_VERSION <= ESP_ARDUINO_VERSION_VAL(2, 0, 2)
|
||||
#define TONE_LEDC_CHANNEL 1 // Using channel 1 makes tone() independent of receiving timer -> No need to stop receiving timer.
|
||||
void tone(uint8_t aPinNumber, unsigned int aFrequency){
|
||||
ledcAttachPin(aPinNumber, TONE_LEDC_CHANNEL);
|
||||
ledcWriteTone(TONE_LEDC_CHANNEL, aFrequency);
|
||||
}
|
||||
void tone(uint8_t aPinNumber, unsigned int aFrequency, unsigned long aDuration){
|
||||
ledcAttachPin(aPinNumber, TONE_LEDC_CHANNEL);
|
||||
ledcWriteTone(TONE_LEDC_CHANNEL, aFrequency);
|
||||
delay(aDuration);
|
||||
ledcWriteTone(TONE_LEDC_CHANNEL, 0);
|
||||
}
|
||||
void noTone(uint8_t aPinNumber){
|
||||
ledcWriteTone(TONE_LEDC_CHANNEL, 0);
|
||||
}
|
||||
#endif // ESP_ARDUINO_VERSION <= ESP_ARDUINO_VERSION_VAL(2, 0, 2)
|
||||
|
||||
#define IR_RECEIVE_PIN 15 // D15
|
||||
#define IR_SEND_PIN 4 // D4
|
||||
#define TONE_PIN 27 // D27 25 & 26 are DAC0 and 1
|
||||
#define APPLICATION_PIN 16 // RX2 pin
|
||||
|
||||
#elif defined(ARDUINO_ARCH_STM32) || defined(ARDUINO_ARCH_STM32F1) // BluePill
|
||||
// Timer 3 blocks PA6, PA7, PB0, PB1 for use by Servo or tone()
|
||||
#define IR_RECEIVE_PIN PA6
|
||||
#define IR_RECEIVE_PIN_STRING "PA6"
|
||||
#define IR_SEND_PIN PA7
|
||||
#define IR_SEND_PIN_STRING "PA7"
|
||||
#define TONE_PIN PA3
|
||||
#define _IR_TIMING_TEST_PIN PA5
|
||||
#define APPLICATION_PIN PA2
|
||||
#define APPLICATION_PIN_STRING "PA2"
|
||||
# if defined(ARDUINO_GENERIC_STM32F103C) || defined(ARDUINO_BLUEPILL_F103C8)
|
||||
// BluePill LED is active low
|
||||
#define FEEDBACK_LED_IS_ACTIVE_LOW
|
||||
# endif
|
||||
|
||||
#elif defined(ARDUINO_ARCH_APOLLO3) // Sparkfun Apollo boards
|
||||
#define IR_RECEIVE_PIN 11
|
||||
#define IR_SEND_PIN 12
|
||||
#define TONE_PIN 5
|
||||
|
||||
#elif defined(ARDUINO_ARCH_MBED) && defined(ARDUINO_ARCH_MBED_NANO) // Arduino Nano 33 BLE and Arduino Nano Connect layout for MBED
|
||||
// Must be before ARDUINO_ARCH_RP2040, since it is the layout for the MBED core of Arduino Nano Connect
|
||||
#define IR_RECEIVE_PIN 3 // GPIO15 Start with pin 3 since pin 2|GPIO25 is connected to LED on Pi pico
|
||||
#define IR_SEND_PIN 4 // GPIO16
|
||||
#define TONE_PIN 5
|
||||
#define APPLICATION_PIN 6
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 7 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 8
|
||||
|
||||
#elif defined(ARDUINO_ARCH_RP2040) // Arduino Nano Connect, Pi Pico with arduino-pico core https://github.com/earlephilhower/arduino-pico
|
||||
#define IR_RECEIVE_PIN 15 // GPIO15 to be compatible with the Arduino Nano RP2040 Connect (pin3)
|
||||
#define IR_SEND_PIN 16 // GPIO16
|
||||
#define TONE_PIN 17
|
||||
#define APPLICATION_PIN 18
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 19 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 20
|
||||
|
||||
// If you program the Nano RP2040 Connect with this core, then you must redefine LED_BUILTIN
|
||||
// and use the external reset with 1 kOhm to ground to enter UF2 mode
|
||||
#undef LED_BUILTIN
|
||||
#define LED_BUILTIN 6
|
||||
|
||||
#elif defined(PARTICLE) // !!!UNTESTED!!!
|
||||
#define IR_RECEIVE_PIN A4
|
||||
#define IR_SEND_PIN A5 // Particle supports multiple pins
|
||||
|
||||
#define LED_BUILTIN D7
|
||||
|
||||
/*
|
||||
* 4 times the same (default) layout for easy adaption in the future
|
||||
*/
|
||||
#elif defined(TEENSYDUINO) // Teensy 2.0 is handled at default for ATmega328 like on Uno, Nano, Leonardo etc.
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
#elif defined(ARDUINO_ARCH_MBED) // Arduino Nano 33 BLE
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
#elif defined(ARDUINO_ARCH_SAMD) || defined(ARDUINO_ARCH_SAM)
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
#if !defined(ARDUINO_SAMD_ADAFRUIT) && !defined(ARDUINO_SEEED_XIAO_M0)
|
||||
// On the Zero and others we switch explicitly to SerialUSB
|
||||
#define Serial SerialUSB
|
||||
#endif
|
||||
|
||||
// Definitions for the Chinese SAMD21 M0-Mini clone, which has no led connected to D13/PA17.
|
||||
// Attention!!! D2 and D4 are swapped on these boards!!!
|
||||
// If you connect the LED, it is on pin 24/PB11. In this case activate the next two lines.
|
||||
//#undef LED_BUILTIN
|
||||
//#define LED_BUILTIN 24 // PB11
|
||||
// As an alternative you can choose pin 25, it is the RX-LED pin (PB03), but active low.In this case activate the next 3 lines.
|
||||
//#undef LED_BUILTIN
|
||||
//#define LED_BUILTIN 25 // PB03
|
||||
//#define FEEDBACK_LED_IS_ACTIVE_LOW // The RX LED on the M0-Mini is active LOW
|
||||
|
||||
#elif defined (NRF51) // BBC micro:bit
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define APPLICATION_PIN 1
|
||||
#define _IR_TIMING_TEST_PIN 4
|
||||
|
||||
#define tone(...) void() // no tone() available
|
||||
#define noTone(a) void()
|
||||
#define TONE_PIN 42 // Dummy for examples using it
|
||||
|
||||
#else
|
||||
#warning Board / CPU is not detected using pre-processor symbols -> using default values, which may not fit. Please extend PinDefinitionsAndMore.h.
|
||||
// Default valued for unidentified boards
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
#endif // defined(ESP8266)
|
||||
|
||||
#if defined(ESP32) || defined(ARDUINO_ARCH_RP2040) || defined(PARTICLE) || defined(ARDUINO_ARCH_MBED)
|
||||
#define SEND_PWM_BY_TIMER // We do not have pin restrictions for this CPU's, so lets use the hardware PWM for send carrier signal generation
|
||||
#else
|
||||
# if defined(SEND_PWM_BY_TIMER)
|
||||
#undef IR_SEND_PIN // SendPin is determined by timer! This avoids warnings in IRremote.hpp and IRTimer.hpp
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if !defined (FLASHEND)
|
||||
#define FLASHEND 0xFFFF // Dummy value for platforms where FLASHEND is not defined
|
||||
#endif
|
||||
|
||||
/*
|
||||
* 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
|
||||
@@ -0,0 +1,147 @@
|
||||
/*
|
||||
* TinyReceiver.cpp
|
||||
*
|
||||
* Small memory footprint and no timer usage!
|
||||
*
|
||||
* Receives IR protocol data of NEC protocol using pin change interrupts.
|
||||
* On complete received IR command the function handleReceivedIRData(uint16_t aAddress, uint8_t aCommand, uint8_t aFlags)
|
||||
* is called in Interrupt context but with interrupts being enabled to enable use of delay() etc.
|
||||
* !!!!!!!!!!!!!!!!!!!!!!
|
||||
* Functions called in interrupt context should be running as short as possible,
|
||||
* so if you require longer action, save the data (address + command) and handle it in the main loop.
|
||||
* !!!!!!!!!!!!!!!!!!!!!
|
||||
*
|
||||
* The FAST protocol is a proprietary modified JVC protocol without address, with parity and with a shorter header.
|
||||
* FAST Protocol characteristics:
|
||||
* - Bit timing is like NEC or JVC
|
||||
* - The header is shorter, 3156 vs. 12500
|
||||
* - No address and 16 bit data, interpreted as 8 bit command and 8 bit inverted command,
|
||||
* leading to a fixed protocol length of (6 + (16 * 3) + 1) * 526 = 55 * 526 = 28930 microseconds or 29 ms.
|
||||
* - Repeats are sent as complete frames but in a 50 ms period / with a 21 ms distance.
|
||||
*
|
||||
*
|
||||
* This file is part of IRMP https://github.com/IRMP-org/IRMP.
|
||||
* This file is part of Arduino-IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
|
||||
*
|
||||
************************************************************************************
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2022-2024 Armin Joachimsmeyer
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is furnished
|
||||
* to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
************************************************************************************
|
||||
*/
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
// IR_RECEIVE_PIN must be avialable to use in attachInterrupt()
|
||||
#define IR_RECEIVE_PIN 4 // 4 P1_9
|
||||
|
||||
|
||||
/*
|
||||
* Protocol selection
|
||||
*/
|
||||
//#define DISABLE_PARITY_CHECKS // Disable parity checks. Saves 48 bytes of program memory.
|
||||
//#define USE_EXTENDED_NEC_PROTOCOL // Like NEC, but take the 16 bit address as one 16 bit value and not as 8 bit normal and 8 bit inverted value.
|
||||
//#define USE_ONKYO_PROTOCOL // Like NEC, but take the 16 bit address and command each as one 16 bit value and not as 8 bit normal and 8 bit inverted value.
|
||||
//#define USE_FAST_PROTOCOL // Use FAST protocol instead of NEC / ONKYO.
|
||||
//#define ENABLE_NEC2_REPEATS // Instead of sending / receiving the NEC special repeat code, send / receive the original frame for repeat.
|
||||
/*
|
||||
* Set compile options to modify the generated code.
|
||||
*/
|
||||
//#define DISABLE_PARITY_CHECKS // Disable parity checks. Saves 48 bytes of program memory.
|
||||
//#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
|
||||
*/
|
||||
#if !defined(STR_HELPER)
|
||||
#define STR_HELPER(x) #x
|
||||
#define STR(x) STR_HELPER(x)
|
||||
#endif
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
while (!Serial)
|
||||
; // Wait for Serial to become available. Is optimized away for some cores.
|
||||
|
||||
// Just to know which program is running on my Arduino
|
||||
Serial.println(F("START " __FILE__ " from " __DATE__ "\r\nUsing library version " VERSION_TINYIR));
|
||||
|
||||
// Enables the interrupt generation on change of IR input signal
|
||||
if (!initPCIInterruptForTinyReceiver()) {
|
||||
Serial.println(F("No interrupt available for pin " STR(IR_RECEIVE_PIN))); // optimized out by the compiler, if not required :-)
|
||||
}
|
||||
#if defined(USE_FAST_PROTOCOL)
|
||||
Serial.println(F("Ready to receive Fast IR signals at pin " STR(IR_RECEIVE_PIN)));
|
||||
#else
|
||||
Serial.println(F("Ready to receive NEC IR signals at pin " STR(IR_RECEIVE_PIN)));
|
||||
#endif
|
||||
}
|
||||
|
||||
void loop() {
|
||||
if (TinyReceiverDecode()) {
|
||||
|
||||
#if !defined(USE_FAST_PROTOCOL)
|
||||
// We have no address at FAST protocol
|
||||
Serial.print(F("Address=0x"));
|
||||
Serial.print(TinyIRReceiverData.Address, HEX);
|
||||
Serial.print(' ');
|
||||
#endif
|
||||
|
||||
Serial.print(F("Command=0x"));
|
||||
Serial.print(TinyIRReceiverData.Command, HEX);
|
||||
if (TinyIRReceiverData.Flags == IRDATA_FLAGS_IS_REPEAT) {
|
||||
Serial.print(F(" Repeat"));
|
||||
}
|
||||
if (TinyIRReceiverData.Flags == IRDATA_FLAGS_PARITY_FAILED) {
|
||||
Serial.print(F(" Parity failed"));
|
||||
|
||||
#if !defined(USE_EXTENDED_NEC_PROTOCOL) && !defined(USE_ONKYO_PROTOCOL)
|
||||
Serial.print(F(", try USE_EXTENDED_NEC_PROTOCOL or USE_ONKYO_PROTOCOL"));
|
||||
#endif
|
||||
|
||||
}
|
||||
Serial.println();
|
||||
}
|
||||
/*
|
||||
* Put your code here
|
||||
*/
|
||||
|
||||
/*
|
||||
* No resume() required :-)
|
||||
*/
|
||||
}
|
||||
|
||||
/*
|
||||
* Optional code, if you require a callback
|
||||
*/
|
||||
#if defined(USE_CALLBACK_FOR_TINY_RECEIVER)
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
|
||||
void handleReceivedTinyIRData() {
|
||||
// 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
|
||||
|
||||
@@ -0,0 +1,349 @@
|
||||
/*
|
||||
* PinDefinitionsAndMore.h
|
||||
*
|
||||
* Contains pin definitions for IRremote examples for various platforms
|
||||
* as well as definitions for feedback LED and tone() and includes
|
||||
*
|
||||
* Copyright (C) 2021-2023 Armin Joachimsmeyer
|
||||
* armin.joachimsmeyer@gmail.com
|
||||
*
|
||||
* This file is part of IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
|
||||
*
|
||||
* Arduino-IRremote is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/gpl.html>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Pin mapping table for different platforms
|
||||
*
|
||||
* Platform IR input IR output Tone Core/Pin schema
|
||||
* --------------------------------------------------------------
|
||||
* DEFAULT/AVR 2 3 4 Arduino
|
||||
* ATtinyX5 0|PB0 4|PB4 3|PB3 ATTinyCore
|
||||
* ATtiny167 3|PA3 2|PA2 7|PA7 ATTinyCore
|
||||
* ATtiny167 9|PA3 8|PA2 5|PA7 Digispark original core
|
||||
* ATtiny84 |PB2 |PA4 |PA3 ATTinyCore
|
||||
* ATtiny88 3|PD3 4|PD4 9|PB1 ATTinyCore
|
||||
* ATtiny3217 18|PA1 19|PA2 20|PA3 MegaTinyCore
|
||||
* ATtiny1604 2 3|PA5 %
|
||||
* ATtiny816 14|PA1 16|PA3 1|PA5 MegaTinyCore
|
||||
* ATtiny1614 8|PA1 10|PA3 1|PA5 MegaTinyCore
|
||||
* SAMD21 3 4 5
|
||||
* ESP8266 14|D5 12|D6 %
|
||||
* ESP32 15 4 27
|
||||
* ESP32-C3 2 3 4
|
||||
* BluePill PA6 PA7 PA3
|
||||
* APOLLO3 11 12 5
|
||||
* RP2040 3|GPIO15 4|GPIO16 5|GPIO17
|
||||
*/
|
||||
//#define _IR_MEASURE_TIMING // For debugging purposes.
|
||||
|
||||
#if defined(__AVR__)
|
||||
#if defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__) // Digispark board. For use with ATTinyCore.
|
||||
#include "ATtinySerialOut.hpp" // TX is at pin 2 - Available as Arduino library "ATtinySerialOut". Saves 700 bytes program memory and 70 bytes RAM for ATtinyCore.
|
||||
#define IR_RECEIVE_PIN PIN_PB0
|
||||
#define IR_SEND_PIN PIN_PB4 // Pin 2 is serial output with ATtinySerialOut. Pin 1 is internal LED and Pin3 is USB+ with pullup on Digispark board.
|
||||
#define TONE_PIN PIN_PB3
|
||||
#define _IR_TIMING_TEST_PIN PIN_PB3
|
||||
|
||||
# elif defined(__AVR_ATtiny87__) || defined(__AVR_ATtiny167__) // Digispark pro board
|
||||
#include "ATtinySerialOut.hpp" // Available as Arduino library "ATtinySerialOut"
|
||||
// For ATtiny167 Pins PB6 and PA3 are usable as interrupt source.
|
||||
# if defined(ARDUINO_AVR_DIGISPARKPRO)
|
||||
// For use with Digispark original core
|
||||
#define IR_RECEIVE_PIN 9 // PA3 - on Digispark board labeled as pin 9
|
||||
//#define IR_RECEIVE_PIN 14 // PB6 / INT0 is connected to USB+ on DigisparkPro boards
|
||||
#define IR_SEND_PIN 8 // PA2 - on Digispark board labeled as pin 8
|
||||
#define TONE_PIN 5 // PA7 - on Digispark board labeled as pin 5
|
||||
#define _IR_TIMING_TEST_PIN 10 // PA4
|
||||
# else
|
||||
// For use with ATTinyCore
|
||||
#define IR_RECEIVE_PIN PIN_PA3 // On Digispark board labeled as pin 9 - INT0 is connected to USB+ on DigisparkPro boards
|
||||
#define IR_SEND_PIN PIN_PA2 // On Digispark board labeled as pin 8
|
||||
#define TONE_PIN PIN_PA7 // On Digispark board labeled as pin 5
|
||||
# endif
|
||||
|
||||
# elif defined(__AVR_ATtiny84__) // For use with ATTinyCore
|
||||
#include "ATtinySerialOut.hpp" // Available as Arduino library "ATtinySerialOut". Saves 128 bytes program memory.
|
||||
#define IR_RECEIVE_PIN PIN_PB2 // INT0
|
||||
#define IR_SEND_PIN PIN_PA4
|
||||
#define TONE_PIN PIN_PA3
|
||||
#define _IR_TIMING_TEST_PIN PIN_PA5
|
||||
|
||||
# elif defined(__AVR_ATtiny88__) // MH-ET Tiny88 board. For use with ATTinyCore.
|
||||
#include "ATtinySerialOut.hpp" // Available as Arduino library "ATtinySerialOut". Saves 128 bytes program memory.
|
||||
// Pin 6 is TX, pin 7 is RX
|
||||
#define IR_RECEIVE_PIN PIN_PD3 // 3 - INT1
|
||||
#define IR_SEND_PIN PIN_PD4 // 4
|
||||
#define TONE_PIN PIN_PB1 // 9
|
||||
#define _IR_TIMING_TEST_PIN PIN_PB0 // 8
|
||||
|
||||
# elif defined(__AVR_ATtiny1616__) || defined(__AVR_ATtiny3216__) || defined(__AVR_ATtiny3217__) // For use with megaTinyCore
|
||||
// Tiny Core Dev board
|
||||
// https://www.tindie.com/products/xkimi/tiny-core-16-dev-board-attiny1616/ - Out of Stock
|
||||
// https://www.tindie.com/products/xkimi/tiny-core-32-dev-board-attiny3217/ - Out of Stock
|
||||
#define IR_RECEIVE_PIN PIN_PA1 // use 18 instead of PIN_PA1 for TinyCore32
|
||||
#define IR_SEND_PIN PIN_PA2 // 19
|
||||
#define TONE_PIN PIN_PA3 // 20
|
||||
#define APPLICATION_PIN PIN_PA0 // 0
|
||||
#undef LED_BUILTIN // No LED available on the TinyCore 32 board, take the one on the programming board which is connected to the DAC output
|
||||
#define LED_BUILTIN PIN_PA6 // use 2 instead of PIN_PA6 for TinyCore32
|
||||
|
||||
# elif defined(__AVR_ATtiny816__) // For use with megaTinyCore
|
||||
#define IR_RECEIVE_PIN PIN_PA1 // 14
|
||||
#define IR_SEND_PIN PIN_PA1 // 16
|
||||
#define TONE_PIN PIN_PA5 // 1
|
||||
#define APPLICATION_PIN PIN_PA4 // 0
|
||||
#undef LED_BUILTIN // No LED available, take the one which is connected to the DAC output
|
||||
#define LED_BUILTIN PIN_PB5 // 4
|
||||
|
||||
# elif defined(__AVR_ATtiny1614__) // For use with megaTinyCore
|
||||
#define IR_RECEIVE_PIN PIN_PA1 // 8
|
||||
#define IR_SEND_PIN PIN_PA3 // 10
|
||||
#define TONE_PIN PIN_PA5 // 1
|
||||
#define APPLICATION_PIN PIN_PA4 // 0
|
||||
|
||||
# elif defined(__AVR_ATtiny1604__) // For use with megaTinyCore
|
||||
#define IR_RECEIVE_PIN PIN_PA6 // 2 - To be compatible with interrupt example, pin 2 is chosen here.
|
||||
#define IR_SEND_PIN PIN_PA7 // 3
|
||||
#define APPLICATION_PIN PIN_PB2 // 5
|
||||
|
||||
#define tone(...) void() // Define as void, since TCB0_INT_vect is also used by tone()
|
||||
#define noTone(a) void()
|
||||
#define TONE_PIN 42 // Dummy for examples using it
|
||||
|
||||
# elif defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) \
|
||||
|| defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) \
|
||||
|| defined(__AVR_ATmega324P__) || defined(__AVR_ATmega324A__) \
|
||||
|| defined(__AVR_ATmega324PA__) || defined(__AVR_ATmega164A__) \
|
||||
|| defined(__AVR_ATmega164P__) || defined(__AVR_ATmega32__) \
|
||||
|| defined(__AVR_ATmega16__) || defined(__AVR_ATmega8535__) \
|
||||
|| defined(__AVR_ATmega64__) || defined(__AVR_ATmega128__) \
|
||||
|| defined(__AVR_ATmega1281__) || defined(__AVR_ATmega2561__) \
|
||||
|| defined(__AVR_ATmega8515__) || defined(__AVR_ATmega162__)
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 13
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
# else // Default as for ATmega328 like on Uno, Nano, Leonardo, Teensy 2.0 etc.
|
||||
#define IR_RECEIVE_PIN 2 // To be compatible with interrupt example, pin 2 is chosen here.
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
# if defined(ARDUINO_AVR_PROMICRO) // Sparkfun Pro Micro is __AVR_ATmega32U4__ but has different external circuit
|
||||
// We have no built in LED at pin 13 -> reuse RX LED
|
||||
#undef LED_BUILTIN
|
||||
#define LED_BUILTIN LED_BUILTIN_RX
|
||||
# endif
|
||||
# endif // defined(__AVR_ATtiny25__)...
|
||||
|
||||
#elif defined(ARDUINO_ARCH_RENESAS_UNO) // Uno R4
|
||||
// To be compatible with Uno R3.
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
#elif defined(ESP8266)
|
||||
#define FEEDBACK_LED_IS_ACTIVE_LOW // The LED on my board (D4) is active LOW
|
||||
#define IR_RECEIVE_PIN 14 // D5
|
||||
#define IR_SEND_PIN 12 // D6 - D4/pin 2 is internal LED
|
||||
#define _IR_TIMING_TEST_PIN 2 // D4
|
||||
#define APPLICATION_PIN 13 // D7
|
||||
|
||||
#define tone(...) void() // tone() inhibits receive timer
|
||||
#define noTone(a) void()
|
||||
#define TONE_PIN 42 // Dummy for examples using it#
|
||||
|
||||
#elif defined(ARDUINO_NOLOGO_ESP32C3_SUPER_MINI)
|
||||
#define FEEDBACK_LED_IS_ACTIVE_LOW // The LED on my board (D8) is active LOW
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 10
|
||||
|
||||
#elif defined(CONFIG_IDF_TARGET_ESP32C3) || defined(ARDUINO_ESP32C3_DEV)
|
||||
#define NO_LED_FEEDBACK_CODE // The WS2812 on pin 8 of AI-C3 board crashes if used as receive feedback LED, other I/O pins are working...
|
||||
#define IR_RECEIVE_PIN 6
|
||||
#define IR_SEND_PIN 7
|
||||
#define TONE_PIN 10
|
||||
#define APPLICATION_PIN 18
|
||||
|
||||
#elif defined(ESP32)
|
||||
#include <Arduino.h>
|
||||
|
||||
// tone() is included in ESP32 core since 2.0.2
|
||||
#if !defined(ESP_ARDUINO_VERSION_VAL)
|
||||
#define ESP_ARDUINO_VERSION_VAL(major, minor, patch) 12345678
|
||||
#endif
|
||||
#if ESP_ARDUINO_VERSION <= ESP_ARDUINO_VERSION_VAL(2, 0, 2)
|
||||
#define TONE_LEDC_CHANNEL 1 // Using channel 1 makes tone() independent of receiving timer -> No need to stop receiving timer.
|
||||
void tone(uint8_t aPinNumber, unsigned int aFrequency){
|
||||
ledcAttachPin(aPinNumber, TONE_LEDC_CHANNEL);
|
||||
ledcWriteTone(TONE_LEDC_CHANNEL, aFrequency);
|
||||
}
|
||||
void tone(uint8_t aPinNumber, unsigned int aFrequency, unsigned long aDuration){
|
||||
ledcAttachPin(aPinNumber, TONE_LEDC_CHANNEL);
|
||||
ledcWriteTone(TONE_LEDC_CHANNEL, aFrequency);
|
||||
delay(aDuration);
|
||||
ledcWriteTone(TONE_LEDC_CHANNEL, 0);
|
||||
}
|
||||
void noTone(uint8_t aPinNumber){
|
||||
ledcWriteTone(TONE_LEDC_CHANNEL, 0);
|
||||
}
|
||||
#endif // ESP_ARDUINO_VERSION <= ESP_ARDUINO_VERSION_VAL(2, 0, 2)
|
||||
|
||||
#define IR_RECEIVE_PIN 15 // D15
|
||||
#define IR_SEND_PIN 4 // D4
|
||||
#define TONE_PIN 27 // D27 25 & 26 are DAC0 and 1
|
||||
#define APPLICATION_PIN 16 // RX2 pin
|
||||
|
||||
#elif defined(ARDUINO_ARCH_STM32) || defined(ARDUINO_ARCH_STM32F1) // BluePill
|
||||
// Timer 3 blocks PA6, PA7, PB0, PB1 for use by Servo or tone()
|
||||
#define IR_RECEIVE_PIN PA6
|
||||
#define IR_RECEIVE_PIN_STRING "PA6"
|
||||
#define IR_SEND_PIN PA7
|
||||
#define IR_SEND_PIN_STRING "PA7"
|
||||
#define TONE_PIN PA3
|
||||
#define _IR_TIMING_TEST_PIN PA5
|
||||
#define APPLICATION_PIN PA2
|
||||
#define APPLICATION_PIN_STRING "PA2"
|
||||
# if defined(ARDUINO_GENERIC_STM32F103C) || defined(ARDUINO_BLUEPILL_F103C8)
|
||||
// BluePill LED is active low
|
||||
#define FEEDBACK_LED_IS_ACTIVE_LOW
|
||||
# endif
|
||||
|
||||
#elif defined(ARDUINO_ARCH_APOLLO3) // Sparkfun Apollo boards
|
||||
#define IR_RECEIVE_PIN 11
|
||||
#define IR_SEND_PIN 12
|
||||
#define TONE_PIN 5
|
||||
|
||||
#elif defined(ARDUINO_ARCH_MBED) && defined(ARDUINO_ARCH_MBED_NANO) // Arduino Nano 33 BLE and Arduino Nano Connect layout for MBED
|
||||
// Must be before ARDUINO_ARCH_RP2040, since it is the layout for the MBED core of Arduino Nano Connect
|
||||
#define IR_RECEIVE_PIN 3 // GPIO15 Start with pin 3 since pin 2|GPIO25 is connected to LED on Pi pico
|
||||
#define IR_SEND_PIN 4 // GPIO16
|
||||
#define TONE_PIN 5
|
||||
#define APPLICATION_PIN 6
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 7 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 8
|
||||
|
||||
#elif defined(ARDUINO_ARCH_RP2040) // Arduino Nano Connect, Pi Pico with arduino-pico core https://github.com/earlephilhower/arduino-pico
|
||||
#define IR_RECEIVE_PIN 15 // GPIO15 to be compatible with the Arduino Nano RP2040 Connect (pin3)
|
||||
#define IR_SEND_PIN 16 // GPIO16
|
||||
#define TONE_PIN 17
|
||||
#define APPLICATION_PIN 18
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 19 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 20
|
||||
|
||||
// If you program the Nano RP2040 Connect with this core, then you must redefine LED_BUILTIN
|
||||
// and use the external reset with 1 kOhm to ground to enter UF2 mode
|
||||
#undef LED_BUILTIN
|
||||
#define LED_BUILTIN 6
|
||||
|
||||
#elif defined(PARTICLE) // !!!UNTESTED!!!
|
||||
#define IR_RECEIVE_PIN A4
|
||||
#define IR_SEND_PIN A5 // Particle supports multiple pins
|
||||
|
||||
#define LED_BUILTIN D7
|
||||
|
||||
/*
|
||||
* 4 times the same (default) layout for easy adaption in the future
|
||||
*/
|
||||
#elif defined(TEENSYDUINO) // Teensy 2.0 is handled at default for ATmega328 like on Uno, Nano, Leonardo etc.
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
#elif defined(ARDUINO_ARCH_MBED) // Arduino Nano 33 BLE
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
#elif defined(ARDUINO_ARCH_SAMD) || defined(ARDUINO_ARCH_SAM)
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
#if !defined(ARDUINO_SAMD_ADAFRUIT) && !defined(ARDUINO_SEEED_XIAO_M0)
|
||||
// On the Zero and others we switch explicitly to SerialUSB
|
||||
#define Serial SerialUSB
|
||||
#endif
|
||||
|
||||
// Definitions for the Chinese SAMD21 M0-Mini clone, which has no led connected to D13/PA17.
|
||||
// Attention!!! D2 and D4 are swapped on these boards!!!
|
||||
// If you connect the LED, it is on pin 24/PB11. In this case activate the next two lines.
|
||||
//#undef LED_BUILTIN
|
||||
//#define LED_BUILTIN 24 // PB11
|
||||
// As an alternative you can choose pin 25, it is the RX-LED pin (PB03), but active low.In this case activate the next 3 lines.
|
||||
//#undef LED_BUILTIN
|
||||
//#define LED_BUILTIN 25 // PB03
|
||||
//#define FEEDBACK_LED_IS_ACTIVE_LOW // The RX LED on the M0-Mini is active LOW
|
||||
|
||||
#elif defined (NRF51) // BBC micro:bit
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define APPLICATION_PIN 1
|
||||
#define _IR_TIMING_TEST_PIN 4
|
||||
|
||||
#define tone(...) void() // no tone() available
|
||||
#define noTone(a) void()
|
||||
#define TONE_PIN 42 // Dummy for examples using it
|
||||
|
||||
#else
|
||||
#warning Board / CPU is not detected using pre-processor symbols -> using default values, which may not fit. Please extend PinDefinitionsAndMore.h.
|
||||
// Default valued for unidentified boards
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
#endif // defined(ESP8266)
|
||||
|
||||
#if defined(ESP32) || defined(ARDUINO_ARCH_RP2040) || defined(PARTICLE) || defined(ARDUINO_ARCH_MBED)
|
||||
#define SEND_PWM_BY_TIMER // We do not have pin restrictions for this CPU's, so lets use the hardware PWM for send carrier signal generation
|
||||
#else
|
||||
# if defined(SEND_PWM_BY_TIMER)
|
||||
#undef IR_SEND_PIN // SendPin is determined by timer! This avoids warnings in IRremote.hpp and IRTimer.hpp
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if !defined (FLASHEND)
|
||||
#define FLASHEND 0xFFFF // Dummy value for platforms where FLASHEND is not defined
|
||||
#endif
|
||||
|
||||
/*
|
||||
* 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
|
||||
@@ -0,0 +1,138 @@
|
||||
/*
|
||||
* TinySender.cpp
|
||||
*
|
||||
* Example for sending using TinyIR. By default sends simultaneously using all supported protocols
|
||||
* To use a single protocol, simply delete or comment out all unneeded protocols in the main loop
|
||||
* Program size is significantly reduced when using a single protocol
|
||||
* For example, sending only 8 bit address and command NEC codes saves 780 bytes program memory and 26 bytes RAM compared to SimpleSender,
|
||||
* which does the same, but uses the IRRemote library (and is therefore much more flexible).
|
||||
*
|
||||
*
|
||||
* The FAST protocol is a proprietary modified JVC protocol without address, with parity and with a shorter header.
|
||||
* FAST Protocol characteristics:
|
||||
* - Bit timing is like NEC or JVC
|
||||
* - The header is shorter, 3156 vs. 12500
|
||||
* - No address and 16 bit data, interpreted as 8 bit command and 8 bit inverted command,
|
||||
* leading to a fixed protocol length of (6 + (16 * 3) + 1) * 526 = 55 * 526 = 28930 microseconds or 29 ms.
|
||||
* - Repeats are sent as complete frames but in a 50 ms period / with a 21 ms distance.
|
||||
*
|
||||
*
|
||||
* This file is part of IRMP https://github.com/IRMP-org/IRMP.
|
||||
* This file is part of Arduino-IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
|
||||
*
|
||||
************************************************************************************
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2022-2024 Armin Joachimsmeyer
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is furnished
|
||||
* to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
************************************************************************************
|
||||
*/
|
||||
#include <Arduino.h>
|
||||
|
||||
#define IR_SEND_PIN 3 // P0_0
|
||||
|
||||
|
||||
#include "TinyIRSender.hpp"
|
||||
|
||||
void setup() {
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
|
||||
Serial.begin(9600);
|
||||
while (!Serial)
|
||||
; // Wait for Serial to become available. Is optimized away for some cores.
|
||||
|
||||
// Just to know which program is running on my Arduino
|
||||
Serial.println(F("START " __FILE__ " from " __DATE__ "\r\nUsing library version " VERSION_TINYIR));
|
||||
Serial.print(F("Send IR signals at pin "));
|
||||
Serial.println(IR_SEND_PIN);
|
||||
}
|
||||
|
||||
/*
|
||||
* Set up the data to be sent.
|
||||
* The compiler is intelligent and removes the code for 16 bit address handling if we call it with an uint8_t address :-).
|
||||
* Using an uint16_t address or data requires additional 28 bytes program memory for NEC and 56 bytes program memory for FAST.
|
||||
*/
|
||||
uint8_t sAddress = 0x02;
|
||||
//uint16_t sAddress = 0x02;
|
||||
uint8_t sCommand = 0x34;
|
||||
//uint16_t sCommand = 0x34;
|
||||
uint8_t sRepeats = 0;
|
||||
|
||||
void loop() {
|
||||
/*
|
||||
* Print current send values
|
||||
*/
|
||||
Serial.println();
|
||||
Serial.print(F("Send now:"));
|
||||
Serial.print(F(" address=0x"));
|
||||
Serial.print(sAddress, HEX);
|
||||
Serial.print(F(" command=0x"));
|
||||
Serial.print(sCommand, HEX);
|
||||
Serial.print(F(" repeats="));
|
||||
Serial.print(sRepeats);
|
||||
Serial.println();
|
||||
|
||||
// Send with FAST
|
||||
// No address and only 16 bits of data, interpreted as 8 bit command and 8 bit inverted command for parity checking
|
||||
Serial.println(F("Send FAST with 8 bit command"));
|
||||
Serial.flush();
|
||||
sendFAST(IR_SEND_PIN, sCommand, sRepeats);
|
||||
|
||||
// Send with NEC
|
||||
// NEC uses 8 bit address and 8 bit command each with 8 bit inverted parity checks
|
||||
// However, sendNEC will accept 16 bit address and commands too (but remove the parity checks)
|
||||
Serial.println(F("Send NEC with 8 bit address and command"));
|
||||
Serial.flush();
|
||||
sendNEC(IR_SEND_PIN, sAddress, sCommand, sRepeats);
|
||||
|
||||
// Send with Extended NEC
|
||||
// Like NEC, but the address is forced 16 bits with no parity check
|
||||
Serial.println(F("Send ExtendedNEC with 16 bit address and 8 bit command"));
|
||||
Serial.flush();
|
||||
sendExtendedNEC(IR_SEND_PIN, sAddress, sCommand, sRepeats);
|
||||
|
||||
// Send with ONKYO
|
||||
// Like NEC, but both the address and command are forced 16 bits with no parity check
|
||||
Serial.println(F("Send ONKYO with 16 bit address and command"));
|
||||
Serial.flush();
|
||||
sendONKYO(IR_SEND_PIN, sAddress, sCommand, sRepeats);
|
||||
|
||||
// Send with NEC2
|
||||
// Instead of sending the NEC special repeat code, sends the full original frame for repeats
|
||||
// Sending NEC2 is done by setting the optional bool NEC2Repeats argument to true (defaults to false)
|
||||
// sendExtendedNEC and sendONKYO also support the NEC2Repeats argument for full frame repeats (not demonstrated here)
|
||||
Serial.println(F("Send NEC2 with 8 bit address and command and original frame repeats"));
|
||||
Serial.flush();
|
||||
sendNEC(IR_SEND_PIN, sAddress, sCommand, sRepeats, true);
|
||||
|
||||
/*
|
||||
* Increment send values
|
||||
* Also increment address just for demonstration, which normally makes no sense
|
||||
*/
|
||||
sAddress += 0x0101;
|
||||
sCommand += 0x11;
|
||||
sRepeats++;
|
||||
// clip repeats at 4
|
||||
if (sRepeats > 4) {
|
||||
sRepeats = 4;
|
||||
}
|
||||
|
||||
delay(1000); // delay must be greater than 5 ms (RECORD_GAP_MICROS), otherwise the receiver sees it as one long signal
|
||||
}
|
||||
@@ -0,0 +1,349 @@
|
||||
/*
|
||||
* PinDefinitionsAndMore.h
|
||||
*
|
||||
* Contains pin definitions for IRremote examples for various platforms
|
||||
* as well as definitions for feedback LED and tone() and includes
|
||||
*
|
||||
* Copyright (C) 2021-2023 Armin Joachimsmeyer
|
||||
* armin.joachimsmeyer@gmail.com
|
||||
*
|
||||
* This file is part of IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
|
||||
*
|
||||
* Arduino-IRremote is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/gpl.html>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Pin mapping table for different platforms
|
||||
*
|
||||
* Platform IR input IR output Tone Core/Pin schema
|
||||
* --------------------------------------------------------------
|
||||
* DEFAULT/AVR 2 3 4 Arduino
|
||||
* ATtinyX5 0|PB0 4|PB4 3|PB3 ATTinyCore
|
||||
* ATtiny167 3|PA3 2|PA2 7|PA7 ATTinyCore
|
||||
* ATtiny167 9|PA3 8|PA2 5|PA7 Digispark original core
|
||||
* ATtiny84 |PB2 |PA4 |PA3 ATTinyCore
|
||||
* ATtiny88 3|PD3 4|PD4 9|PB1 ATTinyCore
|
||||
* ATtiny3217 18|PA1 19|PA2 20|PA3 MegaTinyCore
|
||||
* ATtiny1604 2 3|PA5 %
|
||||
* ATtiny816 14|PA1 16|PA3 1|PA5 MegaTinyCore
|
||||
* ATtiny1614 8|PA1 10|PA3 1|PA5 MegaTinyCore
|
||||
* SAMD21 3 4 5
|
||||
* ESP8266 14|D5 12|D6 %
|
||||
* ESP32 15 4 27
|
||||
* ESP32-C3 2 3 4
|
||||
* BluePill PA6 PA7 PA3
|
||||
* APOLLO3 11 12 5
|
||||
* RP2040 3|GPIO15 4|GPIO16 5|GPIO17
|
||||
*/
|
||||
//#define _IR_MEASURE_TIMING // For debugging purposes.
|
||||
|
||||
#if defined(__AVR__)
|
||||
#if defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__) // Digispark board. For use with ATTinyCore.
|
||||
#include "ATtinySerialOut.hpp" // TX is at pin 2 - Available as Arduino library "ATtinySerialOut". Saves 700 bytes program memory and 70 bytes RAM for ATtinyCore.
|
||||
#define IR_RECEIVE_PIN PIN_PB0
|
||||
#define IR_SEND_PIN PIN_PB4 // Pin 2 is serial output with ATtinySerialOut. Pin 1 is internal LED and Pin3 is USB+ with pullup on Digispark board.
|
||||
#define TONE_PIN PIN_PB3
|
||||
#define _IR_TIMING_TEST_PIN PIN_PB3
|
||||
|
||||
# elif defined(__AVR_ATtiny87__) || defined(__AVR_ATtiny167__) // Digispark pro board
|
||||
#include "ATtinySerialOut.hpp" // Available as Arduino library "ATtinySerialOut"
|
||||
// For ATtiny167 Pins PB6 and PA3 are usable as interrupt source.
|
||||
# if defined(ARDUINO_AVR_DIGISPARKPRO)
|
||||
// For use with Digispark original core
|
||||
#define IR_RECEIVE_PIN 9 // PA3 - on Digispark board labeled as pin 9
|
||||
//#define IR_RECEIVE_PIN 14 // PB6 / INT0 is connected to USB+ on DigisparkPro boards
|
||||
#define IR_SEND_PIN 8 // PA2 - on Digispark board labeled as pin 8
|
||||
#define TONE_PIN 5 // PA7 - on Digispark board labeled as pin 5
|
||||
#define _IR_TIMING_TEST_PIN 10 // PA4
|
||||
# else
|
||||
// For use with ATTinyCore
|
||||
#define IR_RECEIVE_PIN PIN_PA3 // On Digispark board labeled as pin 9 - INT0 is connected to USB+ on DigisparkPro boards
|
||||
#define IR_SEND_PIN PIN_PA2 // On Digispark board labeled as pin 8
|
||||
#define TONE_PIN PIN_PA7 // On Digispark board labeled as pin 5
|
||||
# endif
|
||||
|
||||
# elif defined(__AVR_ATtiny84__) // For use with ATTinyCore
|
||||
#include "ATtinySerialOut.hpp" // Available as Arduino library "ATtinySerialOut". Saves 128 bytes program memory.
|
||||
#define IR_RECEIVE_PIN PIN_PB2 // INT0
|
||||
#define IR_SEND_PIN PIN_PA4
|
||||
#define TONE_PIN PIN_PA3
|
||||
#define _IR_TIMING_TEST_PIN PIN_PA5
|
||||
|
||||
# elif defined(__AVR_ATtiny88__) // MH-ET Tiny88 board. For use with ATTinyCore.
|
||||
#include "ATtinySerialOut.hpp" // Available as Arduino library "ATtinySerialOut". Saves 128 bytes program memory.
|
||||
// Pin 6 is TX, pin 7 is RX
|
||||
#define IR_RECEIVE_PIN PIN_PD3 // 3 - INT1
|
||||
#define IR_SEND_PIN PIN_PD4 // 4
|
||||
#define TONE_PIN PIN_PB1 // 9
|
||||
#define _IR_TIMING_TEST_PIN PIN_PB0 // 8
|
||||
|
||||
# elif defined(__AVR_ATtiny1616__) || defined(__AVR_ATtiny3216__) || defined(__AVR_ATtiny3217__) // For use with megaTinyCore
|
||||
// Tiny Core Dev board
|
||||
// https://www.tindie.com/products/xkimi/tiny-core-16-dev-board-attiny1616/ - Out of Stock
|
||||
// https://www.tindie.com/products/xkimi/tiny-core-32-dev-board-attiny3217/ - Out of Stock
|
||||
#define IR_RECEIVE_PIN PIN_PA1 // use 18 instead of PIN_PA1 for TinyCore32
|
||||
#define IR_SEND_PIN PIN_PA2 // 19
|
||||
#define TONE_PIN PIN_PA3 // 20
|
||||
#define APPLICATION_PIN PIN_PA0 // 0
|
||||
#undef LED_BUILTIN // No LED available on the TinyCore 32 board, take the one on the programming board which is connected to the DAC output
|
||||
#define LED_BUILTIN PIN_PA6 // use 2 instead of PIN_PA6 for TinyCore32
|
||||
|
||||
# elif defined(__AVR_ATtiny816__) // For use with megaTinyCore
|
||||
#define IR_RECEIVE_PIN PIN_PA1 // 14
|
||||
#define IR_SEND_PIN PIN_PA1 // 16
|
||||
#define TONE_PIN PIN_PA5 // 1
|
||||
#define APPLICATION_PIN PIN_PA4 // 0
|
||||
#undef LED_BUILTIN // No LED available, take the one which is connected to the DAC output
|
||||
#define LED_BUILTIN PIN_PB5 // 4
|
||||
|
||||
# elif defined(__AVR_ATtiny1614__) // For use with megaTinyCore
|
||||
#define IR_RECEIVE_PIN PIN_PA1 // 8
|
||||
#define IR_SEND_PIN PIN_PA3 // 10
|
||||
#define TONE_PIN PIN_PA5 // 1
|
||||
#define APPLICATION_PIN PIN_PA4 // 0
|
||||
|
||||
# elif defined(__AVR_ATtiny1604__) // For use with megaTinyCore
|
||||
#define IR_RECEIVE_PIN PIN_PA6 // 2 - To be compatible with interrupt example, pin 2 is chosen here.
|
||||
#define IR_SEND_PIN PIN_PA7 // 3
|
||||
#define APPLICATION_PIN PIN_PB2 // 5
|
||||
|
||||
#define tone(...) void() // Define as void, since TCB0_INT_vect is also used by tone()
|
||||
#define noTone(a) void()
|
||||
#define TONE_PIN 42 // Dummy for examples using it
|
||||
|
||||
# elif defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) \
|
||||
|| defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) \
|
||||
|| defined(__AVR_ATmega324P__) || defined(__AVR_ATmega324A__) \
|
||||
|| defined(__AVR_ATmega324PA__) || defined(__AVR_ATmega164A__) \
|
||||
|| defined(__AVR_ATmega164P__) || defined(__AVR_ATmega32__) \
|
||||
|| defined(__AVR_ATmega16__) || defined(__AVR_ATmega8535__) \
|
||||
|| defined(__AVR_ATmega64__) || defined(__AVR_ATmega128__) \
|
||||
|| defined(__AVR_ATmega1281__) || defined(__AVR_ATmega2561__) \
|
||||
|| defined(__AVR_ATmega8515__) || defined(__AVR_ATmega162__)
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 13
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
# else // Default as for ATmega328 like on Uno, Nano, Leonardo, Teensy 2.0 etc.
|
||||
#define IR_RECEIVE_PIN 2 // To be compatible with interrupt example, pin 2 is chosen here.
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
# if defined(ARDUINO_AVR_PROMICRO) // Sparkfun Pro Micro is __AVR_ATmega32U4__ but has different external circuit
|
||||
// We have no built in LED at pin 13 -> reuse RX LED
|
||||
#undef LED_BUILTIN
|
||||
#define LED_BUILTIN LED_BUILTIN_RX
|
||||
# endif
|
||||
# endif // defined(__AVR_ATtiny25__)...
|
||||
|
||||
#elif defined(ARDUINO_ARCH_RENESAS_UNO) // Uno R4
|
||||
// To be compatible with Uno R3.
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
#elif defined(ESP8266)
|
||||
#define FEEDBACK_LED_IS_ACTIVE_LOW // The LED on my board (D4) is active LOW
|
||||
#define IR_RECEIVE_PIN 14 // D5
|
||||
#define IR_SEND_PIN 12 // D6 - D4/pin 2 is internal LED
|
||||
#define _IR_TIMING_TEST_PIN 2 // D4
|
||||
#define APPLICATION_PIN 13 // D7
|
||||
|
||||
#define tone(...) void() // tone() inhibits receive timer
|
||||
#define noTone(a) void()
|
||||
#define TONE_PIN 42 // Dummy for examples using it#
|
||||
|
||||
#elif defined(ARDUINO_NOLOGO_ESP32C3_SUPER_MINI)
|
||||
#define FEEDBACK_LED_IS_ACTIVE_LOW // The LED on my board (D8) is active LOW
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 10
|
||||
|
||||
#elif defined(CONFIG_IDF_TARGET_ESP32C3) || defined(ARDUINO_ESP32C3_DEV)
|
||||
#define NO_LED_FEEDBACK_CODE // The WS2812 on pin 8 of AI-C3 board crashes if used as receive feedback LED, other I/O pins are working...
|
||||
#define IR_RECEIVE_PIN 6
|
||||
#define IR_SEND_PIN 7
|
||||
#define TONE_PIN 10
|
||||
#define APPLICATION_PIN 18
|
||||
|
||||
#elif defined(ESP32)
|
||||
#include <Arduino.h>
|
||||
|
||||
// tone() is included in ESP32 core since 2.0.2
|
||||
#if !defined(ESP_ARDUINO_VERSION_VAL)
|
||||
#define ESP_ARDUINO_VERSION_VAL(major, minor, patch) 12345678
|
||||
#endif
|
||||
#if ESP_ARDUINO_VERSION <= ESP_ARDUINO_VERSION_VAL(2, 0, 2)
|
||||
#define TONE_LEDC_CHANNEL 1 // Using channel 1 makes tone() independent of receiving timer -> No need to stop receiving timer.
|
||||
void tone(uint8_t aPinNumber, unsigned int aFrequency){
|
||||
ledcAttachPin(aPinNumber, TONE_LEDC_CHANNEL);
|
||||
ledcWriteTone(TONE_LEDC_CHANNEL, aFrequency);
|
||||
}
|
||||
void tone(uint8_t aPinNumber, unsigned int aFrequency, unsigned long aDuration){
|
||||
ledcAttachPin(aPinNumber, TONE_LEDC_CHANNEL);
|
||||
ledcWriteTone(TONE_LEDC_CHANNEL, aFrequency);
|
||||
delay(aDuration);
|
||||
ledcWriteTone(TONE_LEDC_CHANNEL, 0);
|
||||
}
|
||||
void noTone(uint8_t aPinNumber){
|
||||
ledcWriteTone(TONE_LEDC_CHANNEL, 0);
|
||||
}
|
||||
#endif // ESP_ARDUINO_VERSION <= ESP_ARDUINO_VERSION_VAL(2, 0, 2)
|
||||
|
||||
#define IR_RECEIVE_PIN 15 // D15
|
||||
#define IR_SEND_PIN 4 // D4
|
||||
#define TONE_PIN 27 // D27 25 & 26 are DAC0 and 1
|
||||
#define APPLICATION_PIN 16 // RX2 pin
|
||||
|
||||
#elif defined(ARDUINO_ARCH_STM32) || defined(ARDUINO_ARCH_STM32F1) // BluePill
|
||||
// Timer 3 blocks PA6, PA7, PB0, PB1 for use by Servo or tone()
|
||||
#define IR_RECEIVE_PIN PA6
|
||||
#define IR_RECEIVE_PIN_STRING "PA6"
|
||||
#define IR_SEND_PIN PA7
|
||||
#define IR_SEND_PIN_STRING "PA7"
|
||||
#define TONE_PIN PA3
|
||||
#define _IR_TIMING_TEST_PIN PA5
|
||||
#define APPLICATION_PIN PA2
|
||||
#define APPLICATION_PIN_STRING "PA2"
|
||||
# if defined(ARDUINO_GENERIC_STM32F103C) || defined(ARDUINO_BLUEPILL_F103C8)
|
||||
// BluePill LED is active low
|
||||
#define FEEDBACK_LED_IS_ACTIVE_LOW
|
||||
# endif
|
||||
|
||||
#elif defined(ARDUINO_ARCH_APOLLO3) // Sparkfun Apollo boards
|
||||
#define IR_RECEIVE_PIN 11
|
||||
#define IR_SEND_PIN 12
|
||||
#define TONE_PIN 5
|
||||
|
||||
#elif defined(ARDUINO_ARCH_MBED) && defined(ARDUINO_ARCH_MBED_NANO) // Arduino Nano 33 BLE and Arduino Nano Connect layout for MBED
|
||||
// Must be before ARDUINO_ARCH_RP2040, since it is the layout for the MBED core of Arduino Nano Connect
|
||||
#define IR_RECEIVE_PIN 3 // GPIO15 Start with pin 3 since pin 2|GPIO25 is connected to LED on Pi pico
|
||||
#define IR_SEND_PIN 4 // GPIO16
|
||||
#define TONE_PIN 5
|
||||
#define APPLICATION_PIN 6
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 7 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 8
|
||||
|
||||
#elif defined(ARDUINO_ARCH_RP2040) // Arduino Nano Connect, Pi Pico with arduino-pico core https://github.com/earlephilhower/arduino-pico
|
||||
#define IR_RECEIVE_PIN 15 // GPIO15 to be compatible with the Arduino Nano RP2040 Connect (pin3)
|
||||
#define IR_SEND_PIN 16 // GPIO16
|
||||
#define TONE_PIN 17
|
||||
#define APPLICATION_PIN 18
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 19 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 20
|
||||
|
||||
// If you program the Nano RP2040 Connect with this core, then you must redefine LED_BUILTIN
|
||||
// and use the external reset with 1 kOhm to ground to enter UF2 mode
|
||||
#undef LED_BUILTIN
|
||||
#define LED_BUILTIN 6
|
||||
|
||||
#elif defined(PARTICLE) // !!!UNTESTED!!!
|
||||
#define IR_RECEIVE_PIN A4
|
||||
#define IR_SEND_PIN A5 // Particle supports multiple pins
|
||||
|
||||
#define LED_BUILTIN D7
|
||||
|
||||
/*
|
||||
* 4 times the same (default) layout for easy adaption in the future
|
||||
*/
|
||||
#elif defined(TEENSYDUINO) // Teensy 2.0 is handled at default for ATmega328 like on Uno, Nano, Leonardo etc.
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
#elif defined(ARDUINO_ARCH_MBED) // Arduino Nano 33 BLE
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
#elif defined(ARDUINO_ARCH_SAMD) || defined(ARDUINO_ARCH_SAM)
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
|
||||
#if !defined(ARDUINO_SAMD_ADAFRUIT) && !defined(ARDUINO_SEEED_XIAO_M0)
|
||||
// On the Zero and others we switch explicitly to SerialUSB
|
||||
#define Serial SerialUSB
|
||||
#endif
|
||||
|
||||
// Definitions for the Chinese SAMD21 M0-Mini clone, which has no led connected to D13/PA17.
|
||||
// Attention!!! D2 and D4 are swapped on these boards!!!
|
||||
// If you connect the LED, it is on pin 24/PB11. In this case activate the next two lines.
|
||||
//#undef LED_BUILTIN
|
||||
//#define LED_BUILTIN 24 // PB11
|
||||
// As an alternative you can choose pin 25, it is the RX-LED pin (PB03), but active low.In this case activate the next 3 lines.
|
||||
//#undef LED_BUILTIN
|
||||
//#define LED_BUILTIN 25 // PB03
|
||||
//#define FEEDBACK_LED_IS_ACTIVE_LOW // The RX LED on the M0-Mini is active LOW
|
||||
|
||||
#elif defined (NRF51) // BBC micro:bit
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define APPLICATION_PIN 1
|
||||
#define _IR_TIMING_TEST_PIN 4
|
||||
|
||||
#define tone(...) void() // no tone() available
|
||||
#define noTone(a) void()
|
||||
#define TONE_PIN 42 // Dummy for examples using it
|
||||
|
||||
#else
|
||||
#warning Board / CPU is not detected using pre-processor symbols -> using default values, which may not fit. Please extend PinDefinitionsAndMore.h.
|
||||
// Default valued for unidentified boards
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IR_SEND_PIN 3
|
||||
#define TONE_PIN 4
|
||||
#define APPLICATION_PIN 5
|
||||
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
|
||||
#define _IR_TIMING_TEST_PIN 7
|
||||
#endif // defined(ESP8266)
|
||||
|
||||
#if defined(ESP32) || defined(ARDUINO_ARCH_RP2040) || defined(PARTICLE) || defined(ARDUINO_ARCH_MBED)
|
||||
#define SEND_PWM_BY_TIMER // We do not have pin restrictions for this CPU's, so lets use the hardware PWM for send carrier signal generation
|
||||
#else
|
||||
# if defined(SEND_PWM_BY_TIMER)
|
||||
#undef IR_SEND_PIN // SendPin is determined by timer! This avoids warnings in IRremote.hpp and IRTimer.hpp
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if !defined (FLASHEND)
|
||||
#define FLASHEND 0xFFFF // Dummy value for platforms where FLASHEND is not defined
|
||||
#endif
|
||||
|
||||
/*
|
||||
* 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
|
||||
@@ -0,0 +1,790 @@
|
||||
/*
|
||||
* UnitTest.cpp
|
||||
*
|
||||
* Demonstrates sending IR codes in standard format with address and command and
|
||||
* simultaneously receiving. Both values are checked for consistency.
|
||||
*
|
||||
* This file is part of Arduino-IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
|
||||
*
|
||||
************************************************************************************
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2020-2024 Armin Joachimsmeyer
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is furnished
|
||||
* to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
************************************************************************************
|
||||
*/
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
#define IR_SEND_PIN 3
|
||||
|
||||
#if !defined(RAW_BUFFER_LENGTH)
|
||||
#define RAW_BUFFER_LENGTH 400 // 400 is OK with Pronto and 1000 is OK without Pronto. 1200 is too much here, because then variables are overwritten.
|
||||
#endif
|
||||
|
||||
//#define EXCLUDE_UNIVERSAL_PROTOCOLS // Saves up to 1000 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
|
||||
|
||||
// MARK_EXCESS_MICROS is subtracted from all marks and added to all spaces before decoding,
|
||||
//#define USE_MSB_DECODING_FOR_DISTANCE_DECODER
|
||||
// to compensate for the signal forming of different IR receiver modules. See also IRremote.hpp line 142.
|
||||
//#define MARK_EXCESS_MICROS 20 // Adapt it to your IR receiver module. 40 is taken for the cheap VS1838 module her, since we have high intensity.
|
||||
|
||||
//#define RECORD_GAP_MICROS 12000 // Default is 8000. Activate it for some LG air conditioner protocols.
|
||||
|
||||
//#define TRACE // For internal usage
|
||||
//#define DEBUG // Activate this for lots of lovely debug output from the decoders.
|
||||
|
||||
#define DECODE_DENON // Includes Sharp
|
||||
#define DECODE_KASEIKYO
|
||||
#define DECODE_PANASONIC // alias for DECODE_KASEIKYO
|
||||
#define DECODE_NEC // Includes Apple and Onkyo
|
||||
|
||||
#define DECODE_JVC
|
||||
#define DECODE_RC5
|
||||
#define DECODE_RC6
|
||||
|
||||
#define DECODE_DISTANCE_WIDTH // Universal decoder for pulse distance width protocols
|
||||
#define DECODE_HASH // special decoder for all protocols
|
||||
|
||||
#define DECODE_SONY
|
||||
#define DECODE_SAMSUNG
|
||||
#define DECODE_LG
|
||||
|
||||
#define DECODE_BEO // It prevents decoding of SONY (default repeats), which we are not using here.
|
||||
//#define ENABLE_BEO_WITHOUT_FRAME_GAP // !!!For successful unit testing we must see the warning at ir_BangOlufsen.hpp:100:2!!!
|
||||
#define RECORD_GAP_MICROS 16000 // Force to get the complete frame including the 3. space of 15 ms in the receive buffer
|
||||
#define BEO_KHZ 38 // We send and receive Bang&Olufsen with 38 kHz here (instead of 455 kHz).
|
||||
|
||||
#define DECODE_BOSEWAVE
|
||||
#define DECODE_MAGIQUEST
|
||||
#define DECODE_FAST
|
||||
|
||||
//#define DECODE_WHYNTER
|
||||
//#define DECODE_LEGO_PF
|
||||
|
||||
/*
|
||||
* 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_SEND_PIN 3 // P0_0
|
||||
#define IR_RECEIVE_PIN 4 // P0_1
|
||||
|
||||
#define BTN_ACTIVE_STATE HIGH // HIGH for Elbear boards, LOW for Start board
|
||||
|
||||
#include <IRremote.hpp>
|
||||
|
||||
#define DELAY_AFTER_SEND 1000
|
||||
#define DELAY_AFTER_LOOP 5000
|
||||
|
||||
#if defined(SEND_PWM_BY_TIMER) && !defined(SEND_PWM_DOES_NOT_USE_RECEIVE_TIMER)
|
||||
#error Unit test cannot run if SEND_PWM_BY_TIMER is enabled i.e. receive timer us also used by send
|
||||
#endif
|
||||
|
||||
/*
|
||||
* For callback
|
||||
*/
|
||||
volatile bool sDataJustReceived = false;
|
||||
void ReceiveCompleteCallbackHandler();
|
||||
|
||||
void setup() {
|
||||
pinMode(BTN_BUILTIN, INPUT);
|
||||
|
||||
Serial.begin(9600);
|
||||
while (!Serial)
|
||||
; // Wait for Serial to become available. Is optimized away for some cores.
|
||||
|
||||
// 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
|
||||
IrReceiver.begin(IR_RECEIVE_PIN, ENABLE_LED_FEEDBACK);
|
||||
IrReceiver.registerReceiveCompleteCallback(ReceiveCompleteCallbackHandler);
|
||||
|
||||
Serial.print(F("Ready to receive IR signals of protocols: "));
|
||||
printActiveIRProtocols(&Serial);
|
||||
|
||||
Serial.println(F("at pin " STR(IR_RECEIVE_PIN)));
|
||||
|
||||
|
||||
#if defined(LED_BUILTIN) && !defined(NO_LED_FEEDBACK_CODE)
|
||||
Serial.print(F("FeedbackLED at pin "));
|
||||
Serial.println(LED_BUILTIN);
|
||||
#endif
|
||||
|
||||
Serial.println(F("Use ReceiveCompleteCallback"));
|
||||
Serial.println(F("Receive buffer length is " STR(RAW_BUFFER_LENGTH)));
|
||||
|
||||
#if defined(IR_SEND_PIN)
|
||||
IrSender.begin(); // Start with IR_SEND_PIN as send pin and enable feedback LED at default feedback LED pin
|
||||
Serial.println(F("Send IR signals at pin " STR(IR_SEND_PIN)));
|
||||
#else
|
||||
// Here the macro IR_SEND_PIN is not defined or undefined above with #undef IR_SEND_PIN
|
||||
uint8_t tSendPin = 3;
|
||||
IrSender.begin(tSendPin, ENABLE_LED_FEEDBACK, USE_DEFAULT_FEEDBACK_LED_PIN); // Specify send pin and enable feedback LED at default feedback LED pin
|
||||
// You can change send pin later with IrSender.setSendPin();
|
||||
|
||||
Serial.print(F("Send IR signals at pin "));
|
||||
Serial.println(tSendPin);
|
||||
#endif
|
||||
|
||||
Serial.print(F("If you press button "));
|
||||
Serial.print(BTN_BUILTIN);
|
||||
Serial.println(F(" raw data is always printed"));
|
||||
|
||||
# if !defined(SEND_PWM_BY_TIMER)
|
||||
/*
|
||||
* Print internal software PWM generation info
|
||||
*/
|
||||
IrSender.enableIROut(38); // Call it with 38 kHz to initialize the values printed below
|
||||
Serial.print(F("Send signal mark duration for 38kHz is "));
|
||||
Serial.print(IrSender.periodOnTimeMicros);
|
||||
Serial.print(F(" us, pulse narrowing correction is "));
|
||||
Serial.print(IrSender.getPulseCorrectionNanos());
|
||||
Serial.print(F(" ns, total period is "));
|
||||
Serial.print(IrSender.periodTimeMicros);
|
||||
Serial.println(F(" us"));
|
||||
# endif
|
||||
|
||||
// infos for receive
|
||||
Serial.print(RECORD_GAP_MICROS);
|
||||
Serial.println(F(" us is the (minimum) gap, after which the start of a new IR packet is assumed"));
|
||||
Serial.print(MARK_EXCESS_MICROS);
|
||||
Serial.println(F(" us are subtracted from all marks and added to all spaces for decoding"));
|
||||
|
||||
delay(DELAY_AFTER_SEND);
|
||||
|
||||
}
|
||||
|
||||
void checkReceivedRawData(IRRawDataType aRawData) {
|
||||
// wait until signal has received
|
||||
while (!sDataJustReceived) {
|
||||
};
|
||||
sDataJustReceived = false;
|
||||
|
||||
if (IrReceiver.decode()) {
|
||||
// Print a short summary of received data
|
||||
IrReceiver.printIRResultShort(&Serial);
|
||||
IrReceiver.printIRSendUsage(&Serial);
|
||||
if (IrReceiver.decodedIRData.protocol == UNKNOWN || digitalRead(BTN_BUILTIN) == BTN_ACTIVE_STATE) {
|
||||
// We have an unknown protocol, print more info
|
||||
IrReceiver.printIRResultRawFormatted(&Serial, true);
|
||||
}
|
||||
|
||||
if (IrReceiver.decodedIRData.protocol == PULSE_DISTANCE || IrReceiver.decodedIRData.protocol == PULSE_WIDTH) {
|
||||
if (IrReceiver.decodedIRData.decodedRawData != aRawData) {
|
||||
Serial.print(F("ERROR: Received data=0x"));
|
||||
Serial.print(IrReceiver.decodedIRData.decodedRawData, HEX);
|
||||
Serial.print(F(" != sent data=0x"));
|
||||
Serial.print(aRawData, HEX);
|
||||
Serial.println();
|
||||
}
|
||||
}
|
||||
IrReceiver.resume();
|
||||
} else {
|
||||
Serial.println(F("No data received"));
|
||||
}
|
||||
Serial.println();
|
||||
}
|
||||
|
||||
#if defined(DECODE_DISTANCE_WIDTH)
|
||||
void checkReceivedArray(IRRawDataType *aRawDataArrayPointer, uint8_t aArraySize) {
|
||||
// wait until signal has received
|
||||
while (!sDataJustReceived) {
|
||||
};
|
||||
sDataJustReceived = false;
|
||||
|
||||
if (IrReceiver.decode()) {
|
||||
// Print a short summary of received data
|
||||
IrReceiver.printIRResultShort(&Serial);
|
||||
IrReceiver.printIRSendUsage(&Serial);
|
||||
|
||||
if (IrReceiver.decodedIRData.protocol == UNKNOWN || digitalRead(BTN_BUILTIN) == BTN_ACTIVE_STATE) {
|
||||
// We have an unknown protocol, print more info
|
||||
IrReceiver.printIRResultRawFormatted(&Serial, true);
|
||||
}
|
||||
|
||||
if (IrReceiver.decodedIRData.protocol == PULSE_DISTANCE || IrReceiver.decodedIRData.protocol == PULSE_WIDTH) {
|
||||
for (uint_fast8_t i = 0; i < aArraySize; ++i) {
|
||||
if (IrReceiver.decodedIRData.decodedRawDataArray[i] != *aRawDataArrayPointer) {
|
||||
Serial.print(F("ERROR: Received data=0x"));
|
||||
Serial.print(IrReceiver.decodedIRData.decodedRawDataArray[i], HEX);
|
||||
Serial.print(F(" != sent data=0x"));
|
||||
Serial.println(*aRawDataArrayPointer, HEX);
|
||||
}
|
||||
aRawDataArrayPointer++;
|
||||
}
|
||||
}
|
||||
IrReceiver.resume();
|
||||
} else {
|
||||
Serial.println(F("No data received"));
|
||||
}
|
||||
Serial.println();
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Test callback function
|
||||
* Has the same functionality as a check with available()
|
||||
*/
|
||||
void ReceiveCompleteCallbackHandler() {
|
||||
sDataJustReceived = true;
|
||||
}
|
||||
|
||||
void checkReceive(uint16_t aSentAddress, uint16_t aSentCommand) {
|
||||
// wait until signal has received
|
||||
uint16_t tTimeoutCounter = 1000; // gives 10 seconds timeout
|
||||
while (!sDataJustReceived) {
|
||||
delay(10);
|
||||
if (tTimeoutCounter == 0) {
|
||||
Serial.println(F("Receive timeout happened"));
|
||||
break;
|
||||
}
|
||||
tTimeoutCounter--;
|
||||
}
|
||||
sDataJustReceived = false;
|
||||
|
||||
if (IrReceiver.decode()) {
|
||||
// Print a short summary of received data
|
||||
IrReceiver.printIRResultShort(&Serial);
|
||||
IrReceiver.printIRSendUsage(&Serial);
|
||||
|
||||
if (IrReceiver.decodedIRData.flags & IRDATA_FLAGS_WAS_OVERFLOW) {
|
||||
Serial.println(F("Try to increase the \"RAW_BUFFER_LENGTH\" value of " STR(RAW_BUFFER_LENGTH) " in " __FILE__));
|
||||
// see also https://github.com/Arduino-IRremote/Arduino-IRremote#compile-options--macros-for-this-library
|
||||
}
|
||||
|
||||
if (IrReceiver.decodedIRData.protocol == UNKNOWN || digitalRead(BTN_BUILTIN) == BTN_ACTIVE_STATE) {
|
||||
// We have an unknown protocol, print more info
|
||||
IrReceiver.printIRResultRawFormatted(&Serial, true);
|
||||
}
|
||||
IrReceiver.resume(); // Early resume
|
||||
|
||||
if (IrReceiver.decodedIRData.protocol == UNKNOWN) {
|
||||
Serial.println(F("ERROR: Unknown protocol"));
|
||||
} else {
|
||||
/*
|
||||
* Check address
|
||||
*/
|
||||
if (IrReceiver.decodedIRData.address != aSentAddress) {
|
||||
Serial.print(F("ERROR: Received address=0x"));
|
||||
Serial.print(IrReceiver.decodedIRData.address, HEX);
|
||||
Serial.print(F(" != sent address=0x"));
|
||||
Serial.println(aSentAddress, HEX);
|
||||
}
|
||||
/*
|
||||
* Check command
|
||||
*/
|
||||
if (IrReceiver.decodedIRData.command != aSentCommand) {
|
||||
Serial.print(F("ERROR: Received command=0x"));
|
||||
Serial.print(IrReceiver.decodedIRData.command, HEX);
|
||||
Serial.print(F(" != sent command=0x"));
|
||||
Serial.println(aSentCommand, HEX);
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
Serial.println(F("No data received"));
|
||||
IrReceiver.resume();
|
||||
}
|
||||
Serial.println();
|
||||
}
|
||||
|
||||
/*
|
||||
* Set up the data to be sent.
|
||||
* For most protocols, the data is build up with a constant 8 (or 16 byte) address
|
||||
* and a variable 8 bit command.
|
||||
* There are exceptions like Sony and Denon, which have 5 bit address.
|
||||
*/
|
||||
uint16_t sAddress = 0xFFF1;
|
||||
uint8_t sCommand = 0x76;
|
||||
uint16_t s16BitCommand = 0x9876;
|
||||
uint8_t sRepeats = 0;
|
||||
|
||||
void loop() {
|
||||
/*
|
||||
* Print values
|
||||
*/
|
||||
Serial.println();
|
||||
Serial.print(F("address=0x"));
|
||||
Serial.print(sAddress, HEX);
|
||||
Serial.print(F(" command=0x"));
|
||||
Serial.print(sCommand, HEX);
|
||||
Serial.println();
|
||||
Serial.println();
|
||||
|
||||
Serial.print(F("Send NEC with 8 bit address"));
|
||||
if (sRepeats > 0) {
|
||||
Serial.print(F(" and complete NEC frames as repeats to force decoding as NEC2"));
|
||||
}
|
||||
Serial.println();
|
||||
Serial.flush();
|
||||
IrSender.sendNEC(sAddress & 0xFF, sCommand, 0);
|
||||
checkReceive(sAddress & 0xFF, sCommand);
|
||||
|
||||
/*
|
||||
* Complete NEC frames as repeats to force decoding as NEC2 are tested here
|
||||
*/
|
||||
for (int8_t i = 0; i < sRepeats; i++) {
|
||||
if (digitalRead(BTN_BUILTIN) != BTN_ACTIVE_STATE) {
|
||||
// If debug is enabled, printing time (50 ms) is sufficient as delay
|
||||
delayMicroseconds(NEC_REPEAT_DISTANCE - 20000); // 20000 is just a guess
|
||||
}
|
||||
IrSender.sendNEC(sAddress & 0xFF, sCommand, 0);
|
||||
checkReceive(sAddress & 0xFF, sCommand);
|
||||
}
|
||||
|
||||
delay(DELAY_AFTER_SEND); // delay must be greater than 5 ms (RECORD_GAP_MICROS), otherwise the receiver sees it as one long signal
|
||||
|
||||
Serial.println(F("Send NEC with 16 bit address"));
|
||||
Serial.flush();
|
||||
IrSender.sendNEC(sAddress, sCommand, 0);
|
||||
checkReceive(sAddress, sCommand);
|
||||
delay(DELAY_AFTER_SEND);
|
||||
|
||||
Serial.println(F("Send NEC2 with 16 bit address"));
|
||||
Serial.flush();
|
||||
IrSender.sendNEC2(sAddress, sCommand, 0);
|
||||
checkReceive(sAddress, sCommand);
|
||||
delay(DELAY_AFTER_SEND);
|
||||
|
||||
if (sAddress == 0xFFF1) {
|
||||
/*
|
||||
* Send constant values only once in this demo
|
||||
*/
|
||||
Serial.println(F("Send NEC Pronto data with 8 bit address 0x80 and command 0x45 and no repeats"));
|
||||
Serial.flush();
|
||||
// This is copied to stack/ram internally
|
||||
IrSender.sendPronto(F("0000 006D 0022 0000 015E 00AB " /* Pronto header + start bit */
|
||||
"0017 0015 0017 0015 0017 0017 0015 0017 0017 0015 0017 0015 0017 0015 0017 003F " /* Lower address byte */
|
||||
"0017 003F 0017 003E 0017 003F 0015 003F 0017 003E 0017 003F 0017 003E 0017 0015 " /* Upper address byte (inverted at 8 bit mode) */
|
||||
"0017 003E 0017 0015 0017 003F 0017 0015 0017 0015 0017 0015 0017 003F 0017 0015 " /* command byte */
|
||||
"0019 0013 0019 003C 0017 0015 0017 003F 0017 003E 0017 003F 0017 0015 0017 003E " /* inverted command byte */
|
||||
"0017 0806"), 0); //stop bit, no repeat possible, because of missing repeat pattern
|
||||
checkReceive(0x80, 0x45);
|
||||
delay(DELAY_AFTER_SEND);
|
||||
|
||||
Serial.println(
|
||||
F("Send NEC sendRaw data with 8 bit address=0xFB04 and command 0x08 and exact timing (16 bit array format)"));
|
||||
Serial.flush();
|
||||
const uint16_t irSignal[] = { 9000, 4500/*Start bit*/, 560, 560, 560, 560, 560, 1690, 560,
|
||||
560/*0010 0x4 of 16 bit address LSB first*/, 560, 560, 560, 560, 560, 560, 560, 560/*0000*/, 560, 1690, 560, 1690,
|
||||
560, 560, 560, 1690/*1101 0xB*/, 560, 1690, 560, 1690, 560, 1690, 560, 1690/*1111*/, 560, 560, 560, 560, 560, 560,
|
||||
560, 1690/*0001 0x08 of command LSB first*/, 560, 560, 560, 560, 560, 560, 560, 560/*0000 0x00*/, 560, 1690, 560,
|
||||
1690, 560, 1690, 560, 560/*1110 Inverted 8 of command*/, 560, 1690, 560, 1690, 560, 1690, 560,
|
||||
1690/*1111 inverted 0 of command*/, 560 /*stop bit*/}; // Using exact NEC timing
|
||||
IrSender.sendRaw(irSignal, sizeof(irSignal) / sizeof(irSignal[0]), NEC_KHZ); // Note the approach used to automatically calculate the size of the array.
|
||||
checkReceive(0xFB04 & 0xFF, 0x08);
|
||||
delay(DELAY_AFTER_SEND);
|
||||
|
||||
/*
|
||||
* With sendNECRaw() you can send 32 bit codes directly, i.e. without parity etc.
|
||||
*/
|
||||
Serial.println(F("Send ONKYO with 16 bit address 0x0102 and 16 bit command 0x0304 with NECRaw(0x03040102)"));
|
||||
Serial.flush();
|
||||
IrSender.sendNECRaw(0x03040102, 0);
|
||||
checkReceive(0x0102, 0x304);
|
||||
delay(DELAY_AFTER_SEND);
|
||||
|
||||
/*
|
||||
* With Send sendNECMSB() you can send your old 32 bit codes.
|
||||
* To convert one into the other, you must reverse the byte positions and then reverse all positions of each byte.
|
||||
* Use bitreverse32Bit().
|
||||
* Example:
|
||||
* 0xCB340102 byte reverse -> 0x020134CB bit reverse-> 40802CD3
|
||||
*/
|
||||
Serial.println(F("Send ONKYO with 16 bit address 0x0102 and command 0x34 with old 32 bit format MSB first (0x40802CD3)"));
|
||||
Serial.flush();
|
||||
IrSender.sendNECMSB(0x40802CD3, 32, false);
|
||||
checkReceive(0x0102, 0x34);
|
||||
delay(DELAY_AFTER_SEND);
|
||||
|
||||
# if defined(DECODE_PANASONIC) || defined(DECODE_KASEIKYO)
|
||||
Serial.println(F("Send Panasonic 0xB, 0x10 as 48 bit PulseDistance using ProtocolConstants"));
|
||||
Serial.flush();
|
||||
IrSender.sendPulseDistanceWidth(&KaseikyoProtocolConstants, 0xA010B02002, 48, NO_REPEATS); // Panasonic is a Kaseikyo variant
|
||||
checkReceivedRawData(0xA010B02002);
|
||||
delay(DELAY_AFTER_SEND);
|
||||
|
||||
/*
|
||||
* Send 2 Panasonic 48 bit codes as Pulse Distance data, once with LSB and once with MSB first
|
||||
*/
|
||||
Serial.println(F("Send Panasonic 0xB, 0x10 as 48 bit PulseDistance"));
|
||||
Serial.println(F("-LSB first"));
|
||||
Serial.flush();
|
||||
IrSender.sendPulseDistanceWidth(38, 3450, 1700, 450, 1250, 450, 400, 0xA010B02002, 48, PROTOCOL_IS_LSB_FIRST, 0,
|
||||
NO_REPEATS);
|
||||
checkReceivedRawData(0xA010B02002);
|
||||
delay(DELAY_AFTER_SEND);
|
||||
|
||||
// The same with MSB first. Use bit reversed raw data of LSB first part
|
||||
Serial.println(F("-MSB first"));
|
||||
IrSender.sendPulseDistanceWidth(38, 3450, 1700, 450, 1250, 450, 400, 0x40040D000805, 48, PROTOCOL_IS_MSB_FIRST, 0,
|
||||
NO_REPEATS);
|
||||
checkReceivedRawData(0x40040D000805);
|
||||
|
||||
delay(DELAY_AFTER_SEND);
|
||||
# endif // defined(DECODE_PANASONIC) || defined(DECODE_KASEIKYO)
|
||||
|
||||
# if defined(DECODE_DISTANCE_WIDTH)
|
||||
# if defined(USE_MSB_DECODING_FOR_DISTANCE_DECODER)
|
||||
Serial.println(F("Send 52 bit PulseDistance 0x43D8613C and 0x3BC3B MSB first"));
|
||||
Serial.flush();
|
||||
IrSender.sendPulseDistanceWidth(38, 8900, 4450, 550, 1700, 550, 600, 0x43D8613CBC3B, 52, PROTOCOL_IS_MSB_FIRST, 0, NO_REPEATS);
|
||||
checkReceivedRawData(0x43D8613CBC3B);
|
||||
delay(DELAY_AFTER_SEND);
|
||||
|
||||
Serial.println(F("Send 52 bit PulseDistanceWidth 0x43D8613C and 0x3BC3B MSB first"));
|
||||
Serial.flush();
|
||||
// Real PulseDistanceWidth (constant bit length) does not require a stop bit
|
||||
IrSender.sendPulseDistanceWidth(38, 300, 600, 600, 300, 300, 600, 0x123456789ABC, 52, PROTOCOL_IS_MSB_FIRST, 0, 0);
|
||||
checkReceivedRawData(0x123456789ABC);
|
||||
delay(DELAY_AFTER_SEND);
|
||||
Serial.println(F("Send 32 bit PulseWidth 0x43D8613C MSB first"));
|
||||
Serial.flush();
|
||||
// Real PulseDistanceWidth (constant bit length) does not require a stop bit
|
||||
IrSender.sendPulseDistanceWidth(38, 1000, 500, 600, 300, 300, 300, 0x43D8613C, 32, PROTOCOL_IS_MSB_FIRST, 0, 0);
|
||||
checkReceivedRawData(0x43D8613C);
|
||||
delay(DELAY_AFTER_SEND);
|
||||
|
||||
# else // defined(USE_MSB_DECODING_FOR_DISTANCE_DECODER)
|
||||
Serial.println(F("Send 72 bit PulseDistance 0x5A AFEDCBA9 87654321 LSB first"));
|
||||
Serial.flush();
|
||||
IRRawDataType tRawData[] = { 0xAFEDCBA987654321, 0x5A }; // LSB of tRawData[0] is sent first
|
||||
IrSender.sendPulseDistanceWidthFromArray(38, 8900, 4450, 550, 1700, 550, 600, &tRawData[0], 72, PROTOCOL_IS_LSB_FIRST, 0,
|
||||
NO_REPEATS);
|
||||
checkReceivedArray(tRawData, 2);
|
||||
delay(DELAY_AFTER_SEND);
|
||||
|
||||
Serial.println(F("Send 52 bit PulseDistanceWidth 0xDCBA9 87654321 LSB first"));
|
||||
Serial.flush();
|
||||
// Real PulseDistanceWidth (constant bit length) does theoretically not require a stop bit, but we know the stop bit from serial transmission
|
||||
IrSender.sendPulseDistanceWidth(38, 300, 600, 300, 600, 600, 300, 0xDCBA987654321, 52, PROTOCOL_IS_LSB_FIRST, 0, 0);
|
||||
checkReceivedRawData(0xDCBA987654321);
|
||||
delay(DELAY_AFTER_SEND);
|
||||
|
||||
Serial.println(F("Send 52 bit PulseDistanceWidth 0xDCBA9 87654321 LSB first with inverse timing and data"));
|
||||
Serial.flush();
|
||||
IrSender.sendPulseDistanceWidth(38, 300, 600, 600, 300, 300, 600, ~0xDCBA987654321, 52, PROTOCOL_IS_LSB_FIRST, 0, 0);
|
||||
checkReceivedRawData(0xDCBA987654321);
|
||||
delay(DELAY_AFTER_SEND);
|
||||
|
||||
Serial.println(F("Send 7 bit ASCII character with PulseDistanceWidth LSB first"));
|
||||
Serial.flush();
|
||||
// Real PulseDistanceWidth (constant bit length) does theoretically not require a stop bit, but we know the stop bit from serial transmission
|
||||
IrSender.sendPulseDistanceWidth(38, 6000, 500, 500, 1500, 1500, 500, sCommand, 7, PROTOCOL_IS_LSB_FIRST, 0, 0);
|
||||
checkReceivedRawData(sCommand);
|
||||
delay(DELAY_AFTER_SEND);
|
||||
|
||||
Serial.println(F("Send Sony12 as PulseWidth LSB first"));
|
||||
Serial.flush();
|
||||
uint32_t tData = (uint32_t) sAddress << 7 | (sCommand & 0x7F);
|
||||
IrSender.sendPulseDistanceWidth(38, 2400, 600, 1200, 600, 600, 600, tData, SIRCS_12_PROTOCOL, PROTOCOL_IS_LSB_FIRST, 0, 0);
|
||||
checkReceive(sAddress & 0x1F, sCommand & 0x7F);
|
||||
delay(DELAY_AFTER_SEND);
|
||||
|
||||
Serial.println(F("Send 32 bit PulseWidth 0x87654321 LSB first"));
|
||||
Serial.flush();
|
||||
IrSender.sendPulseDistanceWidth(38, 1000, 500, 600, 300, 300, 300, 0x87654321, 32, PROTOCOL_IS_LSB_FIRST, 0, 0);
|
||||
checkReceivedRawData(0x87654321);
|
||||
delay(DELAY_AFTER_SEND);
|
||||
|
||||
# endif // defined(USE_MSB_DECODING_FOR_DISTANCE_DECODER)
|
||||
# endif // defined(DECODE_DISTANCE_WIDTH)
|
||||
|
||||
# if defined(DECODE_MAGIQUEST)
|
||||
Serial.println(F("Send MagiQuest 0x6BCDFF00, 0x176 as 55 bit PulseDistanceWidth MSB first"));
|
||||
Serial.flush();
|
||||
// 0xD79BFE00 is 0x6BCDFF00 is shifted 1 left
|
||||
IrSender.sendPulseDistanceWidth(38, 287, 864, 576, 576, 287, 864, 0xD79BFE017619, 55, PROTOCOL_IS_MSB_FIRST, 0, 0);
|
||||
checkReceive(0xFF00, 0x176);
|
||||
if (IrReceiver.decodedIRData.decodedRawData != 0x6BCDFF00) {
|
||||
Serial.print(F("ERROR: Received address=0x"));
|
||||
Serial.print(IrReceiver.decodedIRData.decodedRawData, HEX);
|
||||
Serial.println(F(" != sent address=0x6BCDFF00"));
|
||||
Serial.println();
|
||||
}
|
||||
delay(DELAY_AFTER_SEND);
|
||||
# endif // defined(DECODE_MAGIQUEST)
|
||||
|
||||
}
|
||||
|
||||
Serial.println(F("Send Onkyo (NEC with 16 bit command)"));
|
||||
Serial.flush();
|
||||
IrSender.sendOnkyo(sAddress, (sCommand + 1) << 8 | sCommand, 0);
|
||||
checkReceive(sAddress, (sCommand + 1) << 8 | sCommand);
|
||||
delay(DELAY_AFTER_SEND);
|
||||
|
||||
Serial.println(F("Send Apple"));
|
||||
Serial.flush();
|
||||
IrSender.sendApple(sAddress & 0xFF, sCommand, 0);
|
||||
checkReceive(sAddress & 0xFF, sCommand);
|
||||
delay(DELAY_AFTER_SEND);
|
||||
|
||||
#if defined(DECODE_PANASONIC) || defined(DECODE_KASEIKYO)
|
||||
Serial.println(F("Send Panasonic"));
|
||||
Serial.flush();
|
||||
IrSender.sendPanasonic(sAddress & 0xFFF, sCommand, 0);
|
||||
checkReceive(sAddress & 0xFFF, sCommand);
|
||||
delay(DELAY_AFTER_SEND);
|
||||
|
||||
Serial.println(F("Send Kaseikyo with 0x4711 as Vendor ID"));
|
||||
Serial.flush();
|
||||
IrSender.sendKaseikyo(sAddress & 0xFFF, sCommand, 0, 0x4711);
|
||||
checkReceive(sAddress & 0xFFF, sCommand);
|
||||
delay(DELAY_AFTER_SEND);
|
||||
|
||||
Serial.println(F("Send Kaseikyo_Denon variant"));
|
||||
Serial.flush();
|
||||
IrSender.sendKaseikyo_Denon(sAddress & 0xFFF, sCommand, 0);
|
||||
checkReceive(sAddress & 0xFFF, sCommand);
|
||||
delay(DELAY_AFTER_SEND);
|
||||
#endif
|
||||
|
||||
#if defined(DECODE_DENON)
|
||||
Serial.println(F("Send Denon"));
|
||||
Serial.flush();
|
||||
IrSender.sendDenon(sAddress & 0x1F, sCommand, 0);
|
||||
checkReceive(sAddress & 0x1F, sCommand);
|
||||
delay(DELAY_AFTER_SEND);
|
||||
|
||||
Serial.println(F("Send Denon/Sharp variant"));
|
||||
Serial.flush();
|
||||
IrSender.sendSharp(sAddress & 0x1F, sCommand, 0);
|
||||
checkReceive(sAddress & 0x1F, sCommand);
|
||||
delay(DELAY_AFTER_SEND);
|
||||
#endif
|
||||
|
||||
#if defined(DECODE_SONY)
|
||||
Serial.println(F("Send Sony/SIRCS with 7 command and 5 address bits"));
|
||||
Serial.flush();
|
||||
IrSender.sendSony(sAddress & 0x1F, sCommand, 0); // SIRCS_12_PROTOCOL is default
|
||||
checkReceive(sAddress & 0x1F, sCommand & 0x7F);
|
||||
delay(DELAY_AFTER_SEND);
|
||||
|
||||
Serial.println(F("Send Sony/SIRCS with 7 command and 8 address bits"));
|
||||
Serial.flush();
|
||||
IrSender.sendSony(sAddress & 0xFF, sCommand, 0, SIRCS_15_PROTOCOL);
|
||||
checkReceive(sAddress & 0xFF, sCommand & 0x7F);
|
||||
delay(DELAY_AFTER_SEND);
|
||||
|
||||
Serial.println(F("Send Sony/SIRCS with 7 command and 13 address bits"));
|
||||
Serial.flush();
|
||||
IrSender.sendSony(sAddress & 0x1FFF, sCommand, 0, SIRCS_20_PROTOCOL);
|
||||
checkReceive(sAddress & 0x1FFF, sCommand & 0x7F);
|
||||
delay(DELAY_AFTER_SEND);
|
||||
#endif
|
||||
|
||||
#if defined(DECODE_SAMSUNG)
|
||||
Serial.println(F("Send Samsung 8 bit command and 8 bit address"));
|
||||
Serial.flush();
|
||||
IrSender.sendSamsung(sAddress & 0xFF, sCommand, 0);
|
||||
checkReceive(sAddress & 0xFF, sCommand);
|
||||
delay(DELAY_AFTER_SEND);
|
||||
|
||||
Serial.println(F("Send Samsung 16 bit command and address"));
|
||||
Serial.flush();
|
||||
IrSender.sendSamsung16BitAddressAndCommand(sAddress, s16BitCommand, 0);
|
||||
checkReceive(sAddress, s16BitCommand);
|
||||
delay(DELAY_AFTER_SEND);
|
||||
|
||||
Serial.println(F("Send Samsung48 16 bit command"));
|
||||
Serial.flush();
|
||||
IrSender.sendSamsung48(sAddress, s16BitCommand, 0);
|
||||
checkReceive(sAddress, s16BitCommand);
|
||||
delay(DELAY_AFTER_SEND);
|
||||
#endif
|
||||
|
||||
#if defined(DECODE_RC5)
|
||||
Serial.println(F("Send RC5"));
|
||||
Serial.flush();
|
||||
IrSender.sendRC5(sAddress & 0x1F, sCommand & 0x3F, 0, true); // 5 address, 6 command bits
|
||||
checkReceive(sAddress & 0x1F, sCommand & 0x3F);
|
||||
delay(DELAY_AFTER_SEND);
|
||||
|
||||
Serial.println(F("Send RC5X with 7.th MSB of command set"));
|
||||
Serial.flush();
|
||||
IrSender.sendRC5(sAddress & 0x1F, (sCommand & 0x3F) + 0x40, 0, true); // 5 address, 7 command bits
|
||||
checkReceive(sAddress & 0x1F, (sCommand & 0x3F) + 0x40);
|
||||
delay(DELAY_AFTER_SEND);
|
||||
#endif
|
||||
|
||||
#if defined(DECODE_RC6)
|
||||
Serial.println(F("Send RC6"));
|
||||
Serial.flush();
|
||||
sLastSendToggleValue = sAddress & 0x01; // to modify toggling at each loop
|
||||
|
||||
IrSender.sendRC6(sAddress & 0xFF, sCommand, 0, true);
|
||||
checkReceive(sAddress & 0xFF, sCommand);
|
||||
delay(DELAY_AFTER_SEND);
|
||||
|
||||
Serial.println(F("Send RC6A with 14 bit 0x2711 as extra"));
|
||||
Serial.flush();
|
||||
IrSender.sendRC6A(sAddress & 0xFF, sCommand, 0, 0x2711, true);
|
||||
checkReceive(sAddress & 0xFF, sCommand);
|
||||
delay(DELAY_AFTER_SEND);
|
||||
#endif
|
||||
|
||||
#if defined(DECODE_BEO)
|
||||
Serial.println(F("Send Bang&Olufsen"));
|
||||
Serial.flush();
|
||||
IrSender.sendBangOlufsen(sAddress & 0x0FF, sCommand, 0);
|
||||
# if defined(ENABLE_BEO_WITHOUT_FRAME_GAP)
|
||||
delay((RECORD_GAP_MICROS / 1000) + 1);
|
||||
Serial.println(F("- ENABLE_BEO_WITHOUT_FRAME_GAP is enabled"));
|
||||
Serial.println(F("- Now print raw data and try to decode the first 6 entries, which results in rawData 0x0"));
|
||||
IrReceiver.printIRResultRawFormatted(&Serial, true);
|
||||
uint8_t tOriginalRawlen = IrReceiver.decodedIRData.rawDataPtr->rawlen;
|
||||
IrReceiver.decodedIRData.rawDataPtr->rawlen = 6;
|
||||
/*
|
||||
* decode first part / AGC part of frame
|
||||
*/
|
||||
IrReceiver.decode(); // sets IrReceiver.decodedIRData.rawlen to 6
|
||||
IrReceiver.printIRResultShort(&Serial); // -> Protocol=Bang&Olufsen Address=0x0 Command=0x0 Raw-Data=0x0 0 bits MSB first
|
||||
|
||||
// Remove trailing 6 entries for second decode try
|
||||
Serial.println();
|
||||
Serial.println(
|
||||
F(
|
||||
"- Remove trailing 6 entries, which is equivalent to define RECORD_GAP_MICROS < 15000, to enable successful B&O decode"));
|
||||
IrReceiver.decodedIRData.rawlen = tOriginalRawlen - 6;
|
||||
IrReceiver.decodedIRData.rawDataPtr->rawlen = tOriginalRawlen - 6;
|
||||
for (uint_fast8_t i = 0; i < IrReceiver.decodedIRData.rawlen; ++i) {
|
||||
IrReceiver.decodedIRData.rawDataPtr->rawbuf[i] = IrReceiver.decodedIRData.rawDataPtr->rawbuf[i + 6];
|
||||
}
|
||||
# endif
|
||||
checkReceive(sAddress & 0x0FF, sCommand);
|
||||
delay(DELAY_AFTER_SEND);
|
||||
#endif
|
||||
|
||||
#if defined(DECODE_MAGIQUEST)
|
||||
Serial.println(F("Send MagiQuest"));
|
||||
Serial.flush();
|
||||
IrSender.sendMagiQuest(0x6BCD0000 | (uint32_t) sAddress, s16BitCommand); // we have 31 bit address
|
||||
checkReceive(sAddress, s16BitCommand & 0x1FF); // we have 9 bit command
|
||||
delay(DELAY_AFTER_SEND);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Next example how to use the IrSender.write function
|
||||
*/
|
||||
IRData IRSendData;
|
||||
// prepare data
|
||||
IRSendData.address = sAddress;
|
||||
IRSendData.command = sCommand;
|
||||
IRSendData.flags = IRDATA_FLAGS_EMPTY;
|
||||
|
||||
Serial.println(F("Send next protocols with IrSender.write"));
|
||||
Serial.println();
|
||||
Serial.flush();
|
||||
|
||||
#if defined(DECODE_JVC)
|
||||
IRSendData.protocol = JVC; // switch protocol
|
||||
Serial.print(F("Send "));
|
||||
Serial.println(getProtocolString(IRSendData.protocol));
|
||||
Serial.flush();
|
||||
IrSender.write(&IRSendData, 0);
|
||||
checkReceive(IRSendData.address & 0xFF, IRSendData.command);
|
||||
delay(DELAY_AFTER_SEND);
|
||||
#endif
|
||||
|
||||
#if defined(DECODE_LG) || defined(DECODE_MAGIQUEST)
|
||||
IRSendData.command = s16BitCommand; // LG support more than 8 bit command
|
||||
#endif
|
||||
|
||||
#if defined(DECODE_LG)
|
||||
IRSendData.protocol = LG;
|
||||
Serial.print(F("Send "));
|
||||
Serial.println(getProtocolString(IRSendData.protocol));
|
||||
Serial.flush();
|
||||
IrSender.write(&IRSendData, 0);
|
||||
checkReceive(IRSendData.address & 0xFF, IRSendData.command);
|
||||
delay(DELAY_AFTER_SEND);
|
||||
#endif
|
||||
|
||||
#if defined(DECODE_BOSEWAVE)
|
||||
IRSendData.protocol = BOSEWAVE;
|
||||
Serial.println(F("Send Bosewave with no address and 8 command bits"));
|
||||
Serial.flush();
|
||||
IrSender.write(&IRSendData, 0);
|
||||
checkReceive(0, IRSendData.command & 0xFF);
|
||||
delay(DELAY_AFTER_SEND);
|
||||
#endif
|
||||
|
||||
#if defined(DECODE_FAST)
|
||||
IRSendData.protocol = FAST;
|
||||
Serial.print(F("Send "));
|
||||
Serial.println(getProtocolString(IRSendData.protocol));
|
||||
Serial.flush();
|
||||
IrSender.write(&IRSendData, 0);
|
||||
checkReceive(0, IRSendData.command & 0xFF);
|
||||
delay(DELAY_AFTER_SEND);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* LEGO is skipped, since it is difficult to receive because of its short marks and spaces
|
||||
*/
|
||||
// Serial.println(F("Send Lego with 2 channel and with 4 command bits"));
|
||||
// Serial.flush();
|
||||
// IrSender.sendLegoPowerFunctions(sAddress, sCommand, LEGO_MODE_COMBO, true);
|
||||
// checkReceive(sAddress, sCommand); // never has success for Lego protocol :-(
|
||||
// delay(DELAY_AFTER_SEND);
|
||||
/*
|
||||
* Force buffer overflow
|
||||
*/
|
||||
Serial.println(F("Force buffer overflow by sending 450 marks and spaces"));
|
||||
for (unsigned int i = 0; i < 225; ++i) {
|
||||
// 400 + 400 should be received as 8/8 and sometimes as 9/7 or 7/9 if compensation by MARK_EXCESS_MICROS is optimal.
|
||||
// 210 + 540 = 750 should be received as 5/10 or 4/11 if compensation by MARK_EXCESS_MICROS is optimal.
|
||||
IrSender.mark(210); // 8 pulses at 38 kHz
|
||||
IrSender.space(540); // to fill up to 750 us
|
||||
}
|
||||
checkReceive(sAddress, sCommand);
|
||||
delay(DELAY_AFTER_SEND);
|
||||
|
||||
/*
|
||||
* Increment values
|
||||
* Also increment address just for demonstration, which normally makes no sense
|
||||
*/
|
||||
sAddress += 0x0101;
|
||||
sCommand += 0x11;
|
||||
s16BitCommand += 0x1111;
|
||||
sRepeats++;
|
||||
// clip repeats at 4
|
||||
if (sRepeats > 4) {
|
||||
sRepeats = 4;
|
||||
}
|
||||
|
||||
/*
|
||||
* Test stop and start of 50 us receiver timer
|
||||
*/
|
||||
Serial.println(F("Stop receiver"));
|
||||
IrReceiver.stop();
|
||||
delay(DELAY_AFTER_LOOP); // additional delay at the end of each loop
|
||||
Serial.println(F("Start receiver"));
|
||||
IrReceiver.start(); // For ESP32 timerEnableReceiveInterrupt() is sufficient here, since timer is not reconfigured by another task
|
||||
}
|
||||
|
||||
@@ -0,0 +1,851 @@
|
||||
START ../src/UnitTest.cpp from Jun 22 2024
|
||||
Using library version 4.4.0
|
||||
Ready to receive IR signals of protocols: NEC/NEC2/Onkyo/Apple, Panasonic/Kaseikyo, Denon/Sharp, Sony, RC5, RC6, LG, JVC, Samsung, Bang & Olufsen, FAST, Bosewave, MagiQuest, Universal Pulse Distance Width, Hash at pin 2
|
||||
Use ReceiveCompleteCallback
|
||||
Receive buffer length is 200
|
||||
Send IR signals at pin 3
|
||||
If you connect debug pin 5 to ground, raw data is always printed
|
||||
Send signal mark duration for 38kHz is 8 us, pulse narrowing correction is 3000 ns, total period is 26 us
|
||||
16000 us is the (minimum) gap, after which the start of a new IR packet is assumed
|
||||
20 us are subtracted from all marks and added to all spaces for decoding
|
||||
|
||||
address=0xFFF1 command=0x76
|
||||
|
||||
Send NEC with 8 bit address
|
||||
Protocol=NEC Address=0xF1 Command=0x76 Raw-Data=0x89760EF1 32 bits LSB first
|
||||
Send with: IrSender.sendNEC(0xF1, 0x76, <numberOfRepeats>);
|
||||
rawData[68]:
|
||||
-1049200
|
||||
+8900,-445
|
||||
+ 600,-1600 + 600,- 550 + 600,- 500 + 600,- 550
|
||||
+ 600,-1600 + 600,-1650 + 600,-1650 + 600,-1650
|
||||
+ 600,- 550 + 600,-1600 + 600,-1650 + 600,-1650
|
||||
+ 600,- 500 + 600,- 550 + 600,- 500 + 600,- 550
|
||||
+ 600,- 500 + 600,-1650 + 600,-1650 + 600,- 550
|
||||
+ 600,-1600 + 600,-1650 + 600,-1650 + 600,- 500
|
||||
+ 600,-1650 + 600,- 550 + 600,- 500 + 600,-1650
|
||||
+ 600,- 550 + 600,- 500 + 600,- 550 + 600,-1650
|
||||
+ 600
|
||||
Sum: 67800
|
||||
|
||||
Send NEC with 16 bit address
|
||||
Protocol=NEC Address=0xFFF1 Command=0x76 Raw-Data=0x8976FFF1 32 bits LSB first
|
||||
Send with: IrSender.sendNEC(0xFFF1, 0x76, <numberOfRepeats>);
|
||||
rawData[68]:
|
||||
-1058500
|
||||
+8950,-4450
|
||||
+ 550,-1650 + 600,- 500 + 600,- 550 + 600,- 500
|
||||
+ 600,-1650 + 600,-1650 + 600,-1650 + 600,-1650
|
||||
+ 600,-1600 + 600,-1650 + 600,-1650 + 600,-1600
|
||||
+ 600,-1650 + 600,-1650 + 600,-1650 + 600,-1650
|
||||
+ 600,- 500 + 600,-1650 + 600,-1650 + 600,- 550
|
||||
+ 600,-1600 + 600,-1650 + 600,-1650 + 600,- 550
|
||||
+ 600,-1600 + 600,- 550 + 600,- 500 + 600,-1650
|
||||
+ 600,- 550 + 600,- 500 + 600,- 550 + 600,-1600
|
||||
+ 600
|
||||
Sum: 73350
|
||||
|
||||
Send NEC2 with 16 bit address
|
||||
Protocol=NEC Address=0xFFF1 Command=0x76 Raw-Data=0x8976FFF1 32 bits LSB first
|
||||
Send with: IrSender.sendNEC(0xFFF1, 0x76, <numberOfRepeats>);
|
||||
rawData[68]:
|
||||
-1059050
|
||||
+8950,-4400
|
||||
+ 600,-1600 + 600,- 550 + 600,- 550 + 600,- 500
|
||||
+ 600,-1650 + 600,-1650 + 600,-1650 + 600,-1600
|
||||
+ 600,-1650 + 600,-1650 + 600,-1600 + 650,-1600
|
||||
+ 600,-1650 + 600,-1650 + 600,-1600 + 650,-1600
|
||||
+ 600,- 550 + 600,-1600 + 600,-1650 + 600,- 550
|
||||
+ 600,-1600 + 600,-1650 + 600,-1650 + 600,- 550
|
||||
+ 600,-1600 + 600,- 550 + 600,- 550 + 600,-1600
|
||||
+ 600,- 550 + 600,- 500 + 600,- 550 + 600,-1600
|
||||
+ 600
|
||||
Sum: 73300
|
||||
|
||||
Send Panasonic 0xB, 0x10 as 48 bit PulseDistance using ProtocolConstants
|
||||
Protocol=Panasonic Address=0xB Command=0x10 Raw-Data=0xA01000B0 48 bits LSB first
|
||||
Send with: IrSender.sendPanasonic(0xB, 0x10, <numberOfRepeats>);
|
||||
rawData[100]:
|
||||
-1062700
|
||||
+3450,-1700
|
||||
+ 450,- 450 + 450,-1250 + 450,- 400 + 500,- 400
|
||||
+ 450,- 400 + 450,- 450 + 450,- 400 + 450,- 450
|
||||
+ 450,- 400 + 450,- 400 + 450,- 450 + 450,- 400
|
||||
+ 450,- 400 + 500,-1250 + 450,- 400 + 500,- 400
|
||||
+ 450,- 400 + 450,- 450 + 450,- 400 + 450,- 400
|
||||
+ 500,-1250 + 450,-1250 + 450,- 450 + 450,-1250
|
||||
+ 450,- 400 + 450,- 450 + 450,- 400 + 450,- 400
|
||||
+ 500,- 400 + 450,- 400 + 450,- 400 + 500,- 400
|
||||
+ 450,- 400 + 500,- 400 + 450,- 400 + 450,- 400
|
||||
+ 500,-1250 + 450,- 400 + 450,- 400 + 450,- 450
|
||||
+ 450,- 400 + 450,- 400 + 450,- 450 + 450,- 400
|
||||
+ 450,- 400 + 500,-1250 + 450,- 400 + 500,-1250
|
||||
+ 450
|
||||
Sum: 54150
|
||||
|
||||
Send Panasonic 0xB, 0x10 as 48 bit PulseDistance
|
||||
-LSB first
|
||||
Protocol=Panasonic Address=0xB Command=0x10 Raw-Data=0xA01000B0 48 bits LSB first
|
||||
Send with: IrSender.sendPanasonic(0xB, 0x10, <numberOfRepeats>);
|
||||
rawData[100]:
|
||||
-1079300
|
||||
+3450,-1650
|
||||
+ 500,- 350 + 500,-1200 + 500,- 350 + 500,- 350
|
||||
+ 500,- 350 + 500,- 350 + 500,- 350 + 500,- 350
|
||||
+ 500,- 350 + 500,- 350 + 500,- 350 + 500,- 350
|
||||
+ 500,- 350 + 500,-1200 + 500,- 350 + 500,- 350
|
||||
+ 500,- 350 + 500,- 350 + 500,- 350 + 500,- 350
|
||||
+ 500,-1200 + 500,-1200 + 500,- 350 + 500,-1200
|
||||
+ 500,- 350 + 500,- 350 + 500,- 350 + 500,- 350
|
||||
+ 500,- 350 + 500,- 350 + 500,- 400 + 450,- 400
|
||||
+ 450,- 400 + 450,- 400 + 450,- 350 + 500,- 350
|
||||
+ 500,-1200 + 500,- 350 + 500,- 350 + 500,- 350
|
||||
+ 500,- 350 + 500,- 350 + 500,- 350 + 500,- 350
|
||||
+ 500,- 400 + 450,-1200 + 500,- 350 + 500,-1200
|
||||
+ 500
|
||||
Sum: 53200
|
||||
|
||||
-MSB first
|
||||
Protocol=Panasonic Address=0xB Command=0x10 Raw-Data=0xA01000B0 48 bits LSB first
|
||||
Send with: IrSender.sendPanasonic(0xB, 0x10, <numberOfRepeats>);
|
||||
rawData[100]:
|
||||
-1074200
|
||||
+3450,-1650
|
||||
+ 500,- 350 + 500,-1200 + 500,- 350 + 500,- 350
|
||||
+ 500,- 350 + 500,- 350 + 500,- 350 + 500,- 350
|
||||
+ 500,- 350 + 500,- 350 + 500,- 350 + 500,- 350
|
||||
+ 500,- 350 + 500,-1200 + 500,- 350 + 500,- 350
|
||||
+ 500,- 350 + 500,- 350 + 500,- 350 + 500,- 350
|
||||
+ 500,-1200 + 500,-1200 + 500,- 350 + 500,-1200
|
||||
+ 500,- 350 + 500,- 350 + 500,- 350 + 500,- 350
|
||||
+ 500,- 350 + 500,- 350 + 500,- 350 + 500,- 400
|
||||
+ 450,- 400 + 450,- 400 + 450,- 400 + 450,- 350
|
||||
+ 500,-1200 + 500,- 350 + 500,- 350 + 500,- 350
|
||||
+ 500,- 350 + 500,- 350 + 500,- 350 + 500,- 350
|
||||
+ 500,- 400 + 450,-1200 + 500,- 350 + 500,-1200
|
||||
+ 500
|
||||
Sum: 53200
|
||||
|
||||
Send 72 bit PulseDistance 0x5A AFEDCBA9 87654321 LSB first
|
||||
Protocol=PulseDistance Raw-Data=0x5A 72 bits LSB first
|
||||
Send on a 8 bit platform with:
|
||||
uint32_t tRawData[]={0x87654321, 0xAFEDCBA9, 0x5A};
|
||||
IrSender.sendPulseDistanceWidthFromArray(38, 8850, 4400, 600, 1650, 600, 550, &tRawData[0], 72, PROTOCOL_IS_LSB_FIRST, <RepeatPeriodMillis>, <numberOfRepeats>);
|
||||
rawData[148]:
|
||||
-1079150
|
||||
+8850,-4400
|
||||
+ 550,-1650 + 600,- 550 + 600,- 550 + 600,- 550
|
||||
+ 600,- 550 + 600,-1650 + 600,- 550 + 600,- 550
|
||||
+ 600,-1650 + 600,-1650 + 600,- 550 + 600,- 550
|
||||
+ 600,- 550 + 600,- 550 + 600,-1650 + 600,- 550
|
||||
+ 600,-1650 + 600,- 550 + 600,-1650 + 600,- 550
|
||||
+ 600,- 550 + 600,-1650 + 600,-1650 + 600,- 550
|
||||
+ 600,-1650 + 600,-1650 + 600,-1650 + 600,- 550
|
||||
+ 600,- 550 + 600,- 550 + 600,- 550 + 600,-1650
|
||||
+ 600,-1650 + 600,- 550 + 600,- 550 + 600,-1650
|
||||
+ 600,- 550 + 600,-1650 + 600,- 550 + 600,-1650
|
||||
+ 600,-1650 + 600,-1650 + 600,- 550 + 600,-1650
|
||||
+ 600,- 550 + 600,- 550 + 600,-1650 + 600,-1650
|
||||
+ 600,-1650 + 600,- 550 + 600,-1650 + 600,-1650
|
||||
+ 600,- 550 + 600,-1650 + 600,-1650 + 600,-1650
|
||||
+ 600,-1650 + 550,-1650 + 600,-1650 + 600,-1650
|
||||
+ 600,- 550 + 600,-1650 + 600,- 550 + 600,-1700
|
||||
+ 550,- 550 + 600,-1650 + 600,- 550 + 600,-1650
|
||||
+ 600,-1650 + 600,- 550 + 600,-1650 + 600,- 550
|
||||
+ 600
|
||||
Sum: 138350
|
||||
|
||||
Send 52 bit PulseDistanceWidth 0xDCBA9 87654321 LSB first
|
||||
Protocol=PulseDistance Raw-Data=0xDCBA9 52 bits LSB first
|
||||
Send on a 8 bit platform with:
|
||||
uint32_t tRawData[]={0x87654321, 0xDCBA9};
|
||||
IrSender.sendPulseDistanceWidthFromArray(38, 300, 600, 350, 550, 650, 250, &tRawData[0], 52, PROTOCOL_IS_LSB_FIRST, <RepeatPeriodMillis>, <numberOfRepeats>);
|
||||
rawData[108]:
|
||||
-1116150
|
||||
+ 300,- 600
|
||||
+ 350,- 550 + 650,- 250 + 650,- 250 + 650,- 250
|
||||
+ 650,- 250 + 350,- 550 + 650,- 250 + 650,- 250
|
||||
+ 350,- 600 + 300,- 600 + 650,- 250 + 650,- 250
|
||||
+ 650,- 250 + 650,- 250 + 350,- 550 + 650,- 250
|
||||
+ 350,- 600 + 600,- 250 + 350,- 600 + 600,- 250
|
||||
+ 650,- 250 + 350,- 600 + 350,- 550 + 600,- 300
|
||||
+ 350,- 550 + 350,- 550 + 350,- 550 + 650,- 250
|
||||
+ 650,- 250 + 650,- 250 + 650,- 250 + 350,- 600
|
||||
+ 350,- 550 + 650,- 250 + 650,- 250 + 350,- 550
|
||||
+ 650,- 250 + 350,- 600 + 600,- 300 + 350,- 550
|
||||
+ 350,- 550 + 350,- 550 + 650,- 250 + 350,- 550
|
||||
+ 650,- 250 + 650,- 250 + 350,- 550 + 350,- 600
|
||||
+ 350,- 550 + 600,- 300 + 350,- 550 + 350,- 550
|
||||
+ 350
|
||||
Sum: 48300
|
||||
|
||||
Send 52 bit PulseDistanceWidth 0xDCBA9 87654321 LSB first with inverse timing and data
|
||||
Protocol=PulseDistance Raw-Data=0xDCBA9 52 bits LSB first
|
||||
Send on a 8 bit platform with:
|
||||
uint32_t tRawData[]={0x87654321, 0xDCBA9};
|
||||
IrSender.sendPulseDistanceWidthFromArray(38, 350, 550, 350, 550, 600, 300, &tRawData[0], 52, PROTOCOL_IS_LSB_FIRST, <RepeatPeriodMillis>, <numberOfRepeats>);
|
||||
rawData[108]:
|
||||
-1095900
|
||||
+ 350,- 550
|
||||
+ 350,- 550 + 650,- 250 + 650,- 250 + 650,- 250
|
||||
+ 650,- 250 + 350,- 600 + 600,- 300 + 600,- 300
|
||||
+ 350,- 550 + 350,- 550 + 600,- 300 + 600,- 300
|
||||
+ 600,- 300 + 600,- 300 + 300,- 600 + 600,- 300
|
||||
+ 350,- 550 + 600,- 300 + 350,- 550 + 600,- 300
|
||||
+ 600,- 300 + 350,- 550 + 350,- 550 + 650,- 250
|
||||
+ 350,- 550 + 350,- 600 + 300,- 600 + 600,- 300
|
||||
+ 600,- 300 + 600,- 250 + 650,- 300 + 300,- 600
|
||||
+ 350,- 550 + 650,- 250 + 650,- 250 + 350,- 600
|
||||
+ 600,- 300 + 350,- 550 + 600,- 300 + 350,- 550
|
||||
+ 350,- 550 + 350,- 550 + 650,- 250 + 350,- 550
|
||||
+ 650,- 250 + 650,- 250 + 350,- 550 + 350,- 550
|
||||
+ 350,- 600 + 600,- 250 + 400,- 550 + 300,- 600
|
||||
+ 600
|
||||
Sum: 48500
|
||||
|
||||
Send ASCII 7 bit PulseDistanceWidth LSB first
|
||||
Protocol=PulseDistance Raw-Data=0x76 7 bits LSB first
|
||||
Send on a 8 bit platform with: IrSender.sendPulseDistanceWidth(38, 5950, 500, 550, 1450, 1550, 500, 0x76, 7, PROTOCOL_IS_LSB_FIRST, <RepeatPeriodMillis>, <numberOfRepeats>);
|
||||
rawData[18]:
|
||||
-1092450
|
||||
+5950,- 500
|
||||
+1500,- 500 + 500,-1450 + 550,-1450 +1550,- 450
|
||||
+ 550,-1450 + 550,-1450 + 550,-1450 + 550
|
||||
Sum: 20950
|
||||
|
||||
Send Sony12 as PulseWidth LSB first
|
||||
Protocol=Sony Address=0x11 Command=0x76 Raw-Data=0x8F6 12 bits LSB first
|
||||
Send with: IrSender.sendSony(0x11, 0x76, 2, 12);
|
||||
rawData[26]:
|
||||
-1036550
|
||||
+2450,- 600
|
||||
+ 600,- 550 +1250,- 550 +1250,- 550 + 650,- 550
|
||||
+1250,- 550 +1250,- 550 +1250,- 550 +1250,- 550
|
||||
+ 650,- 550 + 650,- 550 + 650,- 550 +1250
|
||||
Sum: 21050
|
||||
|
||||
Send 32 bit PulseWidth 0x87654321 LSB first
|
||||
Protocol=PulseWidth Raw-Data=0x87654321 32 bits LSB first
|
||||
Send on a 8 bit platform with: IrSender.sendPulseDistanceWidth(38, 1050, 500, 650, 250, 350, 250, 0x87654321, 32, PROTOCOL_IS_LSB_FIRST, <RepeatPeriodMillis>, <numberOfRepeats>);
|
||||
rawData[66]:
|
||||
-1036150
|
||||
+1050,- 500
|
||||
+ 600,- 300 + 350,- 250 + 350,- 250 + 350,- 250
|
||||
+ 350,- 300 + 600,- 300 + 350,- 250 + 350,- 250
|
||||
+ 650,- 250 + 650,- 250 + 350,- 300 + 350,- 250
|
||||
+ 350,- 250 + 350,- 300 + 600,- 300 + 300,- 300
|
||||
+ 600,- 300 + 350,- 250 + 600,- 300 + 350,- 250
|
||||
+ 350,- 250 + 650,- 250 + 650,- 250 + 350,- 250
|
||||
+ 650,- 250 + 650,- 250 + 650,- 250 + 350,- 300
|
||||
+ 350,- 250 + 350,- 250 + 350,- 250 + 650
|
||||
Sum: 24600
|
||||
|
||||
Send MagiQuest 0x6BCDFF00, 0x176 as 55 bit PulseDistanceWidth MSB first
|
||||
Protocol=MagiQuest Address=0xFF00 Command=0x176 Raw-Data=0x6BCDFF00 56 bits MSB first
|
||||
Send with: IrSender.sendMagiQuest(0x6BCDFF00, 0x176, <numberOfRepeats>);
|
||||
rawData[112]:
|
||||
-1065600
|
||||
+ 350,- 800 + 350,- 800 + 350,- 800 + 350,- 800
|
||||
+ 350,- 800 + 350,- 800 + 350,- 800 + 350,- 800
|
||||
+ 600,- 550 + 600,- 550 + 350,- 800 + 600,- 550
|
||||
+ 350,- 800 + 600,- 550 + 600,- 550 + 600,- 550
|
||||
+ 600,- 550 + 350,- 800 + 350,- 800 + 600,- 550
|
||||
+ 600,- 550 + 350,- 800 + 600,- 550 + 600,- 550
|
||||
+ 600,- 550 + 600,- 550 + 600,- 550 + 600,- 550
|
||||
+ 600,- 550 + 600,- 550 + 600,- 550 + 300,- 850
|
||||
+ 350,- 850 + 300,- 850 + 300,- 800 + 350,- 800
|
||||
+ 350,- 800 + 350,- 800 + 350,- 800 + 600,- 550
|
||||
+ 350,- 800 + 650,- 500 + 600,- 600 + 550,- 550
|
||||
+ 300,- 850 + 600,- 550 + 600,- 550 + 350,- 800
|
||||
+ 300,- 850 + 350,- 800 + 350,- 800 + 600,- 550
|
||||
+ 600,- 550 + 350,- 800 + 350,- 800 + 600
|
||||
Sum: 63850
|
||||
|
||||
Send Onkyo (NEC with 16 bit command)
|
||||
Protocol=Onkyo Address=0xFFF1 Command=0x7776 Raw-Data=0x7776FFF1 32 bits LSB first
|
||||
Send with: IrSender.sendOnkyo(0xFFF1, 0x7776, <numberOfRepeats>);
|
||||
rawData[68]:
|
||||
-1084150
|
||||
+8950,-4400
|
||||
+ 600,-1650 + 600,- 550 + 600,- 500 + 600,- 550
|
||||
+ 600,-1600 + 650,-1600 + 600,-1650 + 600,-1650
|
||||
+ 600,-1600 + 600,-1650 + 600,-1650 + 600,-1650
|
||||
+ 600,-1650 + 600,-1600 + 600,-1650 + 600,-1650
|
||||
+ 600,- 500 + 600,-1650 + 600,-1650 + 600,- 500
|
||||
+ 600,-1650 + 600,-1650 + 600,-1650 + 600,- 500
|
||||
+ 600,-1650 + 600,-1650 + 600,-1650 + 600,- 500
|
||||
+ 600,-1650 + 600,-1650 + 600,-1650 + 600,- 550
|
||||
+ 600
|
||||
Sum: 76750
|
||||
|
||||
Send Apple
|
||||
Protocol=Apple Address=0xF1 Command=0x76 Raw-Data=0xF17687EE 32 bits LSB first
|
||||
Send with: IrSender.sendApple(0xF1, 0x76, <numberOfRepeats>);
|
||||
rawData[68]:
|
||||
-1058150
|
||||
+8900,-4450
|
||||
+ 600,- 500 + 600,-1650 + 600,-1650 + 600,-1600
|
||||
+ 600,- 550 + 600,-1650 + 600,-1600 + 600,-1650
|
||||
+ 600,-1650 + 600,-1650 + 600,-1600 + 600,- 550
|
||||
+ 600,- 500 + 600,- 550 + 600,- 550 + 600,-1600
|
||||
+ 600,- 550 + 600,-1600 + 600,-1650 + 600,- 550
|
||||
+ 600,-1600 + 600,-1650 + 600,-1650 + 600,- 500
|
||||
+ 600,-1650 + 600,- 550 + 600,- 500 + 600,- 550
|
||||
+ 600,-1650 + 600,-1600 + 600,-1650 + 600,-1650
|
||||
+ 600
|
||||
Sum: 72200
|
||||
|
||||
Send Panasonic
|
||||
Protocol=Panasonic Address=0xFF1 Command=0x76 Raw-Data=0x9976FF10 48 bits LSB first
|
||||
Send with: IrSender.sendPanasonic(0xFF1, 0x76, <numberOfRepeats>);
|
||||
rawData[100]:
|
||||
-1057800
|
||||
+3450,-1700
|
||||
+ 450,- 400 + 500,-1250 + 450,- 400 + 450,- 450
|
||||
+ 450,- 400 + 450,- 400 + 500,- 400 + 450,- 400
|
||||
+ 450,- 450 + 450,- 400 + 450,- 400 + 450,- 450
|
||||
+ 450,- 400 + 450,-1300 + 450,- 400 + 450,- 400
|
||||
+ 500,- 400 + 450,- 400 + 450,- 400 + 500,- 400
|
||||
+ 450,-1250 + 450,- 450 + 450,- 400 + 450,- 400
|
||||
+ 450,-1300 + 450,-1250 + 450,-1300 + 450,-1250
|
||||
+ 500,-1250 + 450,-1250 + 500,-1250 + 450,-1300
|
||||
+ 450,- 400 + 450,-1250 + 450,-1300 + 450,- 400
|
||||
+ 450,-1250 + 450,-1300 + 450,-1250 + 500,- 400
|
||||
+ 450,-1250 + 450,- 450 + 450,- 400 + 450,-1250
|
||||
+ 450,-1300 + 450,- 400 + 450,- 400 + 500,-1250
|
||||
+ 450
|
||||
Sum: 64400
|
||||
|
||||
Send Kaseikyo with 0x4711 as Vendor ID
|
||||
Protocol=Kaseikyo Address=0xFF1 Command=0x76 Extra=0x4711 Raw-Data=0x9A76FF13 48 bits LSB first
|
||||
Send with: IrSender.sendKaseikyo(0xFF1, 0x76, <numberOfRepeats>, 0x4711);
|
||||
rawData[100]:
|
||||
-1078000
|
||||
+3450,-1700
|
||||
+ 450,-1250 + 450,- 450 + 450,- 400 + 450,- 450
|
||||
+ 450,-1250 + 450,- 400 + 500,- 400 + 450,- 400
|
||||
+ 450,-1300 + 450,-1250 + 450,-1300 + 450,- 400
|
||||
+ 450,- 400 + 450,- 450 + 450,-1250 + 450,- 450
|
||||
+ 450,-1250 + 450,-1300 + 450,- 400 + 450,- 400
|
||||
+ 500,-1250 + 450,- 400 + 450,- 450 + 450,- 400
|
||||
+ 450,-1250 + 450,-1300 + 450,-1250 + 450,-1300
|
||||
+ 450,-1250 + 450,-1300 + 450,-1250 + 450,-1300
|
||||
+ 450,- 400 + 450,-1300 + 450,-1250 + 450,- 450
|
||||
+ 450,-1250 + 450,-1250 + 500,-1250 + 450,- 400
|
||||
+ 450,- 400 + 500,-1250 + 450,- 400 + 450,-1300
|
||||
+ 450,-1250 + 450,- 450 + 450,- 400 + 450,-1250
|
||||
+ 500
|
||||
Sum: 69550
|
||||
|
||||
Send Kaseikyo_Denon variant
|
||||
Protocol=Kaseikyo_Denon Address=0xFF1 Command=0x76 Raw-Data=0x9976FF10 48 bits LSB first
|
||||
Send with: IrSender.sendKaseikyo_Denon(0xFF1, 0x76, <numberOfRepeats>);
|
||||
rawData[100]:
|
||||
-1078750
|
||||
+3450,-1700
|
||||
+ 500,- 400 + 450,- 400 + 450,-1300 + 450,- 400
|
||||
+ 450,-1250 + 500,- 400 + 450,-1250 + 500,- 400
|
||||
+ 450,- 400 + 450,-1250 + 450,- 450 + 450,- 400
|
||||
+ 450,-1300 + 450,-1250 + 450,- 400 + 500,- 400
|
||||
+ 450,- 400 + 450,- 400 + 500,- 400 + 450,- 400
|
||||
+ 450,-1300 + 450,- 400 + 450,- 400 + 450,- 450
|
||||
+ 450,-1250 + 450,-1300 + 450,-1250 + 450,-1300
|
||||
+ 450,-1250 + 450,-1300 + 450,-1250 + 450,-1300
|
||||
+ 450,- 400 + 450,-1300 + 450,-1250 + 450,- 400
|
||||
+ 500,-1250 + 450,-1250 + 500,-1250 + 450,- 400
|
||||
+ 500,-1250 + 450,- 400 + 450,- 400 + 450,-1300
|
||||
+ 450,-1250 + 450,- 400 + 500,- 400 + 450,-1250
|
||||
+ 500
|
||||
Sum: 67850
|
||||
|
||||
Send Denon
|
||||
Protocol=Denon Address=0x11 Command=0x76 Raw-Data=0xED1 15 bits LSB first
|
||||
Send with: IrSender.sendDenon(0x11, 0x76, <numberOfRepeats>);
|
||||
rawData[32]:
|
||||
-1076500
|
||||
+ 300,-1750 + 300,- 750 + 300,- 750 + 300,- 750
|
||||
+ 300,-1750 + 300,- 750 + 300,-1800 + 250,-1800
|
||||
+ 300,- 750 + 300,-1750 + 300,-1800 + 300,-1750
|
||||
+ 300,- 750 + 300,- 750 + 300,- 750 + 300
|
||||
Sum: 23150
|
||||
|
||||
Send Denon/Sharp variant
|
||||
Protocol=Sharp Address=0x11 Command=0x76 Raw-Data=0x4ED1 15 bits LSB first
|
||||
Send with: IrSender.sendSharp(0x11, 0x76, <numberOfRepeats>);
|
||||
rawData[32]:
|
||||
-1018700
|
||||
+ 300,-1800 + 300,- 750 + 300,- 700 + 300,- 750
|
||||
+ 300,-1800 + 250,- 750 + 300,-1800 + 250,-1800
|
||||
+ 300,- 750 + 300,-1750 + 300,-1800 + 300,-1750
|
||||
+ 300,- 750 + 300,- 750 + 300,-1750 + 300
|
||||
Sum: 24150
|
||||
|
||||
Send Sony/SIRCS with 7 command and 5 address bits
|
||||
Protocol=Sony Address=0x11 Command=0x76 Raw-Data=0x8F6 12 bits LSB first
|
||||
Send with: IrSender.sendSony(0x11, 0x76, 2, 12);
|
||||
rawData[26]:
|
||||
-1020900
|
||||
+2450,- 550
|
||||
+ 650,- 550 +1250,- 550 +1250,- 550 + 650,- 550
|
||||
+1250,- 550 +1250,- 550 +1250,- 550 +1250,- 550
|
||||
+ 650,- 550 + 650,- 550 + 650,- 550 +1250
|
||||
Sum: 21050
|
||||
|
||||
Send Sony/SIRCS with 7 command and 8 address bits
|
||||
Protocol=Sony Address=0xF1 Command=0x76 Raw-Data=0x78F6 15 bits LSB first
|
||||
Send with: IrSender.sendSony(0xF1, 0x76, 2, 15);
|
||||
rawData[32]:
|
||||
-1036650
|
||||
+2450,- 550
|
||||
+ 650,- 550 +1250,- 550 +1250,- 550 + 650,- 550
|
||||
+1250,- 550 +1250,- 550 +1250,- 550 +1250,- 550
|
||||
+ 650,- 550 + 650,- 550 + 650,- 550 +1250,- 550
|
||||
+1250,- 550 +1250,- 550 +1250
|
||||
Sum: 26450
|
||||
|
||||
Send Sony/SIRCS with 7 command and 13 address bits
|
||||
Protocol=Sony Address=0x1FF1 Command=0x76 Raw-Data=0xFF8F6 20 bits LSB first
|
||||
Send with: IrSender.sendSony(0x1FF1, 0x76, 2, 20);
|
||||
rawData[42]:
|
||||
-1040400
|
||||
+2400,- 550
|
||||
+ 650,- 550 +1250,- 550 +1250,- 550 + 650,- 550
|
||||
+1250,- 550 +1250,- 550 +1250,- 550 +1250,- 550
|
||||
+ 650,- 550 + 600,- 600 + 650,- 550 +1250,- 550
|
||||
+1250,- 550 +1250,- 550 +1250,- 550 +1250,- 550
|
||||
+1250,- 550 +1250,- 550 +1250,- 550 +1250
|
||||
Sum: 35400
|
||||
|
||||
Send Samsung 8 bit command and 8 bit address
|
||||
Protocol=Samsung Address=0xF1 Command=0x76 Raw-Data=0x8976F1F1 32 bits LSB first
|
||||
Send with: IrSender.sendSamsung(0xF1, 0x76, <numberOfRepeats>);
|
||||
rawData[68]:
|
||||
-1045200
|
||||
+4500,-4400
|
||||
+ 600,-1650 + 600,- 500 + 600,- 550 + 600,- 500
|
||||
+ 600,-1650 + 600,-1650 + 600,-1650 + 600,-1600
|
||||
+ 600,-1650 + 600,- 550 + 600,- 500 + 600,- 550
|
||||
+ 600,-1600 + 600,-1650 + 600,-1650 + 600,-1650
|
||||
+ 600,- 500 + 600,-1650 + 600,-1650 + 600,- 500
|
||||
+ 600,-1650 + 600,-1650 + 600,-1600 + 650,- 500
|
||||
+ 600,-1650 + 600,- 500 + 600,- 550 + 600,-1600
|
||||
+ 650,- 500 + 600,- 550 + 600,- 500 + 600,-1650
|
||||
+ 600
|
||||
Sum: 65550
|
||||
|
||||
Send Samsung 16 bit command and address
|
||||
Protocol=Samsung Address=0xFFF1 Command=0x9876 Raw-Data=0x9876FFF1 32 bits LSB first
|
||||
Send with: IrSender.sendSamsung(0xFFF1, 0x9876, <numberOfRepeats>);
|
||||
rawData[68]:
|
||||
-1060350
|
||||
+4500,-4450
|
||||
+ 600,-1600 + 600,- 550 + 600,- 500 + 600,- 550
|
||||
+ 600,-1650 + 600,-1650 + 550,-1650 + 600,-1650
|
||||
+ 600,-1650 + 600,-1600 + 650,-1600 + 600,-1650
|
||||
+ 600,-1650 + 600,-1600 + 600,-1650 + 600,-1650
|
||||
+ 600,- 550 + 600,-1600 + 600,-1650 + 600,- 550
|
||||
+ 600,-1600 + 600,-1650 + 600,-1650 + 600,- 500
|
||||
+ 650,- 500 + 600,- 550 + 600,- 500 + 600,-1650
|
||||
+ 600,-1650 + 600,- 550 + 600,- 500 + 600,-1650
|
||||
+ 600
|
||||
Sum: 68950
|
||||
|
||||
Send Samsung48 16 bit command
|
||||
Protocol=Samsung48 Address=0xFFF1 Command=0x9876 Raw-Data=0x6798 48 bits LSB first
|
||||
Send with: IrSender.sendSamsung48(0xFFF1, 0x9876, <numberOfRepeats>);
|
||||
rawData[100]:
|
||||
-1060250
|
||||
+4500,-4450
|
||||
+ 600,-1600 + 600,- 550 + 600,- 500 + 600,- 550
|
||||
+ 600,-1650 + 600,-1600 + 600,-1650 + 600,-1650
|
||||
+ 600,-1650 + 600,-1600 + 600,-1650 + 600,-1650
|
||||
+ 600,-1650 + 600,-1600 + 600,-1650 + 600,-1650
|
||||
+ 600,- 500 + 600,-1650 + 600,-1650 + 600,- 500
|
||||
+ 600,-1650 + 600,-1650 + 600,-1600 + 600,- 550
|
||||
+ 600,-1650 + 600,- 500 + 600,- 550 + 600,-1650
|
||||
+ 600,- 500 + 600,- 550 + 600,- 500 + 600,-1700
|
||||
+ 550,- 550 + 600,- 500 + 600,- 550 + 600,-1650
|
||||
+ 600,-1600 + 600,- 550 + 600,- 500 + 600,-1650
|
||||
+ 600,-1650 + 600,-1650 + 600,-1600 + 600,- 550
|
||||
+ 600,- 500 + 600,-1650 + 600,-1650 + 600,- 500
|
||||
+ 600
|
||||
Sum: 95800
|
||||
|
||||
Send RC5
|
||||
Protocol=RC5 Address=0x11 Command=0x36 Raw-Data=0x1476 13 bits MSB first
|
||||
Send with: IrSender.sendRC5(0x11, 0x36, <numberOfRepeats>);
|
||||
rawData[20]:
|
||||
-1076800
|
||||
+ 900,- 900
|
||||
+1800,-1750 +1800,- 850 + 950,- 850 + 900,-1750
|
||||
+ 900,- 850 + 950,- 850 +1800,-1750 + 900,- 900
|
||||
+1800
|
||||
Sum: 23150
|
||||
|
||||
Send RC5X with 7.th MSB of command set
|
||||
Protocol=RC5 Address=0x11 Command=0x76 Toggle=1 Raw-Data=0xC76 13 bits MSB first
|
||||
Send with: IrSender.sendRC5(0x11, 0x76, <numberOfRepeats>);
|
||||
rawData[20]:
|
||||
-1035650
|
||||
+1800,-1700
|
||||
+ 950,- 850 +1800,- 850 + 950,- 850 + 900,-1750
|
||||
+ 950,- 850 + 900,- 850 +1800,-1750 + 950,- 850
|
||||
+1800
|
||||
Sum: 23100
|
||||
|
||||
Send RC6
|
||||
Protocol=RC6 Address=0xF1 Command=0x76 Raw-Data=0xF176 20 bits MSB first
|
||||
Send with: IrSender.sendRC6(0xF1, 0x76, <numberOfRepeats>);
|
||||
rawData[36]:
|
||||
-1033000
|
||||
+2650,- 850
|
||||
+ 500,- 850 + 500,- 400 + 500,- 400 + 500,- 850
|
||||
+1350,- 450 + 450,- 400 + 500,- 400 + 500,- 850
|
||||
+ 500,- 400 + 500,- 400 + 950,- 850 + 950,- 400
|
||||
+ 500,- 400 + 500,- 850 + 950,- 400 + 500,- 850
|
||||
+ 500
|
||||
Sum: 23300
|
||||
|
||||
Send RC6A with 14 bit 0x2711 as extra
|
||||
Protocol=RC6A Address=0xF1 Command=0x76 Extra=0x2711 Toggle=1 Raw-Data=0xA711F176 35 bits MSB first
|
||||
Send with: IrSender.sendRC6A(0xF1, 0x76, <numberOfRepeats>, 0x2711);
|
||||
rawData[58]:
|
||||
-1032900
|
||||
+2650,- 900
|
||||
+ 450,- 450 + 450,- 450 + 450,- 850 +1400,-1300
|
||||
+ 950,- 850 + 500,- 400 + 950,- 400 + 500,- 450
|
||||
+ 450,- 850 + 500,- 400 + 500,- 400 + 950,- 850
|
||||
+ 500,- 400 + 500,- 400 + 950,- 450 + 450,- 450
|
||||
+ 450,- 450 + 450,- 400 + 500,- 850 + 500,- 400
|
||||
+ 500,- 400 + 950,- 850 + 950,- 400 + 500,- 400
|
||||
+ 500,- 850 + 950,- 450 + 450,- 850 + 500
|
||||
Sum: 36850
|
||||
|
||||
Send Bang&Olufsen
|
||||
- ENABLE_BEO_WITHOUT_FRAME_GAP is enabled
|
||||
- Now print raw data and try to decode the first 6 entries, which results in rawData 0x0
|
||||
rawData[36]:
|
||||
-1033000
|
||||
+ 250,-2850
|
||||
+ 250,-2850 + 250,-15250 + 250,-2850 + 250,-9050
|
||||
+ 250,-6000 + 200,-5950 + 250,-6000 + 200,-2900
|
||||
+ 250,-5950 + 200,-6000 + 200,-9050 + 250,-2900
|
||||
+ 250,-9000 + 250,-6000 + 250,-5950 + 250,-2850
|
||||
+ 250
|
||||
Sum: 105700
|
||||
Protocol=Bang&Olufsen Address=0x0 Command=0x0 Raw-Data=0x0 0 bits MSB first
|
||||
|
||||
- Remove trailing 6 entries, which is equivalent to define RECORD_GAP_MICROS < 15000, to enable successful B&O decode
|
||||
Protocol=Bang&Olufsen Address=0xF1 Command=0x76 Raw-Data=0xF176 16 bits MSB first
|
||||
Send with: IrSender.sendBang&Olufsen(0xF1, 0x76, <numberOfRepeats>);
|
||||
rawData[38]:
|
||||
-15250
|
||||
+ 250,-2850
|
||||
+ 250,-9050 + 250,-6000 + 200,-5950 + 250,-6000
|
||||
+ 200,-2900 + 250,-5950 + 200,-6000 + 200,-9050
|
||||
+ 250,-2900 + 250,-9000 + 250,-6000 + 250,-5950
|
||||
+ 250,-2850 + 250,-9100 + 200,-5950 + 250,-2900
|
||||
+ 200,-12150 + 250
|
||||
Sum: 115000
|
||||
|
||||
Send MagiQuest
|
||||
Protocol=MagiQuest Address=0xFFF1 Command=0x76 Raw-Data=0x6BCDFFF1 56 bits MSB first
|
||||
Send with: IrSender.sendMagiQuest(0x6BCDFFF1, 0x76, <numberOfRepeats>);
|
||||
rawData[112]:
|
||||
-1088700
|
||||
+ 350,- 800 + 350,- 800 + 350,- 800 + 350,- 800
|
||||
+ 350,- 800 + 350,- 800 + 350,- 800 + 350,- 850
|
||||
+ 600,- 550 + 600,- 550 + 300,- 850 + 600,- 550
|
||||
+ 300,- 800 + 650,- 500 + 650,- 500 + 600,- 550
|
||||
+ 600,- 550 + 350,- 800 + 350,- 800 + 600,- 550
|
||||
+ 600,- 550 + 350,- 800 + 600,- 550 + 600,- 550
|
||||
+ 600,- 550 + 600,- 550 + 600,- 550 + 600,- 550
|
||||
+ 600,- 550 + 600,- 550 + 600,- 550 + 600,- 550
|
||||
+ 600,- 550 + 600,- 550 + 600,- 550 + 350,- 800
|
||||
+ 350,- 800 + 350,- 800 + 600,- 600 + 300,- 850
|
||||
+ 300,- 800 + 650,- 550 + 600,- 550 + 600,- 550
|
||||
+ 300,- 800 + 600,- 550 + 600,- 550 + 350,- 850
|
||||
+ 300,- 800 + 350,- 800 + 600,- 550 + 600,- 550
|
||||
+ 350,- 800 + 600,- 550 + 600,- 550 + 600
|
||||
Sum: 63850
|
||||
|
||||
Send next protocols with IrSender.write
|
||||
|
||||
Send JVC
|
||||
Protocol=JVC Address=0xF1 Command=0x76 Raw-Data=0x76F1 16 bits LSB first
|
||||
Send with: IrSender.sendJVC(0xF1, 0x76, <numberOfRepeats>);
|
||||
rawData[36]:
|
||||
-1085250
|
||||
+8400,-4150
|
||||
+ 550,-1550 + 550,- 500 + 550,- 500 + 550,- 500
|
||||
+ 550,-1550 + 550,-1550 + 550,-1550 + 550,-1550
|
||||
+ 550,- 500 + 550,-1550 + 550,-1550 + 550,- 500
|
||||
+ 550,-1550 + 550,-1550 + 550,-1550 + 550,- 500
|
||||
+ 550
|
||||
Sum: 40400
|
||||
|
||||
Send LG
|
||||
Protocol=LG Address=0xF1 Command=0x9876 Raw-Data=0xF19876E 28 bits MSB first
|
||||
Send with: IrSender.sendLG(0xF1, 0x9876, <numberOfRepeats>);
|
||||
rawData[60]:
|
||||
-1039450
|
||||
+8950,-4150
|
||||
+ 550,-1550 + 500,-1550 + 500,-1550 + 550,-1550
|
||||
+ 500,- 550 + 500,- 550 + 500,- 550 + 500,-1550
|
||||
+ 550,-1550 + 500,- 550 + 500,- 550 + 500,-1550
|
||||
+ 550,-1550 + 500,- 550 + 500,- 550 + 500,- 550
|
||||
+ 500,- 500 + 550,-1550 + 500,-1550 + 550,-1550
|
||||
+ 500,- 550 + 500,-1550 + 550,-1550 + 500,- 550
|
||||
+ 500,-1550 + 550,-1550 + 500,-1550 + 550,- 500
|
||||
+ 550
|
||||
Sum: 59400
|
||||
|
||||
Send Bosewave with no address and 8 command bits
|
||||
Protocol=BoseWave Address=0x0 Command=0x76 Raw-Data=0x8976 16 bits LSB first
|
||||
Send with: IrSender.sendBoseWave(0x0, 0x76, <numberOfRepeats>);
|
||||
rawData[36]:
|
||||
-1056200
|
||||
+1050,-1450
|
||||
+ 550,- 450 + 550,-1400 + 550,-1450 + 550,- 450
|
||||
+ 550,-1400 + 550,-1450 + 550,-1400 + 550,- 450
|
||||
+ 550,-1450 + 550,- 450 + 550,- 400 + 550,-1450
|
||||
+ 550,- 450 + 550,- 450 + 550,- 450 + 550,-1400
|
||||
+ 550
|
||||
Sum: 26800
|
||||
|
||||
Send FAST
|
||||
Protocol=FAST Address=0x0 Command=0x76 Raw-Data=0x8976 16 bits LSB first
|
||||
Send with: IrSender.sendFAST(0x0, 0x76, <numberOfRepeats>);
|
||||
rawData[36]:
|
||||
-1040250
|
||||
+2150,-1000
|
||||
+ 550,- 550 + 550,-1550 + 550,-1500 + 550,- 550
|
||||
+ 550,-1550 + 550,-1550 + 550,-1550 + 500,- 550
|
||||
+ 550,-1550 + 550,- 500 + 550,- 500 + 550,-1550
|
||||
+ 550,- 500 + 550,- 500 + 550,- 500 + 550,-1550
|
||||
+ 550
|
||||
Sum: 28950
|
||||
|
||||
Force buffer overflow by sending 280 marks and spaces
|
||||
Overflow
|
||||
Try to increase the "RAW_BUFFER_LENGTH" value of 200 in ../src/UnitTest.cpp
|
||||
rawData[200]:
|
||||
-1039500
|
||||
+ 200,- 500
|
||||
+ 250,- 550 + 250,- 500 + 250,- 500 + 250,- 500
|
||||
+ 250,- 500 + 250,- 500 + 250,- 500 + 250,- 550
|
||||
+ 200,- 500 + 250,- 500 + 250,- 500 + 250,- 500
|
||||
+ 250,- 500 + 250,- 500 + 250,- 500 + 250,- 500
|
||||
+ 250,- 500 + 250,- 500 + 250,- 500 + 250,- 500
|
||||
+ 250,- 500 + 250,- 500 + 250,- 500 + 250,- 500
|
||||
+ 250,- 500 + 250,- 500 + 250,- 500 + 250,- 500
|
||||
+ 250,- 500 + 250,- 500 + 250,- 500 + 250,- 500
|
||||
+ 250,- 500 + 250,- 500 + 250,- 500 + 250,- 500
|
||||
+ 250,- 500 + 250,- 500 + 250,- 500 + 250,- 500
|
||||
+ 250,- 500 + 250,- 500 + 250,- 500 + 250,- 500
|
||||
+ 250,- 500 + 250,- 500 + 250,- 500 + 250,- 500
|
||||
+ 250,- 500 + 250,- 500 + 250,- 500 + 250,- 500
|
||||
+ 250,- 500 + 250,- 500 + 250,- 500 + 250,- 500
|
||||
+ 250,- 500 + 250,- 500 + 250,- 500 + 250,- 500
|
||||
+ 250,- 500 + 250,- 500 + 250,- 500 + 250,- 500
|
||||
+ 250,- 500 + 250,- 500 + 250,- 500 + 250,- 500
|
||||
+ 250,- 500 + 250,- 500 + 250,- 500 + 250,- 500
|
||||
+ 250,- 500 + 250,- 500 + 250,- 500 + 250,- 500
|
||||
+ 250,- 500 + 250,- 500 + 250,- 500 + 250,- 500
|
||||
+ 250,- 500 + 250,- 500 + 250,- 500 + 250,- 500
|
||||
+ 250,- 500 + 250,- 500 + 250,- 500 + 250,- 500
|
||||
+ 250,- 500 + 250,- 500 + 250,- 500 + 250,- 500
|
||||
+ 250,- 500 + 250,- 500 + 250,- 500 + 250,- 500
|
||||
+ 250,- 500 + 250,- 500 + 250
|
||||
Sum: 74500
|
||||
ERROR: Unknown protocol
|
||||
|
||||
|
||||
address=0xF2 command=0x87
|
||||
|
||||
Send NEC with 8 bit address and complete NEC frames as repeats to force decoding as NEC2
|
||||
Protocol=NEC Address=0xF2 Command=0x87 Raw-Data=0x78870DF2 32 bits LSB first
|
||||
Send with: IrSender.sendNEC(0xF2, 0x87, <numberOfRepeats>);
|
||||
rawData[68]:
|
||||
-3276750
|
||||
+8950,-4400
|
||||
+ 600,- 550 + 600,-1600 + 600,- 550 + 600,- 500
|
||||
+ 600,-1650 + 600,-1650 + 600,-1650 + 600,-1600
|
||||
+ 600,-1650 + 600,- 550 + 600,-1600 + 650,-1600
|
||||
+ 600,- 550 + 600,- 500 + 600,- 550 + 600,- 500
|
||||
+ 600,-1650 + 600,-1650 + 600,-1650 + 600,- 500
|
||||
+ 600,- 550 + 600,- 500 + 600,- 550 + 600,-1650
|
||||
+ 550,- 550 + 600,- 500 + 650,- 500 + 600,-1650
|
||||
+ 600,-1650 + 600,-1650 + 600,-1600 + 600,- 550
|
||||
+ 600
|
||||
Sum: 67800
|
||||
|
||||
Protocol=NEC2 Address=0xF2 Command=0x87 Repeat gap=65900us Raw-Data=0x78870DF2 32 bits LSB first
|
||||
Send with: IrSender.sendNEC2(0xF2, 0x87, <numberOfRepeats>);
|
||||
rawData[68]:
|
||||
-65900
|
||||
+8900,-4450
|
||||
+ 550,- 550 + 600,-1650 + 600,- 500 + 600,- 550
|
||||
+ 600,-1600 + 650,-1600 + 600,-1650 + 600,-1650
|
||||
+ 600,-1650 + 600,- 500 + 600,-1650 + 600,-1650
|
||||
+ 600,- 550 + 600,- 500 + 600,- 550 + 600,- 500
|
||||
+ 600,-1650 + 600,-1650 + 600,-1650 + 600,- 500
|
||||
+ 600,- 550 + 600,- 500 + 600,- 550 + 600,-1600
|
||||
+ 600,- 550 + 600,- 500 + 600,- 550 + 600,-1600
|
||||
+ 650,-1600 + 600,-1650 + 600,-1650 + 600,- 500
|
||||
+ 600
|
||||
Sum: 67750
|
||||
|
||||
Send NEC with 16 bit address
|
||||
Protocol=NEC Address=0xF2 Command=0x87 Raw-Data=0x78870DF2 32 bits LSB first
|
||||
Send with: IrSender.sendNEC(0xF2, 0x87, <numberOfRepeats>);
|
||||
rawData[68]:
|
||||
-1060150
|
||||
+8900,-4450
|
||||
+ 600,- 500 + 600,-1650 + 600,- 550 + 600,- 500
|
||||
+ 600,-1650 + 600,-1650 + 600,-1600 + 650,-1600
|
||||
+ 600,-1650 + 600,- 550 + 600,-1600 + 600,-1650
|
||||
+ 600,- 550 + 600,- 500 + 600,- 550 + 600,- 500
|
||||
+ 600,-1650 + 600,-1650 + 600,-1650 + 600,- 550
|
||||
+ 600,- 500 + 600,- 550 + 600,- 500 + 600,-1650
|
||||
+ 600,- 550 + 600,- 500 + 600,- 550 + 600,-1600
|
||||
+ 650,-1600 + 600,-1650 + 600,-1650 + 600,- 500
|
||||
+ 600
|
||||
Sum: 67800
|
||||
|
||||
Send NEC2 with 16 bit address
|
||||
Protocol=NEC Address=0xF2 Command=0x87 Raw-Data=0x78870DF2 32 bits LSB first
|
||||
Send with: IrSender.sendNEC(0xF2, 0x87, <numberOfRepeats>);
|
||||
rawData[68]:
|
||||
-1058650
|
||||
+8900,-4400
|
||||
+ 650,- 500 + 600,-1650 + 600,- 500 + 600,- 550
|
||||
+ 600,-1600 + 600,-1650 + 600,-1650 + 600,-1650
|
||||
+ 600,-1600 + 650,- 500 + 600,-1650 + 600,-1600
|
||||
+ 600,- 550 + 600,- 500 + 600,- 550 + 600,- 550
|
||||
+ 600,-1600 + 600,-1650 + 600,-1650 + 600,- 550
|
||||
+ 600,- 500 + 600,- 550 + 600,- 500 + 600,-1650
|
||||
+ 600,- 550 + 600,- 500 + 600,- 550 + 600,-1600
|
||||
+ 650,-1600 + 600,-1650 + 600,-1650 + 600,- 500
|
||||
+ 600
|
||||
Sum: 67750
|
||||
|
||||
Send Onkyo (NEC with 16 bit command)
|
||||
Protocol=Onkyo Address=0xF2 Command=0x8887 Raw-Data=0x888700F2 32 bits LSB first
|
||||
Send with: IrSender.sendOnkyo(0xF2, 0x8887, <numberOfRepeats>);
|
||||
rawData[68]:
|
||||
-1059250
|
||||
+8900,-4450
|
||||
+ 600,- 500 + 600,-1650 + 600,- 500 + 600,- 550
|
||||
+ 600,-1650 + 600,-1600 + 600,-1650 + 600,-1650
|
||||
+ 600,- 500 + 600,- 550 + 600,- 500 + 600,- 550
|
||||
+ 600,- 500 + 650,- 500 + 600,- 500 + 600,- 550
|
||||
+ 600,-1650 + 600,-1600 + 600,-1650 + 600,- 500
|
||||
+ 600,- 550 + 600,- 500 + 600,- 550 + 600,-1600
|
||||
+ 650,- 500 + 600,- 550 + 600,- 500 + 600,-1650
|
||||
+ 600,- 550 + 600,- 500 + 600,- 550 + 600,-1600
|
||||
+ 600
|
||||
Sum: 62150
|
||||
|
||||
Send Apple
|
||||
Protocol=Apple Address=0xF2 Command=0x87 Raw-Data=0xF28787EE 32 bits LSB first
|
||||
Send with: IrSender.sendApple(0xF2, 0x87, <numberOfRepeats>);
|
||||
rawData[68]:
|
||||
-1057650
|
||||
+8900,-4400
|
||||
+ 600,- 550 + 600,-1650 + 600,-1600 + 600,-1650
|
||||
+ 600,- 550 + 600,-1600 + 650,-1600 + 600,-1650
|
||||
+ 600,-1650 + 600,-1600 + 650,-1600 + 600,- 550
|
||||
+ 600,- 500 + 600,- 550 + 600,- 500 + 600,-1650
|
||||
+ 600,-1650 + 600,-1600 + 650,-1600 + 600,- 550
|
||||
+ 600,- 500 + 600,- 550 + 600,- 500 + 600,-1650
|
||||
+ 600,- 550 + 600,-1600 + 600,- 550 + 600,- 500
|
||||
+ 600,-1650 + 600,-1650 + 600,-1650 + 600,-1600
|
||||
+ 650
|
||||
Sum: 71100
|
||||
|
||||
Send Panasonic
|
||||
Protocol=Panasonic Address=0xF2 Command=0x87 Raw-Data=0xA8870F20 48 bits LSB first
|
||||
Send with: IrSender.sendPanasonic(0xF2, 0x87, <numberOfRepeats>);
|
||||
rawData[100]:
|
||||
-1057750
|
||||
+3450,-1700
|
||||
+ 500,- 400 + 450,-1250 + 500,- 400 + 450,- 400
|
||||
+ 450,- 400 + 500,- 400 + 450,- 400 + 450,- 450
|
||||
+ 450,- 400 + 450,- 400 + 500,- 400 + 450,- 400
|
||||
+ 450,- 400 + 500,-1250 + 450,- 400 + 500,- 400
|
||||
+ 450,- 400 + 450,- 400 + 500,- 400 + 450,- 400
|
||||
+ 450,- 450 + 450,-1250 + 450,- 400 + 500,- 400
|
||||
+ 450,-1250 + 450,-1300 + 450,-1250 + 500,-1250
|
||||
+ 450,- 400 + 450,- 450 + 450,- 400 + 450,- 450
|
||||
+ 450,-1250 + 450,-1300 + 450,-1250 + 450,- 400
|
||||
+ 500,- 400 + 450,- 400 + 450,- 450 + 450,-1250
|
||||
+ 450,- 400 + 500,- 400 + 450,- 400 + 450,-1300
|
||||
+ 450,- 400 + 450,-1300 + 450,- 400 + 450,-1250
|
||||
+ 500
|
||||
Sum: 59350
|
||||
|
||||
Send Kaseikyo with 0x4711 as Vendor ID
|
||||
Protocol=Kaseikyo Address=0xF2 Command=0x87 Extra=0x4711 Raw-Data=0xAB870F23 48 bits LSB first
|
||||
Send with: IrSender.sendKaseikyo(0xF2, 0x87, <numberOfRepeats>, 0x4711);
|
||||
rawData[100]:
|
||||
-1077750
|
||||
+3450,-1700
|
||||
+ 450,-1250 + 450,- 450 + 450,- 400 + 450,- 400
|
||||
+ 450,-1300 + 450,- 400 + 450,- 400 + 500,- 400
|
||||
+ 450,-1250 + 450,-1300 + 450,-1250 + 450,- 400
|
||||
+ 500,- 400 + 450,- 400 + 450,-1300 + 450,- 400
|
||||
+ 450,-1250 + 450,-1300 + 450,- 400 + 500,- 400
|
||||
+ 450,- 400 + 450,-1300 + 450,- 400 + 450,- 400
|
||||
+ 500,-1250 + 450,-1250 + 450,-1300 + 450,-1250
|
||||
+ 500,- 400 + 450,- 400 + 450,- 400 + 500,- 400
|
||||
+ 450,-1300 + 450,-1250 + 500,-1250 + 450,- 400
|
||||
+ 450,- 400 + 500,- 400 + 450,- 400 + 450,-1300
|
||||
+ 450,-1250 + 450,-1300 + 450,- 400 + 450,-1300
|
||||
+ 450,- 400 + 450,-1250 + 450,- 450 + 450,-1250
|
||||
+ 450
|
||||
Sum: 66100
|
||||
|
||||
Send Kaseikyo_Denon variant
|
||||
Protocol=Kaseikyo_Denon Address=0xF2 Command=0x87 Raw-Data=0xA8870F20 48 bits LSB first
|
||||
Send with: IrSender.sendKaseikyo_Denon(0xF2, 0x87, <numberOfRepeats>);
|
||||
rawData[100]:
|
||||
-1078550
|
||||
+3450,-1750
|
||||
+ 450,- 400 + 450,- 400 + 500,-1250 + 450,- 400
|
||||
+ 450,-1300 + 450,- 400 + 450,-1250 + 450,- 450
|
||||
+ 450,- 400 + 450,-1300 + 450,- 400 + 450,- 400
|
||||
+ 450,-1300 + 450,-1250 + 450,- 450 + 450,- 400
|
||||
+ 450,- 400 + 500,- 400 + 450,- 400 + 450,- 450
|
||||
+ 450,- 400 + 450,-1250 + 450,- 450 + 450,- 400
|
||||
+ 450,-1250 + 500,-1250 + 450,-1250 + 450,-1300
|
||||
+ 450,- 400 + 450,- 400 + 500,- 350 + 500,- 400
|
||||
+ 450,-1300 + 450,-1250 + 450,-1300 + 450,- 400
|
||||
+ 450,- 400 + 450,- 450 + 450,- 400 + 450,-1300
|
||||
+ 450,- 400 + 450,- 400 + 500,- 400 + 450,-1250
|
||||
+ 500,- 400 + 450,-1250 + 450,- 450 + 450,-1250
|
||||
+ 450
|
||||
Sum: 62700
|
||||
|
||||
Send Denon
|
||||
Protocol=Denon Address=0x12 Command=0x87 Raw-Data=0x10F2 15 bits LSB first
|
||||
Send with: IrSender.sendDenon(0x12, 0x87, <numberOfRepeats>);
|
||||
rawData[32]:
|
||||
-1076250
|
||||
+ 300,- 750 + 300,-1750 + 300,- 750 + 300,- 750
|
||||
+ 300,-1750 + 300,-1800 + 300,-1750 + 300,-1800
|
||||
+ 250,- 750 + 300,- 750 + 300,- 750 + 300,- 750
|
||||
+ 300,-1750 + 300,- 750 + 300,- 750 + 300
|
||||
Sum: 22100
|
||||
|
||||
Send Denon/Sharp variant
|
||||
Protocol=Sharp Address=0x12 Command=0x87 Raw-Data=0x50F2 15 bits LSB first
|
||||
Send with: IrSender.sendSharp(0x12, 0x87, <numberOfRepeats>);
|
||||
rawData[32]:
|
||||
-1018800
|
||||
+ 300,- 700 + 300,-1800 + 250,- 750 + 300,- 750
|
||||
+ 300,-1800 + 250,-1800 + 300,-1750 + 300,-1800
|
||||
+ 300,- 750 + 250,- 750 + 300,- 750 + 300,- 750
|
||||
+ 300,-1750 + 300,- 750 + 300,-1800 + 250
|
||||
Sum: 23050
|
||||
|
||||
@@ -0,0 +1,825 @@
|
||||
START UnitTest.cpp from Feb 24 2023
|
||||
Using library version 4.1.0
|
||||
Ready to receive IR signals of protocols: NEC/NEC2/Onkyo/Apple, Panasonic/Kaseikyo, Denon/Sharp, Sony, RC5, RC6, LG, JVC, Samsung, Bang & Olufsen, FAST, Bosewave , MagiQuest, Universal Pulse Distance Width, Hash at pin 14
|
||||
Send IR signals at pin 12
|
||||
If you connect debug pin 13 to ground, raw data is always printed
|
||||
Send signal mark duration for 38kHz is 8 us, pulse narrowing correction is 600 ns, total period is 26 us
|
||||
16000 us is the (minimum) gap, after which the start of a new IR packet is assumed
|
||||
100 us are subtracted from all marks and added to all spaces for decoding
|
||||
|
||||
address=0xFFF1 command=0x76
|
||||
|
||||
Send NEC with 8 bit address
|
||||
Protocol=NEC Address=0xF1 Command=0x76 Raw-Data=0x89760EF1 32 bits LSB first
|
||||
Send with: IrSender.sendNEC(0xF1, 0x76, <numberOfRepeats>);
|
||||
rawData[68]:
|
||||
-1050650
|
||||
+9050,-4450
|
||||
+ 650,-1600 + 700,- 450 + 650,- 500 + 650,- 450
|
||||
+ 700,-1600 + 650,-1600 + 650,-1600 + 650,-1600
|
||||
+ 700,- 450 + 650,-1600 + 650,-1650 + 650,-1600
|
||||
+ 650,- 450 + 700,- 450 + 650,- 500 + 650,- 450
|
||||
+ 700,- 450 + 650,-1600 + 650,-1600 + 700,- 450
|
||||
+ 650,-1600 + 650,-1600 + 700,-1600 + 650,- 450
|
||||
+ 700,-1600 + 650,- 450 + 700,- 450 + 650,-1600
|
||||
+ 650,- 500 + 650,- 450 + 700,- 450 + 650,-1600
|
||||
+ 700
|
||||
Sum: 68500
|
||||
|
||||
Send NEC with 16 bit address
|
||||
Protocol=NEC Address=0xFFF1 Command=0x76 Raw-Data=0x8976FFF1 32 bits LSB first
|
||||
Send with: IrSender.sendNEC(0xFFF1, 0x76, <numberOfRepeats>);
|
||||
rawData[68]:
|
||||
-1060200
|
||||
+9050,-4400
|
||||
+ 650,-1600 + 650,- 500 + 650,- 450 + 700,- 450
|
||||
+ 650,-1600 + 650,-1600 + 700,-1600 + 650,-1600
|
||||
+ 650,-1600 + 650,-1600 + 700,-1600 + 650,-1600
|
||||
+ 650,-1600 + 650,-1600 + 700,-1600 + 650,-1600
|
||||
+ 650,- 500 + 650,-1600 + 650,-1600 + 650,- 500
|
||||
+ 650,-1600 + 650,-1600 + 650,-1650 + 650,- 450
|
||||
+ 650,-1600 + 700,- 450 + 650,- 500 + 650,-1600
|
||||
+ 650,- 500 + 650,- 450 + 650,- 500 + 650,-1600
|
||||
+ 650
|
||||
Sum: 74050
|
||||
|
||||
Send NEC2 with 16 bit address
|
||||
Protocol=NEC Address=0xFFF1 Command=0x76 Raw-Data=0x8976FFF1 32 bits LSB first
|
||||
Send with: IrSender.sendNEC(0xFFF1, 0x76, <numberOfRepeats>);
|
||||
rawData[68]:
|
||||
-1060450
|
||||
+9050,-4450
|
||||
+ 650,-1600 + 650,- 500 + 650,- 450 + 650,- 500
|
||||
+ 650,-1600 + 650,-1600 + 700,-1600 + 650,-1600
|
||||
+ 650,-1600 + 650,-1600 + 700,-1600 + 650,-1600
|
||||
+ 650,-1600 + 650,-1600 + 700,-1600 + 650,-1600
|
||||
+ 650,- 500 + 650,-1600 + 650,-1600 + 650,- 500
|
||||
+ 650,-1600 + 650,-1600 + 700,-1600 + 650,- 500
|
||||
+ 650,-1600 + 650,- 500 + 650,- 500 + 650,-1600
|
||||
+ 650,- 450 + 700,- 450 + 650,- 500 + 650,-1600
|
||||
+ 650
|
||||
Sum: 74150
|
||||
|
||||
Send NEC Pronto data with 8 bit address 0x80 and command 0x45 and no repeats
|
||||
Protocol=NEC Address=0x80 Command=0x45 Raw-Data=0xBA457F80 32 bits LSB first
|
||||
Send with: IrSender.sendNEC(0x80, 0x45, <numberOfRepeats>);
|
||||
rawData[68]:
|
||||
-1065600
|
||||
+9200,-4400
|
||||
+ 700,- 450 + 700,- 450 + 700,- 500 + 650,- 500
|
||||
+ 700,- 500 + 650,- 500 + 650,- 550 + 700,-1550
|
||||
+ 700,-1550 + 700,-1550 + 700,-1550 + 650,-1550
|
||||
+ 700,-1550 + 700,-1550 + 700,-1550 + 700,- 450
|
||||
+ 700,-1550 + 650,- 500 + 650,-1600 + 700,- 450
|
||||
+ 700,- 450 + 700,- 450 + 700,-1550 + 700,- 450
|
||||
+ 750,- 450 + 700,-1500 + 700,- 450 + 700,-1550
|
||||
+ 700,-1550 + 700,-1550 + 700,- 450 + 700,-1550
|
||||
+ 700
|
||||
Sum: 68800
|
||||
|
||||
Send NEC sendRaw data with 8 bit address=0xFB04 and command 0x08 and exact timing (16 bit array format)
|
||||
Protocol=NEC Address=0x4 Command=0x8 Raw-Data=0xF708FB04 32 bits LSB first
|
||||
Send with: IrSender.sendNEC(0x4, 0x8, <numberOfRepeats>);
|
||||
rawData[68]:
|
||||
-1066550
|
||||
+9150,-4400
|
||||
+ 650,- 500 + 650,- 450 + 700,-1600 + 650,- 450
|
||||
+ 700,- 450 + 650,- 500 + 650,- 450 + 650,- 500
|
||||
+ 650,-1600 + 700,-1600 + 650,- 450 + 700,-1600
|
||||
+ 650,-1600 + 700,-1600 + 650,-1600 + 650,-1650
|
||||
+ 650,- 450 + 700,- 450 + 650,- 500 + 650,-1600
|
||||
+ 650,- 500 + 650,- 450 + 700,- 450 + 650,- 500
|
||||
+ 650,-1600 + 650,-1600 + 700,-1600 + 650,- 500
|
||||
+ 650,-1600 + 650,-1600 + 700,-1600 + 650,-1600
|
||||
+ 700
|
||||
Sum: 68700
|
||||
|
||||
Send ONKYO with 16 bit address 0x0102 and 16 bit command 0x0304 with NECRaw(0x03040102)
|
||||
Protocol=Onkyo Address=0x102 Command=0x304 Raw-Data=0x3040102 32 bits LSB first
|
||||
Send with: IrSender.sendOnkyo(0x102, 0x304, <numberOfRepeats>);
|
||||
rawData[68]:
|
||||
-1064800
|
||||
+9050,-4450
|
||||
+ 650,- 450 + 650,-1600 + 700,- 450 + 650,- 500
|
||||
+ 650,- 450 + 650,- 500 + 650,- 500 + 650,- 450
|
||||
+ 650,-1600 + 700,- 450 + 700,- 450 + 650,- 500
|
||||
+ 650,- 450 + 650,- 500 + 650,- 450 + 700,- 450
|
||||
+ 650,- 500 + 650,- 450 + 700,-1600 + 650,- 450
|
||||
+ 650,- 500 + 650,- 450 + 650,- 500 + 650,- 500
|
||||
+ 650,-1600 + 650,-1600 + 650,- 500 + 650,- 450
|
||||
+ 650,- 550 + 650,- 500 + 600,- 500 + 650,- 500
|
||||
+ 650
|
||||
Sum: 56050
|
||||
|
||||
Send ONKYO with 16 bit address 0x0102 and command 0x34 with old 32 bit format MSB first (0x40802CD3)
|
||||
Protocol=NEC Address=0x102 Command=0x34 Raw-Data=0xCB340102 32 bits LSB first
|
||||
Send with: IrSender.sendNEC(0x102, 0x34, <numberOfRepeats>);
|
||||
rawData[68]:
|
||||
-1066900
|
||||
+9050,-4400
|
||||
+ 650,- 500 + 650,-1600 + 650,- 500 + 650,- 450
|
||||
+ 650,- 500 + 650,- 450 + 700,- 450 + 650,- 500
|
||||
+ 650,-1600 + 650,- 500 + 650,- 450 + 650,- 550
|
||||
+ 650,- 450 + 700,- 450 + 650,- 500 + 650,- 450
|
||||
+ 650,- 500 + 650,- 450 + 700,-1600 + 650,- 450
|
||||
+ 700,-1600 + 650,-1600 + 650,- 500 + 650,- 450
|
||||
+ 650,-1600 + 700,-1600 + 600,- 500 + 650,-1650
|
||||
+ 650,- 450 + 700,- 450 + 650,-1600 + 650,-1600
|
||||
+ 700
|
||||
Sum: 61700
|
||||
|
||||
Send Panasonic 0xB, 0x10 as 48 bit generic PulseDistance using ProtocolConstants
|
||||
Protocol=Panasonic Address=0x10B Command=0xA0 Raw-Data=0xA010B02002 48 bits LSB first
|
||||
Send with: IrSender.sendPanasonic(0x10B, 0xA0, <numberOfRepeats>);
|
||||
rawData[100]:
|
||||
-1064700
|
||||
+3550,-1650
|
||||
+ 550,- 350 + 500,-1250 + 500,- 400 + 500,- 350
|
||||
+ 500,- 400 + 500,- 350 + 500,- 400 + 500,- 350
|
||||
+ 500,- 400 + 500,- 350 + 500,- 400 + 500,- 350
|
||||
+ 500,- 400 + 450,-1300 + 500,- 350 + 500,- 400
|
||||
+ 500,- 350 + 500,- 400 + 500,- 350 + 500,- 400
|
||||
+ 500,-1250 + 500,-1250 + 500,- 350 + 500,-1250
|
||||
+ 500,- 400 + 500,- 350 + 500,- 400 + 500,- 350
|
||||
+ 500,-1250 + 500,- 400 + 500,- 350 + 500,- 400
|
||||
+ 500,- 350 + 550,- 350 + 500,- 350 + 550,- 350
|
||||
+ 500,- 350 + 500,-1250 + 500,- 400 + 500,-1250
|
||||
+ 500,- 350 + 550,- 350 + 500,- 350 + 550,- 350
|
||||
+ 500,- 350 + 550,- 350 + 500,- 400 + 500,- 350
|
||||
+ 500
|
||||
Sum: 54750
|
||||
|
||||
Send Panasonic 0xB, 0x10 as generic 48 bit PulseDistance
|
||||
LSB first
|
||||
Protocol=Panasonic Address=0x10B Command=0xA0 Raw-Data=0xA010B02002 48 bits LSB first
|
||||
Send with: IrSender.sendPanasonic(0x10B, 0xA0, <numberOfRepeats>);
|
||||
rawData[100]:
|
||||
-1082450
|
||||
+3550,-1600
|
||||
+ 550,- 350 + 550,-1150 + 550,- 300 + 600,- 300
|
||||
+ 550,- 300 + 550,- 300 + 600,- 300 + 550,- 300
|
||||
+ 550,- 300 + 550,- 350 + 550,- 300 + 550,- 350
|
||||
+ 550,- 300 + 550,-1200 + 550,- 300 + 550,- 300
|
||||
+ 550,- 350 + 550,- 300 + 550,- 300 + 550,- 350
|
||||
+ 550,-1150 + 550,-1200 + 550,- 300 + 550,-1200
|
||||
+ 550,- 300 + 550,- 300 + 550,- 300 + 600,- 300
|
||||
+ 550,-1150 + 600,- 300 + 550,- 300 + 550,- 300
|
||||
+ 550,- 350 + 550,- 300 + 550,- 350 + 550,- 300
|
||||
+ 550,- 300 + 550,-1200 + 550,- 300 + 550,-1200
|
||||
+ 550,- 300 + 550,- 300 + 600,- 300 + 550,- 300
|
||||
+ 550,- 300 + 600,- 300 + 550,- 300 + 550,- 300
|
||||
+ 550
|
||||
Sum: 54200
|
||||
|
||||
MSB first
|
||||
Protocol=Panasonic Address=0xB Command=0x10 Raw-Data=0xA01000B02002 48 bits LSB first
|
||||
Send with: IrSender.sendPanasonic(0xB, 0x10, <numberOfRepeats>);
|
||||
rawData[100]:
|
||||
-1076300
|
||||
+3550,-1600
|
||||
+ 550,- 350 + 550,-1150 + 550,- 300 + 600,- 300
|
||||
+ 550,- 300 + 600,- 300 + 550,- 300 + 550,- 300
|
||||
+ 600,- 300 + 550,- 300 + 550,- 300 + 600,- 300
|
||||
+ 550,- 300 + 550,-1200 + 550,- 300 + 550,- 300
|
||||
+ 550,- 350 + 550,- 300 + 550,- 300 + 550,- 350
|
||||
+ 550,-1150 + 550,-1200 + 550,- 300 + 550,-1200
|
||||
+ 550,- 300 + 550,- 300 + 550,- 350 + 550,- 300
|
||||
+ 550,- 350 + 550,- 350 + 550,- 300 + 550,- 300
|
||||
+ 550,- 350 + 550,- 300 + 550,- 300 + 550,- 350
|
||||
+ 550,-1150 + 550,- 300 + 600,- 300 + 550,- 300
|
||||
+ 550,- 300 + 600,- 300 + 550,- 300 + 550,- 300
|
||||
+ 600,- 300 + 550,-1150 + 550,- 350 + 550,-1150
|
||||
+ 550
|
||||
Sum: 54250
|
||||
|
||||
Send generic 72 bit PulseDistance 0x5A AFEDCBA9 87654321 LSB first
|
||||
Protocol=PulseDistance Raw-Data=0x5A 72 bits LSB first
|
||||
Send with:
|
||||
uint64_t tRawData[]={0xAFEDCBA987654321, 0x5A};
|
||||
IrSender.sendPulseDistanceWidthFromArray(38, 9000, 4350, 650, 1600, 650, 500, &tRawData[0], 72, PROTOCOL_IS_LSB_FIRST, <RepeatPeriodMillis>, <numberOfRepeats>);
|
||||
rawData[148]:
|
||||
-1082050
|
||||
+9000,-4350
|
||||
+ 700,-1600 + 650,- 500 + 700,- 500 + 650,- 500
|
||||
+ 650,- 550 + 650,-1600 + 650,- 550 + 650,- 500
|
||||
+ 700,-1600 + 650,-1650 + 650,- 500 + 650,- 500
|
||||
+ 700,- 500 + 650,- 500 + 650,-1650 + 650,- 500
|
||||
+ 650,-1650 + 650,- 500 + 650,-1650 + 650,- 500
|
||||
+ 650,- 550 + 650,-1600 + 650,-1650 + 650,- 500
|
||||
+ 650,-1650 + 650,-1600 + 700,-1600 + 650,- 500
|
||||
+ 700,- 500 + 650,- 500 + 700,- 500 + 650,-1600
|
||||
+ 700,-1600 + 650,- 500 + 700,- 500 + 650,-1600
|
||||
+ 700,- 500 + 650,-1650 + 600,- 550 + 700,-1600
|
||||
+ 650,-1650 + 650,-1600 + 650,- 550 + 650,-1600
|
||||
+ 700,- 500 + 650,- 500 + 650,-1650 + 650,-1600
|
||||
+ 650,-1650 + 650,- 500 + 700,-1600 + 650,-1650
|
||||
+ 650,- 500 + 650,-1650 + 650,-1600 + 700,-1600
|
||||
+ 650,-1650 + 650,-1600 + 700,-1600 + 650,-1650
|
||||
+ 650,- 500 + 650,-1650 + 650,- 500 + 700,-1600
|
||||
+ 650,- 500 + 700,-1600 + 650,- 550 + 650,-1600
|
||||
+ 650,-1650 + 650,- 500 + 650,-1650 + 650,- 500
|
||||
+ 650
|
||||
Sum: 140550
|
||||
|
||||
Send generic 52 bit PulseDistanceWidth 0xDCBA9 87654321 LSB first
|
||||
Protocol=PulseWidth Raw-Data=0xDCBA987654321 52 bits LSB first
|
||||
Send with: IrSender.sendPulseDistanceWidth(38, 400, 550, 750, 150, 400, 500, 0xDCBA987654321, 52, PROTOCOL_IS_LSB_FIRST, <RepeatPeriodMillis>, <numberOfRepeats>);
|
||||
rawData[106]:
|
||||
-1120100
|
||||
+ 400,- 550
|
||||
+ 700,- 150 + 450,- 500 + 400,- 550 + 400,- 500
|
||||
+ 400,- 500 + 700,- 150 + 450,- 550 + 400,- 500
|
||||
+ 700,- 150 + 800,- 150 + 450,- 500 + 400,- 500
|
||||
+ 400,- 550 + 350,- 550 + 700,- 200 + 400,- 550
|
||||
+ 700,- 200 + 400,- 500 + 750,- 200 + 400,- 500
|
||||
+ 400,- 550 + 700,- 150 + 750,- 200 + 450,- 500
|
||||
+ 700,- 150 + 750,- 200 + 750,- 150 + 450,- 500
|
||||
+ 400,- 550 + 400,- 500 + 400,- 500 + 700,- 150
|
||||
+ 800,- 150 + 450,- 500 + 400,- 500 + 750,- 150
|
||||
+ 450,- 500 + 700,- 200 + 450,- 500 + 700,- 250
|
||||
+ 700,- 150 + 800,- 150 + 450,- 500 + 700,- 200
|
||||
+ 450,- 500 + 400,- 500 + 700,- 200 + 750,- 150
|
||||
+ 750,- 150 + 450,- 550 + 700,- 200 + 700
|
||||
Sum: 48450
|
||||
|
||||
Send generic 32 bit PulseWidth 0x87654321 LSB first
|
||||
Protocol=PulseWidth Raw-Data=0x87654321 32 bits LSB first
|
||||
Send with: IrSender.sendPulseDistanceWidth(38, 1100, 400, 750, 200, 450, 200, 0x87654321, 32, PROTOCOL_IS_LSB_FIRST, <RepeatPeriodMillis>, <numberOfRepeats>);
|
||||
rawData[66]:
|
||||
-1090450
|
||||
+1100,- 400
|
||||
+ 700,- 150 + 450,- 200 + 450,- 150 + 450,- 200
|
||||
+ 400,- 200 + 750,- 150 + 450,- 150 + 450,- 200
|
||||
+ 700,- 200 + 750,- 200 + 400,- 200 + 400,- 200
|
||||
+ 450,- 150 + 450,- 150 + 750,- 150 + 450,- 200
|
||||
+ 750,- 200 + 400,- 200 + 750,- 150 + 450,- 150
|
||||
+ 450,- 200 + 700,- 200 + 750,- 200 + 400,- 200
|
||||
+ 750,- 150 + 750,- 200 + 700,- 200 + 450,- 150
|
||||
+ 450,- 200 + 400,- 200 + 450,- 150 + 750
|
||||
Sum: 24900
|
||||
|
||||
Send MagiQuest 0x6BCDFF00, 0x176 as generic 55 bit PulseDistanceWidth MSB first
|
||||
Protocol=MagiQuest Address=0xFF00 Command=0x176 Raw-Data=0x6BCDFF00 56 bits MSB first
|
||||
Send with: IrSender.sendMagiQuest(0x6BCDFF00, 0x176, <numberOfRepeats>);
|
||||
rawData[112]:
|
||||
-1070250
|
||||
+ 400,- 800 + 400,- 750 + 450,- 800 + 400,- 750
|
||||
+ 400,- 800 + 400,- 750 + 400,- 800 + 400,- 750
|
||||
+ 700,- 500 + 650,- 500 + 400,- 800 + 650,- 500
|
||||
+ 400,- 800 + 650,- 500 + 700,- 500 + 650,- 500
|
||||
+ 700,- 450 + 450,- 750 + 400,- 750 + 700,- 500
|
||||
+ 700,- 450 + 400,- 800 + 700,- 450 + 700,- 500
|
||||
+ 700,- 500 + 650,- 500 + 700,- 450 + 700,- 500
|
||||
+ 700,- 450 + 700,- 500 + 700,- 450 + 400,- 800
|
||||
+ 350,- 800 + 400,- 800 + 400,- 750 + 400,- 800
|
||||
+ 400,- 750 + 400,- 800 + 400,- 750 + 700,- 450
|
||||
+ 450,- 750 + 700,- 450 + 700,- 500 + 700,- 450
|
||||
+ 400,- 800 + 650,- 500 + 700,- 500 + 400,- 750
|
||||
+ 400,- 800 + 400,- 750 + 450,- 750 + 700,- 450
|
||||
+ 700,- 500 + 400,- 750 + 400,- 800 + 700
|
||||
Sum: 65350
|
||||
|
||||
Send Onkyo (NEC with 16 bit command)
|
||||
Protocol=Onkyo Address=0xFFF1 Command=0x7776 Raw-Data=0x7776FFF1 32 bits LSB first
|
||||
Send with: IrSender.sendOnkyo(0xFFF1, 0x7776, <numberOfRepeats>);
|
||||
rawData[68]:
|
||||
-1086400
|
||||
+9050,-4400
|
||||
+ 700,-1600 + 650,- 450 + 700,- 450 + 650,- 500
|
||||
+ 650,-1600 + 650,-1600 + 650,-1600 + 700,-1600
|
||||
+ 650,-1600 + 650,-1600 + 650,-1600 + 700,-1600
|
||||
+ 650,-1600 + 650,-1600 + 650,-1600 + 700,-1600
|
||||
+ 650,- 450 + 700,-1600 + 650,-1600 + 650,- 500
|
||||
+ 650,-1600 + 650,-1600 + 650,-1600 + 700,- 450
|
||||
+ 650,-1600 + 650,-1600 + 700,-1600 + 650,- 450
|
||||
+ 700,-1600 + 650,-1600 + 650,-1600 + 650,- 500
|
||||
+ 650
|
||||
Sum: 77500
|
||||
|
||||
Send Apple
|
||||
Protocol=Apple Address=0xF1 Command=0x76 Raw-Data=0xF17687EE 32 bits LSB first
|
||||
Send with: IrSender.sendApple(0xF1, 0x76, <numberOfRepeats>);
|
||||
rawData[68]:
|
||||
-1059500
|
||||
+9050,-4400
|
||||
+ 700,- 500 + 650,-1600 + 700,-1600 + 650,-1600
|
||||
+ 650,- 500 + 650,-1600 + 650,-1600 + 650,-1600
|
||||
+ 700,-1600 + 650,-1600 + 650,-1600 + 650,- 500
|
||||
+ 650,- 450 + 700,- 450 + 700,- 450 + 650,-1600
|
||||
+ 650,- 500 + 650,-1600 + 650,-1600 + 700,- 450
|
||||
+ 650,-1600 + 650,-1600 + 700,-1600 + 650,- 450
|
||||
+ 700,-1600 + 650,- 450 + 650,- 500 + 650,- 500
|
||||
+ 650,-1600 + 650,-1600 + 650,-1600 + 700,-1600
|
||||
+ 600
|
||||
Sum: 73000
|
||||
|
||||
Send Panasonic
|
||||
Protocol=Panasonic Address=0xFF1 Command=0x76 Raw-Data=0x9976FF102002 48 bits LSB first
|
||||
Send with: IrSender.sendPanasonic(0xFF1, 0x76, <numberOfRepeats>);
|
||||
rawData[100]:
|
||||
-1059200
|
||||
+3500,-1700
|
||||
+ 500,- 350 + 500,-1250 + 500,- 400 + 500,- 350
|
||||
+ 500,- 400 + 500,- 350 + 500,- 400 + 500,- 350
|
||||
+ 500,- 400 + 500,- 350 + 500,- 400 + 500,- 350
|
||||
+ 500,- 400 + 500,-1250 + 500,- 350 + 500,- 400
|
||||
+ 500,- 350 + 500,- 400 + 450,- 400 + 500,- 400
|
||||
+ 500,-1250 + 500,- 350 + 500,- 400 + 450,- 400
|
||||
+ 500,-1250 + 500,-1250 + 500,-1250 + 500,-1250
|
||||
+ 500,-1250 + 500,-1250 + 500,-1250 + 500,-1250
|
||||
+ 500,- 400 + 500,-1250 + 500,-1250 + 500,- 350
|
||||
+ 500,-1250 + 500,-1250 + 500,-1250 + 500,- 400
|
||||
+ 500,-1250 + 500,- 350 + 500,- 400 + 500,-1250
|
||||
+ 500,-1250 + 500,- 400 + 500,- 350 + 500,-1250
|
||||
+ 500
|
||||
Sum: 65200
|
||||
|
||||
Send Kaseikyo with 0x4711 as Vendor ID
|
||||
Protocol=Kaseikyo Address=0xFF1 Command=0x76 Extra=0x4711 Raw-Data=0x9A76FF134711 48 bits LSB first
|
||||
Send with: IrSender.sendKaseikyo(0xFF1, 0x76, <numberOfRepeats>, 0x4711);
|
||||
rawData[100]:
|
||||
-1079950
|
||||
+3550,-1650
|
||||
+ 500,-1250 + 500,- 400 + 500,- 350 + 500,- 400
|
||||
+ 500,-1250 + 500,- 350 + 550,- 350 + 500,- 400
|
||||
+ 500,-1250 + 500,-1250 + 500,-1250 + 500,- 350
|
||||
+ 500,- 400 + 500,- 350 + 500,-1250 + 500,- 400
|
||||
+ 500,-1250 + 500,-1250 + 500,- 350 + 500,- 400
|
||||
+ 500,-1250 + 500,- 350 + 500,- 400 + 500,- 350
|
||||
+ 500,-1250 + 500,-1250 + 500,-1250 + 500,-1250
|
||||
+ 500,-1250 + 500,-1250 + 500,-1250 + 550,-1200
|
||||
+ 550,- 350 + 500,-1250 + 500,-1250 + 500,- 350
|
||||
+ 500,-1250 + 500,-1250 + 500,-1250 + 550,- 350
|
||||
+ 500,- 350 + 500,-1250 + 550,- 350 + 500,-1250
|
||||
+ 500,-1250 + 500,- 350 + 500,- 400 + 500,-1250
|
||||
+ 500
|
||||
Sum: 70500
|
||||
|
||||
Send Kaseikyo_Denon variant
|
||||
Protocol=Kaseikyo_Denon Address=0xFF1 Command=0x76 Raw-Data=0x9976FF103254 48 bits LSB first
|
||||
Send with: IrSender.sendKaseikyo_Denon(0xFF1, 0x76, <numberOfRepeats>);
|
||||
rawData[100]:
|
||||
-1080650
|
||||
+3550,-1650
|
||||
+ 550,- 350 + 500,- 350 + 550,-1200 + 550,- 350
|
||||
+ 500,-1250 + 500,- 350 + 550,-1200 + 500,- 400
|
||||
+ 500,- 350 + 500,-1250 + 550,- 350 + 500,- 350
|
||||
+ 550,-1200 + 550,-1200 + 550,- 350 + 500,- 350
|
||||
+ 550,- 350 + 500,- 350 + 550,- 350 + 500,- 350
|
||||
+ 550,-1200 + 550,- 350 + 500,- 350 + 550,- 350
|
||||
+ 500,-1250 + 500,-1250 + 500,-1250 + 500,-1250
|
||||
+ 500,-1250 + 500,-1250 + 500,-1250 + 500,-1250
|
||||
+ 500,- 350 + 500,-1250 + 500,-1250 + 500,- 400
|
||||
+ 500,-1250 + 500,-1250 + 500,-1250 + 500,- 350
|
||||
+ 500,-1250 + 550,- 350 + 500,- 350 + 550,-1250
|
||||
+ 450,-1300 + 500,- 350 + 500,- 400 + 500,-1250
|
||||
+ 500
|
||||
Sum: 68750
|
||||
|
||||
Send Denon
|
||||
Protocol=Denon Address=0x11 Command=0x76 Raw-Data=0xED1 15 bits LSB first
|
||||
Send with: IrSender.sendDenon(0x11, 0x76, <numberOfRepeats>);
|
||||
rawData[32]:
|
||||
-1078400
|
||||
+ 350,-1750 + 350,- 700 + 350,- 700 + 350,- 700
|
||||
+ 350,-1750 + 350,- 700 + 300,-1800 + 350,-1750
|
||||
+ 350,- 700 + 350,-1750 + 350,-1750 + 350,-1750
|
||||
+ 350,- 700 + 350,- 700 + 350,- 700 + 350
|
||||
Sum: 23450
|
||||
|
||||
Send Denon/Sharp variant
|
||||
Protocol=Sharp Address=0x11 Command=0x76 Raw-Data=0x4ED1 15 bits LSB first
|
||||
Send with: IrSender.sendSharp(0x11, 0x76, <numberOfRepeats>);
|
||||
rawData[32]:
|
||||
-1023500
|
||||
+ 350,-1750 + 350,- 700 + 350,- 700 + 350,- 700
|
||||
+ 350,-1750 + 350,- 700 + 350,-1750 + 350,-1750
|
||||
+ 350,- 700 + 350,-1750 + 350,-1750 + 350,-1750
|
||||
+ 350,- 700 + 300,- 750 + 350,-1750 + 350
|
||||
Sum: 24500
|
||||
|
||||
Send Sony/SIRCS with 7 command and 5 address bits
|
||||
Protocol=Sony Address=0x11 Command=0x76 Raw-Data=0x8F6 12 bits LSB first
|
||||
Send with: IrSender.sendSony(0x11, 0x76, 2, 12);
|
||||
rawData[26]:
|
||||
-1025750
|
||||
+2500,- 500
|
||||
+ 700,- 500 +1300,- 650 +1250,- 550 + 700,- 500
|
||||
+1300,- 500 +1300,- 500 +1300,- 550 +1300,- 500
|
||||
+ 700,- 500 + 700,- 500 + 700,- 550 +1250
|
||||
Sum: 21300
|
||||
|
||||
Send Sony/SIRCS with 7 command and 8 address bits
|
||||
Protocol=Sony Address=0xF1 Command=0x76 Raw-Data=0x78F6 15 bits LSB first
|
||||
Send with: IrSender.sendSony(0xF1, 0x76, 2, 15);
|
||||
rawData[32]:
|
||||
-1037600
|
||||
+2500,- 550
|
||||
+ 650,- 550 +1300,- 500 +1300,- 500 + 700,- 500
|
||||
+1300,- 550 +1250,- 550 +1300,- 500 +1300,- 500
|
||||
+ 700,- 500 + 700,- 550 + 650,- 550 +1300,- 500
|
||||
+1300,- 550 +1300,- 500 +1300
|
||||
Sum: 26700
|
||||
|
||||
Send Sony/SIRCS with 7 command and 13 address bits
|
||||
Protocol=Sony Address=0x1FF1 Command=0x76 Raw-Data=0xFF8F6 20 bits LSB first
|
||||
Send with: IrSender.sendSony(0x1FF1, 0x76, 2, 20);
|
||||
rawData[42]:
|
||||
-1041100
|
||||
+2500,- 500
|
||||
+ 700,- 550 +1300,- 500 +1300,- 500 + 700,- 550
|
||||
+1250,- 550 +1300,- 500 +1300,- 550 +1300,- 500
|
||||
+ 700,- 500 + 700,- 500 + 700,- 500 +1300,- 550
|
||||
+1300,- 500 +1300,- 500 +1300,- 500 +1300,- 550
|
||||
+1300,- 500 +1300,- 500 +1300,- 550 +1250
|
||||
Sum: 35750
|
||||
|
||||
Send Samsung 8 bit command
|
||||
Protocol=Samsung Address=0xFFF1 Command=0x76 Raw-Data=0x8976FFF1 32 bits LSB first
|
||||
Send with: IrSender.sendSamsung(0xFFF1, 0x76, <numberOfRepeats>);
|
||||
rawData[68]:
|
||||
-1044850
|
||||
+4550,-4400
|
||||
+ 700,-1600 + 650,- 450 + 700,- 450 + 650,- 500
|
||||
+ 650,-1600 + 650,-1600 + 650,-1600 + 700,-1600
|
||||
+ 650,-1600 + 650,-1600 + 650,-1600 + 700,-1600
|
||||
+ 650,-1600 + 650,-1600 + 650,-1600 + 700,-1600
|
||||
+ 650,- 450 + 700,-1600 + 650,-1600 + 650,- 500
|
||||
+ 650,-1600 + 650,-1600 + 700,-1600 + 650,- 450
|
||||
+ 700,-1600 + 650,- 450 + 650,- 500 + 650,-1600
|
||||
+ 650,- 500 + 650,- 450 + 700,- 450 + 650,-1600
|
||||
+ 650
|
||||
Sum: 69600
|
||||
|
||||
Send Samsung 16 bit command
|
||||
Protocol=Samsung Address=0xFFF1 Command=0x9876 Raw-Data=0x9876FFF1 32 bits LSB first
|
||||
Send with: IrSender.sendSamsung(0xFFF1, 0x9876, <numberOfRepeats>);
|
||||
rawData[68]:
|
||||
-1061000
|
||||
+4600,-4400
|
||||
+ 650,-1600 + 700,- 450 + 650,- 500 + 650,- 450
|
||||
+ 700,-1550 + 700,-1600 + 650,-1600 + 650,-1600
|
||||
+ 650,-1600 + 700,-1600 + 650,-1600 + 650,-1600
|
||||
+ 650,-1600 + 700,-1600 + 650,-1600 + 650,-1600
|
||||
+ 650,- 500 + 650,-1600 + 700,-1600 + 650,- 450
|
||||
+ 700,-1600 + 650,-1600 + 650,-1600 + 650,- 500
|
||||
+ 650,- 450 + 700,- 450 + 650,- 500 + 650,-1600
|
||||
+ 650,-1600 + 650,- 500 + 650,- 450 + 700,-1600
|
||||
+ 650
|
||||
Sum: 69650
|
||||
|
||||
Send Samsung48 16 bit command
|
||||
Protocol=Samsung48 Address=0xFFF1 Command=0x9876 Raw-Data=0xFFFFFFFF8976FFF1 48 bits LSB first
|
||||
Send with: IrSender.sendSamsung48(0xFFF1, 0x9876, <numberOfRepeats>);
|
||||
rawData[100]:
|
||||
-1066350
|
||||
+4550,-4400
|
||||
+ 650,-1650 + 600,- 500 + 700,- 450 + 650,- 500
|
||||
+ 650,-1600 + 650,-1600 + 650,-1600 + 700,-1600
|
||||
+ 600,-1650 + 650,-1600 + 650,-1600 + 700,-1600
|
||||
+ 600,-1650 + 650,-1600 + 650,-1600 + 700,-1550
|
||||
+ 700,- 450 + 650,-1600 + 700,-1600 + 600,- 500
|
||||
+ 650,-1600 + 700,-1600 + 650,-1600 + 650,- 500
|
||||
+ 650,-1600 + 650,- 500 + 650,- 500 + 650,-1600
|
||||
+ 650,- 450 + 700,- 450 + 650,- 500 + 650,-1600
|
||||
+ 650,- 500 + 650,- 450 + 650,- 500 + 650,-1600
|
||||
+ 650,-1600 + 700,- 450 + 650,- 500 + 650,-1600
|
||||
+ 650,-1600 + 650,-1600 + 650,-1650 + 650,- 450
|
||||
+ 650,- 500 + 650,-1600 + 650,-1600 + 650,- 500
|
||||
+ 650
|
||||
Sum: 96750
|
||||
|
||||
Send RC5
|
||||
Protocol=RC5 Address=0x11 Command=0x36 Raw-Data=0x1476 13 bits MSB first
|
||||
Send with: IrSender.sendRC5(0x11, 0x36, <numberOfRepeats>);
|
||||
rawData[20]:
|
||||
-1079150
|
||||
+1000,- 800
|
||||
+1900,-1650 +1900,- 800 +1000,- 800 +1000,-1700
|
||||
+1000,- 800 +1000,- 750 +1900,-1700 +1000,- 800
|
||||
+1900
|
||||
Sum: 23400
|
||||
|
||||
Send RC5X with 7.th MSB of command set
|
||||
Protocol=RC5 Address=0x11 Command=0x76 Toggle=1 Raw-Data=0xC76 13 bits MSB first
|
||||
Send with: IrSender.sendRC5(0x11, 0x76, <numberOfRepeats>);
|
||||
rawData[20]:
|
||||
-1035450
|
||||
+1900,-1700
|
||||
+1000,- 800 +1900,- 750 +1000,- 800 +1000,-1700
|
||||
+1000,- 800 +1000,- 800 +1900,-1650 +1000,- 800
|
||||
+1900
|
||||
Sum: 23400
|
||||
|
||||
Send RC6
|
||||
Protocol=RC6 Address=0xF1 Command=0x76 Raw-Data=0xF176 20 bits MSB first
|
||||
Send with: IrSender.sendRC6(0xF1, 0x76, <numberOfRepeats>);
|
||||
rawData[36]:
|
||||
-1032650
|
||||
+2750,- 800
|
||||
+ 550,- 800 + 550,- 350 + 550,- 350 + 550,- 800
|
||||
+1450,- 350 + 550,- 350 + 550,- 350 + 550,- 800
|
||||
+ 550,- 350 + 550,- 350 +1000,- 800 +1000,- 350
|
||||
+ 550,- 350 + 550,- 800 +1000,- 350 + 550,- 800
|
||||
+ 550
|
||||
Sum: 23450
|
||||
|
||||
Send RC6A with 14 bit 0x2711 as extra
|
||||
Protocol=RC6A Address=0xF1 Command=0x76 Extra=0x2711 Toggle=1 Raw-Data=0xA711F176 35 bits MSB first
|
||||
Send with: IrSender.sendRC6A(0xF1, 0x76, <numberOfRepeats>, 0x2711);
|
||||
rawData[58]:
|
||||
-1032900
|
||||
+2650,- 900
|
||||
+ 450,- 450 + 450,- 450 + 450,- 850 +1400,-1300
|
||||
+ 950,- 850 + 500,- 400 + 950,- 400 + 500,- 450
|
||||
+ 450,- 850 + 500,- 400 + 500,- 400 + 950,- 850
|
||||
+ 500,- 400 + 500,- 400 + 950,- 450 + 450,- 450
|
||||
+ 450,- 450 + 450,- 400 + 500,- 850 + 500,- 400
|
||||
+ 500,- 400 + 950,- 850 + 950,- 400 + 500,- 400
|
||||
+ 500,- 850 + 950,- 450 + 450,- 850 + 500
|
||||
Sum: 36850
|
||||
|
||||
Send Bang&Olufsen
|
||||
- ENABLE_BEO_WITHOUT_FRAME_GAP is enabled
|
||||
- Now print raw data and try to decode the first 6 entries, which results in rawData 0x0!
|
||||
rawData[36]:
|
||||
-1032400
|
||||
+ 300,-2850
|
||||
+ 250,-2850 + 250,-15200 + 300,-2850 + 250,-9000
|
||||
+ 300,-5950 + 250,-5950 + 250,-5900 + 300,-2850
|
||||
+ 250,-5950 + 250,-9050 + 250,-2850 + 250,-9000
|
||||
+ 300,-2850 + 250,-5950 + 250,-5950 + 250,-5950
|
||||
+ 250
|
||||
Sum: 105700
|
||||
Protocol=Bang&Olufsen Address=0x0 Command=0x0 Raw-Data=0x0 0 bits MSB first
|
||||
|
||||
- Remove trailing 6 entries, which is equivalent to define RECORD_GAP_MICROS < 15000, to enable successful B&O decode
|
||||
Protocol=Bang&Olufsen Address=0xF2 Command=0x87 Raw-Data=0xF287 16 bits MSB first
|
||||
Send with: IrSender.sendBang&Olufsen(0xF2, 0x87, <numberOfRepeats>);
|
||||
rawData[38]:
|
||||
-15200
|
||||
+ 300,-2850
|
||||
+ 250,-9000 + 300,-5950 + 250,-5950 + 250,-5900
|
||||
+ 300,-2850 + 250,-5950 + 250,-9050 + 250,-2850
|
||||
+ 250,-9000 + 300,-2850 + 250,-5950 + 250,-5950
|
||||
+ 250,-5950 + 250,-9050 + 250,-5900 + 300,-5950
|
||||
+ 250,-12100 + 300
|
||||
Sum: 118100
|
||||
|
||||
Send MagiQuest
|
||||
Protocol=MagiQuest Address=0xF2 Command=0x187 Raw-Data=0x6BCD00F2 56 bits MSB first
|
||||
Send with: IrSender.sendMagiQuest(0x6BCD00F2, 0x187, <numberOfRepeats>);
|
||||
rawData[112]:
|
||||
-1088750
|
||||
+ 350,- 800 + 350,- 800 + 350,- 800 + 350,- 800
|
||||
+ 350,- 800 + 350,- 800 + 350,- 800 + 350,- 850
|
||||
+ 600,- 550 + 600,- 550 + 350,- 750 + 650,- 550
|
||||
+ 300,- 850 + 600,- 550 + 600,- 550 + 600,- 550
|
||||
+ 600,- 550 + 350,- 800 + 350,- 750 + 650,- 500
|
||||
+ 650,- 500 + 350,- 800 + 650,- 500 + 350,- 800
|
||||
+ 350,- 800 + 350,- 800 + 350,- 800 + 350,- 800
|
||||
+ 350,- 800 + 350,- 800 + 350,- 800 + 650,- 500
|
||||
+ 650,- 500 + 650,- 500 + 650,- 500 + 350,- 800
|
||||
+ 350,- 800 + 650,- 500 + 350,- 850 + 600,- 550
|
||||
+ 600,- 550 + 350,- 800 + 300,- 800 + 350,- 800
|
||||
+ 350,- 800 + 650,- 500 + 650,- 500 + 650,- 550
|
||||
+ 350,- 800 + 300,- 800 + 650,- 500 + 350,- 800
|
||||
+ 350,- 800 + 350,- 800 + 650,- 500 + 350
|
||||
Sum: 63600
|
||||
|
||||
Send next protocols with IrSender.write
|
||||
|
||||
Send JVC
|
||||
Protocol=JVC Address=0xF1 Command=0x76 Raw-Data=0x76F1 16 bits LSB first
|
||||
Send with: IrSender.sendJVC(0xF1, 0x76, <numberOfRepeats>);
|
||||
rawData[36]:
|
||||
-1040750
|
||||
+8500,-4150
|
||||
+ 650,-1500 + 650,- 400 + 650,- 450 + 600,- 450
|
||||
+ 650,-1500 + 600,-1500 + 650,-1500 + 600,-1550
|
||||
+ 600,- 450 + 650,-1500 + 650,-1450 + 650,- 450
|
||||
+ 650,-1450 + 650,-1500 + 650,-1500 + 600,- 450
|
||||
+ 650
|
||||
Sum: 41050
|
||||
|
||||
Send LG
|
||||
Protocol=LG Address=0xF1 Command=0x9876 Raw-Data=0xF19876E 28 bits MSB first
|
||||
Send with: IrSender.sendLG(0xF1, 0x9876, <numberOfRepeats>);
|
||||
rawData[60]:
|
||||
-1059650
|
||||
+9100,-4100
|
||||
+ 650,-1500 + 600,-1500 + 600,-1500 + 600,-1500
|
||||
+ 600,- 500 + 600,- 450 + 600,- 450 + 650,-1500
|
||||
+ 600,-1500 + 600,- 450 + 600,- 500 + 600,-1500
|
||||
+ 600,-1500 + 600,- 500 + 600,- 450 + 600,- 450
|
||||
+ 650,- 450 + 600,-1500 + 600,-1500 + 600,-1500
|
||||
+ 650,- 450 + 600,-1500 + 600,-1500 + 600,- 500
|
||||
+ 600,-1500 + 600,-1500 + 600,-1500 + 600,- 500
|
||||
+ 600
|
||||
Sum: 60450
|
||||
|
||||
Send Bosewave with no address and 8 command bits
|
||||
Protocol=BoseWave Address=0x0 Command=0x76 Raw-Data=0x8976 16 bits LSB first
|
||||
Send with: IrSender.sendBoseWave(0x0, 0x76, <numberOfRepeats>);
|
||||
rawData[36]:
|
||||
-1050250
|
||||
+1100,-1400
|
||||
+ 600,- 400 + 600,-1400 + 600,-1400 + 600,- 400
|
||||
+ 600,-1400 + 600,-1400 + 650,-1400 + 600,- 400
|
||||
+ 600,-1400 + 600,- 400 + 600,- 400 + 600,-1400
|
||||
+ 600,- 400 + 600,- 400 + 600,- 400 + 600,-1400
|
||||
+ 600
|
||||
Sum: 27150
|
||||
|
||||
Send FAST
|
||||
Protocol=FAST Address=0x0 Command=0x76 Raw-Data=0x8976 16 bits LSB first
|
||||
Send with: IrSender.sendFAST(0x0, 0x76, <numberOfRepeats>);
|
||||
rawData[36]:
|
||||
-1041350
|
||||
+2200,-1000
|
||||
+ 650,- 400 + 650,-1500 + 650,-1500 + 600,- 450
|
||||
+ 650,-1500 + 650,-1500 + 600,-1500 + 650,- 450
|
||||
+ 600,-1500 + 650,- 450 + 600,- 450 + 650,-1500
|
||||
+ 600,- 450 + 650,- 450 + 600,- 450 + 650,-1500
|
||||
+ 600
|
||||
Sum: 29450
|
||||
|
||||
Force buffer overflow by sending 280 marks and spaces
|
||||
Overflow
|
||||
Try to increase the "RAW_BUFFER_LENGTH" value of 200 in UnitTest.cpp
|
||||
rawData[200]:
|
||||
-1039850
|
||||
+ 300,- 450
|
||||
+ 300,- 450 + 350,- 450 + 300,- 450 + 350,- 450
|
||||
+ 300,- 450 + 350,- 450 + 300,- 450 + 300,- 500
|
||||
+ 300,- 450 + 350,- 450 + 300,- 450 + 350,- 450
|
||||
+ 300,- 450 + 350,- 450 + 300,- 450 + 350,- 450
|
||||
+ 300,- 450 + 350,- 450 + 300,- 450 + 350,- 450
|
||||
+ 300,- 500 + 300,- 450 + 350,- 450 + 300,- 500
|
||||
+ 350,- 450 + 300,- 450 + 350,- 450 + 300,- 450
|
||||
+ 350,- 400 + 350,- 450 + 300,- 450 + 350,- 450
|
||||
+ 300,- 450 + 350,- 450 + 300,- 450 + 350,- 450
|
||||
+ 300,- 450 + 300,- 500 + 300,- 450 + 300,- 500
|
||||
+ 300,- 450 + 350,- 450 + 300,- 450 + 350,- 450
|
||||
+ 300,- 450 + 350,- 450 + 300,- 450 + 350,- 450
|
||||
+ 300,- 450 + 350,- 450 + 300,- 450 + 350,- 450
|
||||
+ 300,- 450 + 350,- 450 + 300,- 450 + 350,- 450
|
||||
+ 350,- 450 + 300,- 450 + 300,- 450 + 350,- 450
|
||||
+ 300,- 450 + 350,- 450 + 300,- 450 + 350,- 450
|
||||
+ 300,- 450 + 350,- 400 + 350,- 450 + 300,- 450
|
||||
+ 350,- 450 + 300,- 450 + 350,- 450 + 300,- 450
|
||||
+ 350,- 450 + 300,- 450 + 350,- 450 + 300,- 450
|
||||
+ 350,- 450 + 300,- 450 + 350,- 450 + 300,- 450
|
||||
+ 350,- 450 + 300,- 450 + 300,- 500 + 300,- 450
|
||||
+ 350,- 450 + 300,- 450 + 300,- 500 + 300,- 450
|
||||
+ 350,- 450 + 350,- 450 + 300,- 450 + 300,- 450
|
||||
+ 350,- 450 + 300,- 450 + 350,- 450 + 300,- 450
|
||||
+ 350,- 450 + 300,- 450 + 350
|
||||
Sum: 77050
|
||||
ERROR: Unknown protocol
|
||||
|
||||
|
||||
address=0xF2 command=0x87
|
||||
|
||||
Send NEC with 8 bit address and complete NEC frames as repeats to force decoding as NEC2
|
||||
Protocol=NEC Address=0xF2 Command=0x87 Raw-Data=0x78870DF2 32 bits LSB first
|
||||
Send with: IrSender.sendNEC(0xF2, 0x87, <numberOfRepeats>);
|
||||
rawData[68]:
|
||||
-3276750
|
||||
+8900,-4450
|
||||
+ 600,- 500 + 650,-1600 + 600,- 550 + 600,- 500
|
||||
+ 650,-1600 + 600,-1650 + 600,-1650 + 600,-1650
|
||||
+ 600,-1600 + 600,- 550 + 600,-1600 + 650,-1600
|
||||
+ 600,- 550 + 600,- 500 + 600,- 550 + 600,- 500
|
||||
+ 600,-1650 + 600,-1650 + 600,-1650 + 600,- 550
|
||||
+ 600,- 500 + 600,- 550 + 600,- 550 + 600,-1600
|
||||
+ 600,- 550 + 600,- 500 + 650,- 500 + 600,-1650
|
||||
+ 600,-1650 + 600,-1600 + 600,-1650 + 600,- 550
|
||||
+ 600
|
||||
Sum: 67850
|
||||
|
||||
Protocol=NEC2 Address=0xF2 Command=0x87 Repeat gap=65900us Raw-Data=0x78870DF2 32 bits LSB first
|
||||
Send with: IrSender.sendNEC2(0xF2, 0x87, <numberOfRepeats>);
|
||||
rawData[68]:
|
||||
-65900
|
||||
+8900,-4450
|
||||
+ 600,- 500 + 600,-1650 + 600,- 500 + 600,- 550
|
||||
+ 600,-1650 + 600,-1600 + 600,-1650 + 600,-1650
|
||||
+ 600,-1650 + 600,- 500 + 600,-1650 + 600,-1650
|
||||
+ 600,- 500 + 600,- 550 + 600,- 550 + 600,- 500
|
||||
+ 600,-1650 + 600,-1650 + 600,-1600 + 600,- 550
|
||||
+ 600,- 550 + 600,- 500 + 600,- 550 + 600,-1650
|
||||
+ 600,- 500 + 600,- 550 + 600,- 500 + 650,-1600
|
||||
+ 600,-1650 + 600,-1600 + 650,-1600 + 600,- 550
|
||||
+ 600
|
||||
Sum: 67800
|
||||
|
||||
Send NEC with 16 bit address
|
||||
Protocol=NEC Address=0xF2 Command=0x87 Raw-Data=0x78870DF2 32 bits LSB first
|
||||
Send with: IrSender.sendNEC(0xF2, 0x87, <numberOfRepeats>);
|
||||
rawData[68]:
|
||||
-1060000
|
||||
+9100,-4400
|
||||
+ 650,- 450 + 700,-1600 + 650,- 450 + 700,- 450
|
||||
+ 650,-1600 + 650,-1600 + 700,-1600 + 650,-1600
|
||||
+ 650,-1600 + 650,- 500 + 650,-1600 + 650,-1600
|
||||
+ 650,- 500 + 650,- 500 + 600,- 500 + 650,- 500
|
||||
+ 650,-1600 + 650,-1600 + 650,-1600 + 700,- 450
|
||||
+ 650,- 500 + 600,- 500 + 650,- 500 + 650,-1600
|
||||
+ 650,- 500 + 650,- 450 + 700,- 450 + 650,-1600
|
||||
+ 700,-1550 + 700,-1600 + 650,-1600 + 650,- 500
|
||||
+ 650
|
||||
Sum: 68450
|
||||
|
||||
Send NEC2 with 16 bit address
|
||||
Protocol=NEC Address=0xF2 Command=0x87 Raw-Data=0x78870DF2 32 bits LSB first
|
||||
Send with: IrSender.sendNEC(0xF2, 0x87, <numberOfRepeats>);
|
||||
rawData[68]:
|
||||
-1060100
|
||||
+9050,-4400
|
||||
+ 700,- 450 + 650,-1600 + 650,- 500 + 650,- 450
|
||||
+ 700,-1600 + 650,-1600 + 650,-1600 + 650,-1600
|
||||
+ 700,-1600 + 650,- 450 + 700,-1600 + 650,-1600
|
||||
+ 650,- 500 + 600,- 500 + 650,- 500 + 650,- 450
|
||||
+ 700,-1600 + 650,-1600 + 650,-1600 + 650,- 500
|
||||
+ 650,- 450 + 700,- 450 + 650,- 500 + 650,-1600
|
||||
+ 650,- 500 + 650,- 500 + 650,- 450 + 650,-1600
|
||||
+ 700,-1600 + 600,-1650 + 650,-1600 + 650,- 500
|
||||
+ 650
|
||||
Sum: 68450
|
||||
|
||||
Send Onkyo (NEC with 16 bit command)
|
||||
Protocol=Onkyo Address=0xF2 Command=0x8887 Raw-Data=0x888700F2 32 bits LSB first
|
||||
Send with: IrSender.sendOnkyo(0xF2, 0x8887, <numberOfRepeats>);
|
||||
rawData[68]:
|
||||
-1060700
|
||||
+9100,-4400
|
||||
+ 650,- 450 + 700,-1600 + 650,- 450 + 700,- 450
|
||||
+ 650,-1600 + 650,-1600 + 700,-1600 + 650,-1600
|
||||
+ 650,- 450 + 700,- 450 + 650,- 500 + 650,- 450
|
||||
+ 700,- 450 + 650,- 500 + 650,- 450 + 650,- 500
|
||||
+ 650,-1600 + 650,-1600 + 700,-1550 + 700,- 450
|
||||
+ 650,- 500 + 650,- 500 + 650,- 450 + 650,-1600
|
||||
+ 700,- 450 + 650,- 500 + 650,- 450 + 650,-1650
|
||||
+ 650,- 500 + 650,- 450 + 700,- 450 + 650,-1600
|
||||
+ 650
|
||||
Sum: 62800
|
||||
|
||||
Send Apple
|
||||
Protocol=Apple Address=0xF2 Command=0x87 Raw-Data=0xF28787EE 32 bits LSB first
|
||||
Send with: IrSender.sendApple(0xF2, 0x87, <numberOfRepeats>);
|
||||
rawData[68]:
|
||||
-1059150
|
||||
+9050,-4400
|
||||
+ 650,- 500 + 650,-1600 + 650,-1600 + 700,-1600
|
||||
+ 650,- 450 + 650,-1600 + 700,-1600 + 650,-1600
|
||||
+ 650,-1600 + 650,-1600 + 700,-1600 + 650,- 450
|
||||
+ 700,- 450 + 650,- 500 + 650,- 450 + 650,-1600
|
||||
+ 700,-1600 + 650,-1600 + 650,-1600 + 650,- 500
|
||||
+ 650,- 450 + 700,- 450 + 650,- 500 + 650,-1600
|
||||
+ 650,- 500 + 600,-1650 + 650,- 500 + 650,- 450
|
||||
+ 650,-1600 + 650,-1650 + 650,-1600 + 650,-1600
|
||||
+ 650
|
||||
Sum: 71800
|
||||
|
||||
Send Panasonic
|
||||
Protocol=Panasonic Address=0xF2 Command=0x87 Raw-Data=0xA8870F202002 48 bits LSB first
|
||||
Send with: IrSender.sendPanasonic(0xF2, 0x87, <numberOfRepeats>);
|
||||
rawData[100]:
|
||||
-1069050
|
||||
+3550,-1650
|
||||
+ 500,- 400 + 500,-1250 + 500,- 350 + 500,- 400
|
||||
+ 500,- 350 + 500,- 400 + 500,- 350 + 500,- 400
|
||||
+ 500,- 350 + 500,- 400 + 500,- 350 + 500,- 400
|
||||
+ 500,- 350 + 500,-1250 + 500,- 400 + 500,- 350
|
||||
+ 500,- 400 + 500,- 350 + 500,- 400 + 500,- 350
|
||||
+ 500,- 400 + 450,-1300 + 500,- 350 + 550,- 350
|
||||
+ 500,-1250 + 500,-1250 + 500,-1250 + 500,-1250
|
||||
+ 500,- 350 + 500,- 400 + 500,- 350 + 500,- 400
|
||||
+ 500,-1250 + 500,-1250 + 450,-1300 + 500,- 350
|
||||
+ 500,- 400 + 450,- 400 + 500,- 400 + 450,-1300
|
||||
+ 500,- 350 + 550,- 350 + 500,- 350 + 500,-1250
|
||||
+ 550,- 350 + 500,-1250 + 450,- 400 + 550,-1200
|
||||
+ 550
|
||||
Sum: 60000
|
||||
|
||||
Send Kaseikyo with 0x4711 as Vendor ID
|
||||
Protocol=Kaseikyo Address=0xF2 Command=0x87 Extra=0x4711 Raw-Data=0xAB870F234711 48 bits LSB first
|
||||
Send with: IrSender.sendKaseikyo(0xF2, 0x87, <numberOfRepeats>, 0x4711);
|
||||
rawData[100]:
|
||||
-1079750
|
||||
+3550,-1650
|
||||
+ 550,-1200 + 550,- 350 + 500,- 350 + 550,- 350
|
||||
+ 500,-1250 + 500,- 350 + 550,- 350 + 500,- 350
|
||||
+ 550,-1200 + 550,-1200 + 550,-1200 + 550,- 350
|
||||
+ 500,- 350 + 550,- 350 + 500,-1250 + 500,- 350
|
||||
+ 550,-1200 + 550,-1200 + 550,- 350 + 500,- 350
|
||||
+ 550,- 350 + 500,-1250 + 500,- 350 + 550,- 350
|
||||
+ 500,-1250 + 500,-1250 + 500,-1250 + 500,-1250
|
||||
+ 500,- 300 + 550,- 400 + 500,- 350 + 550,- 350
|
||||
+ 500,-1250 + 500,-1250 + 500,-1250 + 500,- 350
|
||||
+ 500,- 400 + 500,- 350 + 500,- 400 + 500,-1250
|
||||
+ 500,-1250 + 500,-1250 + 500,- 350 + 500,-1250
|
||||
+ 500,- 400 + 500,-1250 + 500,- 350 + 500,-1250
|
||||
+ 550
|
||||
Sum: 67000
|
||||
Reference in new issue
Block a user