Documentation

This commit is contained in:
Armin 2024-04-07 20:20:49 +02:00
parent b962db8f4e
commit d781c17620
9 changed files with 71 additions and 29 deletions

View File

@ -52,6 +52,7 @@ Available as [Arduino library "IRremote"](https://www.arduinolibraries.info/libr
- [Tiny NEC receiver and sender](https://github.com/Arduino-IRremote/Arduino-IRremote?tab=readme-ov-file#tiny-nec-receiver-and-sender)
- [The FAST protocol](https://github.com/Arduino-IRremote/Arduino-IRremote?tab=readme-ov-file#the-fast-protocol)
- [FAQ and hints](https://github.com/Arduino-IRremote/Arduino-IRremote?tab=readme-ov-file#faq-and-hints)
* [Receiving does not run if analogWrite() or tone() is used.](https://github.com/Arduino-IRremote/Arduino-IRremote?tab=readme-ov-file#receiving-does-not-run-if-analogwrite-or-tone-is-used)
* [Problems with Neopixels, FastLed etc.](https://github.com/Arduino-IRremote/Arduino-IRremote?tab=readme-ov-file#problems-with-neopixels-fastled-etc)
* [Does not work/compile with another library](https://github.com/Arduino-IRremote/Arduino-IRremote?tab=readme-ov-file#does-not-workcompile-with-another-library)
* [Multiple IR receiver](https://github.com/Arduino-IRremote/Arduino-IRremote?tab=readme-ov-file#multiple-ir-receiver)
@ -242,16 +243,14 @@ Most likely your code will run and you will not miss the new features.
Consider using the [original 2.4 release form 2017](https://github.com/Arduino-IRremote/Arduino-IRremote/releases/tag/v2.4.0)
or the last backwards compatible [2.8 version](https://github.com/Arduino-IRremote/Arduino-IRremote/releases/tag/2.8.0) for you project.<br/>
It may be sufficient and deals flawlessly with 32 bit IR codes.<br/>
If this doesn't fit your case, be assured that 3.x is at least trying to be backwards compatible, so your old examples should still work fine.
If this doesn't fit your case, be assured that 4.x is at least trying to be backwards compatible, so your old examples should still work fine.
### Drawbacks
### Drawbacks of using 2.x
- Only the following decoders are available:<br/>
` NEC ` &nbsp; &nbsp; ` Denon ` &nbsp; &nbsp; ` Panasonic ` &nbsp; &nbsp; ` JVC ` &nbsp; &nbsp; ` LG `<br/>
` RC5 ` &nbsp; &nbsp; ` RC6 ` &nbsp; &nbsp; ` Samsung ` &nbsp; &nbsp; ` Sony `
- The call of `irrecv.decode(&results)` uses the old MSB first decoders like in 2.x and sets the 32 bit codes in `results.value`.
- The old functions `sendNEC()` and `sendJVC()` are renamed to `sendNECMSB()` and `sendJVCMSB()`.<br/>
Use them to send your **old MSB-first 32 bit IR data codes**.
- No decoding by a (constant) 8/16 bit address and an 8 bit command.
- No decoding to a more meaningfull (constant) 8/16 bit address and 8 bit command.
<br/>
@ -411,7 +410,8 @@ If you handle the sending of repeat frames by your own, you must insert sensible
The old send*Raw() functions for sending like e.g. `IrSender.sendNECRaw(0xE61957A8,2)` are kept for backward compatibility to **(old)** tutorials and unsupported as well as error prone.
## Send pin
Any pin can be choosen as send pin, because the PWM signal is generated by default with software bit banging, since `SEND_PWM_BY_TIMER` is not active.
Any pin can be choosen as send pin, because the PWM signal is generated by default with software bit banging, since `SEND_PWM_BY_TIMER` is not active.<br/>
On **ESP32** ledc channel 0 is used for gereating the IR PWM.<br/>
If `IR_SEND_PIN` is specified (as c macro), it reduces program size and improves send timing for AVR. If you want to use a variable to specify send pin e.g. with `setSendPin(uint8_t aSendPinNumber)`, you must disable this `IR_SEND_PIN` macro. Then you can change send pin at any time before sending an IR frame. See also [Compile options / macros for this library](https://github.com/Arduino-IRremote/Arduino-IRremote?tab=readme-ov-file#compile-options--macros-for-this-library).
### List of public IR code databases
@ -508,6 +508,10 @@ void loop() {}
The FAST protocol can be received by IRremote and TinyIRReceiver.
# FAQ and hints
## Receiving does not run if analogWrite() or tone() is used.
The receiver sample interval of 50 µs is generated by a timer. On many boards this must be a [hardware timer](https://github.com/Arduino-IRremote/Arduino-IRremote?tab=readme-ov-file#timer-and-pin-usage). On some boards where a software timer is available, the software timer is used.<br/>
Be aware that the hardware timer used for receiving should not be used for analogWrite().<br/>
On the Uno and other AVR boards the receiver timer ist the same as the tone timer, so receiving will stop after a tone() command. See [ReceiveDemo example](https://github.com/Arduino-IRremote/Arduino-IRremote/blob/b962db8f4e47408df01474a57f313f5a6bbe39a1/examples/ReceiveDemo/ReceiveDemo.ino#L257) how to deal with it.
## Problems with Neopixels, FastLed etc.
IRremote will not work right when you use **Neopixels** (aka WS2811/WS2812/WS2812B) or other libraries blocking interrupts for a longer time (> 50 &micro;s).<br/>
@ -695,7 +699,7 @@ Here you see the delay of the receiver output (blue) from the IR diode input (ye
# Issues and discussions
- Do not open an issue without first testing some of the examples!
- If you have a problem, please post the MCVE (Minimal Complete Verifiable Example) showing this problem. My experience is, that most of the times you will find the problem while creating this MCVE :smile:.
- [Use code blocks](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet#code); **it helps us help you when we can read your code!**
- [Use code blocks](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet#code); **it helps us to help you when we can read your code!**
<br/>
@ -764,6 +768,7 @@ If you are using [Sloeber](https://eclipse.baeyens.it) as your IDE, you can easi
# Supported Boards
**Issues and discussions with the content "Is it possible to use this library with the ATTinyXYZ? / board XYZ" without any reasonable explanations will be immediately closed without further notice.**<br/>
For **ESP8266/ESP32**, [this library](https://github.com/crankyoldgit/IRremoteESP8266) supports an [impressive set of protocols and a lot of air conditioners](https://github.com/crankyoldgit/IRremoteESP8266/blob/master/SupportedProtocols.md)<br/>
<br/>
Digispark boards are only tested with [ATTinyCore](https://github.com/SpenceKonde/ATTinyCore) using `New Style` pin mapping for the Digispark Pro board.<br/>
ATtiny boards are only tested with [ATTinyCore](https://github.com/SpenceKonde/ATTinyCore#supported-devices) or [megaTinyCore](https://github.com/SpenceKonde/megaTinyCore).
@ -786,7 +791,7 @@ ATtiny boards are only tested with [ATTinyCore](https://github.com/SpenceKonde/A
- BluePill with STM32
- RP2040 based boards (Raspberry Pi Pico, Nano RP2040 Connect etc.)
For ESP8266/ESP32, [this library](https://github.com/crankyoldgit/IRremoteESP8266) supports an [impressive set of protocols and a lot of air conditioners](https://github.com/crankyoldgit/IRremoteESP8266/blob/master/SupportedProtocols.md)
We are open to suggestions for adding support to new boards, however we highly recommend you contact your supplier first and ask them to provide support from their side.<br/>
If you can provide **examples of using a periodic timer for interrupts** for the new board, and the board name for selection in the Arduino IDE, then you have way better chances to get your board supported by IRremote.
@ -794,7 +799,8 @@ If you can provide **examples of using a periodic timer for interrupts** for the
<br/>
# Timer and pin usage
The **receiver sample interval of 50 &micro;s is generated by a timer**. On many boards this must be a hardware timer. On some boards where a software timer is available, the software timer is used.
The **receiver sample interval of 50 &micro;s is generated by a timer**. On many boards this must be a hardware timer. On some boards where a software timer is available, the software timer is used.<br/>
On **ESP32** `hw_timer_t` is used for receive interrupts and `ledc` channel 0 is used for gneating the IR PWM.
Every pin can be used for receiving.<br/>
If software PWM is selected, which is default, every pin can also be used for sending. Sending with software PWM does not require a timer!
@ -823,9 +829,10 @@ The code for the timer and the **timer selection** is located in [private/IRTime
| ATmega168, **ATmega328** | 1, **2** | 9, **3** | 9 & 10, **3 & 11** |
| ATmega1280, **ATmega2560** | 1, **2**, 3, 4, 5 | 5, 6, **9**, 11, 46 | 5, 6, **9**, 11, 46 |
| ATmega4809 | **TCB0** | **A4** | |
| Leonardo (Atmega32u4) | 1, 3, **4_HS** | 5, **9**, 13 | 5, **9**, 13 |
| Leonardo (Atmega32u4) | 1, 3, **4_HS** | 5, **9**, 13 | 5, **9**, 13 |
| Zero (SAMD) | **TC3** | \*, **9** | |
| [ESP32](http://esp32.net/) | **Ledc chan. 0** | All pins | |
| [ESP8266](http://esp8266.net/) | **timer1** | % | |
| [ESP32](http://esp32.net/) | **hw_timer_t**<br/>**Ledc channel 0** | All pins | |
| [Sparkfun Pro Micro](https://www.sparkfun.com/products/12640) | 1, **3** | **5**, 9 | |
| [Teensy 1.0](https://www.pjrc.com/teensy/pinout.html) | **1** | **17** | 15, 18 |
| [Teensy 2.0](https://www.pjrc.com/teensy/pinout.html) | 1, 3, **4_HS** | 9, **10**, 14 | 12 |
@ -963,4 +970,4 @@ From the version 2.8.0, the license is the MIT license.
# Copyright
Initially coded 2009 Ken Shirriff http://www.righto.com<br/>
Copyright (c) 2016-2017 Rafi Khan<br/>
Copyright (c) 2020-2023 [Armin Joachimsmeyer](https://github.com/ArminJo)
Copyright (c) 2020-2024 [Armin Joachimsmeyer](https://github.com/ArminJo)

View File

@ -1,4 +1,12 @@
// Based on the work by DFRobot
/*
* Extensions made by AJ 2023
* Removed Arduino 0.x support
* Added SoftI2CMaste support, which drastically reduces program size.
* Added OLED stuff
* Added createChar() with PROGMEM input
* Added fast timing
*/
#include "Arduino.h"
@ -23,6 +31,18 @@ inline size_t LiquidCrystal_I2C::write(uint8_t value) {
#include "SoftWire.h"
#endif
#if defined(__AVR__)
/*
* The datasheet says: a command need > 37us to settle. Enable pulse must be > 450ns.
* Use no delay for enable pulse after each command,
* because the overhead of this library seems to be using the 37 us and 450 ns.
* At least it works perfectly for all my LCD's connected to Uno, Nano etc.
* and it saves a lot of time in realtime applications using LCD as display,
* like https://github.com/ArminJo/Arduino-DTSU666H_PowerMeter
*/
#define USE_FAST_TIMING
#endif
// When the display powers up, it is configured as follows:
//
// 1. Display clear
@ -131,7 +151,11 @@ void LiquidCrystal_I2C::begin(uint8_t cols __attribute__((unused)), uint8_t line
/********** high level commands, for the user! */
void LiquidCrystal_I2C::clear() {
command(LCD_CLEARDISPLAY); // clear display, set cursor position to zero
#if defined(USE_FAST_TIMING)
delayMicroseconds(1500); // this command takes a long time! // AJ 20.9.23 1200 is too short for my 2004 LCD's, 1400 is OK
#else
delayMicroseconds(2000); // this command takes a long time!
#endif
if (_oled)
setCursor(0, 0);
}
@ -274,10 +298,13 @@ void LiquidCrystal_I2C::expanderWrite(uint8_t _data) {
void LiquidCrystal_I2C::pulseEnable(uint8_t _data) {
expanderWrite(_data | En); // En high
// delayMicroseconds(1); // enable pulse must be >450ns // AJ 20.9.23 not required for my LCD's
#if !defined(USE_FAST_TIMING)
delayMicroseconds(1); // enable pulse must be > 450ns // AJ 20.9.23 not required for my LCD's
#endif
expanderWrite(_data & ~En); // En low
// delayMicroseconds(50); // commands need > 37us to settle // AJ 20.9.23 not required for my LCD's
#if !defined(USE_FAST_TIMING)
delayMicroseconds(50); // commands need > 37us to settle // AJ 20.9.23 not required for my LCD's
#endif
}
// Alias functions

View File

@ -98,6 +98,10 @@
//#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();

View File

@ -5,7 +5,7 @@
"repository":
{
"type": "git",
"url": "https://github.com/z3t0/Arduino-IRremote.git"
"url": "https://github.com/Arduino-IRremote/Arduino-IRremote.git"
},
"version": "4.3.1",
"frameworks": "arduino",

Binary file not shown.

After

Width:  |  Height:  |  Size: 149 KiB

View File

@ -772,7 +772,7 @@ bool IRrecv::decodePulseDistanceWidthData(uint_fast8_t aNumberOfBits, IRRawlenTy
} else {
tDecodedData |= tMask;
}
IR_TRACE_PRINTLN('1');
IR_TRACE_PRINTLN(F("=> 1"));
} else {
#if defined DECODE_STRICT_CHECKS
/*
@ -811,7 +811,7 @@ bool IRrecv::decodePulseDistanceWidthData(uint_fast8_t aNumberOfBits, IRRawlenTy
}
#endif
// do not set the bit
IR_TRACE_PRINTLN('0');
IR_TRACE_PRINTLN(F("=> 0"));
}
#if defined DECODE_STRICT_CHECKS
// If we have no stop bit, assume that last space, which is not recorded, is correct, since we can not check it
@ -1225,7 +1225,7 @@ void printActiveIRProtocols(Print *aSerial) {
aSerial->print(F("Lego Power Functions, "));
#endif
#if defined(DECODE_BOSEWAVE)
aSerial->print(F("Bosewave , "));
aSerial->print(F("Bosewave, "));
#endif
#if defined(DECODE_MAGIQUEST)
aSerial->print(F("MagiQuest, "));

View File

@ -30,10 +30,10 @@
//
// Support for Bose Wave Radio CD initially provided by https://github.com/uvotguy.
//
// As seen on my trusty oscilloscope, there is no repeat code. Instead, when I
// As seen on my oscilloscope, there is no repeat code. Instead, when I
// press and hold a button on my remote, it sends a command, makes a 51.2ms space,
// and resends the command, etc, etc.
// LSB first, 1 start bit + 8 bit data + 8 bit inverted data + 1 stop bit.
// and resends the command again, and so on.
// 38 kHz, LSB first, 1 start bit + 8 bit data + 8 bit inverted data + 1 stop bit.
#define BOSEWAVE_BITS 16 // Command and inverted command
#define BOSEWAVE_HEADER_MARK 1014 // 1014 are 39 clock periods (I counted 3 times!)

View File

@ -45,6 +45,7 @@
// from LEGO Power Functions RC Manual 26.02.2010 Version 1.20
// https://github.com/jurriaan/Arduino-PowerFunctions/raw/master/LEGO_Power_Functions_RC_v120.pdf
// https://oberguru.net/elektronik/ir/codes/lego_power_functions_train.lircd.conf
// For original LEGO receiver see: https://www.philohome.com/pfrec/pfrec.htm and https://www.youtube.com/watch?v=KCM4Ug1bPrM
//
// To ensure correct detection of IR messages six 38 kHz cycles are transmitted as mark.
// Low bit consists of 6 cycles of IR and 10 <20>cycles<65> of pause,

View File

@ -1397,6 +1397,9 @@ void timerConfigForSend(uint16_t aFrequencyKHz) {
}
# endif // defined(SEND_PWM_BY_TIMER)
/**********************************************************
* ESP8266 boards
**********************************************************/
#elif defined(ESP8266)
# if defined(SEND_PWM_BY_TIMER)
#error "No support for hardware PWM generation for ESP8266"
@ -1435,8 +1438,8 @@ void timerConfigForReceive() {
// the ledc functions behave like hardware timers for us :-), so we do not require our own soft PWM generation code.
hw_timer_t *s50usTimer = NULL; // set by timerConfigForReceive()
# if ESP_ARDUINO_VERSION < ESP_ARDUINO_VERSION_VAL(3, 0, 0) && !defined(SEND_AND_RECEIVE_TIMER_LEDC_CHANNEL)
#define SEND_AND_RECEIVE_TIMER_LEDC_CHANNEL 0 // The channel used for PWM 0 to 7 are high speed PWM channels
# if ESP_ARDUINO_VERSION < ESP_ARDUINO_VERSION_VAL(3, 0, 0) && !defined(SEND_LEDC_CHANNEL)
#define SEND_LEDC_CHANNEL 0 // The channel used for PWM 0 to 7 are high speed PWM channels
# endif
void timerEnableReceiveInterrupt() {
@ -1490,14 +1493,14 @@ uint8_t sLastSendPin = 0; // To detach before attach, if already attached
# if defined(SEND_PWM_BY_TIMER)
void enableSendPWMByTimer() {
# if ESP_ARDUINO_VERSION < ESP_ARDUINO_VERSION_VAL(3, 0, 0)
ledcWrite(SEND_AND_RECEIVE_TIMER_LEDC_CHANNEL, (IR_SEND_DUTY_CYCLE_PERCENT * 256) / 100); // * 256 since we have 8 bit resolution
ledcWrite(SEND_LEDC_CHANNEL, (IR_SEND_DUTY_CYCLE_PERCENT * 256) / 100); // * 256 since we have 8 bit resolution
# else
ledcWrite(IrSender.sendPin, (IR_SEND_DUTY_CYCLE_PERCENT * 256) / 100); // New API
# endif
}
void disableSendPWMByTimer() {
# if ESP_ARDUINO_VERSION < ESP_ARDUINO_VERSION_VAL(3, 0, 0)
ledcWrite(SEND_AND_RECEIVE_TIMER_LEDC_CHANNEL, 0);
ledcWrite(SEND_LEDC_CHANNEL, 0);
# else
ledcWrite(IrSender.sendPin, 0); // New API
# endif
@ -1509,14 +1512,14 @@ void disableSendPWMByTimer() {
*/
void timerConfigForSend(uint16_t aFrequencyKHz) {
# if ESP_ARDUINO_VERSION < ESP_ARDUINO_VERSION_VAL(3, 0, 0)
ledcSetup(SEND_AND_RECEIVE_TIMER_LEDC_CHANNEL, aFrequencyKHz * 1000, 8); // 8 bit PWM resolution
ledcSetup(SEND_LEDC_CHANNEL, aFrequencyKHz * 1000, 8); // 8 bit PWM resolution
# if defined(IR_SEND_PIN)
ledcAttachPin(IR_SEND_PIN, SEND_AND_RECEIVE_TIMER_LEDC_CHANNEL); // attach pin to channel
ledcAttachPin(IR_SEND_PIN, SEND_LEDC_CHANNEL); // attach pin to channel
# else
if(sLastSendPin != 0 && sLastSendPin != IrSender.sendPin){
ledcDetachPin(IrSender.sendPin); // detach pin before new attaching see #1194
}
ledcAttachPin(IrSender.sendPin, SEND_AND_RECEIVE_TIMER_LEDC_CHANNEL); // attach pin to channel
ledcAttachPin(IrSender.sendPin, SEND_LEDC_CHANNEL); // attach pin to channel
sLastSendPin = IrSender.sendPin;
# endif
# else // New API here