Добавлена библиотека IRremote
1. Инициализация hal библиотек, включение тактирования портов, установка вектора прерываний теперь производится в crt0.S 2. Добавлена библиотека IRremote. Для работы использует прерывание таймера timer16_0 Co-authored-by: KLASSENTS <klassen@elron.tech> Co-committed-by: KLASSENTS <klassen@elron.tech>
This commit was merged in pull request #10.
This commit is contained in:
1 parent
2945cf9c8c
commit
e53bac6ba8
122 files changed
+34285
-29
No files matched your search
@@ -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
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user