初始化提交
This commit is contained in:
388
arduino-cli/libraries/IRremote/examples/MicroGirs/MicroGirs.ino
Normal file
388
arduino-cli/libraries/IRremote/examples/MicroGirs/MicroGirs.ino
Normal file
@@ -0,0 +1,388 @@
|
||||
/**
|
||||
* @file MicroGirs.ino
|
||||
*
|
||||
* @brief This is a minimalistic <a href="http://harctoolbox.org/Girs.html">Girs server</a>.
|
||||
* It only depends on (a subset of) IRremote. It can be used with
|
||||
* <a href="http://www.harctoolbox.org/IrScrutinizer.html">IrScrutinizer</a>
|
||||
* (select Sending/Capturing hw = Girs Client) as well as
|
||||
* <a href="http://lirc.org">Lirc</a>
|
||||
* version 0.9.4 and later, using the driver <a href="http://lirc.org/html/girs.html">Girs</a>).
|
||||
* (Authors of similar software are encourage to implement support.)
|
||||
*
|
||||
* It runs on all hardware on which IRemote runs.
|
||||
*
|
||||
* It consists of an interactive IR server, taking one-line commands from
|
||||
* the "user" (which is typically not a person but another program), and
|
||||
* responds with a one-line response. In the language of the Girs
|
||||
* specifications, the modules "base", receive, and transmit are
|
||||
* implemented. (The two latter can be disabled by not defining two
|
||||
* corresponding CPP symbols.)
|
||||
*
|
||||
* It understands the following commands:
|
||||
*
|
||||
* The "version" command returns the program name and version,
|
||||
* The "modules" command returns the modules implemented, normally base, receive and transmit.
|
||||
* The "receive" command reads an IR signal using the used, demodulating IR sensor.
|
||||
* The "send" commands transmits a supplied raw signal the requested number of times.
|
||||
*
|
||||
* Only the first character of the command is evaluated in this implementation.
|
||||
*
|
||||
* The "receive" command returns the received IR sequence as a sequence
|
||||
* of durations, including a (dummy) trailing silence. On-periods
|
||||
* ("marks", "flashes") are prefixed by "+", while off-periods ("spaces",
|
||||
* "gaps") are prefixed by "-". The present version never times out.
|
||||
*
|
||||
* The \c send command takes the following parameters:
|
||||
*
|
||||
* send noSends frequencyHz introLength repeatLength endingLength durations...
|
||||
|
||||
* where
|
||||
*
|
||||
* * frequencyHz denotes the modulation frequency in Hz
|
||||
* (\e not khz, as is normally used in IRremote)
|
||||
* * introLength denotes the length of the intro sequence, must be even,
|
||||
* * repeatLength denotes the length of the repeat sequence, must be even,
|
||||
* * endingLength denotes the length of the ending sequence (normally 0), must be even.
|
||||
* * duration... denotes the microsecond durations to send,
|
||||
* starting with the first on-period, ending with a (possibly dummy) trailing silence
|
||||
*
|
||||
* Semantics: first the intro sequence will be sent once (i.e., the first
|
||||
* repeatLength durations) (if non-empty). Then the repeat sequence will
|
||||
* be sent (noSends-1) times, unless the intro sequence was empty, in
|
||||
* which case it will be send noSends times. Finally, the ending
|
||||
* sequence will be send once (if non-empty).
|
||||
*
|
||||
* Weaknesses of the IRremote implementation:
|
||||
* * Reception never times out if no IR is seen.
|
||||
* * The IRrecv class does its own decoding which is irrelevant for us.
|
||||
* * The timeout at the end on a signal reception is not configurable.
|
||||
* For example, a NEC1 type signal will cut after the intro sequence,
|
||||
* and the repeats will be considered independent signals.
|
||||
* In IrSqrutinizer, recognition of repeating signals will therefore not work.
|
||||
* The size of the data is platform dependent ("unsigned int", which is 16 bit on AVR boards, 32 bits on 32 bit boards).
|
||||
*
|
||||
*/
|
||||
#include <Arduino.h>
|
||||
|
||||
//#define RAW_BUFFER_LENGTH 750 // 750 is the value for air condition remotes.
|
||||
|
||||
// Change the following two entries if desired
|
||||
|
||||
/**
|
||||
* Baud rate for the serial/USB connection.
|
||||
* (115200 is the default for IrScrutinizer and Lirc.)
|
||||
*/
|
||||
#define BAUDRATE 115200
|
||||
|
||||
#define NO_DECODER
|
||||
|
||||
#include "PinDefinitionsAndMore.h" //Define macros for input and output pin etc.
|
||||
#include "IRremote.hpp"
|
||||
#include <limits.h>
|
||||
|
||||
/**
|
||||
* Define to support reception of IR.
|
||||
*/
|
||||
#define RECEIVE
|
||||
|
||||
/**
|
||||
* Define to support transmission of IR signals.
|
||||
*/
|
||||
#define TRANSMIT
|
||||
|
||||
// (The sending pin is in general not configurable, see the documentation of IRremote.)
|
||||
|
||||
/**
|
||||
* Character that ends the command lines. Do not change unless you known what
|
||||
* you are doing. IrScrutinizer and Lirc expects \r.
|
||||
*/
|
||||
#define EOLCHAR '\r'
|
||||
|
||||
////// End of user configurable variables ////////////////////
|
||||
|
||||
/**
|
||||
* The modules supported, as given by the "modules" command.
|
||||
*/
|
||||
#if defined(TRANSMIT)
|
||||
#if defined(RECEIVE)
|
||||
#define modulesSupported "base transmit receive"
|
||||
#else // ! RECEIVE
|
||||
#define modulesSupported "base transmit"
|
||||
#endif
|
||||
#else // !TRANSMIT
|
||||
#if defined(RECEIVE)
|
||||
#define modulesSupported "base receive"
|
||||
#else // ! RECETVE
|
||||
#error At lease one of TRANSMIT and RECEIVE must be defined
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Name of program, as reported by the "version" command.
|
||||
*/
|
||||
#define PROGNAME "MicroGirs"
|
||||
|
||||
/**
|
||||
* Version of program, as reported by the "version" command.
|
||||
*/
|
||||
#define VERSION "2020-07-05"
|
||||
|
||||
#define okString "OK"
|
||||
#define errorString "ERROR"
|
||||
#define timeoutString "."
|
||||
|
||||
// For compatibility with IRremote, we deliberately use
|
||||
// the platform dependent types.
|
||||
// (Although it is a questionable idea ;-) )
|
||||
/**
|
||||
* Type used for modulation frequency in Hz (\e not kHz).
|
||||
*/
|
||||
typedef unsigned frequency_t; // max 65535, unless 32-bit
|
||||
|
||||
/**
|
||||
* Type used for durations in micro seconds.
|
||||
*/
|
||||
typedef uint16_t microseconds_t; // max 65535
|
||||
|
||||
static const microseconds_t DUMMYENDING = 40000U;
|
||||
static const frequency_t FREQUENCY_T_MAX = UINT16_MAX;
|
||||
static const frequency_t MICROSECONDS_T_MAX = UINT16_MAX;
|
||||
|
||||
/**
|
||||
* Our own tokenizer class. Breaks the command line into tokens.
|
||||
* Usage outside of this package is discouraged.
|
||||
*/
|
||||
class Tokenizer {
|
||||
private:
|
||||
static const int invalidIndex = -1;
|
||||
|
||||
int index; // signed since invalidIndex is possible
|
||||
const String &payload;
|
||||
void trim();
|
||||
|
||||
public:
|
||||
Tokenizer(const String &str);
|
||||
|
||||
String getToken();
|
||||
String getRest();
|
||||
String getLine();
|
||||
long getInt();
|
||||
microseconds_t getMicroseconds();
|
||||
frequency_t getFrequency();
|
||||
|
||||
static const int invalid = INT_MAX;
|
||||
};
|
||||
|
||||
Tokenizer::Tokenizer(const String &str) :
|
||||
index(0), payload(str) {
|
||||
}
|
||||
|
||||
String Tokenizer::getRest() {
|
||||
String result = index == invalidIndex ? String("") : payload.substring(index);
|
||||
index = invalidIndex;
|
||||
return result;
|
||||
}
|
||||
|
||||
String Tokenizer::getLine() {
|
||||
if (index == invalidIndex)
|
||||
return String("");
|
||||
|
||||
int i = payload.indexOf('\n', index);
|
||||
String s = (i > 0) ? payload.substring(index, i) : payload.substring(index);
|
||||
index = (i > 0) ? i + 1 : invalidIndex;
|
||||
return s;
|
||||
}
|
||||
|
||||
String Tokenizer::getToken() {
|
||||
if (index < 0)
|
||||
return String("");
|
||||
|
||||
int i = payload.indexOf(' ', index);
|
||||
String s = (i > 0) ? payload.substring(index, i) : payload.substring(index);
|
||||
index = (i > 0) ? i : invalidIndex;
|
||||
if (index != invalidIndex)
|
||||
if (index != invalidIndex)
|
||||
while (payload.charAt(index) == ' ')
|
||||
index++;
|
||||
return s;
|
||||
}
|
||||
|
||||
long Tokenizer::getInt() {
|
||||
String token = getToken();
|
||||
return token == "" ? (long) invalid : token.toInt();
|
||||
}
|
||||
|
||||
microseconds_t Tokenizer::getMicroseconds() {
|
||||
long t = getToken().toInt();
|
||||
return (microseconds_t) ((t < MICROSECONDS_T_MAX) ? t : MICROSECONDS_T_MAX);
|
||||
}
|
||||
|
||||
frequency_t Tokenizer::getFrequency() {
|
||||
long t = getToken().toInt();
|
||||
return (frequency_t) ((t < FREQUENCY_T_MAX) ? t : FREQUENCY_T_MAX);
|
||||
}
|
||||
///////////////// end Tokenizer /////////////////////////////////
|
||||
|
||||
#if defined(TRANSMIT)
|
||||
static inline unsigned hz2khz(frequency_t hz) {
|
||||
return (hz + 500) / 1000;
|
||||
}
|
||||
|
||||
/**
|
||||
* Transmits the IR signal given as argument.
|
||||
*
|
||||
* The intro sequence (possibly empty) is first sent. Then the repeat signal
|
||||
* (also possibly empty) is sent, "times" times, except for the case of
|
||||
* the intro signal being empty, in which case it is sent "times" times.
|
||||
* Finally the ending sequence (possibly empty) is sent.
|
||||
*
|
||||
* @param intro Sequence to be sent exactly once at the start.
|
||||
* @param lengthIntro Number of durations in intro sequence, must be even.
|
||||
* @param repeat Sequence top possibly be sent multiple times
|
||||
* @param lengthRepeat Number of durations in repeat sequence.
|
||||
* @param ending Sequence to be sent at the end, possibly empty
|
||||
* @param lengthEnding Number of durations in ending sequence
|
||||
* @param frequency Modulation frequency, in Hz (not kHz as normally in IRremote)
|
||||
* @param times Number of times to send the signal, in the sense above.
|
||||
*/
|
||||
static void sendRaw(const microseconds_t intro[], unsigned lengthIntro, const microseconds_t repeat[], unsigned lengthRepeat,
|
||||
const microseconds_t ending[], unsigned lengthEnding, frequency_t frequency, unsigned times) {
|
||||
if (lengthIntro > 0U)
|
||||
IrSender.sendRaw(intro, lengthIntro, hz2khz(frequency));
|
||||
if (lengthRepeat > 0U)
|
||||
for (unsigned i = 0U; i < times - (lengthIntro > 0U); i++)
|
||||
IrSender.sendRaw(repeat, lengthRepeat, hz2khz(frequency));
|
||||
if (lengthEnding > 0U)
|
||||
IrSender.sendRaw(ending, lengthEnding, hz2khz(frequency));
|
||||
}
|
||||
#endif // TRANSMIT
|
||||
|
||||
#if defined(RECEIVE)
|
||||
|
||||
static void dump(Stream &stream) {
|
||||
unsigned int count = IrReceiver.decodedIRData.rawDataPtr->rawlen;
|
||||
// If buffer gets full, count = RAW_BUFFER_LENGTH, which is odd,
|
||||
// and IrScrutinizer does not like that.
|
||||
count &= ~1;
|
||||
for (unsigned int i = 1; i < count; i++) {
|
||||
stream.write(i & 1 ? '+' : '-');
|
||||
stream.print(IrReceiver.decodedIRData.rawDataPtr->rawbuf[i] * MICROS_PER_TICK, DEC);
|
||||
stream.print(" ");
|
||||
}
|
||||
stream.print('-');
|
||||
stream.println(DUMMYENDING);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a command from the stream given as argument.
|
||||
* @param stream Stream to read from, typically Serial.
|
||||
*/
|
||||
static void receive(Stream &stream) {
|
||||
IrReceiver.start();
|
||||
|
||||
while (!IrReceiver.decode()) {
|
||||
}
|
||||
IrReceiver.stop();
|
||||
|
||||
dump(stream);
|
||||
}
|
||||
|
||||
#endif // RECEIVE
|
||||
|
||||
/**
|
||||
* Initialization.
|
||||
*/
|
||||
void setup() {
|
||||
Serial.begin(BAUDRATE);
|
||||
while (!Serial)
|
||||
; // wait for serial port to connect.
|
||||
|
||||
Serial.println(F(PROGNAME " " VERSION));
|
||||
// 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(RECEIVE)
|
||||
// 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.print(F("at pin "));
|
||||
#endif
|
||||
|
||||
IrSender.begin(); // Start with IR_SEND_PIN as send pin and enable feedback LED at default feedback LED pin
|
||||
|
||||
}
|
||||
|
||||
static String readCommand(Stream &stream) {
|
||||
while (stream.available() == 0) {
|
||||
}
|
||||
|
||||
String line = stream.readStringUntil(EOLCHAR);
|
||||
line.trim();
|
||||
return line;
|
||||
}
|
||||
|
||||
static void processCommand(const String &line, Stream &stream) {
|
||||
Tokenizer tokenizer(line);
|
||||
String cmd = tokenizer.getToken();
|
||||
|
||||
// Decode the command in cmd
|
||||
if (cmd.length() == 0) {
|
||||
// empty command, do nothing
|
||||
stream.println(F(okString));
|
||||
return;
|
||||
}
|
||||
|
||||
switch (cmd[0]) {
|
||||
case 'm':
|
||||
stream.println(F(modulesSupported));
|
||||
break;
|
||||
|
||||
#if defined(RECEIVE)
|
||||
case 'r': // receive
|
||||
//case 'a':
|
||||
//case 'c':
|
||||
receive(stream);
|
||||
break;
|
||||
#endif // RECEIVE
|
||||
|
||||
#if defined(TRANSMIT)
|
||||
case 's': // send
|
||||
{
|
||||
// TODO: handle unparsable data gracefully
|
||||
unsigned noSends = (unsigned) tokenizer.getInt();
|
||||
frequency_t frequency = tokenizer.getFrequency();
|
||||
unsigned introLength = (unsigned) tokenizer.getInt();
|
||||
unsigned repeatLength = (unsigned) tokenizer.getInt();
|
||||
unsigned endingLength = (unsigned) tokenizer.getInt();
|
||||
microseconds_t intro[introLength];
|
||||
microseconds_t repeat[repeatLength];
|
||||
microseconds_t ending[endingLength];
|
||||
for (unsigned i = 0; i < introLength; i++)
|
||||
intro[i] = tokenizer.getMicroseconds();
|
||||
for (unsigned i = 0; i < repeatLength; i++)
|
||||
repeat[i] = tokenizer.getMicroseconds();
|
||||
for (unsigned i = 0; i < endingLength; i++)
|
||||
ending[i] = tokenizer.getMicroseconds();
|
||||
sendRaw(intro, introLength, repeat, repeatLength, ending, endingLength, frequency, noSends);
|
||||
stream.println(F(okString));
|
||||
}
|
||||
break;
|
||||
#endif // TRANSMIT
|
||||
|
||||
case 'v': // version
|
||||
stream.println(F(PROGNAME " " VERSION));
|
||||
break;
|
||||
default:
|
||||
stream.println(F(errorString));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a command from the serial line and executes it-
|
||||
*/
|
||||
void loop() {
|
||||
String line = readCommand(Serial);
|
||||
processCommand(line, Serial);
|
||||
}
|
||||
@@ -0,0 +1,286 @@
|
||||
/*
|
||||
* 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-2022 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
|
||||
* ATtinyX5 0|PB0 4|PB4 3|PB3
|
||||
* ATtiny167 3|PA3 2|PA2 7|PA7 ATTinyCore
|
||||
* ATtiny167 9|PA3 8|PA2 5|PA7 Digispark pro
|
||||
* ATtiny3217 18|PA1 19|PA2 20|PA3 MegaTinyCore
|
||||
* ATtiny1604 2 3|PA5 %
|
||||
* SAMD21 3 4 5
|
||||
* ESP8266 14|D5 12|D6 %
|
||||
* ESP32 15 4 27
|
||||
* BluePill PA6 PA7 PA3
|
||||
* APOLLO3 11 12 5
|
||||
* RP2040 3|GPIO15 4|GPIO16 5|GPIO17
|
||||
*/
|
||||
//#define _IR_MEASURE_TIMING // For debugging purposes.
|
||||
|
||||
#if 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 13 // D7
|
||||
#define APPLICATION_PIN 0 // D3
|
||||
|
||||
#define tone(...) void() // tone() inhibits receive timer
|
||||
#define noTone(a) void()
|
||||
#define TONE_PIN 42 // Dummy for examples using it
|
||||
|
||||
#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_SEND_PIN PA7
|
||||
#define TONE_PIN PA3
|
||||
#define _IR_TIMING_TEST_PIN PA5
|
||||
#define APPLICATION_PIN PA2
|
||||
# if defined(ARDUINO_GENERIC_STM32F103C) || defined(ARDUINO_BLUEPILL_F103C8)
|
||||
// BluePill LED is active low
|
||||
#define FEEDBACK_LED_IS_ACTIVE_LOW
|
||||
# endif
|
||||
|
||||
#elif defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__) // Digispark board
|
||||
#include "ATtinySerialOut.hpp" // Available as Arduino library "ATtinySerialOut". saves 370 bytes program memory and 38 bytes RAM for digistump core
|
||||
#define IR_RECEIVE_PIN 0
|
||||
#define IR_SEND_PIN 4 // Pin 2 is serial output with ATtinySerialOut. Pin 1 is internal LED and Pin3 is USB+ with pullup on Digispark board.
|
||||
#define TONE_PIN 3
|
||||
#define _IR_TIMING_TEST_PIN 3
|
||||
|
||||
#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)
|
||||
#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
|
||||
#define _IR_TIMING_TEST_PIN 10 // PA4
|
||||
# else
|
||||
#define IR_RECEIVE_PIN 3
|
||||
#define IR_SEND_PIN 2
|
||||
#define TONE_PIN 7
|
||||
# endif
|
||||
|
||||
#elif defined(__AVR_ATtiny88__) // MH-ET Tiny88 board
|
||||
#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 3 // INT1
|
||||
#define IR_SEND_PIN 4
|
||||
#define TONE_PIN 9
|
||||
#define _IR_TIMING_TEST_PIN 8
|
||||
|
||||
#elif defined(__AVR_ATtiny1616__) || defined(__AVR_ATtiny3216__) || defined(__AVR_ATtiny3217__) // Tiny Core Dev board
|
||||
#define IR_RECEIVE_PIN 18
|
||||
#define IR_SEND_PIN 19
|
||||
#define TONE_PIN 20
|
||||
#define APPLICATION_PIN 0 // PA4
|
||||
#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 2 // PA6
|
||||
|
||||
#elif defined(__AVR_ATtiny1604__)
|
||||
#define IR_RECEIVE_PIN 2 // To be compatible with interrupt example, pin 2 is chosen here.
|
||||
#define IR_SEND_PIN 3
|
||||
#define APPLICATION_PIN 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
|
||||
|
||||
#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
|
||||
#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 // to be compatible with the Arduino Nano RP2040 Connect (pin3)
|
||||
#define IR_SEND_PIN 16
|
||||
#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)
|
||||
#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(__AVR__) // Default as for ATmega328 like on Uno, Nano 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
|
||||
|
||||
#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
|
||||
|
||||
// On the Zero and others we switch explicitly to SerialUSB
|
||||
#define Serial SerialUSB
|
||||
|
||||
// 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 warning in 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
|
||||
Reference in New Issue
Block a user