Compare commits
124 Commits
Author | SHA1 | Date |
---|---|---|
Armin | f5a3af340b | |
Paliak | f6e0255838 | |
Armin | e0ffb2ca08 | |
Armin | 60a3710597 | |
Armin | a28b94fabe | |
Armin | 8e75076a67 | |
Armin | d781c17620 | |
Armin | b962db8f4e | |
Armin | 59f4ce4a7f | |
Armin | 02c0e24da9 | |
Armin | c6c7f17f58 | |
Armin | 672d5cb532 | |
Armin | 8558db8b74 | |
Armin | 29564e83e1 | |
Armin | f2838859e0 | |
Armin | 3930c4148a | |
Armin | ef69840a5f | |
Armin | 2c2be06431 | |
Buzzerb | 483aaa2cc3 | |
Armin | 7c7ced8ecb | |
Armin | 8b9e036889 | |
Buzzerb | 7131adf71e | |
Armin | 11ec335b35 | |
Armin | a7bd9ea78b | |
Armin | fbd3565941 | |
Armin | ea28282d1c | |
Armin | 36403d810b | |
Armin | 1144c99122 | |
Armin | 1008347e33 | |
Armin | f80a7df244 | |
Armin | 8c84e03318 | |
Armin | 5a27b3ad44 | |
Florian Meier | c6aa13e443 | |
Armin | b1941ff470 | |
Armin | c5f50ea538 | |
Armin | 480ca42b1a | |
Armin | fe2010270e | |
Armin | 3a443bbac0 | |
Armin | 36e4a19ff8 | |
Armin | 5507618f93 | |
Armin | 8cedd6b253 | |
Armin | 6251c697fb | |
Armin | c2a3858a26 | |
Armin | f9cf150cd9 | |
Armin | b9e2157d27 | |
Armin | a3423854f5 | |
Armin | e3cdf409d9 | |
Armin | 1a0b5134aa | |
Armin | 8a26bcbdbf | |
Armin | f7dfa180c2 | |
Armin | be70d1e16a | |
Armin | c8c7110ca0 | |
Armin | a73851300a | |
Armin | 5bff1adec2 | |
Armin | 598a4412cb | |
Armin | e4f08bbd7d | |
Armin | 20431e1e5c | |
Armin | 03b39952ba | |
Armin | dfdf835f1b | |
Armin | d78dfdc166 | |
Armin | 06ae9b28da | |
Armin | 312c4133a1 | |
Armin | 7645ece912 | |
Armin | e235273180 | |
Armin | 7a9a1d0c4d | |
Armin | 114cbf335b | |
Armin | 920fa30303 | |
Armin | 970f228027 | |
Armin | c22345d091 | |
Armin | b0c5e49f93 | |
Armin | 1750eca93d | |
Armin | 919ddf8b36 | |
Armin | e92b4c7ba6 | |
Armin | f5edaa65ae | |
Knochi | 6fe2c6f321 | |
Armin | 0f016ed838 | |
Armin | bde7204e9d | |
Armin | fcccbff68b | |
Armin | ad0425f554 | |
Armin | cc13de99f3 | |
Armin | 83387a8493 | |
Armin | b7592e7586 | |
Armin | 36ad7dae9b | |
Armin | 7c42691d9f | |
Armin | 9492d1b163 | |
Armin | d1a290ea23 | |
Armin | 9369fbe871 | |
Armin | 16391f27d5 | |
Armin | 18e9d616c8 | |
Armin | 02a75199ce | |
Joe Ostrander | 65d62cc9f0 | |
Armin | 331de71f7f | |
Armin | 835cddab31 | |
Armin | 70b44fdfb5 | |
Armin | 5fb998db41 | |
Armin | 65136e4227 | |
Armin | e87474e8c0 | |
Armin | 2c234ebded | |
Armin | 7892d5c33b | |
Armin | 5f5026391b | |
Armin | e612155fce | |
Armin | fc1a179aec | |
Armin | e6bbf8638c | |
Armin | 32b8cef088 | |
Armin | da3e9e921a | |
Armin | e311d5150e | |
Armin | 3d89bff37f | |
Armin | ba7b11901a | |
Armin | fd7f47745d | |
Armin | d51b540cb2 | |
Armin | be74ebfe20 | |
Armin | 887066f06f | |
Armin | e36bcaa7b1 | |
Daniel Wallner | 662b70c621 | |
Armin | c68148626d | |
Armin | 909ee341d3 | |
Armin | a975405c34 | |
Armin | f4c5656c53 | |
Armin | 4a3651e23c | |
Armin | c6c1bf2e02 | |
Armin | 3504eda155 | |
Armin | d7217c5c74 | |
Armin | ad4abf825e | |
Armin | 72f7c75b3e |
|
@ -18,7 +18,7 @@ body:
|
|||
attributes:
|
||||
label: The type of board you are using.
|
||||
options:
|
||||
- Arduino ATmega328* board (UNO, Nano, etc.)
|
||||
- Arduino ATmega328* board (Uno, Nano, etc.)
|
||||
- Arduino ATmega2560 board (Mega)
|
||||
- Arduino ATmega32U4 board (Leonardo, etc.)
|
||||
- Arduino ATmega4809 megaAVR board (NanoEvery)
|
||||
|
@ -34,6 +34,21 @@ body:
|
|||
validations:
|
||||
required: true
|
||||
|
||||
- type: input
|
||||
id: Other_board_NAME_FQBN
|
||||
attributes:
|
||||
label: The boards name or FQBN (e.g. esp8266:esp8266:d1_mini:eesz=4M3M,xtal=80) for unspecified board.
|
||||
validations:
|
||||
required: false
|
||||
|
||||
- type: input
|
||||
id: Other_board_URL
|
||||
attributes:
|
||||
label: The board manager URL used for unspecified board.
|
||||
value: "https://"
|
||||
validations:
|
||||
required: false
|
||||
|
||||
- type: dropdown
|
||||
id: IDE
|
||||
attributes:
|
||||
|
@ -58,6 +73,7 @@ body:
|
|||
- BoseWave
|
||||
- Denon
|
||||
- Dish
|
||||
- FAST
|
||||
- JVC
|
||||
- Lego
|
||||
- LG
|
||||
|
@ -77,7 +93,7 @@ body:
|
|||
id: IR_Pin
|
||||
attributes:
|
||||
label: Pin(s) used for IR-receive, if not default.
|
||||
value: "Arduino pin number: "
|
||||
value: "Arduino pin number: default"
|
||||
validations:
|
||||
required: false
|
||||
|
||||
|
@ -91,7 +107,8 @@ body:
|
|||
- label: ReceiveDemo
|
||||
- label: SendRawDemo
|
||||
- label: ReceiverTimingAnalysis
|
||||
- label: MinimalReceiver
|
||||
- label: TinyReceiver
|
||||
- label: TinySender
|
||||
- label: ReceiveAndSend
|
||||
- label: SimpleSender
|
||||
- label: SendDemo
|
||||
|
@ -111,7 +128,8 @@ body:
|
|||
- label: ReceiveDemo
|
||||
- label: SendRawDemo
|
||||
- label: ReceiverTimingAnalysis
|
||||
- label: MinimalReceiver
|
||||
- label: TinyReceiver
|
||||
- label: TinySender
|
||||
- label: ReceiveAndSend
|
||||
- label: SimpleSender
|
||||
- label: SendDemo
|
||||
|
@ -201,3 +219,9 @@ body:
|
|||
- label: The title of the issue is helpful and relevant.
|
||||
required: true
|
||||
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
** We will start to close or delete issues that do not follow these guidelines
|
||||
as it doesn't help the contributors who spend time trying to solve issues if the community ignores guidelines!**
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# https://github.com/Arduino-IRremote/Arduino-IRremote/blob/master/.github/workflows/LibraryBuild.yml
|
||||
# Github workflow script to test compile all examples of an Arduino library repository.
|
||||
#
|
||||
# Copyright (C) 2020 Armin Joachimsmeyer
|
||||
# Copyright (C) 2020-2023 Armin Joachimsmeyer
|
||||
# https://github.com/ArminJo/Github-Actions
|
||||
#
|
||||
# Before being able to push to my .github\workflows directories,
|
||||
|
@ -31,7 +31,7 @@ jobs:
|
|||
build:
|
||||
name: ${{ matrix.arduino-boards-fqbn }} - test compiling examples
|
||||
|
||||
runs-on: ubuntu-18.04 # I picked Ubuntu to use shell scripts.
|
||||
runs-on: ubuntu-22.04 # I picked Ubuntu to use shell scripts.
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
|
@ -40,7 +40,7 @@ jobs:
|
|||
#
|
||||
# Examples: arduino:avr:uno, arduino:avr:leonardo, arduino:avr:nano, arduino:avr:mega
|
||||
# arduino:sam:arduino_due_x, arduino:samd:arduino_zero_native"
|
||||
# ATTinyCore:avr:attinyx5:chip=85,clock=1internal, digistump:avr:digispark-tiny, digistump:avr:digispark-pro
|
||||
# ATTinyCore:avr:attinyx5:chip=85,clock=1internal
|
||||
# STMicroelectronics:stm32:GenF1:pnum=BLUEPILL_F103C8
|
||||
# esp8266:esp8266:huzzah:eesz=4M3M,xtal=80, esp32:esp32:featheresp32:FlashFreq=80
|
||||
# You may add a suffix behind the fqbn with "|" to specify one board for e.g. different compile options like arduino:avr:uno|trace
|
||||
|
@ -55,184 +55,253 @@ jobs:
|
|||
- arduino:avr:leonardo
|
||||
- arduino:megaavr:nona4809:mode=off
|
||||
- arduino:samd:arduino_zero_native
|
||||
- arduino:renesas_uno:unor4wifi
|
||||
- adafruit:samd:adafruit_metro_m4:cache=on,speed=120,opt=small,maxqspi=50,usbstack=arduino,debug=off
|
||||
- arduino:mbed:nano33ble
|
||||
- arduino:mbed_rp2040:pico
|
||||
- rp2040:rp2040:arduino_nano_connect
|
||||
- digistump:avr:digispark-tiny:clock=clock16
|
||||
- ATTinyCore:avr:attinyx5micr:LTO=enable,sketchclock=16pll
|
||||
- ATTinyCore:avr:attinyx7micr:LTO=enable,sketchclock=16external,pinmapping=new,millis=enabled
|
||||
- ATTinyCore:avr:attinyx8micr:LTO=enable,sketchclock=16external,pinmapping=mhtiny,millis=enabled # ATtiny88 China clone board @16 MHz
|
||||
# - ATTinyCore:avr:attinyx5micr:LTO=enable,sketchclock=16pll
|
||||
# - ATTinyCore:avr:attinyx7micr:LTO=enable,sketchclock=16external,pinmapping=new,millis=enabled
|
||||
# - ATTinyCore:avr:attinyx8micr:LTO=enable,sketchclock=16external,pinmapping=mhtiny,millis=enabled # ATtiny88 China clone board @16 MHz
|
||||
- MegaCore:avr:128:bootloader=no_bootloader,eeprom=keep,BOD=2v7,LTO=Os_flto,clock=8MHz_internal # ATmega128
|
||||
- SparkFun:avr:promicro
|
||||
- megaTinyCore:megaavr:atxy4:chip=1604,clock=16internal
|
||||
- megaTinyCore:megaavr:atxy7:chip=3217,clock=16internal
|
||||
# - megaTinyCore:megaavr:atxy4:chip=1604,clock=16internal # https://github.com/SpenceKonde/megaTinyCore/issues/935
|
||||
# - megaTinyCore:megaavr:atxy7:chip=3217,clock=16internal # https://github.com/SpenceKonde/megaTinyCore/issues/935
|
||||
- esp8266:esp8266:d1_mini:eesz=4M3M,xtal=80
|
||||
- esp32:esp32:featheresp32:FlashFreq=80
|
||||
- esp32:esp32:esp32c3
|
||||
- STMicroelectronics:stm32:GenF1:pnum=BLUEPILL_F103C8
|
||||
- STMicroelectronics:stm32:GenL0:pnum=THUNDERPACK_L072
|
||||
- stm32duino:STM32F1:genericSTM32F103C
|
||||
- sandeepmistry:nRF5:BBCmicrobit
|
||||
- Seeeduino:samd:seeed_XIAO_m0:usbstack=arduino,debug=off,sercom4=include
|
||||
|
||||
# Specify parameters for each board.
|
||||
# With sketches-exclude you may exclude specific examples for a board. Use a comma separated list.
|
||||
#############################################################################################################
|
||||
include:
|
||||
- arduino-boards-fqbn: arduino:avr:uno
|
||||
sketches-exclude: IR2Keyboard
|
||||
build-properties: # the flags were put in compiler.cpp.extra_flags
|
||||
ReceiveDemo: -DIR_REMOTE_DISABLE_RECEIVE_COMPLETE_CALLBACK
|
||||
IRremoteExtensionTest: -DRAW_BUFFER_LENGTH=100 -DIR_SEND_PIN=3
|
||||
|
||||
- arduino-boards-fqbn: arduino:avr:uno|DEBUG
|
||||
sketches-exclude: IR2Keyboard
|
||||
build-properties: # the flags were put in compiler.cpp.extra_flags
|
||||
IRremoteExtensionTest: -DRAW_BUFFER_LENGTH=100 -DIR_SEND_PIN=3
|
||||
TinyReceiver: -DUSE_CALLBACK_FOR_TINY_RECEIVER
|
||||
All: -DEBUG
|
||||
|
||||
- arduino-boards-fqbn: arduino:avr:uno|USE_NO_SEND_PWM
|
||||
sketches-exclude: IR2Keyboard
|
||||
build-properties: # the flags were put in compiler.cpp.extra_flags
|
||||
IRremoteExtensionTest: -DRAW_BUFFER_LENGTH=100 -DIR_SEND_PIN=3
|
||||
TinyReceiver: -DUSE_FAST_PROTOCOL
|
||||
TinySender: -DUSE_FAST_PROTOCOL
|
||||
All: -DUSE_NO_SEND_PWM
|
||||
|
||||
- arduino-boards-fqbn: arduino:avr:uno|SEND_PWM_BY_TIMER
|
||||
sketches-exclude: IR2Keyboard,UnitTest
|
||||
sketches-exclude: UnitTest
|
||||
build-properties: # the flags were put in compiler.cpp.extra_flags
|
||||
IRremoteExtensionTest: -DRAW_BUFFER_LENGTH=100 -DIR_SEND_PIN=3 -DSEND_PWM_BY_TIMER
|
||||
ReceiveDemo: -DDECODE_ONKYO
|
||||
TinyReceiver: -DUSE_ONKYO_PROTOCOL
|
||||
TinySender: -DUSE_ONKYO_PROTOCOL
|
||||
All: -DSEND_PWM_BY_TIMER
|
||||
|
||||
- arduino-boards-fqbn: arduino:avr:uno|USE_OPEN_DRAIN_OUTPUT_FOR_SEND_PIN
|
||||
sketches-exclude: IR2Keyboard
|
||||
build-properties: # the flags were put in compiler.cpp.extra_flags
|
||||
IRremoteExtensionTest: -DRAW_BUFFER_LENGTH=100 -DIR_SEND_PIN=3 -DUSE_OPEN_DRAIN_OUTPUT_FOR_SEND_PIN
|
||||
SimpleSender: -DSEND_PWM_BY_TIMER
|
||||
TinyReceiver: -DENABLE_NEC2_REPEATS
|
||||
TinySender: -DENABLE_NEC2_REPEATS
|
||||
All: -DUSE_OPEN_DRAIN_OUTPUT_FOR_SEND_PIN
|
||||
|
||||
- arduino-boards-fqbn: arduino:avr:mega:cpu=atmega2560
|
||||
sketches-exclude: IR2Keyboard
|
||||
build-properties: # the flags were put in compiler.cpp.extra_flags
|
||||
IRremoteExtensionTest: -DRAW_BUFFER_LENGTH=700
|
||||
SimpleSender: -DSEND_PWM_BY_TIMER
|
||||
TinyReceiver: -DDISABLE_PARITY_CHECKS
|
||||
TinySender: -DDISABLE_PARITY_CHECKS
|
||||
|
||||
- arduino-boards-fqbn: arduino:avr:leonardo
|
||||
build-properties: # the flags were put in compiler.cpp.extra_flags
|
||||
IRremoteExtensionTest: -DRAW_BUFFER_LENGTH=100
|
||||
TinyReceiver: -DNO_LED_FEEDBACK_CODE
|
||||
TinySender: -DNO_LED_FEEDBACK_CODE
|
||||
# sketches-exclude: ReceiveAndSend # Not enough RAM for default RAW_BUFFER_LENGTH
|
||||
|
||||
- arduino-boards-fqbn: arduino:megaavr:nona4809:mode=off
|
||||
sketches-exclude: MinimalReceiver,IRDispatcherDemo
|
||||
sketches-exclude: TinyReceiver,IRDispatcherDemo
|
||||
build-properties: # the flags were put in compiler.cpp.extra_flags
|
||||
IRremoteExtensionTest: -DRAW_BUFFER_LENGTH=100
|
||||
SimpleSender: -DSEND_PWM_BY_TIMER
|
||||
TinyReceiver: -DUSE_ONKYO_PROTOCOL -DENABLE_NEC2_REPEATS -DNO_LED_FEEDBACK_CODE -DUSE_CALLBACK_FOR_TINY_RECEIVER
|
||||
TinySender: -DUSE_ONKYO_PROTOCOL -DENABLE_NEC2_REPEATS -DNO_LED_FEEDBACK_CODE
|
||||
|
||||
- arduino-boards-fqbn: arduino:samd:arduino_zero_native
|
||||
sketches-exclude: TinyReceiver,IRDispatcherDemo
|
||||
build-properties: # the flags were put in compiler.cpp.extra_flags
|
||||
IRremoteExtensionTest: -DRAW_BUFFER_LENGTH=100
|
||||
|
||||
- arduino-boards-fqbn: arduino:samd:arduino_zero_native
|
||||
sketches-exclude: MinimalReceiver,IRDispatcherDemo
|
||||
- arduino-boards-fqbn: arduino:renesas_uno:unor4wifi
|
||||
sketches-exclude: TinyReceiver,IRDispatcherDemo
|
||||
build-properties: # the flags were put in compiler.cpp.extra_flags
|
||||
IRremoteExtensionTest: -DRAW_BUFFER_LENGTH=100
|
||||
IRremoteExtensionTest: -DRAW_BUFFER_LENGTH=700
|
||||
|
||||
- arduino-boards-fqbn: adafruit:samd:adafruit_metro_m4:cache=on,speed=120,opt=small,maxqspi=50,usbstack=arduino,debug=off
|
||||
platform-url: https://adafruit.github.io/arduino-board-index/package_adafruit_index.json
|
||||
sketches-exclude: MinimalReceiver,IRDispatcherDemo
|
||||
sketches-exclude: TinyReceiver,IRDispatcherDemo
|
||||
build-properties: # the flags were put in compiler.cpp.extra_flags
|
||||
IRremoteExtensionTest: -DRAW_BUFFER_LENGTH=100
|
||||
|
||||
- arduino-boards-fqbn: arduino:mbed:nano33ble
|
||||
build-properties: # the flags were put in compiler.cpp.extra_flags
|
||||
IRremoteExtensionTest: -DRAW_BUFFER_LENGTH=100
|
||||
SimpleSender: -DSEND_PWM_BY_TIMER
|
||||
|
||||
#
|
||||
# RP2040
|
||||
#
|
||||
- arduino-boards-fqbn: arduino:mbed_rp2040:pico
|
||||
build-properties: # the flags were put in compiler.cpp.extra_flags
|
||||
IRremoteExtensionTest: -DRAW_BUFFER_LENGTH=100
|
||||
SimpleSender: -DSEND_PWM_BY_TIMER
|
||||
|
||||
- arduino-boards-fqbn: rp2040:rp2040:arduino_nano_connect
|
||||
platform-url: https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json
|
||||
build-properties: # the flags were put in compiler.cpp.extra_flags
|
||||
IRremoteExtensionTest: -DRAW_BUFFER_LENGTH=100 -DSEND_PWM_BY_TIMER
|
||||
SimpleSender: -DSEND_PWM_BY_TIMER
|
||||
All: -DRAW_BUFFER_LENGTH=700
|
||||
|
||||
- arduino-boards-fqbn: megaTinyCore:megaavr:atxy4:chip=1604,clock=16internal
|
||||
platform-url: http://drazzy.com/package_drazzy.com_index.json
|
||||
build-properties: # the flags were put in compiler.cpp.extra_flags
|
||||
IRremoteExtensionTest: -DRAW_BUFFER_LENGTH=100
|
||||
#
|
||||
# megaTinyCore
|
||||
#
|
||||
# https://github.com/SpenceKonde/megaTinyCore/issues/935
|
||||
# - arduino-boards-fqbn: megaTinyCore:megaavr:atxy4:chip=1604,clock=16internal
|
||||
# arduino-platform: megaTinyCore:megaavr
|
||||
# platform-url: http://drazzy.com/package_drazzy.com_index.json
|
||||
# sketches-exclude: AllProtocolsOnLCD
|
||||
# build-properties: # the flags were put in compiler.cpp.extra_flags
|
||||
# IRremoteExtensionTest: -DRAW_BUFFER_LENGTH=100
|
||||
|
||||
- arduino-boards-fqbn: megaTinyCore:megaavr:atxy7:chip=3217,clock=16internal
|
||||
platform-url: http://drazzy.com/package_drazzy.com_index.json
|
||||
build-properties: # the flags were put in compiler.cpp.extra_flags
|
||||
IRremoteExtensionTest: -DRAW_BUFFER_LENGTH=100
|
||||
# https://github.com/SpenceKonde/megaTinyCore/issues/935
|
||||
# - arduino-boards-fqbn: megaTinyCore:megaavr:atxy7:chip=3217,clock=16internal
|
||||
# arduino-platform: megaTinyCore:megaavr
|
||||
# platform-url: http://drazzy.com/package_drazzy.com_index.json
|
||||
# sketches-exclude: AllProtocolsOnLCD
|
||||
# build-properties: # the flags were put in compiler.cpp.extra_flags
|
||||
# IRremoteExtensionTest: -DRAW_BUFFER_LENGTH=100
|
||||
|
||||
- arduino-boards-fqbn: digistump:avr:digispark-tiny:clock=clock16
|
||||
platform-url: https://raw.githubusercontent.com/ArminJo/DigistumpArduino/master/package_digistump_index.json
|
||||
required-libraries: ATtinySerialOut
|
||||
sketch-names: MinimalReceiver.ino,IRremoteInfo.ino,SimpleReceiver.ino,ControlRelay.ino,SimpleSender.ino,SendDemo.ino,SendRawDemo.ino,SendAndReceive.ino
|
||||
#
|
||||
# ATTinyCore
|
||||
#
|
||||
# - arduino-boards-fqbn: ATTinyCore:avr:attinyx5micr:LTO=enable,sketchclock=16pll
|
||||
# platform-url: http://drazzy.com/package_drazzy.com_index.json
|
||||
# required-libraries: ATtinySerialOut
|
||||
# sketch-names: TinyReceiver.ino,IRremoteInfo.ino,SimpleReceiver.ino,ReceiveDemo.ino,ControlRelay.ino,SimpleSender.ino,SendDemo.ino,SendRawDemo.ino,SendAndReceive.ino
|
||||
# build-properties: # the flags were put in compiler.cpp.extra_flags
|
||||
# SimpleSender: -DSEND_PWM_BY_TIMER
|
||||
|
||||
- arduino-boards-fqbn: ATTinyCore:avr:attinyx5micr:LTO=enable,sketchclock=16pll
|
||||
platform-url: http://drazzy.com/package_drazzy.com_index.json
|
||||
required-libraries: ATtinySerialOut
|
||||
sketch-names: MinimalReceiver.ino,IRremoteInfo.ino,SimpleReceiver.ino,ReceiveDemo.ino,ControlRelay.ino,SimpleSender.ino,SendDemo.ino,SendRawDemo.ino,SendAndReceive.ino
|
||||
# - arduino-boards-fqbn: ATTinyCore:avr:attinyx7micr:LTO=enable,sketchclock=16external,pinmapping=new,millis=enabled
|
||||
# platform-url: http://drazzy.com/package_drazzy.com_index.json
|
||||
# required-libraries: ATtinySerialOut
|
||||
# sketch-names: TinyReceiver.ino,IRremoteInfo.ino,SimpleReceiver.ino,ReceiveDemo.ino,ControlRelay.ino,SimpleSender.ino,SendDemo.ino,SendRawDemo.ino,SendAndReceive.ino
|
||||
# build-properties: # the flags were put in compiler.cpp.extra_flags
|
||||
# SimpleSender: -DSEND_PWM_BY_TIMER
|
||||
|
||||
- arduino-boards-fqbn: ATTinyCore:avr:attinyx7micr:LTO=enable,sketchclock=16external,pinmapping=new,millis=enabled
|
||||
platform-url: http://drazzy.com/package_drazzy.com_index.json
|
||||
required-libraries: ATtinySerialOut
|
||||
sketch-names: MinimalReceiver.ino,IRremoteInfo.ino,SimpleReceiver.ino,ReceiveDemo.ino,ControlRelay.ino,SimpleSender.ino,SendDemo.ino,SendRawDemo.ino,SendAndReceive.ino
|
||||
|
||||
- arduino-boards-fqbn: ATTinyCore:avr:attinyx8micr:LTO=enable,sketchclock=16external,pinmapping=mhtiny,millis=enabled # ATtiny88 China clone board @16 MHz
|
||||
platform-url: http://drazzy.com/package_drazzy.com_index.json
|
||||
required-libraries: ATtinySerialOut
|
||||
sketch-names: MinimalReceiver.ino,IRremoteInfo.ino,SimpleReceiver.ino,ReceiveDemo.ino,ControlRelay.ino,SimpleSender.ino,SendDemo.ino,SendRawDemo.ino,SendAndReceive.ino
|
||||
# - arduino-boards-fqbn: ATTinyCore:avr:attinyx8micr:LTO=enable,sketchclock=16external,pinmapping=mhtiny,millis=enabled # ATtiny88 China clone board @16 MHz
|
||||
# platform-url: http://drazzy.com/package_drazzy.com_index.json
|
||||
# required-libraries: ATtinySerialOut
|
||||
# sketch-names: TinyReceiver.ino,IRremoteInfo.ino,SimpleReceiver.ino,ReceiveDemo.ino,ControlRelay.ino,SimpleSender.ino,SendDemo.ino,SendRawDemo.ino,SendAndReceive.ino
|
||||
# build-properties: # the flags were put in compiler.cpp.extra_flags
|
||||
# SimpleSender: -DSEND_PWM_BY_TIMER
|
||||
|
||||
#
|
||||
# MegaCore
|
||||
#
|
||||
- arduino-boards-fqbn: MegaCore:avr:128:bootloader=no_bootloader,eeprom=keep,BOD=2v7,LTO=Os_flto,clock=8MHz_internal
|
||||
platform-url: https://mcudude.github.io/MegaCore/package_MCUdude_MegaCore_index.json
|
||||
arduino-platform: arduino:avr,MegaCore:avr # gcc is taken from arduino:avr
|
||||
build-properties: # the flags were put in compiler.cpp.extra_flags
|
||||
IRremoteExtensionTest: -DRAW_BUFFER_LENGTH=300
|
||||
SimpleSender: -DSEND_PWM_BY_TIMER
|
||||
All: -DRAW_BUFFER_LENGTH=700
|
||||
|
||||
#
|
||||
# ESP
|
||||
#
|
||||
- arduino-boards-fqbn: esp8266:esp8266:d1_mini:eesz=4M3M,xtal=80
|
||||
platform-url: https://arduino.esp8266.com/stable/package_esp8266com_index.json
|
||||
sketches-exclude: MinimalReceiver
|
||||
sketches-exclude: TinyReceiver
|
||||
build-properties: # the flags were put in compiler.cpp.extra_flags
|
||||
IRremoteExtensionTest: -DRAW_BUFFER_LENGTH=200
|
||||
All: -DRAW_BUFFER_LENGTH=300
|
||||
|
||||
- arduino-boards-fqbn: esp32:esp32:featheresp32:FlashFreq=80
|
||||
platform-url: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
|
||||
sketches-exclude: MinimalReceiver # undefined reference to `TwoWire::onReceive(void (*)(int))'
|
||||
build-properties: # the flags were put in compiler.cpp.extra_flags
|
||||
IRremoteExtensionTest: -DRAW_BUFFER_LENGTH=500
|
||||
All: -DRAW_BUFFER_LENGTH=300
|
||||
arduino-platform: esp32:esp32@2.0.17 # latest 2.x version of 5/2024
|
||||
sketches-exclude: TinyReceiver # undefined reference to `TwoWire::onReceive(void (*)(int))'
|
||||
build-properties: # the flags were put in compiler.cpp.extra_flags. SEND_PWM_BY_TIMER is always enabled!
|
||||
IRremoteExtensionTest: -DRAW_BUFFER_LENGTH=500 -Wno-error=maybe-uninitialized
|
||||
All: -DRAW_BUFFER_LENGTH=300 -Wno-error=maybe-uninitialized # https://github.com/espressif/arduino-esp32/issues/7024
|
||||
|
||||
- arduino-boards-fqbn: esp32:esp32:esp32c3
|
||||
platform-url: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
|
||||
arduino-platform: esp32:esp32@2.0.17 # latest 2.x version of 5/2024
|
||||
sketches-exclude: TinyReceiver # undefined reference to `TwoWire::onReceive(void (*)(int))'
|
||||
build-properties: # the flags were put in compiler.cpp.extra_flags. SEND_PWM_BY_TIMER is always enabled!
|
||||
IRremoteExtensionTest: -DRAW_BUFFER_LENGTH=500 -Wno-error=maybe-uninitialized
|
||||
All: -DRAW_BUFFER_LENGTH=300 -Wno-error=maybe-uninitialized # https://github.com/espressif/arduino-esp32/issues/7024
|
||||
|
||||
#
|
||||
# STM
|
||||
#
|
||||
- arduino-boards-fqbn: STMicroelectronics:stm32:GenF1:pnum=BLUEPILL_F103C8 # ST version
|
||||
platform-url: https://raw.githubusercontent.com/stm32duino/BoardManagerFiles/main/package_stmicroelectronics_index.json
|
||||
sketches-exclude: MinimalReceiver
|
||||
sketches-exclude: TinyReceiver
|
||||
build-properties: # the flags were put in compiler.cpp.extra_flags
|
||||
IRremoteExtensionTest: -DRAW_BUFFER_LENGTH=700
|
||||
All: -DRAW_BUFFER_LENGTH=300
|
||||
|
||||
- arduino-boards-fqbn: STMicroelectronics:stm32:GenL0:pnum=THUNDERPACK_L072 # ST version
|
||||
platform-url: https://raw.githubusercontent.com/stm32duino/BoardManagerFiles/main/package_stmicroelectronics_index.json
|
||||
sketches-exclude: MinimalReceiver,IRDispatcherDemo
|
||||
sketches-exclude: TinyReceiver,IRDispatcherDemo
|
||||
build-properties: # the flags were put in compiler.cpp.extra_flags
|
||||
IRremoteExtensionTest: -DRAW_BUFFER_LENGTH=700
|
||||
All: -DRAW_BUFFER_LENGTH=300
|
||||
|
||||
- arduino-boards-fqbn: stm32duino:STM32F1:genericSTM32F103C # Roger Clark version
|
||||
platform-url: http://dan.drown.org/stm32duino/package_STM32duino_index.json
|
||||
sketches-exclude: MinimalReceiver
|
||||
sketches-exclude: TinyReceiver
|
||||
build-properties: # the flags were put in compiler.cpp.extra_flags
|
||||
IRremoteExtensionTest: -DRAW_BUFFER_LENGTH=700
|
||||
All: -DRAW_BUFFER_LENGTH=300
|
||||
|
||||
#
|
||||
# Others
|
||||
#
|
||||
- arduino-boards-fqbn: SparkFun:avr:promicro
|
||||
arduino-platform: arduino:avr,SparkFun:avr
|
||||
platform-url: https://raw.githubusercontent.com/sparkfun/Arduino_Boards/master/IDE_Board_Manager/package_sparkfun_index.json # Arduino URL is not required here
|
||||
build-properties: # the flags were put in compiler.cpp.extra_flags
|
||||
build-properties: # the flags were put in compiler.cpp.extra_flags. SEND_PWM_BY_TIMER is always enabled!
|
||||
IRremoteExtensionTest: -DRAW_BUFFER_LENGTH=700
|
||||
All: -DRAW_BUFFER_LENGTH=300
|
||||
|
||||
- arduino-boards-fqbn: sandeepmistry:nRF5:BBCmicrobit
|
||||
platform-url: https://sandeepmistry.github.io/arduino-nRF5/package_nRF5_boards_index.json
|
||||
sketches-exclude: IRDispatcherDemo,MicroGirs,MinimalReceiver
|
||||
sketches-exclude: IRDispatcherDemo,MicroGirs,TinyReceiver
|
||||
build-properties: # the flags were put in compiler.cpp.extra_flags
|
||||
IRremoteExtensionTest: -DRAW_BUFFER_LENGTH=700
|
||||
All: -DRAW_BUFFER_LENGTH=300
|
||||
|
||||
# Do not cancel all jobs / architectures if one job fails
|
||||
fail-fast: false
|
||||
- arduino-boards-fqbn: Seeeduino:samd:seeed_XIAO_m0:usbstack=arduino,debug=off,sercom4=include
|
||||
platform-url: https://files.seeedstudio.com/arduino/package_seeeduino_boards_index.json
|
||||
sketches-exclude: AllProtocolsOnLCD,UnitTest,ReceiveAndSendDistanceWidth # No print(uint64_t,.) available
|
||||
build-properties: # the flags were put in compiler.cpp.extra_flags
|
||||
IRremoteExtensionTest: -DRAW_BUFFER_LENGTH=700
|
||||
All: -DRAW_BUFFER_LENGTH=300
|
||||
|
||||
# fail-fast: false # false -> do not cancel all jobs / architectures if one job fails
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
|
@ -248,3 +317,4 @@ jobs:
|
|||
sketch-names: ${{ matrix.sketch-names }}
|
||||
sketches-exclude: ${{ matrix.sketches-exclude }}
|
||||
build-properties: ${{ toJson(matrix.build-properties) }}
|
||||
cli-version: 0.33.0 # to avoid errors for ATTinyCore
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# PlatformIoPublish.yml
|
||||
# Github workflow script to publish a release to PlatformIo.
|
||||
#
|
||||
# Copyright (C) 2021-2022 Armin Joachimsmeyer
|
||||
# Copyright (C) 2021-2023 Armin Joachimsmeyer
|
||||
# https://github.com/ArminJo/Github-Actions
|
||||
#
|
||||
|
||||
|
@ -18,15 +18,20 @@ jobs:
|
|||
publish:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@master
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v1
|
||||
uses: actions/setup-python@master
|
||||
with:
|
||||
python-version: '3.x'
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install platformio
|
||||
|
||||
- name: Build and publish
|
||||
env:
|
||||
PLATFORMIO_AUTH_TOKEN: ${{ secrets.PLATFORMIO_TOKEN }}
|
||||
|
|
|
@ -10,12 +10,16 @@ If you want to contribute to this project:
|
|||
|
||||
## Guidelines
|
||||
The following are some guidelines to observe when creating discussions / PRs:
|
||||
- Be friendly; it is important that we can all enjoy a safe space as we are all working on the same project and **it is okay for people to have different ideas**.
|
||||
- Use reasonable titles; refrain from using overly long or capitalized titles as they are usually annoying and do little to encourage others to help :smile:.
|
||||
- Use the style; we use the original [C Style by Kerninghan / Ritchie](https://en.wikipedia.org/wiki/Indentation_style#K&R_style) in [variant: 1TBS (OTBS)](https://en.wikipedia.org/wiki/Indentation_style#Variant:_1TBS_(OTBS)).
|
||||
In short: 4 spaces indentation, no tabs, opening braces on the same line, braces are mandatory on all if/while/do, no hard line length limit.
|
||||
To beautify your code, you may use the online formatter [here](https://www.freecodeformat.com/c-format.php).
|
||||
- Cover **all** occurences of the problem / addition you address with your PR. Do not forget the documentation like it is done for existing code. Code changes without proper documentation will be rejected!
|
||||
#### Be friendly
|
||||
It is important that we can all enjoy a safe space as we are all working on the same project and **it is okay for people to have different ideas**.
|
||||
#### Use reasonable titles
|
||||
Refrain from using overly long or capitalized titles as they are usually annoying and do little to encourage others to help :smile:.
|
||||
#### Use the formatting style
|
||||
We use the original [C Style by Kerninghan / Ritchie](https://en.wikipedia.org/wiki/Indentation_style#K&R_style) in [variant: 1TBS (OTBS)](https://en.wikipedia.org/wiki/Indentation_style#Variant:_1TBS_(OTBS)).<br/>
|
||||
In short: 4 spaces indentation, no tabs, opening braces on the same line, braces are mandatory on all if/while/do, no hard line length limit.<br/>
|
||||
To beautify your code, you may use the online formatter [here](https://www.freecodeformat.com/c-format.php).
|
||||
#### Cover **all** occurences of the problem / addition you address with your PR
|
||||
Do not forget the documentation like it is done for existing code. Code changes without proper documentation will be rejected!
|
||||
|
||||
## Adding new protocols
|
||||
To add a new protocol is quite straightforward. Best is too look at the existing protocols to find a similar one and modify it.<br/>
|
||||
|
@ -25,7 +29,7 @@ The **durations** you receive are likely to be longer for marks and shorter for
|
|||
but this depends on the receiver circuit in use. Most protocols use multiples of one time-unit for marks and spaces like e.g. [NEC](https://github.com/Arduino-IRremote/Arduino-IRremote/blob/master/src/ir_NEC.hpp#L62). It's easy to be off-by-one with the last bit, since the last space is not recorded by IRremote.
|
||||
|
||||
Try to make use of the template functions `decodePulseDistanceData()` and `sendPulseDistanceData()`.
|
||||
If your protocol supports address and code fields, try to reflect this in your api like it is done in [`sendNEC(uint16_t aAddress, uint8_t aCommand, uint_fast8_t aNumberOfRepeats, bool aIsRepeat)`](https://github.com/Arduino-IRremote/Arduino-IRremote/blob/master/src/ir_NEC.hpp#L96)
|
||||
If your protocol supports address and code fields, try to reflect this in your api like it is done in [`sendNEC(uint16_t aAddress, uint8_t aCommand, int_fast8_t aNumberOfRepeats, bool aIsRepeat)`](https://github.com/Arduino-IRremote/Arduino-IRremote/blob/master/src/ir_NEC.hpp#L96)
|
||||
and [`decodeNEC()`](https://github.com/Arduino-IRremote/Arduino-IRremote/blob/master/src/ir_NEC.hpp#L194).<br/>
|
||||
|
||||
### Integration
|
||||
|
|
|
@ -26,5 +26,10 @@ These are the active contributors of this project that you may contact if there
|
|||
- [Jim-2249](https://github.com/Jim-2249)
|
||||
- [pmalasp](https://github.com/pmalasp )
|
||||
- [ElectronicsArchiver}(https://github.com/ElectronicsArchiver) improving documentation
|
||||
- [Stephen Humphries](https://github.com/sjahu)Fix for: Prevent long delay caused by overflow when frame duration < repeat period #1028
|
||||
- [Daniel Wallner](https://github.com/danielwallner) Bang & Olufsen protocol.
|
||||
- [slott](https://stackoverflow.com/users/11680056/sklott) Seeduino print(unsigned long long...) support.
|
||||
- [Joe Ostrander](https://github.com/joeostrander) Added support for attiny1614.
|
||||
- [Buzzerb](https://github.com/Buzzerb) Added Extended NEC protocol to TinyIR and making it more consistent.
|
||||
|
||||
Note: Please let [ArminJo](https://github.com/ArminJo) know if you have been missed.
|
||||
|
|
2
Doxyfile
2
Doxyfile
|
@ -58,7 +58,7 @@ PROJECT_LOGO =
|
|||
# entered, it will be relative to the location where doxygen was started. If
|
||||
# left blank the current directory will be used.
|
||||
|
||||
OUTPUT_DIRECTORY = ..\Arduino-IRremote_gh-pages
|
||||
OUTPUT_DIRECTORY = E:\WORKSPACE_ARDUINO\lib\Arduino-IRremote_gh-pages
|
||||
|
||||
# If the CREATE_SUBDIRS tag is set to YES then doxygen will create 4096 sub-
|
||||
# directories (in 2 levels) under the output directory of each output format and
|
||||
|
|
94
changelog.md
94
changelog.md
|
@ -2,6 +2,100 @@
|
|||
The latest version may not be released!
|
||||
See also the commit log at github: https://github.com/Arduino-IRremote/Arduino-IRremote/commits/master
|
||||
|
||||
# 4.3.2
|
||||
- Added sendSonyMSB(unsigned long data, int nbits) as a clone of sendSony(unsigned long data, int nbits) to be more consistent.
|
||||
- Added sendSamsungMSB(unsigned long data, int nbits) as a clone of sendSAMSUNG(unsigned long data, int nbits) to be more consistent.
|
||||
|
||||
# 4.3.1
|
||||
- Fixed overflow bug for rawlen > 254.
|
||||
- Removed deprecated sendPulseDistance... functions with parameter aSendStopBit.
|
||||
|
||||
# 4.3.0
|
||||
- Removed default value USE_DEFAULT_FEEDBACK_LED_PIN for last parameter of IRsend::begin(bool aEnableLEDFeedback, uint_fast8_t aFeedbackLEDPin).
|
||||
Therefore IrSender.begin(DISABLE_LED_FEEDBACK) will not longer work!
|
||||
- Added convenience function isIRReceiverAttachedForTinyReceiver().
|
||||
- Added Extended NEC Protocol macro to TinyIR by Buzzerb.
|
||||
- Fixed sendSamsung() / sendSamsungLG() bug.
|
||||
- Added functions stopTimer(), restartTimer() and restartTimerWithTicksToAdd().
|
||||
- Added rawlen and initialGap to IRData.
|
||||
- Added ReceiveAndSendHobToHood example.
|
||||
- Changed RECORD_GAP_MICROS default value from 5000 to 8000.
|
||||
|
||||
# 4.2.1
|
||||
- Fix wrong type of tEnableLEDFeedback in IRSend.hpp and IRReceive.hpp.
|
||||
- TinyReceiver 2.0
|
||||
- New TinyIRReceiverData which is filled with address, command and flags.
|
||||
- Removed parameters address, command and flags from callback handleReceivedTinyIRData() and printTinyReceiverResultMinimal().
|
||||
- Callback function now only enabled if USE_CALLBACK_FOR_TINY_RECEIVER is activated.
|
||||
- Fix changing IR_SEND_PIN dynamically for ESP32.
|
||||
- Fix wrong type of tEnableLEDFeedback.
|
||||
- Support for ESP32-C3.
|
||||
|
||||
# 4.2.0
|
||||
- The old decode function is renamed to decode_old(decode_results *aResults). decode (decode_results *aResults) is only available in IRremote.h and prints a message.
|
||||
- Added DECODE_ONKYO, to force 16 bit command and data decoding.
|
||||
- Enable Bang&Olufsen 455 kHz if SEND_PWM_BY_TIMER is defined.
|
||||
- Fixed bug: TinyReceiver throwing ISR not in IRAM on ESP8266.
|
||||
- Usage of ATTinyCore pin numbering scheme e.g. PIN_PB2.
|
||||
- Added ARDUINO_ARCH_NRF52 to support Seeed XIAO nRF52840 Sense.
|
||||
- First untested support of Uno R4.
|
||||
- Extraced version macros to IRVersion.h.
|
||||
|
||||
## 4.1.2
|
||||
- Workaround for ESP32 RTOS delay() timing bug influencing the mark() function.
|
||||
|
||||
## 4.1.1
|
||||
- SAMD51 use timer3 if timer5 not available.
|
||||
- Disabled #define LOCAL_DEBUG in IRReceive.hpp, which was accidently enabled at 4.1.0.
|
||||
|
||||
## 4.1.0
|
||||
- Fixed bug in printing durations > 64535 in printIRResultRawFormatted().
|
||||
- Narrowed constraints for RC5 RC6 number of bits.
|
||||
- Changed the first parameter of printTinyReceiverResultMinimal() to &Serial.
|
||||
- Removed 3 Serial prints for deprecation warnings to fix #1094.
|
||||
- Version 1.2.0 of TinyIR. Now FAST protocol with 40 ms period and shorter header space.
|
||||
- Removed field "bool hasStopBit" and parameter "bool aSendStopBit" from PulseDistanceWidthProtocolConstants structure and related functions.
|
||||
- Changed a lot of "unsigned int" types to "uint16_t" types.
|
||||
- Improved overflow handling.
|
||||
- Improved software PWM generation.
|
||||
- Added FAST protocol.
|
||||
- Improved handling of PULSE_DISTANCE + PULSE_WIDTH protocols.
|
||||
- New example ReceiveAndSendDistanceWidth.
|
||||
- Removed the automatic restarting of the receiver timer after sending with SEND_PWM_BY_TIMER enabled.
|
||||
- Split ISR into ISR and function IRPinChangeInterruptHandler().
|
||||
- Added functions addTicksToInternalTickCounter() and addMicrosToInternalTickCounter().
|
||||
|
||||
## 4.0.0
|
||||
- Added decoding of PulseDistanceWidth protocols and therefore changed function decodeDistance() to decodeDistanceWidth() and filename ir_DistanceProtocol.hpp to ir_DistanceWidthProtocol.hpp.
|
||||
- Removed static function printIRSendUsage(), but kept class function printIRSendUsage().
|
||||
- Changed type of decodedRawData and decodedRawDataArray which is now 64 bit for 32 bit platforms.
|
||||
- Added receiver callback functionality and registerReceiveCompleteCallback() function.
|
||||
- Introduced common structure PulseDistanceWidthProtocolConstants.
|
||||
- Where possible, changed all send and decode functions to use PulseDistanceWidthProtocolConstants.
|
||||
- Improved MSB/LSB handling
|
||||
- New convenience fuctions bitreverse32Bit() and bitreverseOneByte().
|
||||
- Improved Magiquest protocol.
|
||||
- Fix for #1028 - Prevent long delay caused by overflow when frame duration < repeat period - Thanks to Stephen Humphries!
|
||||
- Support for ATtiny816 - Thanks to elockman.
|
||||
- Added Bang&Olufsen protocol. #1030.
|
||||
- Third parameter of function "void begin(uint_fast8_t aSendPin, bool aEnableLEDFeedback, uint_fast8_t aFeedbackLEDPin)" is not optional anymore and this function is now only available if IR_SEND_PIN is not defined. #1033.
|
||||
- Fixed bug in sendSony() for command parameter > 0x7F;
|
||||
- Fixed bug with swapped LG2 header mark and space.
|
||||
- Disabled strict checks while decoding. They can be enabled by defining DECODE_STRICT_CHECKS.
|
||||
- Merged the 2 decode pulse width and distance functions.
|
||||
- Changed macro names _REPEAT_SPACE to _REPEAT_DISTANCE.
|
||||
- Improved TinyIRReceiver,added FAST protocol for it and added TinyIRSender.hpp and TinySender example, renamed TinyReceiver.h to TinyIR.h.
|
||||
- Added DISABLE_CODE_FOR_RECEIVER to save program memory and RAM if receiving functionality is not required.
|
||||
- Extracted protocol functions used by receive and send to IRProtocol.hpp.
|
||||
- Analyzed Denon code table and therefore changed Denon from MSB to LSB first.
|
||||
- Renamed sendRC6(aRawData...) to sendRC6Raw( aRawData...).
|
||||
- Support for seeduino which lacks the print(unsigned long long...) method. Thanks to sklott https://stackoverflow.com/users/11680056/sklott
|
||||
- Added support for attiny1614 by Joe Ostrander.
|
||||
- Fixed SEND_PWM_BY_TIMER for ATtiny167 thanks to freskpe.
|
||||
- Improved SHARP repeat decoding.
|
||||
- Replaced macros TIMER_EN/DISABLE_RECEIVE_INTR and EN/DISABLE_SEND_PWM_BY_TIMER by functions.
|
||||
- Added SAMSUNG48 protocol and sendSamsung48() function.
|
||||
|
||||
## 3.9.0
|
||||
- Improved documentation with the help of [ElectronicsArchiver}(https://github.com/ElectronicsArchiver).
|
||||
- Added NEC2 protocol.
|
||||
|
|
|
@ -1,145 +0,0 @@
|
|||
/*
|
||||
* ADCUtils.h
|
||||
*
|
||||
* Copyright (C) 2016-2022 Armin Joachimsmeyer
|
||||
* Email: armin.joachimsmeyer@gmail.com
|
||||
*
|
||||
* This file is part of Arduino-Utils https://github.com/ArminJo/Arduino-Utils.
|
||||
*
|
||||
* ArduinoUtils 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 _ADC_UTILS_H
|
||||
#define _ADC_UTILS_H
|
||||
|
||||
#if defined(__AVR__) && (!defined(__AVR_ATmega4809__))
|
||||
#include <Arduino.h>
|
||||
#if defined(ADATE)
|
||||
|
||||
// PRESCALE4 => 13 * 4 = 52 microseconds per ADC conversion at 1 MHz Clock => 19,2 kHz
|
||||
#define ADC_PRESCALE2 1 // 26 microseconds per ADC conversion at 1 MHz
|
||||
#define ADC_PRESCALE4 2 // 52 microseconds per ADC conversion at 1 MHz
|
||||
// PRESCALE8 => 13 * 8 = 104 microseconds per ADC sample at 1 MHz Clock => 9,6 kHz
|
||||
#define ADC_PRESCALE8 3 // 104 microseconds per ADC conversion at 1 MHz
|
||||
#define ADC_PRESCALE16 4 // 13/208 microseconds per ADC conversion at 16/1 MHz - degradations in linearity at 16 MHz
|
||||
#define ADC_PRESCALE32 5 // 26/416 microseconds per ADC conversion at 16/1 MHz - very good linearity at 16 MHz
|
||||
#define ADC_PRESCALE64 6 // 52 microseconds per ADC conversion at 16 MHz
|
||||
#define ADC_PRESCALE128 7 // 104 microseconds per ADC conversion at 16 MHz --- Arduino default
|
||||
|
||||
// definitions for 0.1 ms conversion time
|
||||
#if (F_CPU == 1000000)
|
||||
#define ADC_PRESCALE ADC_PRESCALE8
|
||||
#elif (F_CPU == 8000000)
|
||||
#define ADC_PRESCALE ADC_PRESCALE64
|
||||
#elif (F_CPU == 16000000)
|
||||
#define ADC_PRESCALE ADC_PRESCALE128
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Reference shift values are complicated for ATtinyX5 since we have the extra register bit REFS2
|
||||
* in ATTinyCore, this bit is handled programmatical and therefore the defines are different.
|
||||
* To keep my library small, I use the changed defines.
|
||||
* After including this file you can not call the ATTinyCore readAnalog functions reliable, if you specify references other than default!
|
||||
*/
|
||||
#if defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__)
|
||||
// defines are for ADCUtils.cpp, they can be used WITHOUT bit reordering
|
||||
#undef DEFAULT
|
||||
#undef EXTERNAL
|
||||
#undef INTERNAL1V1
|
||||
#undef INTERNAL
|
||||
#undef INTERNAL2V56
|
||||
#undef INTERNAL2V56_EXTCAP
|
||||
|
||||
#define DEFAULT 0
|
||||
#define EXTERNAL 4
|
||||
#define INTERNAL1V1 8
|
||||
#define INTERNAL INTERNAL1V1
|
||||
#define INTERNAL2V56 9
|
||||
#define INTERNAL2V56_EXTCAP 13
|
||||
|
||||
#define SHIFT_VALUE_FOR_REFERENCE REFS2
|
||||
#define MASK_FOR_ADC_REFERENCE (_BV(REFS0) | _BV(REFS1) | _BV(REFS2))
|
||||
#define MASK_FOR_ADC_CHANNELS (_BV(MUX0) | _BV(MUX1) | _BV(MUX2) | _BV(MUX3))
|
||||
#else // AVR_ATtiny85
|
||||
|
||||
#define SHIFT_VALUE_FOR_REFERENCE REFS0
|
||||
#define MASK_FOR_ADC_REFERENCE (_BV(REFS0) | _BV(REFS1))
|
||||
#define MASK_FOR_ADC_CHANNELS (_BV(MUX0) | _BV(MUX1) | _BV(MUX2) | _BV(MUX3))
|
||||
#endif
|
||||
|
||||
// Temperature channel definitions - 1 LSB / 1 degree Celsius
|
||||
#if defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__)
|
||||
#define ADC_TEMPERATURE_CHANNEL_MUX 15
|
||||
#define ADC_1_1_VOLT_CHANNEL_MUX 12
|
||||
#define ADC_GND_CHANNEL_MUX 13
|
||||
|
||||
#elif defined(__AVR_ATtiny87__) || defined(__AVR_ATtiny167__)
|
||||
#define ADC_ISCR_CHANNEL_MUX 3
|
||||
#define ADC_TEMPERATURE_CHANNEL_MUX 11
|
||||
#define ADC_1_1_VOLT_CHANNEL_MUX 12
|
||||
#define ADC_GND_CHANNEL_MUX 14
|
||||
#define ADC_VCC_4TH_CHANNEL_MUX 13
|
||||
|
||||
#elif defined(__AVR_ATmega328P__)
|
||||
#define ADC_TEMPERATURE_CHANNEL_MUX 8
|
||||
#define ADC_1_1_VOLT_CHANNEL_MUX 14
|
||||
#define ADC_GND_CHANNEL_MUX 15
|
||||
|
||||
#elif defined(__AVR_ATmega32U4__)
|
||||
#define ADC_TEMPERATURE_CHANNEL_MUX 0x27
|
||||
#define ADC_1_1_VOLT_CHANNEL_MUX 0x1E
|
||||
#define ADC_GND_CHANNEL_MUX 0x1F
|
||||
|
||||
#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) || defined(__AVR_ATmega644__) || defined(__AVR_ATmega644A__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644PA__)
|
||||
#define ADC_1_1_VOLT_CHANNEL_MUX 0x1E
|
||||
#define ADC_GND_CHANNEL_MUX 0x1F
|
||||
#define INTERNAL INTERNAL1V1
|
||||
|
||||
#else
|
||||
#error "No temperature channel definitions specified for this AVR CPU"
|
||||
#endif
|
||||
|
||||
uint16_t readADCChannel(uint8_t aChannelNumber);
|
||||
uint16_t readADCChannelWithReference(uint8_t aChannelNumber, uint8_t aReference);
|
||||
uint16_t waitAndReadADCChannelWithReference(uint8_t aChannelNumber, uint8_t aReference);
|
||||
uint16_t waitAndReadADCChannelWithReferenceAndRestoreADMUXAndReference(uint8_t aChannelNumber, uint8_t aReference);
|
||||
uint16_t readADCChannelWithOversample(uint8_t aChannelNumber, uint8_t aOversampleExponent);
|
||||
void setADCMultiplexerAndReferenceForNextConversion(uint8_t aChannelNumber, uint8_t aReference);
|
||||
uint16_t readADCChannelWithReferenceOversample(uint8_t aChannelNumber, uint8_t aReference, uint8_t aOversampleExponent);
|
||||
uint16_t readADCChannelWithReferenceOversampleFast(uint8_t aChannelNumber, uint8_t aReference, uint8_t aOversampleExponent);
|
||||
uint16_t readADCChannelWithReferenceMultiSamples(uint8_t aChannelNumber, uint8_t aReference, uint8_t aNumberOfSamples);
|
||||
uint16_t readADCChannelWithReferenceMax(uint8_t aChannelNumber, uint8_t aReference, uint16_t aNumberOfSamples);
|
||||
uint16_t readADCChannelWithReferenceMaxMicros(uint8_t aChannelNumber, uint8_t aReference, uint16_t aMicrosecondsToAquire);
|
||||
uint16_t readUntil4ConsecutiveValuesAreEqual(uint8_t aChannelNumber, uint8_t aDelay, uint8_t aAllowedDifference,
|
||||
uint8_t aMaxRetries);
|
||||
|
||||
uint8_t checkAndWaitForReferenceAndChannelToSwitch(uint8_t aChannelNumber, uint8_t aReference);
|
||||
|
||||
float getVCCVoltageSimple(void);
|
||||
uint16_t getVCCVoltageMillivoltSimple(void);
|
||||
float getTemperatureSimple(void);
|
||||
float getVCCVoltage(void);
|
||||
uint16_t getVCCVoltageMillivolt(void);
|
||||
uint16_t getVCCVoltageReadingFor1_1VoltReference(void);
|
||||
uint16_t printVCCVoltageMillivolt(Print *aSerial);
|
||||
void printVCCVoltageMillivolt(Print *aSerial, uint16_t aVCCVoltageMillivolt);
|
||||
uint16_t getVoltageMillivolt(uint16_t aVCCVoltageMillivolt, uint8_t aADCChannelForVoltageMeasurement);
|
||||
uint16_t getVoltageMillivolt(uint8_t aADCChannelForVoltageMeasurement);
|
||||
uint16_t getVoltageMillivoltWith_1_1VoltReference(uint8_t aADCChannelForVoltageMeasurement);
|
||||
float getTemperature(void);
|
||||
|
||||
#endif // defined(ADATE)
|
||||
#endif // defined(__AVR__)
|
||||
#endif // _ADC_UTILS_H
|
|
@ -1,457 +0,0 @@
|
|||
/*
|
||||
* ADCUtils.hpp
|
||||
*
|
||||
* ADC utility functions. Conversion time is defined as 0.104 milliseconds for 16 MHz Arduinos in ADCUtils.h.
|
||||
*
|
||||
* Copyright (C) 2016-2022 Armin Joachimsmeyer
|
||||
* Email: armin.joachimsmeyer@gmail.com
|
||||
*
|
||||
* This file is part of Arduino-Utils https://github.com/ArminJo/Arduino-Utils.
|
||||
*
|
||||
* ArduinoUtils 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 _ADC_UTILS_HPP
|
||||
#define _ADC_UTILS_HPP
|
||||
|
||||
#include "ADCUtils.h"
|
||||
#if defined(__AVR__) && defined(ADCSRA) && defined(ADATE)
|
||||
|
||||
/*
|
||||
* By replacing this value with the voltage you measured a the AREF pin after a conversion
|
||||
* with INTERNAL you can calibrate your ADC readout. For my Nanos I measured e.g. 1060 mV and 1093 mV.
|
||||
*/
|
||||
#if !defined(ADC_INTERNAL_REFERENCE_MILLIVOLT)
|
||||
#define ADC_INTERNAL_REFERENCE_MILLIVOLT 1100L // Value measured at the AREF pin. If value > real AREF voltage, measured values are > real values
|
||||
#endif
|
||||
|
||||
// Union to speed up the combination of low and high bytes to a word
|
||||
// it is not optimal since the compiler still generates 2 unnecessary moves
|
||||
// but using -- value = (high << 8) | low -- gives 5 unnecessary instructions
|
||||
union WordUnionForADCUtils {
|
||||
struct {
|
||||
uint8_t LowByte;
|
||||
uint8_t HighByte;
|
||||
} UByte;
|
||||
uint16_t UWord;
|
||||
int16_t Word;
|
||||
uint8_t *BytePointer;
|
||||
};
|
||||
|
||||
/*
|
||||
* Conversion time is defined as 0.104 milliseconds by ADC_PRESCALE in ADCUtils.h.
|
||||
*/
|
||||
uint16_t readADCChannel(uint8_t aChannelNumber) {
|
||||
WordUnionForADCUtils tUValue;
|
||||
ADMUX = aChannelNumber | (DEFAULT << SHIFT_VALUE_FOR_REFERENCE);
|
||||
|
||||
// ADCSRB = 0; // Only active if ADATE is set to 1.
|
||||
// ADSC-StartConversion ADIF-Reset Interrupt Flag - NOT free running mode
|
||||
ADCSRA = (_BV(ADEN) | _BV(ADSC) | _BV(ADIF) | ADC_PRESCALE);
|
||||
|
||||
// wait for single conversion to finish
|
||||
loop_until_bit_is_clear(ADCSRA, ADSC);
|
||||
|
||||
// Get value
|
||||
tUValue.UByte.LowByte = ADCL;
|
||||
tUValue.UByte.HighByte = ADCH;
|
||||
return tUValue.UWord;
|
||||
// return ADCL | (ADCH <<8); // needs 4 bytes more
|
||||
}
|
||||
|
||||
/*
|
||||
* Conversion time is defined as 0.104 milliseconds by ADC_PRESCALE in ADCUtils.h.
|
||||
*/
|
||||
uint16_t readADCChannelWithReference(uint8_t aChannelNumber, uint8_t aReference) {
|
||||
WordUnionForADCUtils tUValue;
|
||||
ADMUX = aChannelNumber | (aReference << SHIFT_VALUE_FOR_REFERENCE);
|
||||
|
||||
// ADCSRB = 0; // Only active if ADATE is set to 1.
|
||||
// ADSC-StartConversion ADIF-Reset Interrupt Flag - NOT free running mode
|
||||
ADCSRA = (_BV(ADEN) | _BV(ADSC) | _BV(ADIF) | ADC_PRESCALE);
|
||||
|
||||
// wait for single conversion to finish
|
||||
loop_until_bit_is_clear(ADCSRA, ADSC);
|
||||
|
||||
// Get value
|
||||
tUValue.UByte.LowByte = ADCL;
|
||||
tUValue.UByte.HighByte = ADCH;
|
||||
return tUValue.UWord;
|
||||
}
|
||||
|
||||
/*
|
||||
* Conversion time is defined as 0.104 milliseconds by ADC_PRESCALE in ADCUtils.h.
|
||||
* Does NOT restore ADMUX after reading
|
||||
*/
|
||||
uint16_t waitAndReadADCChannelWithReference(uint8_t aChannelNumber, uint8_t aReference) {
|
||||
checkAndWaitForReferenceAndChannelToSwitch(aChannelNumber, aReference);
|
||||
return readADCChannelWithReference(aChannelNumber, aReference);
|
||||
}
|
||||
|
||||
/*
|
||||
* Conversion time is defined as 0.104 milliseconds by ADC_PRESCALE in ADCUtils.h.
|
||||
* Restores ADMUX after reading
|
||||
*/
|
||||
uint16_t waitAndReadADCChannelWithReferenceAndRestoreADMUXAndReference(uint8_t aChannelNumber, uint8_t aReference) {
|
||||
uint8_t tOldADMUX = checkAndWaitForReferenceAndChannelToSwitch(aChannelNumber, aReference);
|
||||
uint16_t tResult = readADCChannelWithReference(aChannelNumber, aReference);
|
||||
checkAndWaitForReferenceAndChannelToSwitch(tOldADMUX & MASK_FOR_ADC_CHANNELS, tOldADMUX >> SHIFT_VALUE_FOR_REFERENCE);
|
||||
return tResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* To prepare reference and ADMUX for next measurement
|
||||
*/
|
||||
void setADCMultiplexerAndReferenceForNextConversion(uint8_t aChannelNumber, uint8_t aReference) {
|
||||
ADMUX = aChannelNumber | (aReference << SHIFT_VALUE_FOR_REFERENCE);
|
||||
}
|
||||
|
||||
/*
|
||||
* @return original ADMUX register content for optional later restoring values
|
||||
* All experimental values are acquired by using the ADCSwitchingTest example from this library
|
||||
*/
|
||||
uint8_t checkAndWaitForReferenceAndChannelToSwitch(uint8_t aChannelNumber, uint8_t aReference) {
|
||||
uint8_t tOldADMUX = ADMUX;
|
||||
/*
|
||||
* Must wait >= 7 us if reference has to be switched from 1.1 volt/INTERNAL to VCC/DEFAULT (seen on oscilloscope)
|
||||
* This is done after the 2 ADC clock cycles required for Sample & Hold :-)
|
||||
*
|
||||
* Must wait >= 7600 us for Nano board >= 6200 for Uno board if reference has to be switched from VCC/DEFAULT to 1.1 volt/INTERNAL
|
||||
* Must wait >= 200 us if channel has to be switched to 1.1 volt internal channel if S&H was at 5 Volt
|
||||
*/
|
||||
uint8_t tNewReference = (aReference << SHIFT_VALUE_FOR_REFERENCE);
|
||||
ADMUX = aChannelNumber | tNewReference;
|
||||
#if defined(INTERNAL2V56)
|
||||
if ((tOldADMUX & MASK_FOR_ADC_REFERENCE) != tNewReference && (aReference == INTERNAL || aReference == INTERNAL2V56)) {
|
||||
#else
|
||||
if ((tOldADMUX & MASK_FOR_ADC_REFERENCE) != tNewReference && aReference == INTERNAL) {
|
||||
#endif
|
||||
/*
|
||||
* Switch reference from DEFAULT to INTERNAL
|
||||
*/
|
||||
delayMicroseconds(8000); // experimental value is >= 7600 us for Nano board and 6200 for UNO board
|
||||
} else if ((tOldADMUX & 0x0F) != aChannelNumber) {
|
||||
if (aChannelNumber == ADC_1_1_VOLT_CHANNEL_MUX) {
|
||||
/*
|
||||
* Internal 1.1 Volt channel requires <= 200 us for Nano board
|
||||
*/
|
||||
delayMicroseconds(350); // 350 was ok and 300 was too less for UltimateBatteryTester - result was 226 instead of 225
|
||||
} else {
|
||||
/*
|
||||
* 100 kOhm requires < 100 us, 1 MOhm requires 120 us S&H switching time
|
||||
*/
|
||||
delayMicroseconds(120); // experimental value is <= 1100 us for Nano board
|
||||
}
|
||||
}
|
||||
return tOldADMUX;
|
||||
}
|
||||
|
||||
/*
|
||||
* Oversample and multiple samples only makes sense if you expect a noisy input signal
|
||||
* It does NOT increase the precision of the measurement, since the ADC has insignificant noise
|
||||
*/
|
||||
uint16_t readADCChannelWithOversample(uint8_t aChannelNumber, uint8_t aOversampleExponent) {
|
||||
return readADCChannelWithReferenceOversample(aChannelNumber, DEFAULT, aOversampleExponent);
|
||||
}
|
||||
|
||||
/*
|
||||
* Conversion time is defined as 0.104 milliseconds by ADC_PRESCALE in ADCUtils.h.
|
||||
*/
|
||||
uint16_t readADCChannelWithReferenceOversample(uint8_t aChannelNumber, uint8_t aReference, uint8_t aOversampleExponent) {
|
||||
uint16_t tSumValue = 0;
|
||||
ADMUX = aChannelNumber | (aReference << SHIFT_VALUE_FOR_REFERENCE);
|
||||
|
||||
ADCSRB = 0; // Free running mode. Only active if ADATE is set to 1.
|
||||
// ADSC-StartConversion ADATE-AutoTriggerEnable ADIF-Reset Interrupt Flag
|
||||
ADCSRA = (_BV(ADEN) | _BV(ADSC) | _BV(ADATE) | _BV(ADIF) | ADC_PRESCALE);
|
||||
|
||||
uint8_t tCount = _BV(aOversampleExponent);
|
||||
for (uint8_t i = 0; i < tCount; i++) {
|
||||
/*
|
||||
* wait for free running conversion to finish.
|
||||
* Do not wait for ADSC here, since ADSC is only low for 1 ADC Clock cycle on free running conversion.
|
||||
*/
|
||||
loop_until_bit_is_set(ADCSRA, ADIF);
|
||||
|
||||
ADCSRA |= _BV(ADIF); // clear bit to enable recognizing next conversion has finished
|
||||
// Add value
|
||||
tSumValue += ADCL | (ADCH << 8); // using WordUnionForADCUtils does not save space here
|
||||
// tSumValue += (ADCH << 8) | ADCL; // this does NOT work!
|
||||
}
|
||||
ADCSRA &= ~_BV(ADATE); // Disable auto-triggering (free running mode)
|
||||
// return rounded value
|
||||
return ((tSumValue + (tCount >> 1)) >> aOversampleExponent);
|
||||
}
|
||||
|
||||
/*
|
||||
* Use ADC_PRESCALE32 which gives 26 us conversion time and good linearity for 16 MHz Arduino
|
||||
*/
|
||||
uint16_t readADCChannelWithReferenceOversampleFast(uint8_t aChannelNumber, uint8_t aReference, uint8_t aOversampleExponent) {
|
||||
uint16_t tSumValue = 0;
|
||||
ADMUX = aChannelNumber | (aReference << SHIFT_VALUE_FOR_REFERENCE);
|
||||
|
||||
ADCSRB = 0; // Free running mode. Only active if ADATE is set to 1.
|
||||
// ADSC-StartConversion ADATE-AutoTriggerEnable ADIF-Reset Interrupt Flag
|
||||
ADCSRA = (_BV(ADEN) | _BV(ADSC) | _BV(ADATE) | _BV(ADIF) | ADC_PRESCALE32);
|
||||
|
||||
uint8_t tCount = _BV(aOversampleExponent);
|
||||
for (uint8_t i = 0; i < tCount; i++) {
|
||||
/*
|
||||
* wait for free running conversion to finish.
|
||||
* Do not wait for ADSC here, since ADSC is only low for 1 ADC Clock cycle on free running conversion.
|
||||
*/
|
||||
loop_until_bit_is_set(ADCSRA, ADIF);
|
||||
|
||||
ADCSRA |= _BV(ADIF); // clear bit to enable recognizing next conversion has finished
|
||||
// Add value
|
||||
tSumValue += ADCL | (ADCH << 8); // using WordUnionForADCUtils does not save space here
|
||||
// tSumValue += (ADCH << 8) | ADCL; // this does NOT work!
|
||||
}
|
||||
ADCSRA &= ~_BV(ADATE); // Disable auto-triggering (free running mode)
|
||||
return ((tSumValue + (tCount >> 1)) >> aOversampleExponent);
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns sum of all sample values
|
||||
* Conversion time is defined as 0.104 milliseconds for 16 MHz Arduino by ADC_PRESCALE in ADCUtils.h.
|
||||
*/
|
||||
uint16_t readADCChannelWithReferenceMultiSamples(uint8_t aChannelNumber, uint8_t aReference, uint8_t aNumberOfSamples) {
|
||||
uint16_t tSumValue = 0;
|
||||
ADMUX = aChannelNumber | (aReference << SHIFT_VALUE_FOR_REFERENCE);
|
||||
|
||||
ADCSRB = 0; // Free running mode. Only active if ADATE is set to 1.
|
||||
// ADSC-StartConversion ADATE-AutoTriggerEnable ADIF-Reset Interrupt Flag
|
||||
ADCSRA = (_BV(ADEN) | _BV(ADSC) | _BV(ADATE) | _BV(ADIF) | ADC_PRESCALE);
|
||||
|
||||
for (uint8_t i = 0; i < aNumberOfSamples; i++) {
|
||||
/*
|
||||
* wait for free running conversion to finish.
|
||||
* Do not wait for ADSC here, since ADSC is only low for 1 ADC Clock cycle on free running conversion.
|
||||
*/
|
||||
loop_until_bit_is_set(ADCSRA, ADIF);
|
||||
|
||||
ADCSRA |= _BV(ADIF); // clear bit to enable recognizing next conversion has finished
|
||||
// Add value
|
||||
tSumValue += ADCL | (ADCH << 8); // using WordUnionForADCUtils does not save space here
|
||||
// tSumValue += (ADCH << 8) | ADCL; // this does NOT work!
|
||||
}
|
||||
ADCSRA &= ~_BV(ADATE); // Disable auto-triggering (free running mode)
|
||||
return tSumValue;
|
||||
}
|
||||
|
||||
/*
|
||||
* use ADC_PRESCALE32 which gives 26 us conversion time and good linearity
|
||||
* @return the maximum of aNumberOfSamples measurements.
|
||||
*/
|
||||
uint16_t readADCChannelWithReferenceMax(uint8_t aChannelNumber, uint8_t aReference, uint16_t aNumberOfSamples) {
|
||||
uint16_t tADCValue = 0;
|
||||
uint16_t tMaximum = 0;
|
||||
ADMUX = aChannelNumber | (aReference << SHIFT_VALUE_FOR_REFERENCE);
|
||||
|
||||
ADCSRB = 0; // Free running mode. Only active if ADATE is set to 1.
|
||||
// ADSC-StartConversion ADATE-AutoTriggerEnable ADIF-Reset Interrupt Flag
|
||||
ADCSRA = (_BV(ADEN) | _BV(ADSC) | _BV(ADATE) | _BV(ADIF) | ADC_PRESCALE32);
|
||||
|
||||
for (uint16_t i = 0; i < aNumberOfSamples; i++) {
|
||||
/*
|
||||
* wait for free running conversion to finish.
|
||||
* Do not wait for ADSC here, since ADSC is only low for 1 ADC Clock cycle on free running conversion.
|
||||
*/
|
||||
loop_until_bit_is_set(ADCSRA, ADIF);
|
||||
|
||||
ADCSRA |= _BV(ADIF); // clear bit to enable recognizing next conversion has finished
|
||||
// check value
|
||||
tADCValue = ADCL | (ADCH << 8);
|
||||
if (tADCValue > tMaximum) {
|
||||
tMaximum = tADCValue;
|
||||
}
|
||||
}
|
||||
ADCSRA &= ~_BV(ADATE); // Disable auto-triggering (free running mode)
|
||||
return tMaximum;
|
||||
}
|
||||
|
||||
/*
|
||||
* use ADC_PRESCALE32 which gives 26 us conversion time and good linearity
|
||||
*/
|
||||
uint16_t readADCChannelWithReferenceMaxMicros(uint8_t aChannelNumber, uint8_t aReference, uint16_t aMicrosecondsToAquire) {
|
||||
uint16_t tNumberOfSamples = aMicrosecondsToAquire / 26;
|
||||
return readADCChannelWithReferenceMax(aChannelNumber, aReference, tNumberOfSamples);
|
||||
}
|
||||
|
||||
/*
|
||||
* aMaxRetries = 255 -> try forever
|
||||
* @return (tMax + tMin) / 2
|
||||
*/
|
||||
uint16_t readUntil4ConsecutiveValuesAreEqual(uint8_t aChannelNumber, uint8_t aDelay, uint8_t aAllowedDifference,
|
||||
uint8_t aMaxRetries) {
|
||||
int tValues[4];
|
||||
int tMin;
|
||||
int tMax;
|
||||
|
||||
tValues[0] = readADCChannel(aChannelNumber);
|
||||
for (int i = 1; i < 4; ++i) {
|
||||
delay(aDelay); // Only 3 delays!
|
||||
tValues[i] = readADCChannel(aChannelNumber);
|
||||
}
|
||||
|
||||
do {
|
||||
// find min and max
|
||||
tMin = 1024;
|
||||
tMax = 0;
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
if (tValues[i] < tMin) {
|
||||
tMin = tValues[i];
|
||||
}
|
||||
if (tValues[i] > tMax) {
|
||||
tMax = tValues[i];
|
||||
}
|
||||
}
|
||||
/*
|
||||
* check for terminating condition
|
||||
*/
|
||||
if ((tMax - tMin) <= aAllowedDifference) {
|
||||
break;
|
||||
} else {
|
||||
// Serial.print("Difference=");
|
||||
// Serial.println(tMax - tMin);
|
||||
|
||||
// move values
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
tValues[i] = tValues[i + 1];
|
||||
}
|
||||
// and wait
|
||||
delay(aDelay);
|
||||
tValues[3] = readADCChannel(aChannelNumber);
|
||||
}
|
||||
if (aMaxRetries != 255) {
|
||||
aMaxRetries--;
|
||||
}
|
||||
} while (aMaxRetries > 0);
|
||||
|
||||
return (tMax + tMin) / 2;
|
||||
}
|
||||
|
||||
/*
|
||||
* !!! Function without handling of switched reference and channel.!!!
|
||||
* Use it ONLY if you only call getVCCVoltageSimple() or getVCCVoltageMillivoltSimple() in your program.
|
||||
* !!! Resolution is only 20 millivolt !!!
|
||||
*/
|
||||
float getVCCVoltageSimple(void) {
|
||||
// use AVCC with (optional) external capacitor at AREF pin as reference
|
||||
float tVCC = readADCChannelWithReferenceMultiSamples(ADC_1_1_VOLT_CHANNEL_MUX, DEFAULT, 4);
|
||||
return ((1023 * 1.1 * 4) / tVCC);
|
||||
}
|
||||
|
||||
/*
|
||||
* !!! Function without handling of switched reference and channel.!!!
|
||||
* Use it ONLY if you only call getVCCVoltageSimple() or getVCCVoltageMillivoltSimple() in your program.
|
||||
* !!! Resolution is only 20 millivolt !!!
|
||||
*/
|
||||
uint16_t getVCCVoltageMillivoltSimple(void) {
|
||||
// use AVCC with external capacitor at AREF pin as reference
|
||||
uint16_t tVCC = readADCChannelWithReferenceMultiSamples(ADC_1_1_VOLT_CHANNEL_MUX, DEFAULT, 4);
|
||||
return ((1023L * ADC_INTERNAL_REFERENCE_MILLIVOLT * 4) / tVCC);
|
||||
}
|
||||
|
||||
/*
|
||||
* Gets the hypothetical 14 bit reading of VCC using 1.1 volt reference
|
||||
* Similar to getVCCVoltageMillivolt() * 1023 / 1100
|
||||
*/
|
||||
uint16_t getVCCVoltageReadingFor1_1VoltReference(void) {
|
||||
uint16_t tVCC = waitAndReadADCChannelWithReference(ADC_1_1_VOLT_CHANNEL_MUX, DEFAULT); // 225 for 1.1 V at 5 V VCC
|
||||
/*
|
||||
* Do not switch back ADMUX to enable checkAndWaitForReferenceAndChannelToSwitch() to work correctly for the next measurement
|
||||
*/
|
||||
return ((1023L * 1023L) / tVCC);
|
||||
}
|
||||
|
||||
/*
|
||||
* !!! Resolution is only 20 millivolt !!!
|
||||
*/
|
||||
float getVCCVoltage(void) {
|
||||
return (getVCCVoltageMillivolt() / 1000.0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Read value of 1.1 volt internal channel using VCC (DEFAULT) as reference.
|
||||
* Handles reference and channel switching by introducing the appropriate delays.
|
||||
* !!! Resolution is only 20 millivolt !!!
|
||||
*/
|
||||
uint16_t getVCCVoltageMillivolt(void) {
|
||||
uint16_t tVCC = waitAndReadADCChannelWithReference(ADC_1_1_VOLT_CHANNEL_MUX, DEFAULT);
|
||||
/*
|
||||
* Do not switch back ADMUX to enable checkAndWaitForReferenceAndChannelToSwitch() to work correctly for the next measurement
|
||||
*/
|
||||
return ((1023L * ADC_INTERNAL_REFERENCE_MILLIVOLT) / tVCC);
|
||||
}
|
||||
|
||||
uint16_t printVCCVoltageMillivolt(Print *aSerial) {
|
||||
aSerial->print(F("VCC="));
|
||||
uint16_t tVCCVoltageMillivolt = getVCCVoltageMillivolt();
|
||||
aSerial->print(tVCCVoltageMillivolt);
|
||||
aSerial->println(" mV");
|
||||
return tVCCVoltageMillivolt;
|
||||
}
|
||||
|
||||
uint16_t getVoltageMillivolt(uint16_t aVCCVoltageMillivolt, uint8_t aADCChannelForVoltageMeasurement) {
|
||||
uint16_t tInputVoltageRaw = waitAndReadADCChannelWithReference(aADCChannelForVoltageMeasurement, DEFAULT);
|
||||
return (aVCCVoltageMillivolt * (uint32_t) tInputVoltageRaw) / 1023;
|
||||
}
|
||||
|
||||
uint16_t getVoltageMillivolt(uint8_t aADCChannelForVoltageMeasurement) {
|
||||
uint16_t tInputVoltageRaw = waitAndReadADCChannelWithReference(aADCChannelForVoltageMeasurement, DEFAULT);
|
||||
return (getVCCVoltageMillivolt() * (uint32_t) tInputVoltageRaw) / 1023;
|
||||
}
|
||||
|
||||
uint16_t getVoltageMillivoltWith_1_1VoltReference(uint8_t aADCChannelForVoltageMeasurement) {
|
||||
uint16_t tInputVoltageRaw = waitAndReadADCChannelWithReference(aADCChannelForVoltageMeasurement, INTERNAL);
|
||||
return (ADC_INTERNAL_REFERENCE_MILLIVOLT * (uint32_t) tInputVoltageRaw) / 1023;
|
||||
}
|
||||
/*
|
||||
* !!! Function without handling of switched reference and channel.!!!
|
||||
* Use it ONLY if you only use INTERNAL reference (call getTemperatureSimple()) in your program.
|
||||
*/
|
||||
float getTemperatureSimple(void) {
|
||||
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
|
||||
return 0.0;
|
||||
#else
|
||||
// use internal 1.1 volt as reference
|
||||
float tTemp = (readADCChannelWithReferenceMultiSamples(ADC_TEMPERATURE_CHANNEL_MUX, INTERNAL, 2) - 317);
|
||||
return (tTemp * (4 / 1.22));
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* Handles reference and channel switching by introducing the appropriate delays.
|
||||
*/
|
||||
float getTemperature(void) {
|
||||
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
|
||||
return 0.0;
|
||||
#else
|
||||
// use internal 1.1 volt as reference
|
||||
checkAndWaitForReferenceAndChannelToSwitch(ADC_TEMPERATURE_CHANNEL_MUX, INTERNAL);
|
||||
// assume the signal has noise, but never verified :-(
|
||||
float tTemp = (readADCChannelWithReferenceOversample(ADC_TEMPERATURE_CHANNEL_MUX, INTERNAL, 1) - 317);
|
||||
return (tTemp / 1.22);
|
||||
#endif
|
||||
}
|
||||
|
||||
#elif defined(ARDUINO_ARCH_APOLLO3) // defined(__AVR__) && defined(ADATE)
|
||||
void ADCUtilsDummyToAvoidBFDAssertions(){
|
||||
;
|
||||
}
|
||||
#endif // defined(__AVR__) && defined(ADATE)
|
||||
|
||||
#endif // _ADC_UTILS_HPP
|
|
@ -1,309 +0,0 @@
|
|||
/*
|
||||
* AllProtocols.cpp
|
||||
*
|
||||
* Modified ReceiveDemo.cpp with additional LCD output.
|
||||
* If debug button is pressed (pin connected to ground) a long output is generated.
|
||||
*
|
||||
* 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 RAMEND <= 0x4FF || (defined(RAMSIZE) && RAMSIZE < 0x4FF)
|
||||
#define RAW_BUFFER_LENGTH 180 // 750 (600 if we have only 2k RAM) is the value for air condition remotes. Default is 112 if DECODE_MAGIQUEST is enabled, otherwise 100.
|
||||
#elif RAMEND <= 0x8FF || (defined(RAMSIZE) && RAMSIZE < 0x8FF)
|
||||
#define RAW_BUFFER_LENGTH 600 // 750 (600 if we have only 2k RAM) is the value for air condition remotes. Default is 112 if DECODE_MAGIQUEST is enabled, otherwise 100.
|
||||
#else
|
||||
#define RAW_BUFFER_LENGTH 750 // 750 (600 if we have only 2k RAM) is the value for air condition remotes. Default is 112 if DECODE_MAGIQUEST is enabled, otherwise 100.
|
||||
#endif
|
||||
//#define NO_LED_FEEDBACK_CODE // saves 92 bytes program memory
|
||||
#if FLASHEND <= 0x1FFF // For 8k flash or less, like ATtiny85. Exclude exotic protocols.
|
||||
#define EXCLUDE_EXOTIC_PROTOCOLS
|
||||
# if !defined(DIGISTUMPCORE) // ATTinyCore is bigger than Digispark core
|
||||
#define EXCLUDE_UNIVERSAL_PROTOCOLS // Saves up to 1000 bytes program memory.
|
||||
# endif
|
||||
#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
|
||||
|
||||
// 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.
|
||||
//#define MARK_EXCESS_MICROS 20 // 20 is recommended for the cheap VS1838 modules
|
||||
|
||||
//#define RECORD_GAP_MICROS 12000 // Activate it for some LG air conditioner protocols
|
||||
|
||||
//#define DEBUG // Activate this for lots of lovely debug output from the decoders.
|
||||
|
||||
#include "PinDefinitionsAndMore.h" // Define macros for input and output pin etc.
|
||||
#include <IRremote.hpp>
|
||||
|
||||
#if defined(APPLICATION_PIN)
|
||||
#define DEBUG_BUTTON_PIN APPLICATION_PIN // if low, print timing for each received data set
|
||||
#else
|
||||
#define DEBUG_BUTTON_PIN 6
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Activate the type of LCD you use
|
||||
* Default is serial LCD with 2 rows of 16 characters (1602).
|
||||
*/
|
||||
//#define USE_NO_LCD
|
||||
//#define USE_PARALLEL_LCD
|
||||
#if defined(USE_PARALLEL_LCD)
|
||||
#include "LiquidCrystal.h"
|
||||
#elif !defined(USE_NO_LCD)
|
||||
#define USE_SERIAL_LCD
|
||||
#include "LiquidCrystal_I2C.h" // Use an up to date library version, which has the init method
|
||||
#endif
|
||||
|
||||
#if defined(USE_SERIAL_LCD) || defined(USE_PARALLEL_LCD)
|
||||
#define USE_LCD
|
||||
// definitions for a 1602 LCD
|
||||
#define LCD_COLUMNS 16
|
||||
#define LCD_ROWS 2
|
||||
# if defined(__AVR__) && defined(ADCSRA) && defined(ADATE)
|
||||
// For cyclically display of VCC
|
||||
#include "ADCUtils.hpp"
|
||||
#define MILLIS_BETWEEN_VOLTAGE_PRINT 5000
|
||||
uint32_t volatile sMillisOfLastVoltagePrint;
|
||||
# endif
|
||||
|
||||
static uint8_t sLastProtocolIndex;
|
||||
#endif
|
||||
|
||||
#if defined(USE_SERIAL_LCD)
|
||||
LiquidCrystal_I2C myLCD(0x27, LCD_COLUMNS, LCD_ROWS); // set the LCD address to 0x27 for a 20 chars and 2 line display
|
||||
#endif
|
||||
#if defined(USE_PARALLEL_LCD)
|
||||
LiquidCrystal myLCD(4, 5, 6, 7, 8, 9);
|
||||
#endif
|
||||
|
||||
void printIRResultOnLCD();
|
||||
|
||||
void setup() {
|
||||
#if FLASHEND >= 0x3FFF // For 16k flash or more, like ATtiny1604. Code does not fit in program memory of ATtiny85 etc.
|
||||
pinMode(DEBUG_BUTTON_PIN, INPUT_PULLUP);
|
||||
#endif
|
||||
|
||||
Serial.begin(115200);
|
||||
#if defined(__AVR_ATmega32U4__) || defined(SERIAL_PORT_USBVIRTUAL) || defined(SERIAL_USB) /*stm32duino*/|| defined(USBCON) /*STM32_stm32*/|| defined(SERIALUSB_PID) || defined(ARDUINO_attiny3217)
|
||||
delay(4000); // To be able to connect Serial monitor after reset or power up and before first print out. Do not wait for an attached Serial Monitor!
|
||||
#endif
|
||||
// Just to know which program is running on my Arduino
|
||||
Serial.println(F("START " __FILE__ " from " __DATE__ "\r\nUsing library version " VERSION_IRREMOTE));
|
||||
|
||||
// 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)));
|
||||
|
||||
#if FLASHEND >= 0x3FFF // For 16k flash or more, like ATtiny1604. Code does not fit in program memory of ATtiny85 etc.
|
||||
Serial.print(F("Debug button pin is "));
|
||||
Serial.println(DEBUG_BUTTON_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(F(" us are subtracted from all marks and added to all spaces for decoding"));
|
||||
#endif
|
||||
|
||||
#if defined(USE_LCD) && defined(__AVR__) && defined(ADCSRA) && defined(ADATE)
|
||||
getVCCVoltageMillivoltSimple(); // to initialize ADC mux and reference
|
||||
#endif
|
||||
|
||||
#if defined(USE_SERIAL_LCD)
|
||||
myLCD.init();
|
||||
myLCD.clear();
|
||||
myLCD.backlight();
|
||||
#endif
|
||||
#if defined(USE_PARALLEL_LCD)
|
||||
myLCD.begin(LCD_COLUMNS, LCD_ROWS);
|
||||
#endif
|
||||
|
||||
#if defined(USE_LCD)
|
||||
myLCD.print(F("IRRemote v" VERSION_IRREMOTE));
|
||||
myLCD.setCursor(0, 1);
|
||||
myLCD.print(F(__DATE__));
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
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) {
|
||||
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
|
||||
|
||||
} else {
|
||||
// Print a short summary of received data
|
||||
IrReceiver.printIRResultShort(&Serial);
|
||||
|
||||
if (IrReceiver.decodedIRData.protocol == UNKNOWN || digitalRead(DEBUG_BUTTON_PIN) == LOW) {
|
||||
// We have an unknown protocol, print more info
|
||||
IrReceiver.printIRResultRawFormatted(&Serial, false);
|
||||
}
|
||||
#if defined(USE_LCD)
|
||||
printIRResultOnLCD();
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* !!!Important!!! Enable receiving of the next value,
|
||||
* since receiving has stopped after the end of the current received data packet.
|
||||
*/
|
||||
IrReceiver.resume();
|
||||
} // if (IrReceiver.decode())
|
||||
|
||||
#if defined(USE_LCD) && defined(__AVR__) && defined(ADCSRA) && defined(ADATE)
|
||||
/*
|
||||
* Periodically print VCC
|
||||
*/
|
||||
if (millis() - sMillisOfLastVoltagePrint > MILLIS_BETWEEN_VOLTAGE_PRINT) {
|
||||
sMillisOfLastVoltagePrint = millis();
|
||||
uint16_t tVCC = getVCCVoltageMillivoltSimple();
|
||||
|
||||
myLCD.setCursor(10, 0);
|
||||
myLCD.print(' ');
|
||||
myLCD.print(tVCC / 1000);
|
||||
myLCD.print('.');
|
||||
myLCD.print(((tVCC + 5) / 10) % 100);
|
||||
myLCD.print('V');
|
||||
|
||||
sLastProtocolIndex = 0; // enable new printing of protocol
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* LCD output for 1602 LCDs
|
||||
* 40 - 55 Milliseconds per initial output
|
||||
* The expander runs at 100 kHz :-(
|
||||
* 8 milliseconds for 8 bit; 10 ms for 16 bit code output
|
||||
* 3 milliseconds for repeat output
|
||||
*
|
||||
*/
|
||||
void printIRResultOnLCD() {
|
||||
#if defined(USE_LCD)
|
||||
static uint16_t sLastProtocolAddress;
|
||||
static uint16_t sLastCommand;
|
||||
static uint8_t sLastCommandPrintPosition;
|
||||
|
||||
bool tDisplayWasCleared = false;
|
||||
|
||||
/*
|
||||
* Print only if protocol or address has changed
|
||||
*/
|
||||
if (sLastProtocolIndex != IrReceiver.decodedIRData.protocol || sLastProtocolAddress != IrReceiver.decodedIRData.address) {
|
||||
sLastProtocolIndex = IrReceiver.decodedIRData.protocol;
|
||||
sLastProtocolAddress = IrReceiver.decodedIRData.address;
|
||||
|
||||
myLCD.clear(); // includes a delay of 2 ms
|
||||
tDisplayWasCleared = true;
|
||||
|
||||
/*
|
||||
* Show protocol name
|
||||
*/
|
||||
myLCD.setCursor(0, 0);
|
||||
const __FlashStringHelper *tProtocolStringPtr = getProtocolString(IrReceiver.decodedIRData.protocol);
|
||||
myLCD.print(tProtocolStringPtr);
|
||||
|
||||
/*
|
||||
* Show address
|
||||
*/
|
||||
myLCD.setCursor(0, 1);
|
||||
myLCD.print(F("A=0x"));
|
||||
myLCD.print(IrReceiver.decodedIRData.address, HEX);
|
||||
|
||||
} else {
|
||||
/*
|
||||
* Show or clear repetition flag
|
||||
*/
|
||||
myLCD.setCursor(15, 1);
|
||||
if (IrReceiver.decodedIRData.flags & (IRDATA_FLAGS_IS_REPEAT)) {
|
||||
myLCD.print('R');
|
||||
return; // Since it is a repetition, printed data has not changed
|
||||
} else {
|
||||
myLCD.print(' ');
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Command prefix
|
||||
*/
|
||||
uint16_t tCommand = IrReceiver.decodedIRData.command;
|
||||
|
||||
// check if prefix position must change
|
||||
if (tDisplayWasCleared || (sLastCommand > 0x100 && tCommand < 0x100) || (sLastCommand < 0x100 && tCommand > 0x100)) {
|
||||
sLastCommand = tCommand;
|
||||
/*
|
||||
* Print prefix of command
|
||||
*/
|
||||
myLCD.setCursor(9, 1);
|
||||
|
||||
/*
|
||||
* Print prefix for 8/16 bit commands
|
||||
*/
|
||||
if (tCommand >= 0x100) {
|
||||
myLCD.print(F("0x"));
|
||||
sLastCommandPrintPosition = 11;
|
||||
} else {
|
||||
myLCD.print(F("C=0x"));
|
||||
sLastCommandPrintPosition = 13;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Command data
|
||||
*/
|
||||
myLCD.setCursor(sLastCommandPrintPosition, 1);
|
||||
if (IrReceiver.decodedIRData.command < 0x10) {
|
||||
// leading 0
|
||||
myLCD.print('0');
|
||||
}
|
||||
myLCD.print(tCommand, HEX);
|
||||
|
||||
#endif // defined(USE_LCD)
|
||||
}
|
||||
|
|
@ -0,0 +1,227 @@
|
|||
/*
|
||||
* ADCUtils.h
|
||||
*
|
||||
* Copyright (C) 2016-2022 Armin Joachimsmeyer
|
||||
* Email: armin.joachimsmeyer@gmail.com
|
||||
*
|
||||
* This file is part of Arduino-Utils https://github.com/ArminJo/Arduino-Utils.
|
||||
*
|
||||
* ArduinoUtils 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 _ADC_UTILS_H
|
||||
#define _ADC_UTILS_H
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
#if defined(__AVR__) && defined(ADCSRA) && defined(ADATE) && (!defined(__AVR_ATmega4809__))
|
||||
#define ADC_UTILS_ARE_AVAILABLE
|
||||
|
||||
// PRESCALE4 => 13 * 4 = 52 microseconds per ADC conversion at 1 MHz Clock => 19,2 kHz
|
||||
#define ADC_PRESCALE2 1 // 26 microseconds per ADC conversion at 1 MHz
|
||||
#define ADC_PRESCALE4 2 // 52 microseconds per ADC conversion at 1 MHz
|
||||
// PRESCALE8 => 13 * 8 = 104 microseconds per ADC sample at 1 MHz Clock => 9,6 kHz
|
||||
#define ADC_PRESCALE8 3 // 104 microseconds per ADC conversion at 1 MHz
|
||||
#define ADC_PRESCALE16 4 // 13/208 microseconds per ADC conversion at 16/1 MHz - degradations in linearity at 16 MHz
|
||||
#define ADC_PRESCALE32 5 // 26/416 microseconds per ADC conversion at 16/1 MHz - very good linearity at 16 MHz
|
||||
#define ADC_PRESCALE64 6 // 52 microseconds per ADC conversion at 16 MHz
|
||||
#define ADC_PRESCALE128 7 // 104 microseconds per ADC conversion at 16 MHz --- Arduino default
|
||||
|
||||
// definitions for 0.1 ms conversion time
|
||||
#if (F_CPU == 1000000)
|
||||
#define ADC_PRESCALE ADC_PRESCALE8
|
||||
#elif (F_CPU == 8000000)
|
||||
#define ADC_PRESCALE ADC_PRESCALE64
|
||||
#elif (F_CPU == 16000000)
|
||||
#define ADC_PRESCALE ADC_PRESCALE128
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Reference shift values are complicated for ATtinyX5 since we have the extra register bit REFS2
|
||||
* in ATTinyCore, this bit is handled programmatical and therefore the defines are different.
|
||||
* To keep my library small, I use the changed defines.
|
||||
* After including this file you can not call the ATTinyCore readAnalog functions reliable, if you specify references other than default!
|
||||
*/
|
||||
#if defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__)
|
||||
// defines are for ADCUtils.cpp, they can be used WITHOUT bit reordering
|
||||
#undef DEFAULT
|
||||
#undef EXTERNAL
|
||||
#undef INTERNAL1V1
|
||||
#undef INTERNAL
|
||||
#undef INTERNAL2V56
|
||||
#undef INTERNAL2V56_EXTCAP
|
||||
|
||||
#define DEFAULT 0
|
||||
#define EXTERNAL 4
|
||||
#define INTERNAL1V1 8
|
||||
#define INTERNAL INTERNAL1V1
|
||||
#define INTERNAL2V56 9
|
||||
#define INTERNAL2V56_EXTCAP 13
|
||||
|
||||
#define SHIFT_VALUE_FOR_REFERENCE REFS2
|
||||
#define MASK_FOR_ADC_REFERENCE (_BV(REFS0) | _BV(REFS1) | _BV(REFS2))
|
||||
#define MASK_FOR_ADC_CHANNELS (_BV(MUX0) | _BV(MUX1) | _BV(MUX2) | _BV(MUX3))
|
||||
#else // AVR_ATtiny85
|
||||
|
||||
#define SHIFT_VALUE_FOR_REFERENCE REFS0
|
||||
#define MASK_FOR_ADC_REFERENCE (_BV(REFS0) | _BV(REFS1))
|
||||
#define MASK_FOR_ADC_CHANNELS (_BV(MUX0) | _BV(MUX1) | _BV(MUX2) | _BV(MUX3))
|
||||
#endif
|
||||
|
||||
// Temperature channel definitions - 1 LSB / 1 degree Celsius
|
||||
#if defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__)
|
||||
#define ADC_TEMPERATURE_CHANNEL_MUX 15
|
||||
#define ADC_1_1_VOLT_CHANNEL_MUX 12
|
||||
#define ADC_GND_CHANNEL_MUX 13
|
||||
#define ADC_CHANNEL_MUX_MASK 0x0F
|
||||
|
||||
#elif defined(__AVR_ATtiny87__) || defined(__AVR_ATtiny167__)
|
||||
#define ADC_ISCR_CHANNEL_MUX 3
|
||||
#define ADC_TEMPERATURE_CHANNEL_MUX 11
|
||||
#define ADC_1_1_VOLT_CHANNEL_MUX 12
|
||||
#define ADC_GND_CHANNEL_MUX 14
|
||||
#define ADC_VCC_4TH_CHANNEL_MUX 13
|
||||
#define ADC_CHANNEL_MUX_MASK 0x1F
|
||||
|
||||
#elif defined(__AVR_ATmega328P__)
|
||||
#define ADC_TEMPERATURE_CHANNEL_MUX 8
|
||||
#define ADC_1_1_VOLT_CHANNEL_MUX 14
|
||||
#define ADC_GND_CHANNEL_MUX 15
|
||||
#define ADC_CHANNEL_MUX_MASK 0x0F
|
||||
|
||||
#elif defined(__AVR_ATmega32U4__)
|
||||
#define ADC_TEMPERATURE_CHANNEL_MUX 0x27
|
||||
#define ADC_1_1_VOLT_CHANNEL_MUX 0x1E
|
||||
#define ADC_GND_CHANNEL_MUX 0x1F
|
||||
#define ADC_CHANNEL_MUX_MASK 0x3F
|
||||
|
||||
#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) || defined(__AVR_ATmega644__) || defined(__AVR_ATmega644A__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644PA__)
|
||||
#define ADC_1_1_VOLT_CHANNEL_MUX 0x1E
|
||||
#define ADC_GND_CHANNEL_MUX 0x1F
|
||||
#define ADC_CHANNEL_MUX_MASK 0x1F
|
||||
|
||||
#define INTERNAL INTERNAL1V1
|
||||
|
||||
#else
|
||||
#error "No temperature channel definitions specified for this AVR CPU"
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Thresholds for OVER and UNDER voltage and detection of kind of power supply (USB or Li-ion)
|
||||
*
|
||||
* Default values are suitable for Li-ion batteries.
|
||||
* We normally have voltage drop at the connectors, so the battery voltage is assumed slightly higher, than the Arduino VCC.
|
||||
* But keep in mind that the ultrasonic distance module HC-SR04 may not work reliable below 3.7 volt.
|
||||
*/
|
||||
#if !defined(LI_ION_VCC_UNDERVOLTAGE_THRESHOLD_MILLIVOLT)
|
||||
#define LI_ION_VCC_UNDERVOLTAGE_THRESHOLD_MILLIVOLT 3400 // Do not stress your battery and we require some power for standby
|
||||
#endif
|
||||
#if !defined(LI_ION_VCC_EMERGENCY_UNDERVOLTAGE_THRESHOLD_MILLIVOLT)
|
||||
#define LI_ION_VCC_EMERGENCY_UNDERVOLTAGE_THRESHOLD_MILLIVOLT 3000 // Many Li-ions are specified down to 3.0 volt
|
||||
#endif
|
||||
|
||||
#if !defined(VCC_UNDERVOLTAGE_THRESHOLD_MILLIVOLT)
|
||||
#define VCC_UNDERVOLTAGE_THRESHOLD_MILLIVOLT LI_ION_VCC_UNDERVOLTAGE_THRESHOLD_MILLIVOLT
|
||||
#endif
|
||||
#if !defined(VCC_EMERGENCY_UNDERVOLTAGE_THRESHOLD_MILLIVOLT)
|
||||
#define VCC_EMERGENCY_UNDERVOLTAGE_THRESHOLD_MILLIVOLT LI_ION_VCC_EMERGENCY_UNDERVOLTAGE_THRESHOLD_MILLIVOLT
|
||||
#endif
|
||||
#if !defined(VCC_OVERVOLTAGE_THRESHOLD_MILLIVOLT)
|
||||
#define VCC_OVERVOLTAGE_THRESHOLD_MILLIVOLT 5250 // + 5 % operation voltage
|
||||
#endif
|
||||
#if !defined(VCC_EMERGENCY_OVERVOLTAGE_THRESHOLD_MILLIVOLT)
|
||||
#define VCC_EMERGENCY_OVERVOLTAGE_THRESHOLD_MILLIVOLT 5500 // +10 %. Max recommended operation voltage
|
||||
#endif
|
||||
#if !defined(VCC_CHECK_PERIOD_MILLIS)
|
||||
#define VCC_CHECK_PERIOD_MILLIS 10000L // 10 seconds period of VCC checks
|
||||
#endif
|
||||
#if !defined(VCC_UNDERVOLTAGE_CHECKS_BEFORE_STOP)
|
||||
#define VCC_UNDERVOLTAGE_CHECKS_BEFORE_STOP 6 // Shutdown after 6 times (60 seconds) VCC below VCC_UNDERVOLTAGE_THRESHOLD_MILLIVOLT or 1 time below VCC_EMERGENCY_UNDERVOLTAGE_THRESHOLD_MILLIVOLT
|
||||
#endif
|
||||
|
||||
#if !defined(VOLTAGE_USB_POWERED_LOWER_THRESHOLD_MILLIVOLT)
|
||||
#define VOLTAGE_USB_POWERED_LOWER_THRESHOLD_MILLIVOLT 4300 // Assume USB powered above this voltage
|
||||
#endif
|
||||
|
||||
#if !defined(VOLTAGE_USB_POWERED_UPPER_THRESHOLD_MILLIVOLT)
|
||||
#define VOLTAGE_USB_POWERED_UPPER_THRESHOLD_MILLIVOLT 4950 // Assume USB powered below this voltage, because of the loss in USB cable. If we have > 4950, we assume to be powered by VIN.
|
||||
// In contrast to e.g. powered by VIN, which results in almost perfect 5 volt supply
|
||||
#endif
|
||||
|
||||
extern long sLastVCCCheckMillis;
|
||||
extern uint8_t sVCCTooLowCounter;
|
||||
|
||||
uint16_t readADCChannel(uint8_t aADCChannelNumber);
|
||||
uint16_t readADCChannelWithReference(uint8_t aADCChannelNumber, uint8_t aReference);
|
||||
uint16_t waitAndReadADCChannelWithReference(uint8_t aADCChannelNumber, uint8_t aReference);
|
||||
uint16_t waitAndReadADCChannelWithReferenceAndRestoreADMUXAndReference(uint8_t aADCChannelNumber, uint8_t aReference);
|
||||
uint16_t readADCChannelWithOversample(uint8_t aADCChannelNumber, uint8_t aOversampleExponent);
|
||||
void setADCChannelAndReferenceForNextConversion(uint8_t aADCChannelNumber, uint8_t aReference);
|
||||
uint16_t readADCChannelWithReferenceOversampleFast(uint8_t aADCChannelNumber, uint8_t aReference, uint8_t aOversampleExponent);
|
||||
uint32_t readADCChannelMultiSamples(uint8_t aPrescale, uint16_t aNumberOfSamples);
|
||||
uint16_t readADCChannelMultiSamplesWithReference(uint8_t aADCChannelNumber, uint8_t aReference, uint8_t aNumberOfSamples);
|
||||
uint32_t readADCChannelMultiSamplesWithReferenceAndPrescaler(uint8_t aADCChannelNumber, uint8_t aReference, uint8_t aPrescale,
|
||||
uint16_t aNumberOfSamples);
|
||||
uint16_t readADCChannelWithReferenceMax(uint8_t aADCChannelNumber, uint8_t aReference, uint16_t aNumberOfSamples);
|
||||
uint16_t readADCChannelWithReferenceMaxMicros(uint8_t aADCChannelNumber, uint8_t aReference, uint16_t aMicrosecondsToAquire);
|
||||
uint16_t readUntil4ConsecutiveValuesAreEqual(uint8_t aADCChannelNumber, uint8_t aReference, uint8_t aDelay,
|
||||
uint8_t aAllowedDifference, uint8_t aMaxRetries);
|
||||
|
||||
uint8_t checkAndWaitForReferenceAndChannelToSwitch(uint8_t aADCChannelNumber, uint8_t aReference);
|
||||
|
||||
/*
|
||||
* readVCC*() functions store the result in sVCCVoltageMillivolt or sVCCVoltage
|
||||
*/
|
||||
float getVCCVoltageSimple(void);
|
||||
void readVCCVoltageSimple(void);
|
||||
void readVCCVoltageMillivoltSimple(void);
|
||||
void readVCCVoltage(void);
|
||||
uint16_t getVCCVoltageMillivolt(void);
|
||||
void readVCCVoltageMillivolt(void);
|
||||
uint16_t getVCCVoltageReadingFor1_1VoltReference(void);
|
||||
uint16_t printVCCVoltageMillivolt(Print *aSerial);
|
||||
void readAndPrintVCCVoltageMillivolt(Print *aSerial);
|
||||
|
||||
uint16_t getVoltageMillivolt(uint16_t aVCCVoltageMillivolt, uint8_t aADCChannelForVoltageMeasurement);
|
||||
uint16_t getVoltageMillivolt(uint8_t aADCChannelForVoltageMeasurement);
|
||||
uint16_t getVoltageMillivoltWith_1_1VoltReference(uint8_t aADCChannelForVoltageMeasurement);
|
||||
float getCPUTemperatureSimple(void);
|
||||
float getCPUTemperature(void);
|
||||
float getTemperature(void) __attribute__ ((deprecated ("Renamed to getCPUTemperature()"))); // deprecated
|
||||
|
||||
bool isVCCUSBPowered();
|
||||
bool isVCCUSBPowered(Print *aSerial);
|
||||
bool isVCCUndervoltageMultipleTimes();
|
||||
void resetCounterForVCCUndervoltageMultipleTimes();
|
||||
bool isVCCUndervoltage();
|
||||
bool isVCCEmergencyUndervoltage();
|
||||
bool isVCCOvervoltage();
|
||||
bool isVCCOvervoltageSimple();
|
||||
|
||||
#endif // defined(__AVR__) ...
|
||||
|
||||
/*
|
||||
* Variables and functions defined as dummies to allow for seamless compiling on non AVR platforms
|
||||
*/
|
||||
extern float sVCCVoltage;
|
||||
extern uint16_t sVCCVoltageMillivolt;
|
||||
|
||||
uint16_t readADCChannelWithReferenceOversample(uint8_t aADCChannelNumber, uint8_t aReference, uint8_t aOversampleExponent);
|
||||
|
||||
uint16_t getVCCVoltageMillivoltSimple(void);
|
||||
float getVCCVoltage(void);
|
||||
float getCPUTemperature(void);
|
||||
|
||||
#endif // _ADC_UTILS_H
|
|
@ -0,0 +1,799 @@
|
|||
/*
|
||||
* ADCUtils.hpp
|
||||
*
|
||||
* ADC utility functions. Conversion time is defined as 0.104 milliseconds for 16 MHz Arduinos in ADCUtils.h.
|
||||
*
|
||||
* Copyright (C) 2016-2023 Armin Joachimsmeyer
|
||||
* Email: armin.joachimsmeyer@gmail.com
|
||||
*
|
||||
* This file is part of Arduino-Utils https://github.com/ArminJo/Arduino-Utils.
|
||||
*
|
||||
* ArduinoUtils 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 _ADC_UTILS_HPP
|
||||
#define _ADC_UTILS_HPP
|
||||
|
||||
#include "ADCUtils.h"
|
||||
#if defined(ADC_UTILS_ARE_AVAILABLE) // set in ADCUtils.h, if supported architecture was detected
|
||||
|
||||
#if !defined(STR_HELPER)
|
||||
#define STR_HELPER(x) #x
|
||||
#define STR(x) STR_HELPER(x)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* By replacing this value with the voltage you measured a the AREF pin after a conversion
|
||||
* with INTERNAL you can calibrate your ADC readout. For my Nanos I measured e.g. 1060 mV and 1093 mV.
|
||||
*/
|
||||
#if !defined(ADC_INTERNAL_REFERENCE_MILLIVOLT)
|
||||
#define ADC_INTERNAL_REFERENCE_MILLIVOLT 1100L // Change to value measured at the AREF pin. If value > real AREF voltage, measured values are > real values
|
||||
#endif
|
||||
|
||||
// Union to speed up the combination of low and high bytes to a word
|
||||
// it is not optimal since the compiler still generates 2 unnecessary moves
|
||||
// but using -- value = (high << 8) | low -- gives 5 unnecessary instructions
|
||||
union WordUnionForADCUtils {
|
||||
struct {
|
||||
uint8_t LowByte;
|
||||
uint8_t HighByte;
|
||||
} UByte;
|
||||
uint16_t UWord;
|
||||
int16_t Word;
|
||||
uint8_t *BytePointer;
|
||||
};
|
||||
|
||||
/*
|
||||
* 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(DEBUG) && !defined(LOCAL_DEBUG)
|
||||
#define LOCAL_DEBUG
|
||||
#else
|
||||
//#define LOCAL_DEBUG // This enables debug output only for this file
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Persistent storage for VCC value
|
||||
*/
|
||||
float sVCCVoltage;
|
||||
uint16_t sVCCVoltageMillivolt;
|
||||
|
||||
// for isVCCTooLowMultipleTimes()
|
||||
long sLastVCCCheckMillis;
|
||||
uint8_t sVCCTooLowCounter = 0;
|
||||
|
||||
/*
|
||||
* Conversion time is defined as 0.104 milliseconds by ADC_PRESCALE in ADCUtils.h.
|
||||
*/
|
||||
uint16_t readADCChannel(uint8_t aADCChannelNumber) {
|
||||
WordUnionForADCUtils tUValue;
|
||||
ADMUX = aADCChannelNumber | (DEFAULT << SHIFT_VALUE_FOR_REFERENCE);
|
||||
|
||||
// ADCSRB = 0; // Only active if ADATE is set to 1.
|
||||
// ADSC-StartConversion ADIF-Reset Interrupt Flag - NOT free running mode
|
||||
ADCSRA = (_BV(ADEN) | _BV(ADSC) | _BV(ADIF) | ADC_PRESCALE);
|
||||
|
||||
// wait for single conversion to finish
|
||||
loop_until_bit_is_clear(ADCSRA, ADSC);
|
||||
|
||||
// Get value
|
||||
tUValue.UByte.LowByte = ADCL;
|
||||
tUValue.UByte.HighByte = ADCH;
|
||||
return tUValue.UWord;
|
||||
// return ADCL | (ADCH <<8); // needs 4 bytes more
|
||||
}
|
||||
|
||||
/*
|
||||
* Conversion time is defined as 0.104 milliseconds by ADC_PRESCALE in ADCUtils.h.
|
||||
*/
|
||||
uint16_t readADCChannelWithReference(uint8_t aADCChannelNumber, uint8_t aReference) {
|
||||
WordUnionForADCUtils tUValue;
|
||||
ADMUX = aADCChannelNumber | (aReference << SHIFT_VALUE_FOR_REFERENCE);
|
||||
|
||||
// ADCSRB = 0; // Only active if ADATE is set to 1.
|
||||
// ADSC-StartConversion ADIF-Reset Interrupt Flag - NOT free running mode
|
||||
ADCSRA = (_BV(ADEN) | _BV(ADSC) | _BV(ADIF) | ADC_PRESCALE);
|
||||
|
||||
// wait for single conversion to finish
|
||||
loop_until_bit_is_clear(ADCSRA, ADSC);
|
||||
|
||||
// Get value
|
||||
tUValue.UByte.LowByte = ADCL;
|
||||
tUValue.UByte.HighByte = ADCH;
|
||||
return tUValue.UWord;
|
||||
}
|
||||
|
||||
/*
|
||||
* Conversion time is defined as 0.104 milliseconds by ADC_PRESCALE in ADCUtils.h.
|
||||
* Does NOT restore ADMUX after reading
|
||||
*/
|
||||
uint16_t waitAndReadADCChannelWithReference(uint8_t aADCChannelNumber, uint8_t aReference) {
|
||||
checkAndWaitForReferenceAndChannelToSwitch(aADCChannelNumber, aReference);
|
||||
return readADCChannelWithReference(aADCChannelNumber, aReference);
|
||||
}
|
||||
|
||||
/*
|
||||
* Conversion time is defined as 0.104 milliseconds by ADC_PRESCALE in ADCUtils.h.
|
||||
* Restores ADMUX after reading
|
||||
*/
|
||||
uint16_t waitAndReadADCChannelWithReferenceAndRestoreADMUXAndReference(uint8_t aADCChannelNumber, uint8_t aReference) {
|
||||
uint8_t tOldADMUX = checkAndWaitForReferenceAndChannelToSwitch(aADCChannelNumber, aReference);
|
||||
uint16_t tResult = readADCChannelWithReference(aADCChannelNumber, aReference);
|
||||
checkAndWaitForReferenceAndChannelToSwitch(tOldADMUX & MASK_FOR_ADC_CHANNELS, tOldADMUX >> SHIFT_VALUE_FOR_REFERENCE);
|
||||
return tResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* To prepare reference and ADMUX for next measurement
|
||||
*/
|
||||
void setADCChannelAndReferenceForNextConversion(uint8_t aADCChannelNumber, uint8_t aReference) {
|
||||
ADMUX = aADCChannelNumber | (aReference << SHIFT_VALUE_FOR_REFERENCE);
|
||||
}
|
||||
|
||||
/*
|
||||
* @return original ADMUX register content for optional later restoring values
|
||||
* All experimental values are acquired by using the ADCSwitchingTest example from this library
|
||||
*/
|
||||
uint8_t checkAndWaitForReferenceAndChannelToSwitch(uint8_t aADCChannelNumber, uint8_t aReference) {
|
||||
uint8_t tOldADMUX = ADMUX;
|
||||
/*
|
||||
* Must wait >= 7 us if reference has to be switched from 1.1 volt/INTERNAL to VCC/DEFAULT (seen on oscilloscope)
|
||||
* This is done after the 2 ADC clock cycles required for Sample & Hold :-)
|
||||
*
|
||||
* Must wait >= 7600 us for Nano board >= 6200 for Uno board if reference has to be switched from VCC/DEFAULT to 1.1 volt/INTERNAL
|
||||
* Must wait >= 200 us if channel has to be switched to 1.1 volt internal channel if S&H was at 5 Volt
|
||||
*/
|
||||
uint8_t tNewReference = (aReference << SHIFT_VALUE_FOR_REFERENCE);
|
||||
ADMUX = aADCChannelNumber | tNewReference;
|
||||
#if defined(INTERNAL2V56)
|
||||
if ((tOldADMUX & MASK_FOR_ADC_REFERENCE) != tNewReference && (aReference == INTERNAL || aReference == INTERNAL2V56)) {
|
||||
#else
|
||||
if ((tOldADMUX & MASK_FOR_ADC_REFERENCE) != tNewReference && aReference == INTERNAL) {
|
||||
#endif
|
||||
#if defined(LOCAL_DEBUG)
|
||||
Serial.println(F("Switch from DEFAULT to INTERNAL"));
|
||||
#endif
|
||||
/*
|
||||
* Switch reference from DEFAULT to INTERNAL
|
||||
*/
|
||||
delayMicroseconds(8000); // experimental value is >= 7600 us for Nano board and 6200 for Uno board
|
||||
} else if ((tOldADMUX & ADC_CHANNEL_MUX_MASK) != aADCChannelNumber) {
|
||||
if (aADCChannelNumber == ADC_1_1_VOLT_CHANNEL_MUX) {
|
||||
/*
|
||||
* Internal 1.1 Volt channel requires <= 200 us for Nano board
|
||||
*/
|
||||
delayMicroseconds(350); // 350 was ok and 300 was too less for UltimateBatteryTester - result was 226 instead of 225
|
||||
} else {
|
||||
/*
|
||||
* 100 kOhm requires < 100 us, 1 MOhm requires 120 us S&H switching time
|
||||
*/
|
||||
delayMicroseconds(120); // experimental value is <= 1100 us for Nano board
|
||||
}
|
||||
}
|
||||
return tOldADMUX;
|
||||
}
|
||||
|
||||
/*
|
||||
* Oversample and multiple samples only makes sense if you expect a noisy input signal
|
||||
* It does NOT increase the precision of the measurement, since the ADC has insignificant noise
|
||||
*/
|
||||
uint16_t readADCChannelWithOversample(uint8_t aADCChannelNumber, uint8_t aOversampleExponent) {
|
||||
return readADCChannelWithReferenceOversample(aADCChannelNumber, DEFAULT, aOversampleExponent);
|
||||
}
|
||||
|
||||
/*
|
||||
* Conversion time is defined as 0.104 milliseconds by ADC_PRESCALE in ADCUtils.h.
|
||||
*/
|
||||
uint16_t readADCChannelWithReferenceOversample(uint8_t aADCChannelNumber, uint8_t aReference, uint8_t aOversampleExponent) {
|
||||
uint16_t tSumValue = 0;
|
||||
ADMUX = aADCChannelNumber | (aReference << SHIFT_VALUE_FOR_REFERENCE);
|
||||
|
||||
ADCSRB = 0; // Free running mode. Only active if ADATE is set to 1.
|
||||
// ADSC-StartConversion ADATE-AutoTriggerEnable ADIF-Reset Interrupt Flag
|
||||
ADCSRA = (_BV(ADEN) | _BV(ADSC) | _BV(ADATE) | _BV(ADIF) | ADC_PRESCALE);
|
||||
|
||||
uint8_t tCount = _BV(aOversampleExponent);
|
||||
for (uint8_t i = 0; i < tCount; i++) {
|
||||
/*
|
||||
* wait for free running conversion to finish.
|
||||
* Do not wait for ADSC here, since ADSC is only low for 1 ADC Clock cycle on free running conversion.
|
||||
*/
|
||||
loop_until_bit_is_set(ADCSRA, ADIF);
|
||||
|
||||
ADCSRA |= _BV(ADIF); // clear bit to enable recognizing next conversion has finished
|
||||
// Add value
|
||||
tSumValue += ADCL | (ADCH << 8); // using WordUnionForADCUtils does not save space here
|
||||
// tSumValue += (ADCH << 8) | ADCL; // this does NOT work!
|
||||
}
|
||||
ADCSRA &= ~_BV(ADATE); // Disable auto-triggering (free running mode)
|
||||
// return rounded value
|
||||
return ((tSumValue + (tCount >> 1)) >> aOversampleExponent);
|
||||
}
|
||||
|
||||
/*
|
||||
* Use ADC_PRESCALE32 which gives 26 us conversion time and good linearity for 16 MHz Arduino
|
||||
*/
|
||||
uint16_t readADCChannelWithReferenceOversampleFast(uint8_t aADCChannelNumber, uint8_t aReference, uint8_t aOversampleExponent) {
|
||||
uint16_t tSumValue = 0;
|
||||
ADMUX = aADCChannelNumber | (aReference << SHIFT_VALUE_FOR_REFERENCE);
|
||||
|
||||
ADCSRB = 0; // Free running mode. Only active if ADATE is set to 1.
|
||||
// ADSC-StartConversion ADATE-AutoTriggerEnable ADIF-Reset Interrupt Flag
|
||||
ADCSRA = (_BV(ADEN) | _BV(ADSC) | _BV(ADATE) | _BV(ADIF) | ADC_PRESCALE32);
|
||||
|
||||
uint8_t tCount = _BV(aOversampleExponent);
|
||||
for (uint8_t i = 0; i < tCount; i++) {
|
||||
/*
|
||||
* wait for free running conversion to finish.
|
||||
* Do not wait for ADSC here, since ADSC is only low for 1 ADC Clock cycle on free running conversion.
|
||||
*/
|
||||
loop_until_bit_is_set(ADCSRA, ADIF);
|
||||
|
||||
ADCSRA |= _BV(ADIF); // clear bit to enable recognizing next conversion has finished
|
||||
// Add value
|
||||
tSumValue += ADCL | (ADCH << 8); // using WordUnionForADCUtils does not save space here
|
||||
// tSumValue += (ADCH << 8) | ADCL; // this does NOT work!
|
||||
}
|
||||
ADCSRA &= ~_BV(ADATE); // Disable auto-triggering (free running mode)
|
||||
return ((tSumValue + (tCount >> 1)) >> aOversampleExponent);
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns sum of all sample values
|
||||
* Conversion time is defined as 0.104 milliseconds for 16 MHz Arduino by ADC_PRESCALE (=ADC_PRESCALE128) in ADCUtils.h.
|
||||
* @ param aNumberOfSamples If > 64 an overflow may occur.
|
||||
*/
|
||||
uint16_t readADCChannelMultiSamplesWithReference(uint8_t aADCChannelNumber, uint8_t aReference, uint8_t aNumberOfSamples) {
|
||||
uint16_t tSumValue = 0;
|
||||
ADMUX = aADCChannelNumber | (aReference << SHIFT_VALUE_FOR_REFERENCE);
|
||||
|
||||
ADCSRB = 0; // Free running mode. Only active if ADATE is set to 1.
|
||||
// ADSC-StartConversion ADATE-AutoTriggerEnable ADIF-Reset Interrupt Flag
|
||||
ADCSRA = (_BV(ADEN) | _BV(ADSC) | _BV(ADATE) | _BV(ADIF) | ADC_PRESCALE);
|
||||
|
||||
for (uint8_t i = 0; i < aNumberOfSamples; i++) {
|
||||
/*
|
||||
* wait for free running conversion to finish.
|
||||
* Do not wait for ADSC here, since ADSC is only low for 1 ADC Clock cycle on free running conversion.
|
||||
*/
|
||||
loop_until_bit_is_set(ADCSRA, ADIF);
|
||||
|
||||
ADCSRA |= _BV(ADIF); // clear bit to enable recognizing next conversion has finished
|
||||
// Add value
|
||||
tSumValue += ADCL | (ADCH << 8); // using WordUnionForADCUtils does not save space here
|
||||
// tSumValue += (ADCH << 8) | ADCL; // this does NOT work!
|
||||
}
|
||||
ADCSRA &= ~_BV(ADATE); // Disable auto-triggering (free running mode)
|
||||
return tSumValue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns sum of all sample values
|
||||
* Conversion time is defined as 0.104 milliseconds for 16 MHz Arduino for ADC_PRESCALE128 in ADCUtils.h.
|
||||
* @ param aPrescale can be one of ADC_PRESCALE2, ADC_PRESCALE4, 8, 16, 32, 64, 128.
|
||||
* ADC_PRESCALE32 is recommended for excellent linearity and fast readout of 26 microseconds
|
||||
* @ param aNumberOfSamples If > 16k an overflow may occur.
|
||||
*/
|
||||
uint32_t readADCChannelMultiSamplesWithReferenceAndPrescaler(uint8_t aADCChannelNumber, uint8_t aReference, uint8_t aPrescale,
|
||||
uint16_t aNumberOfSamples) {
|
||||
uint32_t tSumValue = 0;
|
||||
ADMUX = aADCChannelNumber | (aReference << SHIFT_VALUE_FOR_REFERENCE);
|
||||
|
||||
ADCSRB = 0; // Free running mode. Only active if ADATE is set to 1.
|
||||
// ADSC-StartConversion ADATE-AutoTriggerEnable ADIF-Reset Interrupt Flag
|
||||
ADCSRA = (_BV(ADEN) | _BV(ADSC) | _BV(ADATE) | _BV(ADIF) | aPrescale);
|
||||
|
||||
for (uint16_t i = 0; i < aNumberOfSamples; i++) {
|
||||
/*
|
||||
* wait for free running conversion to finish.
|
||||
* Do not wait for ADSC here, since ADSC is only low for 1 ADC Clock cycle on free running conversion.
|
||||
*/
|
||||
loop_until_bit_is_set(ADCSRA, ADIF);
|
||||
|
||||
ADCSRA |= _BV(ADIF); // clear bit to enable recognizing next conversion has finished
|
||||
// Add value
|
||||
tSumValue += ADCL | (ADCH << 8); // using WordUnionForADCUtils does not save space here
|
||||
// tSumValue += (ADCH << 8) | ADCL; // this does NOT work!
|
||||
}
|
||||
ADCSRA &= ~_BV(ADATE); // Disable auto-triggering (free running mode)
|
||||
return tSumValue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns sum of all sample values
|
||||
* Assumes, that channel and reference are still set to the right values
|
||||
* @ param aNumberOfSamples If > 16k an overflow may occur.
|
||||
*/
|
||||
uint32_t readADCChannelMultiSamples(uint8_t aPrescale, uint16_t aNumberOfSamples) {
|
||||
uint32_t tSumValue = 0;
|
||||
|
||||
ADCSRB = 0; // Free running mode. Only active if ADATE is set to 1.
|
||||
// ADSC-StartConversion ADATE-AutoTriggerEnable ADIF-Reset Interrupt Flag
|
||||
ADCSRA = (_BV(ADEN) | _BV(ADSC) | _BV(ADATE) | _BV(ADIF) | aPrescale);
|
||||
|
||||
for (uint16_t i = 0; i < aNumberOfSamples; i++) {
|
||||
/*
|
||||
* wait for free running conversion to finish.
|
||||
* Do not wait for ADSC here, since ADSC is only low for 1 ADC Clock cycle on free running conversion.
|
||||
*/
|
||||
loop_until_bit_is_set(ADCSRA, ADIF);
|
||||
|
||||
ADCSRA |= _BV(ADIF); // clear bit to enable recognizing next conversion has finished
|
||||
// Add value
|
||||
tSumValue += ADCL | (ADCH << 8); // using WordUnionForADCUtils does not save space here
|
||||
// tSumValue += (ADCH << 8) | ADCL; // this does NOT work!
|
||||
}
|
||||
ADCSRA &= ~_BV(ADATE); // Disable auto-triggering (free running mode)
|
||||
return tSumValue;
|
||||
}
|
||||
/*
|
||||
* use ADC_PRESCALE32 which gives 26 us conversion time and good linearity
|
||||
* @return the maximum value of aNumberOfSamples samples.
|
||||
*/
|
||||
uint16_t readADCChannelWithReferenceMax(uint8_t aADCChannelNumber, uint8_t aReference, uint16_t aNumberOfSamples) {
|
||||
uint16_t tADCValue = 0;
|
||||
uint16_t tMaximum = 0;
|
||||
ADMUX = aADCChannelNumber | (aReference << SHIFT_VALUE_FOR_REFERENCE);
|
||||
|
||||
ADCSRB = 0; // Free running mode. Only active if ADATE is set to 1.
|
||||
// ADSC-StartConversion ADATE-AutoTriggerEnable ADIF-Reset Interrupt Flag
|
||||
ADCSRA = (_BV(ADEN) | _BV(ADSC) | _BV(ADATE) | _BV(ADIF) | ADC_PRESCALE32);
|
||||
|
||||
for (uint16_t i = 0; i < aNumberOfSamples; i++) {
|
||||
/*
|
||||
* wait for free running conversion to finish.
|
||||
* Do not wait for ADSC here, since ADSC is only low for 1 ADC Clock cycle on free running conversion.
|
||||
*/
|
||||
loop_until_bit_is_set(ADCSRA, ADIF);
|
||||
|
||||
ADCSRA |= _BV(ADIF); // clear bit to enable recognizing next conversion has finished
|
||||
// check value
|
||||
tADCValue = ADCL | (ADCH << 8);
|
||||
if (tADCValue > tMaximum) {
|
||||
tMaximum = tADCValue;
|
||||
}
|
||||
}
|
||||
ADCSRA &= ~_BV(ADATE); // Disable auto-triggering (free running mode)
|
||||
return tMaximum;
|
||||
}
|
||||
|
||||
/*
|
||||
* use ADC_PRESCALE32 which gives 26 us conversion time and good linearity
|
||||
* @return the maximum value during aMicrosecondsToAquire measurement.
|
||||
*/
|
||||
uint16_t readADCChannelWithReferenceMaxMicros(uint8_t aADCChannelNumber, uint8_t aReference, uint16_t aMicrosecondsToAquire) {
|
||||
uint16_t tNumberOfSamples = aMicrosecondsToAquire / 26;
|
||||
return readADCChannelWithReferenceMax(aADCChannelNumber, aReference, tNumberOfSamples);
|
||||
}
|
||||
|
||||
/*
|
||||
* aMaxRetries = 255 -> try forever
|
||||
* @return (tMax + tMin) / 2
|
||||
*/
|
||||
uint16_t readUntil4ConsecutiveValuesAreEqual(uint8_t aADCChannelNumber, uint8_t aReference, uint8_t aDelay,
|
||||
uint8_t aAllowedDifference, uint8_t aMaxRetries) {
|
||||
int tValues[4]; // last value is in tValues[3]
|
||||
int tMin;
|
||||
int tMax;
|
||||
|
||||
/*
|
||||
* Initialize first 4 values before checking
|
||||
*/
|
||||
tValues[0] = readADCChannelWithReference(aADCChannelNumber, aReference);
|
||||
for (int i = 1; i < 4; ++i) {
|
||||
if (aDelay != 0) {
|
||||
delay(aDelay); // Minimum is only 3 delays!
|
||||
}
|
||||
tValues[i] = readADCChannelWithReference(aADCChannelNumber, aReference);
|
||||
}
|
||||
|
||||
do {
|
||||
/*
|
||||
* Get min and max of the last 4 values
|
||||
*/
|
||||
tMin = 1024;
|
||||
tMax = 0;
|
||||
for (uint_fast8_t i = 0; i < 4; ++i) {
|
||||
if (tValues[i] < tMin) {
|
||||
tMin = tValues[i];
|
||||
}
|
||||
if (tValues[i] > tMax) {
|
||||
tMax = tValues[i];
|
||||
}
|
||||
}
|
||||
/*
|
||||
* check for terminating condition
|
||||
*/
|
||||
if ((tMax - tMin) <= aAllowedDifference) {
|
||||
break;
|
||||
} else {
|
||||
/*
|
||||
* Get next value
|
||||
*/
|
||||
// Serial.print("Difference=");
|
||||
// Serial.println(tMax - tMin);
|
||||
// Move values to front
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
tValues[i] = tValues[i + 1];
|
||||
}
|
||||
// and wait before getting next value
|
||||
if (aDelay != 0) {
|
||||
delay(aDelay);
|
||||
}
|
||||
tValues[3] = readADCChannelWithReference(aADCChannelNumber, aReference);
|
||||
}
|
||||
if (aMaxRetries != 255) {
|
||||
aMaxRetries--;
|
||||
}
|
||||
} while (aMaxRetries > 0);
|
||||
|
||||
#if defined(LOCAL_DEBUG)
|
||||
if(aMaxRetries == 0) {
|
||||
Serial.print(F("No 4 equal values for difference "));
|
||||
Serial.print(aAllowedDifference);
|
||||
Serial.print(F(" found "));
|
||||
Serial.print(tValues[0]);
|
||||
Serial.print(' ');
|
||||
Serial.print(tValues[1]);
|
||||
Serial.print(' ');
|
||||
Serial.print(tValues[2]);
|
||||
Serial.print(' ');
|
||||
Serial.println(tValues[3]);
|
||||
} else {
|
||||
Serial.print(aMaxRetries);
|
||||
Serial.println(F(" retries left"));
|
||||
}
|
||||
#endif
|
||||
|
||||
return (tMax + tMin) / 2;
|
||||
}
|
||||
|
||||
/*
|
||||
* !!! Function without handling of switched reference and channel.!!!
|
||||
* Use it ONLY if you only call getVCCVoltageSimple() or getVCCVoltageMillivoltSimple() in your program.
|
||||
* !!! Resolution is only 20 millivolt !!!
|
||||
* Raw reading of 1.1 V is 225 at 5 V.
|
||||
* Raw reading of 1.1 V is 221 at 5.1 V.
|
||||
* Raw reading of 1.1 V is 214 at 5.25 V (+5 %).
|
||||
* Raw reading of 1.1 V is 204 at 5.5 V (+10 %).
|
||||
*/
|
||||
float getVCCVoltageSimple(void) {
|
||||
// use AVCC with (optional) external capacitor at AREF pin as reference
|
||||
float tVCC = readADCChannelMultiSamplesWithReference(ADC_1_1_VOLT_CHANNEL_MUX, DEFAULT, 4);
|
||||
return ((1023 * 1.1 * 4) / tVCC);
|
||||
}
|
||||
|
||||
/*
|
||||
* !!! Function without handling of switched reference and channel.!!!
|
||||
* Use it ONLY if you only call getVCCVoltageSimple() or getVCCVoltageMillivoltSimple() in your program.
|
||||
* !!! Resolution is only 20 millivolt !!!
|
||||
*/
|
||||
uint16_t getVCCVoltageMillivoltSimple(void) {
|
||||
// use AVCC with external capacitor at AREF pin as reference
|
||||
uint16_t tVCC = readADCChannelMultiSamplesWithReference(ADC_1_1_VOLT_CHANNEL_MUX, DEFAULT, 4);
|
||||
return ((1023L * ADC_INTERNAL_REFERENCE_MILLIVOLT * 4) / tVCC);
|
||||
}
|
||||
|
||||
/*
|
||||
* Gets the hypothetical 14 bit reading of VCC using 1.1 volt reference
|
||||
* Similar to getVCCVoltageMillivolt() * 1023 / 1100
|
||||
*/
|
||||
uint16_t getVCCVoltageReadingFor1_1VoltReference(void) {
|
||||
uint16_t tVCC = waitAndReadADCChannelWithReference(ADC_1_1_VOLT_CHANNEL_MUX, DEFAULT);
|
||||
/*
|
||||
* Do not switch back ADMUX to enable checkAndWaitForReferenceAndChannelToSwitch() to work correctly for the next measurement
|
||||
*/
|
||||
return ((1023L * 1023L) / tVCC);
|
||||
}
|
||||
|
||||
/*
|
||||
* !!! Resolution is only 20 millivolt !!!
|
||||
*/
|
||||
float getVCCVoltage(void) {
|
||||
return (getVCCVoltageMillivolt() / 1000.0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Read value of 1.1 volt internal channel using VCC (DEFAULT) as reference.
|
||||
* Handles reference and channel switching by introducing the appropriate delays.
|
||||
* !!! Resolution is only 20 millivolt !!!
|
||||
* Raw reading of 1.1 V is 225 at 5 V.
|
||||
* Raw reading of 1.1 V is 221 at 5.1 V.
|
||||
* Raw reading of 1.1 V is 214 at 5.25 V (+5 %).
|
||||
* Raw reading of 1.1 V is 204 at 5.5 V (+10 %).
|
||||
*/
|
||||
uint16_t getVCCVoltageMillivolt(void) {
|
||||
uint16_t tVCC = waitAndReadADCChannelWithReference(ADC_1_1_VOLT_CHANNEL_MUX, DEFAULT);
|
||||
/*
|
||||
* Do not switch back ADMUX to enable checkAndWaitForReferenceAndChannelToSwitch() to work correctly for the next measurement
|
||||
*/
|
||||
return ((1023L * ADC_INTERNAL_REFERENCE_MILLIVOLT) / tVCC);
|
||||
}
|
||||
|
||||
/*
|
||||
* Does not set sVCCVoltageMillivolt
|
||||
*/
|
||||
uint16_t printVCCVoltageMillivolt(Print *aSerial) {
|
||||
aSerial->print(F("VCC="));
|
||||
uint16_t tVCCVoltageMillivolt = getVCCVoltageMillivolt();
|
||||
aSerial->print(tVCCVoltageMillivolt);
|
||||
aSerial->println(" mV");
|
||||
return tVCCVoltageMillivolt;
|
||||
}
|
||||
|
||||
void readAndPrintVCCVoltageMillivolt(Print *aSerial) {
|
||||
aSerial->print(F("VCC="));
|
||||
sVCCVoltageMillivolt = getVCCVoltageMillivolt();
|
||||
aSerial->print(sVCCVoltageMillivolt);
|
||||
aSerial->println(" mV");
|
||||
}
|
||||
/*
|
||||
* !!! Function without handling of switched reference and channel.!!!
|
||||
* Use it ONLY if you only call getVCCVoltageSimple() or getVCCVoltageMillivoltSimple() in your program.
|
||||
* !!! Resolution is only 20 millivolt !!!
|
||||
*/
|
||||
void readVCCVoltageSimple(void) {
|
||||
// use AVCC with (optional) external capacitor at AREF pin as reference
|
||||
float tVCC = readADCChannelMultiSamplesWithReference(ADC_1_1_VOLT_CHANNEL_MUX, DEFAULT, 4);
|
||||
sVCCVoltage = (1023 * (((float) ADC_INTERNAL_REFERENCE_MILLIVOLT) / 1000) * 4) / tVCC;
|
||||
}
|
||||
|
||||
/*
|
||||
* !!! Function without handling of switched reference and channel.!!!
|
||||
* Use it ONLY if you only call getVCCVoltageSimple() or getVCCVoltageMillivoltSimple() in your program.
|
||||
* !!! Resolution is only 20 millivolt !!!
|
||||
*/
|
||||
void readVCCVoltageMillivoltSimple(void) {
|
||||
// use AVCC with external capacitor at AREF pin as reference
|
||||
uint16_t tVCCVoltageMillivoltRaw = readADCChannelMultiSamplesWithReference(ADC_1_1_VOLT_CHANNEL_MUX, DEFAULT, 4);
|
||||
sVCCVoltageMillivolt = (1023L * ADC_INTERNAL_REFERENCE_MILLIVOLT * 4) / tVCCVoltageMillivoltRaw;
|
||||
}
|
||||
|
||||
/*
|
||||
* !!! Resolution is only 20 millivolt !!!
|
||||
*/
|
||||
void readVCCVoltage(void) {
|
||||
sVCCVoltage = getVCCVoltageMillivolt() / 1000.0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Read value of 1.1 volt internal channel using VCC (DEFAULT) as reference.
|
||||
* Handles reference and channel switching by introducing the appropriate delays.
|
||||
* !!! Resolution is only 20 millivolt !!!
|
||||
* Sets also the sVCCVoltageMillivolt variable.
|
||||
*/
|
||||
void readVCCVoltageMillivolt(void) {
|
||||
uint16_t tVCCVoltageMillivoltRaw = waitAndReadADCChannelWithReference(ADC_1_1_VOLT_CHANNEL_MUX, DEFAULT);
|
||||
/*
|
||||
* Do not switch back ADMUX to enable checkAndWaitForReferenceAndChannelToSwitch() to work correctly for the next measurement
|
||||
*/
|
||||
sVCCVoltageMillivolt = (1023L * ADC_INTERNAL_REFERENCE_MILLIVOLT) / tVCCVoltageMillivoltRaw;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get voltage at ADC channel aADCChannelForVoltageMeasurement
|
||||
* aVCCVoltageMillivolt is assumed as reference voltage
|
||||
*/
|
||||
uint16_t getVoltageMillivolt(uint16_t aVCCVoltageMillivolt, uint8_t aADCChannelForVoltageMeasurement) {
|
||||
uint16_t tInputVoltageRaw = waitAndReadADCChannelWithReference(aADCChannelForVoltageMeasurement, DEFAULT);
|
||||
return (aVCCVoltageMillivolt * (uint32_t) tInputVoltageRaw) / 1023;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get voltage at ADC channel aADCChannelForVoltageMeasurement
|
||||
* Reference voltage VCC is determined just before
|
||||
*/
|
||||
uint16_t getVoltageMillivolt(uint8_t aADCChannelForVoltageMeasurement) {
|
||||
uint16_t tInputVoltageRaw = waitAndReadADCChannelWithReference(aADCChannelForVoltageMeasurement, DEFAULT);
|
||||
return (getVCCVoltageMillivolt() * (uint32_t) tInputVoltageRaw) / 1023;
|
||||
}
|
||||
|
||||
uint16_t getVoltageMillivoltWith_1_1VoltReference(uint8_t aADCChannelForVoltageMeasurement) {
|
||||
uint16_t tInputVoltageRaw = waitAndReadADCChannelWithReference(aADCChannelForVoltageMeasurement, INTERNAL);
|
||||
return (ADC_INTERNAL_REFERENCE_MILLIVOLT * (uint32_t) tInputVoltageRaw) / 1023;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return true if sVCCVoltageMillivolt is > 4.3 V and < 4.95 V
|
||||
*/
|
||||
bool isVCCUSBPowered() {
|
||||
readVCCVoltageMillivolt();
|
||||
return (VOLTAGE_USB_POWERED_LOWER_THRESHOLD_MILLIVOLT < sVCCVoltageMillivolt
|
||||
&& sVCCVoltageMillivolt < VOLTAGE_USB_POWERED_UPPER_THRESHOLD_MILLIVOLT);
|
||||
}
|
||||
|
||||
/*
|
||||
* Return true if sVCCVoltageMillivolt is > 4.3 V and < 4.95 V
|
||||
*/
|
||||
bool isVCCUSBPowered(Print *aSerial) {
|
||||
readVCCVoltageMillivolt();
|
||||
aSerial->print(F("USB powered is "));
|
||||
bool tReturnValue;
|
||||
if (VOLTAGE_USB_POWERED_LOWER_THRESHOLD_MILLIVOLT
|
||||
< sVCCVoltageMillivolt&& sVCCVoltageMillivolt < VOLTAGE_USB_POWERED_UPPER_THRESHOLD_MILLIVOLT) {
|
||||
tReturnValue = true;
|
||||
aSerial->print(F("true "));
|
||||
} else {
|
||||
tReturnValue = false;
|
||||
aSerial->print(F("false "));
|
||||
}
|
||||
printVCCVoltageMillivolt(aSerial);
|
||||
return tReturnValue;
|
||||
}
|
||||
|
||||
/*
|
||||
* @ return true only once, when VCC_UNDERVOLTAGE_CHECKS_BEFORE_STOP (6) times voltage too low -> shutdown
|
||||
*/
|
||||
bool isVCCUndervoltageMultipleTimes() {
|
||||
/*
|
||||
* Check VCC every VCC_CHECK_PERIOD_MILLIS (10) seconds
|
||||
*/
|
||||
|
||||
if (millis() - sLastVCCCheckMillis >= VCC_CHECK_PERIOD_MILLIS) {
|
||||
sLastVCCCheckMillis = millis();
|
||||
|
||||
# if defined(INFO)
|
||||
readAndPrintVCCVoltageMillivolt(&Serial);
|
||||
# else
|
||||
readVCCVoltageMillivolt();
|
||||
# endif
|
||||
|
||||
if (sVCCTooLowCounter < VCC_UNDERVOLTAGE_CHECKS_BEFORE_STOP) {
|
||||
/*
|
||||
* Do not check again if shutdown has happened
|
||||
*/
|
||||
if (sVCCVoltageMillivolt > VCC_UNDERVOLTAGE_THRESHOLD_MILLIVOLT) {
|
||||
sVCCTooLowCounter = 0; // reset counter
|
||||
} else {
|
||||
/*
|
||||
* Voltage too low, wait VCC_UNDERVOLTAGE_CHECKS_BEFORE_STOP (6) times and then shut down.
|
||||
*/
|
||||
if (sVCCVoltageMillivolt < VCC_EMERGENCY_UNDERVOLTAGE_THRESHOLD_MILLIVOLT) {
|
||||
// emergency shutdown
|
||||
sVCCTooLowCounter = VCC_UNDERVOLTAGE_CHECKS_BEFORE_STOP;
|
||||
# if defined(INFO)
|
||||
Serial.println(
|
||||
F(
|
||||
"Voltage < " STR(VCC_EMERGENCY_UNDERVOLTAGE_THRESHOLD_MILLIVOLT) " mV detected -> emergency shutdown"));
|
||||
# endif
|
||||
} else {
|
||||
sVCCTooLowCounter++;
|
||||
# if defined(INFO)
|
||||
Serial.print(F("Voltage < " STR(VCC_UNDERVOLTAGE_THRESHOLD_MILLIVOLT) " mV detected: "));
|
||||
Serial.print(VCC_UNDERVOLTAGE_CHECKS_BEFORE_STOP - sVCCTooLowCounter);
|
||||
Serial.println(F(" tries left"));
|
||||
# endif
|
||||
}
|
||||
if (sVCCTooLowCounter == VCC_UNDERVOLTAGE_CHECKS_BEFORE_STOP) {
|
||||
/*
|
||||
* 6 times voltage too low -> return signal for shutdown etc.
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return true if VCC_EMERGENCY_UNDERVOLTAGE_THRESHOLD_MILLIVOLT (3 V) reached
|
||||
*/
|
||||
bool isVCCUndervoltage() {
|
||||
readVCCVoltageMillivolt();
|
||||
return (sVCCVoltageMillivolt < VCC_UNDERVOLTAGE_THRESHOLD_MILLIVOLT);
|
||||
}
|
||||
|
||||
/*
|
||||
* Return true if VCC_EMERGENCY_UNDERVOLTAGE_THRESHOLD_MILLIVOLT (3 V) reached
|
||||
*/
|
||||
bool isVCCEmergencyUndervoltage() {
|
||||
readVCCVoltageMillivolt();
|
||||
return (sVCCVoltageMillivolt < VCC_EMERGENCY_UNDERVOLTAGE_THRESHOLD_MILLIVOLT);
|
||||
}
|
||||
|
||||
void resetCounterForVCCUndervoltageMultipleTimes() {
|
||||
sVCCTooLowCounter = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Recommended VCC is 1.8 V to 5.5 V, absolute maximum VCC is 6.0 V.
|
||||
* Check for 5.25 V, because such overvoltage is quite unlikely to happen during regular operation.
|
||||
* Raw reading of 1.1 V is 225 at 5 V.
|
||||
* Raw reading of 1.1 V is 221 at 5.1 V.
|
||||
* Raw reading of 1.1 V is 214 at 5.25 V (+5 %).
|
||||
* Raw reading of 1.1 V is 204 at 5.5 V (+10 %).
|
||||
* @return true if 5 % overvoltage reached
|
||||
*/
|
||||
bool isVCCOvervoltage() {
|
||||
readVCCVoltageMillivolt();
|
||||
return (sVCCVoltageMillivolt > VCC_OVERVOLTAGE_THRESHOLD_MILLIVOLT);
|
||||
}
|
||||
bool isVCCOvervoltageSimple() {
|
||||
readVCCVoltageMillivoltSimple();
|
||||
return (sVCCVoltageMillivolt > VCC_OVERVOLTAGE_THRESHOLD_MILLIVOLT);
|
||||
}
|
||||
|
||||
/*
|
||||
* Temperature sensor is enabled by selecting the appropriate channel.
|
||||
* Different formula for 328P and 328PB!
|
||||
* !!! Function without handling of switched reference and channel.!!!
|
||||
* Use it ONLY if you only use INTERNAL reference (e.g. only call getTemperatureSimple()) in your program.
|
||||
*/
|
||||
float getCPUTemperatureSimple(void) {
|
||||
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
|
||||
return 0.0;
|
||||
#else
|
||||
// use internal 1.1 volt as reference. 4 times oversample. Assume the signal has noise, but never verified :-(
|
||||
uint16_t tTempRaw = readADCChannelWithReferenceOversample(ADC_TEMPERATURE_CHANNEL_MUX, INTERNAL, 2);
|
||||
#if defined(LOCAL_DEBUG)
|
||||
Serial.print(F("TempRaw="));
|
||||
Serial.println(tTempRaw);
|
||||
#endif
|
||||
|
||||
#if defined(__AVR_ATmega328PB__)
|
||||
tTempRaw -= 245;
|
||||
return (float)tTempRaw;
|
||||
#else
|
||||
tTempRaw -= 317;
|
||||
return (float) tTempRaw / 1.22;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* Handles usage of 1.1 V reference and channel switching by introducing the appropriate delays.
|
||||
*/
|
||||
float getTemperature(void) {
|
||||
return getCPUTemperature();
|
||||
}
|
||||
float getCPUTemperature(void) {
|
||||
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
|
||||
return 0.0;
|
||||
#else
|
||||
// use internal 1.1 volt as reference
|
||||
checkAndWaitForReferenceAndChannelToSwitch(ADC_TEMPERATURE_CHANNEL_MUX, INTERNAL);
|
||||
return getCPUTemperatureSimple();
|
||||
#endif
|
||||
}
|
||||
|
||||
#else // defined(ADC_UTILS_ARE_AVAILABLE)
|
||||
// Dummy definition of functions defined in ADCUtils to compile examples for non AVR platforms without errors
|
||||
/*
|
||||
* Persistent storage for VCC value
|
||||
*/
|
||||
float sVCCVoltage;
|
||||
uint16_t sVCCVoltageMillivolt;
|
||||
|
||||
uint16_t getVCCVoltageMillivoltSimple(void){
|
||||
return 3300;
|
||||
}
|
||||
|
||||
uint16_t readADCChannelWithReferenceOversample(uint8_t aChannelNumber __attribute__((unused)),
|
||||
uint8_t aReference __attribute__((unused)), uint8_t aOversampleExponent __attribute__((unused))) {
|
||||
return 0;
|
||||
}
|
||||
float getCPUTemperature() {
|
||||
return 20.0;
|
||||
}
|
||||
float getVCCVoltage() {
|
||||
return 3.3;
|
||||
}
|
||||
#endif // defined(ADC_UTILS_ARE_AVAILABLE)
|
||||
|
||||
#if defined(LOCAL_DEBUG)
|
||||
#undef LOCAL_DEBUG
|
||||
#endif
|
||||
#endif // _ADC_UTILS_HPP
|
|
@ -0,0 +1,463 @@
|
|||
/*
|
||||
* AllProtocolsOnLCD.cpp
|
||||
*
|
||||
* Modified ReceiveDemo.cpp with additional 1602 LCD output.
|
||||
* If debug button is pressed (pin connected to ground) a long output is generated.
|
||||
*
|
||||
* This file is part of Arduino-IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
|
||||
*
|
||||
************************************************************************************
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2022-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>
|
||||
|
||||
#include "PinDefinitionsAndMore.h" // Define macros for input and output pin etc.
|
||||
|
||||
#if !defined(RAW_BUFFER_LENGTH)
|
||||
// For air condition remotes it requires 600 (maximum for 2k RAM) to 750. Default is 112 if DECODE_MAGIQUEST is enabled, otherwise 100.
|
||||
# if (defined(RAMEND) && RAMEND <= 0x4FF) || (defined(RAMSIZE) && RAMSIZE < 0x4FF)
|
||||
#define RAW_BUFFER_LENGTH 180
|
||||
# elif (defined(RAMEND) && RAMEND <= 0x8FF) || (defined(RAMSIZE) && RAMSIZE < 0x8FF)
|
||||
#define RAW_BUFFER_LENGTH 600
|
||||
# else
|
||||
#define RAW_BUFFER_LENGTH 750
|
||||
# endif
|
||||
#endif
|
||||
|
||||
//#define NO_LED_FEEDBACK_CODE // saves 92 bytes program memory
|
||||
#if FLASHEND <= 0x1FFF // For 8k flash or less, like ATtiny85. Exclude exotic protocols.
|
||||
#define EXCLUDE_EXOTIC_PROTOCOLS
|
||||
# if !defined(DIGISTUMPCORE) // ATTinyCore is bigger than Digispark core
|
||||
#define EXCLUDE_UNIVERSAL_PROTOCOLS // Saves up to 1000 bytes program memory.
|
||||
# endif
|
||||
#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
|
||||
|
||||
// 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 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.
|
||||
//#define DECODE_NEC // Includes Apple and Onkyo
|
||||
|
||||
#include <IRremote.hpp>
|
||||
|
||||
/*
|
||||
* Activate the type of LCD you use
|
||||
* Default is parallel LCD with 2 rows of 16 characters (1602).
|
||||
* Serial LCD has the disadvantage, that the first repeat is not detected,
|
||||
* because of the long lasting serial communication.
|
||||
*/
|
||||
//#define USE_NO_LCD
|
||||
//#define USE_SERIAL_LCD
|
||||
// Definitions for the 1602 LCD
|
||||
#define LCD_COLUMNS 16
|
||||
#define LCD_ROWS 2
|
||||
|
||||
#if defined(USE_SERIAL_LCD)
|
||||
#include "LiquidCrystal_I2C.h" // Use an up to date library version, which has the init method
|
||||
LiquidCrystal_I2C myLCD(0x27, LCD_COLUMNS, LCD_ROWS); // set the LCD address to 0x27 for a 16 chars and 2 line display
|
||||
#elif !defined(USE_NO_LCD)
|
||||
#define USE_PARALLEL_LCD
|
||||
#include "LiquidCrystal.h"
|
||||
//LiquidCrystal myLCD(4, 5, 6, 7, 8, 9);
|
||||
LiquidCrystal myLCD(7, 8, 3, 4, 5, 6);
|
||||
#endif
|
||||
|
||||
#if defined(USE_PARALLEL_LCD)
|
||||
#define DEBUG_BUTTON_PIN 11 // If low, print timing for each received data set
|
||||
#undef TONE_PIN
|
||||
#define TONE_PIN 9 // Pin 4 is used by LCD
|
||||
#else
|
||||
#define DEBUG_BUTTON_PIN 6
|
||||
#endif
|
||||
#if defined(__AVR_ATmega328P__)
|
||||
#define AUXILIARY_DEBUG_BUTTON_PIN 12 // Is set to low to enable using of a simple connector for enabling debug with pin 11
|
||||
#endif
|
||||
|
||||
#define MILLIS_BETWEEN_ATTENTION_BEEP 60000 // 60 sec
|
||||
uint32_t sMillisOfLastReceivedIRFrame = 0;
|
||||
|
||||
#if defined(USE_SERIAL_LCD) || defined(USE_PARALLEL_LCD)
|
||||
#define USE_LCD
|
||||
# if defined(__AVR__) && defined(ADCSRA) && defined(ADATE)
|
||||
// For cyclically display of VCC and isVCCUSBPowered()
|
||||
#define VOLTAGE_USB_POWERED_LOWER_THRESHOLD_MILLIVOLT 4250
|
||||
#include "ADCUtils.hpp"
|
||||
#define MILLIS_BETWEEN_VOLTAGE_PRINT 5000
|
||||
#define LCD_VOLTAGE_START_INDEX 11
|
||||
uint32_t volatile sMillisOfLastVoltagePrint = 0;
|
||||
bool ProtocolStringOverwritesVoltage = false;
|
||||
# endif
|
||||
#define LCD_IR_COMMAND_START_INDEX 9
|
||||
|
||||
void printsVCCVoltageMillivoltOnLCD();
|
||||
void printIRResultOnLCD();
|
||||
size_t printByteHexOnLCD(uint16_t aHexByteValue);
|
||||
void printSpacesOnLCD(uint_fast8_t aNumberOfSpacesToPrint);
|
||||
|
||||
#endif // defined(USE_SERIAL_LCD) || defined(USE_PARALLEL_LCD)
|
||||
|
||||
void setup() {
|
||||
#if FLASHEND >= 0x3FFF // For 16k flash or more, like ATtiny1604. Code does not fit in program memory of ATtiny85 etc.
|
||||
pinMode(DEBUG_BUTTON_PIN, INPUT_PULLUP);
|
||||
# if defined(AUXILIARY_DEBUG_BUTTON_PIN)
|
||||
pinMode(AUXILIARY_DEBUG_BUTTON_PIN, OUTPUT);
|
||||
digitalWrite(AUXILIARY_DEBUG_BUTTON_PIN, LOW); // To use a simple connector to enable debug
|
||||
# endif
|
||||
#endif
|
||||
|
||||
Serial.begin(115200);
|
||||
#if defined(__AVR_ATmega32U4__) || defined(SERIAL_PORT_USBVIRTUAL) || defined(SERIAL_USB) /*stm32duino*/|| defined(USBCON) /*STM32_stm32*/|| defined(SERIALUSB_PID) || defined(ARDUINO_attiny3217)
|
||||
delay(4000); // To be able to connect Serial monitor after reset or power up and before first print out. Do not wait for an attached Serial Monitor!
|
||||
#endif
|
||||
// Just to know which program is running on my Arduino
|
||||
Serial.println(F("START " __FILE__ " from " __DATE__ "\r\nUsing library version " VERSION_IRREMOTE));
|
||||
|
||||
tone(TONE_PIN, 2200);
|
||||
delay(200);
|
||||
noTone(TONE_PIN);
|
||||
|
||||
// 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)));
|
||||
|
||||
#if defined(USE_SERIAL_LCD)
|
||||
Serial.println(
|
||||
F("With serial LCD connection, the first repeat is not detected, because of the long lasting serial communication!"));
|
||||
#endif
|
||||
|
||||
#if FLASHEND >= 0x3FFF // For 16k flash or more, like ATtiny1604. Code does not fit in program memory of ATtiny85 etc.
|
||||
Serial.println();
|
||||
Serial.print(F("If you connect debug pin "));
|
||||
# if defined(APPLICATION_PIN_STRING)
|
||||
Serial.print(APPLICATION_PIN_STRING);
|
||||
# else
|
||||
Serial.print(DEBUG_BUTTON_PIN);
|
||||
# endif
|
||||
Serial.print(F(" to ground"));
|
||||
# if defined(AUXILIARY_DEBUG_BUTTON_PIN)
|
||||
Serial.print(F(" or to pin "));
|
||||
Serial.print(AUXILIARY_DEBUG_BUTTON_PIN);
|
||||
#endif
|
||||
Serial.println(F(", raw data is always printed"));
|
||||
|
||||
// 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"));
|
||||
#endif
|
||||
|
||||
#if defined(USE_LCD) && defined(ADC_UTILS_ARE_AVAILABLE)
|
||||
readVCCVoltageMillivolt();
|
||||
#endif
|
||||
|
||||
#if defined(USE_SERIAL_LCD)
|
||||
myLCD.init();
|
||||
myLCD.clear();
|
||||
myLCD.backlight(); // Switch backlight LED on
|
||||
#endif
|
||||
#if defined(USE_PARALLEL_LCD)
|
||||
myLCD.begin(LCD_COLUMNS, LCD_ROWS); // This also clears display
|
||||
#endif
|
||||
|
||||
#if defined(USE_LCD)
|
||||
myLCD.setCursor(0, 0);
|
||||
myLCD.print(F("IRRemote v" VERSION_IRREMOTE));
|
||||
myLCD.setCursor(0, 1);
|
||||
myLCD.print(F(__DATE__));
|
||||
#endif
|
||||
|
||||
#if defined(USE_LCD) && defined(ADC_UTILS_ARE_AVAILABLE)
|
||||
readVCCVoltageMillivolt();
|
||||
#endif
|
||||
}
|
||||
|
||||
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();
|
||||
// Print a short summary of received data
|
||||
IrReceiver.printIRResultShort(&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__));
|
||||
#if defined(USE_LCD)
|
||||
myLCD.setCursor(0, 0);
|
||||
myLCD.print(F("Overflow "));
|
||||
#endif
|
||||
|
||||
// see also https://github.com/Arduino-IRremote/Arduino-IRremote#compile-options--macros-for-this-library
|
||||
|
||||
} else {
|
||||
// play tone
|
||||
auto tStartMillis = millis();
|
||||
IrReceiver.stopTimer();
|
||||
tone(TONE_PIN, 2200);
|
||||
|
||||
if ((IrReceiver.decodedIRData.protocol == UNKNOWN || digitalRead(DEBUG_BUTTON_PIN) == LOW)
|
||||
#if defined(USE_LCD) && defined(ADC_UTILS_ARE_AVAILABLE)
|
||||
|| isVCCUSBPowered()
|
||||
#endif
|
||||
) {
|
||||
// Print more info, but only if we are connected to USB, i.e. VCC is > 4300 mV, because this may take to long to detect some fast repeats
|
||||
IrReceiver.printIRSendUsage(&Serial);
|
||||
// IrReceiver.printIRResultRawFormatted(&Serial, false); // print ticks, this is faster :-)
|
||||
IrReceiver.printIRResultRawFormatted(&Serial); // print us, this is better to compare :-)
|
||||
}
|
||||
|
||||
// Guarantee at least 5 millis for tone. decode starts 5 millis (RECORD_GAP_MICROS) after end of frame
|
||||
// so here we are 10 millis after end of frame. Sony20 has only a 12 ms repeat gap.
|
||||
while ((millis() - tStartMillis) < 5)
|
||||
;
|
||||
noTone(TONE_PIN);
|
||||
|
||||
// Restore IR timer. millis() - tStartMillis to compensate for stop of receiver. This enables a correct gap measurement.
|
||||
IrReceiver.restartTimerWithTicksToAdd((millis() - tStartMillis) * (MICROS_IN_ONE_MILLI / MICROS_PER_TICK));
|
||||
|
||||
#if defined(USE_LCD)
|
||||
printIRResultOnLCD();
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* !!!Important!!! Enable receiving of the next value,
|
||||
* since receiving has stopped after the end of the current received data packet.
|
||||
*/
|
||||
IrReceiver.resume();
|
||||
} // if (IrReceiver.decode())
|
||||
|
||||
/*
|
||||
* Check if generating attention beep every minute, after the current measurement was finished
|
||||
*/
|
||||
if ((millis() - sMillisOfLastReceivedIRFrame) >= MILLIS_BETWEEN_ATTENTION_BEEP
|
||||
#if defined(USE_LCD) && defined(ADC_UTILS_ARE_AVAILABLE)
|
||||
&& !isVCCUSBPowered()
|
||||
#endif
|
||||
) {
|
||||
sMillisOfLastReceivedIRFrame = millis();
|
||||
#if defined(USE_LCD) && defined(ADC_UTILS_ARE_AVAILABLE)
|
||||
printsVCCVoltageMillivoltOnLCD();
|
||||
#endif
|
||||
IrReceiver.stopTimer();
|
||||
tone(TONE_PIN, 2200);
|
||||
delay(50);
|
||||
noTone(TONE_PIN);
|
||||
IrReceiver.restartTimerWithTicksToAdd(50 * (MICROS_IN_ONE_MILLI / MICROS_PER_TICK));
|
||||
}
|
||||
|
||||
#if defined(USE_LCD) && defined(ADC_UTILS_ARE_AVAILABLE)
|
||||
//Periodically print VCC
|
||||
if (!ProtocolStringOverwritesVoltage && millis() - sMillisOfLastVoltagePrint > MILLIS_BETWEEN_VOLTAGE_PRINT) {
|
||||
/*
|
||||
* Periodically print VCC
|
||||
*/
|
||||
sMillisOfLastVoltagePrint = millis();
|
||||
readVCCVoltageMillivolt();
|
||||
printsVCCVoltageMillivoltOnLCD();
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#if defined(USE_LCD)
|
||||
void printsVCCVoltageMillivoltOnLCD() {
|
||||
# if defined(ADC_UTILS_ARE_AVAILABLE)
|
||||
char tVoltageString[5];
|
||||
dtostrf(sVCCVoltageMillivolt / 1000.0, 4, 2, tVoltageString);
|
||||
myLCD.setCursor(LCD_VOLTAGE_START_INDEX - 1, 0);
|
||||
myLCD.print(' ');
|
||||
myLCD.print(tVoltageString);
|
||||
myLCD.print('V');
|
||||
# endif
|
||||
}
|
||||
|
||||
/*
|
||||
* LCD output for 1602 LCDs
|
||||
* 40 - 55 Milliseconds per initial output
|
||||
* The expander runs at 100 kHz :-(
|
||||
* 8 milliseconds for 8 bit; 10 ms for 16 bit code output
|
||||
* 3 milliseconds for repeat output
|
||||
*
|
||||
*/
|
||||
void printIRResultOnLCD() {
|
||||
static uint16_t sLastProtocolIndex = 4711;
|
||||
static uint16_t sLastProtocolAddress = 4711;
|
||||
static uint16_t sLastCommand = 0;
|
||||
static uint8_t sLastCommandPrintPosition;
|
||||
|
||||
/*
|
||||
* Print only if protocol has changed
|
||||
*/
|
||||
if (sLastProtocolIndex != IrReceiver.decodedIRData.protocol) {
|
||||
sLastProtocolIndex = IrReceiver.decodedIRData.protocol;
|
||||
/*
|
||||
* Show protocol name and handle overwrite over voltage display
|
||||
*/
|
||||
myLCD.setCursor(0, 0);
|
||||
uint_fast8_t tProtocolStringLength = myLCD.print(getProtocolString(IrReceiver.decodedIRData.protocol));
|
||||
# if defined(__AVR__) && defined(ADCSRA) && defined(ADATE)
|
||||
if (tProtocolStringLength > LCD_VOLTAGE_START_INDEX) {
|
||||
// we overwrite the voltage -> clear rest of line and inhibit new printing of voltage
|
||||
ProtocolStringOverwritesVoltage = true;
|
||||
if (tProtocolStringLength < LCD_COLUMNS) {
|
||||
printSpacesOnLCD(LCD_COLUMNS - tProtocolStringLength);
|
||||
}
|
||||
} else {
|
||||
// Trigger printing of VCC in main loop
|
||||
sMillisOfLastVoltagePrint = 0;
|
||||
ProtocolStringOverwritesVoltage = false;
|
||||
printSpacesOnLCD(LCD_VOLTAGE_START_INDEX - tProtocolStringLength);
|
||||
}
|
||||
# else
|
||||
printSpacesOnLCD(LCD_COLUMNS - tProtocolStringLength);
|
||||
# endif
|
||||
}
|
||||
|
||||
if (IrReceiver.decodedIRData.protocol == UNKNOWN) {
|
||||
/*
|
||||
* Print number of bits received and hash code or microseconds of signal
|
||||
*/
|
||||
myLCD.setCursor(0, 1);
|
||||
uint8_t tNumberOfBits = (IrReceiver.decodedIRData.rawDataPtr->rawlen + 1) / 2;
|
||||
uint_fast8_t tPrintedStringLength = myLCD.print(tNumberOfBits);
|
||||
myLCD.print(F(" bit "));
|
||||
|
||||
if (IrReceiver.decodedIRData.decodedRawData != 0) {
|
||||
if (tNumberOfBits < 10) {
|
||||
myLCD.print('0');
|
||||
tPrintedStringLength++;
|
||||
}
|
||||
myLCD.print('x');
|
||||
tPrintedStringLength += myLCD.print(IrReceiver.decodedIRData.decodedRawData, HEX) + 1;
|
||||
} else {
|
||||
tPrintedStringLength += myLCD.print(IrReceiver.getTotalDurationOfRawData());
|
||||
myLCD.print(F(" \xE4s")); // \xE4 is micro symbol
|
||||
}
|
||||
printSpacesOnLCD(11 - tPrintedStringLength);
|
||||
sLastProtocolAddress = 4711;
|
||||
sLastCommand = 44711;
|
||||
|
||||
} else {
|
||||
/*
|
||||
* Print only if address has changed
|
||||
*/
|
||||
if (sLastProtocolAddress != IrReceiver.decodedIRData.address) {
|
||||
sLastProtocolAddress = IrReceiver.decodedIRData.address;
|
||||
|
||||
myLCD.setCursor(0, 1);
|
||||
/*
|
||||
* Show address
|
||||
*/
|
||||
# if defined(DECODE_DISTANCE_WIDTH)
|
||||
if (IrReceiver.decodedIRData.protocol == PULSE_DISTANCE || IrReceiver.decodedIRData.protocol == PULSE_WIDTH) {
|
||||
myLCD.print(F("[0]=0x"));
|
||||
uint_fast8_t tAddressStringLength = myLCD.print(IrReceiver.decodedIRData.decodedRawDataArray[0], HEX);
|
||||
printSpacesOnLCD(LCD_COLUMNS - tAddressStringLength);
|
||||
sLastCommand = 0; // to trigger restoration of "C=" string
|
||||
return; // no command here
|
||||
} else {
|
||||
# endif
|
||||
myLCD.print(F("A="));
|
||||
uint_fast8_t tAddressStringLength = printByteHexOnLCD(IrReceiver.decodedIRData.address);
|
||||
printSpacesOnLCD((LCD_IR_COMMAND_START_INDEX - 2) - tAddressStringLength);
|
||||
# if defined(DECODE_DISTANCE_WIDTH)
|
||||
}
|
||||
# endif
|
||||
}
|
||||
|
||||
/*
|
||||
* Print command always
|
||||
*/
|
||||
uint16_t tCommand = IrReceiver.decodedIRData.command;
|
||||
|
||||
// Check if prefix position must change
|
||||
if (sLastCommand == 0 || (sLastCommand >= 0x100 && tCommand < 0x100) || (sLastCommand < 0x100 && tCommand >= 0x100)) {
|
||||
sLastCommand = tCommand;
|
||||
/*
|
||||
* Print prefix for 8/16 bit commands
|
||||
*/
|
||||
if (tCommand >= 0x100) {
|
||||
// Do not print "C=" here to have 2 additional characters for command
|
||||
sLastCommandPrintPosition = 9;
|
||||
} else {
|
||||
myLCD.setCursor(LCD_IR_COMMAND_START_INDEX, 1);
|
||||
myLCD.print(F("C="));
|
||||
sLastCommandPrintPosition = 11;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Command data
|
||||
*/
|
||||
myLCD.setCursor(sLastCommandPrintPosition, 1);
|
||||
printByteHexOnLCD(tCommand);
|
||||
|
||||
/*
|
||||
* Show or clear repetition flag
|
||||
*/
|
||||
if (IrReceiver.decodedIRData.flags & (IRDATA_FLAGS_IS_REPEAT)) {
|
||||
myLCD.print('R');
|
||||
return; // Since it is a repetition, printed data has not changed
|
||||
} else {
|
||||
myLCD.print(' ');
|
||||
}
|
||||
} // IrReceiver.decodedIRData.protocol == UNKNOWN
|
||||
}
|
||||
|
||||
size_t printByteHexOnLCD(uint16_t aHexByteValue) {
|
||||
myLCD.print(F("0x"));
|
||||
size_t tPrintSize = 2;
|
||||
if (aHexByteValue < 0x10 || (aHexByteValue > 0x100 && aHexByteValue < 0x1000)) {
|
||||
myLCD.print('0'); // leading 0
|
||||
tPrintSize++;
|
||||
}
|
||||
return myLCD.print(aHexByteValue, HEX) + tPrintSize;
|
||||
}
|
||||
|
||||
void printSpacesOnLCD(uint_fast8_t aNumberOfSpacesToPrint) {
|
||||
for (uint_fast8_t i = 0; i < aNumberOfSpacesToPrint; ++i) {
|
||||
myLCD.print(' ');
|
||||
}
|
||||
}
|
||||
#endif // defined(USE_LCD)
|
|
@ -8,17 +8,17 @@
|
|||
// When the display powers up, it is configured as follows:
|
||||
//
|
||||
// 1. Display clear
|
||||
// 2. Function set:
|
||||
// DL = 1; 8-bit interface data
|
||||
// N = 0; 1-line display
|
||||
// F = 0; 5x8 dot character font
|
||||
// 3. Display on/off control:
|
||||
// D = 0; Display off
|
||||
// C = 0; Cursor off
|
||||
// B = 0; Blinking off
|
||||
// 4. Entry mode set:
|
||||
// I/D = 1; Increment by 1
|
||||
// S = 0; No shift
|
||||
// 2. Function set:
|
||||
// DL = 1; 8-bit interface data
|
||||
// N = 0; 1-line display
|
||||
// F = 0; 5x8 dot character font
|
||||
// 3. Display on/off control:
|
||||
// D = 0; Display off
|
||||
// C = 0; Cursor off
|
||||
// B = 0; Blinking off
|
||||
// 4. Entry mode set:
|
||||
// I/D = 1; Increment by 1
|
||||
// S = 0; No shift
|
||||
//
|
||||
// Note, however, that resetting the Arduino doesn't reset the LCD, so we
|
||||
// can't assume that its in that state when a sketch starts (and the
|
||||
|
@ -57,22 +57,22 @@ void LiquidCrystal::init(uint8_t fourbitmode, uint8_t rs, uint8_t rw, uint8_t en
|
|||
_rs_pin = rs;
|
||||
_rw_pin = rw;
|
||||
_enable_pin = enable;
|
||||
|
||||
|
||||
_data_pins[0] = d0;
|
||||
_data_pins[1] = d1;
|
||||
_data_pins[2] = d2;
|
||||
_data_pins[3] = d3;
|
||||
_data_pins[3] = d3;
|
||||
_data_pins[4] = d4;
|
||||
_data_pins[5] = d5;
|
||||
_data_pins[6] = d6;
|
||||
_data_pins[7] = d7;
|
||||
_data_pins[7] = d7;
|
||||
|
||||
if (fourbitmode)
|
||||
_displayfunction = LCD_4BITMODE | LCD_1LINE | LCD_5x8DOTS;
|
||||
else
|
||||
else
|
||||
_displayfunction = LCD_8BITMODE | LCD_1LINE | LCD_5x8DOTS;
|
||||
|
||||
begin(16, 1);
|
||||
|
||||
begin(16, 1);
|
||||
}
|
||||
|
||||
void LiquidCrystal::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) {
|
||||
|
@ -81,7 +81,7 @@ void LiquidCrystal::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) {
|
|||
}
|
||||
_numlines = lines;
|
||||
|
||||
setRowOffsets(0x00, 0x40, 0x00 + cols, 0x40 + cols);
|
||||
setRowOffsets(0x00, 0x40, 0x00 + cols, 0x40 + cols);
|
||||
|
||||
// for some 1 line displays you can select a 10 pixel high font
|
||||
if ((dotsize != LCD_5x8DOTS) && (lines == 1)) {
|
||||
|
@ -90,28 +90,28 @@ void LiquidCrystal::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) {
|
|||
|
||||
pinMode(_rs_pin, OUTPUT);
|
||||
// we can save 1 pin by not using RW. Indicate by passing 255 instead of pin#
|
||||
if (_rw_pin != 255) {
|
||||
if (_rw_pin != 255) {
|
||||
pinMode(_rw_pin, OUTPUT);
|
||||
}
|
||||
pinMode(_enable_pin, OUTPUT);
|
||||
|
||||
|
||||
// Do these once, instead of every time a character is drawn for speed reasons.
|
||||
for (int i=0; i<((_displayfunction & LCD_8BITMODE) ? 8 : 4); ++i)
|
||||
{
|
||||
pinMode(_data_pins[i], OUTPUT);
|
||||
}
|
||||
}
|
||||
|
||||
// SEE PAGE 45/46 FOR INITIALIZATION SPECIFICATION!
|
||||
// according to datasheet, we need at least 40ms after power rises above 2.7V
|
||||
// before sending commands. Arduino can turn on way before 4.5V so we'll wait 50
|
||||
delayMicroseconds(50000);
|
||||
delayMicroseconds(50000);
|
||||
// Now we pull both RS and R/W low to begin commands
|
||||
digitalWrite(_rs_pin, LOW);
|
||||
digitalWrite(_enable_pin, LOW);
|
||||
if (_rw_pin != 255) {
|
||||
if (_rw_pin != 255) {
|
||||
digitalWrite(_rw_pin, LOW);
|
||||
}
|
||||
|
||||
|
||||
//put the LCD into 4 bit or 8 bit mode
|
||||
if (! (_displayfunction & LCD_8BITMODE)) {
|
||||
// this is according to the hitachi HD44780 datasheet
|
||||
|
@ -124,13 +124,13 @@ void LiquidCrystal::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) {
|
|||
// second try
|
||||
write4bits(0x03);
|
||||
delayMicroseconds(4500); // wait min 4.1ms
|
||||
|
||||
|
||||
// third go!
|
||||
write4bits(0x03);
|
||||
write4bits(0x03);
|
||||
delayMicroseconds(150);
|
||||
|
||||
// finally, set to 4-bit interface
|
||||
write4bits(0x02);
|
||||
write4bits(0x02);
|
||||
} else {
|
||||
// this is according to the hitachi HD44780 datasheet
|
||||
// page 45 figure 23
|
||||
|
@ -148,10 +148,10 @@ void LiquidCrystal::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) {
|
|||
}
|
||||
|
||||
// finally, set # lines, font size, etc.
|
||||
command(LCD_FUNCTIONSET | _displayfunction);
|
||||
command(LCD_FUNCTIONSET | _displayfunction);
|
||||
|
||||
// turn the display on with no cursor or blinking default
|
||||
_displaycontrol = LCD_DISPLAYON | LCD_CURSOROFF | LCD_BLINKOFF;
|
||||
_displaycontrol = LCD_DISPLAYON | LCD_CURSOROFF | LCD_BLINKOFF;
|
||||
display();
|
||||
|
||||
// clear it off
|
||||
|
@ -194,7 +194,7 @@ void LiquidCrystal::setCursor(uint8_t col, uint8_t row)
|
|||
if ( row >= _numlines ) {
|
||||
row = _numlines - 1; // we count rows starting w/0
|
||||
}
|
||||
|
||||
|
||||
command(LCD_SETDDRAMADDR | (col + _row_offsets[row]));
|
||||
}
|
||||
|
||||
|
@ -288,12 +288,12 @@ void LiquidCrystal::send(uint8_t value, uint8_t mode) {
|
|||
digitalWrite(_rs_pin, mode);
|
||||
|
||||
// if there is a RW pin indicated, set it low to Write
|
||||
if (_rw_pin != 255) {
|
||||
if (_rw_pin != 255) {
|
||||
digitalWrite(_rw_pin, LOW);
|
||||
}
|
||||
|
||||
|
||||
if (_displayfunction & LCD_8BITMODE) {
|
||||
write8bits(value);
|
||||
write8bits(value);
|
||||
} else {
|
||||
write4bits(value>>4);
|
||||
write4bits(value);
|
||||
|
@ -302,7 +302,7 @@ void LiquidCrystal::send(uint8_t value, uint8_t mode) {
|
|||
|
||||
void LiquidCrystal::pulseEnable(void) {
|
||||
digitalWrite(_enable_pin, LOW);
|
||||
delayMicroseconds(1);
|
||||
delayMicroseconds(1);
|
||||
digitalWrite(_enable_pin, HIGH);
|
||||
delayMicroseconds(1); // enable pulse must be >450ns
|
||||
digitalWrite(_enable_pin, LOW);
|
||||
|
@ -321,6 +321,6 @@ void LiquidCrystal::write8bits(uint8_t value) {
|
|||
for (int i = 0; i < 8; i++) {
|
||||
digitalWrite(_data_pins[i], (value >> i) & 0x01);
|
||||
}
|
||||
|
||||
|
||||
pulseEnable();
|
||||
}
|
|
@ -58,7 +58,7 @@ public:
|
|||
void init(uint8_t fourbitmode, uint8_t rs, uint8_t rw, uint8_t enable,
|
||||
uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3,
|
||||
uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7);
|
||||
|
||||
|
||||
void begin(uint8_t cols, uint8_t rows, uint8_t charsize = LCD_5x8DOTS);
|
||||
|
||||
void clear();
|
||||
|
@ -79,10 +79,10 @@ public:
|
|||
|
||||
void setRowOffsets(int row1, int row2, int row3, int row4);
|
||||
void createChar(uint8_t, uint8_t[]);
|
||||
void setCursor(uint8_t, uint8_t);
|
||||
void setCursor(uint8_t, uint8_t);
|
||||
virtual size_t write(uint8_t);
|
||||
void command(uint8_t);
|
||||
|
||||
|
||||
using Print::write;
|
||||
private:
|
||||
void send(uint8_t, uint8_t);
|
|
@ -1,20 +1,46 @@
|
|||
// 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"
|
||||
|
||||
#if defined(__AVR__) && !defined(USE_SOFT_I2C_MASTER) && __has_include("SoftI2CMasterConfig.h")
|
||||
#define USE_SOFT_I2C_MASTER // must be before #include "LiquidCrystal_I2C.h"
|
||||
#endif
|
||||
|
||||
#include "LiquidCrystal_I2C.h"
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "Arduino.h"
|
||||
|
||||
inline size_t LiquidCrystal_I2C::write(uint8_t value) {
|
||||
send(value, Rs);
|
||||
return 1;
|
||||
}
|
||||
|
||||
#if defined(USE_SOFT_I2C_MASTER)
|
||||
#define USE_SOFT_I2C_MASTER_H_AS_PLAIN_INCLUDE
|
||||
#include "SoftI2CMaster.h"
|
||||
#else
|
||||
#define printIIC(args) Wire.write(args)
|
||||
//#define USE_SOFT_I2C_MASTER_H_AS_PLAIN_INCLUDE
|
||||
#include "SoftI2CMasterConfig.h" // Include configuration for sources
|
||||
#include "SoftI2CMaster.h" // include sources
|
||||
#elif defined(USE_SOFT_WIRE)
|
||||
#define USE_SOFTWIRE_H_AS_PLAIN_INCLUDE
|
||||
#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:
|
||||
|
@ -63,7 +89,7 @@ void LiquidCrystal_I2C::init_priv() {
|
|||
begin(_cols, _rows);
|
||||
}
|
||||
|
||||
void LiquidCrystal_I2C::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) {
|
||||
void LiquidCrystal_I2C::begin(uint8_t cols __attribute__((unused)), uint8_t lines, uint8_t dotsize) {
|
||||
if (lines > 1) {
|
||||
_displayfunction |= LCD_2LINE;
|
||||
}
|
||||
|
@ -125,7 +151,11 @@ void LiquidCrystal_I2C::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) {
|
|||
/********** 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);
|
||||
}
|
||||
|
@ -261,17 +291,20 @@ void LiquidCrystal_I2C::expanderWrite(uint8_t _data) {
|
|||
i2c_write_byte(_Addr << 1, _data | _backlightval);
|
||||
#else
|
||||
Wire.beginTransmission(_Addr);
|
||||
printIIC((int )(_data) | _backlightval);
|
||||
Wire.write((int )(_data) | _backlightval);
|
||||
Wire.endTransmission();
|
||||
#endif
|
||||
}
|
||||
|
||||
void LiquidCrystal_I2C::pulseEnable(uint8_t _data) {
|
||||
expanderWrite(_data | En); // En high
|
||||
delayMicroseconds(1); // enable pulse must be >450ns
|
||||
|
||||
#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
|
||||
#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
|
|
@ -4,13 +4,8 @@
|
|||
|
||||
#include <inttypes.h>
|
||||
#include "Print.h"
|
||||
#if !defined(USE_SOFT_I2C_MASTER)
|
||||
# if defined(USE_SOFT_WIRE)
|
||||
#define USE_SOFTWIRE_H_AS_PLAIN_INCLUDE
|
||||
#include "SoftWire.h"
|
||||
# else
|
||||
#if !defined(USE_SOFT_I2C_MASTER) && !defined(USE_SOFT_WIRE)
|
||||
#include <Wire.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
// commands
|
||||
|
@ -55,9 +50,9 @@
|
|||
#define LCD_BACKLIGHT 0x08
|
||||
#define LCD_NOBACKLIGHT 0x00
|
||||
|
||||
#define En B00000100 // Enable bit
|
||||
#define Rw B00000010 // Read/Write bit
|
||||
#define Rs B00000001 // Register select bit
|
||||
#define En 0b00000100 // Enable bit
|
||||
#define Rw 0b00000010 // Read/Write bit
|
||||
#define Rs 0b00000001 // Register select bit
|
||||
|
||||
class LiquidCrystal_I2C : public Print {
|
||||
public:
|
|
@ -4,7 +4,7 @@
|
|||
* 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
|
||||
* Copyright (C) 2021-2023 Armin Joachimsmeyer
|
||||
* armin.joachimsmeyer@gmail.com
|
||||
*
|
||||
* This file is part of IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
|
||||
|
@ -16,8 +16,8 @@
|
|||
*
|
||||
* 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.
|
||||
* 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>.
|
||||
|
@ -29,68 +29,99 @@
|
|||
*
|
||||
* Platform IR input IR output Tone Core/Pin schema
|
||||
* --------------------------------------------------------------
|
||||
* DEFAULT/AVR 2 3 4
|
||||
* ATtinyX5 0|PB0 4|PB4 3|PB3
|
||||
* 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 pro
|
||||
* 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
|
||||
* BluePill PA6 PA7 PA3
|
||||
* ESP32 15 4 27
|
||||
* ESP32-C3 6 7 10
|
||||
* 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
|
||||
#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
|
||||
#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
|
||||
#define TONE_PIN 5 // PA7 - on Digispark board labeled as pin 5
|
||||
#define _IR_TIMING_TEST_PIN 10 // PA4
|
||||
# else
|
||||
#define IR_RECEIVE_PIN 3
|
||||
#define IR_SEND_PIN 2
|
||||
#define TONE_PIN 7
|
||||
// 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_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_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_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_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_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
|
||||
# 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
|
||||
#define TONE_PIN 42 // Dummy for examples using it
|
||||
|
||||
# elif defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) \
|
||||
|| defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) \
|
||||
|
@ -123,17 +154,33 @@
|
|||
# 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 13 // D7
|
||||
#define APPLICATION_PIN 0 // D3
|
||||
#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(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>
|
||||
|
||||
|
@ -166,10 +213,13 @@ void noTone(uint8_t aPinNumber){
|
|||
#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
|
||||
|
@ -234,7 +284,7 @@ void noTone(uint8_t aPinNumber){
|
|||
#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)
|
||||
#if !defined(ARDUINO_SAMD_ADAFRUIT) && !defined(ARDUINO_SEEED_XIAO_M0)
|
||||
// On the Zero and others we switch explicitly to SerialUSB
|
||||
#define Serial SerialUSB
|
||||
#endif
|
||||
|
@ -274,13 +324,14 @@ void noTone(uint8_t aPinNumber){
|
|||
#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
|
||||
#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
|
||||
*/
|
|
@ -33,12 +33,13 @@
|
|||
*/
|
||||
#include <Arduino.h>
|
||||
|
||||
#if FLASHEND <= 0x1FFF // For 8k flash or less, like ATtiny85. Exclude exotic protocols.
|
||||
#include "PinDefinitionsAndMore.h" // Define macros for input and output pin etc.
|
||||
|
||||
#if FLASHEND <= 0x1FFF || (defined(RAMEND) && RAMEND <= 0x4FF) || (defined(RAMSIZE) && RAMSIZE < 0x4FF) // For 8k flash or 512 bytes RAM or less, like ATtiny85, ATtiny167
|
||||
#define EXCLUDE_UNIVERSAL_PROTOCOLS // Saves up to 1000 bytes program memory.
|
||||
#define EXCLUDE_EXOTIC_PROTOCOLS
|
||||
#endif
|
||||
|
||||
#include "PinDefinitionsAndMore.h" // Define macros for input and output pin etc.
|
||||
#include <IRremote.hpp>
|
||||
|
||||
#if defined(APPLICATION_PIN)
|
||||
|
@ -90,6 +91,7 @@ void loop() {
|
|||
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);
|
||||
}
|
||||
#else
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* 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
|
||||
* Copyright (C) 2021-2023 Armin Joachimsmeyer
|
||||
* armin.joachimsmeyer@gmail.com
|
||||
*
|
||||
* This file is part of IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
|
||||
|
@ -16,8 +16,8 @@
|
|||
*
|
||||
* 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.
|
||||
* 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>.
|
||||
|
@ -29,68 +29,99 @@
|
|||
*
|
||||
* Platform IR input IR output Tone Core/Pin schema
|
||||
* --------------------------------------------------------------
|
||||
* DEFAULT/AVR 2 3 4
|
||||
* ATtinyX5 0|PB0 4|PB4 3|PB3
|
||||
* 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 pro
|
||||
* 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
|
||||
* BluePill PA6 PA7 PA3
|
||||
* ESP32 15 4 27
|
||||
* ESP32-C3 6 7 10
|
||||
* 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
|
||||
#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
|
||||
#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
|
||||
#define TONE_PIN 5 // PA7 - on Digispark board labeled as pin 5
|
||||
#define _IR_TIMING_TEST_PIN 10 // PA4
|
||||
# else
|
||||
#define IR_RECEIVE_PIN 3
|
||||
#define IR_SEND_PIN 2
|
||||
#define TONE_PIN 7
|
||||
// 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_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_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_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_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_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
|
||||
# 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
|
||||
#define TONE_PIN 42 // Dummy for examples using it
|
||||
|
||||
# elif defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) \
|
||||
|| defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) \
|
||||
|
@ -123,17 +154,33 @@
|
|||
# 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 13 // D7
|
||||
#define APPLICATION_PIN 0 // D3
|
||||
#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(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>
|
||||
|
||||
|
@ -166,10 +213,13 @@ void noTone(uint8_t aPinNumber){
|
|||
#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
|
||||
|
@ -234,7 +284,7 @@ void noTone(uint8_t aPinNumber){
|
|||
#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)
|
||||
#if !defined(ARDUINO_SAMD_ADAFRUIT) && !defined(ARDUINO_SEEED_XIAO_M0)
|
||||
// On the Zero and others we switch explicitly to SerialUSB
|
||||
#define Serial SerialUSB
|
||||
#endif
|
||||
|
@ -274,13 +324,14 @@ void noTone(uint8_t aPinNumber){
|
|||
#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
|
||||
#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
|
||||
*/
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* IRCommandMapping.h
|
||||
* DemoIRCommandMapping.h
|
||||
*
|
||||
* IR remote button codes, strings, and functions to call
|
||||
*
|
||||
* Copyright (C) 2019-2021 Armin Joachimsmeyer
|
||||
* Copyright (C) 2019-2022 Armin Joachimsmeyer
|
||||
* armin.joachimsmeyer@gmail.com
|
||||
*
|
||||
*/
|
||||
|
@ -169,26 +169,25 @@ 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 },
|
||||
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_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 },
|
||||
{ COMMAND_STOP, IR_COMMAND_FLAG_IS_STOP_COMMAND, &doStop, stop },
|
||||
|
||||
/*
|
||||
* 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_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
|
|
@ -5,22 +5,22 @@
|
|||
*
|
||||
* To run this example you need to install the "IRremote" or "IRMP" library under "Tools -> Manage Libraries..." or "Ctrl+Shift+I"
|
||||
*
|
||||
* Copyright (C) 2019-2021 Armin Joachimsmeyer
|
||||
* 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.
|
||||
*
|
||||
* ServoEasing is free software: you can redistribute it and/or modify
|
||||
* 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.
|
||||
* 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>.
|
||||
|
@ -36,17 +36,32 @@
|
|||
*/
|
||||
#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 / non regular) (short) command that can be processed any time and may interrupt other IR commands - used for stop, set direction etc.
|
||||
#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)
|
||||
/*
|
||||
* if this command is received, requestToStopReceived is set until call of next loop.
|
||||
* This stops ongoing commands which use: RDispatcher.delayAndCheckForStop(100); RETURN_IF_STOP;
|
||||
*/
|
||||
#define IR_COMMAND_FLAG_IS_STOP_COMMAND 0x04 // sets requestToStopReceived (to stop other commands)
|
||||
#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;
|
||||
|
@ -54,47 +69,63 @@ struct IRToCommandMappingStruct {
|
|||
|
||||
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.
|
||||
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
|
||||
*/
|
||||
#define COMMAND_EMPTY 0xFE // code no command received
|
||||
#define COMMAND_INVALID 0xFF // code for command received, but not in mapping
|
||||
|
||||
#define RETURN_IF_STOP if (IRDispatcher.requestToStopReceived) return
|
||||
#define BREAK_IF_STOP if (IRDispatcher.requestToStopReceived) break
|
||||
#define DELAY_AND_RETURN_IF_STOP(aDurationMillis) if (IRDispatcher.delayAndCheckForStop(aDurationMillis)) return
|
||||
#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 aCallAlsoBlockingCommands);
|
||||
void checkAndCallCommand(bool aCallBlockingCommandImmediately);
|
||||
|
||||
void printIRCommandString(Print *aSerial);
|
||||
void setRequestToStopReceived(bool aRequestToStopReceived = true);
|
||||
|
||||
uint8_t currentBlockingCommandCalled = COMMAND_INVALID; // The code for the current called command
|
||||
bool executingBlockingCommand = false; // Lock for recursive calls of regular commands
|
||||
#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
|
||||
uint8_t BlockingCommandToRunNext = COMMAND_INVALID; // Storage for command currently suspended to allow the current command to end, before it is called by main loop
|
||||
/*
|
||||
* Flag for running blocking commands to terminate. To check, you can use "if (requestToStopReceived) return;" (available as macro RETURN_IF_STOP).
|
||||
* Is reset by next IR command received. Can be reset by main loop, if command has stopped.
|
||||
* 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;
|
||||
/*
|
||||
* If we have a function, which want to interpret the IR codes by itself e.g. the calibrate function if QuadrupedControl then this flag must be true
|
||||
* 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;
|
||||
|
||||
|
|
|
@ -7,30 +7,38 @@
|
|||
* 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 context!
|
||||
* 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-2021 Armin Joachimsmeyer
|
||||
* 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.
|
||||
*
|
||||
* ServoEasing is free software: you can redistribute it and/or modify
|
||||
* 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.
|
||||
* 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
|
||||
|
||||
|
@ -38,6 +46,10 @@
|
|||
|
||||
#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.
|
||||
|
@ -57,9 +69,6 @@
|
|||
|
||||
IRCommandDispatcher IRDispatcher;
|
||||
|
||||
#if defined(USE_TINY_IR_RECEIVER)
|
||||
#include "TinyIRReceiver.hpp" // included in "IRremote" library
|
||||
|
||||
#if defined(LOCAL_INFO)
|
||||
#define CD_INFO_PRINT(...) Serial.print(__VA_ARGS__);
|
||||
#define CD_INFO_PRINTLN(...) Serial.println(__VA_ARGS__);
|
||||
|
@ -68,38 +77,50 @@ IRCommandDispatcher IRDispatcher;
|
|||
#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();
|
||||
}
|
||||
|
||||
/*
|
||||
* This is the TinyReceiver callback function which is called if a complete command was received
|
||||
* @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(ESP32) || defined(ESP8266)
|
||||
void IRAM_ATTR handleReceivedTinyIRData(uint16_t aAddress, uint8_t aCommand, bool isRepeat)
|
||||
# else
|
||||
void handleReceivedTinyIRData(uint16_t aAddress, uint8_t aCommand, bool isRepeat)
|
||||
# if defined(ESP8266) || defined(ESP32)
|
||||
IRAM_ATTR
|
||||
# endif
|
||||
{
|
||||
IRDispatcher.IRReceivedData.address = aAddress;
|
||||
IRDispatcher.IRReceivedData.command = aCommand;
|
||||
IRDispatcher.IRReceivedData.isRepeat = isRepeat;
|
||||
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();
|
||||
|
||||
CD_INFO_PRINT(F("A=0x"));
|
||||
CD_INFO_PRINT(aAddress, HEX);
|
||||
CD_INFO_PRINT(F(" C=0x"));
|
||||
CD_INFO_PRINT(aCommand, HEX);
|
||||
if (isRepeat) {
|
||||
CD_INFO_PRINT(F("R"));
|
||||
}
|
||||
CD_INFO_PRINTLN();
|
||||
# if defined(LOCAL_INFO)
|
||||
printTinyReceiverResultMinimal(&Serial);
|
||||
# endif
|
||||
|
||||
if (aAddress == IR_ADDRESS) { // IR_ADDRESS is defined in IRCommandMapping.h
|
||||
if (TinyIRReceiverData.Address == IR_ADDRESS) { // IR_ADDRESS is defined in *IRCommandMapping.h
|
||||
IRDispatcher.IRReceivedData.isAvailable = true;
|
||||
if(!IRDispatcher.doNotUseDispatcher) {
|
||||
IRDispatcher.checkAndCallCommand(false); // only short commands are executed directly
|
||||
/*
|
||||
* 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 {
|
||||
|
@ -109,23 +130,21 @@ void handleReceivedTinyIRData(uint16_t aAddress, uint8_t aCommand, bool isRepeat
|
|||
}
|
||||
|
||||
#elif defined(USE_IRMP_LIBRARY)
|
||||
#if !defined(IRMP_USE_COMPLETE_CALLBACK)
|
||||
# if !defined(IRMP_USE_COMPLETE_CALLBACK)
|
||||
# error IRMP_USE_COMPLETE_CALLBACK must be activated for IRMP library
|
||||
#endif
|
||||
# endif
|
||||
|
||||
void IRCommandDispatcher::init() {
|
||||
irmp_init();
|
||||
}
|
||||
|
||||
/*
|
||||
* This is the callback function is called if a complete command was received
|
||||
* This is the callback function, which is called if a complete command was received
|
||||
*/
|
||||
#if defined(ESP32) || defined(ESP8266)
|
||||
void IRAM_ATTR handleReceivedIRData()
|
||||
#else
|
||||
void handleReceivedIRData()
|
||||
#if defined(ESP8266) || defined(ESP32)
|
||||
IRAM_ATTR
|
||||
#endif
|
||||
{
|
||||
void handleReceivedIRData() {
|
||||
IRMP_DATA tTeporaryData;
|
||||
irmp_get_data(&tTeporaryData);
|
||||
IRDispatcher.IRReceivedData.address = tTeporaryData.address;
|
||||
|
@ -143,9 +162,9 @@ void handleReceivedIRData()
|
|||
CD_INFO_PRINTLN();
|
||||
|
||||
// To enable delay() for commands
|
||||
#if !defined(ARDUINO_ARCH_MBED)
|
||||
# if !defined(ARDUINO_ARCH_MBED)
|
||||
interrupts(); // be careful with always executable commands which lasts longer than the IR repeat duration.
|
||||
#endif
|
||||
# endif
|
||||
|
||||
if (IRDispatcher.IRReceivedData.address == IR_ADDRESS) {
|
||||
IRDispatcher.checkAndCallCommand(true);
|
||||
|
@ -154,13 +173,16 @@ void handleReceivedIRData()
|
|||
CD_INFO_PRINTLN(IR_ADDRESS, HEX);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif // elif defined(USE_IRMP_LIBRARY)
|
||||
|
||||
/*
|
||||
* The main dispatcher function
|
||||
* Sets flags justCalledRegularIRCommand, executingBlockingCommand
|
||||
* 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 aCallAlsoBlockingCommands) {
|
||||
void IRCommandDispatcher::checkAndCallCommand(bool aCallBlockingCommandImmediately) {
|
||||
if (IRReceivedData.command == COMMAND_EMPTY) {
|
||||
return;
|
||||
}
|
||||
|
@ -177,7 +199,7 @@ void IRCommandDispatcher::checkAndCallCommand(bool aCallAlsoBlockingCommands) {
|
|||
const __FlashStringHelper *tCommandName = reinterpret_cast<const __FlashStringHelper*>(IRMapping[i].CommandString);
|
||||
#endif
|
||||
/*
|
||||
* Check for repeat and if it is allowed for the current command
|
||||
* 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)
|
||||
|
@ -201,88 +223,73 @@ void IRCommandDispatcher::checkAndCallCommand(bool aCallAlsoBlockingCommands) {
|
|||
}
|
||||
|
||||
/*
|
||||
* Handle stop commands
|
||||
* Execute commands
|
||||
*/
|
||||
if (IRMapping[i].Flags & IR_COMMAND_FLAG_IS_STOP_COMMAND) {
|
||||
requestToStopReceived = true;
|
||||
CD_INFO_PRINTLN(F("Stop command received"));
|
||||
} else {
|
||||
// lets start a new turn
|
||||
requestToStopReceived = false;
|
||||
}
|
||||
|
||||
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);
|
||||
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 {
|
||||
if (!aCallAlsoBlockingCommands) {
|
||||
/*
|
||||
* Blocking command here
|
||||
*/
|
||||
if (aCallBlockingCommandImmediately && currentBlockingCommandCalled == COMMAND_EMPTY) {
|
||||
/*
|
||||
* Store for main loop to execute
|
||||
*/
|
||||
BlockingCommandToRunNext = IRReceivedData.command;
|
||||
requestToStopReceived = true; // to stop running command
|
||||
CD_INFO_PRINT(F("Blocking command "));
|
||||
CD_INFO_PRINT (tCommandName);
|
||||
CD_INFO_PRINTLN(F(" stored as next command and requested stop"));
|
||||
} else {
|
||||
if (executingBlockingCommand) {
|
||||
// Logical error has happened
|
||||
CD_INFO_PRINTLN(
|
||||
F("Request to execute blocking command while another command is running. This should not happen!"));
|
||||
/*
|
||||
* A blocking command may not be called as long as another blocking command is running.
|
||||
* Try to stop again
|
||||
*/
|
||||
BlockingCommandToRunNext = IRReceivedData.command;
|
||||
requestToStopReceived = true; // to stop running command
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* here we are called from main loop and execute a command
|
||||
* Here no blocking command was running and we are called from main loop
|
||||
*/
|
||||
requestToStopReceived = false; // Do not stop the command executed now
|
||||
justCalledBlockingCommand = true;
|
||||
executingBlockingCommand = true; // set lock for recursive calls
|
||||
currentBlockingCommandCalled = IRReceivedData.command;
|
||||
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);
|
||||
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
|
||||
executingBlockingCommand = false;
|
||||
currentBlockingCommandCalled = COMMAND_INVALID;
|
||||
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;
|
||||
}
|
||||
|
||||
/*
|
||||
* 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 (IRDispatcher.requestToStopReceived) {
|
||||
return true;
|
||||
}
|
||||
} while (millis() - tStartMillis < aDelayMillis);
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Intended to be called from main loop
|
||||
* @return true, if command was called
|
||||
|
@ -291,22 +298,52 @@ bool IRCommandDispatcher::checkAndRunSuspendedBlockingCommands() {
|
|||
/*
|
||||
* Take last rejected command and call associated function
|
||||
*/
|
||||
if (BlockingCommandToRunNext != COMMAND_INVALID) {
|
||||
if (BlockingCommandToRunNext != COMMAND_EMPTY) {
|
||||
|
||||
CD_INFO_PRINT(F("Take stored command = 0x"));
|
||||
CD_INFO_PRINT(F("Run stored command=0x"));
|
||||
CD_INFO_PRINTLN(BlockingCommandToRunNext, HEX);
|
||||
|
||||
IRReceivedData.command = BlockingCommandToRunNext;
|
||||
BlockingCommandToRunNext = COMMAND_INVALID;
|
||||
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) {
|
||||
aSerial->print(F("IRCommand="));
|
||||
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));
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
*
|
||||
* 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.
|
||||
* 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>.
|
||||
|
@ -30,7 +30,7 @@
|
|||
* 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 // costs 112 bytes program memory + 4 bytes RAM
|
||||
//#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.
|
||||
// Some kind of auto detect library if USE_TINY_IR_RECEIVER is deactivated
|
||||
|
@ -49,37 +49,11 @@
|
|||
#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.
|
||||
|
||||
/*
|
||||
* Set sensible receive pin for different CPU's
|
||||
*/
|
||||
#if defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__) || defined(__AVR_ATtiny87__) || defined(__AVR_ATtiny167__)
|
||||
#include "ATtinySerialOut.hpp" // Available as Arduino library "ATtinySerialOut"
|
||||
# if defined(ARDUINO_AVR_DIGISPARKPRO)
|
||||
#define IR_INPUT_PIN 9 // PA3 - on Digispark board labeled as pin 9
|
||||
# else
|
||||
#define IR_INPUT_PIN 0 // PCINT0
|
||||
# endif
|
||||
# elif defined(__AVR_ATtiny1616__) || defined(__AVR_ATtiny3216__) || defined(__AVR_ATtiny3217__)
|
||||
#define IR_INPUT_PIN 10
|
||||
# elif (defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__))
|
||||
#define IR_INPUT_PIN 21 // INT0
|
||||
# elif defined(ESP8266)
|
||||
#define IR_INPUT_PIN 14 // D5
|
||||
# elif defined(ESP32)
|
||||
#define IR_INPUT_PIN 15
|
||||
# elif defined(ARDUINO_ARCH_MBED) && defined(ARDUINO_ARCH_MBED_NANO)
|
||||
#define IR_INPUT_PIN 3 // GPIO15 Use pin 3 since pin 2|GPIO25 is connected to LED on Pi pico
|
||||
# elif defined(ARDUINO_ARCH_RP2040) // Pi Pico with arduino-pico core https://github.com/earlephilhower/arduino-pico
|
||||
#define IR_INPUT_PIN 15 // to be compatible with the Arduino Nano RP2040 Connect (pin3)
|
||||
# else
|
||||
#define IR_INPUT_PIN 2 // INT0
|
||||
# endif
|
||||
|
||||
#elif defined(USE_IRMP_LIBRARY)
|
||||
/*
|
||||
* IRMP version
|
||||
*/
|
||||
#define IR_INPUT_PIN 2
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#define IRMP_USE_COMPLETE_CALLBACK 1 // Enable callback functionality. It is required if IRMP library is used.
|
||||
#if defined(ALTERNATIVE_IR_FEEDBACK_LED_PIN)
|
||||
#define FEEDBACK_LED_PIN ALTERNATIVE_IR_FEEDBACK_LED_PIN
|
||||
|
@ -123,7 +97,7 @@ void doTone2200();
|
|||
*/
|
||||
#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 "IRCommandMapping.h" // must be included before IRCommandDispatcher.hpp to define IR_ADDRESS and IRMapping and string "unknown".
|
||||
#include "DemoIRCommandMapping.h" // must be included before IRCommandDispatcher.hpp to define IR_ADDRESS and IRMapping and string "unknown".
|
||||
#include "IRCommandDispatcher.hpp"
|
||||
|
||||
/*
|
||||
|
@ -159,7 +133,7 @@ void setup() {
|
|||
|
||||
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_INPUT_PIN)));
|
||||
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
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* 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
|
||||
* Copyright (C) 2021-2023 Armin Joachimsmeyer
|
||||
* armin.joachimsmeyer@gmail.com
|
||||
*
|
||||
* This file is part of IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
|
||||
|
@ -16,8 +16,8 @@
|
|||
*
|
||||
* 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.
|
||||
* 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>.
|
||||
|
@ -29,68 +29,99 @@
|
|||
*
|
||||
* Platform IR input IR output Tone Core/Pin schema
|
||||
* --------------------------------------------------------------
|
||||
* DEFAULT/AVR 2 3 4
|
||||
* ATtinyX5 0|PB0 4|PB4 3|PB3
|
||||
* 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 pro
|
||||
* 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
|
||||
* BluePill PA6 PA7 PA3
|
||||
* ESP32 15 4 27
|
||||
* ESP32-C3 6 7 10
|
||||
* 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
|
||||
#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
|
||||
#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
|
||||
#define TONE_PIN 5 // PA7 - on Digispark board labeled as pin 5
|
||||
#define _IR_TIMING_TEST_PIN 10 // PA4
|
||||
# else
|
||||
#define IR_RECEIVE_PIN 3
|
||||
#define IR_SEND_PIN 2
|
||||
#define TONE_PIN 7
|
||||
// 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_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_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_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_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_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
|
||||
# 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
|
||||
#define TONE_PIN 42 // Dummy for examples using it
|
||||
|
||||
# elif defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) \
|
||||
|| defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) \
|
||||
|
@ -123,17 +154,33 @@
|
|||
# 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 13 // D7
|
||||
#define APPLICATION_PIN 0 // D3
|
||||
#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(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>
|
||||
|
||||
|
@ -166,10 +213,13 @@ void noTone(uint8_t aPinNumber){
|
|||
#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
|
||||
|
@ -234,7 +284,7 @@ void noTone(uint8_t aPinNumber){
|
|||
#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)
|
||||
#if !defined(ARDUINO_SAMD_ADAFRUIT) && !defined(ARDUINO_SEEED_XIAO_M0)
|
||||
// On the Zero and others we switch explicitly to SerialUSB
|
||||
#define Serial SerialUSB
|
||||
#endif
|
||||
|
@ -274,13 +324,14 @@ void noTone(uint8_t aPinNumber){
|
|||
#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
|
||||
#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
|
||||
*/
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
************************************************************************************
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2021 Armin Joachimsmeyer
|
||||
* 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
|
||||
|
@ -31,11 +31,34 @@
|
|||
*/
|
||||
#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 600 (maximum for 2k RAM) to 750. Default is 112 if DECODE_MAGIQUEST is enabled, otherwise 100.
|
||||
# if (defined(RAMEND) && RAMEND <= 0x4FF) || (defined(RAMSIZE) && RAMSIZE < 0x4FF)
|
||||
#define RAW_BUFFER_LENGTH 180
|
||||
# elif (defined(RAMEND) && RAMEND <= 0x8FF) || (defined(RAMSIZE) && RAMSIZE < 0x8FF)
|
||||
#define RAW_BUFFER_LENGTH 600
|
||||
# else
|
||||
#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();
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
************************************************************************************
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2021 Armin Joachimsmeyer
|
||||
* 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
|
||||
|
@ -39,6 +39,8 @@ class IRExtensionClass
|
|||
public:
|
||||
IRrecv * MyIrReceiver;
|
||||
IRExtensionClass(IRrecv * aIrReceiver);
|
||||
bool decode();
|
||||
bool printIRResultShort(Print *aSerial, bool aPrintRepeatGap = true, bool aCheckForRecordGapsMicros = true);
|
||||
void resume();
|
||||
};
|
||||
|
||||
|
|
|
@ -1,18 +1,48 @@
|
|||
/*
|
||||
* 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 RAMEND <= 0x4FF || (defined(RAMSIZE) && RAMSIZE < 0x4FF)
|
||||
#define RAW_BUFFER_LENGTH 180 // 750 (600 if we have only 2k RAM) is the value for air condition remotes. Default is 112 if DECODE_MAGIQUEST is enabled, otherwise 100.
|
||||
#elif RAMEND <= 0x8FF || (defined(RAMSIZE) && RAMSIZE < 0x8FF)
|
||||
#define RAW_BUFFER_LENGTH 500 // 750 (600 if we have only 2k RAM) is the value for air condition remotes. Default is 112 if DECODE_MAGIQUEST is enabled, otherwise 100.
|
||||
#else
|
||||
#define RAW_BUFFER_LENGTH 750 // 750 (600 if we have only 2k RAM) is the value for air condition remotes. Default is 112 if DECODE_MAGIQUEST is enabled, otherwise 100.
|
||||
#include "PinDefinitionsAndMore.h" // Define macros for input and output pin etc.
|
||||
|
||||
#if !defined(RAW_BUFFER_LENGTH)
|
||||
// For air condition remotes it requires 600 (maximum for 2k RAM) to 750. Default is 112 if DECODE_MAGIQUEST is enabled, otherwise 100.
|
||||
# if (defined(RAMEND) && RAMEND <= 0x4FF) || (defined(RAMSIZE) && RAMSIZE < 0x4FF)
|
||||
#define RAW_BUFFER_LENGTH 180
|
||||
# elif (defined(RAMEND) && RAMEND <= 0x8FF) || (defined(RAMSIZE) && RAMSIZE < 0x8FF)
|
||||
#define RAW_BUFFER_LENGTH 600
|
||||
# else
|
||||
#define RAW_BUFFER_LENGTH 750
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include "PinDefinitionsAndMore.h" // Define macros for input and output pin etc.
|
||||
#include <IRremote.hpp>
|
||||
|
||||
#include "IRremoteExtensionClass.h"
|
||||
|
@ -41,10 +71,10 @@ void setup() {
|
|||
}
|
||||
|
||||
void loop() {
|
||||
if (IrReceiver.decode()) {
|
||||
IrReceiver.printIRResultShort(&Serial);
|
||||
if (IRExtension.decode()) {
|
||||
IRExtension.printIRResultShort(&Serial);
|
||||
IrReceiver.printIRSendUsage(&Serial);
|
||||
IRExtension.resume(); // Use the extended function
|
||||
IRExtension.resume(); // Use the extended function provided by IRExtension class
|
||||
}
|
||||
delay(100);
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* 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
|
||||
* Copyright (C) 2021-2023 Armin Joachimsmeyer
|
||||
* armin.joachimsmeyer@gmail.com
|
||||
*
|
||||
* This file is part of IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
|
||||
|
@ -16,8 +16,8 @@
|
|||
*
|
||||
* 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.
|
||||
* 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>.
|
||||
|
@ -29,68 +29,99 @@
|
|||
*
|
||||
* Platform IR input IR output Tone Core/Pin schema
|
||||
* --------------------------------------------------------------
|
||||
* DEFAULT/AVR 2 3 4
|
||||
* ATtinyX5 0|PB0 4|PB4 3|PB3
|
||||
* 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 pro
|
||||
* 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
|
||||
* BluePill PA6 PA7 PA3
|
||||
* ESP32 15 4 27
|
||||
* ESP32-C3 6 7 10
|
||||
* 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
|
||||
#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
|
||||
#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
|
||||
#define TONE_PIN 5 // PA7 - on Digispark board labeled as pin 5
|
||||
#define _IR_TIMING_TEST_PIN 10 // PA4
|
||||
# else
|
||||
#define IR_RECEIVE_PIN 3
|
||||
#define IR_SEND_PIN 2
|
||||
#define TONE_PIN 7
|
||||
// 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_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_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_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_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_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
|
||||
# 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
|
||||
#define TONE_PIN 42 // Dummy for examples using it
|
||||
|
||||
# elif defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) \
|
||||
|| defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) \
|
||||
|
@ -123,17 +154,33 @@
|
|||
# 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 13 // D7
|
||||
#define APPLICATION_PIN 0 // D3
|
||||
#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(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>
|
||||
|
||||
|
@ -166,10 +213,13 @@ void noTone(uint8_t aPinNumber){
|
|||
#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
|
||||
|
@ -234,7 +284,7 @@ void noTone(uint8_t aPinNumber){
|
|||
#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)
|
||||
#if !defined(ARDUINO_SAMD_ADAFRUIT) && !defined(ARDUINO_SEEED_XIAO_M0)
|
||||
// On the Zero and others we switch explicitly to SerialUSB
|
||||
#define Serial SerialUSB
|
||||
#endif
|
||||
|
@ -274,13 +324,14 @@ void noTone(uint8_t aPinNumber){
|
|||
#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
|
||||
#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
|
||||
*/
|
||||
|
|
|
@ -296,6 +296,13 @@ void dumpProtocols() {
|
|||
|
||||
#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"));
|
||||
|
@ -310,6 +317,12 @@ void dumpProtocols() {
|
|||
Serial.println(F("Disabled"));
|
||||
#endif
|
||||
|
||||
Serial.print(F("FAST: "));
|
||||
#if defined(DECODE_FAST)
|
||||
Serial.println(F("Enabled"));
|
||||
#else
|
||||
Serial.println(F("Disabled"));
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -64,25 +64,26 @@
|
|||
*/
|
||||
#include <Arduino.h>
|
||||
|
||||
#if RAMEND <= 0x4FF || (defined(RAMSIZE) && RAMSIZE < 0x4FF)
|
||||
#define RAW_BUFFER_LENGTH 180 // 750 (600 if we have only 2k RAM) is the value for air condition remotes. Default is 112 if DECODE_MAGIQUEST is enabled, otherwise 100.
|
||||
#elif RAMEND <= 0x8FF || (defined(RAMSIZE) && RAMSIZE < 0x8FF)
|
||||
#define RAW_BUFFER_LENGTH 500 // 750 (600 if we have only 2k RAM) is the value for air condition remotes. Default is 112 if DECODE_MAGIQUEST is enabled, otherwise 100.
|
||||
#else
|
||||
#define RAW_BUFFER_LENGTH 750 // 750 (600 if we have only 2k RAM) is the value for air condition remotes. Default is 112 if DECODE_MAGIQUEST is enabled, otherwise 100.
|
||||
#endif
|
||||
#include "PinDefinitionsAndMore.h" // Define macros for input and output pin etc.
|
||||
|
||||
// Change the following two entries if desired
|
||||
#if !defined(RAW_BUFFER_LENGTH)
|
||||
// For air condition remotes it requires 600 (maximum for 2k RAM) to 750. Default is 112 if DECODE_MAGIQUEST is enabled, otherwise 100.
|
||||
# if (defined(RAMEND) && RAMEND <= 0x4FF) || (defined(RAMSIZE) && RAMSIZE < 0x4FF)
|
||||
#define RAW_BUFFER_LENGTH 180
|
||||
# elif (defined(RAMEND) && RAMEND <= 0x8FF) || (defined(RAMSIZE) && RAMSIZE < 0x8FF)
|
||||
#define RAW_BUFFER_LENGTH 600
|
||||
# else
|
||||
#define RAW_BUFFER_LENGTH 750
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/**
|
||||
* 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>
|
||||
|
||||
|
@ -316,7 +317,11 @@ void setup() {
|
|||
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
|
||||
#if defined(IR_SEND_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
|
||||
#else
|
||||
IrSender.begin(3, ENABLE_LED_FEEDBACK, USE_DEFAULT_FEEDBACK_LED_PIN); // Specify send pin and enable feedback LED at default feedback LED pin
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* 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
|
||||
* Copyright (C) 2021-2023 Armin Joachimsmeyer
|
||||
* armin.joachimsmeyer@gmail.com
|
||||
*
|
||||
* This file is part of IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
|
||||
|
@ -16,8 +16,8 @@
|
|||
*
|
||||
* 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.
|
||||
* 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>.
|
||||
|
@ -29,68 +29,99 @@
|
|||
*
|
||||
* Platform IR input IR output Tone Core/Pin schema
|
||||
* --------------------------------------------------------------
|
||||
* DEFAULT/AVR 2 3 4
|
||||
* ATtinyX5 0|PB0 4|PB4 3|PB3
|
||||
* 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 pro
|
||||
* 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
|
||||
* BluePill PA6 PA7 PA3
|
||||
* ESP32 15 4 27
|
||||
* ESP32-C3 6 7 10
|
||||
* 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
|
||||
#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
|
||||
#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
|
||||
#define TONE_PIN 5 // PA7 - on Digispark board labeled as pin 5
|
||||
#define _IR_TIMING_TEST_PIN 10 // PA4
|
||||
# else
|
||||
#define IR_RECEIVE_PIN 3
|
||||
#define IR_SEND_PIN 2
|
||||
#define TONE_PIN 7
|
||||
// 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_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_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_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_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_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
|
||||
# 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
|
||||
#define TONE_PIN 42 // Dummy for examples using it
|
||||
|
||||
# elif defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) \
|
||||
|| defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) \
|
||||
|
@ -123,17 +154,33 @@
|
|||
# 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 13 // D7
|
||||
#define APPLICATION_PIN 0 // D3
|
||||
#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(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>
|
||||
|
||||
|
@ -166,10 +213,13 @@ void noTone(uint8_t aPinNumber){
|
|||
#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
|
||||
|
@ -234,7 +284,7 @@ void noTone(uint8_t aPinNumber){
|
|||
#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)
|
||||
#if !defined(ARDUINO_SAMD_ADAFRUIT) && !defined(ARDUINO_SEEED_XIAO_M0)
|
||||
// On the Zero and others we switch explicitly to SerialUSB
|
||||
#define Serial SerialUSB
|
||||
#endif
|
||||
|
@ -274,13 +324,14 @@ void noTone(uint8_t aPinNumber){
|
|||
#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
|
||||
#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
|
||||
*/
|
||||
|
|
|
@ -1,152 +0,0 @@
|
|||
/*
|
||||
* MinimalReceiver.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, bool isRepetition)
|
||||
* 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.
|
||||
* !!!!!!!!!!!!!!!!!!!!!
|
||||
*
|
||||
*
|
||||
* Copyright (C) 2020-2022 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.
|
||||
*
|
||||
* MinimalReceiver 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>
|
||||
|
||||
/*
|
||||
* Set sensible receive pin for different CPU's
|
||||
*/
|
||||
#if defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__) || defined(__AVR_ATtiny87__) || defined(__AVR_ATtiny167__)
|
||||
#include "ATtinySerialOut.hpp" // Available as Arduino library "ATtinySerialOut"
|
||||
# if defined(ARDUINO_AVR_DIGISPARKPRO)
|
||||
#define IR_INPUT_PIN 9 // PA3 - on Digispark board labeled as pin 9
|
||||
# else
|
||||
#define IR_INPUT_PIN 0 // PCINT0
|
||||
# endif
|
||||
#elif defined(__AVR_ATtiny1616__) || defined(__AVR_ATtiny3216__) || defined(__AVR_ATtiny3217__)
|
||||
#define IR_INPUT_PIN 10
|
||||
#elif (defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__))
|
||||
#define IR_INPUT_PIN 21 // INT0
|
||||
#elif defined(ESP8266)
|
||||
#define IR_INPUT_PIN 14 // D5
|
||||
#elif defined(ESP32)
|
||||
#define IR_INPUT_PIN 15
|
||||
#elif defined(ARDUINO_ARCH_MBED) && defined(ARDUINO_ARCH_MBED_NANO)
|
||||
#define IR_INPUT_PIN 3 // GPIO15 Use pin 3 since pin 2|GPIO25 is connected to LED on Pi pico
|
||||
#elif defined(ARDUINO_ARCH_RP2040) // Pi Pico with arduino-pico core https://github.com/earlephilhower/arduino-pico
|
||||
#define IR_INPUT_PIN 15 // to be compatible with the Arduino Nano RP2040 Connect (pin3)
|
||||
#else
|
||||
#define IR_INPUT_PIN 2 // INT0
|
||||
//#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.
|
||||
#endif
|
||||
|
||||
//#define DEBUG // to see if attachInterrupt is used
|
||||
//#define TRACE // to see the state of the ISR state machine
|
||||
|
||||
/*
|
||||
* Second: include the code and compile it.
|
||||
*/
|
||||
#include "TinyIRReceiver.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
|
||||
|
||||
volatile struct TinyIRReceiverCallbackDataStruct sCallbackData;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
#if defined(__AVR_ATmega32U4__) || defined(SERIAL_PORT_USBVIRTUAL) || defined(SERIAL_USB) /*stm32duino*/|| defined(USBCON) /*STM32_stm32*/|| defined(SERIALUSB_PID) || defined(ARDUINO_attiny3217)
|
||||
delay(4000); // To be able to connect Serial monitor after reset or power up and before first print out. Do not wait for an attached Serial Monitor!
|
||||
#endif
|
||||
// Just to know which program is running on my Arduino
|
||||
#if defined(ESP8266)
|
||||
Serial.println();
|
||||
#endif
|
||||
Serial.println(F("START " __FILE__ " from " __DATE__));
|
||||
if(!initPCIInterruptForTinyReceiver()){
|
||||
Serial.println(F("No interrupt available for pin " STR(IR_INPUT_PIN))); // optimized out by the compiler, if not required :-)
|
||||
}
|
||||
Serial.println(F("Ready to receive NEC IR signals at pin " STR(IR_INPUT_PIN)));
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
if (sCallbackData.justWritten)
|
||||
{
|
||||
sCallbackData.justWritten = false;
|
||||
Serial.print(F("Address=0x"));
|
||||
Serial.print(sCallbackData.Address, HEX);
|
||||
Serial.print(F(" Command=0x"));
|
||||
Serial.print(sCallbackData.Command, HEX);
|
||||
if (sCallbackData.isRepeat)
|
||||
{
|
||||
Serial.print(F(" Repeat"));
|
||||
}
|
||||
Serial.println();
|
||||
}
|
||||
/*
|
||||
* Put your code here
|
||||
*/
|
||||
}
|
||||
|
||||
/*
|
||||
* This is the function is called if a complete command was received
|
||||
* It runs in an ISR context with interrupts enabled, so functions like delay() etc. are working here
|
||||
*/
|
||||
#if defined(ESP8266) || defined(ESP32)
|
||||
void IRAM_ATTR handleReceivedTinyIRData(uint16_t aAddress, uint8_t aCommand, bool isRepeat)
|
||||
#else
|
||||
void handleReceivedTinyIRData(uint16_t aAddress, uint8_t aCommand, bool isRepeat)
|
||||
#endif
|
||||
{
|
||||
|
||||
#if defined(ARDUINO_ARCH_MBED) || defined(ESP32)
|
||||
// Copy data for main loop, this is the recommended way for handling a callback :-)
|
||||
sCallbackData.Address = aAddress;
|
||||
sCallbackData.Command = aCommand;
|
||||
sCallbackData.isRepeat = isRepeat;
|
||||
sCallbackData.justWritten = true;
|
||||
#else
|
||||
/*
|
||||
* This is not allowed in ISR context for any kind of RTOS
|
||||
* For Mbed we get a kernel panic and "Error Message: Semaphore: 0x0, Not allowed in ISR context" for Serial.print()
|
||||
* for ESP32 we get a "Guru Meditation Error: Core 1 panic'ed" (we also have an RTOS running!)
|
||||
*/
|
||||
// Print only very short output, since we are in an interrupt context and do not want to miss the next interrupts of the repeats coming soon
|
||||
Serial.print(F("A=0x"));
|
||||
Serial.print(aAddress, HEX);
|
||||
Serial.print(F(" C=0x"));
|
||||
Serial.print(aCommand, HEX);
|
||||
Serial.print(F(" R="));
|
||||
Serial.print(isRepeat);
|
||||
Serial.println();
|
||||
#endif
|
||||
}
|
|
@ -4,7 +4,7 @@
|
|||
* 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
|
||||
* Copyright (C) 2021-2023 Armin Joachimsmeyer
|
||||
* armin.joachimsmeyer@gmail.com
|
||||
*
|
||||
* This file is part of IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
|
||||
|
@ -16,8 +16,8 @@
|
|||
*
|
||||
* 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.
|
||||
* 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>.
|
||||
|
@ -29,68 +29,99 @@
|
|||
*
|
||||
* Platform IR input IR output Tone Core/Pin schema
|
||||
* --------------------------------------------------------------
|
||||
* DEFAULT/AVR 2 3 4
|
||||
* ATtinyX5 0|PB0 4|PB4 3|PB3
|
||||
* 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 pro
|
||||
* 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
|
||||
* BluePill PA6 PA7 PA3
|
||||
* ESP32 15 4 27
|
||||
* ESP32-C3 6 7 10
|
||||
* 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
|
||||
#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
|
||||
#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
|
||||
#define TONE_PIN 5 // PA7 - on Digispark board labeled as pin 5
|
||||
#define _IR_TIMING_TEST_PIN 10 // PA4
|
||||
# else
|
||||
#define IR_RECEIVE_PIN 3
|
||||
#define IR_SEND_PIN 2
|
||||
#define TONE_PIN 7
|
||||
// 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_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_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_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_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_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
|
||||
# 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
|
||||
#define TONE_PIN 42 // Dummy for examples using it
|
||||
|
||||
# elif defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) \
|
||||
|| defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) \
|
||||
|
@ -123,17 +154,33 @@
|
|||
# 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 13 // D7
|
||||
#define APPLICATION_PIN 0 // D3
|
||||
#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(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>
|
||||
|
||||
|
@ -166,10 +213,13 @@ void noTone(uint8_t aPinNumber){
|
|||
#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
|
||||
|
@ -234,7 +284,7 @@ void noTone(uint8_t aPinNumber){
|
|||
#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)
|
||||
#if !defined(ARDUINO_SAMD_ADAFRUIT) && !defined(ARDUINO_SEEED_XIAO_M0)
|
||||
// On the Zero and others we switch explicitly to SerialUSB
|
||||
#define Serial SerialUSB
|
||||
#endif
|
||||
|
@ -274,13 +324,14 @@ void noTone(uint8_t aPinNumber){
|
|||
#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
|
||||
#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
|
||||
*/
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
* 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.
|
||||
*
|
||||
|
@ -13,6 +14,7 @@
|
|||
* 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
|
||||
*
|
||||
|
@ -21,7 +23,7 @@
|
|||
************************************************************************************
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2009-2021 Ken Shirriff, Armin Joachimsmeyer
|
||||
* 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
|
||||
|
@ -44,45 +46,62 @@
|
|||
*/
|
||||
#include <Arduino.h>
|
||||
|
||||
#include "PinDefinitionsAndMore.h" // Define macros for input and output pin etc.
|
||||
|
||||
/*
|
||||
* Specify which protocol(s) should be used for decoding.
|
||||
* If no protocol is defined, all protocols are active.
|
||||
* 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
|
||||
//#define DECODE_DISTANCE
|
||||
// etc. see IRremote.hpp
|
||||
#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 RAMEND <= 0x4FF || (defined(RAMSIZE) && RAMSIZE < 0x4FF)
|
||||
#define RAW_BUFFER_LENGTH 120
|
||||
#elif RAMEND <= 0xAFF || (defined(RAMSIZE) && RAMSIZE < 0xAFF) // 0xAFF for LEONARDO
|
||||
#define RAW_BUFFER_LENGTH 500 // 600 is too much here, because we have additional uint8_t rawCode[RAW_BUFFER_LENGTH];
|
||||
#else
|
||||
#if !defined(RAW_BUFFER_LENGTH)
|
||||
// For air condition remotes it requires 600 (maximum for 2k RAM) to 750. Default is 112 if DECODE_MAGIQUEST is enabled, otherwise 100.
|
||||
# if (defined(RAMEND) && RAMEND <= 0x4FF) || (defined(RAMSIZE) && RAMSIZE < 0x4FF)
|
||||
#define RAW_BUFFER_LENGTH 120 // 180 is too much here, because we have additional uint8_t rawCode[RAW_BUFFER_LENGTH];
|
||||
# elif (defined(RAMEND) && RAMEND <= 0x8FF) || (defined(RAMSIZE) && RAMSIZE < 0x8FF)
|
||||
#define RAW_BUFFER_LENGTH 400 // 600 is too much here, because we have additional uint8_t rawCode[RAW_BUFFER_LENGTH];
|
||||
# elif (defined(RAMEND) && RAMEND <= 0xAFF) || (defined(RAMSIZE) && RAMSIZE < 0xAFF)
|
||||
#define RAW_BUFFER_LENGTH 500 // 750 is too much here, because we have additional uint8_t rawCode[RAW_BUFFER_LENGTH];
|
||||
# else
|
||||
#define RAW_BUFFER_LENGTH 750
|
||||
# endif
|
||||
#endif
|
||||
|
||||
//#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 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.
|
||||
//#define MARK_EXCESS_MICROS 20 // 20 is recommended for the cheap VS1838 modules
|
||||
|
||||
//#define RECORD_GAP_MICROS 12000 // Activate it for some LG air conditioner protocols
|
||||
// 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.
|
||||
|
||||
#include "PinDefinitionsAndMore.h" // Define macros for input and output pin etc.
|
||||
#include <IRremote.hpp>
|
||||
|
||||
int SEND_BUTTON_PIN = APPLICATION_PIN;
|
||||
int STATUS_PIN = LED_BUILTIN;
|
||||
|
||||
int DELAY_BETWEEN_REPEAT = 50;
|
||||
int DEFAULT_NUMBER_OF_REPEATS_TO_SEND = 3;
|
||||
|
||||
// Storage for the recorded code
|
||||
struct storedIRDataStruct {
|
||||
|
@ -92,12 +111,14 @@ struct storedIRDataStruct {
|
|||
uint8_t rawCodeLength; // The length of the code
|
||||
} sStoredIRData;
|
||||
|
||||
int lastButtonState;
|
||||
bool sSendButtonWasActive;
|
||||
|
||||
void storeCode(IRData *aIRReceivedData);
|
||||
void storeCode();
|
||||
void sendCode(storedIRDataStruct *aIRDataToSend);
|
||||
|
||||
void setup() {
|
||||
pinMode(SEND_BUTTON_PIN, INPUT_PULLUP);
|
||||
|
||||
Serial.begin(115200);
|
||||
#if defined(__AVR_ATmega32U4__) || defined(SERIAL_PORT_USBVIRTUAL) || defined(SERIAL_USB) /*stm32duino*/|| defined(USBCON) /*STM32_stm32*/|| defined(SERIALUSB_PID) || defined(ARDUINO_attiny3217)
|
||||
delay(4000); // To be able to connect Serial monitor after reset or power up and before first print out. Do not wait for an attached Serial Monitor!
|
||||
|
@ -107,81 +128,86 @@ void setup() {
|
|||
|
||||
// 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);
|
||||
|
||||
IrSender.begin(IR_SEND_PIN, ENABLE_LED_FEEDBACK); // Specify send pin and enable feedback LED at default feedback LED pin
|
||||
|
||||
pinMode(STATUS_PIN, OUTPUT);
|
||||
|
||||
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.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.
|
||||
int buttonState = digitalRead(SEND_BUTTON_PIN); // Button pin is active LOW
|
||||
bool tSendButtonIsActive = (digitalRead(SEND_BUTTON_PIN) == LOW); // Button pin is active LOW
|
||||
|
||||
/*
|
||||
* Check for button just released in order to activate receiving
|
||||
* Check for current button state
|
||||
*/
|
||||
if (lastButtonState == LOW && buttonState == HIGH) {
|
||||
// Re-enable receiver
|
||||
Serial.println(F("Button released"));
|
||||
IrReceiver.start();
|
||||
}
|
||||
|
||||
/*
|
||||
* Check for static button state
|
||||
*/
|
||||
if (buttonState == LOW) {
|
||||
IrReceiver.stop();
|
||||
/*
|
||||
* Button pressed send stored data or repeat
|
||||
*/
|
||||
Serial.println(F("Button pressed, now sending"));
|
||||
digitalWrite(STATUS_PIN, HIGH);
|
||||
if (lastButtonState == buttonState) {
|
||||
sStoredIRData.receivedIRData.flags = IRDATA_FLAGS_IS_REPEAT;
|
||||
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);
|
||||
digitalWrite(STATUS_PIN, LOW);
|
||||
delay(DELAY_BETWEEN_REPEAT); // Wait a bit between retransmissions
|
||||
|
||||
} else if (sSendButtonWasActive) {
|
||||
/*
|
||||
* Button is not pressed, check for incoming data
|
||||
* Button is just released -> activate receiving
|
||||
*/
|
||||
} else if (IrReceiver.available()) {
|
||||
storeCode(IrReceiver.read());
|
||||
// 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
|
||||
}
|
||||
|
||||
lastButtonState = buttonState;
|
||||
sSendButtonWasActive = tSendButtonIsActive;
|
||||
delay(100);
|
||||
}
|
||||
|
||||
// Stores the code for later playback in sStoredIRData
|
||||
// Most of this code is just logging
|
||||
void storeCode(IRData *aIRReceivedData) {
|
||||
if (aIRReceivedData->flags & IRDATA_FLAGS_IS_REPEAT) {
|
||||
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 (aIRReceivedData->flags & IRDATA_FLAGS_IS_AUTO_REPEAT) {
|
||||
if (IrReceiver.decodedIRData.flags & IRDATA_FLAGS_IS_AUTO_REPEAT) {
|
||||
Serial.println(F("Ignore autorepeat"));
|
||||
return;
|
||||
}
|
||||
if (aIRReceivedData->flags & IRDATA_FLAGS_PARITY_FAILED) {
|
||||
if (IrReceiver.decodedIRData.flags & IRDATA_FLAGS_PARITY_FAILED) {
|
||||
Serial.println(F("Ignore parity error"));
|
||||
return;
|
||||
}
|
||||
/*
|
||||
* Copy decoded data
|
||||
*/
|
||||
sStoredIRData.receivedIRData = *aIRReceivedData;
|
||||
sStoredIRData.receivedIRData = IrReceiver.decodedIRData;
|
||||
|
||||
if (sStoredIRData.receivedIRData.protocol == UNKNOWN) {
|
||||
Serial.print(F("Received unknown code and store "));
|
||||
|
@ -206,7 +232,7 @@ void sendCode(storedIRDataStruct *aIRDataToSend) {
|
|||
// Assume 38 KHz
|
||||
IrSender.sendRaw(aIRDataToSend->rawCode, aIRDataToSend->rawCodeLength, 38);
|
||||
|
||||
Serial.print(F("Sent raw "));
|
||||
Serial.print(F("raw "));
|
||||
Serial.print(aIRDataToSend->rawCodeLength);
|
||||
Serial.println(F(" marks or spaces"));
|
||||
} else {
|
||||
|
@ -214,9 +240,7 @@ void sendCode(storedIRDataStruct *aIRDataToSend) {
|
|||
/*
|
||||
* Use the write function, which does the switch for different protocols
|
||||
*/
|
||||
IrSender.write(&aIRDataToSend->receivedIRData, DEFAULT_NUMBER_OF_REPEATS_TO_SEND);
|
||||
|
||||
Serial.print(F("Sent: "));
|
||||
IrSender.write(&aIRDataToSend->receivedIRData);
|
||||
printIRResultShort(&Serial, &aIRDataToSend->receivedIRData, false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,341 @@
|
|||
/*
|
||||
* 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 6 7 10
|
||||
* 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(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
|
||||
#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,186 @@
|
|||
/*
|
||||
* 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>
|
||||
|
||||
#include "PinDefinitionsAndMore.h" // Define macros for input and output pin etc.
|
||||
#if !defined(IR_SEND_PIN)
|
||||
#define IR_SEND_PIN 3
|
||||
#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)
|
||||
// For air condition remotes it requires 600 (maximum for 2k RAM) to 750. Default is 112 if DECODE_MAGIQUEST is enabled, otherwise 100.
|
||||
# if (defined(RAMEND) && RAMEND <= 0x4FF) || (defined(RAMSIZE) && RAMSIZE < 0x4FF)
|
||||
#define RAW_BUFFER_LENGTH 180
|
||||
# elif (defined(RAMEND) && RAMEND <= 0x8FF) || (defined(RAMSIZE) && RAMSIZE < 0x8FF)
|
||||
#define RAW_BUFFER_LENGTH 600
|
||||
# else
|
||||
#define RAW_BUFFER_LENGTH 750
|
||||
# endif
|
||||
#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 SEND_BUTTON_PIN APPLICATION_PIN
|
||||
|
||||
#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_PULLUP);
|
||||
|
||||
Serial.begin(115200);
|
||||
#if defined(__AVR_ATmega32U4__) || defined(SERIAL_PORT_USBVIRTUAL) || defined(SERIAL_USB) /*stm32duino*/|| defined(USBCON) /*STM32_stm32*/|| defined(SERIALUSB_PID) || defined(ARDUINO_attiny3217)
|
||||
delay(4000); // To be able to connect Serial monitor after reset or power up and before first print out. Do not wait for an attached Serial Monitor!
|
||||
#endif
|
||||
// Just to know which program is running on my Arduino
|
||||
Serial.println(F("START " __FILE__ " from " __DATE__ "\r\nUsing library version " VERSION_IRREMOTE));
|
||||
|
||||
// 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 -which is defined in PinDefinitionsAndMore.h- 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) == LOW); // 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 "));
|
||||
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
|
||||
}
|
||||
|
||||
sSendButtonWasActive = tSendButtonIsActive;
|
||||
delay(100);
|
||||
}
|
|
@ -0,0 +1,341 @@
|
|||
/*
|
||||
* 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 6 7 10
|
||||
* 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(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
|
||||
#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,143 @@
|
|||
/*
|
||||
* ReceiveAndSendHob2Hood.cpp
|
||||
*
|
||||
* Demonstrates receiving and sending of IR codes for AEG / Elektrolux Hob2Hood protocol
|
||||
*
|
||||
* 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>
|
||||
|
||||
#define DECODE_HASH // Only decoder, which works for Hob2Hood. protocol is UNKNOWN and only raw data is set.
|
||||
|
||||
//#define NO_LED_FEEDBACK_CODE // saves 92 bytes program memory
|
||||
//#define SEND_PWM_BY_TIMER // Disable carrier PWM generation in software and use (restricted) hardware PWM.
|
||||
|
||||
#include "PinDefinitionsAndMore.h" // Define macros for input and output pin etc.
|
||||
#include <IRremote.hpp>
|
||||
|
||||
// IR commands from AEG hob2hood device
|
||||
#define NUMBER_OF_HOB_TO_HOOD_COMMANDS 7
|
||||
#define HOB_TO_HOOD_HASH_CODE_FAN_1 0xE3C01BE2
|
||||
#define HOB_TO_HOOD_HASH_CODE_FAN_2 0xD051C301
|
||||
#define HOB_TO_HOOD_HASH_CODE_FAN_3 0xC22FFFD7
|
||||
#define HOB_TO_HOOD_HASH_CODE_FAN_4 0xB9121B29
|
||||
#define HOB_TO_HOOD_HASH_CODE_FAN_OFF 0x55303A3
|
||||
#define HOB_TO_HOOD_HASH_CODE_LIGHT_ON 0xE208293C
|
||||
#define HOB_TO_HOOD_HASH_CODE_LIGHT_OFF 0x24ACF947
|
||||
|
||||
// based on https://pastebin.com/N6kG7Wu5
|
||||
#define HOB_TO_HOOD_UNIT_MICROS 725
|
||||
#define H2H_1 HOB_TO_HOOD_UNIT_MICROS
|
||||
#define H2H_2 (HOB_TO_HOOD_UNIT_MICROS*2) // 1450
|
||||
#define H2H_3 (HOB_TO_HOOD_UNIT_MICROS*3) // 2175
|
||||
#define H2H_4 (HOB_TO_HOOD_UNIT_MICROS*4) // 2900
|
||||
#define H2H_5 (HOB_TO_HOOD_UNIT_MICROS*5) // 3625
|
||||
|
||||
// First entry is the length of the raw command
|
||||
const uint16_t Fan1[] PROGMEM { 15, H2H_2, H2H_2, H2H_1, H2H_2, H2H_3, H2H_2, H2H_1, H2H_2, H2H_1, H2H_1, H2H_1, H2H_2, H2H_1,
|
||||
H2H_3, H2H_1 };
|
||||
const uint16_t Fan2[] PROGMEM { 9, H2H_2, H2H_2, H2H_1, H2H_4, H2H_1, H2H_3, H2H_5, H2H_3, H2H_3 };
|
||||
const uint16_t Fan3[] PROGMEM { 9, H2H_1, H2H_3, H2H_4, H2H_4, H2H_3, H2H_1, H2H_1, H2H_3, H2H_3 };
|
||||
const uint16_t Fan4[] PROGMEM { 13, H2H_2, H2H_3, H2H_2, H2H_1, H2H_2, H2H_3, H2H_2, H2H_2, H2H_1, H2H_3, H2H_1, H2H_1, H2H_2 };
|
||||
const uint16_t FanOff[] PROGMEM { 15, H2H_1, H2H_2, H2H_1, H2H_2, H2H_3, H2H_2, H2H_1, H2H_2, H2H_2, H2H_3, H2H_1, H2H_2, H2H_1,
|
||||
H2H_1, H2H_1 };
|
||||
const uint16_t LightOn[] PROGMEM { 17, H2H_1, H2H_2, H2H_1, H2H_1, H2H_2, H2H_1, H2H_1, H2H_2, H2H_1, H2H_1, H2H_2, H2H_4, H2H_1,
|
||||
H2H_1, H2H_1, H2H_1, H2H_2 };
|
||||
const uint16_t LightOff[] PROGMEM { 17, H2H_1, H2H_2, H2H_1, H2H_1, H2H_1, H2H_1, H2H_1, H2H_3, H2H_1, H2H_1, H2H_1, H2H_2, H2H_1,
|
||||
H2H_2, H2H_1, H2H_1, H2H_1 };
|
||||
const uint16_t *const Hob2HoodSendCommands[NUMBER_OF_HOB_TO_HOOD_COMMANDS] = { Fan1, Fan2, Fan3, Fan4, FanOff, LightOn, LightOff }; // Constant array in RAM
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
#if defined(__AVR_ATmega32U4__) || defined(SERIAL_PORT_USBVIRTUAL) || defined(SERIAL_USB) /*stm32duino*/|| defined(USBCON) /*STM32_stm32*/|| defined(SERIALUSB_PID) || defined(ARDUINO_attiny3217)
|
||||
delay(4000); // To be able to connect Serial monitor after reset or power up and before first print out. Do not wait for an attached Serial Monitor!
|
||||
#endif
|
||||
// Just to know which program is running on my Arduino
|
||||
Serial.println(F("START " __FILE__ " from " __DATE__ "\r\nUsing library version " VERSION_IRREMOTE));
|
||||
|
||||
// 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 Hob2Hood IR signals 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("Send Hob2Hood IR signals at pin " STR(IR_SEND_PIN)));
|
||||
}
|
||||
|
||||
/*
|
||||
* Send Hob2Hood protocol
|
||||
*/
|
||||
void loop() {
|
||||
static long sLastMillisOfSend = 0;
|
||||
static uint8_t sSendCommandIndex = 0;
|
||||
|
||||
if (IrReceiver.decode()) {
|
||||
IrReceiver.resume(); // Early enable receiving of the next IR frame
|
||||
IrReceiver.printIRResultShort(&Serial);
|
||||
|
||||
/*
|
||||
* Finally, check the received data and perform actions according to the received command
|
||||
*/
|
||||
switch (IrReceiver.decodedIRData.decodedRawData) {
|
||||
case HOB_TO_HOOD_HASH_CODE_FAN_OFF:
|
||||
Serial.print(F("FAN off"));
|
||||
break;
|
||||
case HOB_TO_HOOD_HASH_CODE_FAN_1:
|
||||
Serial.print(F("FAN 1"));
|
||||
break;
|
||||
case HOB_TO_HOOD_HASH_CODE_FAN_2:
|
||||
Serial.print(F("FAN 2"));
|
||||
break;
|
||||
default:
|
||||
Serial.print(F("unknown Hob2Hood IR command"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Send next command every 5 seconds
|
||||
*/
|
||||
if (millis() - sLastMillisOfSend > 2000) {
|
||||
sLastMillisOfSend = millis();
|
||||
|
||||
#if defined(__AVR__)
|
||||
uint16_t tLengthOfRawCommand = pgm_read_word(Hob2HoodSendCommands[sSendCommandIndex]); // length is the 1. word in array
|
||||
#else
|
||||
uint16_t tLengthOfRawCommand = *Hob2HoodSendCommands[sSendCommandIndex]; // length is the 1. word in array
|
||||
#endif
|
||||
const uint16_t *tAddressOfRawCommandSequence = Hob2HoodSendCommands[sSendCommandIndex] + 1; // Raw sequence starts at the 2. word of array
|
||||
Serial.print(F("Send Hob2Hood command index="));
|
||||
Serial.println(sSendCommandIndex);
|
||||
IrSender.sendRaw_P(tAddressOfRawCommandSequence, tLengthOfRawCommand, 38);
|
||||
|
||||
// Prepare for next command
|
||||
sSendCommandIndex++;
|
||||
if (sSendCommandIndex >= NUMBER_OF_HOB_TO_HOOD_COMMANDS) {
|
||||
sSendCommandIndex = 0;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,151 +1,178 @@
|
|||
START ../src/ReceiveDemo.cpp from Mar 8 2021
|
||||
Using library version 3.1.0
|
||||
START ../src/ReceiveDemo.cpp from Feb 24 2023
|
||||
Using library version 4.1.0
|
||||
Enabling IRin...
|
||||
Ready to receive IR signals at pin 2
|
||||
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=0x102 Command=0x34 Parity fail Raw-Data=0xC0340102 32 bits LSB first
|
||||
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=APPLE Address=0x2 Command=0x34 Raw-Data=0x23487EE 32 bits LSB first
|
||||
Protocol=Panasonic Address=0xB Command=0x10 Raw-Data=0xA01000B0 48 bits LSB first
|
||||
Send with: IrSender.sendPanasonic(0xB, 0x10, <numberOfRepeats>);
|
||||
|
||||
Protocol=PANASONIC Address=0x102 Command=0x34 Raw-Data=0x4341020 48 bits LSB first
|
||||
Protocol=Panasonic Address=0xB Command=0x10 Raw-Data=0xA01000B0 48 bits LSB first
|
||||
Send with: IrSender.sendPanasonic(0xB, 0x10, <numberOfRepeats>);
|
||||
|
||||
Protocol=KASEIKYO Address=0x102 Command=0x34 Extra=0x4711 Raw-Data=0x7341023 48 bits LSB first
|
||||
Protocol=Panasonic Address=0xB Command=0x10 Raw-Data=0xA01000B0 48 bits LSB first
|
||||
Send with: IrSender.sendPanasonic(0xB, 0x10, <numberOfRepeats>);
|
||||
|
||||
Protocol=DENON Address=0x2 Command=0x34 Raw-Data=0x8D0 15 bits MSB first
|
||||
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=DENON Address=0x2 Command=0x34 Auto-Repeat gap=44550us Raw-Data=0xB2F 15 bits MSB first
|
||||
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=SHARP Address=0x2 Command=0x34 Raw-Data=0x8D2 15 bits MSB first
|
||||
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=SHARP Address=0x2 Command=0x34 Auto-Repeat gap=44600us Raw-Data=0xB2D 15 bits MSB first
|
||||
Protocol=Onkyo Address=0x102 Command=0x5634 Raw-Data=0x56340102 32 bits LSB first
|
||||
Send with: IrSender.sendOnkyo(0x102, 0x5634, <numberOfRepeats>);
|
||||
|
||||
Protocol=SONY Address=0x2 Command=0x34 Raw-Data=0x134 12 bits LSB first
|
||||
Protocol=Apple Address=0x2 Command=0x34 Raw-Data=0x23487EE 32 bits LSB first
|
||||
Send with: IrSender.sendApple(0x2, 0x34, <numberOfRepeats>);
|
||||
|
||||
Protocol=SONY Address=0x2 Command=0x34 Raw-Data=0x134 15 bits LSB first
|
||||
Protocol=Panasonic Address=0x102 Command=0x34 Raw-Data=0x4341020 48 bits LSB first
|
||||
Send with: IrSender.sendPanasonic(0x102, 0x34, <numberOfRepeats>);
|
||||
|
||||
Protocol=SONY Address=0x0 Command=0x0 Raw-Data=0x0 0 bits LSB first
|
||||
Protocol=Kaseikyo Address=0x102 Command=0x34 Extra=0x4711 Raw-Data=0x7341023 48 bits LSB first
|
||||
Send with: IrSender.sendKaseikyo(0x102, 0x34, <numberOfRepeats>, 0x4711);
|
||||
|
||||
Protocol=SONY Address=0x102 Command=0x34 Raw-Data=0x8134 20 bits LSB first
|
||||
Protocol=Kaseikyo_Denon Address=0x102 Command=0x34 Raw-Data=0x4341020 48 bits LSB first
|
||||
Send with: IrSender.sendKaseikyo_Denon(0x102, 0x34, <numberOfRepeats>);
|
||||
|
||||
Protocol=RC5 Address=0x2 Command=0x34 Toggle=1 Raw-Data=0x38B4 13 bits MSB first
|
||||
Protocol=Denon Address=0x2 Command=0x34 Raw-Data=0x682 15 bits LSB first
|
||||
Send with: IrSender.sendDenon(0x2, 0x34, <numberOfRepeats>);
|
||||
|
||||
Protocol=RC5 Address=0x2 Command=0x74 Raw-Data=0x20B4 13 bits MSB first
|
||||
Protocol=Denon Address=0x2 Command=0x34 Auto-Repeat gap=45650us Raw-Data=0x7962 15 bits LSB first
|
||||
|
||||
Protocol=RC6 Address=0x2 Command=0x34 Raw-Data=0x234 16 bits MSB first
|
||||
Protocol=Sharp Address=0x2 Command=0x34 Raw-Data=0x4682 15 bits LSB first
|
||||
Send with: IrSender.sendSharp(0x2, 0x34, <numberOfRepeats>);
|
||||
|
||||
Protocol=SAMSUNG Address=0x102 Command=0x34 Raw-Data=0xCB340102 32 bits LSB first
|
||||
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=LG Address=0x2 Command=0x34 Raw-Data=0x200347 28 bits MSB first
|
||||
Protocol=Samsung Address=0x102 Command=0x5634 Raw-Data=0x56340102 32 bits LSB first
|
||||
Send with: IrSender.sendSamsung(0x102, 0x5634, <numberOfRepeats>);
|
||||
|
||||
Protocol=BOSEWAVE Address=0x0 Command=0x34 Raw-Data=0xCB34 16 bits LSB first
|
||||
Protocol=LG Address=0x2 Command=0x5634 Raw-Data=0x256342 28 bits MSB first
|
||||
Send with: IrSender.sendLG(0x2, 0x5634, <numberOfRepeats>);
|
||||
|
||||
Protocol=LEGO_PF Address=0x3 Command=0x14 Raw-Data=0x2148 16 bits MSB first
|
||||
Protocol=MagiQuest Address=0x102 Command=0x34 Raw-Data=0x6BCD0102 56 bits MSB first
|
||||
Send with: IrSender.sendMagiQuest(0x6BCD0102, 0x34, <numberOfRepeats>);
|
||||
|
||||
Protocol=LEGO_PF Address=0x3 Command=0x14 Auto-Repeat gap=216800us Raw-Data=0x2148 16 bits MSB first
|
||||
Protocol=BoseWave Address=0x0 Command=0x34 Raw-Data=0xCB34 16 bits LSB first
|
||||
Send with: IrSender.sendBoseWave(0x0, 0x34, <numberOfRepeats>);
|
||||
|
||||
Protocol=LEGO_PF Address=0x2 Command=0x14 Auto-Repeat gap=177200us Raw-Data=0x2148 16 bits MSB first
|
||||
Protocol=FAST Address=0x0 Command=0x34 Raw-Data=0xCB34 16 bits LSB first
|
||||
Send with: IrSender.sendFAST(0x0, 0x34, <numberOfRepeats>);
|
||||
|
||||
Protocol=LEGO_PF Address=0x2 Command=0x14 Auto-Repeat gap=177200us Raw-Data=0x2148 16 bits MSB first
|
||||
Protocol=Lego Address=0x2 Command=0x14 Raw-Data=0x2148 16 bits MSB first
|
||||
Send with: IrSender.sendLego(0x2, 0x14, <numberOfRepeats>);
|
||||
|
||||
Protocol=LEGO_PF Address=0x2 Command=0x14 Auto-Repeat gap=177200us Raw-Data=0x2148 16 bits MSB first
|
||||
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=47550us
|
||||
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=APPLE Address=0x3 Command=0x45 Raw-Data=0x34587EE 32 bits LSB first
|
||||
Protocol=NEC Address=0x203 Command=0x45 Raw-Data=0xBA450203 32 bits LSB first
|
||||
Send with: IrSender.sendNEC(0x203, 0x45, <numberOfRepeats>);
|
||||
|
||||
Protocol=APPLE Address=0x3 Command=0x45 Repeat gap=47550us
|
||||
Protocol=NEC2 Address=0x203 Command=0x45 Repeat gap=46500us Raw-Data=0xBA450203 32 bits LSB first
|
||||
|
||||
Protocol=PANASONIC Address=0x203 Command=0x45 Raw-Data=0x55452030 48 bits LSB first
|
||||
Protocol=Onkyo Address=0x203 Command=0x6745 Raw-Data=0x67450203 32 bits LSB first
|
||||
Send with: IrSender.sendOnkyo(0x203, 0x6745, <numberOfRepeats>);
|
||||
|
||||
Protocol=PANASONIC Address=0x203 Command=0x45 Repeat gap=73250us Raw-Data=0x55452030 48 bits LSB first
|
||||
Protocol=Onkyo Address=0x203 Command=0x6745 Repeat gap=46550us
|
||||
|
||||
Protocol=KASEIKYO Address=0x203 Command=0x45 Extra=0x4711 Raw-Data=0x56452033 48 bits LSB first
|
||||
Protocol=Apple Address=0x3 Command=0x45 Raw-Data=0x34587EE 32 bits LSB first
|
||||
Send with: IrSender.sendApple(0x3, 0x45, <numberOfRepeats>);
|
||||
|
||||
Protocol=KASEIKYO Address=0x203 Command=0x45 Extra=0x4711 Repeat gap=73250us Raw-Data=0x56452033 48 bits LSB first
|
||||
Protocol=Apple Address=0x3 Command=0x45 Repeat gap=31550us
|
||||
|
||||
Protocol=DENON Address=0x3 Command=0x45 Raw-Data=0xD14 15 bits MSB first
|
||||
Protocol=Panasonic Address=0x203 Command=0x45 Raw-Data=0x55452030 48 bits LSB first
|
||||
Send with: IrSender.sendPanasonic(0x203, 0x45, <numberOfRepeats>);
|
||||
|
||||
Protocol=DENON Address=0x3 Command=0x45 Auto-Repeat gap=44550us Raw-Data=0xEEB 15 bits MSB first
|
||||
Protocol=Panasonic Address=0x203 Command=0x45 Repeat gap=72550us Raw-Data=0x55452030 48 bits LSB first
|
||||
|
||||
Protocol=DENON Address=0x3 Command=0x45 Repeat gap=44550us Raw-Data=0xD14 15 bits MSB 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=DENON Address=0x3 Command=0x45 Auto-Repeat gap=44550us Raw-Data=0xEEB 15 bits MSB first
|
||||
Protocol=Kaseikyo Address=0x203 Command=0x45 Extra=0x4711 Repeat gap=66750us Raw-Data=0x56452033 48 bits LSB first
|
||||
|
||||
Protocol=SHARP Address=0x3 Command=0x45 Raw-Data=0xD16 15 bits MSB first
|
||||
|
||||
Protocol=SHARP Address=0x3 Command=0x45 Auto-Repeat gap=44550us Raw-Data=0xEE9 15 bits MSB first
|
||||
|
||||
Protocol=SHARP Address=0x3 Command=0x45 Repeat gap=44550us Raw-Data=0xD16 15 bits MSB first
|
||||
|
||||
Protocol=SHARP Address=0x3 Command=0x45 Auto-Repeat gap=44550us Raw-Data=0xEE9 15 bits MSB first
|
||||
|
||||
Protocol=SONY Address=0x3 Command=0x45 Raw-Data=0x1C5 12 bits LSB first
|
||||
|
||||
Protocol=SONY Address=0x3 Command=0x45 Repeat gap=24350us Raw-Data=0x1C5 12 bits LSB first
|
||||
|
||||
Protocol=SONY Address=0x3 Command=0x45 Raw-Data=0x1C5 15 bits LSB first
|
||||
|
||||
Protocol=SONY Address=0x3 Command=0x45 Repeat gap=24350us Raw-Data=0x1C5 15 bits LSB first
|
||||
|
||||
Protocol=SONY Address=0x203 Command=0x45 Raw-Data=0x101C5 20 bits LSB first
|
||||
|
||||
Protocol=SONY Address=0x203 Command=0x45 Repeat gap=24300us Raw-Data=0x101C5 20 bits LSB first
|
||||
|
||||
Protocol=RC5 Address=0x3 Command=0x5 Raw-Data=0x30C5 13 bits MSB first
|
||||
|
||||
Protocol=RC5 Address=0x3 Command=0x5 Repeat gap=99000us Raw-Data=0x30C5 13 bits MSB first
|
||||
|
||||
Protocol=RC5 Address=0x3 Command=0x45 Toggle=1 Raw-Data=0x28C5 13 bits MSB first
|
||||
|
||||
Protocol=RC5 Address=0x3 Command=0x45 Toggle=1 Repeat gap=98950us Raw-Data=0x28C5 13 bits MSB first
|
||||
|
||||
Protocol=RC6 Address=0x3 Command=0x45 Raw-Data=0x345 16 bits MSB first
|
||||
|
||||
Protocol=RC6 Address=0x3 Command=0x45 Repeat gap=106400us Raw-Data=0x345 16 bits MSB first
|
||||
|
||||
Protocol=SAMSUNG Address=0x203 Command=0x45 Raw-Data=0xBA450203 32 bits LSB first
|
||||
|
||||
Protocol=SAMSUNG Address=0x203 Command=0x45 Repeat gap=54500us
|
||||
|
||||
Protocol=JVC Address=0x3 Command=0x45 Raw-Data=0x4503 16 bits LSB first
|
||||
|
||||
Protocol=JVC Address=0x3 Command=0x45 Repeat gap=22750us
|
||||
|
||||
Protocol=LG Address=0x3 Command=0x45 Raw-Data=0x300459 28 bits MSB first
|
||||
|
||||
Protocol=LG Address=0x3 Command=0x45 Repeat gap=51500us
|
||||
|
||||
Protocol=BOSEWAVE Address=0x0 Command=0x45 Raw-Data=0xBA45 16 bits LSB first
|
||||
|
||||
Protocol=BOSEWAVE Address=0x0 Command=0x45 Repeat gap=51450us Raw-Data=0xBA45 16 bits LSB first
|
||||
|
||||
Protocol=LEGO_PF Address=0x3 Command=0x15 Raw-Data=0x3158 16 bits MSB first
|
||||
|
||||
Protocol=LEGO_PF Address=0x3 Command=0x15 Auto-Repeat gap=216800us Raw-Data=0x3158 16 bits MSB first
|
||||
|
||||
Protocol=LEGO_PF Address=0x3 Command=0x15 Auto-Repeat gap=216800us Raw-Data=0x3158 16 bits MSB first
|
||||
|
||||
Protocol=LEGO_PF Address=0x3 Command=0x15 Auto-Repeat gap=216800us Raw-Data=0x3158 16 bits MSB first
|
||||
|
||||
Protocol=LEGO_PF Address=0x3 Command=0x15 Auto-Repeat gap=216800us Raw-Data=0x3158 16 bits MSB first
|
||||
|
||||
Overflow detected
|
||||
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
|
|
@ -4,7 +4,7 @@
|
|||
* 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
|
||||
* Copyright (C) 2021-2023 Armin Joachimsmeyer
|
||||
* armin.joachimsmeyer@gmail.com
|
||||
*
|
||||
* This file is part of IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
|
||||
|
@ -16,8 +16,8 @@
|
|||
*
|
||||
* 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.
|
||||
* 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>.
|
||||
|
@ -29,68 +29,99 @@
|
|||
*
|
||||
* Platform IR input IR output Tone Core/Pin schema
|
||||
* --------------------------------------------------------------
|
||||
* DEFAULT/AVR 2 3 4
|
||||
* ATtinyX5 0|PB0 4|PB4 3|PB3
|
||||
* 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 pro
|
||||
* 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
|
||||
* BluePill PA6 PA7 PA3
|
||||
* ESP32 15 4 27
|
||||
* ESP32-C3 6 7 10
|
||||
* 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
|
||||
#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
|
||||
#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
|
||||
#define TONE_PIN 5 // PA7 - on Digispark board labeled as pin 5
|
||||
#define _IR_TIMING_TEST_PIN 10 // PA4
|
||||
# else
|
||||
#define IR_RECEIVE_PIN 3
|
||||
#define IR_SEND_PIN 2
|
||||
#define TONE_PIN 7
|
||||
// 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_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_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_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_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_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
|
||||
# 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
|
||||
#define TONE_PIN 42 // Dummy for examples using it
|
||||
|
||||
# elif defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) \
|
||||
|| defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) \
|
||||
|
@ -123,17 +154,33 @@
|
|||
# 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 13 // D7
|
||||
#define APPLICATION_PIN 0 // D3
|
||||
#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(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>
|
||||
|
||||
|
@ -166,10 +213,13 @@ void noTone(uint8_t aPinNumber){
|
|||
#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
|
||||
|
@ -234,7 +284,7 @@ void noTone(uint8_t aPinNumber){
|
|||
#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)
|
||||
#if !defined(ARDUINO_SAMD_ADAFRUIT) && !defined(ARDUINO_SEEED_XIAO_M0)
|
||||
// On the Zero and others we switch explicitly to SerialUSB
|
||||
#define Serial SerialUSB
|
||||
#endif
|
||||
|
@ -274,13 +324,14 @@ void noTone(uint8_t aPinNumber){
|
|||
#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
|
||||
#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
|
||||
*/
|
||||
|
|
|
@ -2,14 +2,15 @@
|
|||
* ReceiveDemo.cpp
|
||||
*
|
||||
* Demonstrates receiving IR codes with the IRremote library and the use of the Arduino tone() function with this library.
|
||||
* If debug button is pressed (pin connected to ground) a long output is generated.
|
||||
* 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-2022 Armin Joachimsmeyer
|
||||
* 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
|
||||
|
@ -33,39 +34,68 @@
|
|||
|
||||
#include <Arduino.h>
|
||||
|
||||
#include "PinDefinitionsAndMore.h" // Define macros for input and output pin etc.
|
||||
|
||||
//#define LOCAL_DEBUG // If defined, print timing for each received data set (the same as if DEBUG_BUTTON_PIN was connected to low)
|
||||
|
||||
/*
|
||||
* Specify which protocol(s) should be used for decoding.
|
||||
* If no protocol is defined, all protocols are active.
|
||||
* 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
|
||||
//#define DECODE_DISTANCE
|
||||
//#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!
|
||||
#if FLASHEND >= 0x3FFF // For 16k flash or more, like ATtiny1604. Code does not fit in program memory of ATtiny85 etc.
|
||||
// !!! Enabling B&O disables detection of Sony, because the repeat gap for SONY is smaller than the B&O frame gap :-( !!!
|
||||
//#define DECODE_BEO // Bang & Olufsen protocol always must be enabled explicitly. It has an IR transmit frequency of 455 kHz! It prevents decoding of SONY!
|
||||
#endif
|
||||
#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
|
||||
// etc. see IRremote.hpp
|
||||
//
|
||||
|
||||
#if RAMEND <= 0x4FF || (defined(RAMSIZE) && RAMSIZE < 0x4FF)
|
||||
#define RAW_BUFFER_LENGTH 150 // 750 (600 if we have only 2k RAM) is the value for air condition remotes. Default is 112 if DECODE_MAGIQUEST is enabled, otherwise 100.
|
||||
#define EXCLUDE_EXOTIC_PROTOCOLS // saves around 650 bytes program memory if all other protocols are active
|
||||
#elif RAMEND <= 0x8FF || (defined(RAMSIZE) && RAMSIZE < 0x8FF)
|
||||
#define RAW_BUFFER_LENGTH 600 // 750 (600 if we have only 2k RAM) is the value for air condition remotes. Default is 112 if DECODE_MAGIQUEST is enabled, otherwise 100.
|
||||
#else
|
||||
#define RAW_BUFFER_LENGTH 750 // 750 (600 if we have only 2k RAM) is the value for air condition remotes. Default is 112 if DECODE_MAGIQUEST is enabled, otherwise 100.
|
||||
#if !defined(RAW_BUFFER_LENGTH)
|
||||
// For air condition remotes it requires 600 (maximum for 2k RAM) to 750. Default is 112 if DECODE_MAGIQUEST is enabled, otherwise 100.
|
||||
# if (defined(RAMEND) && RAMEND <= 0x4FF) || (defined(RAMSIZE) && RAMSIZE < 0x4FF)
|
||||
#define RAW_BUFFER_LENGTH 180
|
||||
# elif (defined(RAMEND) && RAMEND <= 0x8FF) || (defined(RAMSIZE) && RAMSIZE < 0x8FF)
|
||||
#define RAW_BUFFER_LENGTH 600
|
||||
# else
|
||||
#define RAW_BUFFER_LENGTH 750
|
||||
# endif
|
||||
#endif
|
||||
|
||||
//#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.
|
||||
//#define MARK_EXCESS_MICROS 20 // 20 is recommended for the cheap VS1838 modules
|
||||
// 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 // Activate it for some LG air conditioner protocols
|
||||
//#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 "PinDefinitionsAndMore.h" // Define macros for input and output pin etc.
|
||||
#include <IRremote.hpp>
|
||||
|
||||
#if defined(APPLICATION_PIN)
|
||||
|
@ -74,6 +104,10 @@
|
|||
#define DEBUG_BUTTON_PIN 6
|
||||
#endif
|
||||
|
||||
void generateTone();
|
||||
void handleOverflow();
|
||||
bool detectLongPress(uint16_t aLongPressDurationMillis);
|
||||
|
||||
void setup() {
|
||||
#if FLASHEND >= 0x3FFF // For 16k flash or more, like ATtiny1604. Code does not fit in program memory of ATtiny85 etc.
|
||||
pinMode(DEBUG_BUTTON_PIN, INPUT_PULLUP);
|
||||
|
@ -95,11 +129,24 @@ void setup() {
|
|||
|
||||
Serial.print(F("Ready to receive IR signals of protocols: "));
|
||||
printActiveIRProtocols(&Serial);
|
||||
#if defined(IR_RECEIVE_PIN_STRING)
|
||||
Serial.println(F("at pin " IR_RECEIVE_PIN_STRING));
|
||||
#else
|
||||
Serial.println(F("at pin " STR(IR_RECEIVE_PIN)));
|
||||
#endif
|
||||
|
||||
#if FLASHEND >= 0x3FFF // For 16k flash or more, like ATtiny1604. Code does not fit in program memory of ATtiny85 etc.
|
||||
Serial.print(F("Debug button pin is "));
|
||||
Serial.println(DEBUG_BUTTON_PIN);
|
||||
Serial.println();
|
||||
if (digitalRead(DEBUG_BUTTON_PIN) != LOW) {
|
||||
Serial.print(F("If you connect debug pin "));
|
||||
# if defined(APPLICATION_PIN_STRING)
|
||||
Serial.print(APPLICATION_PIN_STRING);
|
||||
# else
|
||||
Serial.print(DEBUG_BUTTON_PIN);
|
||||
# endif
|
||||
Serial.print(F(" to ground, "));
|
||||
}
|
||||
Serial.println(F("raw data is always printed"));
|
||||
|
||||
// infos for receive
|
||||
Serial.print(RECORD_GAP_MICROS);
|
||||
|
@ -107,7 +154,6 @@ void setup() {
|
|||
Serial.print(MARK_EXCESS_MICROS);
|
||||
Serial.println(F(" us are subtracted from all marks and added to all spaces for decoding"));
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
@ -121,64 +167,58 @@ void loop() {
|
|||
*/
|
||||
if (IrReceiver.decode()) {
|
||||
Serial.println();
|
||||
#if FLASHEND >= 0x3FFF // For 16k flash or more, like ATtiny1604
|
||||
if (IrReceiver.decodedIRData.flags & IRDATA_FLAGS_WAS_OVERFLOW) {
|
||||
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
|
||||
# if !defined(ESP8266) && !defined(NRF5)
|
||||
/*
|
||||
* do double beep
|
||||
*/
|
||||
# if !defined(ESP32)
|
||||
IrReceiver.stop(); // ESP32 uses another timer for tone()
|
||||
# endif
|
||||
tone(TONE_PIN, 1100, 10);
|
||||
delay(50);
|
||||
tone(TONE_PIN, 1100, 10);
|
||||
delay(50);
|
||||
# if !defined(ESP32)
|
||||
IrReceiver.start(100000); // to compensate for 100 ms stop of receiver. This enables a correct gap measurement.
|
||||
# endif
|
||||
# endif
|
||||
|
||||
} else {
|
||||
// Print a short summary of received data
|
||||
IrReceiver.printIRResultShort(&Serial);
|
||||
IrReceiver.printIRSendUsage(&Serial);
|
||||
|
||||
if (IrReceiver.decodedIRData.protocol == UNKNOWN || digitalRead(DEBUG_BUTTON_PIN) == LOW) {
|
||||
// We have an unknown protocol, print more info
|
||||
IrReceiver.printIRResultRawFormatted(&Serial, true);
|
||||
}
|
||||
}
|
||||
|
||||
// tone on esp8266 works once, then it disables the successful IrReceiver.start() / timerConfigForReceive().
|
||||
# if !defined(ESP8266) && !defined(NRF5)
|
||||
if (IrReceiver.decodedIRData.protocol != UNKNOWN && digitalRead(DEBUG_BUTTON_PIN) != LOW) {
|
||||
/*
|
||||
* If no debug mode or a valid protocol was received, play tone, wait and restore IR timer.
|
||||
* Otherwise do not play a tone to get exact gap time between transmissions and not running into repeat frames while wait for tone to end.
|
||||
* This will give the next CheckForRecordGapsMicros() call a chance to eventually propose a change of the current RECORD_GAP_MICROS value.
|
||||
*/
|
||||
# if !defined(ESP32)
|
||||
IrReceiver.stop(); // ESP32 uses another timer for tone()
|
||||
# endif
|
||||
tone(TONE_PIN, 2200, 8);
|
||||
# if !defined(ESP32)
|
||||
delay(8);
|
||||
IrReceiver.start(8000); // to compensate for 8 ms stop of receiver. This enables a correct gap measurement.
|
||||
# endif
|
||||
}
|
||||
# endif
|
||||
#else
|
||||
// Print a minimal summary of received data
|
||||
#if FLASHEND < 0x3FFF //
|
||||
// For less than 16k flash, only print a minimal summary of received data
|
||||
IrReceiver.printIRResultMinimal(&Serial);
|
||||
#endif // FLASHEND
|
||||
#else
|
||||
|
||||
/*
|
||||
* !!!Important!!! Enable receiving of the next value,
|
||||
* since receiving has stopped after the end of the current received data packet.
|
||||
*
|
||||
*/
|
||||
if (IrReceiver.decodedIRData.flags & IRDATA_FLAGS_WAS_OVERFLOW) {
|
||||
handleOverflow();
|
||||
} else {
|
||||
/*
|
||||
* No overflow here.
|
||||
* Stop receiver, generate a single beep, print short info and send usage and start receiver again
|
||||
*****************************************************************************************************/
|
||||
|
||||
if ((IrReceiver.decodedIRData.protocol != SONY) && (IrReceiver.decodedIRData.protocol != PULSE_WIDTH)
|
||||
&& (IrReceiver.decodedIRData.protocol != PULSE_DISTANCE) && (IrReceiver.decodedIRData.protocol != UNKNOWN)
|
||||
&& digitalRead(DEBUG_BUTTON_PIN) != LOW) {
|
||||
/*
|
||||
* For SONY the tone prevents the detection of a repeat after the 15 ms SONY gap.
|
||||
* In debug mode and for unknown protocols, we need the time for extended output.
|
||||
* Skipping tone will get exact gap time between transmissions and not running into repeat frames while wait for tone to end.
|
||||
* This in turn enables the next CheckForRecordGapsMicros() call a chance to eventually propose a change of the current RECORD_GAP_MICROS value.
|
||||
*/
|
||||
generateTone();
|
||||
}
|
||||
|
||||
/*
|
||||
* Print info
|
||||
*/
|
||||
if (IrReceiver.decodedIRData.protocol == UNKNOWN || digitalRead(DEBUG_BUTTON_PIN) == LOW) {
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
#endif // #if FLASHEND >= 0x3FFF
|
||||
|
||||
/*
|
||||
* !!!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();
|
||||
|
||||
|
@ -192,6 +232,13 @@ void loop() {
|
|||
// 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())
|
||||
|
||||
/*
|
||||
|
@ -203,3 +250,67 @@ void loop() {
|
|||
*/
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Stop receiver, generate a single beep and start receiver again
|
||||
*/
|
||||
void generateTone() {
|
||||
#if !defined(ESP8266) && !defined(NRF5) // tone on esp8266 works only once, then it disables IrReceiver.restartTimer() / timerConfigForReceive().
|
||||
# if defined(ESP32) // ESP32 uses another timer for tone()
|
||||
tone(TONE_PIN, 2200, 5);
|
||||
# else
|
||||
IrReceiver.stopTimer(); // ESP32 uses another timer for tone(), maybe other platforms (not tested yet) too.
|
||||
tone(TONE_PIN, 2200, 8);
|
||||
delay(8);
|
||||
IrReceiver.restartTimer(8000); // Restart IR timer. 8000 to compensate for 8 ms stop of receiver. This enables a correct gap measurement.
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
#if !defined(ESP8266) && !defined(NRF5) // tone on esp8266 works once, then it disables IrReceiver.restartTimer() / timerConfigForReceive().
|
||||
/*
|
||||
* Stop timer, generate a double beep and start timer again
|
||||
*/
|
||||
# if defined(ESP32) // ESP32 uses another timer for tone()
|
||||
tone(TONE_PIN, 1100, 10);
|
||||
delay(50);
|
||||
tone(TONE_PIN, 1100, 10);
|
||||
# else
|
||||
IrReceiver.stopTimer();
|
||||
tone(TONE_PIN, 1100, 10);
|
||||
delay(50);
|
||||
tone(TONE_PIN, 1100, 10);
|
||||
delay(50);
|
||||
IrReceiver.restartTimer(100000); // to compensate for 100 ms stop of receiver. This enables a correct gap measurement.
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* 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
|
||||
* Copyright (C) 2021-2023 Armin Joachimsmeyer
|
||||
* armin.joachimsmeyer@gmail.com
|
||||
*
|
||||
* This file is part of IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
|
||||
|
@ -16,8 +16,8 @@
|
|||
*
|
||||
* 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.
|
||||
* 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>.
|
||||
|
@ -29,68 +29,99 @@
|
|||
*
|
||||
* Platform IR input IR output Tone Core/Pin schema
|
||||
* --------------------------------------------------------------
|
||||
* DEFAULT/AVR 2 3 4
|
||||
* ATtinyX5 0|PB0 4|PB4 3|PB3
|
||||
* 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 pro
|
||||
* 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
|
||||
* BluePill PA6 PA7 PA3
|
||||
* ESP32 15 4 27
|
||||
* ESP32-C3 6 7 10
|
||||
* 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
|
||||
#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
|
||||
#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
|
||||
#define TONE_PIN 5 // PA7 - on Digispark board labeled as pin 5
|
||||
#define _IR_TIMING_TEST_PIN 10 // PA4
|
||||
# else
|
||||
#define IR_RECEIVE_PIN 3
|
||||
#define IR_SEND_PIN 2
|
||||
#define TONE_PIN 7
|
||||
// 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_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_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_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_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_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
|
||||
# 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
|
||||
#define TONE_PIN 42 // Dummy for examples using it
|
||||
|
||||
# elif defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) \
|
||||
|| defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) \
|
||||
|
@ -123,17 +154,33 @@
|
|||
# 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 13 // D7
|
||||
#define APPLICATION_PIN 0 // D3
|
||||
#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(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>
|
||||
|
||||
|
@ -166,10 +213,13 @@ void noTone(uint8_t aPinNumber){
|
|||
#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
|
||||
|
@ -234,7 +284,7 @@ void noTone(uint8_t aPinNumber){
|
|||
#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)
|
||||
#if !defined(ARDUINO_SAMD_ADAFRUIT) && !defined(ARDUINO_SEEED_XIAO_M0)
|
||||
// On the Zero and others we switch explicitly to SerialUSB
|
||||
#define Serial SerialUSB
|
||||
#endif
|
||||
|
@ -274,13 +324,14 @@ void noTone(uint8_t aPinNumber){
|
|||
#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
|
||||
#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
|
||||
*/
|
||||
|
|
|
@ -2,14 +2,15 @@
|
|||
* ReceiveDump.cpp
|
||||
*
|
||||
* Dumps the received signal in different flavors.
|
||||
* Since the printing takes so much time, repeat signals may be skipped or interpreted as UNKNOWN.
|
||||
* 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-2022 Armin Joachimsmeyer
|
||||
* 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
|
||||
|
@ -32,26 +33,33 @@
|
|||
*/
|
||||
#include <Arduino.h>
|
||||
|
||||
#if RAMEND <= 0x4FF || (defined(RAMSIZE) && RAMSIZE < 0x4FF)
|
||||
#define RAW_BUFFER_LENGTH 180 // 750 (600 if we have only 2k RAM) is the value for air condition remotes. Default is 112 if DECODE_MAGIQUEST is enabled, otherwise 100.
|
||||
#elif RAMEND <= 0x8FF || (defined(RAMSIZE) && RAMSIZE < 0x8FF)
|
||||
#define RAW_BUFFER_LENGTH 600 // 750 (600 if we have only 2k RAM) is the value for air condition remotes. Default is 112 if DECODE_MAGIQUEST is enabled, otherwise 100.
|
||||
#else
|
||||
#define RAW_BUFFER_LENGTH 750 // 750 (600 if we have only 2k RAM) is the value for air condition remotes. Default is 112 if DECODE_MAGIQUEST is enabled, otherwise 100.
|
||||
#include "PinDefinitionsAndMore.h" // Define macros for input and output pin etc.
|
||||
|
||||
#if !defined(RAW_BUFFER_LENGTH)
|
||||
// For air condition remotes it requires 600 (maximum for 2k RAM) to 750. Default is 112 if DECODE_MAGIQUEST is enabled, otherwise 100.
|
||||
# if (defined(RAMEND) && RAMEND <= 0x4FF) || (defined(RAMSIZE) && RAMSIZE < 0x4FF)
|
||||
#define RAW_BUFFER_LENGTH 180
|
||||
# elif (defined(RAMEND) && RAMEND <= 0x8FF) || (defined(RAMSIZE) && RAMSIZE < 0x8FF)
|
||||
#define RAW_BUFFER_LENGTH 600
|
||||
# else
|
||||
#define RAW_BUFFER_LENGTH 750
|
||||
# endif
|
||||
#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 // recommended for the cheap VS1838 modules
|
||||
#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 // Activate it for some LG air conditioner protocols
|
||||
//#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 "PinDefinitionsAndMore.h" // Define macros for input and output pin etc.
|
||||
#include <IRremote.hpp>
|
||||
|
||||
//+=============================================================================
|
||||
|
@ -78,7 +86,12 @@ void setup() {
|
|||
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"));
|
||||
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();
|
||||
|
||||
}
|
||||
|
||||
//+=============================================================================
|
||||
|
@ -86,15 +99,18 @@ void setup() {
|
|||
//
|
||||
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("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
|
||||
} else {
|
||||
Serial.println(); // 2 blank lines between entries
|
||||
Serial.println();
|
||||
IrReceiver.printIRResultShort(&Serial);
|
||||
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();
|
||||
|
@ -103,13 +119,14 @@ void loop() {
|
|||
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 ticks (50 us) array - compensated with MARK_EXCESS_MICROS="));
|
||||
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);
|
||||
|
||||
|
@ -117,7 +134,7 @@ void loop() {
|
|||
* 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.
|
||||
* 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
|
||||
|
@ -132,6 +149,6 @@ void loop() {
|
|||
// Serial.println(); // blank line between entries
|
||||
// }
|
||||
}
|
||||
IrReceiver.resume(); // Prepare for the next value
|
||||
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 ";
|
|
@ -4,7 +4,7 @@
|
|||
* 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
|
||||
* Copyright (C) 2021-2023 Armin Joachimsmeyer
|
||||
* armin.joachimsmeyer@gmail.com
|
||||
*
|
||||
* This file is part of IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
|
||||
|
@ -16,8 +16,8 @@
|
|||
*
|
||||
* 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.
|
||||
* 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>.
|
||||
|
@ -29,68 +29,99 @@
|
|||
*
|
||||
* Platform IR input IR output Tone Core/Pin schema
|
||||
* --------------------------------------------------------------
|
||||
* DEFAULT/AVR 2 3 4
|
||||
* ATtinyX5 0|PB0 4|PB4 3|PB3
|
||||
* 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 pro
|
||||
* 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
|
||||
* BluePill PA6 PA7 PA3
|
||||
* ESP32 15 4 27
|
||||
* ESP32-C3 6 7 10
|
||||
* 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
|
||||
#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
|
||||
#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
|
||||
#define TONE_PIN 5 // PA7 - on Digispark board labeled as pin 5
|
||||
#define _IR_TIMING_TEST_PIN 10 // PA4
|
||||
# else
|
||||
#define IR_RECEIVE_PIN 3
|
||||
#define IR_SEND_PIN 2
|
||||
#define TONE_PIN 7
|
||||
// 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_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_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_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_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_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
|
||||
# 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
|
||||
#define TONE_PIN 42 // Dummy for examples using it
|
||||
|
||||
# elif defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) \
|
||||
|| defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) \
|
||||
|
@ -123,17 +154,33 @@
|
|||
# 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 13 // D7
|
||||
#define APPLICATION_PIN 0 // D3
|
||||
#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(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>
|
||||
|
||||
|
@ -166,10 +213,13 @@ void noTone(uint8_t aPinNumber){
|
|||
#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
|
||||
|
@ -234,7 +284,7 @@ void noTone(uint8_t aPinNumber){
|
|||
#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)
|
||||
#if !defined(ARDUINO_SAMD_ADAFRUIT) && !defined(ARDUINO_SEEED_XIAO_M0)
|
||||
// On the Zero and others we switch explicitly to SerialUSB
|
||||
#define Serial SerialUSB
|
||||
#endif
|
||||
|
@ -274,13 +324,14 @@ void noTone(uint8_t aPinNumber){
|
|||
#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
|
||||
#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
|
||||
*/
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
* 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.
|
||||
*
|
||||
************************************************************************************
|
||||
|
@ -34,14 +36,58 @@
|
|||
*/
|
||||
|
||||
// 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.
|
||||
// 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)
|
||||
* 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
|
||||
|
@ -73,12 +119,11 @@ void setup() {
|
|||
// 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);
|
||||
|
||||
IrSender.begin(IR_SEND_PIN, ENABLE_LED_FEEDBACK); // Specify send pin and enable feedback LED at default feedback LED pin
|
||||
|
||||
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)));
|
||||
}
|
||||
|
||||
|
@ -114,6 +159,7 @@ void loop() {
|
|||
* !!!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
|
||||
}
|
||||
}
|
||||
|
@ -144,7 +190,7 @@ void sendSamsungSmartHubMacro(bool aDoSelect) {
|
|||
}
|
||||
|
||||
# if !defined(ESP32)
|
||||
IrReceiver.stop(); // ESP32 uses another timer for tone()
|
||||
IrReceiver.stopTimer(); // ESP32 uses another timer for tone()
|
||||
# endif
|
||||
if (millis() < tWaitTimeAfterBoot) {
|
||||
// division by 1000 and printing requires much (8%) program memory
|
||||
|
@ -172,7 +218,7 @@ void sendSamsungSmartHubMacro(bool aDoSelect) {
|
|||
delay(200);
|
||||
|
||||
# if !defined(ESP32)
|
||||
IrReceiver.start(200000); // to compensate for 200 ms stop of receiver. This enables a correct gap measurement.
|
||||
IrReceiver.restartTimer(200000); // to compensate for 200 ms stop of receiver. This enables a correct gap measurement.
|
||||
# endif
|
||||
|
||||
Serial.println(F("Wait for \"not supported\" to disappear"));
|
||||
|
|
|
@ -23,8 +23,8 @@
|
|||
*
|
||||
* 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.
|
||||
* 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>.
|
||||
|
@ -33,8 +33,8 @@
|
|||
|
||||
#include <Arduino.h>
|
||||
|
||||
#define IR_INPUT_PIN 2
|
||||
//#define IR_INPUT_PIN 3
|
||||
#define IR_RECEIVE_PIN 2
|
||||
//#define IR_RECEIVE_PIN 3
|
||||
|
||||
/*
|
||||
* Helper macro for getting a macro definition as string
|
||||
|
@ -55,19 +55,19 @@ void setup()
|
|||
Serial.println(F("START " __FILE__ " from " __DATE__));
|
||||
|
||||
#if defined(EICRA) && defined(EIFR) && defined(EIMSK)
|
||||
# if (IR_INPUT_PIN == 2)
|
||||
# if (IR_RECEIVE_PIN == 2)
|
||||
EICRA |= _BV(ISC00); // interrupt on any logical change
|
||||
EIFR |= _BV(INTF0); // clear interrupt bit
|
||||
EIMSK |= _BV(INT0); // enable interrupt on next change
|
||||
# elif (IR_INPUT_PIN == 3)
|
||||
# elif (IR_RECEIVE_PIN == 3)
|
||||
EICRA |= _BV(ISC10); // enable interrupt on pin3 on both edges for ATmega328
|
||||
EIFR |= _BV(INTF1); // clear interrupt bit
|
||||
EIMSK |= _BV(INT1); // enable interrupt on next change
|
||||
# endif
|
||||
#else
|
||||
attachInterrupt(digitalPinToInterrupt(IR_INPUT_PIN), measureTimingISR, CHANGE);
|
||||
attachInterrupt(digitalPinToInterrupt(IR_RECEIVE_PIN), measureTimingISR, CHANGE);
|
||||
#endif
|
||||
Serial.println(F("Ready to analyze NEC IR signal at pin " STR(IR_INPUT_PIN)));
|
||||
Serial.println(F("Ready to analyze NEC IR signal at pin " STR(IR_RECEIVE_PIN)));
|
||||
Serial.println();
|
||||
}
|
||||
|
||||
|
@ -193,15 +193,13 @@ void loop()
|
|||
* The interrupt handler.
|
||||
* Just add to the appropriate timing structure.
|
||||
*/
|
||||
#if defined(ESP8266)
|
||||
void ICACHE_RAM_ATTR measureTimingISR()
|
||||
#elif defined(ESP32)
|
||||
#if defined(ESP8266) || defined(ESP32)
|
||||
void IRAM_ATTR measureTimingISR()
|
||||
#else
|
||||
# if defined(EICRA) && defined(EIFR) && defined(EIMSK)
|
||||
# if (IR_INPUT_PIN == 2)
|
||||
# if (IR_RECEIVE_PIN == 2)
|
||||
ISR(INT0_vect)
|
||||
# elif (IR_INPUT_PIN == 3)
|
||||
# elif (IR_RECEIVE_PIN == 3)
|
||||
ISR(INT1_vect)
|
||||
# endif
|
||||
# else
|
||||
|
@ -215,7 +213,7 @@ void measureTimingISR()
|
|||
/*
|
||||
* read level and give feedback
|
||||
*/
|
||||
uint8_t tInputLevel = digitalRead(IR_INPUT_PIN);
|
||||
uint8_t tInputLevel = digitalRead(IR_RECEIVE_PIN);
|
||||
digitalWrite(LED_BUILTIN, !tInputLevel);
|
||||
|
||||
if (tMicrosDelta > 10000)
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* 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
|
||||
* Copyright (C) 2021-2023 Armin Joachimsmeyer
|
||||
* armin.joachimsmeyer@gmail.com
|
||||
*
|
||||
* This file is part of IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
|
||||
|
@ -16,8 +16,8 @@
|
|||
*
|
||||
* 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.
|
||||
* 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>.
|
||||
|
@ -29,68 +29,99 @@
|
|||
*
|
||||
* Platform IR input IR output Tone Core/Pin schema
|
||||
* --------------------------------------------------------------
|
||||
* DEFAULT/AVR 2 3 4
|
||||
* ATtinyX5 0|PB0 4|PB4 3|PB3
|
||||
* 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 pro
|
||||
* 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
|
||||
* BluePill PA6 PA7 PA3
|
||||
* ESP32 15 4 27
|
||||
* ESP32-C3 6 7 10
|
||||
* 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
|
||||
#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
|
||||
#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
|
||||
#define TONE_PIN 5 // PA7 - on Digispark board labeled as pin 5
|
||||
#define _IR_TIMING_TEST_PIN 10 // PA4
|
||||
# else
|
||||
#define IR_RECEIVE_PIN 3
|
||||
#define IR_SEND_PIN 2
|
||||
#define TONE_PIN 7
|
||||
// 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_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_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_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_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_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
|
||||
# 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
|
||||
#define TONE_PIN 42 // Dummy for examples using it
|
||||
|
||||
# elif defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) \
|
||||
|| defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) \
|
||||
|
@ -123,17 +154,33 @@
|
|||
# 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 13 // D7
|
||||
#define APPLICATION_PIN 0 // D3
|
||||
#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(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>
|
||||
|
||||
|
@ -166,10 +213,13 @@ void noTone(uint8_t aPinNumber){
|
|||
#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
|
||||
|
@ -234,7 +284,7 @@ void noTone(uint8_t aPinNumber){
|
|||
#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)
|
||||
#if !defined(ARDUINO_SAMD_ADAFRUIT) && !defined(ARDUINO_SEEED_XIAO_M0)
|
||||
// On the Zero and others we switch explicitly to SerialUSB
|
||||
#define Serial SerialUSB
|
||||
#endif
|
||||
|
@ -274,13 +324,14 @@ void noTone(uint8_t aPinNumber){
|
|||
#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
|
||||
#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
|
||||
*/
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
************************************************************************************
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2021 Armin Joachimsmeyer
|
||||
* 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
|
||||
|
@ -34,13 +34,15 @@
|
|||
|
||||
// select only NEC and the universal decoder for pulse distance protocols
|
||||
#define DECODE_NEC // Includes Apple and Onkyo
|
||||
#define DECODE_DISTANCE // in case NEC is not received correctly
|
||||
#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
|
||||
//#define SEND_PWM_BY_TIMER
|
||||
//#define USE_NO_SEND_PWM
|
||||
//#define NO_LED_FEEDBACK_CODE // saves 500 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.
|
||||
|
||||
#include "PinDefinitionsAndMore.h" // Define macros for input and output pin etc.
|
||||
|
@ -60,18 +62,11 @@ void setup() {
|
|||
// 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);
|
||||
|
||||
#if defined(IR_SEND_PIN)
|
||||
IrSender.begin(); // Start with IR_SEND_PIN as send pin and enable feedback LED at default feedback LED pin
|
||||
#else
|
||||
IrSender.begin(3, ENABLE_LED_FEEDBACK); // Specify send pin and enable feedback LED at default feedback LED pin
|
||||
#endif
|
||||
|
||||
Serial.print(F("Ready to receive IR signals of protocols: "));
|
||||
printActiveIRProtocols(&Serial);
|
||||
Serial.println(F("at pin " STR(IR_RECEIVE_PIN)));
|
||||
|
||||
Serial.println(F("Ready to send IR signals at pin " STR(IR_SEND_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("Send IR signals at pin " STR(IR_SEND_PIN)));
|
||||
|
||||
#if FLASHEND >= 0x3FFF // For 16k flash or more, like ATtiny1604
|
||||
// For esp32 we use PWM generation by ledcWrite() for each pin.
|
||||
|
@ -109,6 +104,7 @@ void send_ir_data() {
|
|||
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) {
|
||||
|
@ -122,8 +118,12 @@ 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(F(", decoded raw data: "));
|
||||
#if (__INT_WIDTH__ < 32)
|
||||
Serial.print(IrReceiver.decodedIRData.decodedRawData, HEX);
|
||||
#else
|
||||
PrintULL::print(&Serial, IrReceiver.decodedIRData.decodedRawData, HEX);
|
||||
#endif
|
||||
Serial.print(F(", decoded address: "));
|
||||
Serial.print(IrReceiver.decodedIRData.address, HEX);
|
||||
Serial.print(F(", decoded command: "));
|
||||
|
@ -146,6 +146,8 @@ void loop() {
|
|||
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();
|
||||
|
|
|
@ -1,38 +1,39 @@
|
|||
START SendAndReceive.cpp from Apr 19 2021
|
||||
Using library version 3.1.1
|
||||
Ready to receive IR signals at pin D5
|
||||
Ready to send IR signals at pin D6
|
||||
Send signal mark duration is 7 us, pulse correction is 600 ns, total period is 26 us
|
||||
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: NECDecoded raw data: CB340102, decoded address: 102, decoded command: 34
|
||||
Decoded protocol: NEC2, decoded raw data: CB340102, decoded address: 102, decoded command: 34
|
||||
|
||||
address=0x203 command=0x45 repeats=2
|
||||
Sending: 0x203452
|
||||
Decoded protocol: NECDecoded raw data: BA450203, decoded address: 203, decoded command: 45
|
||||
Decoded protocol: NEC, decoded raw data: BA450203, decoded address: 203, decoded command: 45
|
||||
|
||||
address=0x304 command=0x56 repeats=3
|
||||
Sending: 0x304563
|
||||
Decoded protocol: NECDecoded raw data: A9560304, decoded address: 304, decoded command: 56
|
||||
Decoded protocol: NEC, decoded raw data: A9560304, decoded address: 304, decoded command: 56
|
||||
|
||||
address=0x405 command=0x67 repeats=4
|
||||
Sending: 0x405674
|
||||
Decoded protocol: NECDecoded raw data: 98670405, decoded address: 405, decoded command: 67
|
||||
Decoded protocol: NEC, decoded raw data: 98670405, decoded address: 405, decoded command: 67
|
||||
|
||||
address=0x506 command=0x78 repeats=5
|
||||
Sending: 0x506785
|
||||
Decoded protocol: NECDecoded raw data: 87780506, decoded address: 506, decoded command: 78
|
||||
Decoded protocol: NEC, decoded raw data: 87780506, decoded address: 506, decoded command: 78
|
||||
|
||||
address=0x607 command=0x89 repeats=5
|
||||
Sending: 0x607895
|
||||
Decoded protocol: NECDecoded raw data: 76890607, decoded address: 607, decoded command: 89
|
||||
Decoded protocol: NEC, decoded raw data: 76890607, decoded address: 607, decoded command: 89
|
||||
|
||||
address=0x708 command=0x9A repeats=5
|
||||
Sending: 0x7089A5
|
||||
Decoded protocol: NECDecoded raw data: 659A0708, decoded address: 708, decoded command: 9A
|
||||
Decoded protocol: NEC, decoded raw data: 659A0708, decoded address: 708, decoded command: 9A
|
||||
|
||||
address=0x809 command=0xAB repeats=5
|
||||
Sending: 0x809AB5
|
||||
Decoded protocol: NECDecoded raw data: 54AB0809, decoded address: 809, decoded command: AB
|
||||
Decoded protocol: NEC, decoded raw data: 54AB0809, decoded address: 809, decoded command: AB
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* 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
|
||||
* Copyright (C) 2021-2023 Armin Joachimsmeyer
|
||||
* armin.joachimsmeyer@gmail.com
|
||||
*
|
||||
* This file is part of IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
|
||||
|
@ -16,8 +16,8 @@
|
|||
*
|
||||
* 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.
|
||||
* 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>.
|
||||
|
@ -29,68 +29,99 @@
|
|||
*
|
||||
* Platform IR input IR output Tone Core/Pin schema
|
||||
* --------------------------------------------------------------
|
||||
* DEFAULT/AVR 2 3 4
|
||||
* ATtinyX5 0|PB0 4|PB4 3|PB3
|
||||
* 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 pro
|
||||
* 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
|
||||
* BluePill PA6 PA7 PA3
|
||||
* ESP32 15 4 27
|
||||
* ESP32-C3 6 7 10
|
||||
* 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
|
||||
#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
|
||||
#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
|
||||
#define TONE_PIN 5 // PA7 - on Digispark board labeled as pin 5
|
||||
#define _IR_TIMING_TEST_PIN 10 // PA4
|
||||
# else
|
||||
#define IR_RECEIVE_PIN 3
|
||||
#define IR_SEND_PIN 2
|
||||
#define TONE_PIN 7
|
||||
// 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_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_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_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_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_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
|
||||
# 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
|
||||
#define TONE_PIN 42 // Dummy for examples using it
|
||||
|
||||
# elif defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) \
|
||||
|| defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) \
|
||||
|
@ -123,17 +154,33 @@
|
|||
# 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 13 // D7
|
||||
#define APPLICATION_PIN 0 // D3
|
||||
#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(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>
|
||||
|
||||
|
@ -166,10 +213,13 @@ void noTone(uint8_t aPinNumber){
|
|||
#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
|
||||
|
@ -234,7 +284,7 @@ void noTone(uint8_t aPinNumber){
|
|||
#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)
|
||||
#if !defined(ARDUINO_SAMD_ADAFRUIT) && !defined(ARDUINO_SEEED_XIAO_M0)
|
||||
// On the Zero and others we switch explicitly to SerialUSB
|
||||
#define Serial SerialUSB
|
||||
#endif
|
||||
|
@ -274,13 +324,14 @@ void noTone(uint8_t aPinNumber){
|
|||
#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
|
||||
#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
|
||||
*/
|
||||
|
|
|
@ -33,6 +33,10 @@
|
|||
*/
|
||||
#include <Arduino.h>
|
||||
|
||||
#if !defined(ARDUINO_ESP32C3_DEV) // This is due to a bug in RISC-V compiler, which requires unused function sections :-(.
|
||||
#define DISABLE_CODE_FOR_RECEIVER // Disables static receiver code like receive timer ISR handler and static IRReceiver and irparams data. Saves 450 bytes program memory and 269 bytes RAM if receiving functions are not required.
|
||||
#endif
|
||||
|
||||
#include "PinDefinitionsAndMore.h" // Define macros for input and output pin etc.
|
||||
#include <IRremote.hpp>
|
||||
|
||||
|
@ -94,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();
|
||||
|
@ -108,10 +116,17 @@ void setup() {
|
|||
// Just to know which program is running on my Arduino
|
||||
Serial.println(F("START " __FILE__ " from " __DATE__ "\r\nUsing library version " VERSION_IRREMOTE));
|
||||
|
||||
IrSender.begin(IR_SEND_PIN, ENABLE_LED_FEEDBACK); // Specify send pin and enable feedback LED at default feedback LED pin
|
||||
#if defined(IR_SEND_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("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("Ready to send IR signals at pin "));
|
||||
Serial.println(IR_SEND_PIN);
|
||||
Serial.print(F("Send IR signals at pin "));
|
||||
Serial.println(tSendPin);
|
||||
#endif
|
||||
|
||||
sPrintMenu = true;
|
||||
}
|
||||
|
|
|
@ -1,151 +1,178 @@
|
|||
START ../src/ReceiveDemo.cpp from Mar 8 2021
|
||||
Using library version 3.1.0
|
||||
START ../src/ReceiveDemo.cpp from Feb 24 2023
|
||||
Using library version 4.1.0
|
||||
Enabling IRin...
|
||||
Ready to receive IR signals at pin 2
|
||||
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=0x102 Command=0x34 Parity fail Raw-Data=0xC0340102 32 bits LSB first
|
||||
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=APPLE Address=0x2 Command=0x34 Raw-Data=0x23487EE 32 bits LSB first
|
||||
Protocol=Panasonic Address=0xB Command=0x10 Raw-Data=0xA01000B0 48 bits LSB first
|
||||
Send with: IrSender.sendPanasonic(0xB, 0x10, <numberOfRepeats>);
|
||||
|
||||
Protocol=PANASONIC Address=0x102 Command=0x34 Raw-Data=0x4341020 48 bits LSB first
|
||||
Protocol=Panasonic Address=0xB Command=0x10 Raw-Data=0xA01000B0 48 bits LSB first
|
||||
Send with: IrSender.sendPanasonic(0xB, 0x10, <numberOfRepeats>);
|
||||
|
||||
Protocol=KASEIKYO Address=0x102 Command=0x34 Extra=0x4711 Raw-Data=0x7341023 48 bits LSB first
|
||||
Protocol=Panasonic Address=0xB Command=0x10 Raw-Data=0xA01000B0 48 bits LSB first
|
||||
Send with: IrSender.sendPanasonic(0xB, 0x10, <numberOfRepeats>);
|
||||
|
||||
Protocol=DENON Address=0x2 Command=0x34 Raw-Data=0x8D0 15 bits MSB first
|
||||
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=DENON Address=0x2 Command=0x34 Auto-Repeat gap=44550us Raw-Data=0xB2F 15 bits MSB first
|
||||
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=SHARP Address=0x2 Command=0x34 Raw-Data=0x8D2 15 bits MSB first
|
||||
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=SHARP Address=0x2 Command=0x34 Auto-Repeat gap=44600us Raw-Data=0xB2D 15 bits MSB first
|
||||
Protocol=Onkyo Address=0x102 Command=0x5634 Raw-Data=0x56340102 32 bits LSB first
|
||||
Send with: IrSender.sendOnkyo(0x102, 0x5634, <numberOfRepeats>);
|
||||
|
||||
Protocol=SONY Address=0x2 Command=0x34 Raw-Data=0x134 12 bits LSB first
|
||||
Protocol=Apple Address=0x2 Command=0x34 Raw-Data=0x23487EE 32 bits LSB first
|
||||
Send with: IrSender.sendApple(0x2, 0x34, <numberOfRepeats>);
|
||||
|
||||
Protocol=SONY Address=0x2 Command=0x34 Raw-Data=0x134 15 bits LSB first
|
||||
Protocol=Panasonic Address=0x102 Command=0x34 Raw-Data=0x4341020 48 bits LSB first
|
||||
Send with: IrSender.sendPanasonic(0x102, 0x34, <numberOfRepeats>);
|
||||
|
||||
Protocol=SONY Address=0x0 Command=0x0 Raw-Data=0x0 0 bits LSB first
|
||||
Protocol=Kaseikyo Address=0x102 Command=0x34 Extra=0x4711 Raw-Data=0x7341023 48 bits LSB first
|
||||
Send with: IrSender.sendKaseikyo(0x102, 0x34, <numberOfRepeats>, 0x4711);
|
||||
|
||||
Protocol=SONY Address=0x102 Command=0x34 Raw-Data=0x8134 20 bits LSB first
|
||||
Protocol=Kaseikyo_Denon Address=0x102 Command=0x34 Raw-Data=0x4341020 48 bits LSB first
|
||||
Send with: IrSender.sendKaseikyo_Denon(0x102, 0x34, <numberOfRepeats>);
|
||||
|
||||
Protocol=RC5 Address=0x2 Command=0x34 Toggle=1 Raw-Data=0x38B4 13 bits MSB first
|
||||
Protocol=Denon Address=0x2 Command=0x34 Raw-Data=0x682 15 bits LSB first
|
||||
Send with: IrSender.sendDenon(0x2, 0x34, <numberOfRepeats>);
|
||||
|
||||
Protocol=RC5 Address=0x2 Command=0x74 Raw-Data=0x20B4 13 bits MSB first
|
||||
Protocol=Denon Address=0x2 Command=0x34 Auto-Repeat gap=45650us Raw-Data=0x7962 15 bits LSB first
|
||||
|
||||
Protocol=RC6 Address=0x2 Command=0x34 Raw-Data=0x234 16 bits MSB first
|
||||
Protocol=Sharp Address=0x2 Command=0x34 Raw-Data=0x4682 15 bits LSB first
|
||||
Send with: IrSender.sendSharp(0x2, 0x34, <numberOfRepeats>);
|
||||
|
||||
Protocol=SAMSUNG Address=0x102 Command=0x34 Raw-Data=0xCB340102 32 bits LSB first
|
||||
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=LG Address=0x2 Command=0x34 Raw-Data=0x200347 28 bits MSB first
|
||||
Protocol=Samsung Address=0x102 Command=0x5634 Raw-Data=0x56340102 32 bits LSB first
|
||||
Send with: IrSender.sendSamsung(0x102, 0x5634, <numberOfRepeats>);
|
||||
|
||||
Protocol=BOSEWAVE Address=0x0 Command=0x34 Raw-Data=0xCB34 16 bits LSB first
|
||||
Protocol=LG Address=0x2 Command=0x5634 Raw-Data=0x256342 28 bits MSB first
|
||||
Send with: IrSender.sendLG(0x2, 0x5634, <numberOfRepeats>);
|
||||
|
||||
Protocol=LEGO_PF Address=0x3 Command=0x14 Raw-Data=0x2148 16 bits MSB first
|
||||
Protocol=MagiQuest Address=0x102 Command=0x34 Raw-Data=0x6BCD0102 56 bits MSB first
|
||||
Send with: IrSender.sendMagiQuest(0x6BCD0102, 0x34, <numberOfRepeats>);
|
||||
|
||||
Protocol=LEGO_PF Address=0x3 Command=0x14 Auto-Repeat gap=216800us Raw-Data=0x2148 16 bits MSB first
|
||||
Protocol=BoseWave Address=0x0 Command=0x34 Raw-Data=0xCB34 16 bits LSB first
|
||||
Send with: IrSender.sendBoseWave(0x0, 0x34, <numberOfRepeats>);
|
||||
|
||||
Protocol=LEGO_PF Address=0x2 Command=0x14 Auto-Repeat gap=177200us Raw-Data=0x2148 16 bits MSB first
|
||||
Protocol=FAST Address=0x0 Command=0x34 Raw-Data=0xCB34 16 bits LSB first
|
||||
Send with: IrSender.sendFAST(0x0, 0x34, <numberOfRepeats>);
|
||||
|
||||
Protocol=LEGO_PF Address=0x2 Command=0x14 Auto-Repeat gap=177200us Raw-Data=0x2148 16 bits MSB first
|
||||
Protocol=Lego Address=0x2 Command=0x14 Raw-Data=0x2148 16 bits MSB first
|
||||
Send with: IrSender.sendLego(0x2, 0x14, <numberOfRepeats>);
|
||||
|
||||
Protocol=LEGO_PF Address=0x2 Command=0x14 Auto-Repeat gap=177200us Raw-Data=0x2148 16 bits MSB first
|
||||
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=47550us
|
||||
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=APPLE Address=0x3 Command=0x45 Raw-Data=0x34587EE 32 bits LSB first
|
||||
Protocol=NEC Address=0x203 Command=0x45 Raw-Data=0xBA450203 32 bits LSB first
|
||||
Send with: IrSender.sendNEC(0x203, 0x45, <numberOfRepeats>);
|
||||
|
||||
Protocol=APPLE Address=0x3 Command=0x45 Repeat gap=47550us
|
||||
Protocol=NEC2 Address=0x203 Command=0x45 Repeat gap=46500us Raw-Data=0xBA450203 32 bits LSB first
|
||||
|
||||
Protocol=PANASONIC Address=0x203 Command=0x45 Raw-Data=0x55452030 48 bits LSB first
|
||||
Protocol=Onkyo Address=0x203 Command=0x6745 Raw-Data=0x67450203 32 bits LSB first
|
||||
Send with: IrSender.sendOnkyo(0x203, 0x6745, <numberOfRepeats>);
|
||||
|
||||
Protocol=PANASONIC Address=0x203 Command=0x45 Repeat gap=73250us Raw-Data=0x55452030 48 bits LSB first
|
||||
Protocol=Onkyo Address=0x203 Command=0x6745 Repeat gap=46550us
|
||||
|
||||
Protocol=KASEIKYO Address=0x203 Command=0x45 Extra=0x4711 Raw-Data=0x56452033 48 bits LSB first
|
||||
Protocol=Apple Address=0x3 Command=0x45 Raw-Data=0x34587EE 32 bits LSB first
|
||||
Send with: IrSender.sendApple(0x3, 0x45, <numberOfRepeats>);
|
||||
|
||||
Protocol=KASEIKYO Address=0x203 Command=0x45 Extra=0x4711 Repeat gap=73250us Raw-Data=0x56452033 48 bits LSB first
|
||||
Protocol=Apple Address=0x3 Command=0x45 Repeat gap=31550us
|
||||
|
||||
Protocol=DENON Address=0x3 Command=0x45 Raw-Data=0xD14 15 bits MSB first
|
||||
Protocol=Panasonic Address=0x203 Command=0x45 Raw-Data=0x55452030 48 bits LSB first
|
||||
Send with: IrSender.sendPanasonic(0x203, 0x45, <numberOfRepeats>);
|
||||
|
||||
Protocol=DENON Address=0x3 Command=0x45 Auto-Repeat gap=44550us Raw-Data=0xEEB 15 bits MSB first
|
||||
Protocol=Panasonic Address=0x203 Command=0x45 Repeat gap=72550us Raw-Data=0x55452030 48 bits LSB first
|
||||
|
||||
Protocol=DENON Address=0x3 Command=0x45 Repeat gap=44550us Raw-Data=0xD14 15 bits MSB 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=DENON Address=0x3 Command=0x45 Auto-Repeat gap=44550us Raw-Data=0xEEB 15 bits MSB first
|
||||
Protocol=Kaseikyo Address=0x203 Command=0x45 Extra=0x4711 Repeat gap=66750us Raw-Data=0x56452033 48 bits LSB first
|
||||
|
||||
Protocol=SHARP Address=0x3 Command=0x45 Raw-Data=0xD16 15 bits MSB first
|
||||
|
||||
Protocol=SHARP Address=0x3 Command=0x45 Auto-Repeat gap=44550us Raw-Data=0xEE9 15 bits MSB first
|
||||
|
||||
Protocol=SHARP Address=0x3 Command=0x45 Repeat gap=44550us Raw-Data=0xD16 15 bits MSB first
|
||||
|
||||
Protocol=SHARP Address=0x3 Command=0x45 Auto-Repeat gap=44550us Raw-Data=0xEE9 15 bits MSB first
|
||||
|
||||
Protocol=SONY Address=0x3 Command=0x45 Raw-Data=0x1C5 12 bits LSB first
|
||||
|
||||
Protocol=SONY Address=0x3 Command=0x45 Repeat gap=24350us Raw-Data=0x1C5 12 bits LSB first
|
||||
|
||||
Protocol=SONY Address=0x3 Command=0x45 Raw-Data=0x1C5 15 bits LSB first
|
||||
|
||||
Protocol=SONY Address=0x3 Command=0x45 Repeat gap=24350us Raw-Data=0x1C5 15 bits LSB first
|
||||
|
||||
Protocol=SONY Address=0x203 Command=0x45 Raw-Data=0x101C5 20 bits LSB first
|
||||
|
||||
Protocol=SONY Address=0x203 Command=0x45 Repeat gap=24300us Raw-Data=0x101C5 20 bits LSB first
|
||||
|
||||
Protocol=RC5 Address=0x3 Command=0x5 Raw-Data=0x30C5 13 bits MSB first
|
||||
|
||||
Protocol=RC5 Address=0x3 Command=0x5 Repeat gap=99000us Raw-Data=0x30C5 13 bits MSB first
|
||||
|
||||
Protocol=RC5 Address=0x3 Command=0x45 Toggle=1 Raw-Data=0x28C5 13 bits MSB first
|
||||
|
||||
Protocol=RC5 Address=0x3 Command=0x45 Toggle=1 Repeat gap=98950us Raw-Data=0x28C5 13 bits MSB first
|
||||
|
||||
Protocol=RC6 Address=0x3 Command=0x45 Raw-Data=0x345 16 bits MSB first
|
||||
|
||||
Protocol=RC6 Address=0x3 Command=0x45 Repeat gap=106400us Raw-Data=0x345 16 bits MSB first
|
||||
|
||||
Protocol=SAMSUNG Address=0x203 Command=0x45 Raw-Data=0xBA450203 32 bits LSB first
|
||||
|
||||
Protocol=SAMSUNG Address=0x203 Command=0x45 Repeat gap=54500us
|
||||
|
||||
Protocol=JVC Address=0x3 Command=0x45 Raw-Data=0x4503 16 bits LSB first
|
||||
|
||||
Protocol=JVC Address=0x3 Command=0x45 Repeat gap=22750us
|
||||
|
||||
Protocol=LG Address=0x3 Command=0x45 Raw-Data=0x300459 28 bits MSB first
|
||||
|
||||
Protocol=LG Address=0x3 Command=0x45 Repeat gap=51500us
|
||||
|
||||
Protocol=BOSEWAVE Address=0x0 Command=0x45 Raw-Data=0xBA45 16 bits LSB first
|
||||
|
||||
Protocol=BOSEWAVE Address=0x0 Command=0x45 Repeat gap=51450us Raw-Data=0xBA45 16 bits LSB first
|
||||
|
||||
Protocol=LEGO_PF Address=0x3 Command=0x15 Raw-Data=0x3158 16 bits MSB first
|
||||
|
||||
Protocol=LEGO_PF Address=0x3 Command=0x15 Auto-Repeat gap=216800us Raw-Data=0x3158 16 bits MSB first
|
||||
|
||||
Protocol=LEGO_PF Address=0x3 Command=0x15 Auto-Repeat gap=216800us Raw-Data=0x3158 16 bits MSB first
|
||||
|
||||
Protocol=LEGO_PF Address=0x3 Command=0x15 Auto-Repeat gap=216800us Raw-Data=0x3158 16 bits MSB first
|
||||
|
||||
Protocol=LEGO_PF Address=0x3 Command=0x15 Auto-Repeat gap=216800us Raw-Data=0x3158 16 bits MSB first
|
||||
|
||||
Overflow detected
|
||||
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
|
|
@ -4,7 +4,7 @@
|
|||
* 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
|
||||
* Copyright (C) 2021-2023 Armin Joachimsmeyer
|
||||
* armin.joachimsmeyer@gmail.com
|
||||
*
|
||||
* This file is part of IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
|
||||
|
@ -16,8 +16,8 @@
|
|||
*
|
||||
* 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.
|
||||
* 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>.
|
||||
|
@ -29,68 +29,99 @@
|
|||
*
|
||||
* Platform IR input IR output Tone Core/Pin schema
|
||||
* --------------------------------------------------------------
|
||||
* DEFAULT/AVR 2 3 4
|
||||
* ATtinyX5 0|PB0 4|PB4 3|PB3
|
||||
* 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 pro
|
||||
* 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
|
||||
* BluePill PA6 PA7 PA3
|
||||
* ESP32 15 4 27
|
||||
* ESP32-C3 6 7 10
|
||||
* 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
|
||||
#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
|
||||
#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
|
||||
#define TONE_PIN 5 // PA7 - on Digispark board labeled as pin 5
|
||||
#define _IR_TIMING_TEST_PIN 10 // PA4
|
||||
# else
|
||||
#define IR_RECEIVE_PIN 3
|
||||
#define IR_SEND_PIN 2
|
||||
#define TONE_PIN 7
|
||||
// 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_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_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_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_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_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
|
||||
# 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
|
||||
#define TONE_PIN 42 // Dummy for examples using it
|
||||
|
||||
# elif defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) \
|
||||
|| defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) \
|
||||
|
@ -123,17 +154,33 @@
|
|||
# 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 13 // D7
|
||||
#define APPLICATION_PIN 0 // D3
|
||||
#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(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>
|
||||
|
||||
|
@ -166,10 +213,13 @@ void noTone(uint8_t aPinNumber){
|
|||
#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
|
||||
|
@ -234,7 +284,7 @@ void noTone(uint8_t aPinNumber){
|
|||
#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)
|
||||
#if !defined(ARDUINO_SAMD_ADAFRUIT) && !defined(ARDUINO_SEEED_XIAO_M0)
|
||||
// On the Zero and others we switch explicitly to SerialUSB
|
||||
#define Serial SerialUSB
|
||||
#endif
|
||||
|
@ -274,13 +324,14 @@ void noTone(uint8_t aPinNumber){
|
|||
#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
|
||||
#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
|
||||
*/
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
************************************************************************************
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2020-2022 Armin Joachimsmeyer
|
||||
* 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
|
||||
|
@ -32,13 +32,19 @@
|
|||
|
||||
#include <Arduino.h>
|
||||
|
||||
#include "PinDefinitionsAndMore.h" // Define macros for input and output pin etc.
|
||||
|
||||
#if !defined(ARDUINO_ESP32C3_DEV) // This is due to a bug in RISC-V compiler, which requires unused function sections :-(.
|
||||
#define DISABLE_CODE_FOR_RECEIVER // Disables static receiver code like receive timer ISR handler and static IRReceiver and irparams data. Saves 450 bytes program memory and 269 bytes RAM if receiving functions are not required.
|
||||
#endif
|
||||
//#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 USE_OPEN_DRAIN_OUTPUT_FOR_SEND_PIN // Use or simulate open drain output mode at send pin. Attention, active state of open drain is LOW, so connect the send LED between positive supply and send pin!
|
||||
//#define NO_LED_FEEDBACK_CODE // Saves 566 bytes program memory
|
||||
//#define USE_OPEN_DRAIN_OUTPUT_FOR_SEND_PIN // Use or simulate open drain output mode at send pin. Attention, active state of open drain is LOW, so connect the send LED between positive supply and send pin!
|
||||
|
||||
#include "PinDefinitionsAndMore.h" // Define macros for input and output pin etc.
|
||||
//#undef IR_SEND_PIN // enable this, if you need to set send pin programmatically using uint8_t tSendPin below
|
||||
#include <IRremote.hpp>
|
||||
|
||||
#define DELAY_AFTER_SEND 2000
|
||||
|
@ -54,25 +60,31 @@ void setup() {
|
|||
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
|
||||
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
|
||||
# if defined(IR_SEND_PIN_STRING)
|
||||
Serial.println(F("Send IR signals at pin " IR_SEND_PIN_STRING));
|
||||
# else
|
||||
Serial.println(F("Send IR signals at pin " STR(IR_SEND_PIN)));
|
||||
# endif
|
||||
#else
|
||||
IrSender.begin(3, ENABLE_LED_FEEDBACK); // Specify send pin and enable feedback LED at default feedback LED pin
|
||||
#endif
|
||||
// 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();
|
||||
|
||||
#if defined(IR_SEND_PIN)
|
||||
Serial.println(F("Ready to send IR signals at pin " STR(IR_SEND_PIN)));
|
||||
#else
|
||||
Serial.println(F("Ready to send IR signals at pin 3"));
|
||||
Serial.print(F("Send IR signals at pin "));
|
||||
Serial.println(tSendPin);
|
||||
#endif
|
||||
|
||||
#if !defined(SEND_PWM_BY_TIMER)
|
||||
/*
|
||||
* Print internal signal generation info
|
||||
* Print internal software PWM signal generation info
|
||||
*/
|
||||
IrSender.enableIROut(38); // Call it with 38 kHz to initialize the values printed below
|
||||
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 correction is "));
|
||||
Serial.print(F(" us, pulse narrowing correction is "));
|
||||
Serial.print(IrSender.getPulseCorrectionNanos());
|
||||
Serial.print(F(" ns, total period is "));
|
||||
Serial.print(IrSender.periodTimeMicros);
|
||||
|
@ -88,6 +100,7 @@ void setup() {
|
|||
*/
|
||||
uint16_t sAddress = 0x0102;
|
||||
uint8_t sCommand = 0x34;
|
||||
uint16_t s16BitCommand = 0x5634;
|
||||
uint8_t sRepeats = 0;
|
||||
|
||||
void loop() {
|
||||
|
@ -115,8 +128,13 @@ void loop() {
|
|||
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) {
|
||||
#if FLASHEND >= 0x3FFF // For 16k flash or more, like ATtiny1604. Code does not fit in program memory of ATtiny85 etc.
|
||||
#if FLASHEND >= 0x3FFF && ((defined(RAMEND) && RAMEND > 0x6FF) || (defined(RAMSIZE) && RAMSIZE > 0x6FF)) // For 16k flash or more, like ATtiny1604. Code does not fit in program memory of ATtiny85 etc.
|
||||
/*
|
||||
* Send constant values only once in this demo
|
||||
*/
|
||||
|
@ -130,7 +148,11 @@ void loop() {
|
|||
"0017 0806"), 0); //stop bit, no repeat possible, because of missing repeat pattern
|
||||
delay(DELAY_AFTER_SEND);
|
||||
|
||||
Serial.println(F("Send NEC 16 bit address=0xFB04 and command 0x08 with exact timing (16 bit array format)"));
|
||||
/*
|
||||
* !!! 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,
|
||||
|
@ -140,34 +162,38 @@ void loop() {
|
|||
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);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* With sendNECRaw() you can send 32 bit combined codes
|
||||
*/
|
||||
Serial.println(F("Send NEC / ONKYO with 16 bit address 0x0102 and 16 bit command 0x0304 with NECRaw(0x03040102)"));
|
||||
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);
|
||||
|
||||
Serial.println(F("Send NEC with 16 bit address 0x0102 and 16 bit command 0x0304 with sendPulseDistanceWidthData()"));
|
||||
// Header
|
||||
IrSender.mark(9000);
|
||||
IrSender.space(4500);
|
||||
// LSB first + stop bit
|
||||
IrSender.sendPulseDistanceWidthData(560, 1680, 560, 560, 0x03040102, 32, PROTOCOL_IS_LSB_FIRST, SEND_STOP_BIT);
|
||||
IrReceiver.restartAfterSend();
|
||||
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();
|
||||
Serial.println(F("Send NEC with 16 bit address 0x0102 and command 0x34 with old 32 bit format MSB first"));
|
||||
IrSender.sendNECMSB(0x40802CD3, 32, false);
|
||||
delay(DELAY_AFTER_SEND);
|
||||
#endif
|
||||
|
||||
Serial.println(F("Send Panasonic 0xB, 0x10 as 48 bit PulseDistance using ProtocolConstants"));
|
||||
Serial.flush();
|
||||
#if __INT_WIDTH__ < 32
|
||||
IRRawDataType tRawData[] = { 0xB02002, 0xA010 }; // LSB of tRawData[0] is sent first
|
||||
IrSender.sendPulseDistanceWidthFromArray(&KaseikyoProtocolConstants, &tRawData[0], 48, NO_REPEATS); // Panasonic is a Kaseikyo variant
|
||||
#else
|
||||
IrSender.sendPulseDistanceWidth(&KaseikyoProtocolConstants, 0xA010B02002, 48, NO_REPEATS); // Panasonic is a Kaseikyo variant
|
||||
#endif
|
||||
|
||||
delay(DELAY_AFTER_SEND);
|
||||
|
||||
/*
|
||||
* Send 2 Panasonic 48 bit codes as generic Pulse Distance data, once with LSB and once with MSB first
|
||||
|
@ -175,21 +201,64 @@ void loop() {
|
|||
Serial.println(F("Send Panasonic 0xB, 0x10 as generic 48 bit PulseDistance"));
|
||||
Serial.println(F(" LSB first"));
|
||||
Serial.flush();
|
||||
uint32_t tRawData[] = { 0xB02002, 0xA010 }; // LSB of tRawData[0] is sent first
|
||||
IrSender.sendPulseDistanceWidthFromArray(38, 3450, 1700, 450, 1250, 450, 400, &tRawData[0], 48, false, 0, 0);
|
||||
#if __INT_WIDTH__ < 32
|
||||
IrSender.sendPulseDistanceWidthFromArray(38, 3450, 1700, 450, 1250, 450, 400, &tRawData[0], 48,
|
||||
PROTOCOL_IS_LSB_FIRST, 0, NO_REPEATS);
|
||||
#else
|
||||
IrSender.sendPulseDistanceWidth(38, 3450, 1700, 450, 1250, 450, 400, 0xA010B02002, 48, PROTOCOL_IS_LSB_FIRST,
|
||||
0, NO_REPEATS);
|
||||
#endif
|
||||
delay(DELAY_AFTER_SEND);
|
||||
|
||||
// The same with MSB first. Use bit reversed raw data of LSB first part
|
||||
Serial.println(F(" MSB first"));
|
||||
#if __INT_WIDTH__ < 32
|
||||
tRawData[0] = 0x40040D00; // MSB of tRawData[0] is sent first
|
||||
tRawData[1] = 0x805;
|
||||
IrSender.sendPulseDistanceWidthFromArray(38, 3450, 1700, 450, 1250, 450, 400, &tRawData[0], 48, true, 0, 0);
|
||||
IrSender.sendPulseDistanceWidthFromArray(38, 3450, 1700, 450, 1250, 450, 400, &tRawData[0], 48,
|
||||
PROTOCOL_IS_MSB_FIRST, 0, NO_REPEATS);
|
||||
#else
|
||||
IrSender.sendPulseDistanceWidth(38, 3450, 1700, 450, 1250, 450, 400, 0x40040D000805, 48, PROTOCOL_IS_MSB_FIRST,
|
||||
0, NO_REPEATS);
|
||||
#endif
|
||||
delay(DELAY_AFTER_SEND);
|
||||
|
||||
Serial.println(F("Send generic 72 bit PulseDistance 0x5A AFEDCBA9 87654321 LSB first"));
|
||||
Serial.flush();
|
||||
# if __INT_WIDTH__ < 32
|
||||
tRawData[0] = 0x87654321; // LSB of tRawData[0] is sent first
|
||||
tRawData[1] = 0xAFEDCBA9;
|
||||
tRawData[2] = 0x5A;
|
||||
IrSender.sendPulseDistanceWidthFromArray(38, 8900, 4450, 550, 1700, 550, 600, &tRawData[0], 72, PROTOCOL_IS_LSB_FIRST, 0,
|
||||
NO_REPEATS);
|
||||
# else
|
||||
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);
|
||||
# endif
|
||||
delay(DELAY_AFTER_SEND);
|
||||
|
||||
Serial.println(F("Send generic 52 bit PulseDistanceWidth 0xDCBA9 87654321 LSB first"));
|
||||
Serial.flush();
|
||||
// Real PulseDistanceWidth (constant bit length) does not require a stop bit
|
||||
#if __INT_WIDTH__ < 32
|
||||
IrSender.sendPulseDistanceWidthFromArray(38, 300, 600, 600, 300, 300, 600, &tRawData[0], 52,
|
||||
PROTOCOL_IS_LSB_FIRST, 0, 0);
|
||||
#else
|
||||
IrSender.sendPulseDistanceWidth(38, 300, 600, 600, 300, 300, 600, 0xDCBA987654321, 52, PROTOCOL_IS_LSB_FIRST,
|
||||
0, 0);
|
||||
#endif
|
||||
delay(DELAY_AFTER_SEND);
|
||||
|
||||
Serial.println(F("Send generic 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, sCommand << 8 | sCommand, sRepeats);
|
||||
IrSender.sendOnkyo(sAddress, s16BitCommand, sRepeats);
|
||||
delay(DELAY_AFTER_SEND);
|
||||
|
||||
Serial.println(F("Send Apple"));
|
||||
|
@ -237,6 +306,21 @@ void loop() {
|
|||
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
|
||||
|
@ -252,7 +336,7 @@ void loop() {
|
|||
IrSender.sendRC6(sAddress, sCommand, sRepeats, true);
|
||||
delay(DELAY_AFTER_SEND);
|
||||
|
||||
#if FLASHEND >= 0x3FFF // For 16k flash or more, like ATtiny1604. Code does not fit in program memory of ATtiny85 etc.
|
||||
#if FLASHEND >= 0x3FFF && ((defined(RAMEND) && RAMEND > 0x4FF) || (defined(RAMSIZE) && RAMSIZE > 0x4FF)) // For 16k flash or more, like ATtiny1604. Code does not fit in program memory of ATtiny85 etc.
|
||||
/*
|
||||
* Next example how to use the IrSender.write function
|
||||
*/
|
||||
|
@ -262,6 +346,9 @@ void loop() {
|
|||
IRSendData.command = sCommand;
|
||||
IRSendData.flags = IRDATA_FLAGS_EMPTY;
|
||||
|
||||
Serial.println(F("Send next protocols with IrSender.write"));
|
||||
Serial.flush();
|
||||
|
||||
IRSendData.protocol = SAMSUNG;
|
||||
Serial.print(F("Send "));
|
||||
Serial.println(getProtocolString(IRSendData.protocol));
|
||||
|
@ -276,6 +363,15 @@ void loop() {
|
|||
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));
|
||||
|
@ -283,12 +379,30 @@ void loop() {
|
|||
IrSender.write(&IRSendData, sRepeats);
|
||||
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);
|
||||
|
||||
// Bang&Olufsen must be sent with 455 kHz
|
||||
// Serial.println(F("Send Bang&Olufsen"));
|
||||
// Serial.flush();
|
||||
// IrSender.sendBangOlufsen(sAddress, sCommand, 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
|
||||
*/
|
||||
|
@ -301,8 +415,8 @@ void loop() {
|
|||
/*
|
||||
* Force buffer overflow
|
||||
*/
|
||||
Serial.println(F("Force buffer overflow by sending 280 marks and spaces"));
|
||||
for (unsigned int i = 0; i < 140; ++i) {
|
||||
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
|
||||
|
@ -316,6 +430,7 @@ void loop() {
|
|||
*/
|
||||
sAddress += 0x0101;
|
||||
sCommand += 0x11;
|
||||
s16BitCommand += 0x1111;
|
||||
sRepeats++;
|
||||
// clip repeats at 4
|
||||
if (sRepeats > 4) {
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* 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
|
||||
* Copyright (C) 2021-2023 Armin Joachimsmeyer
|
||||
* armin.joachimsmeyer@gmail.com
|
||||
*
|
||||
* This file is part of IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
|
||||
|
@ -16,8 +16,8 @@
|
|||
*
|
||||
* 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.
|
||||
* 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>.
|
||||
|
@ -29,68 +29,99 @@
|
|||
*
|
||||
* Platform IR input IR output Tone Core/Pin schema
|
||||
* --------------------------------------------------------------
|
||||
* DEFAULT/AVR 2 3 4
|
||||
* ATtinyX5 0|PB0 4|PB4 3|PB3
|
||||
* 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 pro
|
||||
* 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
|
||||
* BluePill PA6 PA7 PA3
|
||||
* ESP32 15 4 27
|
||||
* ESP32-C3 6 7 10
|
||||
* 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
|
||||
#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
|
||||
#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
|
||||
#define TONE_PIN 5 // PA7 - on Digispark board labeled as pin 5
|
||||
#define _IR_TIMING_TEST_PIN 10 // PA4
|
||||
# else
|
||||
#define IR_RECEIVE_PIN 3
|
||||
#define IR_SEND_PIN 2
|
||||
#define TONE_PIN 7
|
||||
// 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_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_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_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_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_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
|
||||
# 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
|
||||
#define TONE_PIN 42 // Dummy for examples using it
|
||||
|
||||
# elif defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) \
|
||||
|| defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) \
|
||||
|
@ -123,17 +154,33 @@
|
|||
# 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 13 // D7
|
||||
#define APPLICATION_PIN 0 // D3
|
||||
#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(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>
|
||||
|
||||
|
@ -166,10 +213,13 @@ void noTone(uint8_t aPinNumber){
|
|||
#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
|
||||
|
@ -234,7 +284,7 @@ void noTone(uint8_t aPinNumber){
|
|||
#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)
|
||||
#if !defined(ARDUINO_SAMD_ADAFRUIT) && !defined(ARDUINO_SEEED_XIAO_M0)
|
||||
// On the Zero and others we switch explicitly to SerialUSB
|
||||
#define Serial SerialUSB
|
||||
#endif
|
||||
|
@ -274,13 +324,14 @@ void noTone(uint8_t aPinNumber){
|
|||
#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
|
||||
#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
|
||||
*/
|
||||
|
|
|
@ -42,6 +42,10 @@
|
|||
//#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
|
||||
|
||||
#if !defined(ARDUINO_ESP32C3_DEV) // This is due to a bug in RISC-V compiler, which requires unused function sections :-(.
|
||||
#define DISABLE_CODE_FOR_RECEIVER // Disables static receiver code like receive timer ISR handler and static IRReceiver and irparams data. Saves 450 bytes program memory and 269 bytes RAM if receiving functions are not required.
|
||||
#endif
|
||||
|
||||
#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.
|
||||
|
||||
|
@ -68,18 +72,14 @@ delay(4000); // To be able to connect Serial monitor after reset or power up and
|
|||
#endif
|
||||
// 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!
|
||||
*/
|
||||
#if defined(IR_SEND_PIN)
|
||||
IrSender.begin(); // Start with IR_SEND_PIN as send pin and enable feedback LED at default feedback LED pin
|
||||
#else
|
||||
IrSender.begin(3, ENABLE_LED_FEEDBACK); // Specify send pin and enable feedback LED at default feedback LED pin
|
||||
#endif
|
||||
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.print(F("Ready to send IR signals at pin "));
|
||||
Serial.println(IR_SEND_PIN);
|
||||
Serial.println();
|
||||
MyLG_Aircondition.setType(LG_IS_WALL_TYPE);
|
||||
MyLG_Aircondition.printMenu(&Serial);
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* 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
|
||||
* Copyright (C) 2021-2023 Armin Joachimsmeyer
|
||||
* armin.joachimsmeyer@gmail.com
|
||||
*
|
||||
* This file is part of IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
|
||||
|
@ -16,8 +16,8 @@
|
|||
*
|
||||
* 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.
|
||||
* 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>.
|
||||
|
@ -29,68 +29,99 @@
|
|||
*
|
||||
* Platform IR input IR output Tone Core/Pin schema
|
||||
* --------------------------------------------------------------
|
||||
* DEFAULT/AVR 2 3 4
|
||||
* ATtinyX5 0|PB0 4|PB4 3|PB3
|
||||
* 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 pro
|
||||
* 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
|
||||
* BluePill PA6 PA7 PA3
|
||||
* ESP32 15 4 27
|
||||
* ESP32-C3 6 7 10
|
||||
* 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
|
||||
#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
|
||||
#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
|
||||
#define TONE_PIN 5 // PA7 - on Digispark board labeled as pin 5
|
||||
#define _IR_TIMING_TEST_PIN 10 // PA4
|
||||
# else
|
||||
#define IR_RECEIVE_PIN 3
|
||||
#define IR_SEND_PIN 2
|
||||
#define TONE_PIN 7
|
||||
// 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_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_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_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_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_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
|
||||
# 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
|
||||
#define TONE_PIN 42 // Dummy for examples using it
|
||||
|
||||
# elif defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) \
|
||||
|| defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) \
|
||||
|
@ -123,17 +154,33 @@
|
|||
# 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 13 // D7
|
||||
#define APPLICATION_PIN 0 // D3
|
||||
#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(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>
|
||||
|
||||
|
@ -166,10 +213,13 @@ void noTone(uint8_t aPinNumber){
|
|||
#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
|
||||
|
@ -234,7 +284,7 @@ void noTone(uint8_t aPinNumber){
|
|||
#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)
|
||||
#if !defined(ARDUINO_SAMD_ADAFRUIT) && !defined(ARDUINO_SEEED_XIAO_M0)
|
||||
// On the Zero and others we switch explicitly to SerialUSB
|
||||
#define Serial SerialUSB
|
||||
#endif
|
||||
|
@ -274,13 +324,14 @@ void noTone(uint8_t aPinNumber){
|
|||
#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
|
||||
#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
|
||||
*/
|
||||
|
|
|
@ -32,6 +32,10 @@
|
|||
*/
|
||||
#include <Arduino.h>
|
||||
|
||||
#if !defined(ARDUINO_ESP32C3_DEV) // This is due to a bug in RISC-V compiler, which requires unused function sections :-(.
|
||||
#define DISABLE_CODE_FOR_RECEIVER // Disables static receiver code like receive timer ISR handler and static IRReceiver and irparams data. Saves 450 bytes program memory and 269 bytes RAM if receiving functions are not required.
|
||||
#endif
|
||||
|
||||
#include "PinDefinitionsAndMore.h" // Define macros for input and output pin etc.
|
||||
#include <IRremote.hpp>
|
||||
|
||||
|
@ -40,7 +44,10 @@
|
|||
// 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[] PROGMEM
|
||||
const char yamahaVolDown[]
|
||||
#if defined(__AVR__)
|
||||
PROGMEM
|
||||
#endif
|
||||
= "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) */
|
||||
|
@ -57,15 +64,9 @@ void setup() {
|
|||
|
||||
// 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)));
|
||||
|
||||
#if defined(IR_SEND_PIN)
|
||||
IrSender.begin(); // Start with IR_SEND_PIN as send pin and enable feedback LED at default feedback LED pin
|
||||
#else
|
||||
IrSender.begin(3, ENABLE_LED_FEEDBACK); // Specify send pin and enable feedback LED at default feedback LED pin
|
||||
#endif
|
||||
|
||||
Serial.print(F("Ready to send IR signals at pin "));
|
||||
Serial.println(IR_SEND_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
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* 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
|
||||
* Copyright (C) 2021-2023 Armin Joachimsmeyer
|
||||
* armin.joachimsmeyer@gmail.com
|
||||
*
|
||||
* This file is part of IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
|
||||
|
@ -16,8 +16,8 @@
|
|||
*
|
||||
* 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.
|
||||
* 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>.
|
||||
|
@ -29,68 +29,99 @@
|
|||
*
|
||||
* Platform IR input IR output Tone Core/Pin schema
|
||||
* --------------------------------------------------------------
|
||||
* DEFAULT/AVR 2 3 4
|
||||
* ATtinyX5 0|PB0 4|PB4 3|PB3
|
||||
* 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 pro
|
||||
* 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
|
||||
* BluePill PA6 PA7 PA3
|
||||
* ESP32 15 4 27
|
||||
* ESP32-C3 6 7 10
|
||||
* 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
|
||||
#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
|
||||
#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
|
||||
#define TONE_PIN 5 // PA7 - on Digispark board labeled as pin 5
|
||||
#define _IR_TIMING_TEST_PIN 10 // PA4
|
||||
# else
|
||||
#define IR_RECEIVE_PIN 3
|
||||
#define IR_SEND_PIN 2
|
||||
#define TONE_PIN 7
|
||||
// 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_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_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_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_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_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
|
||||
# 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
|
||||
#define TONE_PIN 42 // Dummy for examples using it
|
||||
|
||||
# elif defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) \
|
||||
|| defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) \
|
||||
|
@ -123,17 +154,33 @@
|
|||
# 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 13 // D7
|
||||
#define APPLICATION_PIN 0 // D3
|
||||
#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(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>
|
||||
|
||||
|
@ -166,10 +213,13 @@ void noTone(uint8_t aPinNumber){
|
|||
#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
|
||||
|
@ -234,7 +284,7 @@ void noTone(uint8_t aPinNumber){
|
|||
#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)
|
||||
#if !defined(ARDUINO_SAMD_ADAFRUIT) && !defined(ARDUINO_SEEED_XIAO_M0)
|
||||
// On the Zero and others we switch explicitly to SerialUSB
|
||||
#define Serial SerialUSB
|
||||
#endif
|
||||
|
@ -274,13 +324,14 @@ void noTone(uint8_t aPinNumber){
|
|||
#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
|
||||
#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
|
||||
*/
|
||||
|
|
|
@ -37,6 +37,10 @@
|
|||
*/
|
||||
#include <Arduino.h>
|
||||
|
||||
#if !defined(ARDUINO_ESP32C3_DEV) // This is due to a bug in RISC-V compiler, which requires unused function sections :-(.
|
||||
#define DISABLE_CODE_FOR_RECEIVER // Disables static receiver code like receive timer ISR handler and static IRReceiver and irparams data. Saves 450 bytes program memory and 269 bytes RAM if receiving functions are not required.
|
||||
#endif
|
||||
|
||||
//#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
|
||||
|
@ -54,14 +58,9 @@ void setup() {
|
|||
#endif
|
||||
// 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)));
|
||||
|
||||
#if defined(IR_SEND_PIN)
|
||||
IrSender.begin(); // Start with IR_SEND_PIN as send pin and enable feedback LED at default feedback LED pin
|
||||
#else
|
||||
IrSender.begin(3, ENABLE_LED_FEEDBACK); // Specify send pin and enable feedback LED at default feedback LED pin
|
||||
#endif
|
||||
|
||||
Serial.println(F("Ready to send IR signals at pin " STR(IR_SEND_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
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -75,7 +74,10 @@ void setup() {
|
|||
* 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[] PROGMEM
|
||||
const uint8_t rawDataP[]
|
||||
#if defined(__AVR__)
|
||||
PROGMEM
|
||||
#endif
|
||||
= { 180, 90 /*Start bit*/, 11, 11, 11, 11, 11, 34, 11, 34/*0011 0xC of 16 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,
|
||||
|
@ -114,7 +116,7 @@ void loop() {
|
|||
|
||||
Serial.println(F("Send NEC 16 bit address 0x0102, 8 bit data 0x34 with generated timing"));
|
||||
Serial.flush();
|
||||
IrSender.sendNEC(0x0102, 0x34, true, 0);
|
||||
IrSender.sendNEC(0x0102, 0x34, 0);
|
||||
|
||||
delay(3000);
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* 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
|
||||
* Copyright (C) 2021-2023 Armin Joachimsmeyer
|
||||
* armin.joachimsmeyer@gmail.com
|
||||
*
|
||||
* This file is part of IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
|
||||
|
@ -16,8 +16,8 @@
|
|||
*
|
||||
* 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.
|
||||
* 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>.
|
||||
|
@ -29,68 +29,99 @@
|
|||
*
|
||||
* Platform IR input IR output Tone Core/Pin schema
|
||||
* --------------------------------------------------------------
|
||||
* DEFAULT/AVR 2 3 4
|
||||
* ATtinyX5 0|PB0 4|PB4 3|PB3
|
||||
* 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 pro
|
||||
* 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
|
||||
* BluePill PA6 PA7 PA3
|
||||
* ESP32 15 4 27
|
||||
* ESP32-C3 6 7 10
|
||||
* 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
|
||||
#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
|
||||
#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
|
||||
#define TONE_PIN 5 // PA7 - on Digispark board labeled as pin 5
|
||||
#define _IR_TIMING_TEST_PIN 10 // PA4
|
||||
# else
|
||||
#define IR_RECEIVE_PIN 3
|
||||
#define IR_SEND_PIN 2
|
||||
#define TONE_PIN 7
|
||||
// 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_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_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_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_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_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
|
||||
# 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
|
||||
#define TONE_PIN 42 // Dummy for examples using it
|
||||
|
||||
# elif defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) \
|
||||
|| defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) \
|
||||
|
@ -123,17 +154,33 @@
|
|||
# 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 13 // D7
|
||||
#define APPLICATION_PIN 0 // D3
|
||||
#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(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>
|
||||
|
||||
|
@ -166,10 +213,13 @@ void noTone(uint8_t aPinNumber){
|
|||
#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
|
||||
|
@ -234,7 +284,7 @@ void noTone(uint8_t aPinNumber){
|
|||
#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)
|
||||
#if !defined(ARDUINO_SAMD_ADAFRUIT) && !defined(ARDUINO_SEEED_XIAO_M0)
|
||||
// On the Zero and others we switch explicitly to SerialUSB
|
||||
#define Serial SerialUSB
|
||||
#endif
|
||||
|
@ -274,13 +324,14 @@ void noTone(uint8_t aPinNumber){
|
|||
#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
|
||||
#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
|
||||
*/
|
||||
|
|
|
@ -1,14 +1,15 @@
|
|||
/*
|
||||
* SimpleReceiver.cpp
|
||||
*
|
||||
* Demonstrates receiving NEC IR codes with IRrecv
|
||||
* 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-2022 Armin Joachimsmeyer
|
||||
* 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
|
||||
|
@ -32,14 +33,15 @@
|
|||
|
||||
/*
|
||||
* Specify which protocol(s) should be used for decoding.
|
||||
* If no protocol is defined, all protocols are active.
|
||||
* 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 // the same as DECODE_KASEIKYO
|
||||
//#define DECODE_PANASONIC // alias for DECODE_KASEIKYO
|
||||
//#define DECODE_LG
|
||||
#define DECODE_NEC // Includes Apple and Onkyo
|
||||
#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
|
||||
|
@ -49,16 +51,24 @@
|
|||
//#define DECODE_LEGO_PF
|
||||
//#define DECODE_MAGIQUEST
|
||||
//#define DECODE_WHYNTER
|
||||
//#define DECODE_FAST
|
||||
|
||||
//#define DECODE_DISTANCE // universal decoder for pulse distance protocols
|
||||
//#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 180 // Default is 112 if DECODE_MAGIQUEST is enabled, otherwise 100.
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
#include "PinDefinitionsAndMore.h" // Define macros for input and output pin etc.
|
||||
#include <IRremote.hpp>
|
||||
/*
|
||||
* 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
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
|
@ -84,22 +94,21 @@ void loop() {
|
|||
*/
|
||||
if (IrReceiver.decode()) {
|
||||
|
||||
// Print a short summary of received data
|
||||
IrReceiver.printIRResultShort(&Serial);
|
||||
IrReceiver.printIRSendUsage(&Serial);
|
||||
/*
|
||||
* 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
|
||||
// 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();
|
||||
|
||||
/*
|
||||
* !!!Important!!! Enable receiving of the next value,
|
||||
* since receiving has stopped after the end of the current received data packet.
|
||||
*/
|
||||
IrReceiver.resume(); // Enable receiving of the next value
|
||||
|
||||
/*
|
||||
* Finally, check the received data and perform actions according to the received command
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,341 @@
|
|||
/*
|
||||
* 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 6 7 10
|
||||
* 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(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
|
||||
#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,154 @@
|
|||
/*
|
||||
* 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 180 // Default is 112 if DECODE_MAGIQUEST is enabled, otherwise 100.
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
#include "PinDefinitionsAndMore.h" // Define macros for input and output pin etc.
|
||||
#include <IRremote.hpp>
|
||||
|
||||
/*
|
||||
* 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(115200);
|
||||
// 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();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
#if defined(ESP32) || defined(ESP8266)
|
||||
IRAM_ATTR
|
||||
# endif
|
||||
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;
|
||||
|
||||
}
|
|
@ -4,7 +4,7 @@
|
|||
* 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
|
||||
* Copyright (C) 2021-2023 Armin Joachimsmeyer
|
||||
* armin.joachimsmeyer@gmail.com
|
||||
*
|
||||
* This file is part of IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
|
||||
|
@ -16,8 +16,8 @@
|
|||
*
|
||||
* 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.
|
||||
* 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>.
|
||||
|
@ -29,68 +29,99 @@
|
|||
*
|
||||
* Platform IR input IR output Tone Core/Pin schema
|
||||
* --------------------------------------------------------------
|
||||
* DEFAULT/AVR 2 3 4
|
||||
* ATtinyX5 0|PB0 4|PB4 3|PB3
|
||||
* 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 pro
|
||||
* 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
|
||||
* BluePill PA6 PA7 PA3
|
||||
* ESP32 15 4 27
|
||||
* ESP32-C3 6 7 10
|
||||
* 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
|
||||
#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
|
||||
#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
|
||||
#define TONE_PIN 5 // PA7 - on Digispark board labeled as pin 5
|
||||
#define _IR_TIMING_TEST_PIN 10 // PA4
|
||||
# else
|
||||
#define IR_RECEIVE_PIN 3
|
||||
#define IR_SEND_PIN 2
|
||||
#define TONE_PIN 7
|
||||
// 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_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_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_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_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_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
|
||||
# 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
|
||||
#define TONE_PIN 42 // Dummy for examples using it
|
||||
|
||||
# elif defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) \
|
||||
|| defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) \
|
||||
|
@ -123,17 +154,33 @@
|
|||
# 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 13 // D7
|
||||
#define APPLICATION_PIN 0 // D3
|
||||
#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(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>
|
||||
|
||||
|
@ -166,10 +213,13 @@ void noTone(uint8_t aPinNumber){
|
|||
#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
|
||||
|
@ -234,7 +284,7 @@ void noTone(uint8_t aPinNumber){
|
|||
#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)
|
||||
#if !defined(ARDUINO_SAMD_ADAFRUIT) && !defined(ARDUINO_SEEED_XIAO_M0)
|
||||
// On the Zero and others we switch explicitly to SerialUSB
|
||||
#define Serial SerialUSB
|
||||
#endif
|
||||
|
@ -274,13 +324,14 @@ void noTone(uint8_t aPinNumber){
|
|||
#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
|
||||
#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
|
||||
*/
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* Demonstrates sending IR codes in standard format with address and command
|
||||
* An extended example for sending can be found as SendDemo.
|
||||
*
|
||||
* Copyright (C) 2020-2021 Armin Joachimsmeyer
|
||||
* Copyright (C) 2020-2022 Armin Joachimsmeyer
|
||||
* armin.joachimsmeyer@gmail.com
|
||||
*
|
||||
* This file is part of Arduino-IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
|
||||
|
@ -13,11 +13,17 @@
|
|||
*/
|
||||
#include <Arduino.h>
|
||||
|
||||
#if !defined(ARDUINO_ESP32C3_DEV) // This is due to a bug in RISC-V compiler, which requires unused function sections :-(.
|
||||
#define DISABLE_CODE_FOR_RECEIVER // Disables static receiver code like receive timer ISR handler and static IRReceiver and irparams data. Saves 450 bytes program memory and 269 bytes RAM if receiving functions are not required.
|
||||
#endif
|
||||
//#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
|
||||
|
||||
#include "PinDefinitionsAndMore.h" // Define macros for input and output pin etc.
|
||||
#include <IRremote.hpp>
|
||||
/*
|
||||
* 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
|
||||
|
||||
void setup() {
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
|
@ -26,14 +32,14 @@ void setup() {
|
|||
|
||||
// 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 as send pin and if NO_LED_FEEDBACK_CODE is NOT defined, enable feedback LED at default feedback LED pin
|
||||
|
||||
Serial.print(F("Ready to send IR signals at pin "));
|
||||
Serial.println(IR_SEND_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
|
||||
disableLEDFeedback(); // Disable feedback LED at default feedback LED pin
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -42,7 +48,6 @@ void setup() {
|
|||
* and a variable 8 bit command.
|
||||
* There are exceptions like Sony and Denon, which have 5 bit address.
|
||||
*/
|
||||
uint16_t sAddress = 0x0102;
|
||||
uint8_t sCommand = 0x34;
|
||||
uint8_t sRepeats = 0;
|
||||
|
||||
|
@ -51,30 +56,33 @@ void loop() {
|
|||
* Print current send values
|
||||
*/
|
||||
Serial.println();
|
||||
Serial.print(F("Send now: address=0x"));
|
||||
Serial.print(sAddress, HEX);
|
||||
Serial.print(F(" command=0x"));
|
||||
Serial.print(F("Send now: address=0x00, command=0x"));
|
||||
Serial.print(sCommand, HEX);
|
||||
Serial.print(F(" repeats="));
|
||||
Serial.print(F(", repeats="));
|
||||
Serial.print(sRepeats);
|
||||
Serial.println();
|
||||
|
||||
Serial.println(F("Send NEC with 16 bit address"));
|
||||
Serial.println(F("Send standard NEC with 8 bit address"));
|
||||
Serial.flush();
|
||||
|
||||
// Results for the first loop to: Protocol=NEC Address=0x102 Command=0x34 Raw-Data=0xCB340102 (32 bits)
|
||||
IrSender.sendNEC(sAddress, sCommand, sRepeats);
|
||||
// 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 cannot avoid to send a raw value directly like e.g. 0xCB340102 you must use sendNECRaw()
|
||||
* If you want to send a raw HEX value directly like e.g. 0xCB340102 you must use sendNECRaw()
|
||||
*/
|
||||
// Serial.println(F("Send NECRaw 0xCB340102"));
|
||||
// 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
|
||||
* Also increment address just for demonstration, which normally makes no sense
|
||||
*/
|
||||
sAddress += 0x0101;
|
||||
sCommand += 0x11;
|
||||
sRepeats++;
|
||||
// clip repeats at 4
|
||||
|
|
|
@ -0,0 +1,341 @@
|
|||
/*
|
||||
* 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 6 7 10
|
||||
* 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(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
|
||||
#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,158 @@
|
|||
/*
|
||||
* 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>
|
||||
|
||||
#include "PinDefinitionsAndMore.h" // Set IR_RECEIVE_PIN for different CPU's
|
||||
|
||||
//#define DEBUG // to see if attachInterrupt is used
|
||||
//#define TRACE // to see the state of the ISR state machine
|
||||
|
||||
/*
|
||||
* 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(115200);
|
||||
#if defined(__AVR_ATmega32U4__) || defined(SERIAL_PORT_USBVIRTUAL) || defined(SERIAL_USB) /*stm32duino*/|| defined(USBCON) /*STM32_stm32*/|| defined(SERIALUSB_PID) || defined(ARDUINO_attiny3217)
|
||||
delay(4000); // To be able to connect Serial monitor after reset or power up and before first print out. Do not wait for an attached Serial Monitor!
|
||||
#endif
|
||||
// Just to know which program is running on my Arduino
|
||||
#if defined(ESP8266) || defined(ESP32)
|
||||
Serial.println();
|
||||
#endif
|
||||
Serial.println(F("START " __FILE__ " from " __DATE__ "\r\nUsing library version " VERSION_TINYIR));
|
||||
|
||||
// Enables the interrupt generation on change of IR input signal
|
||||
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 (TinyIRReceiverData.justWritten) {
|
||||
TinyIRReceiverData.justWritten = false;
|
||||
#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
|
||||
*/
|
||||
}
|
||||
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
# if defined(ESP8266) || defined(ESP32)
|
||||
IRAM_ATTR
|
||||
# endif
|
||||
|
||||
void handleReceivedTinyIRData() {
|
||||
# if defined(ARDUINO_ARCH_MBED) || defined(ESP32)
|
||||
/*
|
||||
* Printing is not allowed in ISR context for any kind of RTOS, so we use the slihjtly more complex,
|
||||
* but recommended way for handling a callback :-). Copy data for main loop.
|
||||
* For Mbed we get a kernel panic and "Error Message: Semaphore: 0x0, Not allowed in ISR context" for Serial.print()
|
||||
* for ESP32 we get a "Guru Meditation Error: Core 1 panic'ed" (we also have an RTOS running!)
|
||||
*/
|
||||
// Do something useful here...
|
||||
# else
|
||||
// As an example, print very short output, since we are in an interrupt context and do not want to miss the next interrupts of the repeats coming soon
|
||||
printTinyReceiverResultMinimal(&Serial);
|
||||
# endif
|
||||
}
|
||||
#endif
|
||||
|
|
@ -0,0 +1,341 @@
|
|||
/*
|
||||
* 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 6 7 10
|
||||
* 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(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
|
||||
#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,135 @@
|
|||
/*
|
||||
* 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>
|
||||
|
||||
#include "PinDefinitionsAndMore.h" // Set IR_SEND_PIN for different CPU's
|
||||
|
||||
#include "TinyIRSender.hpp"
|
||||
|
||||
void setup() {
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
|
||||
Serial.begin(115200);
|
||||
|
||||
// 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
|
||||
}
|
|
@ -4,7 +4,7 @@
|
|||
* 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
|
||||
* Copyright (C) 2021-2023 Armin Joachimsmeyer
|
||||
* armin.joachimsmeyer@gmail.com
|
||||
*
|
||||
* This file is part of IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
|
||||
|
@ -16,8 +16,8 @@
|
|||
*
|
||||
* 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.
|
||||
* 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>.
|
||||
|
@ -29,68 +29,99 @@
|
|||
*
|
||||
* Platform IR input IR output Tone Core/Pin schema
|
||||
* --------------------------------------------------------------
|
||||
* DEFAULT/AVR 2 3 4
|
||||
* ATtinyX5 0|PB0 4|PB4 3|PB3
|
||||
* 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 pro
|
||||
* 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
|
||||
* BluePill PA6 PA7 PA3
|
||||
* ESP32 15 4 27
|
||||
* ESP32-C3 6 7 10
|
||||
* 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
|
||||
#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
|
||||
#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
|
||||
#define TONE_PIN 5 // PA7 - on Digispark board labeled as pin 5
|
||||
#define _IR_TIMING_TEST_PIN 10 // PA4
|
||||
# else
|
||||
#define IR_RECEIVE_PIN 3
|
||||
#define IR_SEND_PIN 2
|
||||
#define TONE_PIN 7
|
||||
// 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_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_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_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_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_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
|
||||
# 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
|
||||
#define TONE_PIN 42 // Dummy for examples using it
|
||||
|
||||
# elif defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) \
|
||||
|| defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) \
|
||||
|
@ -123,17 +154,33 @@
|
|||
# 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 13 // D7
|
||||
#define APPLICATION_PIN 0 // D3
|
||||
#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(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>
|
||||
|
||||
|
@ -166,10 +213,13 @@ void noTone(uint8_t aPinNumber){
|
|||
#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
|
||||
|
@ -234,7 +284,7 @@ void noTone(uint8_t aPinNumber){
|
|||
#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)
|
||||
#if !defined(ARDUINO_SAMD_ADAFRUIT) && !defined(ARDUINO_SEEED_XIAO_M0)
|
||||
// On the Zero and others we switch explicitly to SerialUSB
|
||||
#define Serial SerialUSB
|
||||
#endif
|
||||
|
@ -274,13 +324,14 @@ void noTone(uint8_t aPinNumber){
|
|||
#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
|
||||
#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
|
||||
*/
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
************************************************************************************
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2020-2022 Armin Joachimsmeyer
|
||||
* 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
|
||||
|
@ -33,12 +33,17 @@
|
|||
|
||||
#include <Arduino.h>
|
||||
|
||||
#if RAMEND <= 0x4FF || (defined(RAMSIZE) && RAMSIZE < 0x4FF)
|
||||
//#define RAW_BUFFER_LENGTH 180 // 750 (600 if we have only 2k RAM) is the value for air condition remotes. Default is 112 if DECODE_MAGIQUEST is enabled, otherwise 100.
|
||||
#elif RAMEND <= 0x8FF || (defined(RAMSIZE) && RAMSIZE < 0x8FF)
|
||||
#define RAW_BUFFER_LENGTH 140 // 750 (600 if we have only 2k RAM) is the value for air condition remotes. Default is 112 if DECODE_MAGIQUEST is enabled, otherwise 100.
|
||||
#else
|
||||
#define RAW_BUFFER_LENGTH 200 // 750 (600 if we have only 2k RAM) is the value for air condition remotes. Default is 112 if DECODE_MAGIQUEST is enabled, otherwise 100.
|
||||
#include "PinDefinitionsAndMore.h" // Define macros for input and output pin etc.
|
||||
|
||||
#if !defined(RAW_BUFFER_LENGTH)
|
||||
// For air condition remotes it requires 600 (maximum for 2k RAM) to 750. Default is 112 if DECODE_MAGIQUEST is enabled, otherwise 100.
|
||||
# if (defined(RAMEND) && RAMEND <= 0x4FF) || (defined(RAMSIZE) && RAMSIZE < 0x4FF)
|
||||
#define RAW_BUFFER_LENGTH 180
|
||||
# elif (defined(RAMEND) && RAMEND <= 0x8FF) || (defined(RAMSIZE) && RAMSIZE < 0x8FF)
|
||||
#define RAW_BUFFER_LENGTH 200 // 600 is too much here, because then variables are overwritten. 500 is OK without Pronto and 200 is OK with Pronto
|
||||
# else
|
||||
#define RAW_BUFFER_LENGTH 750
|
||||
# endif
|
||||
#endif
|
||||
|
||||
//#define EXCLUDE_UNIVERSAL_PROTOCOLS // Saves up to 1000 bytes program memory.
|
||||
|
@ -46,7 +51,12 @@
|
|||
//#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 344 bytes program memory
|
||||
#define MARK_EXCESS_MICROS 10 // Adapt it to your IR receiver module. See also IRremote.h.
|
||||
// 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.
|
||||
|
@ -54,6 +64,7 @@
|
|||
#if FLASHEND >= 0x1FFF // For 8k flash or more, like ATtiny85
|
||||
#define DECODE_DENON // Includes Sharp
|
||||
#define DECODE_KASEIKYO
|
||||
#define DECODE_PANASONIC // alias for DECODE_KASEIKYO
|
||||
#define DECODE_NEC // Includes Apple and Onkyo
|
||||
#endif
|
||||
|
||||
|
@ -61,24 +72,31 @@
|
|||
#define DECODE_JVC
|
||||
#define DECODE_RC5
|
||||
#define DECODE_RC6
|
||||
#define DECODE_SONY
|
||||
#define DECODE_PANASONIC // the same as DECODE_KASEIKYO
|
||||
|
||||
#define DECODE_DISTANCE // universal decoder for pulse distance protocols
|
||||
#define DECODE_DISTANCE_WIDTH // Universal decoder for pulse distance width protocols
|
||||
#define DECODE_HASH // special decoder for all protocols
|
||||
#endif
|
||||
|
||||
#if FLASHEND >= 0x7FFF // For 32k flash or more, like ATmega328
|
||||
#define DECODE_SONY
|
||||
#define DECODE_SAMSUNG
|
||||
#define DECODE_LG
|
||||
|
||||
#define DECODE_BOSEWAVE
|
||||
#define DECODE_LEGO_PF
|
||||
#define DECODE_MAGIQUEST
|
||||
#define DECODE_WHYNTER
|
||||
#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!!!
|
||||
#if defined(DECODE_BEO)
|
||||
#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).
|
||||
#endif
|
||||
|
||||
#include "PinDefinitionsAndMore.h" // Define macros for input and output pin etc.
|
||||
#define DECODE_BOSEWAVE
|
||||
//#define DECODE_LEGO_PF
|
||||
#define DECODE_MAGIQUEST
|
||||
//#define DECODE_WHYNTER
|
||||
#define DECODE_FAST
|
||||
#endif
|
||||
|
||||
//#undef IR_SEND_PIN // enable this, if you need to set send pin programmatically using uint8_t tSendPin below
|
||||
#include <IRremote.hpp>
|
||||
|
||||
#if defined(APPLICATION_PIN)
|
||||
|
@ -94,6 +112,12 @@
|
|||
#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(DEBUG_BUTTON_PIN, INPUT_PULLUP);
|
||||
|
||||
|
@ -106,25 +130,54 @@ void setup() {
|
|||
|
||||
// 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);
|
||||
|
||||
IrSender.begin(IR_SEND_PIN, ENABLE_LED_FEEDBACK); // Specify send pin and enable feedback LED at default feedback LED pin
|
||||
IrReceiver.registerReceiveCompleteCallback(ReceiveCompleteCallbackHandler);
|
||||
|
||||
Serial.print(F("Ready to receive IR signals of protocols: "));
|
||||
printActiveIRProtocols(&Serial);
|
||||
#if defined(IR_RECEIVE_PIN_STRING)
|
||||
Serial.println(F("at pin " IR_RECEIVE_PIN_STRING));
|
||||
#else
|
||||
Serial.println(F("at pin " STR(IR_RECEIVE_PIN)));
|
||||
#endif
|
||||
|
||||
Serial.println(F("Ready to send IR signals at pin " STR(IR_SEND_PIN)));
|
||||
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 -which is defined in PinDefinitionsAndMore.h- as send pin and enable feedback LED at default feedback LED pin
|
||||
# if defined(IR_SEND_PIN_STRING)
|
||||
Serial.println(F("Send IR signals at pin " IR_SEND_PIN_STRING));
|
||||
# else
|
||||
Serial.println(F("Send IR signals at pin " STR(IR_SEND_PIN)));
|
||||
# endif
|
||||
#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 FLASHEND >= 0x3FFF // For 16k flash or more, like ATtiny1604
|
||||
// For esp32 we use PWM generation by ledcWrite() for each pin.
|
||||
Serial.print(F("If you connect debug pin "));
|
||||
# if defined(APPLICATION_PIN_STRING)
|
||||
Serial.print(APPLICATION_PIN_STRING);
|
||||
# else
|
||||
Serial.print(DEBUG_BUTTON_PIN);
|
||||
# endif
|
||||
Serial.println(F(" to ground, raw data is always printed"));
|
||||
|
||||
// For esp32 we use PWM generation by ledcWrite() for each pin.
|
||||
# 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(F("Send signal mark duration for 38kHz is "));
|
||||
Serial.print(IrSender.periodOnTimeMicros);
|
||||
Serial.print(F(" us, pulse correction is "));
|
||||
Serial.print(F(" us, pulse narrowing correction is "));
|
||||
Serial.print(IrSender.getPulseCorrectionNanos());
|
||||
Serial.print(F(" ns, total period is "));
|
||||
Serial.print(IrSender.periodTimeMicros);
|
||||
|
@ -141,9 +194,115 @@ void setup() {
|
|||
|
||||
}
|
||||
|
||||
void checkReceivedRawData(IRRawDataType aRawData) {
|
||||
// wait until signal has received
|
||||
while (!sDataJustReceived) {
|
||||
};
|
||||
sDataJustReceived = false;
|
||||
|
||||
if (IrReceiver.decode()) {
|
||||
// Print a short summary of received data
|
||||
#if FLASHEND >= 0x3FFF // For 16k flash or more, like ATtiny1604
|
||||
IrReceiver.printIRResultShort(&Serial);
|
||||
IrReceiver.printIRSendUsage(&Serial);
|
||||
#else
|
||||
IrReceiver.printIRResultMinimal(&Serial);
|
||||
#endif
|
||||
#if FLASHEND >= 0x3FFF // For 16k flash or more, like ATtiny1604
|
||||
if (IrReceiver.decodedIRData.protocol == UNKNOWN || digitalRead(DEBUG_BUTTON_PIN) == LOW) {
|
||||
// We have an unknown protocol, print more info
|
||||
IrReceiver.printIRResultRawFormatted(&Serial, true);
|
||||
}
|
||||
#endif
|
||||
if (IrReceiver.decodedIRData.protocol == PULSE_DISTANCE || IrReceiver.decodedIRData.protocol == PULSE_WIDTH) {
|
||||
if (IrReceiver.decodedIRData.decodedRawData != aRawData) {
|
||||
Serial.print(F("ERROR: Received data=0x"));
|
||||
#if (__INT_WIDTH__ < 32)
|
||||
Serial.print(IrReceiver.decodedIRData.decodedRawData, HEX);
|
||||
#else
|
||||
PrintULL::print(&Serial, IrReceiver.decodedIRData.decodedRawData, HEX);
|
||||
#endif
|
||||
Serial.print(F(" != sent data=0x"));
|
||||
#if (__INT_WIDTH__ < 32)
|
||||
Serial.print(aRawData, HEX);
|
||||
#else
|
||||
PrintULL::print(&Serial, aRawData, HEX);
|
||||
#endif
|
||||
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
|
||||
#if FLASHEND >= 0x3FFF // For 16k flash or more, like ATtiny1604
|
||||
IrReceiver.printIRResultShort(&Serial);
|
||||
IrReceiver.printIRSendUsage(&Serial);
|
||||
#else
|
||||
IrReceiver.printIRResultMinimal(&Serial);
|
||||
#endif
|
||||
#if FLASHEND >= 0x3FFF // For 16k flash or more, like ATtiny1604
|
||||
if (IrReceiver.decodedIRData.protocol == UNKNOWN || digitalRead(DEBUG_BUTTON_PIN) == LOW) {
|
||||
// We have an unknown protocol, print more info
|
||||
IrReceiver.printIRResultRawFormatted(&Serial, true);
|
||||
}
|
||||
#endif
|
||||
|
||||
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"));
|
||||
# if (__INT_WIDTH__ < 32)
|
||||
Serial.print(IrReceiver.decodedIRData.decodedRawDataArray[i], HEX);
|
||||
# else
|
||||
PrintULL::print(&Serial, IrReceiver.decodedIRData.decodedRawDataArray[i], HEX);
|
||||
# endif
|
||||
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
|
||||
delay((RECORD_GAP_MICROS / 1000) + 1);
|
||||
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
|
||||
|
@ -155,42 +314,44 @@ void checkReceive(uint16_t aSentAddress, uint16_t aSentCommand) {
|
|||
#endif
|
||||
|
||||
if (IrReceiver.decodedIRData.flags & IRDATA_FLAGS_WAS_OVERFLOW) {
|
||||
IrReceiver.decodedIRData.flags = false; // yes we have recognized the flag :-)
|
||||
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
|
||||
} else {
|
||||
}
|
||||
|
||||
#if FLASHEND >= 0x3FFF // For 16k flash or more, like ATtiny1604
|
||||
if (IrReceiver.decodedIRData.protocol == UNKNOWN || digitalRead(DEBUG_BUTTON_PIN) == LOW) {
|
||||
// We have an unknown protocol, print more info
|
||||
IrReceiver.printIRResultRawFormatted(&Serial, true);
|
||||
}
|
||||
if (IrReceiver.decodedIRData.protocol == UNKNOWN || digitalRead(DEBUG_BUTTON_PIN) == LOW) {
|
||||
// We have an unknown protocol, print more info
|
||||
IrReceiver.printIRResultRawFormatted(&Serial, true);
|
||||
}
|
||||
#endif
|
||||
if (IrReceiver.decodedIRData.protocol != UNKNOWN && IrReceiver.decodedIRData.protocol != PULSE_DISTANCE) {
|
||||
/*
|
||||
* 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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
IrReceiver.resume();
|
||||
} else {
|
||||
Serial.println(F("No data received"));
|
||||
IrReceiver.resume();
|
||||
}
|
||||
Serial.println();
|
||||
}
|
||||
|
@ -203,7 +364,8 @@ void checkReceive(uint16_t aSentAddress, uint16_t aSentCommand) {
|
|||
*/
|
||||
uint16_t sAddress = 0xFFF1;
|
||||
uint8_t sCommand = 0x76;
|
||||
#define sRepeats 0 // no unit test for repeats
|
||||
uint16_t s16BitCommand = 0x9876;
|
||||
uint8_t sRepeats = 0;
|
||||
|
||||
void loop() {
|
||||
/*
|
||||
|
@ -219,25 +381,42 @@ void loop() {
|
|||
|
||||
Serial.println(F("Send NEC with 8 bit address"));
|
||||
Serial.flush();
|
||||
IrSender.sendNEC(sAddress & 0xFF, sCommand, sRepeats);
|
||||
IrSender.sendNEC(sAddress & 0xFF, sCommand, 0);
|
||||
checkReceive(sAddress & 0xFF, sCommand);
|
||||
//
|
||||
for (int8_t i = 0; i < sRepeats; i++) {
|
||||
Serial.println(F("Repeat NEC frame for NEC2"));
|
||||
Serial.flush();
|
||||
// if debug is enabled, printing time (50 ms) is too high anyway
|
||||
delayMicroseconds(NEC_REPEAT_DISTANCE - 200); // 200 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, sRepeats);
|
||||
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 FLASHEND >= 0x3FFF // For 16k flash or more, like ATtiny1604. Code does not fit in program memory of ATtiny85 etc.
|
||||
|
||||
if (sAddress == 0xFFF1) {
|
||||
# if FLASHEND >= 0x7FFF // For 32k flash or more, like UNO. Code does not fit in program memory of ATtiny1604 etc.
|
||||
# if FLASHEND >= 0x7FFF && ((defined(RAMEND) && RAMEND <= 0x6FF) || (defined(RAMSIZE) && RAMSIZE < 0x6FF)) // For 32k flash or more, like Uno. Code does not fit in program memory of ATtiny1604 etc.
|
||||
/*
|
||||
* 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.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) */
|
||||
|
@ -247,8 +426,8 @@ void loop() {
|
|||
checkReceive(0x80, 0x45);
|
||||
delay(DELAY_AFTER_SEND);
|
||||
|
||||
|
||||
Serial.println(F("Send NEC 16 bit address=0xFB04 and command 0x08 with exact timing (16 bit array format)"));
|
||||
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,
|
||||
|
@ -259,130 +438,273 @@ void loop() {
|
|||
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);
|
||||
# endif
|
||||
|
||||
/*
|
||||
* With sendNECRaw() you can send 32 bit combined codes
|
||||
* With sendNECRaw() you can send 32 bit codes directly, i.e. without parity etc.
|
||||
*/
|
||||
Serial.println(F("Send NEC / ONKYO with 16 bit address 0x0102 and 16 bit command 0x0304 with NECRaw(0x03040102)"));
|
||||
Serial.println(F("Send ONKYO with 16 bit address 0x0102 and 16 bit command 0x0304 with NECRaw(0x03040102)"));
|
||||
Serial.flush();
|
||||
IrSender.sendNECRaw(0x03040102, sRepeats);
|
||||
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 NEC with 16 bit address 0x0102 and command 0x34 with old 32 bit format MSB first"));
|
||||
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);
|
||||
# endif
|
||||
|
||||
# if defined(DECODE_PANASONIC) || defined(DECODE_KASEIKYO)
|
||||
Serial.println(F("Send Panasonic 0xB, 0x10 as 48 bit generic PulseDistance using ProtocolConstants"));
|
||||
Serial.flush();
|
||||
# if __INT_WIDTH__ < 32
|
||||
IRRawDataType tRawData[] = { 0xB02002, 0xA010, 0x0 }; // LSB of tRawData[0] is sent first
|
||||
IrSender.sendPulseDistanceWidthFromArray(&KaseikyoProtocolConstants, &tRawData[0], 48, NO_REPEATS); // Panasonic is a Kaseikyo variant
|
||||
checkReceive(0x0B, 0x10);
|
||||
# else
|
||||
IrSender.sendPulseDistanceWidth(&KaseikyoProtocolConstants, 0xA010B02002, 48, NO_REPEATS); // Panasonic is a Kaseikyo variant
|
||||
checkReceivedRawData(0xA010B02002);
|
||||
# endif
|
||||
delay(DELAY_AFTER_SEND);
|
||||
|
||||
/*
|
||||
* Send 2 Panasonic 48 bit codes as generic Pulse Distance data, once with LSB and once with MSB first
|
||||
*/
|
||||
Serial.println(F("Send Panasonic 0xB, 0x10 as generic 48 bit PulseDistance"));
|
||||
Serial.println(F(" LSB first"));
|
||||
Serial.println(F("-LSB first"));
|
||||
Serial.flush();
|
||||
uint32_t tRawData[] = { 0xB02002, 0xA010 }; // LSB of tRawData[0] is sent first
|
||||
IrSender.sendPulseDistanceWidthFromArray(38, 3450, 1700, 450, 1250, 450, 400, &tRawData[0], 48, PROTOCOL_IS_LSB_FIRST, 0, 0);
|
||||
# if __INT_WIDTH__ < 32
|
||||
IrSender.sendPulseDistanceWidthFromArray(38, 3450, 1700, 450, 1250, 450, 400, &tRawData[0], 48, PROTOCOL_IS_LSB_FIRST, 0,
|
||||
NO_REPEATS);
|
||||
checkReceive(0x0B, 0x10);
|
||||
# else
|
||||
IrSender.sendPulseDistanceWidth(38, 3450, 1700, 450, 1250, 450, 400, 0xA010B02002, 48, PROTOCOL_IS_LSB_FIRST,
|
||||
0, NO_REPEATS);
|
||||
checkReceivedRawData(0xA010B02002);
|
||||
# endif
|
||||
delay(DELAY_AFTER_SEND);
|
||||
|
||||
// The same with MSB first. Use bit reversed raw data of LSB first part
|
||||
Serial.println(F(" MSB first"));
|
||||
Serial.println(F("-MSB first"));
|
||||
# if __INT_WIDTH__ < 32
|
||||
tRawData[0] = 0x40040D00; // MSB of tRawData[0] is sent first
|
||||
tRawData[1] = 0x805;
|
||||
IrSender.sendPulseDistanceWidthFromArray(38, 3450, 1700, 450, 1250, 450, 400, &tRawData[0], 48, PROTOCOL_IS_MSB_FIRST, 0, 0);
|
||||
IrSender.sendPulseDistanceWidthFromArray(38, 3450, 1700, 450, 1250, 450, 400, &tRawData[0], 48, PROTOCOL_IS_MSB_FIRST, 0,
|
||||
NO_REPEATS);
|
||||
checkReceive(0x0B, 0x10);
|
||||
# else
|
||||
IrSender.sendPulseDistanceWidth(38, 3450, 1700, 450, 1250, 450, 400, 0x40040D000805, 48, PROTOCOL_IS_MSB_FIRST, 0, NO_REPEATS);
|
||||
checkReceivedRawData(0x40040D000805);
|
||||
# endif
|
||||
|
||||
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 generic 52 bit PulseDistance 0x43D8613C and 0x3BC3B MSB first"));
|
||||
Serial.flush();
|
||||
# if __INT_WIDTH__ < 32
|
||||
tRawData[0] = 0x43D8613C; // MSB of tRawData[0] is sent first
|
||||
tRawData[1] = 0x3BC3B;
|
||||
IrSender.sendPulseDistanceWidthFromArray(38, 8900, 4450, 550, 1700, 550, 600, &tRawData[0], 52, PROTOCOL_IS_MSB_FIRST, 0,
|
||||
NO_REPEATS);
|
||||
checkReceivedArray(tRawData, 2);
|
||||
# else
|
||||
IrSender.sendPulseDistanceWidth(38, 8900, 4450, 550, 1700, 550, 600, 0x43D8613CBC3B, 52, PROTOCOL_IS_MSB_FIRST, 0, NO_REPEATS);
|
||||
checkReceivedRawData(0x43D8613CBC3B);
|
||||
# endif
|
||||
delay(DELAY_AFTER_SEND);
|
||||
|
||||
Serial.println(F("Send generic 56 bit PulseDistance 0x43D8613C and 0x3BC3BC LSB first"));
|
||||
Serial.println(F("Send generic 52 bit PulseDistanceWidth 0x43D8613C and 0x3BC3B MSB first"));
|
||||
Serial.flush();
|
||||
tRawData[0] = 0x43D8613C;
|
||||
tRawData[1] = 0x3BC3BC;
|
||||
IrSender.sendPulseDistanceWidthFromArray(38, 8900, 4450, 550, 1700, 550, 600, &tRawData[0], 56, PROTOCOL_IS_LSB_FIRST, 0, 0);
|
||||
checkReceive(0x0, 0x0); // No real check, only printing of received result
|
||||
// Real PulseDistanceWidth (constant bit length) does not require a stop bit
|
||||
# if __INT_WIDTH__ < 32
|
||||
IrSender.sendPulseDistanceWidthFromArray(38, 300, 600, 600, 300, 300, 600, &tRawData[0], 52, PROTOCOL_IS_MSB_FIRST, 0, 0);
|
||||
checkReceivedArray(tRawData, 2);
|
||||
# else
|
||||
IrSender.sendPulseDistanceWidth(38, 300, 600, 600, 300, 300, 600, 0x123456789ABC, 52, PROTOCOL_IS_MSB_FIRST, 0, 0);
|
||||
checkReceivedRawData(0x123456789ABC);
|
||||
# endif
|
||||
delay(DELAY_AFTER_SEND);
|
||||
}
|
||||
Serial.println(F("Send generic 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 generic 72 bit PulseDistance 0x5A AFEDCBA9 87654321 LSB first"));
|
||||
Serial.flush();
|
||||
# if __INT_WIDTH__ < 32
|
||||
tRawData[0] = 0x87654321; // LSB of tRawData[0] is sent first
|
||||
tRawData[1] = 0xAFEDCBA9;
|
||||
tRawData[2] = 0x5A;
|
||||
IrSender.sendPulseDistanceWidthFromArray(38, 8900, 4450, 550, 1700, 550, 600, &tRawData[0], 72, PROTOCOL_IS_LSB_FIRST, 0,
|
||||
NO_REPEATS);
|
||||
checkReceivedArray(tRawData, 3);
|
||||
# else
|
||||
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);
|
||||
# endif
|
||||
delay(DELAY_AFTER_SEND);
|
||||
|
||||
Serial.println(F("Send generic 52 bit PulseDistanceWidth 0xDCBA9 87654321 LSB first"));
|
||||
Serial.flush();
|
||||
// Real PulseDistanceWidth (constant bit length) does not require a stop bit
|
||||
# if __INT_WIDTH__ < 32
|
||||
tRawData[1] = 0xDCBA9;
|
||||
IrSender.sendPulseDistanceWidthFromArray(38, 300, 600, 600, 300, 300, 600, &tRawData[0], 52, PROTOCOL_IS_LSB_FIRST, 0, 0);
|
||||
checkReceivedArray(tRawData, 2);
|
||||
# else
|
||||
IrSender.sendPulseDistanceWidth(38, 300, 600, 600, 300, 300, 600, 0xDCBA987654321, 52, PROTOCOL_IS_LSB_FIRST, 0, 0);
|
||||
checkReceivedRawData(0xDCBA987654321);
|
||||
# endif
|
||||
delay(DELAY_AFTER_SEND);
|
||||
|
||||
Serial.println(F("Send generic 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);
|
||||
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 generic 55 bit PulseDistanceWidth MSB first"));
|
||||
Serial.flush();
|
||||
# if __INT_WIDTH__ < 32
|
||||
tRawData[0] = 0x01AF37FC; // We have 1 header (start) bit and 7 start bits and 31 address bits for MagiQuest, so 0x6BCDFF00 is shifted 2 left
|
||||
tRawData[1] = 0x017619; // We send only 23 instead of 24 bite here! 19 is the checksum
|
||||
IrSender.sendPulseDistanceWidthFromArray(38, 287, 864, 576, 576, 287, 864, &tRawData[0], 55, PROTOCOL_IS_MSB_FIRST, 0, 0);
|
||||
# else
|
||||
// 0xD79BFE00 is 0x6BCDFF00 is shifted 1 left
|
||||
IrSender.sendPulseDistanceWidth(38, 287, 864, 576, 576, 287, 864, 0xD79BFE017619, 55, PROTOCOL_IS_MSB_FIRST, 0, 0);
|
||||
# endif
|
||||
checkReceive(0xFF00, 0x176);
|
||||
if (IrReceiver.decodedIRData.decodedRawData != 0x6BCDFF00) {
|
||||
Serial.print(F("ERROR: Received address=0x"));
|
||||
#if (__INT_WIDTH__ < 32)
|
||||
Serial.print(IrReceiver.decodedIRData.decodedRawData, HEX);
|
||||
#else
|
||||
PrintULL::print(&Serial, IrReceiver.decodedIRData.decodedRawData, HEX);
|
||||
#endif
|
||||
Serial.println(F(" != sent address=0x6BCDFF00"));
|
||||
Serial.println();
|
||||
}
|
||||
delay(DELAY_AFTER_SEND);
|
||||
# endif // defined(DECODE_MAGIQUEST)
|
||||
|
||||
}
|
||||
#endif // if FLASHEND >= 0x3FFF
|
||||
|
||||
Serial.println(F("Send Onkyo (NEC with 16 bit command)"));
|
||||
Serial.flush();
|
||||
IrSender.sendOnkyo(sAddress, sCommand << 8 | sCommand, sRepeats);
|
||||
checkReceive(sAddress, sCommand << 8 | sCommand);
|
||||
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, sRepeats);
|
||||
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, sRepeats);
|
||||
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, sRepeats, 0x4711);
|
||||
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, sRepeats);
|
||||
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, sRepeats);
|
||||
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, sRepeats);
|
||||
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 & 0x7F, sRepeats);
|
||||
IrSender.sendSony(sAddress & 0x1F, sCommand, 0);
|
||||
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, sRepeats, SIRCS_15_PROTOCOL);
|
||||
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 & 0x7F, sRepeats, SIRCS_20_PROTOCOL);
|
||||
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, sRepeats, true); // 5 address, 6 command bits
|
||||
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, sRepeats, true); // 5 address, 7 command bits
|
||||
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
|
||||
|
@ -391,7 +713,7 @@ void loop() {
|
|||
Serial.println(F("Send RC6"));
|
||||
// RC6 check does not work stable without the flush
|
||||
Serial.flush();
|
||||
IrSender.sendRC6(sAddress & 0xFF, sCommand, sRepeats, true);
|
||||
IrSender.sendRC6(sAddress & 0xFF, sCommand, 0, true);
|
||||
checkReceive(sAddress & 0xFF, sCommand);
|
||||
delay(DELAY_AFTER_SEND);
|
||||
#endif
|
||||
|
@ -405,28 +727,28 @@ void loop() {
|
|||
IRSendData.command = sCommand;
|
||||
IRSendData.flags = IRDATA_FLAGS_EMPTY;
|
||||
|
||||
#if defined(DECODE_SAMSUNG)
|
||||
IRSendData.protocol = SAMSUNG;
|
||||
Serial.print(F("Send "));
|
||||
Serial.println(getProtocolString(IRSendData.protocol));
|
||||
Serial.flush();
|
||||
IrSender.write(&IRSendData, sRepeats);
|
||||
checkReceive(IRSendData.address, IRSendData.command);
|
||||
delay(DELAY_AFTER_SEND);
|
||||
#endif
|
||||
|
||||
#if defined(DECODE_JVC)
|
||||
IRSendData.protocol = JVC; // switch protocol
|
||||
Serial.print(F("Send "));
|
||||
Serial.println(getProtocolString(IRSendData.protocol));
|
||||
Serial.flush();
|
||||
IrSender.write(&IRSendData, sRepeats);
|
||||
IrSender.write(&IRSendData, 0);
|
||||
checkReceive(IRSendData.address & 0xFF, IRSendData.command);
|
||||
delay(DELAY_AFTER_SEND);
|
||||
#endif
|
||||
|
||||
#if defined(DECODE_LG) || defined(DECODE_MAGIQUEST)
|
||||
IRSendData.command = sCommand << 8 | sCommand; // LG and MAGIQUEST support 16 bit command
|
||||
IRSendData.command = s16BitCommand; // LG support more than 8 bit command
|
||||
#endif
|
||||
|
||||
#if defined(DECODE_SAMSUNG)
|
||||
IRSendData.protocol = SAMSUNG;
|
||||
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)
|
||||
|
@ -434,18 +756,45 @@ void loop() {
|
|||
Serial.print(F("Send "));
|
||||
Serial.println(getProtocolString(IRSendData.protocol));
|
||||
Serial.flush();
|
||||
IrSender.write(&IRSendData, sRepeats);
|
||||
IrSender.write(&IRSendData, 0);
|
||||
checkReceive(IRSendData.address & 0xFF, IRSendData.command);
|
||||
delay(DELAY_AFTER_SEND);
|
||||
#endif
|
||||
|
||||
#if defined(DECODE_MAGIQUEST)
|
||||
IRSendData.protocol = MAGIQUEST;
|
||||
Serial.print(F("Send "));
|
||||
Serial.println(getProtocolString(IRSendData.protocol));
|
||||
Serial.println(F("Send MagiQuest"));
|
||||
Serial.flush();
|
||||
IrSender.write(&IRSendData);
|
||||
checkReceive(IRSendData.address, IRSendData.command);
|
||||
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
|
||||
|
||||
#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 it, which must fail!"));
|
||||
IrReceiver.printIRResultRawFormatted(&Serial, true);
|
||||
uint8_t tOriginalRawlen = IrReceiver.decodedIRData.rawlen;
|
||||
IrReceiver.decodedIRData.rawlen = 6;
|
||||
// decode first part of frame
|
||||
IrReceiver.decode();
|
||||
IrReceiver.printIRResultShort(&Serial);
|
||||
|
||||
// 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;
|
||||
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
|
||||
|
||||
|
@ -453,7 +802,17 @@ void loop() {
|
|||
IRSendData.protocol = BOSEWAVE;
|
||||
Serial.println(F("Send Bosewave with no address and 8 command bits"));
|
||||
Serial.flush();
|
||||
IrSender.write(&IRSendData, sRepeats);
|
||||
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
|
||||
|
@ -473,7 +832,7 @@ void loop() {
|
|||
for (unsigned int i = 0; i < 140; ++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.mark(210); // 8 pulses at 38 kHz
|
||||
IrSender.space(540); // to fill up to 750 us
|
||||
}
|
||||
checkReceive(sAddress, sCommand);
|
||||
|
@ -485,7 +844,12 @@ void loop() {
|
|||
*/
|
||||
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
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,796 @@
|
|||
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 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 Samsung
|
||||
Protocol=Samsung Address=0xFFF1 Command=0x9876 Raw-Data=0x9876FFF1 32 bits LSB first
|
||||
Send with: IrSender.sendSamsung(0xFFF1, 0x9876, <numberOfRepeats>);
|
||||
rawData[68]:
|
||||
-1040900
|
||||
+4600,-4400
|
||||
+ 650,-1600 + 700,- 450 + 650,- 500 + 650,- 450
|
||||
+ 700,-1600 + 650,-1600 + 650,-1600 + 650,-1600
|
||||
+ 650,-1650 + 650,-1600 + 650,-1600 + 650,-1600
|
||||
+ 650,-1600 + 700,-1600 + 650,-1600 + 650,-1600
|
||||
+ 650,- 500 + 650,-1600 + 650,-1600 + 700,- 450
|
||||
+ 650,-1600 + 650,-1600 + 700,-1600 + 650,- 450
|
||||
+ 700,- 450 + 650,- 500 + 650,- 450 + 650,-1600
|
||||
+ 700,-1600 + 650,- 500 + 650,- 450 + 650,-1600
|
||||
+ 700
|
||||
Sum: 69650
|
||||
|
||||
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 MagiQuest
|
||||
Protocol=MagiQuest Address=0xFFF1 Command=0x76 Raw-Data=0x6BCDFFF1 56 bits MSB first
|
||||
Send with: IrSender.sendMagiQuest(0x6BCDFFF1, 0x76, <numberOfRepeats>);
|
||||
rawData[112]:
|
||||
-1054600
|
||||
+ 400,- 750 + 400,- 800 + 400,- 750 + 400,- 750
|
||||
+ 400,- 800 + 400,- 750 + 400,- 800 + 400,- 750
|
||||
+ 700,- 500 + 650,- 500 + 400,- 800 + 650,- 500
|
||||
+ 400,- 750 + 700,- 500 + 700,- 450 + 700,- 500
|
||||
+ 650,- 500 + 400,- 800 + 400,- 750 + 700,- 500
|
||||
+ 650,- 500 + 400,- 800 + 650,- 500 + 700,- 450
|
||||
+ 700,- 500 + 650,- 500 + 700,- 500 + 650,- 500
|
||||
+ 700,- 450 + 700,- 500 + 700,- 450 + 700,- 500
|
||||
+ 650,- 500 + 700,- 450 + 700,- 500 + 400,- 750
|
||||
+ 400,- 800 + 400,- 750 + 700,- 500 + 400,- 800
|
||||
+ 400,- 750 + 700,- 450 + 700,- 500 + 650,- 500
|
||||
+ 400,- 800 + 650,- 500 + 700,- 450 + 400,- 800
|
||||
+ 400,- 750 + 400,- 800 + 650,- 500 + 700,- 500
|
||||
+ 350,- 800 + 700,- 450 + 700,- 500 + 650
|
||||
Sum: 65100
|
||||
|
||||
Send Bang&Olufsen
|
||||
Protocol=Bang&Olufsen Address=0xF1 Command=0x76 Raw-Data=0xF176 16 bits MSB first
|
||||
Send with: IrSender.sendBang&Olufsen(0xF1, 0x76, <numberOfRepeats>);
|
||||
rawData[44]:
|
||||
-1084600
|
||||
+ 300,-2850
|
||||
+ 250,-2900 + 250,-15400 + 300,-2850 + 300,-9100
|
||||
+ 250,-6050 + 250,-6000 + 250,-6000 + 300,-2850
|
||||
+ 300,-6000 + 250,-6000 + 300,-9100 + 300,-2850
|
||||
+ 300,-9100 + 300,-6000 + 250,-6000 + 300,-2850
|
||||
+ 300,-9100 + 250,-6000 + 300,-2900 + 250,-12250
|
||||
+ 300
|
||||
Sum: 138300
|
||||
|
||||
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
|
||||
Protocol=NEC Address=0xF2 Command=0x87 Raw-Data=0x78870DF2 32 bits LSB first
|
||||
Send with: IrSender.sendNEC(0xF2, 0x87, <numberOfRepeats>);
|
||||
rawData[68]:
|
||||
-3276750
|
||||
+9050,-4400
|
||||
+ 650,- 500 + 650,-1600 + 650,- 500 + 650,- 450
|
||||
+ 650,-1600 + 700,-1600 + 650,-1600 + 650,-1600
|
||||
+ 650,-1600 + 650,- 500 + 650,-1600 + 700,-1550
|
||||
+ 650,- 500 + 650,- 500 + 600,- 500 + 700,- 450
|
||||
+ 650,-1600 + 650,-1600 + 700,-1600 + 650,- 450
|
||||
+ 700,- 450 + 650,- 500 + 650,- 450 + 700,-1550
|
||||
+ 700,- 450 + 650,- 500 + 650,- 500 + 650,-1600
|
||||
+ 650,-1650 + 650,-1600 + 650,-1600 + 650,- 500
|
||||
+ 650
|
||||
Sum: 68450
|
||||
|
||||
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
|
|
@ -66,7 +66,7 @@ sendLegoPowerFunctions KEYWORD2
|
|||
sendMagiQuest KEYWORD2
|
||||
sendPronto KEYWORD2
|
||||
sendMagiQuest KEYWORD2
|
||||
|
||||
sendFAST KEYWORD2
|
||||
#######################################
|
||||
# Constants (LITERAL1)
|
||||
#######################################
|
||||
|
@ -92,10 +92,12 @@ SHARP LITERAL1
|
|||
SONY LITERAL1
|
||||
ONKYO LITERAL1
|
||||
APPLE LITERAL1
|
||||
BANG_OLUFSEN LITERAL1
|
||||
BOSEWAVE LITERAL1
|
||||
LEGO_PF LITERAL1
|
||||
MAGIQUEST LITERAL1
|
||||
WHYNTER LITERAL1
|
||||
FAST LITERAL1
|
||||
UNKNOWN LITERAL1
|
||||
IR_RECEIVE_PIN LITERAL1
|
||||
IR_SEND_PIN LITERAL1
|
||||
|
|
|
@ -5,16 +5,17 @@
|
|||
"repository":
|
||||
{
|
||||
"type": "git",
|
||||
"url": "https://github.com/z3t0/Arduino-IRremote.git"
|
||||
"url": "https://github.com/Arduino-IRremote/Arduino-IRremote.git"
|
||||
},
|
||||
"version": "3.9.0",
|
||||
"version": "4.3.1",
|
||||
"frameworks": "arduino",
|
||||
"platforms": ["atmelavr", "atmelmegaavr", "atmelsam", "espressif8266", "espressif32", "ststm32"],
|
||||
"authors" :
|
||||
[
|
||||
{
|
||||
"name":"Armin Joachimsmeyer",
|
||||
"email":"armin.arduino@gmail.com"
|
||||
"email":"armin.arduino@gmail.com",
|
||||
"maintainer": true
|
||||
},
|
||||
{
|
||||
"name":"Rafi Khan",
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
name=IRremote
|
||||
version=3.9.0
|
||||
version=4.3.1
|
||||
author=shirriff, z3t0, ArminJo
|
||||
maintainer=Armin Joachimsmeyer <armin.arduino@gmail.com>
|
||||
sentence=Send and receive infrared signals with multiple protocols
|
||||
paragraph=Currently included protocols: Denon / Sharp, JVC, LG / LG2, NEC / Onkyo / Apple, Panasonic / Kaseikyo, RC5, RC6, Samsung, Sony, (Pronto), BoseWave, Lego, Whynter, MagiQuest.<br/><br/><b>New: </b>Added NEC2 protocol. Improved Magiquest protocol. Added function sendPulseDistanceWidth().<br/><a href="https://github.com/Arduino-IRremote/Arduino-IRremote/blob/master/changelog.md">Release notes</a><br/>
|
||||
paragraph=Currently included protocols: Denon / Sharp, JVC, LG / LG2, NEC / Onkyo / Apple, Panasonic / Kaseikyo, RC5, RC6, Samsung, Sony, (Pronto), BangOlufsen, BoseWave, Lego, Whynter, FAST, MagiQuest, Universal Pulse Distance and Pulse Width. NEW: TinyRSender improvements, sendSamsung bug fixes, new fields rawlen and initialGap and new functions stop/startTimer...().
|
||||
category=Communication
|
||||
url=https://github.com/Arduino-IRremote/Arduino-IRremote
|
||||
architectures=avr,megaavr,samd,esp8266,esp32,stm32,STM32F1,mbed,mbed_nano,rp2040
|
||||
architectures=avr,megaavr,samd,esp8266,esp32,stm32,STM32F1,mbed,mbed_nano,rp2040,mbed_rp2040,renesas_uno
|
||||
includes=IRremote.hpp
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 149 KiB |
Binary file not shown.
After Width: | Height: | Size: 36 KiB |
Binary file not shown.
After Width: | Height: | Size: 1.1 MiB |
123
src/IRProtocol.h
123
src/IRProtocol.h
|
@ -8,7 +8,7 @@
|
|||
************************************************************************************
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2020-2022 Armin Joachimsmeyer
|
||||
* 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
|
||||
|
@ -35,19 +35,20 @@
|
|||
/**
|
||||
* An enum consisting of all supported formats.
|
||||
* You do NOT need to remove entries from this list when disabling protocols!
|
||||
* !!!Must be the same order as ProtocolNames in IRReceive.hpp!!!
|
||||
*/
|
||||
typedef enum {
|
||||
UNKNOWN = 0,
|
||||
#if defined(SUPPORT_PULSE_WIDTH_DECODING) // The only known pulse width protocol is Sony
|
||||
PULSE_WIDTH,
|
||||
#endif
|
||||
PULSE_DISTANCE,
|
||||
APPLE,
|
||||
DENON,
|
||||
SHARP,
|
||||
JVC,
|
||||
LG,
|
||||
LG2,
|
||||
NEC,
|
||||
NEC2, /* NEC with full frame as repeat */
|
||||
ONKYO,
|
||||
PANASONIC,
|
||||
KASEIKYO,
|
||||
KASEIKYO_DENON,
|
||||
|
@ -57,43 +58,95 @@ typedef enum {
|
|||
RC5,
|
||||
RC6,
|
||||
SAMSUNG,
|
||||
SAMSUNG_LG,
|
||||
SAMSUNGLG,
|
||||
SAMSUNG48,
|
||||
SHARP,
|
||||
SONY,
|
||||
NEC2, /* NEC with full frame as repeat */
|
||||
ONKYO,
|
||||
APPLE,
|
||||
#if !defined(EXCLUDE_EXOTIC_PROTOCOLS)
|
||||
/* Now the exotic protocols */
|
||||
BANG_OLUFSEN,
|
||||
BOSEWAVE,
|
||||
LEGO_PF,
|
||||
MAGIQUEST,
|
||||
WHYNTER,
|
||||
#endif
|
||||
FAST
|
||||
} decode_type_t;
|
||||
|
||||
struct PulsePauseWidthProtocolConstants {
|
||||
#define SIRCS_12_PROTOCOL 12
|
||||
#define SIRCS_15_PROTOCOL 15
|
||||
#define SIRCS_20_PROTOCOL 20
|
||||
|
||||
struct DistanceWidthTimingInfoStruct {
|
||||
uint16_t HeaderMarkMicros;
|
||||
uint16_t HeaderSpaceMicros;
|
||||
uint16_t OneMarkMicros;
|
||||
uint16_t OneSpaceMicros;
|
||||
uint16_t ZeroMarkMicros;
|
||||
uint16_t ZeroSpaceMicros;
|
||||
};
|
||||
|
||||
/*
|
||||
* Definitions for member IRData.flags
|
||||
*/
|
||||
#define IRDATA_FLAGS_EMPTY 0x00
|
||||
#define IRDATA_FLAGS_IS_REPEAT 0x01 ///< The gap between the preceding frame is as smaller than the maximum gap expected for a repeat. !!!We do not check for changed command or address, because it is almost not possible to press 2 different buttons on the remote within around 100 ms!!!
|
||||
#define IRDATA_FLAGS_IS_AUTO_REPEAT 0x02 ///< The current repeat frame is a repeat, that is always sent after a regular frame and cannot be avoided. Only specified for protocols DENON, and LEGO.
|
||||
#define IRDATA_FLAGS_PARITY_FAILED 0x04 ///< The current (autorepeat) frame violated parity check.
|
||||
#define IRDATA_FLAGS_TOGGLE_BIT 0x08 ///< Is set if RC5 or RC6 toggle bit is set.
|
||||
#define IRDATA_TOGGLE_BIT_MASK 0x08 ///< deprecated -is set if RC5 or RC6 toggle bit is set.
|
||||
#define IRDATA_FLAGS_EXTRA_INFO 0x10 ///< There is extra info not contained in address and data (e.g. Kaseikyo unknown vendor ID, or in decodedRawDataArray).
|
||||
#define IRDATA_FLAGS_IS_PROTOCOL_WITH_DIFFERENT_REPEAT 0x20 ///< Here we have a repeat of type NEC2 or SamsungLG
|
||||
#define IRDATA_FLAGS_WAS_OVERFLOW 0x40 ///< irparams.rawlen is set to 0 in this case to avoid endless OverflowFlag.
|
||||
#define IRDATA_FLAGS_IS_MSB_FIRST 0x80 ///< Value is mainly determined by the (known) protocol.
|
||||
#define IRDATA_FLAGS_IS_LSB_FIRST 0x00
|
||||
|
||||
#define RAW_DATA_ARRAY_SIZE ((((RAW_BUFFER_LENGTH - 2) - 1) / (2 * BITS_IN_RAW_DATA_TYPE)) + 1) // The -2 is for initial gap + stop bit mark, 128 mark + spaces for 64 bit.
|
||||
/**
|
||||
* Data structure for the user application, available as decodedIRData.
|
||||
* Filled by decoders and read by print functions or user application.
|
||||
*/
|
||||
struct IRData {
|
||||
decode_type_t protocol; ///< UNKNOWN, NEC, SONY, RC5, PULSE_DISTANCE, ...
|
||||
uint16_t address; ///< Decoded address, Distance protocol (tMarkTicksLong (if tMarkTicksLong == 0, then tMarkTicksShort) << 8) | tSpaceTicksLong
|
||||
uint16_t command; ///< Decoded command, Distance protocol (tMarkTicksShort << 8) | tSpaceTicksShort
|
||||
uint16_t extra; ///< Contains upper 16 bit of Magiquest WandID, Kaseikyo unknown vendor ID and Distance protocol (HeaderMarkTicks << 8) | HeaderSpaceTicks.
|
||||
IRRawDataType decodedRawData; ///< Up to 32/64 bit decoded raw data, to be used for send functions.
|
||||
#if defined(DECODE_DISTANCE_WIDTH)
|
||||
// This replaces the address, command, extra and decodedRawData in case of protocol == PULSE_DISTANCE or -rather seldom- protocol == PULSE_WIDTH.
|
||||
DistanceWidthTimingInfoStruct DistanceWidthTimingInfo; // 12 bytes
|
||||
IRRawDataType decodedRawDataArray[RAW_DATA_ARRAY_SIZE]; ///< 32/64 bit decoded raw data, to be used for send function.
|
||||
#endif
|
||||
uint16_t numberOfBits; ///< Number of bits received for data (address + command + parity) - to determine protocol length if different length are possible.
|
||||
uint8_t flags; ///< IRDATA_FLAGS_IS_REPEAT, IRDATA_FLAGS_WAS_OVERFLOW etc. See IRDATA_FLAGS_* definitions above
|
||||
|
||||
// These 2 variables allow to call resume() directly after decode, if no dump is required. Since 4.3.0.
|
||||
IRRawlenType rawlen; ///< counter of entries in rawbuf
|
||||
uint16_t initialGap; ///< rawbuf[0] contains the initial gap of the last frame.
|
||||
|
||||
irparams_struct *rawDataPtr; ///< Pointer of the raw timing data to be decoded. Mainly the OverflowFlag and the data buffer filled by receiving ISR.
|
||||
};
|
||||
|
||||
struct PulseDistanceWidthProtocolConstants {
|
||||
decode_type_t ProtocolIndex;
|
||||
uint_fast8_t FrequencyKHz;
|
||||
unsigned int HeaderMarkMicros;
|
||||
unsigned int HeaderSpaceMicros;
|
||||
unsigned int OneMarkMicros;
|
||||
unsigned int OneSpaceMicros;
|
||||
unsigned int ZeroMarkMicros;
|
||||
unsigned int ZeroSpaceMicros;
|
||||
bool isMSBFirst;
|
||||
bool hasStopBit;
|
||||
DistanceWidthTimingInfoStruct DistanceWidthTimingInfo;
|
||||
uint8_t Flags;
|
||||
unsigned int RepeatPeriodMillis;
|
||||
void (*SpecialSendRepeatFunction)(); // using non member functions here saves up to 250 bytes for send demo
|
||||
// void (IRsend::*SpecialSendRepeatFunction)();
|
||||
};
|
||||
|
||||
const __FlashStringHelper* getProtocolString(decode_type_t aProtocol);
|
||||
|
||||
#define PROTOCOL_IS_LSB_FIRST false
|
||||
#define PROTOCOL_IS_MSB_FIRST true
|
||||
/*
|
||||
* Definitions for member PulseDistanceWidthProtocolConstants.Flags
|
||||
*/
|
||||
#define SUPPRESS_STOP_BIT_FOR_THIS_DATA 0x20 // Stop bit is otherwise sent for all pulse distance protocols.
|
||||
#define PROTOCOL_IS_MSB_FIRST IRDATA_FLAGS_IS_MSB_FIRST
|
||||
#define PROTOCOL_IS_LSB_FIRST IRDATA_FLAGS_IS_LSB_FIRST
|
||||
|
||||
/*
|
||||
* Carrier frequencies for various protocols
|
||||
*/
|
||||
#if !defined(BEO_KHZ) // guard used for unit test, which sends and receive Bang&Olufsen with 38 kHz.
|
||||
#define BEO_KHZ 455
|
||||
#endif
|
||||
#define SONY_KHZ 40
|
||||
#define BOSEWAVE_KHZ 38
|
||||
#define DENON_KHZ 38
|
||||
|
@ -104,17 +157,17 @@ const __FlashStringHelper* getProtocolString(decode_type_t aProtocol);
|
|||
#define KASEIKYO_KHZ 37
|
||||
#define RC5_RC6_KHZ 36
|
||||
|
||||
/*
|
||||
* Constants for some protocols
|
||||
*/
|
||||
#define PANASONIC_VENDOR_ID_CODE 0x2002
|
||||
#define DENON_VENDOR_ID_CODE 0x3254
|
||||
#define MITSUBISHI_VENDOR_ID_CODE 0xCB23
|
||||
#define SHARP_VENDOR_ID_CODE 0x5AAA
|
||||
#define JVC_VENDOR_ID_CODE 0x0103
|
||||
#if defined(__AVR__)
|
||||
const __FlashStringHelper* getProtocolString(decode_type_t aProtocol);
|
||||
#else
|
||||
const char* getProtocolString(decode_type_t aProtocol);
|
||||
#endif
|
||||
void printIRResultShort(Print *aSerial, IRData *aIRDataPtr, bool aPrintGap); // A static function to be able to print send or copied received data.
|
||||
|
||||
#define SIRCS_12_PROTOCOL 12
|
||||
#define SIRCS_15_PROTOCOL 15
|
||||
#define SIRCS_20_PROTOCOL 20
|
||||
/*
|
||||
* Convenience functions to convert MSB to LSB values
|
||||
*/
|
||||
uint8_t bitreverseOneByte(uint8_t aValue);
|
||||
uint32_t bitreverse32Bit(uint32_t aInput);
|
||||
|
||||
#endif // _IR_PROTOCOL_H
|
||||
|
|
|
@ -0,0 +1,289 @@
|
|||
/*
|
||||
* IRReceive.hpp
|
||||
* This file is exclusively included by IRremote.h to enable easy configuration of library switches
|
||||
*
|
||||
* Contains all protocol functions used by receiver and sender.
|
||||
*
|
||||
* This file is part of Arduino-IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
|
||||
*
|
||||
************************************************************************************
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2009-2023 Ken Shirriff, Rafi Khan, 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.
|
||||
*
|
||||
************************************************************************************
|
||||
*/
|
||||
#ifndef _IR_PROTOCOL_HPP
|
||||
#define _IR_PROTOCOL_HPP
|
||||
|
||||
#if defined(DEBUG) && !defined(LOCAL_DEBUG)
|
||||
#define LOCAL_DEBUG
|
||||
#else
|
||||
//#define LOCAL_DEBUG // This enables debug output only for this file
|
||||
#endif
|
||||
|
||||
/** \addtogroup Receiving Receiving IR data for multiple protocols
|
||||
* @{
|
||||
*/
|
||||
|
||||
const char string_Unknown[] PROGMEM = "UNKNOWN";
|
||||
const char string_PulseWidth[] PROGMEM = "PulseWidth";
|
||||
const char string_PulseDistance[] PROGMEM = "PulseDistance";
|
||||
const char string_Apple[] PROGMEM = "Apple";
|
||||
const char string_Denon[] PROGMEM = "Denon";
|
||||
const char string_JVC[] PROGMEM = "JVC";
|
||||
const char string_LG[] PROGMEM = "LG";
|
||||
const char string_LG2[] PROGMEM = "LG2";
|
||||
const char string_NEC[] PROGMEM = "NEC";
|
||||
const char string_NEC2[] PROGMEM = "NEC2";
|
||||
const char string_Onkyo[] PROGMEM = "Onkyo";
|
||||
const char string_Panasonic[] PROGMEM = "Panasonic";
|
||||
const char string_Kaseikyo[] PROGMEM = "Kaseikyo";
|
||||
const char string_Kaseikyo_Denon[] PROGMEM = "Kaseikyo_Denon";
|
||||
const char string_Kaseikyo_Sharp[] PROGMEM = "Kaseikyo_Sharp";
|
||||
const char string_Kaseikyo_JVC[] PROGMEM = "Kaseikyo_JVC";
|
||||
const char string_Kaseikyo_Mitsubishi[] PROGMEM = "Kaseikyo_Mitsubishi";
|
||||
const char string_RC5[] PROGMEM = "RC5";
|
||||
const char string_RC6[] PROGMEM = "RC6";
|
||||
const char string_Samsung[] PROGMEM = "Samsung";
|
||||
const char string_SamsungLG[] PROGMEM = "SamsungLG";
|
||||
const char string_Samsung48[] PROGMEM = "Samsung48";
|
||||
const char string_Sharp[] PROGMEM = "Sharp";
|
||||
const char string_Sony[] PROGMEM = "Sony";
|
||||
const char string_BangOlufsen[] PROGMEM = "Bang&Olufsen";
|
||||
const char string_BoseWave[] PROGMEM = "BoseWave";
|
||||
const char string_Lego[] PROGMEM = "Lego";
|
||||
const char string_MagiQuest[] PROGMEM = "MagiQuest";
|
||||
const char string_Whynter[] PROGMEM = "Whynter";
|
||||
const char string_FAST[] PROGMEM = "FAST";
|
||||
|
||||
/*
|
||||
* !!Must be the same order as in decode_type_t in IRProtocol.h!!!
|
||||
*/
|
||||
const char *const ProtocolNames[]
|
||||
PROGMEM = { string_Unknown, string_PulseWidth, string_PulseDistance, string_Apple, string_Denon, string_JVC, string_LG, string_LG2,
|
||||
string_NEC, string_NEC2, string_Onkyo, string_Panasonic, string_Kaseikyo, string_Kaseikyo_Denon, string_Kaseikyo_Sharp,
|
||||
string_Kaseikyo_JVC, string_Kaseikyo_Mitsubishi, string_RC5, string_RC6, string_Samsung, string_SamsungLG, string_Samsung48,
|
||||
string_Sharp, string_Sony
|
||||
#if !defined(EXCLUDE_EXOTIC_PROTOCOLS)
|
||||
, string_BangOlufsen, string_BoseWave, string_Lego, string_MagiQuest, string_Whynter, string_FAST
|
||||
#endif
|
||||
};
|
||||
|
||||
#if defined(__AVR__)
|
||||
const __FlashStringHelper* getProtocolString(decode_type_t aProtocol) {
|
||||
const char *tProtocolStringPtr = (char*) pgm_read_word(&ProtocolNames[aProtocol]);
|
||||
return ((__FlashStringHelper*) (tProtocolStringPtr));
|
||||
}
|
||||
#else
|
||||
const char* getProtocolString(decode_type_t aProtocol) {
|
||||
return ProtocolNames[aProtocol];
|
||||
}
|
||||
#endif
|
||||
|
||||
#if (__INT_WIDTH__ >= 32)
|
||||
# if __has_include(<type_traits>)
|
||||
/*
|
||||
* This code to handle the missing print(unsigned long long...) function of seeduino core was contributed by sklott
|
||||
* https://stackoverflow.com/questions/74622227/avoid-calling-of-function-size-t-printprintunsigned-long-long-n-int-base-if
|
||||
*/
|
||||
#include <type_traits>
|
||||
|
||||
// If you have C++17 you can just use std::void_t, or use this for all versions
|
||||
#if __cpp_lib_void_t >= 201411L
|
||||
template<typename T>
|
||||
using void_t = std::void_t<T>;
|
||||
#else
|
||||
template<typename ... Ts> struct make_void {
|
||||
typedef void type;
|
||||
};
|
||||
template<typename ... Ts> using void_t = typename make_void<Ts...>::type;
|
||||
#endif
|
||||
|
||||
// Detecting if we have print(unsigned long long value, int base) / print(0ull, 0) overload
|
||||
template<typename T, typename = void>
|
||||
struct has_ull_print: std::false_type {
|
||||
};
|
||||
template<typename T>
|
||||
struct has_ull_print<T, void_t<decltype(std::declval<T>().print(0ull, 0))>> : std::true_type {
|
||||
};
|
||||
|
||||
// Must be namespace, to avoid public and static declarations for class
|
||||
namespace PrintULL {
|
||||
template<typename PrintImplType, typename std::enable_if<!has_ull_print<PrintImplType>::value, bool>::type = true>
|
||||
size_t print(PrintImplType *p, unsigned long long value, int base) {
|
||||
size_t tLength = p->print(static_cast<uint32_t>(value >> 32), base);
|
||||
tLength += p->print(static_cast<uint32_t>(value), base);
|
||||
return tLength;
|
||||
}
|
||||
|
||||
template<typename PrintImplType, typename std::enable_if<has_ull_print<PrintImplType>::value, bool>::type = true>
|
||||
size_t print(PrintImplType *p, unsigned long long value, int base) {
|
||||
return p->print(value, base);
|
||||
}
|
||||
}
|
||||
;
|
||||
# else
|
||||
namespace PrintULL {
|
||||
size_t print(Print *aSerial, unsigned long long n, int base) {
|
||||
return aSerial->print(n, base);
|
||||
}
|
||||
};
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Function to print decoded result and flags in one line.
|
||||
* A static function to be able to print data to send or copied received data.
|
||||
* Ends with println().
|
||||
*
|
||||
* @param aSerial The Print object on which to write, for Arduino you can use &Serial.
|
||||
* @param aIRDataPtr Pointer to the data to be printed.
|
||||
* @param aPrintRepeatGap If true also print the gap before repeats.
|
||||
*
|
||||
*/
|
||||
void printIRResultShort(Print *aSerial, IRData *aIRDataPtr, bool aPrintRepeatGap) {
|
||||
if (aIRDataPtr->flags & IRDATA_FLAGS_WAS_OVERFLOW) {
|
||||
aSerial->println(F("Overflow"));
|
||||
return;
|
||||
}
|
||||
aSerial->print(F("Protocol="));
|
||||
aSerial->print(getProtocolString(aIRDataPtr->protocol));
|
||||
if (aIRDataPtr->protocol == UNKNOWN) {
|
||||
#if defined(DECODE_HASH)
|
||||
aSerial->print(F(" Hash=0x"));
|
||||
#if (__INT_WIDTH__ < 32)
|
||||
aSerial->print(aIRDataPtr->decodedRawData, HEX);
|
||||
#else
|
||||
PrintULL::print(aSerial,aIRDataPtr->decodedRawData, HEX);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#if !defined(DISABLE_CODE_FOR_RECEIVER)
|
||||
aSerial->print(' ');
|
||||
aSerial->print((aIRDataPtr->rawlen + 1) / 2, DEC);
|
||||
aSerial->println(F(" bits (incl. gap and start) received"));
|
||||
#endif
|
||||
} else {
|
||||
#if defined(DECODE_DISTANCE_WIDTH)
|
||||
if (aIRDataPtr->protocol != PULSE_DISTANCE && aIRDataPtr->protocol != PULSE_WIDTH) {
|
||||
#endif
|
||||
/*
|
||||
* New decoders have address and command
|
||||
*/
|
||||
aSerial->print(F(" Address=0x"));
|
||||
aSerial->print(aIRDataPtr->address, HEX);
|
||||
|
||||
aSerial->print(F(" Command=0x"));
|
||||
aSerial->print(aIRDataPtr->command, HEX);
|
||||
|
||||
if (aIRDataPtr->flags & IRDATA_FLAGS_EXTRA_INFO) {
|
||||
aSerial->print(F(" Extra=0x"));
|
||||
aSerial->print(aIRDataPtr->extra, HEX);
|
||||
}
|
||||
|
||||
if (aIRDataPtr->flags & IRDATA_FLAGS_PARITY_FAILED) {
|
||||
aSerial->print(F(" Parity fail"));
|
||||
}
|
||||
|
||||
if (aIRDataPtr->flags & IRDATA_FLAGS_TOGGLE_BIT) {
|
||||
aSerial->print(F(" Toggle=1"));
|
||||
}
|
||||
#if defined(DECODE_DISTANCE_WIDTH)
|
||||
}
|
||||
#endif
|
||||
if (aIRDataPtr->flags & (IRDATA_FLAGS_IS_AUTO_REPEAT | IRDATA_FLAGS_IS_REPEAT)) {
|
||||
aSerial->print(' ');
|
||||
if (aIRDataPtr->flags & IRDATA_FLAGS_IS_AUTO_REPEAT) {
|
||||
aSerial->print(F("Auto-"));
|
||||
}
|
||||
aSerial->print(F("Repeat"));
|
||||
#if !defined(DISABLE_CODE_FOR_RECEIVER)
|
||||
if (aPrintRepeatGap) {
|
||||
aSerial->print(F(" gap="));
|
||||
aSerial->print((uint32_t) aIRDataPtr->initialGap * MICROS_PER_TICK);
|
||||
aSerial->print(F("us"));
|
||||
}
|
||||
#else
|
||||
(void)aPrintRepeatGap;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* Print raw data
|
||||
*/
|
||||
if (!(aIRDataPtr->flags & IRDATA_FLAGS_IS_REPEAT) || aIRDataPtr->decodedRawData != 0) {
|
||||
aSerial->print(F(" Raw-Data=0x"));
|
||||
#if (__INT_WIDTH__ < 32)
|
||||
aSerial->print(aIRDataPtr->decodedRawData, HEX);
|
||||
#else
|
||||
PrintULL::print(aSerial, aIRDataPtr->decodedRawData, HEX);
|
||||
#endif
|
||||
/*
|
||||
* Print number of bits processed
|
||||
*/
|
||||
aSerial->print(' ');
|
||||
aSerial->print(aIRDataPtr->numberOfBits, DEC);
|
||||
aSerial->print(F(" bits"));
|
||||
|
||||
if (aIRDataPtr->flags & IRDATA_FLAGS_IS_MSB_FIRST) {
|
||||
aSerial->println(F(" MSB first"));
|
||||
} else {
|
||||
aSerial->println(F(" LSB first"));
|
||||
}
|
||||
|
||||
} else {
|
||||
aSerial->println();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**********************************************************************************************************************
|
||||
* Function to bit reverse OLD MSB values of e.g. NEC.
|
||||
**********************************************************************************************************************/
|
||||
uint8_t bitreverseOneByte(uint8_t aValue) {
|
||||
// uint8_t tReversedValue;
|
||||
// return __builtin_avr_insert_bits(0x01234567, aValue, tReversedValue);
|
||||
// 76543210
|
||||
aValue = (aValue >> 4) | (aValue << 4); // Swap in groups of 4
|
||||
// 32107654
|
||||
aValue = ((aValue & 0xcc) >> 2) | ((aValue & 0x33) << 2); // Swap in groups of 2
|
||||
// 10325476
|
||||
aValue = ((aValue & 0xaa) >> 1) | ((aValue & 0x55) << 1); // Swap bit pairs
|
||||
// 01234567
|
||||
return aValue;
|
||||
}
|
||||
|
||||
uint32_t bitreverse32Bit(uint32_t aInput) {
|
||||
// __builtin_avr_insert_bits();
|
||||
LongUnion tValue;
|
||||
tValue.UByte.HighByte = bitreverseOneByte(aInput);
|
||||
tValue.UByte.MidHighByte = bitreverseOneByte(aInput >> 8);
|
||||
tValue.UByte.MidLowByte = bitreverseOneByte(aInput >> 16);
|
||||
tValue.UByte.LowByte = bitreverseOneByte(aInput >> 24);
|
||||
return tValue.ULong;
|
||||
}
|
||||
|
||||
/** @}*/
|
||||
|
||||
#if defined(LOCAL_DEBUG)
|
||||
#undef LOCAL_DEBUG
|
||||
#endif
|
||||
#endif // _IR_PROTOCOL_HPP
|
1486
src/IRReceive.hpp
1486
src/IRReceive.hpp
File diff suppressed because it is too large
Load Diff
752
src/IRSend.hpp
752
src/IRSend.hpp
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,51 @@
|
|||
/**
|
||||
* @file IRversion.hpp
|
||||
*
|
||||
* This file is part of Arduino-IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
|
||||
*
|
||||
************************************************************************************
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2015-2023 Ken Shirriff http://www.righto.com, Rafi Khan, 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.
|
||||
*
|
||||
************************************************************************************
|
||||
*
|
||||
* For Ken Shiriffs original blog entry, see http://www.righto.com/2009/08/multi-protocol-infrared-remote-library.html
|
||||
* Initially influenced by:
|
||||
* http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1210243556
|
||||
* and http://zovirl.com/2008/11/12/building-a-universal-remote-with-an-arduino/
|
||||
*/
|
||||
|
||||
#ifndef _IR_VERSION_HPP
|
||||
#define _IR_VERSION_HPP
|
||||
|
||||
#define VERSION_IRREMOTE "4.3.1"
|
||||
#define VERSION_IRREMOTE_MAJOR 4
|
||||
#define VERSION_IRREMOTE_MINOR 3
|
||||
#define VERSION_IRREMOTE_PATCH 1
|
||||
|
||||
/*
|
||||
* Macro to convert 3 version parts into an integer
|
||||
* To be used in preprocessor comparisons, such as #if VERSION_IRREMOTE_HEX >= VERSION_HEX_VALUE(3, 7, 0)
|
||||
*/
|
||||
#define VERSION_HEX_VALUE(major, minor, patch) ((major << 16) | (minor << 8) | (patch))
|
||||
#define VERSION_IRREMOTE_HEX VERSION_HEX_VALUE(VERSION_IRREMOTE_MAJOR, VERSION_IRREMOTE_MINOR, VERSION_IRREMOTE_PATCH)
|
||||
|
||||
#endif // _IR_VERSION_HPP
|
|
@ -9,6 +9,50 @@
|
|||
|
||||
#include "IRremote.hpp"
|
||||
|
||||
#warning Thank you for using the IRremote library!
|
||||
#warning It seems, that you are using a old version 2.0 code / example.
|
||||
#warning This version is no longer supported!
|
||||
#warning Please use one of the new code examples from the library available at "File > Examples > Examples from Custom Libraries / IRremote".
|
||||
#warning Or downgrade your library to version 2.6.0.
|
||||
#warning Start with the SimpleReceiver or SimpleSender example.
|
||||
#warning The examples are documented here: https://github.com/Arduino-IRremote/Arduino-IRremote#examples-for-this-library
|
||||
#warning A guide how to convert your 2.0 program is here: https://github.com/Arduino-IRremote/Arduino-IRremote#converting-your-2x-program-to-the-4x-version
|
||||
|
||||
/**********************************************************************************************************************
|
||||
* The OLD and DEPRECATED decode function with parameter aResults, kept for backward compatibility to old 2.0 tutorials
|
||||
* This function calls the old MSB first decoders and fills only the 3 variables:
|
||||
* aResults->value
|
||||
* aResults->bits
|
||||
* aResults->decode_type
|
||||
* It prints a message on the first call.
|
||||
**********************************************************************************************************************/
|
||||
bool IRrecv::decode(decode_results *aResults) {
|
||||
static bool sMessageWasSent = false;
|
||||
if (!sMessageWasSent) {
|
||||
Serial.println(F("**************************************************************************************************"));
|
||||
Serial.println(F("Thank you for using the IRremote library!"));
|
||||
Serial.println(F("It seems, that you are using a old version 2.0 code / example."));
|
||||
Serial.println(F("This version is no longer supported!"));
|
||||
Serial.println(F("Please use one of the new code examples from the library,"));
|
||||
Serial.println(F(" available at \"File > Examples > Examples from Custom Libraries / IRremote\"."));
|
||||
Serial.println(F("Or downgrade your library to version 2.6.0."));
|
||||
Serial.println();
|
||||
Serial.println(F("Start with the SimpleReceiver or SimpleSender example."));
|
||||
Serial.println();
|
||||
Serial.println(F("The examples are documented here:"));
|
||||
Serial.println(F(" https://github.com/Arduino-IRremote/Arduino-IRremote#examples-for-this-library"));
|
||||
Serial.println(F("A guide how to convert your 2.0 program is here:"));
|
||||
Serial.println(F(" https://github.com/Arduino-IRremote/Arduino-IRremote#converting-your-2x-program-to-the-4x-version"));
|
||||
Serial.println();
|
||||
Serial.println(F("Thanks"));
|
||||
Serial.println(F("**************************************************************************************************"));
|
||||
Serial.println();
|
||||
Serial.println();
|
||||
sMessageWasSent = true;
|
||||
}
|
||||
return decode_old(aResults);
|
||||
}
|
||||
|
||||
#endif // IRremote_h
|
||||
#pragma once
|
||||
|
||||
|
|
108
src/IRremote.hpp
108
src/IRremote.hpp
|
@ -13,7 +13,7 @@
|
|||
************************************************************************************
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2015-2022 Ken Shirriff http://www.righto.com, Rafi Khan, Armin Joachimsmeyer
|
||||
* Copyright (c) 2015-2023 Ken Shirriff http://www.righto.com, Rafi Khan, 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
|
||||
|
@ -49,7 +49,7 @@
|
|||
* - SEND_PWM_BY_TIMER Disable carrier PWM generation in software and use (restricted) hardware PWM.
|
||||
* - USE_NO_SEND_PWM Use no carrier PWM, just simulate an **active low** receiver signal. Overrides SEND_PWM_BY_TIMER definition.
|
||||
* - USE_OPEN_DRAIN_OUTPUT_FOR_SEND_PIN Use or simulate open drain output mode at send pin. Attention, active state of open drain is LOW, so connect the send LED between positive supply and send pin!
|
||||
* - EXCLUDE_EXOTIC_PROTOCOLS If activated, BOSEWAVE, WHYNTER and LEGO_PF are excluded in decode() and in sending with IrSender.write().
|
||||
* - EXCLUDE_EXOTIC_PROTOCOLS If activated, BANG_OLUFSEN, BOSEWAVE, WHYNTER, FAST and LEGO_PF are excluded in decode() and in sending with IrSender.write().
|
||||
* - EXCLUDE_UNIVERSAL_PROTOCOLS If activated, the universal decoder for pulse distance protocols and decodeHash (special decoder for all protocols) are excluded in decode().
|
||||
* - DECODE_* Selection of individual protocols to be decoded. See below.
|
||||
* - MARK_EXCESS_MICROS Value is subtracted from all marks and added to all spaces before decoding, to compensate for the signal forming of different IR receiver modules.
|
||||
|
@ -65,23 +65,13 @@
|
|||
#ifndef _IR_REMOTE_HPP
|
||||
#define _IR_REMOTE_HPP
|
||||
|
||||
#define VERSION_IRREMOTE "3.9.0"
|
||||
#define VERSION_IRREMOTE_MAJOR 3
|
||||
#define VERSION_IRREMOTE_MINOR 9
|
||||
#define VERSION_IRREMOTE_PATCH 0
|
||||
|
||||
/*
|
||||
* Macro to convert 3 version parts into an integer
|
||||
* To be used in preprocessor comparisons, such as #if VERSION_IRREMOTE_HEX >= VERSION_HEX_VALUE(3, 7, 0)
|
||||
*/
|
||||
#define VERSION_HEX_VALUE(major, minor, patch) ((major << 16) | (minor << 8) | (patch))
|
||||
#define VERSION_IRREMOTE_HEX VERSION_HEX_VALUE(VERSION_IRREMOTE_MAJOR, VERSION_IRREMOTE_MINOR, VERSION_IRREMOTE_PATCH)
|
||||
#include "IRVersion.h"
|
||||
|
||||
// activate it for all cores that does not use the -flto flag, if you get false error messages regarding begin() during compilation.
|
||||
//#define SUPPRESS_ERROR_MESSAGE_FOR_BEGIN
|
||||
|
||||
/*
|
||||
* If activated, BOSEWAVE, MAGIQUEST,WHYNTER and LEGO_PF are excluded in decoding and in sending with IrSender.write
|
||||
* If activated, BANG_OLUFSEN, BOSEWAVE, MAGIQUEST, WHYNTER, FAST and LEGO_PF are excluded in decoding and in sending with IrSender.write
|
||||
*/
|
||||
//#define EXCLUDE_EXOTIC_PROTOCOLS
|
||||
/****************************************************
|
||||
|
@ -96,17 +86,17 @@
|
|||
|
||||
#if !defined(NO_DECODER) // for sending raw only
|
||||
# if (!(defined(DECODE_DENON) || defined(DECODE_JVC) || defined(DECODE_KASEIKYO) \
|
||||
|| defined(DECODE_PANASONIC) || defined(DECODE_LG) || defined(DECODE_NEC) || defined(DECODE_SAMSUNG) \
|
||||
|| defined(DECODE_PANASONIC) || defined(DECODE_LG) || defined(DECODE_NEC) || defined(DECODE_ONKYO) || defined(DECODE_SAMSUNG) \
|
||||
|| defined(DECODE_SONY) || defined(DECODE_RC5) || defined(DECODE_RC6) \
|
||||
|| defined(DECODE_DISTANCE) || defined(DECODE_HASH) || defined(DECODE_BOSEWAVE) \
|
||||
|| defined(DECODE_LEGO_PF) || defined(DECODE_WHYNTER)))
|
||||
|| defined(DECODE_DISTANCE_WIDTH) || defined(DECODE_HASH) || defined(DECODE_BOSEWAVE) \
|
||||
|| defined(DECODE_LEGO_PF) || defined(DECODE_MAGIQUEST) || defined(DECODE_FAST) || defined(DECODE_WHYNTER)))
|
||||
/*
|
||||
* If no protocol is explicitly enabled, we enable all protocols
|
||||
*/
|
||||
#define DECODE_DENON // Includes Sharp
|
||||
#define DECODE_JVC
|
||||
#define DECODE_KASEIKYO
|
||||
#define DECODE_PANASONIC // the same as DECODE_KASEIKYO
|
||||
#define DECODE_PANASONIC // alias for DECODE_KASEIKYO
|
||||
#define DECODE_LG
|
||||
#define DECODE_NEC // Includes Apple and Onkyo
|
||||
#define DECODE_SAMSUNG
|
||||
|
@ -119,15 +109,18 @@
|
|||
#define DECODE_LEGO_PF
|
||||
#define DECODE_MAGIQUEST // It modifies the RAW_BUFFER_LENGTH from 100 to 112
|
||||
#define DECODE_WHYNTER
|
||||
#define DECODE_FAST
|
||||
# endif
|
||||
|
||||
# if !defined(EXCLUDE_UNIVERSAL_PROTOCOLS)
|
||||
#define DECODE_DISTANCE // universal decoder for pulse distance protocols - requires up to 750 bytes additional program memory
|
||||
#define DECODE_DISTANCE_WIDTH // universal decoder for pulse distance width protocols - requires up to 750 bytes additional program memory
|
||||
#define DECODE_HASH // special decoder for all protocols - requires up to 250 bytes additional program memory
|
||||
# endif
|
||||
# endif
|
||||
#endif // !defined(NO_DECODER)
|
||||
|
||||
//#define DECODE_BEO // Bang & Olufsen protocol always must be enabled explicitly. It prevents decoding of SONY!
|
||||
|
||||
#if defined(DECODE_NEC) && !(~(~DECODE_NEC + 0) == 0 && ~(~DECODE_NEC + 1) == 1)
|
||||
#warning "The macros DECODE_XXX no longer require a value. Decoding is now switched by defining / non defining the macro."
|
||||
#endif
|
||||
|
@ -137,23 +130,6 @@
|
|||
/****************************************************
|
||||
* RECEIVING
|
||||
****************************************************/
|
||||
|
||||
/**
|
||||
* The length of the buffer where the IR timing data is stored before decoding
|
||||
* 100 is sufficient for most standard protocols, but air conditioners often send a longer protocol data stream
|
||||
*/
|
||||
#if !defined(RAW_BUFFER_LENGTH)
|
||||
# if defined(DECODE_MAGIQUEST)
|
||||
#define RAW_BUFFER_LENGTH 112 // MagiQuest requires 112 bytes.
|
||||
# else
|
||||
#define RAW_BUFFER_LENGTH 100 ///< Length of raw duration buffer. Must be even. 100 supports up to 48 bit codings inclusive 1 start and 1 stop bit.
|
||||
//#define RAW_BUFFER_LENGTH 750 // 750 (600 if we have only 2k RAM) is the value for air condition remotes.
|
||||
# endif
|
||||
#endif
|
||||
#if RAW_BUFFER_LENGTH % 2 == 1
|
||||
#error RAW_BUFFER_LENGTH must be even, since the array consists of space / mark pairs.
|
||||
#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
|
||||
|
@ -166,7 +142,7 @@
|
|||
*
|
||||
* 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
|
||||
* VS1838 Mark Excess -50 at low intensity to +50 us at high intensity
|
||||
* TSOP31238 Mark Excess 0 to +50
|
||||
*/
|
||||
#if !defined(MARK_EXCESS_MICROS)
|
||||
|
@ -177,23 +153,23 @@
|
|||
/**
|
||||
* Minimum gap between IR transmissions, to detect the end of a protocol.
|
||||
* Must be greater than any space of a protocol e.g. the NEC header space of 4500 us.
|
||||
* Must be smaller than any gap between a command and a repeat; e.g. the retransmission gap for Sony is around 24 ms.
|
||||
* Must be smaller than any gap between a command and a repeat; e.g. the retransmission gap for Sony is around 15 ms for Sony20 protocol.
|
||||
* Keep in mind, that this is the delay between the end of the received command and the start of decoding.
|
||||
*/
|
||||
#if !defined(RECORD_GAP_MICROS)
|
||||
// To change this value, you simply can add a line #define "RECORD_GAP_MICROS <My_new_value>" in your ino file before the line "#include <IRremote.hpp>"
|
||||
#define RECORD_GAP_MICROS 5000 // FREDRICH28AC / LG2 header space is 9700, NEC header space is 4500
|
||||
#define RECORD_GAP_MICROS 8000 // RECS80 (https://www.mikrocontroller.net/articles/IRMP#RECS80) 1 bit space is 7500µs , NEC header space is 4500
|
||||
#endif
|
||||
/**
|
||||
* Threshold for warnings at printIRResult*() to report about changing the RECORD_GAP_MICROS value to a higher value.
|
||||
*/
|
||||
#if !defined(RECORD_GAP_MICROS_WARNING_THRESHOLD)
|
||||
// To change this value, you simply can add a line #define "RECORD_GAP_MICROS_WARNING_THRESHOLD <My_new_value>" in your ino file before the line "#include <IRremote.hpp>"
|
||||
#define RECORD_GAP_MICROS_WARNING_THRESHOLD 20000
|
||||
#define RECORD_GAP_MICROS_WARNING_THRESHOLD 15000
|
||||
#endif
|
||||
|
||||
/** Minimum gap between IR transmissions, in MICROS_PER_TICK */
|
||||
#define RECORD_GAP_TICKS (RECORD_GAP_MICROS / MICROS_PER_TICK) // 221 for 1100
|
||||
#define RECORD_GAP_TICKS (RECORD_GAP_MICROS / MICROS_PER_TICK) // 100
|
||||
|
||||
/*
|
||||
* Activate this line if your receiver has an external output driver transistor / "inverted" output
|
||||
|
@ -213,11 +189,10 @@
|
|||
* Define to disable carrier PWM generation in software and use (restricted) hardware PWM.
|
||||
*/
|
||||
//#define SEND_PWM_BY_TIMER // restricts send pin on many platforms to fixed pin numbers
|
||||
|
||||
#if (defined(ESP32) || defined(ARDUINO_ARCH_RP2040) || defined(PARTICLE)) || defined(ARDUINO_ARCH_MBED)
|
||||
# if !defined(SEND_PWM_BY_TIMER)
|
||||
#define SEND_PWM_BY_TIMER // the best and default method for ESP32 etc.
|
||||
#warning INFO: For ESP32, RP2040, mbed and particle boards SEND_PWM_BY_TIMER is enabled by default. If this is not intended, deactivate the line in IRremote.hpp over this warning message in file IRremote.hpp.
|
||||
#warning INFO: For ESP32, RP2040, mbed and particle boards SEND_PWM_BY_TIMER is enabled by default, since we have the resources and timing is more exact than the software generated one. If this is not intended, deactivate the line in IRremote.hpp over this warning message in file IRremote.hpp.
|
||||
# endif
|
||||
#else
|
||||
# if defined(SEND_PWM_BY_TIMER)
|
||||
|
@ -271,7 +246,7 @@
|
|||
* microseconds per clock interrupt tick
|
||||
*/
|
||||
#if ! defined(MICROS_PER_TICK)
|
||||
#define MICROS_PER_TICK 50
|
||||
#define MICROS_PER_TICK 50L // must be with L to get 32 bit results if multiplied with rawbuf[] content.
|
||||
#endif
|
||||
|
||||
#define MILLIS_IN_ONE_SECOND 1000L
|
||||
|
@ -296,59 +271,42 @@
|
|||
#warning INFO: No definition for LED_BUILTIN found -> default LED feedback is disabled.
|
||||
# endif
|
||||
#include "IRFeedbackLED.hpp"
|
||||
# else
|
||||
void disableLEDFeedback() {}; // dummy function for examples
|
||||
# endif
|
||||
|
||||
#include "LongUnion.h" // used in most decoders
|
||||
|
||||
/*
|
||||
* Include the sources here to enable compilation with macro values set by user program.
|
||||
*/
|
||||
#include "IRProtocol.hpp" // must be first, it includes definition for PrintULL (unsigned long long)
|
||||
#if !defined(DISABLE_CODE_FOR_RECEIVER)
|
||||
#include "IRReceive.hpp"
|
||||
#endif
|
||||
#include "IRSend.hpp"
|
||||
|
||||
/*
|
||||
* Include the sources of all decoders here to enable compilation with macro values set by user program.
|
||||
*/
|
||||
# if defined(DECODE_BOSEWAVE)
|
||||
#include "ir_BangOlufsen.hpp"
|
||||
#include "ir_BoseWave.hpp"
|
||||
# endif
|
||||
# if defined(DECODE_DENON ) // Includes Sharp
|
||||
#include "ir_Denon.hpp"
|
||||
# endif
|
||||
# if defined(DECODE_DISTANCE) // universal decoder for pulse distance protocols - requires up to 750 bytes additional program memory
|
||||
#include "ir_DistanceProtocol.hpp"
|
||||
# endif
|
||||
# if defined(DECODE_JVC)
|
||||
#include "ir_JVC.hpp"
|
||||
# endif
|
||||
# if defined(DECODE_KASEIKYO) || defined(DECODE_PANASONIC)
|
||||
#include "ir_Kaseikyo.hpp"
|
||||
# endif
|
||||
# if defined(DECODE_LEGO_PF)
|
||||
#include "ir_Lego.hpp"
|
||||
# endif
|
||||
# if defined(DECODE_LG)
|
||||
#include "ir_LG.hpp"
|
||||
# endif
|
||||
# if defined(DECODE_MAGIQUEST)
|
||||
#include "ir_MagiQuest.hpp"
|
||||
# endif
|
||||
# if defined(DECODE_NEC) // Includes Apple and Onkyo
|
||||
#include "ir_NEC.hpp"
|
||||
# endif
|
||||
# if defined(DECODE_RC5) || defined(DECODE_RC6)
|
||||
#include "ir_RC5_RC6.hpp"
|
||||
# endif
|
||||
# if defined(DECODE_SAMSUNG)
|
||||
#include "ir_Samsung.hpp"
|
||||
# endif
|
||||
# if defined(DECODE_SONY)
|
||||
#include "ir_Sony.hpp"
|
||||
# endif
|
||||
# if defined(DECODE_WHYNTER)
|
||||
#include "ir_Whynter.hpp"
|
||||
# endif
|
||||
|
||||
#include "ir_FAST.hpp"
|
||||
#include "ir_Others.hpp"
|
||||
#include "ir_Pronto.hpp" // pronto is an universal decoder and encoder
|
||||
|
||||
#include "ir_Dish.hpp" // contains only sendDISH(unsigned long data, int nbits)
|
||||
# if defined(DECODE_DISTANCE_WIDTH) // universal decoder for pulse distance width protocols - requires up to 750 bytes additional program memory
|
||||
#include <ir_DistanceWidthProtocol.hpp>
|
||||
# endif
|
||||
#endif // #if !defined(USE_IRREMOTE_HPP_AS_PLAIN_INCLUDE)
|
||||
|
||||
/**
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
************************************************************************************
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2015-2022 Ken Shirriff http://www.righto.com, Rafi Khan, Armin Joachimsmeyer
|
||||
* Copyright (c) 2015-2023 Ken Shirriff http://www.righto.com, Rafi Khan, 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
|
||||
|
@ -63,16 +63,35 @@
|
|||
#define ENABLE_LED_FEEDBACK true
|
||||
#define USE_DEFAULT_FEEDBACK_LED_PIN 0
|
||||
|
||||
#include "IRProtocol.h"
|
||||
/**
|
||||
* The length of the buffer where the IR timing data is stored before decoding
|
||||
* 100 is sufficient for most standard protocols, but air conditioners often send a longer protocol data stream
|
||||
*/
|
||||
#if !defined(RAW_BUFFER_LENGTH)
|
||||
# if defined(DECODE_MAGIQUEST)
|
||||
#define RAW_BUFFER_LENGTH 112 // MagiQuest requires 112 bytes.
|
||||
# else
|
||||
#define RAW_BUFFER_LENGTH 100 ///< Length of raw duration buffer. Must be even. 100 supports up to 48 bit codings inclusive 1 start and 1 stop bit.
|
||||
//#define RAW_BUFFER_LENGTH 750 // 750 (600 if we have only 2k RAM) is the value for air condition remotes.
|
||||
# endif
|
||||
#endif
|
||||
#if RAW_BUFFER_LENGTH % 2 == 1
|
||||
#error RAW_BUFFER_LENGTH must be even, since the array consists of space / mark pairs.
|
||||
#endif
|
||||
|
||||
#if RAW_BUFFER_LENGTH <= 254 // saves around 75 bytes program memory and speeds up ISR
|
||||
typedef uint_fast8_t IRRawlenType;
|
||||
#else
|
||||
typedef unsigned int IRRawlenType;
|
||||
#endif
|
||||
/****************************************************
|
||||
* Declarations for the receiver Interrupt Service Routine
|
||||
****************************************************/
|
||||
// ISR State-Machine : Receiver States
|
||||
#define IR_REC_STATE_IDLE 0
|
||||
#define IR_REC_STATE_MARK 1
|
||||
#define IR_REC_STATE_SPACE 2
|
||||
#define IR_REC_STATE_STOP 3 // set to IR_REC_STATE_IDLE only by resume()
|
||||
#define IR_REC_STATE_IDLE 0 // Counting the gap time and waiting for the start bit to arrive
|
||||
#define IR_REC_STATE_MARK 1 // A mark was received and we are counting the duration of it.
|
||||
#define IR_REC_STATE_SPACE 2 // A space was received and we are counting the duration of it. If space is too long, we assume end of frame.
|
||||
#define IR_REC_STATE_STOP 3 // Stopped until set to IR_REC_STATE_IDLE which can only be done by resume()
|
||||
|
||||
/**
|
||||
* This struct contains the data and control used for receiver static functions and the ISR (interrupt service routine)
|
||||
|
@ -86,19 +105,28 @@ struct irparams_struct {
|
|||
volatile uint8_t *IRReceivePinPortInputRegister;
|
||||
uint8_t IRReceivePinMask;
|
||||
#endif
|
||||
uint_fast16_t TickCounterForISR; ///< Counts 50uS ticks. The value is copied into the rawbuf array on every transition.
|
||||
|
||||
bool OverflowFlag; ///< Raw buffer OverflowFlag occurred
|
||||
#if RAW_BUFFER_LENGTH <= 254 // saves around 75 bytes program memory and speeds up ISR
|
||||
uint_fast8_t rawlen; ///< counter of entries in rawbuf
|
||||
#else
|
||||
uint_fast16_t rawlen; ///< counter of entries in rawbuf
|
||||
volatile uint_fast16_t TickCounterForISR; ///< Counts 50uS ticks. The value is copied into the rawbuf array on every transition. Counting is independent of state or resume().
|
||||
#if !defined(IR_REMOTE_DISABLE_RECEIVE_COMPLETE_CALLBACK)
|
||||
void (*ReceiveCompleteCallbackFunction)(void); ///< The function to call if a protocol message has arrived, i.e. StateForISR changed to IR_REC_STATE_STOP
|
||||
#endif
|
||||
unsigned int rawbuf[RAW_BUFFER_LENGTH]; ///< raw data / tick counts per mark/space, first entry is the length of the gap between previous and current command
|
||||
bool OverflowFlag; ///< Raw buffer OverflowFlag occurred
|
||||
IRRawlenType rawlen; ///< counter of entries in rawbuf
|
||||
uint16_t rawbuf[RAW_BUFFER_LENGTH]; ///< raw data / tick counts per mark/space, first entry is the length of the gap between previous and current command
|
||||
};
|
||||
|
||||
#if (__INT_WIDTH__ < 32)
|
||||
typedef uint32_t IRRawDataType;
|
||||
#define BITS_IN_RAW_DATA_TYPE 32
|
||||
#else
|
||||
typedef uint64_t IRRawDataType;
|
||||
#define BITS_IN_RAW_DATA_TYPE 64
|
||||
#endif
|
||||
#include "IRProtocol.h"
|
||||
|
||||
/*
|
||||
* Debug directives
|
||||
* Outputs with IR_DEBUG_PRINT can only be activated by defining DEBUG!
|
||||
* If LOCAL_DEBUG is defined in one file, all outputs with IR_DEBUG_PRINT are still suppressed.
|
||||
*/
|
||||
#if defined(DEBUG) || defined(TRACE)
|
||||
# define IR_DEBUG_PRINT(...) Serial.print(__VA_ARGS__)
|
||||
|
@ -125,40 +153,6 @@ struct irparams_struct {
|
|||
/****************************************************
|
||||
* RECEIVING
|
||||
****************************************************/
|
||||
/*
|
||||
* Definitions for member IRData.flags
|
||||
*/
|
||||
#define IRDATA_FLAGS_EMPTY 0x00
|
||||
#define IRDATA_FLAGS_IS_REPEAT 0x01
|
||||
#define IRDATA_FLAGS_IS_AUTO_REPEAT 0x02
|
||||
#define IRDATA_FLAGS_PARITY_FAILED 0x04 ///< the current (autorepeat) frame violated parity check
|
||||
#define IRDATA_FLAGS_TOGGLE_BIT 0x08 ///< is set if RC5 or RC6 toggle bit is set
|
||||
#define IRDATA_FLAGS_EXTRA_INFO 0x10 ///< there is extra info not contained in address and data (e.g. Kaseikyo unknown vendor ID)
|
||||
#define IRDATA_FLAGS_WAS_OVERFLOW 0x40 ///< irparams.rawlen is 0 in this case to avoid endless OverflowFlag
|
||||
#define IRDATA_FLAGS_IS_LSB_FIRST 0x00
|
||||
#define IRDATA_FLAGS_IS_MSB_FIRST 0x80 ///< Just for info. Value is mainly determined by the protocol
|
||||
|
||||
// deprecated
|
||||
#define IRDATA_TOGGLE_BIT_MASK 0x08 ///< is set if RC5 or RC6 toggle bit is set
|
||||
|
||||
#define RAW_DATA_ARRAY_SIZE ((((RAW_BUFFER_LENGTH - 2) - 1) / 64) + 1) // The -2 is for initial gap + stop bit mark, 64 mark + spaces for 32 bit.
|
||||
/**
|
||||
* Data structure for the user application, available as decodedIRData.
|
||||
* Filled by decoders and read by print functions or user application.
|
||||
*/
|
||||
struct IRData {
|
||||
decode_type_t protocol; ///< UNKNOWN, NEC, SONY, RC5, PULSE_DISTANCE, ...
|
||||
uint16_t address; ///< Decoded address, Distance protocol (OneMarkTicks << 8) | OneSpaceTicks
|
||||
uint16_t command; ///< Decoded command, Distance protocol (ZeroMarkTicks << 8) | ZeroSpaceTicks
|
||||
uint16_t extra; ///< Contains upper 16 bit of Magiquest WandID, Kaseikyo unknown vendor ID and Distance protocol (HeaderMarkTicks << 8) | HeaderSpaceTicks.
|
||||
uint16_t numberOfBits; ///< Number of bits received for data (address + command + parity) - to determine protocol length if different length are possible.
|
||||
uint8_t flags; ///< See IRDATA_FLAGS_* definitions above
|
||||
uint32_t decodedRawData; ///< Up to 32 bit decoded raw data, to be used for send functions.
|
||||
#if defined(DECODE_DISTANCE)
|
||||
uint32_t decodedRawDataArray[RAW_DATA_ARRAY_SIZE]; ///< 32 bit decoded raw data, to be used for send function.
|
||||
#endif
|
||||
irparams_struct *rawDataPtr; ///< Pointer of the raw timing data to be decoded. Mainly the data buffer filled by receiving ISR.
|
||||
};
|
||||
|
||||
/**
|
||||
* Results returned from old decoders !!!deprecated!!!
|
||||
|
@ -171,8 +165,8 @@ struct decode_results {
|
|||
uint16_t magnitude; // deprecated, moved to decodedIRData.extra ///< Used by MagiQuest [16-bits]
|
||||
bool isRepeat; // deprecated, moved to decodedIRData.flags ///< True if repeat of value is detected
|
||||
|
||||
// next 3 values are copies of irparams values - see IRremoteint.h
|
||||
unsigned int *rawbuf; // deprecated, moved to decodedIRData.rawDataPtr->rawbuf ///< Raw intervals in 50uS ticks
|
||||
// next 3 values are copies of irparams_struct values - see above
|
||||
uint16_t *rawbuf; // deprecated, moved to decodedIRData.rawDataPtr->rawbuf ///< Raw intervals in 50uS ticks
|
||||
uint_fast8_t rawlen; // deprecated, moved to decodedIRData.rawDataPtr->rawlen ///< Number of records in rawbuf
|
||||
bool overflow; // deprecated, moved to decodedIRData.flags ///< true if IR raw code too long
|
||||
};
|
||||
|
@ -187,21 +181,32 @@ public:
|
|||
IRrecv(uint_fast8_t aReceivePin);
|
||||
IRrecv(uint_fast8_t aReceivePin, uint_fast8_t aFeedbackLEDPin);
|
||||
void setReceivePin(uint_fast8_t aReceivePinNumber);
|
||||
#if !defined(IR_REMOTE_DISABLE_RECEIVE_COMPLETE_CALLBACK)
|
||||
void registerReceiveCompleteCallback(void (*aReceiveCompleteCallbackFunction)(void));
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Stream like API
|
||||
*/
|
||||
void begin(uint_fast8_t aReceivePin, bool aEnableLEDFeedback = false, uint_fast8_t aFeedbackLEDPin =
|
||||
USE_DEFAULT_FEEDBACK_LED_PIN);
|
||||
void restartTimer();
|
||||
void start();
|
||||
void enableIRIn(); // alias for start
|
||||
void start(uint32_t aMicrosecondsToAddToGapCounter);
|
||||
void restartTimer(uint32_t aMicrosecondsToAddToGapCounter);
|
||||
void startWithTicksToAdd(uint16_t aTicksToAddToGapCounter);
|
||||
void restartTimerWithTicksToAdd(uint16_t aTicksToAddToGapCounter);
|
||||
void restartAfterSend();
|
||||
|
||||
void addTicksToInternalTickCounter(uint16_t aTicksToAddToInternalTickCounter);
|
||||
void addMicrosToInternalTickCounter(uint16_t aMicrosecondsToAddToInternalTickCounter);
|
||||
|
||||
bool available();
|
||||
IRData* read(); // returns decoded data
|
||||
// write is a method of class IRsend below
|
||||
// size_t write(IRData *aIRSendData, uint_fast8_t aNumberOfRepeats = NO_REPEATS);
|
||||
// size_t write(IRData *aIRSendData, int_fast8_t aNumberOfRepeats = NO_REPEATS);
|
||||
void stopTimer();
|
||||
void stop();
|
||||
void disableIRIn(); // alias for stop
|
||||
void end(); // alias for stop
|
||||
|
@ -220,44 +225,52 @@ public:
|
|||
void printIRResultMinimal(Print *aSerial);
|
||||
void printIRResultRawFormatted(Print *aSerial, bool aOutputMicrosecondsInsteadOfTicks = true);
|
||||
void printIRResultAsCVariables(Print *aSerial);
|
||||
uint32_t getTotalDurationOfRawData();
|
||||
|
||||
/*
|
||||
* Next 4 functions are also available as non member functions
|
||||
*/
|
||||
void printIRResultShort(Print *aSerial);
|
||||
bool printIRResultShort(Print *aSerial, bool aPrintRepeatGap = true, bool aCheckForRecordGapsMicros = true);
|
||||
void printDistanceWidthTimingInfo(Print *aSerial, DistanceWidthTimingInfoStruct *aDistanceWidthTimingInfo);
|
||||
void printIRSendUsage(Print *aSerial);
|
||||
#if defined(__AVR__)
|
||||
const __FlashStringHelper* getProtocolString();
|
||||
#else
|
||||
const char* getProtocolString();
|
||||
#endif
|
||||
static void printActiveIRProtocols(Print *aSerial);
|
||||
|
||||
void compensateAndPrintIRResultAsCArray(Print *aSerial, bool aOutputMicrosecondsInsteadOfTicks = true);
|
||||
void compensateAndPrintIRResultAsPronto(Print *aSerial, unsigned int frequency = 38000U);
|
||||
void compensateAndPrintIRResultAsPronto(Print *aSerial, uint16_t frequency = 38000U);
|
||||
|
||||
/*
|
||||
* Store the data for further processing
|
||||
*/
|
||||
void compensateAndStoreIRResultInArray(uint8_t *aArrayPtr);
|
||||
size_t compensateAndStorePronto(String *aString, unsigned int frequency = 38000U);
|
||||
size_t compensateAndStorePronto(String *aString, uint16_t frequency = 38000U);
|
||||
|
||||
/*
|
||||
* The main decoding functions used by the individual decoders
|
||||
*/
|
||||
bool decodePulseDistanceData(uint_fast8_t aNumberOfBits, uint_fast8_t aStartOffset, unsigned int aBitMarkMicros,
|
||||
unsigned int aOneSpaceMicros, unsigned int aZeroSpaceMicros, bool aMSBfirst);
|
||||
bool decodePulseDistanceWidthData(PulseDistanceWidthProtocolConstants *aProtocolConstants, uint_fast8_t aNumberOfBits,
|
||||
IRRawlenType aStartOffset = 3);
|
||||
|
||||
bool decodePulseWidthData(uint_fast8_t aNumberOfBits, uint_fast8_t aStartOffset, unsigned int aOneMarkMicros,
|
||||
unsigned int aZeroMarkMicros, unsigned int aBitSpaceMicros, bool aMSBfirst);
|
||||
bool decodePulseDistanceWidthData(uint_fast8_t aNumberOfBits, IRRawlenType aStartOffset, uint16_t aOneMarkMicros,
|
||||
uint16_t aZeroMarkMicros, uint16_t aOneSpaceMicros, uint16_t aZeroSpaceMicros, bool aMSBfirst);
|
||||
|
||||
bool decodeBiPhaseData(uint_fast8_t aNumberOfBits, uint_fast8_t aStartOffset, uint_fast8_t aStartClockCount,
|
||||
uint_fast8_t aValueOfSpaceToMarkTransition, unsigned int aBiphaseTimeUnit);
|
||||
bool decodeBiPhaseData(uint_fast8_t aNumberOfBits, IRRawlenType aStartOffset, uint_fast8_t aStartClockCount,
|
||||
uint_fast8_t aValueOfSpaceToMarkTransition, uint16_t aBiphaseTimeUnit);
|
||||
|
||||
void initBiphaselevel(uint_fast8_t aRCDecodeRawbuffOffset, unsigned int aBiphaseTimeUnit);
|
||||
void initBiphaselevel(uint_fast8_t aRCDecodeRawbuffOffset, uint16_t aBiphaseTimeUnit);
|
||||
uint_fast8_t getBiphaselevel();
|
||||
|
||||
/*
|
||||
* All standard (decode address + command) protocol decoders
|
||||
*/
|
||||
bool decodeBangOlufsen();
|
||||
bool decodeBoseWave();
|
||||
bool decodeDenon();
|
||||
bool decodeFAST();
|
||||
bool decodeJVC();
|
||||
bool decodeKaseikyo();
|
||||
bool decodeLegoPowerFunctions();
|
||||
|
@ -271,7 +284,7 @@ public:
|
|||
bool decodeSony();
|
||||
bool decodeWhynter();
|
||||
|
||||
bool decodeDistance();
|
||||
bool decodeDistanceWidth();
|
||||
|
||||
bool decodeHash();
|
||||
|
||||
|
@ -290,23 +303,28 @@ public:
|
|||
bool decodeSAMSUNG(decode_results *aResults);
|
||||
bool decodeHashOld(decode_results *aResults);
|
||||
|
||||
bool decode_old(decode_results *aResults);
|
||||
|
||||
bool decode(
|
||||
decode_results *aResults)
|
||||
__attribute__ ((deprecated ("Please use IrReceiver.decode() without a parameter and IrReceiver.decodedIRData.<fieldname> ."))); // deprecated
|
||||
__attribute__ ((deprecated ("Please use IrReceiver.decode() without a parameter and IrReceiver.decodedIRData.<fieldname> .")));
|
||||
|
||||
// for backward compatibility. Now in IRFeedbackLED.hpp
|
||||
void blink13(uint8_t aEnableLEDFeedback)
|
||||
__attribute__ ((deprecated ("Please use setLEDFeedback() or enableLEDFeedback() / disableLEDFeedback()."))); // deprecated
|
||||
__attribute__ ((deprecated ("Please use setLEDFeedback() or enableLEDFeedback() / disableLEDFeedback().")));
|
||||
|
||||
/*
|
||||
* Internal functions
|
||||
*/
|
||||
void initDecodedIRData();
|
||||
uint_fast8_t compare(unsigned int oldval, unsigned int newval);
|
||||
uint_fast8_t compare(uint16_t oldval, uint16_t newval);
|
||||
bool checkHeader(PulseDistanceWidthProtocolConstants *aProtocolConstants);
|
||||
void checkForRepeatSpaceTicksAndSetFlag(uint16_t aMaximumRepeatSpaceTicks);
|
||||
bool checkForRecordGapsMicros(Print *aSerial);
|
||||
|
||||
IRData decodedIRData; // New: decoded IR data for the application
|
||||
IRData decodedIRData; // Decoded IR data for the application
|
||||
|
||||
// Last decoded IR data for repeat detection
|
||||
// Last decoded IR data for repeat detection and parity for Denon autorepeat
|
||||
decode_type_t lastDecodedProtocol;
|
||||
uint32_t lastDecodedAddress;
|
||||
uint32_t lastDecodedCommand;
|
||||
|
@ -319,24 +337,19 @@ extern uint_fast8_t sBiphaseDecodeRawbuffOffset; //
|
|||
/*
|
||||
* Mark & Space matching functions
|
||||
*/
|
||||
bool matchTicks(unsigned int aMeasuredTicks, unsigned int aMatchValueMicros);
|
||||
bool matchMark(unsigned int aMeasuredTicks, unsigned int aMatchValueMicros);
|
||||
bool matchSpace(unsigned int aMeasuredTicks, unsigned int aMatchValueMicros);
|
||||
bool matchTicks(uint16_t aMeasuredTicks, uint16_t aMatchValueMicros);
|
||||
bool matchMark(uint16_t aMeasuredTicks, uint16_t aMatchValueMicros);
|
||||
bool matchSpace(uint16_t aMeasuredTicks, uint16_t aMatchValueMicros);
|
||||
|
||||
/*
|
||||
* Old function names
|
||||
*/
|
||||
bool MATCH(unsigned int measured, unsigned int desired);
|
||||
bool MATCH_MARK(unsigned int measured_ticks, unsigned int desired_us);
|
||||
bool MATCH_SPACE(unsigned int measured_ticks, unsigned int desired_us);
|
||||
bool MATCH(uint16_t measured, uint16_t desired);
|
||||
bool MATCH_MARK(uint16_t measured_ticks, uint16_t desired_us);
|
||||
bool MATCH_SPACE(uint16_t measured_ticks, uint16_t desired_us);
|
||||
|
||||
int getMarkExcessMicros();
|
||||
/*
|
||||
* Next 4 functions are also available as member functions
|
||||
*/
|
||||
void printIRResultShort(Print *aSerial, IRData *aIRDataPtr, bool aPrintGap);
|
||||
void printIRSendUsage(Print *aSerial, IRData *aIRDataPtr);
|
||||
const __FlashStringHelper* getProtocolString();
|
||||
|
||||
void printActiveIRProtocols(Print *aSerial);
|
||||
|
||||
/****************************************************
|
||||
|
@ -380,8 +393,8 @@ void setBlinkPin(uint8_t aFeedbackLEDPin) __attribute__ ((deprecated ("Please us
|
|||
#define TICKS_LOW(us) ((us)/67 ) // (us) / ((MICROS_PER_TICK:50 / LTOL:75 ) * 100)
|
||||
#define TICKS_HIGH(us) (((us)/40) + 1) // (us) / ((MICROS_PER_TICK:50 / UTOL:125) * 100) + 1
|
||||
#else
|
||||
#define TICKS_LOW(us) ((unsigned int ) ((long) (us) * LTOL / (MICROS_PER_TICK * 100) ))
|
||||
#define TICKS_HIGH(us) ((unsigned int ) ((long) (us) * UTOL / (MICROS_PER_TICK * 100) + 1))
|
||||
#define TICKS_LOW(us) ((uint16_t ) ((long) (us) * LTOL / (MICROS_PER_TICK * 100) ))
|
||||
#define TICKS_HIGH(us) ((uint16_t ) ((long) (us) * UTOL / (MICROS_PER_TICK * 100) + 1))
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
@ -389,6 +402,11 @@ void setBlinkPin(uint8_t aFeedbackLEDPin) __attribute__ ((deprecated ("Please us
|
|||
*/
|
||||
extern IRrecv IrReceiver;
|
||||
|
||||
/*
|
||||
* The receiver interrupt handler for timer interrupt
|
||||
*/
|
||||
void IRReceiveTimerInterruptHandler();
|
||||
|
||||
/****************************************************
|
||||
* SENDING
|
||||
****************************************************/
|
||||
|
@ -397,8 +415,6 @@ extern IRrecv IrReceiver;
|
|||
* Just for better readability of code
|
||||
*/
|
||||
#define NO_REPEATS 0
|
||||
#define SEND_STOP_BIT true
|
||||
#define SEND_NO_STOP_BIT false
|
||||
#define SEND_REPEAT_COMMAND true ///< used for e.g. NEC, where a repeat is different from just repeating the data.
|
||||
|
||||
/**
|
||||
|
@ -409,37 +425,68 @@ public:
|
|||
IRsend();
|
||||
|
||||
/*
|
||||
* IR_SEND_PIN is defined
|
||||
* IR_SEND_PIN is defined or fixed by timer, value of IR_SEND_PIN is then "DeterminedByTimer"
|
||||
*/
|
||||
#if defined(IR_SEND_PIN)
|
||||
void begin();
|
||||
void begin(bool aEnableLEDFeedback, uint_fast8_t aFeedbackLEDPin = USE_DEFAULT_FEEDBACK_LED_PIN);
|
||||
// The default parameter allowed to specify IrSender.begin(7); without errors, if IR_SEND_PIN was defined. But the semantics is not the one the user expect.
|
||||
void begin(bool aEnableLEDFeedback, uint_fast8_t aFeedbackLEDPin); // 4.3.1 Removed default value USE_DEFAULT_FEEDBACK_LED_PIN for last parameter
|
||||
// The next function is a dummy to avoid acceptance of pre 4.3 calls to begin(DISABLE_LED_FEEDBACK);
|
||||
void begin(uint8_t aSendPin)
|
||||
# if !defined (DOXYGEN)
|
||||
__attribute__ ((deprecated ("Error: IR_SEND_PIN is still defined, therefore the function begin(aSendPin) is NOT available. You must disable '#define IR_SEND_PIN' to enable this function.")));
|
||||
# endif
|
||||
|
||||
// The next function is a dummy to avoid acceptance of pre 4.0 calls to begin(IR_SEND_PIN, DISABLE_LED_FEEDBACK);
|
||||
void begin(uint_fast8_t aSendPin, bool aEnableLEDFeedback)
|
||||
# if !defined (DOXYGEN)
|
||||
__attribute__ ((deprecated ("You must use begin() and enableLEDFeedback() or disableLEDFeedback() since version 4.3.")));
|
||||
# endif
|
||||
#else
|
||||
IRsend(uint_fast8_t aSendPin);
|
||||
void begin(uint_fast8_t aSendPin);
|
||||
void setSendPin(uint_fast8_t aSendPin); // required if we use IRsend() as constructor
|
||||
// Since 4.0 guarded and without default parameter
|
||||
void begin(uint_fast8_t aSendPin, bool aEnableLEDFeedback, uint_fast8_t aFeedbackLEDPin); // aFeedbackLEDPin can be USE_DEFAULT_FEEDBACK_LED_PIN
|
||||
#endif
|
||||
|
||||
// Not guarded for backward compatibility
|
||||
void begin(uint_fast8_t aSendPin, bool aEnableLEDFeedback, uint_fast8_t aFeedbackLEDPin = USE_DEFAULT_FEEDBACK_LED_PIN);
|
||||
|
||||
size_t write(IRData *aIRSendData, uint_fast8_t aNumberOfRepeats = NO_REPEATS);
|
||||
size_t write(IRData *aIRSendData, int_fast8_t aNumberOfRepeats = NO_REPEATS);
|
||||
size_t write(decode_type_t aProtocol, uint16_t aAddress, uint16_t aCommand, int_fast8_t aNumberOfRepeats = NO_REPEATS);
|
||||
|
||||
void enableIROut(uint_fast8_t aFrequencyKHz);
|
||||
#if defined(SEND_PWM_BY_TIMER)
|
||||
void enableHighFrequencyIROut(uint_fast16_t aFrequencyKHz); // Used for Bang&Olufsen
|
||||
#endif
|
||||
|
||||
void sendPulseDistanceWidthFromArray(uint_fast8_t aFrequencyKHz, unsigned int aHeaderMarkMicros, unsigned int aHeaderSpaceMicros, unsigned int aOneMarkMicros,
|
||||
unsigned int aOneSpaceMicros, unsigned int aZeroMarkMicros, unsigned int aZeroSpaceMicros,
|
||||
uint32_t *aDecodedRawDataArray, unsigned int aNumberOfBits, bool aMSBfirst, unsigned int aRepeatPeriodMillis = 110,
|
||||
uint_fast8_t aNumberOfRepeats = 0);
|
||||
void sendPulseDistanceWidth(uint_fast8_t aFrequencyKHz, unsigned int aHeaderMarkMicros, unsigned int aHeaderSpaceMicros, unsigned int aOneMarkMicros, unsigned int aOneSpaceMicros, unsigned int aZeroMarkMicros,
|
||||
unsigned int aZeroSpaceMicros, uint32_t aData, uint_fast8_t aNumberOfBits, bool aMSBfirst, bool aSendStopBit, unsigned int aRepeatPeriodMillis = 110,
|
||||
uint_fast8_t aNumberOfRepeats = 0);
|
||||
void sendPulseDistanceWidthData(unsigned int aOneMarkMicros, unsigned int aOneSpaceMicros, unsigned int aZeroMarkMicros,
|
||||
unsigned int aZeroSpaceMicros, uint32_t aData, uint_fast8_t aNumberOfBits, bool aMSBfirst, bool aSendStopBit = false);
|
||||
void sendBiphaseData(unsigned int aBiphaseTimeUnit, uint32_t aData, uint_fast8_t aNumberOfBits);
|
||||
void sendPulseDistanceWidthFromArray(uint_fast8_t aFrequencyKHz, uint16_t aHeaderMarkMicros, uint16_t aHeaderSpaceMicros,
|
||||
uint16_t aOneMarkMicros, uint16_t aOneSpaceMicros, uint16_t aZeroMarkMicros, uint16_t aZeroSpaceMicros,
|
||||
IRRawDataType *aDecodedRawDataArray, uint16_t aNumberOfBits, uint8_t aFlags, uint16_t aRepeatPeriodMillis,
|
||||
int_fast8_t aNumberOfRepeats);
|
||||
void sendPulseDistanceWidthFromArray(PulseDistanceWidthProtocolConstants *aProtocolConstants,
|
||||
IRRawDataType *aDecodedRawDataArray, uint16_t aNumberOfBits, int_fast8_t aNumberOfRepeats);
|
||||
void sendPulseDistanceWidthFromArray(uint_fast8_t aFrequencyKHz, DistanceWidthTimingInfoStruct *aDistanceWidthTimingInfo,
|
||||
IRRawDataType *aDecodedRawDataArray, uint16_t aNumberOfBits, uint8_t aFlags, uint16_t aRepeatPeriodMillis,
|
||||
int_fast8_t aNumberOfRepeats);
|
||||
|
||||
void mark(unsigned int aMarkMicros);
|
||||
void space(unsigned int aSpaceMicros);
|
||||
void sendPulseDistanceWidth(PulseDistanceWidthProtocolConstants *aProtocolConstants, IRRawDataType aData,
|
||||
uint_fast8_t aNumberOfBits, int_fast8_t aNumberOfRepeats);
|
||||
void sendPulseDistanceWidthData(PulseDistanceWidthProtocolConstants *aProtocolConstants, IRRawDataType aData,
|
||||
uint_fast8_t aNumberOfBits);
|
||||
void sendPulseDistanceWidth(uint_fast8_t aFrequencyKHz, uint16_t aHeaderMarkMicros, uint16_t aHeaderSpaceMicros,
|
||||
uint16_t aOneMarkMicros, uint16_t aOneSpaceMicros, uint16_t aZeroMarkMicros, uint16_t aZeroSpaceMicros,
|
||||
IRRawDataType aData, uint_fast8_t aNumberOfBits, uint8_t aFlags, uint16_t aRepeatPeriodMillis,
|
||||
int_fast8_t aNumberOfRepeats, void (*aSpecialSendRepeatFunction)() = NULL);
|
||||
void sendPulseDistanceWidth(uint_fast8_t aFrequencyKHz, uint16_t aHeaderMarkMicros, uint16_t aHeaderSpaceMicros,
|
||||
uint16_t aOneMarkMicros, uint16_t aOneSpaceMicros, uint16_t aZeroMarkMicros, uint16_t aZeroSpaceMicros,
|
||||
IRRawDataType aData, uint_fast8_t aNumberOfBits, bool aMSBFirst, bool aSendStopBit, uint16_t aRepeatPeriodMillis,
|
||||
int_fast8_t aNumberOfRepeats, void (*aSpecialSendRepeatFunction)() = NULL)
|
||||
__attribute__ ((deprecated ("Since version 4.1.0 parameter aSendStopBit is not longer required.")));
|
||||
void sendPulseDistanceWidthData(uint16_t aOneMarkMicros, uint16_t aOneSpaceMicros, uint16_t aZeroMarkMicros,
|
||||
uint16_t aZeroSpaceMicros, IRRawDataType aData, uint_fast8_t aNumberOfBits, uint8_t aFlags);
|
||||
void sendBiphaseData(uint16_t aBiphaseTimeUnit, uint32_t aData, uint_fast8_t aNumberOfBits);
|
||||
|
||||
void mark(uint16_t aMarkMicros);
|
||||
static void space(uint16_t aSpaceMicros);
|
||||
void IRLedOff();
|
||||
|
||||
// 8 Bit array
|
||||
|
@ -453,66 +500,80 @@ public:
|
|||
/*
|
||||
* New send functions
|
||||
*/
|
||||
void sendBoseWave(uint8_t aCommand, uint_fast8_t aNumberOfRepeats = NO_REPEATS);
|
||||
void sendDenon(uint8_t aAddress, uint8_t aCommand, uint_fast8_t aNumberOfRepeats, bool aSendSharp = false);
|
||||
void sendDenonRaw(uint16_t aRawData, uint_fast8_t aNumberOfRepeats = 0)
|
||||
void sendBangOlufsen(uint16_t aHeader, uint8_t aData, int_fast8_t aNumberOfRepeats = NO_REPEATS,
|
||||
int8_t aNumberOfHeaderBits = 8);
|
||||
void sendBangOlufsenDataLink(uint32_t aHeader, uint8_t aData, int_fast8_t aNumberOfRepeats = NO_REPEATS,
|
||||
int8_t aNumberOfHeaderBits = 8);
|
||||
void sendBangOlufsenRaw(uint32_t aRawData, int_fast8_t aBits, bool aBackToBack = false);
|
||||
void sendBangOlufsenRawDataLink(uint64_t aRawData, int_fast8_t aBits, bool aBackToBack = false,
|
||||
bool aUseDatalinkTiming = false);
|
||||
void sendBoseWave(uint8_t aCommand, int_fast8_t aNumberOfRepeats = NO_REPEATS);
|
||||
void sendDenon(uint8_t aAddress, uint8_t aCommand, int_fast8_t aNumberOfRepeats, bool aSendSharp = false);
|
||||
void sendDenonRaw(uint16_t aRawData, int_fast8_t aNumberOfRepeats = NO_REPEATS)
|
||||
#if !defined (DOXYGEN)
|
||||
__attribute__ ((deprecated ("Please use sendDenon(aAddress, aCommand, aNumberOfRepeats).")));
|
||||
#endif
|
||||
void sendJVC(uint8_t aAddress, uint8_t aCommand, uint_fast8_t aNumberOfRepeats);
|
||||
void sendFAST(uint8_t aCommand, int_fast8_t aNumberOfRepeats);
|
||||
void sendJVC(uint8_t aAddress, uint8_t aCommand, int_fast8_t aNumberOfRepeats);
|
||||
|
||||
void sendLGRepeat(bool aUseLG2Protocol = false);
|
||||
void sendLG(uint8_t aAddress, uint16_t aCommand, uint_fast8_t aNumberOfRepeats, bool aSendOnlySpecialLGRepeat = false, bool aUseLG2Protocol =
|
||||
false);
|
||||
void sendLG2(uint8_t aAddress, uint16_t aCommand, uint_fast8_t aNumberOfRepeats, bool aSendOnlySpecialLGRepeat = false);
|
||||
void sendLGRaw(uint32_t aRawData, uint_fast8_t aNumberOfRepeats = 0, bool aSendOnlySpecialLGRepeat = false, bool aUseLG2Protocol = false);
|
||||
void sendLG2Repeat();
|
||||
uint32_t computeLGRawDataAndChecksum(uint8_t aAddress, uint16_t aCommand);
|
||||
void sendLG(uint8_t aAddress, uint16_t aCommand, int_fast8_t aNumberOfRepeats);
|
||||
void sendLG2(uint8_t aAddress, uint16_t aCommand, int_fast8_t aNumberOfRepeats);
|
||||
void sendLGRaw(uint32_t aRawData, int_fast8_t aNumberOfRepeats = NO_REPEATS);
|
||||
|
||||
void sendNECRepeat();
|
||||
void sendNEC(uint16_t aAddress, uint8_t aCommand, uint_fast8_t aNumberOfRepeats, bool aSendOnlySpecialNECRepeat = false);
|
||||
void sendNEC2(uint16_t aAddress, uint8_t aCommand, uint_fast8_t aNumberOfRepeats);
|
||||
void sendNECRaw(uint32_t aRawData, uint_fast8_t aNumberOfRepeats = 0, bool aSendOnlySpecialNECRepeat = false);
|
||||
uint32_t computeNECRawDataAndChecksum(uint16_t aAddress, uint16_t aCommand);
|
||||
void sendNEC(uint16_t aAddress, uint8_t aCommand, int_fast8_t aNumberOfRepeats);
|
||||
void sendNEC2(uint16_t aAddress, uint8_t aCommand, int_fast8_t aNumberOfRepeats);
|
||||
void sendNECRaw(uint32_t aRawData, int_fast8_t aNumberOfRepeats = NO_REPEATS);
|
||||
// NEC variants
|
||||
void sendOnkyo(uint16_t aAddress, uint16_t aCommand, uint_fast8_t aNumberOfRepeats, bool aSendOnlySpecialNECRepeat = false);
|
||||
void sendApple(uint8_t aAddress, uint8_t aCommand, uint_fast8_t aNumberOfRepeats, bool aSendOnlySpecialNECRepeat = false);
|
||||
void sendOnkyo(uint16_t aAddress, uint16_t aCommand, int_fast8_t aNumberOfRepeats);
|
||||
void sendApple(uint8_t aAddress, uint8_t aCommand, int_fast8_t aNumberOfRepeats);
|
||||
|
||||
void sendKaseikyo(uint16_t aAddress, uint8_t aData, uint_fast8_t aNumberOfRepeats, uint16_t aVendorCode); // LSB first
|
||||
void sendPanasonic(uint16_t aAddress, uint8_t aData, uint_fast8_t aNumberOfRepeats); // LSB first
|
||||
void sendKaseikyo_Denon(uint16_t aAddress, uint8_t aData, uint_fast8_t aNumberOfRepeats); // LSB first
|
||||
void sendKaseikyo_Mitsubishi(uint16_t aAddress, uint8_t aData, uint_fast8_t aNumberOfRepeats); // LSB first
|
||||
void sendKaseikyo_Sharp(uint16_t aAddress, uint8_t aData, uint_fast8_t aNumberOfRepeats); // LSB first
|
||||
void sendKaseikyo_JVC(uint16_t aAddress, uint8_t aData, uint_fast8_t aNumberOfRepeats); // LSB first
|
||||
void sendKaseikyo(uint16_t aAddress, uint8_t aData, int_fast8_t aNumberOfRepeats, uint16_t aVendorCode); // LSB first
|
||||
void sendPanasonic(uint16_t aAddress, uint8_t aData, int_fast8_t aNumberOfRepeats); // LSB first
|
||||
void sendKaseikyo_Denon(uint16_t aAddress, uint8_t aData, int_fast8_t aNumberOfRepeats); // LSB first
|
||||
void sendKaseikyo_Mitsubishi(uint16_t aAddress, uint8_t aData, int_fast8_t aNumberOfRepeats); // LSB first
|
||||
void sendKaseikyo_Sharp(uint16_t aAddress, uint8_t aData, int_fast8_t aNumberOfRepeats); // LSB first
|
||||
void sendKaseikyo_JVC(uint16_t aAddress, uint8_t aData, int_fast8_t aNumberOfRepeats); // LSB first
|
||||
|
||||
void sendRC5(uint8_t aAddress, uint8_t aCommand, uint_fast8_t aNumberOfRepeats, bool aEnableAutomaticToggle = true);
|
||||
void sendRC6(uint8_t aAddress, uint8_t aCommand, uint_fast8_t aNumberOfRepeats, bool aEnableAutomaticToggle = true);
|
||||
void sendRC5(uint8_t aAddress, uint8_t aCommand, int_fast8_t aNumberOfRepeats, bool aEnableAutomaticToggle = true);
|
||||
void sendRC6(uint8_t aAddress, uint8_t aCommand, int_fast8_t aNumberOfRepeats, bool aEnableAutomaticToggle = true);
|
||||
void sendSamsungLGRepeat();
|
||||
void sendSamsung(uint16_t aAddress, uint16_t aCommand, uint_fast8_t aNumberOfRepeats);
|
||||
void sendSamsungLG(uint16_t aAddress, uint16_t aCommand, uint_fast8_t aNumberOfRepeats, bool aSendOnlySpecialSamsungRepeat = false);
|
||||
void sendSharp(uint8_t aAddress, uint8_t aCommand, uint_fast8_t aNumberOfRepeats); // redirected to sendDenon
|
||||
void sendSony(uint16_t aAddress, uint8_t aCommand, uint_fast8_t aNumberOfRepeats, uint8_t numberOfBits = SIRCS_12_PROTOCOL);
|
||||
void sendSamsung(uint16_t aAddress, uint16_t aCommand, int_fast8_t aNumberOfRepeats);
|
||||
void sendSamsung16BitAddressAnd8BitCommand(uint16_t aAddress, uint8_t aCommand, int_fast8_t aNumberOfRepeats);
|
||||
void sendSamsung16BitAddressAndCommand(uint16_t aAddress, uint16_t aCommand, int_fast8_t aNumberOfRepeats);
|
||||
void sendSamsung48(uint16_t aAddress, uint32_t aCommand, int_fast8_t aNumberOfRepeats);
|
||||
void sendSamsungLG(uint16_t aAddress, uint16_t aCommand, int_fast8_t aNumberOfRepeats);
|
||||
void sendSharp(uint8_t aAddress, uint8_t aCommand, int_fast8_t aNumberOfRepeats); // redirected to sendDenon
|
||||
void sendSony(uint16_t aAddress, uint8_t aCommand, int_fast8_t aNumberOfRepeats, uint8_t numberOfBits = 12); // SIRCS_12_PROTOCOL
|
||||
|
||||
void sendLegoPowerFunctions(uint8_t aChannel, uint8_t tCommand, uint8_t aMode, bool aDoSend5Times = true);
|
||||
void sendLegoPowerFunctions(uint16_t aRawData, bool aDoSend5Times = true);
|
||||
void sendLegoPowerFunctions(uint16_t aRawData, uint8_t aChannel, bool aDoSend5Times = true);
|
||||
|
||||
void sendMagiQuest(uint32_t wand_id, uint16_t magnitude);
|
||||
void sendMagiQuest(uint32_t aWandId, uint16_t aMagnitude);
|
||||
|
||||
void sendPronto(const __FlashStringHelper *str, uint_fast8_t aNumberOfRepeats = NO_REPEATS);
|
||||
void sendPronto(const char *prontoHexString, uint_fast8_t aNumberOfRepeats = NO_REPEATS);
|
||||
void sendPronto(const uint16_t *data, unsigned int length, uint_fast8_t aNumberOfRepeats = NO_REPEATS);
|
||||
void sendPronto(const __FlashStringHelper *str, int_fast8_t aNumberOfRepeats = NO_REPEATS);
|
||||
void sendPronto(const char *prontoHexString, int_fast8_t aNumberOfRepeats = NO_REPEATS);
|
||||
void sendPronto(const uint16_t *data, uint16_t length, int_fast8_t aNumberOfRepeats = NO_REPEATS);
|
||||
|
||||
#if defined(__AVR__)
|
||||
void sendPronto_PF(uint_farptr_t str, uint_fast8_t aNumberOfRepeats = NO_REPEATS);
|
||||
void sendPronto_P(const char *str, uint_fast8_t aNumberOfRepeats);
|
||||
void sendPronto_PF(uint_farptr_t str, int_fast8_t aNumberOfRepeats = NO_REPEATS);
|
||||
void sendPronto_P(const char *str, int_fast8_t aNumberOfRepeats);
|
||||
#endif
|
||||
|
||||
// Template protocol :-)
|
||||
void sendShuzu(uint16_t aAddress, uint8_t aCommand, uint_fast8_t aNumberOfRepeats);
|
||||
void sendShuzu(uint16_t aAddress, uint8_t aCommand, int_fast8_t aNumberOfRepeats);
|
||||
|
||||
/*
|
||||
* OLD send functions
|
||||
*/
|
||||
void sendDenon(unsigned long data, int nbits);
|
||||
void sendDISH(unsigned long data, int nbits);
|
||||
void sendDenon(unsigned long data,
|
||||
int nbits)
|
||||
__attribute__ ((deprecated ("The function sendDenon(data, nbits) is deprecated and may not work as expected! Use sendDenonRaw(data, NumberOfRepeats) or better sendDenon(Address, Command, NumberOfRepeats).")));
|
||||
void sendDish(uint16_t aData);
|
||||
void sendJVC(unsigned long data, int nbits,
|
||||
bool repeat)
|
||||
__attribute__ ((deprecated ("This old function sends MSB first! Please use sendJVC(aAddress, aCommand, aNumberOfRepeats)."))) {
|
||||
|
@ -520,39 +581,43 @@ public:
|
|||
}
|
||||
void sendJVCMSB(unsigned long data, int nbits, bool repeat = false);
|
||||
|
||||
void sendLG(unsigned long data, int nbits);
|
||||
void sendLG(unsigned long data,
|
||||
int nbits)
|
||||
__attribute__ ((deprecated ("The function sendLG(data, nbits) is deprecated and may not work as expected! Use sendLGRaw(data, NumberOfRepeats) or better sendLG(Address, Command, NumberOfRepeats).")));
|
||||
|
||||
void sendNEC(uint32_t aRawData,
|
||||
uint8_t nbits)
|
||||
__attribute__ ((deprecated ("This old function sends MSB first! Please use sendNEC(aAddress, aCommand, aNumberOfRepeats)."))) {
|
||||
__attribute__ ((deprecated ("This old function sends MSB first! Please use sendNECMSB() or sendNEC(aAddress, aCommand, aNumberOfRepeats)."))) {
|
||||
sendNECMSB(aRawData, nbits);
|
||||
}
|
||||
void sendNECMSB(uint32_t data, uint8_t nbits, bool repeat = false);
|
||||
void sendPanasonic(uint16_t aAddress,
|
||||
uint32_t aData)
|
||||
__attribute__ ((deprecated ("This old function sends MSB first! Please use sendPanasonic(aAddress, aCommand, aNumberOfRepeats).")));
|
||||
void sendRC5(uint32_t data, uint8_t nbits);
|
||||
void sendRC5ext(uint8_t addr, uint8_t cmd, bool toggle);
|
||||
void sendRC6(uint32_t data, uint8_t nbits);
|
||||
void sendRC6(uint64_t data, uint8_t nbits);
|
||||
void sendRC6Raw(uint32_t data, uint8_t nbits);
|
||||
void sendRC6(uint32_t data, uint8_t nbits) __attribute__ ((deprecated ("Please use sendRC6Raw().")));
|
||||
void sendRC6Raw(uint64_t data, uint8_t nbits);
|
||||
void sendRC6(uint64_t data, uint8_t nbits) __attribute__ ((deprecated ("Please use sendRC6Raw().")));
|
||||
;
|
||||
void sendSharpRaw(unsigned long data, int nbits);
|
||||
void sendSharp(unsigned int address, unsigned int command);
|
||||
void sendSharp(uint16_t address, uint16_t command);
|
||||
void sendSAMSUNG(unsigned long data, int nbits);
|
||||
__attribute__ ((deprecated ("This old function sends MSB first! Please use sendSamsung().")));
|
||||
void sendSamsungMSB(unsigned long data, int nbits);
|
||||
void sendSonyMSB(unsigned long data, int nbits);
|
||||
void sendSony(unsigned long data,
|
||||
int nbits)
|
||||
__attribute__ ((deprecated ("This old function sends MSB first! Please use sendSony(aAddress, aCommand, aNumberOfRepeats).")));
|
||||
;
|
||||
void sendWhynter(unsigned long data, int nbits);
|
||||
void sendWhynter(uint32_t aData, uint8_t aNumberOfBitsToSend);
|
||||
|
||||
#if !defined(IR_SEND_PIN)
|
||||
uint8_t sendPin;
|
||||
#endif
|
||||
unsigned int periodTimeMicros;
|
||||
unsigned int periodOnTimeMicros; // compensated with PULSE_CORRECTION_NANOS for duration of digitalWrite. Around 8 microseconds for 38 kHz.
|
||||
unsigned int getPulseCorrectionNanos();
|
||||
uint16_t periodTimeMicros;
|
||||
uint16_t periodOnTimeMicros; // compensated with PULSE_CORRECTION_NANOS for duration of digitalWrite. Around 8 microseconds for 38 kHz.
|
||||
uint16_t getPulseCorrectionNanos();
|
||||
|
||||
void customDelayMicroseconds(unsigned long aMicroseconds);
|
||||
static void customDelayMicroseconds(unsigned long aMicroseconds);
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -560,4 +625,8 @@ public:
|
|||
*/
|
||||
extern IRsend IrSender;
|
||||
|
||||
void sendNECSpecialRepeat();
|
||||
void sendLG2SpecialRepeat();
|
||||
void sendSamsungLGSpecialRepeat();
|
||||
|
||||
#endif // _IR_REMOTE_INT_H
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* LongUnion.h
|
||||
*
|
||||
* Copyright (C) 2020 Armin Joachimsmeyer
|
||||
* Copyright (C) 2020-2022 Armin Joachimsmeyer
|
||||
* Email: armin.joachimsmeyer@gmail.com
|
||||
*
|
||||
* This file is part of Arduino-Utils https://github.com/ArminJo/Arduino-Utils.
|
||||
|
@ -13,15 +13,15 @@
|
|||
*
|
||||
* 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.
|
||||
* 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>.
|
||||
*
|
||||
*/
|
||||
|
||||
#if !defined(_WORD_UNION_H) || !defined(_LONG_UNION_H)
|
||||
#if !defined(_WORD_UNION_H) || !defined(_LONG_UNION_H) || !defined(_LONG_LONG_UNION_H)
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
|
@ -30,6 +30,8 @@
|
|||
/**
|
||||
* Union to specify parts / manifestations of a 16 bit Word without casts and shifts.
|
||||
* It also supports the compiler generating small code.
|
||||
* Usage: WordUnion tWord;
|
||||
* tWord.UByte.HighByte = 0x12;
|
||||
*/
|
||||
union WordUnion {
|
||||
struct {
|
||||
|
@ -40,7 +42,7 @@ union WordUnion {
|
|||
int8_t LowByte;
|
||||
int8_t HighByte;
|
||||
} Byte;
|
||||
uint8_t UBytes[2];
|
||||
uint8_t UBytes[2]; // UBytes[0] is LowByte
|
||||
int8_t Bytes[2];
|
||||
uint16_t UWord;
|
||||
int16_t Word;
|
||||
|
@ -67,11 +69,17 @@ union LongUnion {
|
|||
int8_t MidHighByte;
|
||||
int8_t HighByte;
|
||||
} Byte;
|
||||
/* Does not work for STM32
|
||||
struct {
|
||||
uint8_t LowByte;
|
||||
WordUnion MidWord;
|
||||
uint16_t MidWord;
|
||||
uint8_t HighByte;
|
||||
} ByteWord;
|
||||
} UByteWord;
|
||||
*/
|
||||
struct {
|
||||
uint16_t LowWord;
|
||||
uint16_t HighWord;
|
||||
} UWord;
|
||||
struct {
|
||||
int16_t LowWord;
|
||||
int16_t HighWord;
|
||||
|
@ -80,17 +88,66 @@ union LongUnion {
|
|||
WordUnion LowWord;
|
||||
WordUnion HighWord;
|
||||
} WordUnion;
|
||||
struct {
|
||||
uint16_t LowWord;
|
||||
uint16_t HighWord;
|
||||
} UWord;
|
||||
uint8_t UBytes[4]; // seems to have the same code size as using struct UByte
|
||||
int8_t Bytes[4];
|
||||
int8_t Bytes[4]; // Bytes[0] is LowByte
|
||||
uint16_t UWords[2];
|
||||
int16_t Words[2];
|
||||
uint32_t ULong;
|
||||
int32_t Long;
|
||||
float Float;
|
||||
};
|
||||
#endif // _LONG_UNION_H
|
||||
|
||||
#endif // !defined(_WORD_UNION_H) || !defined(_LONG_UNION_H)
|
||||
#ifndef _LONG_LONG_UNION_H
|
||||
#define _LONG_LONG_UNION_H
|
||||
/**
|
||||
* Union to specify parts / manifestations of a 64 bit LongLong without casts and shifts.
|
||||
* It also supports the compiler generating small code.
|
||||
*/
|
||||
union LongLongUnion {
|
||||
struct {
|
||||
uint16_t LowWord;
|
||||
uint16_t MidLowWord;
|
||||
uint16_t MidHighWord;
|
||||
uint16_t HighWord;
|
||||
} UWord;
|
||||
struct {
|
||||
int16_t LowWord;
|
||||
int16_t MidLowWord;
|
||||
int16_t MidHighWord;
|
||||
int16_t HighWord;
|
||||
} Word;
|
||||
struct {
|
||||
WordUnion LowWord;
|
||||
WordUnion MidLowWord;
|
||||
WordUnion MidHighWord;
|
||||
WordUnion HighWord;
|
||||
} WordUnion;
|
||||
struct {
|
||||
uint32_t LowLong;
|
||||
uint32_t HighLong;
|
||||
} ULong;
|
||||
struct {
|
||||
int32_t LowLong;
|
||||
int32_t HighLong;
|
||||
} Long;
|
||||
struct {
|
||||
LongUnion LowLong;
|
||||
LongUnion HighLong;
|
||||
} LongUnion;
|
||||
uint8_t UBytes[8]; // seems to have the same code size as using struct UByte
|
||||
int8_t Bytes[8];
|
||||
uint16_t UWords[4];
|
||||
int16_t Words[4];
|
||||
uint64_t ULongLong;
|
||||
int64_t LongLong;
|
||||
#if __DBL_MANT_DIG__== 24
|
||||
float Floats[2]; // 32 bit double, as for AVR
|
||||
#else
|
||||
// 64 bit double
|
||||
double Double;
|
||||
#endif
|
||||
};
|
||||
#endif // _LONG_LONG_UNION_H
|
||||
|
||||
#endif // !defined(_WORD_UNION_H) || !defined(_LONG_UNION_H) || !defined(_LONG_LONG_UNION_H)
|
||||
|
|
|
@ -0,0 +1,283 @@
|
|||
/*
|
||||
* TinyIR.h
|
||||
*
|
||||
*
|
||||
* Copyright (C) 2021-2023 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.
|
||||
*
|
||||
* TinyIRReceiver 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 _TINY_IR_H
|
||||
#define _TINY_IR_H
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
#include "LongUnion.h"
|
||||
|
||||
/** \addtogroup TinyReceiver Minimal receiver for NEC and FAST protocol
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define VERSION_TINYIR "2.1.0"
|
||||
#define VERSION_TINYIR_MAJOR 2
|
||||
#define VERSION_TINYIR_MINOR 1
|
||||
#define VERSION_TINYIR_PATCH 0
|
||||
// The change log is at the bottom of the file
|
||||
|
||||
/**
|
||||
* Timing for NEC protocol
|
||||
*
|
||||
* see: https://www.sbprojects.net/knowledge/ir/nec.php
|
||||
* LSB first, 1 start bit + 16 bit address + 8 bit data + 8 bit inverted data + 1 stop bit.
|
||||
*/
|
||||
#if !defined(NEC_ADDRESS_BITS)
|
||||
#define NEC_ADDRESS_BITS 16 // 16 bit address or 8 bit address and 8 bit inverted address
|
||||
#define NEC_COMMAND_BITS 16 // Command and inverted command
|
||||
#define NEC_BITS (NEC_ADDRESS_BITS + NEC_COMMAND_BITS)
|
||||
|
||||
#define NEC_UNIT 560
|
||||
|
||||
#define NEC_HEADER_MARK (16 * NEC_UNIT) // 9000
|
||||
#define NEC_HEADER_SPACE (8 * NEC_UNIT) // 4500
|
||||
|
||||
#define NEC_BIT_MARK NEC_UNIT
|
||||
#define NEC_ONE_SPACE (3 * NEC_UNIT) // 1690
|
||||
#define NEC_ZERO_SPACE NEC_UNIT
|
||||
|
||||
#define NEC_REPEAT_HEADER_SPACE (4 * NEC_UNIT) // 2250
|
||||
|
||||
#define NEC_REPEAT_PERIOD 110000 // Commands are repeated every 110 ms (measured from start to start) for as long as the key on the remote control is held down.
|
||||
#define NEC_MINIMAL_DURATION 49900 // NEC_HEADER_MARK + NEC_HEADER_SPACE + 32 * 2 * NEC_UNIT + NEC_UNIT // 2.5 because we assume more zeros than ones
|
||||
#define NEC_MAXIMUM_REPEAT_DISTANCE (NEC_REPEAT_PERIOD - NEC_MINIMAL_DURATION + 10000) // 70 ms
|
||||
#endif
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
/*
|
||||
Protocol=FAST Address=0x0 Command=0x76 Raw-Data=0x8976 16 bits LSB first
|
||||
+2100,-1050
|
||||
+ 550,- 500 + 550,-1550 + 550,-1550 + 550,- 500
|
||||
+ 550,-1550 + 550,-1550 + 550,-1550 + 550,- 500
|
||||
+ 550,-1550 + 550,- 500 + 550,- 500 + 550,-1550
|
||||
+ 550,- 500 + 550,- 500 + 550,- 500 + 550,-1550
|
||||
+ 550
|
||||
Sum: 28900
|
||||
*/
|
||||
#define FAST_KHZ 38
|
||||
#define FAST_ADDRESS_BITS 0 // No address
|
||||
#define FAST_COMMAND_BITS 16 // Command and inverted command (parity)
|
||||
#define FAST_BITS (FAST_ADDRESS_BITS + FAST_COMMAND_BITS)
|
||||
|
||||
#define FAST_UNIT 526 // 20 periods of 38 kHz (526.315789)
|
||||
|
||||
#define FAST_BIT_MARK FAST_UNIT
|
||||
#define FAST_ONE_SPACE (3 * FAST_UNIT) // 1578 -> bit period = 2104
|
||||
#define FAST_ZERO_SPACE FAST_UNIT // 526 -> bit period = 1052
|
||||
|
||||
#define FAST_HEADER_MARK (4 * FAST_UNIT) // 2104
|
||||
#define FAST_HEADER_SPACE (2 * FAST_UNIT) // 1052
|
||||
|
||||
#define FAST_REPEAT_PERIOD 50000 // Commands are repeated every 50 ms (measured from start to start) for as long as the key on the remote control is held down.
|
||||
#define FAST_REPEAT_DISTANCE (FAST_REPEAT_PERIOD - (55 * FAST_UNIT)) // 19 ms
|
||||
#define FAST_MAXIMUM_REPEAT_DISTANCE (FAST_REPEAT_DISTANCE + 10000) // 29 ms
|
||||
|
||||
/*
|
||||
* Definitions to switch between FAST and NEC/ONKYO timing with the same code.
|
||||
*/
|
||||
#if defined(USE_FAST_PROTOCOL)
|
||||
#define ENABLE_NEC2_REPEATS // Disables detection of special short frame NEC repeats. Saves 40 bytes program memory.
|
||||
|
||||
#define TINY_RECEIVER_ADDRESS_BITS FAST_ADDRESS_BITS
|
||||
#define TINY_RECEIVER_COMMAND_BITS FAST_COMMAND_BITS
|
||||
#if !defined(TINY_RECEIVER_COMMAND_HAS_8_BIT_PARITY)
|
||||
#define TINY_RECEIVER_COMMAND_HAS_8_BIT_PARITY true // 8 bit and 8 bit parity
|
||||
//#define TINY_RECEIVER_COMMAND_HAS_8_BIT_PARITY false // 16 bit command without parity - not tested
|
||||
#endif
|
||||
|
||||
#define TINY_RECEIVER_BITS FAST_BITS
|
||||
#define TINY_RECEIVER_UNIT FAST_UNIT
|
||||
|
||||
#define TINY_RECEIVER_HEADER_MARK FAST_HEADER_MARK
|
||||
#define TINY_RECEIVER_HEADER_SPACE FAST_HEADER_SPACE
|
||||
|
||||
#define TINY_RECEIVER_BIT_MARK FAST_BIT_MARK
|
||||
#define TINY_RECEIVER_ONE_SPACE FAST_ONE_SPACE
|
||||
#define TINY_RECEIVER_ZERO_SPACE FAST_ZERO_SPACE
|
||||
|
||||
#define TINY_RECEIVER_MAXIMUM_REPEAT_DISTANCE FAST_MAXIMUM_REPEAT_DISTANCE // for repeat detection
|
||||
|
||||
#else
|
||||
|
||||
#define TINY_RECEIVER_ADDRESS_BITS NEC_ADDRESS_BITS // the address bits + parity
|
||||
# if defined(USE_ONKYO_PROTOCOL)
|
||||
#define TINY_RECEIVER_ADDRESS_HAS_8_BIT_PARITY false // 16 bit address without parity
|
||||
# elif defined(USE_EXTENDED_NEC_PROTOCOL)
|
||||
#define TINY_RECEIVER_ADDRESS_HAS_8_BIT_PARITY false // 16 bit address without parity
|
||||
# else
|
||||
#define TINY_RECEIVER_ADDRESS_HAS_8_BIT_PARITY true // 8 bit and 8 bit parity
|
||||
# endif
|
||||
|
||||
#define TINY_RECEIVER_COMMAND_BITS NEC_COMMAND_BITS // the command bits + parity
|
||||
# if defined(USE_ONKYO_PROTOCOL)
|
||||
#define TINY_RECEIVER_COMMAND_HAS_8_BIT_PARITY false // 16 bit command without parity
|
||||
# else
|
||||
#define TINY_RECEIVER_COMMAND_HAS_8_BIT_PARITY true // 8 bit and 8 bit parity
|
||||
# endif
|
||||
|
||||
#define TINY_RECEIVER_BITS NEC_BITS
|
||||
#define TINY_RECEIVER_UNIT NEC_UNIT
|
||||
|
||||
#define TINY_RECEIVER_HEADER_MARK NEC_HEADER_MARK
|
||||
#define TINY_RECEIVER_HEADER_SPACE NEC_HEADER_SPACE
|
||||
|
||||
#define TINY_RECEIVER_BIT_MARK NEC_BIT_MARK
|
||||
#define TINY_RECEIVER_ONE_SPACE NEC_ONE_SPACE
|
||||
#define TINY_RECEIVER_ZERO_SPACE NEC_ZERO_SPACE
|
||||
|
||||
#define TINY_RECEIVER_MAXIMUM_REPEAT_DISTANCE NEC_MAXIMUM_REPEAT_DISTANCE
|
||||
#endif
|
||||
|
||||
#if defined(USE_CALLBACK_FOR_TINY_RECEIVER)
|
||||
/*
|
||||
* This function is called, if a complete command was received and must be implemented in the file (user code)
|
||||
* which includes this library if USE_CALLBACK_FOR_TINY_RECEIVER is activated.
|
||||
*/
|
||||
extern void handleReceivedTinyIRData();
|
||||
#endif
|
||||
|
||||
#if !defined(MICROS_IN_ONE_SECOND)
|
||||
#define MICROS_IN_ONE_SECOND 1000000L
|
||||
#endif
|
||||
|
||||
#if !defined(MICROS_IN_ONE_MILLI)
|
||||
#define MICROS_IN_ONE_MILLI 1000L
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Macros for comparing timing values
|
||||
*/
|
||||
#define lowerValue25Percent(aDuration) (aDuration - (aDuration / 4))
|
||||
#define upperValue25Percent(aDuration) (aDuration + (aDuration / 4))
|
||||
#define lowerValue50Percent(aDuration) (aDuration / 2) // (aDuration - (aDuration / 2))
|
||||
#define upperValue50Percent(aDuration) (aDuration + (aDuration / 2))
|
||||
|
||||
/*
|
||||
* The states for the state machine
|
||||
*/
|
||||
#define IR_RECEIVER_STATE_WAITING_FOR_START_MARK 0
|
||||
#define IR_RECEIVER_STATE_WAITING_FOR_START_SPACE 1
|
||||
#define IR_RECEIVER_STATE_WAITING_FOR_FIRST_DATA_MARK 2
|
||||
#define IR_RECEIVER_STATE_WAITING_FOR_DATA_SPACE 3
|
||||
#define IR_RECEIVER_STATE_WAITING_FOR_DATA_MARK 4
|
||||
#define IR_RECEIVER_STATE_WAITING_FOR_STOP_MARK 5
|
||||
/**
|
||||
* Control and data variables of the state machine for TinyReceiver
|
||||
*/
|
||||
struct TinyIRReceiverStruct {
|
||||
/*
|
||||
* State machine
|
||||
*/
|
||||
uint32_t LastChangeMicros; ///< Microseconds of last Pin Change Interrupt.
|
||||
uint8_t IRReceiverState; ///< The state of the state machine.
|
||||
uint8_t IRRawDataBitCounter; ///< How many bits are currently contained in raw data.
|
||||
/*
|
||||
* Data
|
||||
*/
|
||||
#if (TINY_RECEIVER_BITS > 16)
|
||||
uint32_t IRRawDataMask; ///< The corresponding bit mask for IRRawDataBitCounter.
|
||||
LongUnion IRRawData; ///< The current raw data. LongUnion helps with decoding of address and command.
|
||||
#else
|
||||
uint16_t IRRawDataMask; ///< The corresponding bit mask for IRRawDataBitCounter.
|
||||
WordUnion IRRawData; ///< The current raw data. WordUnion helps with decoding of command.
|
||||
#endif
|
||||
uint8_t Flags; ///< One of IRDATA_FLAGS_EMPTY, IRDATA_FLAGS_IS_REPEAT, and IRDATA_FLAGS_PARITY_FAILED
|
||||
};
|
||||
|
||||
/*
|
||||
* Definitions for member TinyIRReceiverCallbackDataStruct.Flags
|
||||
* From IRremoteInt.h
|
||||
*/
|
||||
#define IRDATA_FLAGS_EMPTY 0x00
|
||||
#define IRDATA_FLAGS_IS_REPEAT 0x01
|
||||
#define IRDATA_FLAGS_IS_AUTO_REPEAT 0x02 // not used here, overwritten with _IRDATA_FLAGS_IS_SHORT_REPEAT
|
||||
#define IRDATA_FLAGS_PARITY_FAILED 0x04 ///< the current (autorepeat) frame violated parity check
|
||||
|
||||
/**
|
||||
* Is filled before calling the user callback to transfer received data to main loop for further processing.
|
||||
*/
|
||||
struct TinyIRReceiverCallbackDataStruct {
|
||||
#if (TINY_RECEIVER_ADDRESS_BITS > 0)
|
||||
# if (TINY_RECEIVER_ADDRESS_BITS == 16) && !TINY_RECEIVER_ADDRESS_HAS_8_BIT_PARITY
|
||||
uint16_t Address;
|
||||
# else
|
||||
uint8_t Address;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
# if (TINY_RECEIVER_COMMAND_BITS == 16) && !TINY_RECEIVER_COMMAND_HAS_8_BIT_PARITY
|
||||
uint16_t Command;
|
||||
#else
|
||||
uint8_t Command;
|
||||
#endif
|
||||
uint8_t Flags; // Bit coded flags. Can contain one of the bits: IRDATA_FLAGS_IS_REPEAT and IRDATA_FLAGS_PARITY_FAILED
|
||||
bool justWritten; ///< Is set true if new data is available. Used by the main loop, to avoid multiple evaluations of the same IR frame.
|
||||
};
|
||||
extern volatile TinyIRReceiverCallbackDataStruct TinyIRReceiverData;
|
||||
|
||||
bool isIRReceiverAttachedForTinyReceiver();
|
||||
bool initPCIInterruptForTinyReceiver();
|
||||
bool enablePCIInterruptForTinyReceiver();
|
||||
void disablePCIInterruptForTinyReceiver();
|
||||
bool isTinyReceiverIdle();
|
||||
void printTinyReceiverResultMinimal(Print *aSerial);
|
||||
|
||||
void sendFAST(uint8_t aSendPin, uint16_t aCommand, uint_fast8_t aNumberOfRepeats = 0);
|
||||
void sendFast8BitAndParity(uint8_t aSendPin, uint8_t aCommand, uint_fast8_t aNumberOfRepeats = 0);
|
||||
void sendONKYO(uint8_t aSendPin, uint16_t aAddress, uint16_t aCommand, uint_fast8_t aNumberOfRepeats = 0, bool aSendNEC2Repeats = false); // Send NEC with 16 bit command, even if aCommand < 0x100
|
||||
void sendNECMinimal(uint8_t aSendPin, uint16_t aAddress, uint16_t aCommand, uint_fast8_t aNumberOfRepeats = 0)
|
||||
__attribute__ ((deprecated ("Renamed to sendNEC().")));
|
||||
void sendNEC(uint8_t aSendPin, uint16_t aAddress, uint16_t aCommand, uint_fast8_t aNumberOfRepeats = 0, bool aSendNEC2Repeats = false);
|
||||
void sendExtendedNEC(uint8_t aSendPin, uint16_t aAddress, uint16_t aCommand, uint_fast8_t aNumberOfRepeats = 0, bool aSendNEC2Repeats = false);
|
||||
|
||||
/*
|
||||
* Version 2.1.0 - 2/2024
|
||||
* - New sendExtendedNEC() function and new parameter aSendNEC2Repeats.
|
||||
*
|
||||
* Version 2.0.0 - 10/2023
|
||||
* - New TinyIRReceiverData which is filled with address, command and flags.
|
||||
* - Removed parameters address, command and flags from callback handleReceivedTinyIRData() and printTinyReceiverResultMinimal().
|
||||
* - Callback function now only enabled if USE_CALLBACK_FOR_TINY_RECEIVER is activated.
|
||||
*
|
||||
* Version 1.2.0 - 01/2023
|
||||
* - Added ONKYO protocol, NEC with 16 bit address and command, instead of 8 bit + 8 bit parity address and command.
|
||||
* - Renamed functions and macros.
|
||||
*
|
||||
* Version 1.1.0 - 01/2023
|
||||
* - FAST protocol added.
|
||||
*/
|
||||
/** @}*/
|
||||
|
||||
#endif // _TINY_IR_H
|
|
@ -1,121 +0,0 @@
|
|||
/*
|
||||
* TinyIRReceiver.h
|
||||
*
|
||||
*
|
||||
* Copyright (C) 2021-2022 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.
|
||||
*
|
||||
* TinyIRReceiver 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 _TINY_IR_RECEIVER_H
|
||||
#define _TINY_IR_RECEIVER_H
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
//#define DISABLE_NEC_SPECIAL_REPEAT_SUPPORT // Activating this disables detection of full NEC frame repeats. Saves 40 bytes program memory.
|
||||
|
||||
#include "LongUnion.h"
|
||||
|
||||
/** \addtogroup TinyReceiver Minimal receiver for NEC protocol
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*
|
||||
* This function is called if a complete command was received and must be implemented by the including file (user code)
|
||||
*/
|
||||
void handleReceivedTinyIRData(uint16_t aAddress, uint8_t aCommand, bool isRepeat);
|
||||
|
||||
// LSB first, 1 start bit + 16 bit address + 8 bit data + 8 bit inverted data + 1 stop bit.
|
||||
// see: https://www.sbprojects.net/knowledge/ir/nec.php
|
||||
|
||||
#define NEC_ADDRESS_BITS 16 // 16 bit address or 8 bit address and 8 bit inverted address
|
||||
#define NEC_COMMAND_BITS 16 // Command and inverted command
|
||||
|
||||
#define NEC_BITS (NEC_ADDRESS_BITS + NEC_COMMAND_BITS)
|
||||
#define NEC_UNIT 560
|
||||
|
||||
#define NEC_HEADER_MARK (16 * NEC_UNIT) // 9000
|
||||
#define NEC_HEADER_SPACE (8 * NEC_UNIT) // 4500
|
||||
|
||||
#define NEC_BIT_MARK NEC_UNIT
|
||||
#define NEC_ONE_SPACE (3 * NEC_UNIT) // 1690
|
||||
#define NEC_ZERO_SPACE NEC_UNIT
|
||||
|
||||
#define NEC_REPEAT_HEADER_SPACE (4 * NEC_UNIT) // 2250
|
||||
#define NEC_REPEAT_PERIOD 110000 // Commands are repeated every 110 ms (measured from start to start) for as long as the key on the remote control is held down.
|
||||
#define NEC_MINIMAL_DURATION 49900 // NEC_HEADER_MARK + NEC_HEADER_SPACE + 32 * 2 * NEC_UNIT + NEC_UNIT // 2.5 because we assume more zeros than ones
|
||||
#define NEC_MAXIMUM_REPEAT_SPACE (NEC_REPEAT_PERIOD - NEC_MINIMAL_DURATION + 5) // 65 ms
|
||||
|
||||
/*
|
||||
* Macros for comparing timing values
|
||||
*/
|
||||
#define lowerValue25Percent(aDuration) (aDuration - (aDuration / 4))
|
||||
#define upperValue25Percent(aDuration) (aDuration + (aDuration / 4))
|
||||
#define lowerValue50Percent(aDuration) (aDuration / 2) // (aDuration - (aDuration / 2))
|
||||
#define upperValue50Percent(aDuration) (aDuration + (aDuration / 2))
|
||||
|
||||
/*
|
||||
* The states for the state machine
|
||||
*/
|
||||
#define IR_RECEIVER_STATE_WAITING_FOR_START_MARK 0
|
||||
#define IR_RECEIVER_STATE_WAITING_FOR_START_SPACE 1
|
||||
#define IR_RECEIVER_STATE_WAITING_FOR_FIRST_DATA_MARK 2
|
||||
#define IR_RECEIVER_STATE_WAITING_FOR_DATA_SPACE 3
|
||||
#define IR_RECEIVER_STATE_WAITING_FOR_DATA_MARK 4
|
||||
#define IR_RECEIVER_STATE_WAITING_FOR_STOP_MARK 5
|
||||
/**
|
||||
* Control and data variables of the state machine for TinyReceiver
|
||||
*/
|
||||
struct TinyIRReceiverStruct {
|
||||
/*
|
||||
* State machine
|
||||
*/
|
||||
uint32_t LastChangeMicros; ///< Microseconds of last Pin Change Interrupt.
|
||||
uint8_t IRReceiverState; ///< The state of the state machine.
|
||||
uint8_t IRRawDataBitCounter; ///< How many bits are currently contained in raw data.
|
||||
/*
|
||||
* Data
|
||||
*/
|
||||
uint32_t IRRawDataMask; ///< The corresponding bit mask for IRRawDataBitCounter.
|
||||
LongUnion IRRawData; ///< The current raw data. LongUnion helps with decoding of address and command.
|
||||
bool IRRepeatFrameDetected; ///< A "standard" NEC repeat frame was detected.
|
||||
#if !defined(DISABLE_NEC_SPECIAL_REPEAT_SUPPORT)
|
||||
bool IRRepeatDistanceDetected; ///< A small gap between two frames is detected -> assume a "non standard" repeat.
|
||||
#endif
|
||||
};
|
||||
|
||||
/**
|
||||
* Can be used by the callback to transfer received data to main loop for further processing.
|
||||
* E.g. with volatile struct TinyIRReceiverCallbackDataStruct sCallbackData;
|
||||
*/
|
||||
struct TinyIRReceiverCallbackDataStruct {
|
||||
uint16_t Address;
|
||||
uint8_t Command;
|
||||
bool isRepeat;
|
||||
bool justWritten; ///< Is set true if new data is available. Used by the main loop, to avoid multiple evaluations of the same IR frame.
|
||||
};
|
||||
|
||||
bool initPCIInterruptForTinyReceiver();
|
||||
bool enablePCIInterruptForTinyReceiver();
|
||||
void disablePCIInterruptForTinyReceiver();
|
||||
bool isTinyReceiverIdle();
|
||||
|
||||
/** @}*/
|
||||
|
||||
#endif // _TINY_IR_RECEIVER_H
|
|
@ -4,44 +4,65 @@
|
|||
* Receives IR protocol data of NEC protocol using pin change interrupts.
|
||||
* NEC is the protocol of most cheap remote controls for Arduino.
|
||||
*
|
||||
* No parity check is done!
|
||||
* On a completely received IR command, the user function handleReceivedIRData(uint16_t aAddress, uint8_t aCommand, bool isRepetition)
|
||||
* Parity check is done for address and data.
|
||||
* On a completely received IR command, the user function handleReceivedIRData(uint8_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 them in the main loop.
|
||||
* !!!!!!!!!!!!!!!!!!!!!
|
||||
* aFlags can contain one of IRDATA_FLAGS_EMPTY, IRDATA_FLAGS_IS_REPEAT and IRDATA_FLAGS_PARITY_FAILED bits
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* Copyright (C) 2021-2022 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.
|
||||
*
|
||||
* TinyIRReceiver 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.
|
||||
************************************************************************************
|
||||
* MIT License
|
||||
*
|
||||
* 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.
|
||||
* Copyright (c) 2022-2024 Armin Joachimsmeyer
|
||||
*
|
||||
* 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>.
|
||||
* 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.
|
||||
*
|
||||
************************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
* This library can be configured at compile time by the following options / macros:
|
||||
* For more details see: https://github.com/Arduino-IRremote/Arduino-IRremote#compile-options--macros-for-this-library (scroll down)
|
||||
*
|
||||
* - IR_INPUT_PIN The pin number for TinyIRReceiver IR input.
|
||||
* - IR_RECEIVE_PIN The pin number for TinyIRReceiver IR input.
|
||||
* - IR_FEEDBACK_LED_PIN The pin number for TinyIRReceiver feedback LED.
|
||||
* - NO_LED_FEEDBACK_CODE Disables the feedback LED function. Saves 14 bytes program memory.
|
||||
*
|
||||
* - DISABLE_PARITY_CHECKS Disable parity checks. Saves 48 bytes of program memory.
|
||||
* - 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.
|
||||
* - 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.
|
||||
* - USE_FAST_PROTOCOL Use FAST protocol (no address and 16 bit data, interpreted as 8 bit command and 8 bit inverted command) instead of NEC.
|
||||
* - ENABLE_NEC2_REPEATS Instead of sending / receiving the NEC special repeat code, send / receive the original frame for repeat.
|
||||
* - USE_CALLBACK_FOR_TINY_RECEIVER Call the fixed function "void handleReceivedTinyIRData()" each time a frame or repeat is received.
|
||||
*/
|
||||
|
||||
#ifndef _TINY_IR_RECEIVER_HPP
|
||||
|
@ -49,12 +70,25 @@
|
|||
|
||||
#include <Arduino.h>
|
||||
|
||||
// - DISABLE_NEC_SPECIAL_REPEAT_SUPPORT // Activating this disables detection of full NEC frame repeats. Saves 40 bytes program memory.
|
||||
#if defined(DEBUG) && !defined(LOCAL_DEBUG)
|
||||
#define LOCAL_DEBUG
|
||||
#else
|
||||
//#define LOCAL_DEBUG // This enables debug output only for this file
|
||||
#endif
|
||||
|
||||
#include "TinyIRReceiver.h" // If not defined, it defines IR_INPUT_PIN, IR_FEEDBACK_LED_PIN and TINY_RECEIVER_USE_ARDUINO_ATTACH_INTERRUPT
|
||||
/*
|
||||
* 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.
|
||||
|
||||
#include "TinyIR.h" // If not defined, it defines IR_RECEIVE_PIN, IR_FEEDBACK_LED_PIN and TINY_RECEIVER_USE_ARDUINO_ATTACH_INTERRUPT
|
||||
|
||||
#include "digitalWriteFast.h"
|
||||
/** \addtogroup TinyReceiver Minimal receiver for NEC protocol
|
||||
/** \addtogroup TinyReceiver Minimal receiver for NEC and FAST protocol
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
@ -66,23 +100,31 @@
|
|||
#if defined(TRACE)
|
||||
#define LOCAL_TRACE_STATE_MACHINE
|
||||
#else
|
||||
//#define LOCAL_TRACE_STATE_MACHINE // to see the state of the ISR state machine
|
||||
//#define LOCAL_TRACE_STATE_MACHINE // to see the state of the ISR (Interrupt Service Routine) state machine
|
||||
#endif
|
||||
|
||||
//#define _IR_MEASURE_TIMING // Activate this if you want to enable internal hardware timing measurement.
|
||||
//#define _IR_TIMING_TEST_PIN 7
|
||||
TinyIRReceiverStruct TinyIRReceiverControl;
|
||||
volatile TinyIRReceiverCallbackDataStruct TinyIRReceiverData;
|
||||
|
||||
/*
|
||||
* Set input pin and output pin definitions etc.
|
||||
*/
|
||||
#if !defined(IR_INPUT_PIN)
|
||||
#if defined(__AVR_ATtiny1616__) || defined(__AVR_ATtiny3216__) || defined(__AVR_ATtiny3217__)
|
||||
#warning "IR_INPUT_PIN is not defined, so it is set to 10"
|
||||
#define IR_INPUT_PIN 10
|
||||
#if defined(IR_INPUT_PIN)
|
||||
#warning "IR_INPUT_PIN is deprecated, use IR_RECEIVE_PIN"
|
||||
#define IR_RECEIVE_PIN IR_INPUT_PIN
|
||||
#endif
|
||||
#if !defined(IR_RECEIVE_PIN)
|
||||
#if defined(__AVR_ATtiny1616__) || defined(__AVR_ATtiny3216__) || defined(__AVR_ATtiny3217__)
|
||||
#warning "IR_RECEIVE_PIN is not defined, so it is set to 10"
|
||||
#define IR_RECEIVE_PIN 10
|
||||
#elif defined(__AVR_ATtiny816__)
|
||||
#warning "IR_RECEIVE_PIN is not defined, so it is set to 14"
|
||||
#define IR_RECEIVE_PIN 14
|
||||
#else
|
||||
#warning "IR_INPUT_PIN is not defined, so it is set to 2"
|
||||
#define IR_INPUT_PIN 2
|
||||
#warning "IR_RECEIVE_PIN is not defined, so it is set to 2"
|
||||
#define IR_RECEIVE_PIN 2
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -98,8 +140,8 @@ TinyIRReceiverStruct TinyIRReceiverControl;
|
|||
|| defined(__AVR_ATmega8__) || defined(__AVR_ATmega48__) || defined(__AVR_ATmega48P__) || defined(__AVR_ATmega48PB__) || defined(__AVR_ATmega88P__) || defined(__AVR_ATmega88PB__) \
|
||||
|| defined(__AVR_ATmega168__) || defined(__AVR_ATmega168PA__) || defined(__AVR_ATmega168PB__) || defined(__AVR_ATmega328__) || defined(__AVR_ATmega328P__) || defined(__AVR_ATmega328PB__) \
|
||||
/* ATmegas with ports 0,1,2 above and ATtiny167 only 2 pins below */ \
|
||||
|| ( (defined(__AVR_ATtiny87__) || defined(__AVR_ATtiny167__)) && ( (defined(ARDUINO_AVR_DIGISPARKPRO) && ((IR_INPUT_PIN == 3) || (IR_INPUT_PIN == 9))) /*ATtinyX7(digisparkpro) and pin 3 or 9 */\
|
||||
|| (! defined(ARDUINO_AVR_DIGISPARKPRO) && ((IR_INPUT_PIN == 3) || (IR_INPUT_PIN == 14)))) ) /*ATtinyX7(ATTinyCore) and pin 3 or 14 */ \
|
||||
|| ( (defined(__AVR_ATtiny87__) || defined(__AVR_ATtiny167__)) && ( (defined(ARDUINO_AVR_DIGISPARKPRO) && ((IR_RECEIVE_PIN == 3) || (IR_RECEIVE_PIN == 9))) /*ATtinyX7(digisparkpro) and pin 3 or 9 */\
|
||||
|| (! defined(ARDUINO_AVR_DIGISPARKPRO) && ((IR_RECEIVE_PIN == 3) || (IR_RECEIVE_PIN == 14)))) ) /*ATtinyX7(ATTinyCore) and pin 3 or 14 */ \
|
||||
)
|
||||
#define TINY_RECEIVER_USE_ARDUINO_ATTACH_INTERRUPT // Cannot use any static ISR vector here. In other cases we have code provided for generating interrupt on pin change.
|
||||
#endif
|
||||
|
@ -108,23 +150,20 @@ TinyIRReceiverStruct TinyIRReceiverControl;
|
|||
* Declaration of the callback function provided by the user application.
|
||||
* It is called every time a complete IR command or repeat was received.
|
||||
*/
|
||||
#if defined(ESP32) || defined(ESP8266)
|
||||
extern void IRAM_ATTR handleReceivedIRData(uint16_t aAddress, uint8_t aCommand, bool isRepetition);
|
||||
#else
|
||||
extern void handleReceivedIRData(uint16_t aAddress, uint8_t aCommand, bool isRepetition);
|
||||
#endif
|
||||
extern void handleTinyReceivedIRData();
|
||||
|
||||
#if defined(LOCAL_DEBUG)
|
||||
uint32_t sMicrosOfGap; // The length of the gap before the start bit
|
||||
#endif
|
||||
/**
|
||||
* The ISR of TinyIRRreceiver.
|
||||
* The ISR (Interrupt Service Routine) of TinyIRRreceiver.
|
||||
* It handles the NEC protocol decoding and calls the user callback function on complete.
|
||||
* 5 us + 3 us for push + pop for a 16MHz ATmega
|
||||
*/
|
||||
#if defined(ESP32) || defined(ESP8266)
|
||||
void IRAM_ATTR IRPinChangeInterruptHandler(void)
|
||||
#else
|
||||
void IRPinChangeInterruptHandler(void)
|
||||
#if defined(ESP8266) || defined(ESP32)
|
||||
IRAM_ATTR
|
||||
#endif
|
||||
{
|
||||
void IRPinChangeInterruptHandler(void) {
|
||||
#if defined(_IR_MEASURE_TIMING) && defined(_IR_TIMING_TEST_PIN)
|
||||
digitalWriteFast(_IR_TIMING_TEST_PIN, HIGH); // 2 clock cycles
|
||||
#endif
|
||||
|
@ -132,7 +171,7 @@ void IRPinChangeInterruptHandler(void)
|
|||
* Save IR input level
|
||||
* Negative logic, true / HIGH means inactive / IR space, LOW / false means IR mark.
|
||||
*/
|
||||
uint_fast8_t tIRLevel = digitalReadFast(IR_INPUT_PIN);
|
||||
uint_fast8_t tIRLevel = digitalReadFast(IR_RECEIVE_PIN);
|
||||
|
||||
#if !defined(NO_LED_FEEDBACK_CODE) && defined(IR_FEEDBACK_LED_PIN)
|
||||
digitalWriteFast(IR_FEEDBACK_LED_PIN, !tIRLevel);
|
||||
|
@ -141,13 +180,11 @@ void IRPinChangeInterruptHandler(void)
|
|||
/*
|
||||
* 1. compute microseconds after last change
|
||||
*/
|
||||
// Repeats can be sent after a pause, which is longer than 64000 microseconds, so we need a 32 bit value for check of repeats
|
||||
uint32_t tCurrentMicros = micros();
|
||||
#if defined(DISABLE_NEC_SPECIAL_REPEAT_SUPPORT)
|
||||
uint16_t tMicrosOfMarkOrSpace = tCurrentMicros - TinyIRReceiverControl.LastChangeMicros;
|
||||
#else
|
||||
uint32_t tMicrosOfMarkOrSpace32 = tCurrentMicros - TinyIRReceiverControl.LastChangeMicros;
|
||||
uint16_t tMicrosOfMarkOrSpace = tMicrosOfMarkOrSpace32;
|
||||
#endif
|
||||
|
||||
TinyIRReceiverControl.LastChangeMicros = tCurrentMicros;
|
||||
|
||||
uint8_t tState = TinyIRReceiverControl.IRReceiverState;
|
||||
|
@ -165,39 +202,52 @@ void IRPinChangeInterruptHandler(void)
|
|||
/*
|
||||
* We have a mark here
|
||||
*/
|
||||
if (tMicrosOfMarkOrSpace > 2 * NEC_HEADER_MARK) {
|
||||
if (tMicrosOfMarkOrSpace > 2 * TINY_RECEIVER_HEADER_MARK) {
|
||||
// timeout -> must reset state machine
|
||||
tState = IR_RECEIVER_STATE_WAITING_FOR_START_MARK;
|
||||
}
|
||||
if (tState == IR_RECEIVER_STATE_WAITING_FOR_START_MARK) {
|
||||
// We are at the beginning of the header mark, check timing at the next transition
|
||||
tState = IR_RECEIVER_STATE_WAITING_FOR_START_SPACE;
|
||||
TinyIRReceiverControl.IRRepeatFrameDetected = false; // If we do it here, it saves 4 bytes
|
||||
#if !defined(DISABLE_NEC_SPECIAL_REPEAT_SUPPORT)
|
||||
// Check for special repeat, where full frame is sent again after 110 ms
|
||||
TinyIRReceiverControl.Flags = IRDATA_FLAGS_EMPTY; // If we do it here, it saves 4 bytes
|
||||
#if defined(LOCAL_TRACE)
|
||||
sMicrosOfGap = tMicrosOfMarkOrSpace32;
|
||||
#endif
|
||||
#if defined(ENABLE_NEC2_REPEATS)
|
||||
// Check for repeat, where full frame is sent again after TINY_RECEIVER_REPEAT_PERIOD ms
|
||||
// Not required for NEC, where repeats are detected by a special header space duration
|
||||
// Must use 32 bit arithmetic here!
|
||||
TinyIRReceiverControl.IRRepeatDistanceDetected = (tMicrosOfMarkOrSpace32 < NEC_MAXIMUM_REPEAT_SPACE);
|
||||
if (tMicrosOfMarkOrSpace32 < TINY_RECEIVER_MAXIMUM_REPEAT_DISTANCE) {
|
||||
TinyIRReceiverControl.Flags = IRDATA_FLAGS_IS_REPEAT;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
else if (tState == IR_RECEIVER_STATE_WAITING_FOR_FIRST_DATA_MARK) {
|
||||
if (tMicrosOfMarkOrSpace >= lowerValue25Percent(NEC_HEADER_SPACE)
|
||||
&& tMicrosOfMarkOrSpace <= upperValue25Percent(NEC_HEADER_SPACE)) {
|
||||
if (tMicrosOfMarkOrSpace >= lowerValue25Percent(TINY_RECEIVER_HEADER_SPACE)
|
||||
&& tMicrosOfMarkOrSpace <= upperValue25Percent(TINY_RECEIVER_HEADER_SPACE)) {
|
||||
/*
|
||||
* We have a valid data header space here -> initialize data
|
||||
*/
|
||||
TinyIRReceiverControl.IRRawDataBitCounter = 0;
|
||||
#if (TINY_RECEIVER_BITS > 16)
|
||||
TinyIRReceiverControl.IRRawData.ULong = 0;
|
||||
#else
|
||||
TinyIRReceiverControl.IRRawData.UWord = 0;
|
||||
#endif
|
||||
TinyIRReceiverControl.IRRawDataMask = 1;
|
||||
tState = IR_RECEIVER_STATE_WAITING_FOR_DATA_SPACE;
|
||||
#if !defined(ENABLE_NEC2_REPEATS)
|
||||
// Check for NEC repeat header
|
||||
} else if (tMicrosOfMarkOrSpace >= lowerValue25Percent(NEC_REPEAT_HEADER_SPACE)
|
||||
&& tMicrosOfMarkOrSpace <= upperValue25Percent(NEC_REPEAT_HEADER_SPACE)
|
||||
&& TinyIRReceiverControl.IRRawDataBitCounter >= NEC_BITS) {
|
||||
&& TinyIRReceiverControl.IRRawDataBitCounter >= TINY_RECEIVER_BITS) {
|
||||
/*
|
||||
* We have a repeat header here and no broken receive before -> set repeat flag
|
||||
*/
|
||||
TinyIRReceiverControl.IRRepeatFrameDetected = true;
|
||||
TinyIRReceiverControl.Flags = IRDATA_FLAGS_IS_REPEAT;
|
||||
tState = IR_RECEIVER_STATE_WAITING_FOR_DATA_SPACE;
|
||||
#endif
|
||||
} else {
|
||||
// This parts are optimized by the compiler into jumps to one code :-)
|
||||
// Wrong length -> reset state
|
||||
|
@ -207,13 +257,17 @@ void IRPinChangeInterruptHandler(void)
|
|||
|
||||
else if (tState == IR_RECEIVER_STATE_WAITING_FOR_DATA_MARK) {
|
||||
// Check data space length
|
||||
if (tMicrosOfMarkOrSpace >= lowerValue50Percent(NEC_ZERO_SPACE)
|
||||
&& tMicrosOfMarkOrSpace <= upperValue50Percent(NEC_ONE_SPACE)) {
|
||||
if (tMicrosOfMarkOrSpace >= lowerValue50Percent(TINY_RECEIVER_ZERO_SPACE)
|
||||
&& tMicrosOfMarkOrSpace <= upperValue50Percent(TINY_RECEIVER_ONE_SPACE)) {
|
||||
// We have a valid bit here
|
||||
tState = IR_RECEIVER_STATE_WAITING_FOR_DATA_SPACE;
|
||||
if (tMicrosOfMarkOrSpace >= 2 * NEC_UNIT) {
|
||||
if (tMicrosOfMarkOrSpace >= 2 * TINY_RECEIVER_UNIT) {
|
||||
// we received a 1
|
||||
#if (TINY_RECEIVER_BITS > 16)
|
||||
TinyIRReceiverControl.IRRawData.ULong |= TinyIRReceiverControl.IRRawDataMask;
|
||||
#else
|
||||
TinyIRReceiverControl.IRRawData.UWord |= TinyIRReceiverControl.IRRawDataMask;
|
||||
#endif
|
||||
} else {
|
||||
// we received a 0 - empty code for documentation
|
||||
}
|
||||
|
@ -238,8 +292,8 @@ void IRPinChangeInterruptHandler(void)
|
|||
/*
|
||||
* Check length of header mark here
|
||||
*/
|
||||
if (tMicrosOfMarkOrSpace >= lowerValue25Percent(NEC_HEADER_MARK)
|
||||
&& tMicrosOfMarkOrSpace <= upperValue25Percent(NEC_HEADER_MARK)) {
|
||||
if (tMicrosOfMarkOrSpace >= lowerValue25Percent(TINY_RECEIVER_HEADER_MARK)
|
||||
&& tMicrosOfMarkOrSpace <= upperValue25Percent(TINY_RECEIVER_HEADER_MARK)) {
|
||||
tState = IR_RECEIVER_STATE_WAITING_FOR_FIRST_DATA_MARK;
|
||||
} else {
|
||||
// Wrong length of header mark -> reset state
|
||||
|
@ -249,38 +303,104 @@ void IRPinChangeInterruptHandler(void)
|
|||
|
||||
else if (tState == IR_RECEIVER_STATE_WAITING_FOR_DATA_SPACE) {
|
||||
// Check data mark length
|
||||
if (tMicrosOfMarkOrSpace >= lowerValue50Percent(NEC_BIT_MARK)
|
||||
&& tMicrosOfMarkOrSpace <= upperValue50Percent(NEC_BIT_MARK)) {
|
||||
if (tMicrosOfMarkOrSpace >= lowerValue50Percent(TINY_RECEIVER_BIT_MARK)
|
||||
&& tMicrosOfMarkOrSpace <= upperValue50Percent(TINY_RECEIVER_BIT_MARK)) {
|
||||
/*
|
||||
* We have a valid mark here, check for transmission complete, i.e. the mark of the stop bit
|
||||
*/
|
||||
if (TinyIRReceiverControl.IRRawDataBitCounter >= NEC_BITS || TinyIRReceiverControl.IRRepeatFrameDetected) {
|
||||
if (TinyIRReceiverControl.IRRawDataBitCounter >= TINY_RECEIVER_BITS
|
||||
#if !defined(ENABLE_NEC2_REPEATS)
|
||||
|| (TinyIRReceiverControl.Flags & IRDATA_FLAGS_IS_REPEAT) // Do not check for full length received, if we have a short repeat frame
|
||||
#endif
|
||||
) {
|
||||
/*
|
||||
* Code complete -> call callback, no parity check!
|
||||
* Code complete -> optionally check parity
|
||||
*/
|
||||
// Reset state for new start
|
||||
tState = IR_RECEIVER_STATE_WAITING_FOR_START_MARK;
|
||||
|
||||
#if !defined(DISABLE_PARITY_CHECKS) && (TINY_RECEIVER_ADDRESS_BITS == 16) && TINY_RECEIVER_ADDRESS_HAS_8_BIT_PARITY
|
||||
/*
|
||||
* Check address parity
|
||||
* Address is sent first and contained in the lower word
|
||||
*/
|
||||
if (TinyIRReceiverControl.IRRawData.UBytes[0] != (uint8_t) (~TinyIRReceiverControl.IRRawData.UBytes[1])) {
|
||||
#if defined(ENABLE_NEC2_REPEATS)
|
||||
TinyIRReceiverControl.Flags |= IRDATA_FLAGS_PARITY_FAILED; // here we can have the repeat flag already set
|
||||
#else
|
||||
TinyIRReceiverControl.Flags = IRDATA_FLAGS_PARITY_FAILED; // here we do not check anything, if we have a repeat
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
#if !defined(DISABLE_PARITY_CHECKS) && (TINY_RECEIVER_COMMAND_BITS == 16) && TINY_RECEIVER_COMMAND_HAS_8_BIT_PARITY
|
||||
/*
|
||||
* Check command parity
|
||||
*/
|
||||
#if (TINY_RECEIVER_ADDRESS_BITS > 0)
|
||||
if (TinyIRReceiverControl.IRRawData.UBytes[2] != (uint8_t) (~TinyIRReceiverControl.IRRawData.UBytes[3])) {
|
||||
#if defined(ENABLE_NEC2_REPEATS)
|
||||
TinyIRReceiverControl.Flags |= IRDATA_FLAGS_PARITY_FAILED;
|
||||
#else
|
||||
TinyIRReceiverControl.Flags = IRDATA_FLAGS_PARITY_FAILED;
|
||||
#endif
|
||||
# if defined(LOCAL_DEBUG)
|
||||
Serial.print(F("Parity check for command failed. Command="));
|
||||
Serial.print(TinyIRReceiverControl.IRRawData.UBytes[2], HEX);
|
||||
Serial.print(F(" parity="));
|
||||
Serial.println(TinyIRReceiverControl.IRRawData.UBytes[3], HEX);
|
||||
# endif
|
||||
#else
|
||||
// No address, so command and parity are in the lowest bytes
|
||||
if (TinyIRReceiverControl.IRRawData.UBytes[0] != (uint8_t) (~TinyIRReceiverControl.IRRawData.UBytes[1])) {
|
||||
TinyIRReceiverControl.Flags |= IRDATA_FLAGS_PARITY_FAILED;
|
||||
# if defined(LOCAL_DEBUG)
|
||||
Serial.print(F("Parity check for command failed. Command="));
|
||||
Serial.print(TinyIRReceiverControl.IRRawData.UBytes[0], HEX);
|
||||
Serial.print(F(" parity="));
|
||||
Serial.println(TinyIRReceiverControl.IRRawData.UBytes[1], HEX);
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
/*
|
||||
* Call user provided callback here
|
||||
* The parameter size is dependent of the code variant used in order to save program memory.
|
||||
* We have 6 cases: 0, 8 bit or 16 bit address, each with 8 or 16 bit command
|
||||
*/
|
||||
#if !defined(ARDUINO_ARCH_MBED) && !defined(ESP32) // no Serial etc. in callback for ESP -> no interrupt required, WDT is running!
|
||||
interrupts(); // enable interrupts, so delay() etc. works in callback
|
||||
#endif
|
||||
/*
|
||||
* Address reduction to 8 bit
|
||||
*/
|
||||
if (TinyIRReceiverControl.IRRawData.UByte.LowByte
|
||||
== (uint8_t) (~TinyIRReceiverControl.IRRawData.UByte.MidLowByte)) {
|
||||
// standard 8 bit address NEC protocol
|
||||
TinyIRReceiverControl.IRRawData.UByte.MidLowByte = 0; // Address is the first 8 bit
|
||||
}
|
||||
TinyIRReceiverData.justWritten = true;
|
||||
TinyIRReceiverData.Flags = TinyIRReceiverControl.Flags;
|
||||
#if (TINY_RECEIVER_ADDRESS_BITS > 0)
|
||||
# if TINY_RECEIVER_ADDRESS_HAS_8_BIT_PARITY
|
||||
// Here we have 8 bit address
|
||||
TinyIRReceiverData.Address = TinyIRReceiverControl.IRRawData.UBytes[0];
|
||||
# else
|
||||
// Here we have 16 bit address
|
||||
TinyIRReceiverData.Address = TinyIRReceiverControl.IRRawData.UWord.LowWord;
|
||||
# endif
|
||||
# if TINY_RECEIVER_COMMAND_HAS_8_BIT_PARITY
|
||||
// Here we have 8 bit command
|
||||
TinyIRReceiverData.Command = TinyIRReceiverControl.IRRawData.UBytes[2];
|
||||
# else
|
||||
// Here we have 16 bit command
|
||||
TinyIRReceiverData.Command = TinyIRReceiverControl.IRRawData.UWord.HighWord;
|
||||
# endif
|
||||
|
||||
/*
|
||||
* Call user provided callback here
|
||||
*/
|
||||
handleReceivedTinyIRData(TinyIRReceiverControl.IRRawData.UWord.LowWord,
|
||||
TinyIRReceiverControl.IRRawData.UByte.MidHighByte, (TinyIRReceiverControl.IRRepeatFrameDetected
|
||||
#if !defined(DISABLE_NEC_SPECIAL_REPEAT_SUPPORT)
|
||||
|| TinyIRReceiverControl.IRRepeatDistanceDetected
|
||||
#else
|
||||
// Here we have NO address
|
||||
# if TINY_RECEIVER_COMMAND_HAS_8_BIT_PARITY
|
||||
// Here we have 8 bit command
|
||||
TinyIRReceiverData.Command = TinyIRReceiverControl.IRRawData.UBytes[0];
|
||||
# else
|
||||
// Here we have 16 bit command
|
||||
TinyIRReceiverData.Command = TinyIRReceiverControl.IRRawData.UWord;
|
||||
# endif
|
||||
#endif
|
||||
#if defined(USE_CALLBACK_FOR_TINY_RECEIVER)
|
||||
handleReceivedTinyIRData();
|
||||
#endif
|
||||
));
|
||||
|
||||
} else {
|
||||
// not finished yet
|
||||
|
@ -306,11 +426,23 @@ bool isTinyReceiverIdle() {
|
|||
return (TinyIRReceiverControl.IRReceiverState == IR_RECEIVER_STATE_WAITING_FOR_START_MARK);
|
||||
}
|
||||
|
||||
/*
|
||||
* Checks if IR_RECEIVE_PIN is connected and high
|
||||
* @return true, if IR Receiver is attached
|
||||
*/
|
||||
bool isIRReceiverAttachedForTinyReceiver() {
|
||||
pinModeFast(IR_RECEIVE_PIN, OUTPUT);
|
||||
digitalWriteFast(IR_RECEIVE_PIN, LOW); // discharge pin capacity
|
||||
pinModeFast(IR_RECEIVE_PIN, INPUT);
|
||||
return digitalRead(IR_RECEIVE_PIN); // use slow digitalRead here, since the pin capacity is not fully charged again if we use digitalReadFast.
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets IR_INPUT_PIN mode to INPUT_PULLUP, if required, sets feedback LED output mode and call enablePCIInterruptForTinyReceiver()
|
||||
* Sets IR_RECEIVE_PIN mode to INPUT, and if IR_FEEDBACK_LED_PIN is defined, sets feedback LED output mode.
|
||||
* Then call enablePCIInterruptForTinyReceiver()
|
||||
*/
|
||||
bool initPCIInterruptForTinyReceiver() {
|
||||
pinModeFast(IR_INPUT_PIN, INPUT_PULLUP);
|
||||
pinModeFast(IR_RECEIVE_PIN, INPUT);
|
||||
|
||||
#if !defined(NO_LED_FEEDBACK_CODE) && defined(IR_FEEDBACK_LED_PIN)
|
||||
pinModeFast(IR_FEEDBACK_LED_PIN, OUTPUT);
|
||||
|
@ -318,6 +450,28 @@ bool initPCIInterruptForTinyReceiver() {
|
|||
return enablePCIInterruptForTinyReceiver();
|
||||
}
|
||||
|
||||
void printTinyReceiverResultMinimal(Print *aSerial) {
|
||||
// Print only very short output, since we are in an interrupt context and do not want to miss the next interrupts of the repeats coming soon
|
||||
// Print only very short output, since we are in an interrupt context and do not want to miss the next interrupts of the repeats coming soon
|
||||
#if defined(USE_FAST_PROTOCOL)
|
||||
aSerial->print(F("C=0x"));
|
||||
#else
|
||||
aSerial->print(F("A=0x"));
|
||||
aSerial->print(TinyIRReceiverData.Address, HEX);
|
||||
aSerial->print(F(" C=0x"));
|
||||
#endif
|
||||
aSerial->print(TinyIRReceiverData.Command, HEX);
|
||||
if (TinyIRReceiverData.Flags == IRDATA_FLAGS_IS_REPEAT) {
|
||||
aSerial->print(F(" R"));
|
||||
}
|
||||
#if !defined(DISABLE_PARITY_CHECKS)
|
||||
if (TinyIRReceiverData.Flags == IRDATA_FLAGS_PARITY_FAILED) {
|
||||
aSerial->print(F(" P"));
|
||||
}
|
||||
#endif
|
||||
aSerial->println();
|
||||
}
|
||||
|
||||
#if defined (LOCAL_DEBUG_ATTACH_INTERRUPT) && !defined(STR)
|
||||
// Helper macro for getting a macro definition as string
|
||||
#define STR_HELPER(x) #x
|
||||
|
@ -327,7 +481,7 @@ bool initPCIInterruptForTinyReceiver() {
|
|||
/**************************************************
|
||||
* Pin to interrupt mapping for different platforms
|
||||
**************************************************/
|
||||
#if defined(__AVR_ATtiny1616__) || defined(__AVR_ATtiny3216__) || defined(__AVR_ATtiny3217__)
|
||||
#if defined(__AVR_ATtiny816__) || defined(__AVR_ATtiny1616__) || defined(__AVR_ATtiny3216__) || defined(__AVR_ATtiny3217__)
|
||||
#define USE_ATTACH_INTERRUPT_DIRECT
|
||||
|
||||
#elif !defined(__AVR__) || defined(TINY_RECEIVER_USE_ARDUINO_ATTACH_INTERRUPT)
|
||||
|
@ -340,30 +494,30 @@ bool initPCIInterruptForTinyReceiver() {
|
|||
|
||||
# elif defined(__AVR_ATtiny87__) || defined(__AVR_ATtiny167__)
|
||||
# if defined(ARDUINO_AVR_DIGISPARKPRO)
|
||||
# if (IR_INPUT_PIN == 3)
|
||||
# if (IR_RECEIVE_PIN == 3)
|
||||
#define USE_INT0
|
||||
# elif (IR_INPUT_PIN == 9)
|
||||
# elif (IR_RECEIVE_PIN == 9)
|
||||
#define USE_INT1
|
||||
# else
|
||||
# error "IR_INPUT_PIN must be 9 or 3."
|
||||
# endif // if (IR_INPUT_PIN == 9)
|
||||
# error "IR_RECEIVE_PIN must be 9 or 3."
|
||||
# endif // if (IR_RECEIVE_PIN == 9)
|
||||
# else // defined(ARDUINO_AVR_DIGISPARKPRO)
|
||||
# if (IR_INPUT_PIN == 14)
|
||||
# if (IR_RECEIVE_PIN == 14)
|
||||
#define USE_INT0
|
||||
# elif (IR_INPUT_PIN == 3)
|
||||
# elif (IR_RECEIVE_PIN == 3)
|
||||
#define USE_INT1
|
||||
# else
|
||||
# error "IR_INPUT_PIN must be 14 or 3."
|
||||
# endif // if (IR_INPUT_PIN == 14)
|
||||
# error "IR_RECEIVE_PIN must be 14 or 3."
|
||||
# endif // if (IR_RECEIVE_PIN == 14)
|
||||
# endif
|
||||
|
||||
# elif (defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__))
|
||||
# if (IR_INPUT_PIN == 21)
|
||||
# if (IR_RECEIVE_PIN == 21)
|
||||
#define USE_INT0
|
||||
# elif (IR_INPUT_PIN == 20)
|
||||
# elif (IR_RECEIVE_PIN == 20)
|
||||
#define USE_INT1
|
||||
# else
|
||||
#warning "No pin mapping for IR_INPUT_PIN to interrupt found -> attachInterrupt() is used now."
|
||||
#warning "No pin mapping for IR_RECEIVE_PIN to interrupt found -> attachInterrupt() is used now."
|
||||
#define USE_ATTACH_INTERRUPT
|
||||
# endif
|
||||
|
||||
|
@ -371,30 +525,31 @@ bool initPCIInterruptForTinyReceiver() {
|
|||
/*
|
||||
* ATmegas + ATtiny88 here
|
||||
*/
|
||||
# if (IR_INPUT_PIN == 2)
|
||||
# if (IR_RECEIVE_PIN == 2)
|
||||
#define USE_INT0
|
||||
# elif (IR_INPUT_PIN == 3)
|
||||
# elif (IR_RECEIVE_PIN == 3)
|
||||
#define USE_INT1
|
||||
|
||||
# elif IR_INPUT_PIN == 4 || IR_INPUT_PIN == 5 || IR_INPUT_PIN == 6 || IR_INPUT_PIN == 7
|
||||
# elif IR_RECEIVE_PIN == 4 || IR_RECEIVE_PIN == 5 || IR_RECEIVE_PIN == 6 || IR_RECEIVE_PIN == 7
|
||||
//ATmega328 (Uno, Nano ) etc. Enable pin change interrupt 20 to 23 for port PD4 to PD7 (Arduino pin 4 to 7)
|
||||
#define USE_PCINT2
|
||||
# elif IR_INPUT_PIN == 8 || IR_INPUT_PIN == 9 || IR_INPUT_PIN == 10 || IR_INPUT_PIN == 11 || IR_INPUT_PIN == 12 || IR_INPUT_PIN == 13
|
||||
# elif IR_RECEIVE_PIN == 8 || IR_RECEIVE_PIN == 9 || IR_RECEIVE_PIN == 10 || IR_RECEIVE_PIN == 11 || IR_RECEIVE_PIN == 12 || IR_RECEIVE_PIN == 13
|
||||
//ATmega328 (Uno, Nano ) etc. Enable pin change interrupt 0 to 5 for port PB0 to PB5 (Arduino pin 8 to 13)
|
||||
#define USE_PCINT0
|
||||
# elif IR_INPUT_PIN == A0 || IR_INPUT_PIN == A1 || IR_INPUT_PIN == A2 || IR_INPUT_PIN == A3 || IR_INPUT_PIN == A4 || IR_INPUT_PIN == A5
|
||||
# elif IR_RECEIVE_PIN == A0 || IR_RECEIVE_PIN == A1 || IR_RECEIVE_PIN == A2 || IR_RECEIVE_PIN == A3 || IR_RECEIVE_PIN == A4 || IR_RECEIVE_PIN == A5
|
||||
//ATmega328 (Uno, Nano ) etc. Enable pin change interrupt 8 to 13 for port PC0 to PC5 (Arduino pin A0 to A5)
|
||||
#define USE_PCINT1
|
||||
|
||||
# else
|
||||
#warning "No pin mapping for IR_INPUT_PIN to interrupt found -> attachInterrupt() is used now."
|
||||
#warning "No pin mapping for IR_RECEIVE_PIN to interrupt found -> attachInterrupt() is used now."
|
||||
#define USE_ATTACH_INTERRUPT
|
||||
# endif // if (IR_INPUT_PIN == 2)
|
||||
# endif // if (IR_RECEIVE_PIN == 2)
|
||||
# endif // defined(__AVR_ATtiny25__)
|
||||
#endif // ! defined(__AVR__) || defined(TINY_RECEIVER_USE_ARDUINO_ATTACH_INTERRUPT)
|
||||
|
||||
/**
|
||||
* Initializes hardware interrupt generation according to IR_INPUT_PIN or use attachInterrupt() function.
|
||||
* Initializes hardware interrupt generation according to IR_RECEIVE_PIN or use attachInterrupt() function.
|
||||
* @return true if interrupt was successfully enabled
|
||||
*/
|
||||
bool enablePCIInterruptForTinyReceiver() {
|
||||
#if defined(_IR_MEASURE_TIMING) && defined(_IR_TIMING_TEST_PIN)
|
||||
|
@ -404,24 +559,24 @@ bool enablePCIInterruptForTinyReceiver() {
|
|||
#if defined(USE_ATTACH_INTERRUPT) || defined(USE_ATTACH_INTERRUPT_DIRECT)
|
||||
# if defined(USE_ATTACH_INTERRUPT)
|
||||
#if defined(NOT_AN_INTERRUPT)
|
||||
if(digitalPinToInterrupt(IR_INPUT_PIN) == NOT_AN_INTERRUPT){
|
||||
if(digitalPinToInterrupt(IR_RECEIVE_PIN) == NOT_AN_INTERRUPT){
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
// costs 112 bytes program space + 4 bytes RAM
|
||||
attachInterrupt(digitalPinToInterrupt(IR_INPUT_PIN), IRPinChangeInterruptHandler, CHANGE);
|
||||
// costs 112 bytes program memory + 4 bytes RAM
|
||||
attachInterrupt(digitalPinToInterrupt(IR_RECEIVE_PIN), IRPinChangeInterruptHandler, CHANGE);
|
||||
# else
|
||||
// 2.2 us more than version configured with macros and not compatible
|
||||
attachInterrupt(IR_INPUT_PIN, IRPinChangeInterruptHandler, CHANGE); // no extra pin mapping here
|
||||
attachInterrupt(IR_RECEIVE_PIN, IRPinChangeInterruptHandler, CHANGE); // no extra pin mapping here
|
||||
# endif
|
||||
|
||||
# if defined(LOCAL_DEBUG_ATTACH_INTERRUPT)
|
||||
Serial.println(F("Use attachInterrupt for pin=" STR(IR_INPUT_PIN)));
|
||||
Serial.println(F("Use attachInterrupt for pin=" STR(IR_RECEIVE_PIN)));
|
||||
# endif
|
||||
|
||||
#else
|
||||
# if defined(LOCAL_DEBUG_ATTACH_INTERRUPT)
|
||||
Serial.println(F("Use static interrupt for pin=" STR(IR_INPUT_PIN)));
|
||||
Serial.println(F("Use static interrupt for pin=" STR(IR_RECEIVE_PIN)));
|
||||
# endif
|
||||
# if defined(USE_INT0)
|
||||
// interrupt on any logical change
|
||||
|
@ -440,7 +595,7 @@ bool enablePCIInterruptForTinyReceiver() {
|
|||
|
||||
# elif defined(USE_PCIE) // For ATtiny85 etc.
|
||||
// use PinChangeInterrupt no INT0 for pin PB2
|
||||
PCMSK = _BV(IR_INPUT_PIN);
|
||||
PCMSK = _BV(IR_RECEIVE_PIN);
|
||||
// clear interrupt bit
|
||||
GIFR |= 1 << PCIF;
|
||||
// enable interrupt on next change
|
||||
|
@ -448,13 +603,13 @@ bool enablePCIInterruptForTinyReceiver() {
|
|||
|
||||
# elif defined(USE_PCINT0)
|
||||
PCICR |= _BV(PCIE0);
|
||||
PCMSK0 = digitalPinToBitMask(IR_INPUT_PIN);
|
||||
PCMSK0 = digitalPinToBitMask(IR_RECEIVE_PIN);
|
||||
# elif defined(USE_PCINT1)
|
||||
PCICR |= _BV(PCIE1);
|
||||
PCMSK1 = digitalPinToBitMask(IR_INPUT_PIN);
|
||||
PCMSK1 = digitalPinToBitMask(IR_RECEIVE_PIN);
|
||||
# elif defined(USE_PCINT2)
|
||||
PCICR |= _BV(PCIE2);
|
||||
PCMSK2 = digitalPinToBitMask(IR_INPUT_PIN);
|
||||
PCMSK2 = digitalPinToBitMask(IR_RECEIVE_PIN);
|
||||
# else
|
||||
return false;
|
||||
# endif
|
||||
|
@ -469,9 +624,9 @@ void disablePCIInterruptForTinyReceiver() {
|
|||
|
||||
#if defined(USE_ATTACH_INTERRUPT) || defined(USE_ATTACH_INTERRUPT_DIRECT)
|
||||
# if defined(USE_ATTACH_INTERRUPT)
|
||||
detachInterrupt(digitalPinToInterrupt(IR_INPUT_PIN));
|
||||
detachInterrupt(digitalPinToInterrupt(IR_RECEIVE_PIN));
|
||||
# else
|
||||
detachInterrupt(IR_INPUT_PIN);
|
||||
detachInterrupt(IR_RECEIVE_PIN);
|
||||
# endif
|
||||
|
||||
#else
|
||||
|
@ -541,4 +696,8 @@ void dummyFunctionToAvoidCompilerErrors()
|
|||
#if defined(LOCAL_TRACE_STATE_MACHINE)
|
||||
#undef LOCAL_TRACE_STATE_MACHINE
|
||||
#endif
|
||||
|
||||
#if defined(LOCAL_DEBUG)
|
||||
#undef LOCAL_DEBUG
|
||||
#endif
|
||||
#endif // _TINY_IR_RECEIVER_HPP
|
||||
|
|
|
@ -0,0 +1,347 @@
|
|||
/*
|
||||
* TinyIRSender.hpp
|
||||
*
|
||||
* Sends IR protocol data of NEC and FAST protocol using bit banging.
|
||||
* NEC is the protocol of most cheap remote controls for Arduino.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
************************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef _TINY_IR_SENDER_HPP
|
||||
#define _TINY_IR_SENDER_HPP
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
//#define ENABLE_NEC2_REPEATS // Instead of sending / receiving the NEC special repeat code, send / receive the original frame for repeat.
|
||||
|
||||
#if defined(DEBUG) && !defined(LOCAL_DEBUG)
|
||||
#define LOCAL_DEBUG
|
||||
#else
|
||||
//#define LOCAL_DEBUG // This enables debug output only for this file
|
||||
#endif
|
||||
#include "TinyIR.h" // Defines protocol timings
|
||||
|
||||
#include "digitalWriteFast.h"
|
||||
/** \addtogroup TinySender Minimal sender for NEC and FAST protocol
|
||||
* @{
|
||||
*/
|
||||
|
||||
#if !defined(IR_SEND_PIN)
|
||||
#warning "IR_SEND_PIN is not defined, so it is set to 3"
|
||||
#define IR_SEND_PIN 3
|
||||
#endif
|
||||
/*
|
||||
* Generate 38 kHz IR signal by bit banging
|
||||
*/
|
||||
void sendMark(uint8_t aSendPin, unsigned int aMarkMicros) {
|
||||
unsigned long tStartMicros = micros();
|
||||
unsigned long tNextPeriodEnding = tStartMicros;
|
||||
unsigned long tMicros;
|
||||
do {
|
||||
/*
|
||||
* Generate pulse
|
||||
*/
|
||||
noInterrupts(); // do not let interrupts extend the short on period
|
||||
digitalWriteFast(aSendPin, HIGH);
|
||||
delayMicroseconds(8); // 8 us for a 30 % duty cycle for 38 kHz
|
||||
digitalWriteFast(aSendPin, LOW);
|
||||
interrupts(); // Enable interrupts - to keep micros correct- for the longer off period 3.4 us until receive ISR is active (for 7 us + pop's)
|
||||
|
||||
/*
|
||||
* PWM pause timing and end check
|
||||
* Minimal pause duration is 4.3 us
|
||||
*/
|
||||
tNextPeriodEnding += 26; // for 38 kHz
|
||||
do {
|
||||
tMicros = micros(); // we have only 4 us resolution for AVR @16MHz
|
||||
/*
|
||||
* Exit the forever loop if aMarkMicros has reached
|
||||
*/
|
||||
unsigned int tDeltaMicros = tMicros - tStartMicros;
|
||||
#if defined(__AVR__)
|
||||
// Just getting variables and check for end condition takes minimal 3.8 us
|
||||
if (tDeltaMicros >= aMarkMicros - (112 / (F_CPU / MICROS_IN_ONE_SECOND))) { // To compensate for call duration - 112 is an empirical value
|
||||
#else
|
||||
if (tDeltaMicros >= aMarkMicros) {
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
} while (tMicros < tNextPeriodEnding);
|
||||
} while (true);
|
||||
}
|
||||
|
||||
/*
|
||||
* Send NEC with 16 bit address and command, even if aCommand < 0x100 (I.E. ONKYO)
|
||||
* @param aAddress - The 16 bit address to send.
|
||||
* @param aCommand - The 16 bit command to send.
|
||||
* @param aNumberOfRepeats - Number of repeats send at a period of 110 ms.
|
||||
* @param aSendNEC2Repeats - Instead of sending the NEC special repeat code, send the original frame for repeat.
|
||||
*/
|
||||
void sendONKYO(uint8_t aSendPin, uint16_t aAddress, uint16_t aCommand, uint_fast8_t aNumberOfRepeats, bool aSendNEC2Repeats) {
|
||||
pinModeFast(aSendPin, OUTPUT);
|
||||
|
||||
uint_fast8_t tNumberOfCommands = aNumberOfRepeats + 1;
|
||||
while (tNumberOfCommands > 0) {
|
||||
unsigned long tStartOfFrameMillis = millis();
|
||||
|
||||
sendMark(aSendPin, NEC_HEADER_MARK);
|
||||
if ((!aSendNEC2Repeats) && (tNumberOfCommands < aNumberOfRepeats + 1)) {
|
||||
// send the NEC special repeat
|
||||
delayMicroseconds(NEC_REPEAT_HEADER_SPACE); // - 2250
|
||||
} else {
|
||||
// send header
|
||||
delayMicroseconds(NEC_HEADER_SPACE);
|
||||
LongUnion tData;
|
||||
tData.UWord.LowWord = aAddress;
|
||||
tData.UWord.HighWord = aCommand;
|
||||
// Send data
|
||||
for (uint_fast8_t i = 0; i < NEC_BITS; ++i) {
|
||||
sendMark(aSendPin, NEC_BIT_MARK); // constant mark length
|
||||
if (tData.ULong & 1) {
|
||||
delayMicroseconds(NEC_ONE_SPACE);
|
||||
} else {
|
||||
delayMicroseconds(NEC_ZERO_SPACE);
|
||||
}
|
||||
tData.ULong >>= 1; // shift command for next bit
|
||||
}
|
||||
} // send stop bit
|
||||
sendMark(aSendPin, NEC_BIT_MARK);
|
||||
|
||||
tNumberOfCommands--;
|
||||
// skip last delay!
|
||||
if (tNumberOfCommands > 0) {
|
||||
/*
|
||||
* Check and fallback for wrong RepeatPeriodMillis parameter. I.e the repeat period must be greater than each frame duration.
|
||||
*/
|
||||
auto tFrameDurationMillis = millis() - tStartOfFrameMillis;
|
||||
if (NEC_REPEAT_PERIOD / 1000 > tFrameDurationMillis) {
|
||||
delay(NEC_REPEAT_PERIOD / 1000 - tFrameDurationMillis);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Send NEC with 8 or 16 bit address or command depending on the values of aAddress and aCommand.
|
||||
* @param aAddress - If aAddress < 0x100 send 8 bit address and 8 bit inverted address, else send 16 bit address.
|
||||
* @param aCommand - If aCommand < 0x100 send 8 bit command and 8 bit inverted command, else send 16 bit command.
|
||||
* @param aNumberOfRepeats - Number of repeats send at a period of 110 ms.
|
||||
* @param aSendNEC2Repeats - Instead of sending the NEC special repeat code, send the original frame for repeat.
|
||||
*/
|
||||
void sendNECMinimal(uint8_t aSendPin, uint16_t aAddress, uint16_t aCommand, uint_fast8_t aNumberOfRepeats) {
|
||||
sendNEC(aSendPin, aAddress, aCommand, aNumberOfRepeats); // sendNECMinimal() is deprecated
|
||||
}
|
||||
void sendNEC(uint8_t aSendPin, uint16_t aAddress, uint16_t aCommand, uint_fast8_t aNumberOfRepeats, bool aSendNEC2Repeats) {
|
||||
pinModeFast(aSendPin, OUTPUT);
|
||||
|
||||
uint_fast8_t tNumberOfCommands = aNumberOfRepeats + 1;
|
||||
while (tNumberOfCommands > 0) {
|
||||
unsigned long tStartOfFrameMillis = millis();
|
||||
|
||||
sendMark(aSendPin, NEC_HEADER_MARK);
|
||||
if ((!aSendNEC2Repeats) && (tNumberOfCommands < aNumberOfRepeats + 1)) {
|
||||
// send the NEC special repeat
|
||||
delayMicroseconds(NEC_REPEAT_HEADER_SPACE); // - 2250
|
||||
} else {
|
||||
// send header
|
||||
delayMicroseconds(NEC_HEADER_SPACE);
|
||||
LongUnion tData;
|
||||
/*
|
||||
* The compiler is intelligent and removes the code for "(aAddress > 0xFF)" if we are called with an uint8_t address :-).
|
||||
* Using an uint16_t address requires additional 28 bytes program memory.
|
||||
*/
|
||||
if (aAddress > 0xFF) {
|
||||
tData.UWord.LowWord = aAddress;
|
||||
} else {
|
||||
tData.UByte.LowByte = aAddress; // LSB first
|
||||
tData.UByte.MidLowByte = ~aAddress;
|
||||
}
|
||||
if (aCommand > 0xFF) {
|
||||
tData.UWord.HighWord = aCommand;
|
||||
} else {
|
||||
tData.UByte.MidHighByte = aCommand;
|
||||
tData.UByte.HighByte = ~aCommand; // LSB first
|
||||
}
|
||||
// Send data
|
||||
for (uint_fast8_t i = 0; i < NEC_BITS; ++i) {
|
||||
sendMark(aSendPin, NEC_BIT_MARK); // constant mark length
|
||||
|
||||
if (tData.ULong & 1) {
|
||||
delayMicroseconds(NEC_ONE_SPACE);
|
||||
} else {
|
||||
delayMicroseconds(NEC_ZERO_SPACE);
|
||||
}
|
||||
tData.ULong >>= 1; // shift command for next bit
|
||||
}
|
||||
} // send stop bit
|
||||
sendMark(aSendPin, NEC_BIT_MARK);
|
||||
|
||||
tNumberOfCommands--;
|
||||
// skip last delay!
|
||||
if (tNumberOfCommands > 0) {
|
||||
/*
|
||||
* Check and fallback for wrong RepeatPeriodMillis parameter. I.e the repeat period must be greater than each frame duration.
|
||||
*/
|
||||
auto tFrameDurationMillis = millis() - tStartOfFrameMillis;
|
||||
if (NEC_REPEAT_PERIOD / 1000 > tFrameDurationMillis) {
|
||||
delay(NEC_REPEAT_PERIOD / 1000 - tFrameDurationMillis);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Send Extended NEC with a forced 16 bit address and 8 or 16 bit command depending on the value of aCommand.
|
||||
* @param aAddress - Send 16 bit address.
|
||||
* @param aCommand - If aCommand < 0x100 send 8 bit command and 8 bit inverted command, else send 16 bit command.
|
||||
* @param aNumberOfRepeats - Number of repeats send at a period of 110 ms.
|
||||
* @param aSendNEC2Repeats - Instead of sending the NEC special repeat code, send the original frame for repeat.
|
||||
*/
|
||||
void sendExtendedNEC(uint8_t aSendPin, uint16_t aAddress, uint16_t aCommand, uint_fast8_t aNumberOfRepeats, bool aSendNEC2Repeats) {
|
||||
pinModeFast(aSendPin, OUTPUT);
|
||||
|
||||
uint_fast8_t tNumberOfCommands = aNumberOfRepeats + 1;
|
||||
while (tNumberOfCommands > 0) {
|
||||
unsigned long tStartOfFrameMillis = millis();
|
||||
|
||||
sendMark(aSendPin, NEC_HEADER_MARK);
|
||||
if ((!aSendNEC2Repeats) && (tNumberOfCommands < aNumberOfRepeats + 1)) {
|
||||
// send the NEC special repeat
|
||||
delayMicroseconds(NEC_REPEAT_HEADER_SPACE); // - 2250
|
||||
} else {
|
||||
// send header
|
||||
delayMicroseconds(NEC_HEADER_SPACE);
|
||||
LongUnion tData;
|
||||
tData.UWord.LowWord = aAddress;
|
||||
if (aCommand > 0xFF) {
|
||||
tData.UWord.HighWord = aCommand;
|
||||
} else {
|
||||
tData.UByte.MidHighByte = aCommand;
|
||||
tData.UByte.HighByte = ~aCommand; // LSB first
|
||||
}
|
||||
// Send data
|
||||
for (uint_fast8_t i = 0; i < NEC_BITS; ++i) {
|
||||
sendMark(aSendPin, NEC_BIT_MARK); // constant mark length
|
||||
|
||||
if (tData.ULong & 1) {
|
||||
delayMicroseconds(NEC_ONE_SPACE);
|
||||
} else {
|
||||
delayMicroseconds(NEC_ZERO_SPACE);
|
||||
}
|
||||
tData.ULong >>= 1; // shift command for next bit
|
||||
}
|
||||
} // send stop bit
|
||||
sendMark(aSendPin, NEC_BIT_MARK);
|
||||
|
||||
tNumberOfCommands--;
|
||||
// skip last delay!
|
||||
if (tNumberOfCommands > 0) {
|
||||
/*
|
||||
* Check and fallback for wrong RepeatPeriodMillis parameter. I.e the repeat period must be greater than each frame duration.
|
||||
*/
|
||||
auto tFrameDurationMillis = millis() - tStartOfFrameMillis;
|
||||
if (NEC_REPEAT_PERIOD / 1000 > tFrameDurationMillis) {
|
||||
delay(NEC_REPEAT_PERIOD / 1000 - tFrameDurationMillis);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* LSB first, send header, command, inverted command and stop bit
|
||||
*/
|
||||
void sendFast8BitAndParity(uint8_t aSendPin, uint8_t aCommand, uint_fast8_t aNumberOfRepeats) {
|
||||
sendFAST(aSendPin, aCommand, aNumberOfRepeats);
|
||||
}
|
||||
|
||||
/*
|
||||
* LSB first, send header, 16 bit command or 8 bit command, inverted command and stop bit
|
||||
*/
|
||||
void sendFAST(uint8_t aSendPin, uint16_t aCommand, uint_fast8_t aNumberOfRepeats) {
|
||||
pinModeFast(aSendPin, OUTPUT);
|
||||
|
||||
uint_fast8_t tNumberOfCommands = aNumberOfRepeats + 1;
|
||||
while (tNumberOfCommands > 0) {
|
||||
unsigned long tStartOfFrameMillis = millis();
|
||||
|
||||
// send header
|
||||
sendMark(aSendPin, FAST_HEADER_MARK);
|
||||
delayMicroseconds(FAST_HEADER_SPACE);
|
||||
uint16_t tData;
|
||||
/*
|
||||
* The compiler is intelligent and removes the code for "(aCommand > 0xFF)" if we are called with an uint8_t command :-).
|
||||
* Using an uint16_t command requires additional 56 bytes program memory.
|
||||
*/
|
||||
if (aCommand > 0xFF) {
|
||||
tData = aCommand;
|
||||
} else {
|
||||
tData = aCommand | (((uint8_t) (~aCommand)) << 8); // LSB first
|
||||
}
|
||||
// Send data
|
||||
for (uint_fast8_t i = 0; i < FAST_BITS; ++i) {
|
||||
sendMark(aSendPin, FAST_BIT_MARK); // constant mark length
|
||||
|
||||
if (tData & 1) {
|
||||
delayMicroseconds(FAST_ONE_SPACE);
|
||||
} else {
|
||||
delayMicroseconds(FAST_ZERO_SPACE);
|
||||
}
|
||||
tData >>= 1; // shift command for next bit
|
||||
}
|
||||
// send stop bit
|
||||
sendMark(aSendPin, FAST_BIT_MARK);
|
||||
|
||||
tNumberOfCommands--;
|
||||
// skip last delay!
|
||||
if (tNumberOfCommands > 0) {
|
||||
/*
|
||||
* Check and fallback for wrong RepeatPeriodMillis parameter. I.e the repeat period must be greater than each frame duration.
|
||||
*/
|
||||
auto tFrameDurationMillis = millis() - tStartOfFrameMillis;
|
||||
if (FAST_REPEAT_PERIOD / 1000 > tFrameDurationMillis) {
|
||||
delay(FAST_REPEAT_PERIOD / 1000 - tFrameDurationMillis);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** @}*/
|
||||
|
||||
#if defined(LOCAL_DEBUG)
|
||||
#undef LOCAL_DEBUG
|
||||
#endif
|
||||
#endif // _TINY_IR_SENDER_HPP
|
|
@ -258,7 +258,7 @@ void Aircondition_LG::sendIRCommand(uint16_t aCommand) {
|
|||
Serial.println(aCommand, BIN);
|
||||
#endif
|
||||
|
||||
IrSender.sendLG((uint8_t) LG_ADDRESS, aCommand, 0, false, useLG2Protocol);
|
||||
IrSender.sendLG2((uint8_t) LG_ADDRESS, aCommand, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -4,12 +4,14 @@
|
|||
* Optimized digital functions for AVR microcontrollers
|
||||
* by Watterott electronic (www.watterott.com)
|
||||
* based on https://code.google.com/p/digitalwritefast
|
||||
*
|
||||
* License: BSD 3-Clause License (https://opensource.org/licenses/BSD-3-Clause)
|
||||
*/
|
||||
|
||||
#ifndef __digitalWriteFast_h_
|
||||
#define __digitalWriteFast_h_ 1
|
||||
|
||||
//#define SANGUINO_PINOUT //define for Sanguino pinout
|
||||
//#define SANGUINO_PINOUT // define for Sanguino pinout
|
||||
|
||||
// general macros/defines
|
||||
#if !defined(BIT_READ)
|
||||
|
@ -25,122 +27,10 @@
|
|||
# define BIT_WRITE(value, bit, bitvalue) (bitvalue ? BIT_SET(value, bit) : BIT_CLEAR(value, bit))
|
||||
#endif
|
||||
|
||||
#if !defined(SWAP)
|
||||
# define SWAP(x,y) do{ (x)=(x)^(y); (y)=(x)^(y); (x)=(x)^(y); }while(0)
|
||||
#endif
|
||||
|
||||
#if !defined(DEC)
|
||||
# define DEC (10)
|
||||
#endif
|
||||
#if !defined(HEX)
|
||||
# define HEX (16)
|
||||
#endif
|
||||
#if !defined(OCT)
|
||||
# define OCT (8)
|
||||
#endif
|
||||
#if !defined(BIN)
|
||||
# define BIN (2)
|
||||
#endif
|
||||
|
||||
// workarounds for ARM microcontrollers
|
||||
#if (!defined(__AVR__) || \
|
||||
defined(ARDUINO_ARCH_SAM) || \
|
||||
defined(ARDUINO_ARCH_SAMD))
|
||||
|
||||
#if !defined(PROGMEM)
|
||||
# define PROGMEM
|
||||
#endif
|
||||
#if !defined(PGM_P)
|
||||
# define PGM_P const char *
|
||||
#endif
|
||||
#if !defined(PSTR)
|
||||
# define PSTR(str) (str)
|
||||
#endif
|
||||
|
||||
#if !defined(memcpy_P)
|
||||
# define memcpy_P(dest, src, num) memcpy((dest), (src), (num))
|
||||
#endif
|
||||
#if !defined(strcpy_P)
|
||||
# define strcpy_P(dst, src) strcpy((dst), (src))
|
||||
#endif
|
||||
#if !defined(strcat_P)
|
||||
# define strcat_P(dst, src) strcat((dst), (src))
|
||||
#endif
|
||||
#if !defined(strcmp_P)
|
||||
# define strcmp_P(a, b) strcmp((a), (b))
|
||||
#endif
|
||||
#if !defined(strcasecmp_P)
|
||||
# define strcasecmp_P(a, b) strcasecmp((a), (b))
|
||||
#endif
|
||||
#if !defined(strncmp_P)
|
||||
# define strncmp_P(a, b, n) strncmp((a), (b), (n))
|
||||
#endif
|
||||
#if !defined(strncasecmp_P)
|
||||
# define strncasecmp_P(a, b, n) strncasecmp((a), (b), (n))
|
||||
#endif
|
||||
#if !defined(strstr_P)
|
||||
# define strstr_P(a, b) strstr((a), (b))
|
||||
#endif
|
||||
#if !defined(strlen_P)
|
||||
# define strlen_P(a) strlen((a))
|
||||
#endif
|
||||
#if !defined(sprintf_P)
|
||||
# define sprintf_P(s, f, ...) sprintf((s), (f), __VA_ARGS__)
|
||||
#endif
|
||||
|
||||
#if !defined(pgm_read_byte)
|
||||
# define pgm_read_byte(addr) (*(const unsigned char *)(addr))
|
||||
#endif
|
||||
#if !defined(pgm_read_word)
|
||||
# define pgm_read_word(addr) (*(const unsigned short *)(addr))
|
||||
#endif
|
||||
#if !defined(pgm_read_dword)
|
||||
# define pgm_read_dword(addr) (*(const unsigned long *)(addr))
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
// digital functions
|
||||
//#if !defined(digitalPinToPortReg)
|
||||
#define SPI_SW_SS_PIN (10) //SS on Uno (for software SPI)
|
||||
#define SPI_SW_MOSI_PIN (11) //MOSI on Uno (for software SPI)
|
||||
#define SPI_SW_MISO_PIN (12) //MISO on Uno (for software SPI)
|
||||
#define SPI_SW_SCK_PIN (13) //SCK on Uno (for software SPI)
|
||||
|
||||
// --- Arduino Due and SAM3X8E based boards ---
|
||||
#if (defined(ARDUINO_SAM_DUE) || \
|
||||
defined(__SAM3X8E__))
|
||||
|
||||
#define UART_RX_PIN (0)
|
||||
#define UART_TX_PIN (1)
|
||||
|
||||
#define I2C_SDA_PIN (20)
|
||||
#define I2C_SCL_PIN (21)
|
||||
|
||||
#define SPI_HW_SS_PIN (78) //SS0:77, SS1:87, SS2:86, SS3:78
|
||||
#define SPI_HW_MOSI_PIN (75) //75
|
||||
#define SPI_HW_MISO_PIN (74) //74
|
||||
#define SPI_HW_SCK_PIN (76) //76
|
||||
|
||||
|
||||
// --- Arduino Zero and SAMD21G18 based boards ---
|
||||
#elif (defined(ARDUINO_SAMD_ZERO) || \
|
||||
defined(__SAMD21G18A__))
|
||||
|
||||
#define UART_RX_PIN (0)
|
||||
#define UART_TX_PIN (1)
|
||||
|
||||
#define I2C_SDA_PIN (16)
|
||||
#define I2C_SCL_PIN (17)
|
||||
|
||||
#define SPI_HW_SS_PIN (14) //14
|
||||
#define SPI_HW_MOSI_PIN (21) //21
|
||||
#define SPI_HW_MISO_PIN (18) //18
|
||||
#define SPI_HW_SCK_PIN (20) //20
|
||||
|
||||
#include <Arduino.h> // declarations for the fallback to digitalWrite(), digitalRead() etc.
|
||||
|
||||
// --- Arduino Mega and ATmega128x/256x based boards ---
|
||||
#elif (defined(ARDUINO_AVR_MEGA) || \
|
||||
#if (defined(ARDUINO_AVR_MEGA) || \
|
||||
defined(ARDUINO_AVR_MEGA1280) || \
|
||||
defined(ARDUINO_AVR_MEGA2560) || \
|
||||
defined(__AVR_ATmega1280__) || \
|
||||
|
@ -148,17 +38,6 @@
|
|||
defined(__AVR_ATmega2560__) || \
|
||||
defined(__AVR_ATmega2561__))
|
||||
|
||||
#define UART_RX_PIN (0) //PE0
|
||||
#define UART_TX_PIN (1) //PE1
|
||||
|
||||
#define I2C_SDA_PIN (20)
|
||||
#define I2C_SCL_PIN (21)
|
||||
|
||||
#define SPI_HW_SS_PIN (53) //PB0
|
||||
#define SPI_HW_MOSI_PIN (51) //PB2
|
||||
#define SPI_HW_MISO_PIN (50) //PB3
|
||||
#define SPI_HW_SCK_PIN (52) //PB1
|
||||
|
||||
#define __digitalPinToPortReg(P) \
|
||||
(((P) >= 22 && (P) <= 29) ? &PORTA : \
|
||||
((((P) >= 10 && (P) <= 13) || ((P) >= 50 && (P) <= 53)) ? &PORTB : \
|
||||
|
@ -230,17 +109,6 @@
|
|||
defined(__AVR_ATmega8535__)) && \
|
||||
!defined(BOBUINO_PINOUT)
|
||||
|
||||
#define UART_RX_PIN (8) //PD0
|
||||
#define UART_TX_PIN (9) //PD1
|
||||
|
||||
#define I2C_SDA_PIN (17) //PC1
|
||||
#define I2C_SCL_PIN (16) //PC0
|
||||
|
||||
#define SPI_HW_SS_PIN (4) //PB4
|
||||
#define SPI_HW_MOSI_PIN (5) //PB5
|
||||
#define SPI_HW_MISO_PIN (6) //PB6
|
||||
#define SPI_HW_SCK_PIN (7) //PB7
|
||||
|
||||
#if defined(__AVR_ATmega324PB__)
|
||||
#define __digitalPinToPortReg(P) \
|
||||
(((P) <= 7) ? &PORTB : (((P) >= 8 && (P) <= 15) ? &PORTD : (((P) >= 16 && (P) <= 23) ? &PORTC : (((P) >= 24 && (P) <= 31) ? &PORTA : &PORTE))))
|
||||
|
@ -255,7 +123,7 @@
|
|||
#define __digitalPinToBit(P) \
|
||||
(((P) <= 7) ? (P) : (((P) >= 8 && (P) <= 15) ? (P) - 8 : (((P) >= 16 && (P) <= 23) ? (P) - 16 : (((P) >= 16 && (P) <= 23) ? (P) - 24 : (P) - 32))))
|
||||
# endif
|
||||
#else
|
||||
#elif defined(PORTA)
|
||||
#define __digitalPinToPortReg(P) \
|
||||
(((P) <= 7) ? &PORTB : (((P) >= 8 && (P) <= 15) ? &PORTD : (((P) >= 16 && (P) <= 23) ? &PORTC : &PORTA)))
|
||||
#define __digitalPinToDDRReg(P) \
|
||||
|
@ -269,6 +137,20 @@
|
|||
#define __digitalPinToBit(P) \
|
||||
(((P) <= 7) ? (P) : (((P) >= 8 && (P) <= 15) ? (P) - 8 : (((P) >= 16 && (P) <= 23) ? (P) - 16 : (P) - 24)))
|
||||
# endif
|
||||
#else
|
||||
#define __digitalPinToPortReg(P) \
|
||||
(((P) <= 7) ? &PORTB : (((P) >= 8 && (P) <= 15) ? &PORTD : &PORTC))
|
||||
#define __digitalPinToDDRReg(P) \
|
||||
(((P) <= 7) ? &DDRB : (((P) >= 8 && (P) <= 15) ? &DDRD : &DDRC))
|
||||
#define __digitalPinToPINReg(P) \
|
||||
(((P) <= 7) ? &PINB : (((P) >= 8 && (P) <= 15) ? &PIND : &PINC))
|
||||
# if defined(SANGUINO_PINOUT)
|
||||
#define __digitalPinToBit(P) \
|
||||
(((P) <= 7) ? (P) : (((P) >= 8 && (P) <= 15) ? (P) - 8 : (((P) >= 16 && (P) <= 23) ? (P) - 16 : (7 - ((P) - 24)))))
|
||||
# else //MightyCore Pinout
|
||||
#define __digitalPinToBit(P) \
|
||||
(((P) <= 7) ? (P) : (((P) >= 8 && (P) <= 15) ? (P) - 8 : (((P) >= 16 && (P) <= 23) ? (P) - 16 : (P) - 24)))
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -277,16 +159,6 @@
|
|||
defined(__AVR_ATmega16U4__) || \
|
||||
defined(__AVR_ATmega32U4__))
|
||||
# if defined(TEENSYDUINO)
|
||||
#define UART_RX_PIN (7) //PD2
|
||||
#define UART_TX_PIN (8) //PD3
|
||||
|
||||
#define I2C_SDA_PIN (6) //PD1
|
||||
#define I2C_SCL_PIN (5) //PD0
|
||||
|
||||
#define SPI_HW_SS_PIN (0) //PB0
|
||||
#define SPI_HW_MOSI_PIN (2) //PB2
|
||||
#define SPI_HW_MISO_PIN (3) //PB3
|
||||
#define SPI_HW_SCK_PIN (1) //PB1
|
||||
|
||||
#define __digitalPinToPortReg(P) \
|
||||
((((P) <= 4) || ((P) >= 13 && (P) <= 15)) ? &PORTB : (((P) == 9 || (P) == 10) ? &PORTC : (((P) >= 16 && (P) <= 21)) ? &PORTF : &PORTD))
|
||||
|
@ -305,17 +177,6 @@
|
|||
(((P) <= 21) ? 21 - (P) : (P) - 18))))))))
|
||||
# else
|
||||
|
||||
#define UART_RX_PIN (0) //PD2
|
||||
#define UART_TX_PIN (1) //PD3
|
||||
|
||||
#define I2C_SDA_PIN (2) //PD1
|
||||
#define I2C_SCL_PIN (3) //PD0
|
||||
|
||||
#define SPI_HW_SS_PIN (17) //PB0
|
||||
#define SPI_HW_MOSI_PIN (16) //PB2
|
||||
#define SPI_HW_MISO_PIN (14) //PB3
|
||||
#define SPI_HW_SCK_PIN (15) //PB1
|
||||
|
||||
#define __digitalPinToPortReg(P) \
|
||||
((((P) <= 4) || (P) == 6 || (P) == 12 || (P) == 24 || (P) == 25 || (P) == 29) ? &PORTD : (((P) == 5 || (P) == 13) ? &PORTC : (((P) >= 18 && (P) <= 23)) ? &PORTF : (((P) == 7) ? &PORTE : &PORTB)))
|
||||
#define __digitalPinToDDRReg(P) \
|
||||
|
@ -346,17 +207,6 @@
|
|||
defined(__AVR_ATmega328P__) || \
|
||||
defined(__AVR_ATmega328PB__))
|
||||
|
||||
#define UART_RX_PIN (0) //PD0
|
||||
#define UART_TX_PIN (1) //PD1
|
||||
|
||||
#define I2C_SDA_PIN (18) //A4
|
||||
#define I2C_SCL_PIN (19) //A5
|
||||
|
||||
#define SPI_HW_SS_PIN (10) //PB0
|
||||
#define SPI_HW_MOSI_PIN (11) //PB2
|
||||
#define SPI_HW_MISO_PIN (12) //PB3
|
||||
#define SPI_HW_SCK_PIN (13) //PB1
|
||||
|
||||
#if defined(__AVR_ATmega48PB__) || defined(__AVR_ATmega88PB__) || defined(__AVR_ATmega168PB__) || defined(__AVR_ATmega328PB__)
|
||||
#define __digitalPinToPortReg(P) \
|
||||
(((P) <= 7) ? &PORTD : (((P) >= 8 && (P) <= 13) ? &PORTB : (((P) >= 14 && (P) <= 19) ? &PORTC : &PORTE)))
|
||||
|
@ -380,17 +230,6 @@
|
|||
// --- Arduino Uno WiFi Rev 2, Nano Every ---
|
||||
#elif defined(__AVR_ATmega4809__)
|
||||
|
||||
#define UART_RX_PIN (0) //PB0
|
||||
#define UART_TX_PIN (1) //PB1
|
||||
|
||||
#define I2C_SDA_PIN (22) //PA2
|
||||
#define I2C_SCL_PIN (23) //PA3
|
||||
|
||||
#define SPI_HW_SS_PIN (8) //PE3
|
||||
#define SPI_HW_MOSI_PIN (11) //PE0
|
||||
#define SPI_HW_MISO_PIN (12) //PE1
|
||||
#define SPI_HW_SCK_PIN (13) //PE2
|
||||
|
||||
#define __digitalPinToPortReg(P) \
|
||||
(((P) == 2 || (P) == 7 ) ? &VPORTA.OUT : ((P) == 5 || (P) == 9 || (P) == 10) ? &VPORTB.OUT : ((P) == 4) ? &VPORTC.OUT : (((P) >= 14 && (P) <= 17) || (P) == 20 || (P) == 21) ? &VPORTD.OUT : ((P) == 8 || (P) == 11 || (P) == 12 || (P) == 13) ? &VPORTE.OUT : &VPORTF.OUT)
|
||||
#define __digitalPinToDDRReg(P) \
|
||||
|
@ -404,12 +243,24 @@
|
|||
// TinyCore
|
||||
// https://raw.githubusercontent.com/xukangmin/TinyCore/master/avr/package/package_tinycore_index.json
|
||||
// https://docs.tinycore.dev/en/latest/
|
||||
#elif defined(__AVR_ATtiny1616__) || defined(__AVR_ATtiny3216__) || defined(__AVR_ATtiny3217__)
|
||||
#elif defined(__AVR_ATtiny1616__) || defined(__AVR_ATtiny3216__) || defined(__AVR_ATtiny3217__)
|
||||
#define __digitalPinToPortReg(P) ((P) <= 5 ? &VPORTB.OUT : ((P) <= 9 ? &VPORTC.OUT : ((P) <= 16 ? &VPORTA.OUT : ((P) <= 18 ? &VPORTB.OUT : &VPORTC.OUT))))
|
||||
#define __digitalPinToDDRReg(P) ((P) <= 5 ? &VPORTB.DIR : ((P) <= 9 ? &VPORTC.DIR : ((P) <= 16 ? &VPORTA.DIR : ((P) <= 18 ? &VPORTB.DIR : &VPORTC.DIR))))
|
||||
#define __digitalPinToPINReg(P) ((P) <= 5 ? &VPORTB.IN : ((P) <= 9 ? &VPORTC.IN : ((P) <= 16 ? &VPORTA.IN : ((P) <= 18 ? &VPORTB.IN : &VPORTC.IN))))
|
||||
#define __digitalPinToBit(P) ( (P) <= 3 ? (3 - P) : ((P) <= 5 ? (P) : ((P) <= 9 ? (P - 6) : ((P) <= 16 ? ((P) - 9) : ((P) <= 18 ? ((P) - 11) : ((P) - 15))))) )
|
||||
|
||||
#elif defined(__AVR_ATtiny1614__)
|
||||
#define __digitalPinToPortReg(P) ((P) <= 3 ? &VPORTA.OUT : ((P) <= 7 ? &VPORTB.OUT : &VPORTA.OUT))
|
||||
#define __digitalPinToDDRReg(P) ((P) <= 3 ? &VPORTA.DIR : ((P) <= 7 ? &VPORTB.DIR : &VPORTA.DIR))
|
||||
#define __digitalPinToPINReg(P) ((P) <= 3 ? &VPORTA.IN : ((P) <= 7 ? &VPORTB.IN : &VPORTA.IN))
|
||||
#define __digitalPinToBit(P) ( (P) <= 3 ? (P + 4) : ((P) <= 7 ? (7 - P) : ((P) <= 10 ? (P - 7) : (P) - 11)) )
|
||||
|
||||
#elif defined(__AVR_ATtiny816__)
|
||||
// https://github.com/Arduino-IRremote/Arduino-IRremote/discussions/1029
|
||||
#define __digitalPinToPortReg(P) ((P) <= 3 ? &VPORTA.OUT : ((P) <= 9 ? &VPORTB.OUT : ((P) <= 13 ? &VPORTC.OUT : ((P) <= 17 ? &VPORTA.OUT : &VPORTC.OUT))))
|
||||
#define __digitalPinToDDRReg(P) ((P) <= 3 ? &VPORTA.DIR : ((P) <= 9 ? &VPORTB.DIR : ((P) <= 13 ? &VPORTC.DIR : ((P) <= 17 ? &VPORTA.DIR : &VPORTC.DIR))))
|
||||
#define __digitalPinToPINReg(P) ((P) <= 3 ? &VPORTA.IN : ((P) <= 9 ? &VPORTB.IN : ((P) <= 13 ? &VPORTC.IN : ((P) <= 17 ? &VPORTA.IN : &VPORTC.IN))))
|
||||
#define __digitalPinToBit(P) ( (P) <= 3 ? (P + 4) : ((P) <= 9 ? (9 - P) : ((P) <= 13 ? (P - 10) : ((P) <= 16 ? (P - 13) : ((P) - 17)))) )
|
||||
|
||||
// --- ATtinyX5 ---
|
||||
#elif defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__)
|
||||
|
@ -436,7 +287,8 @@
|
|||
|
||||
|
||||
// --- ATtinyX4 + ATtinyX7 ---
|
||||
#elif defined(__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny87__) || defined(__AVR_ATtiny167__)
|
||||
#elif defined(__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__) \
|
||||
|| defined(__AVR_ATtiny441__) || defined(__AVR_ATtiny841__) || defined(__AVR_ATtiny87__) || defined(__AVR_ATtiny167__)
|
||||
# if defined(ARDUINO_AVR_DIGISPARKPRO) || PIN_PA7 == 5
|
||||
// Strange enumeration of pins on Digispark board and core library
|
||||
#define __digitalPinToPortReg(P) (((P) <= 4) ? &PORTB : &PORTA)
|
||||
|
@ -449,32 +301,40 @@
|
|||
#define __digitalPinToPortReg(P) (((P) <= 7) ? &PORTA : &PORTB)
|
||||
#define __digitalPinToDDRReg(P) (((P) <= 7) ? &DDRA : &DDRB)
|
||||
#define __digitalPinToPINReg(P) (((P) <= 7) ? &PINA : &PINB)
|
||||
# endif
|
||||
# if defined(__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny441__) || defined(__AVR_ATtiny841__)
|
||||
// https://github.com/SpenceKonde/ATTinyCore/blob/v2.0.0-devThis-is-the-head-submit-PRs-against-this/avr/variants/tinyx41_cw/pins_arduino.h#L334
|
||||
// Clockwise layout
|
||||
#define __digitalPinToBit(P) (((P) <= 7) ? (P) : ((P) == 11 ? (3) : 10 - (P)))
|
||||
# else
|
||||
#define __digitalPinToBit(P) (((P) <= 7) ? (P) : (P) - 8 )
|
||||
# endif
|
||||
|
||||
// --- Other ---
|
||||
#else
|
||||
|
||||
#define I2C_SDA_PIN SDA
|
||||
#define I2C_SCL_PIN SCL
|
||||
|
||||
#define SPI_HW_SS_PIN SS
|
||||
#define SPI_HW_MOSI_PIN MOSI
|
||||
#define SPI_HW_MISO_PIN MISO
|
||||
#define SPI_HW_SCK_PIN SCK
|
||||
|
||||
|
||||
#endif
|
||||
//#endif //#if !defined(digitalPinToPortReg)
|
||||
|
||||
|
||||
void NonConstantsUsedForPinModeFast( void ) __attribute__ (( error("Parameter for pinModeFast() function is not constant") ));
|
||||
void NonConstantsUsedForDigitalWriteFast( void ) __attribute__ (( error("Parameter for digitalWriteFast() function is not constant") ));
|
||||
void NonConstantsUsedForDigitalToggleFast( void ) __attribute__ (( error("Parameter for digitalToggleFast() function is not constant") ));
|
||||
int NonConstantsUsedForDigitalReadFast( void ) __attribute__ (( error("Parameter for digitalReadFast() function is not constant") ));
|
||||
|
||||
#if !defined(digitalWriteFast)
|
||||
# if (defined(__AVR__) || defined(ARDUINO_ARCH_AVR)) && defined(__digitalPinToPortReg)
|
||||
# if defined(THROW_ERROR_IF_NOT_FAST)
|
||||
#define digitalWriteFast(P, V) \
|
||||
if (__builtin_constant_p(P)) { \
|
||||
BIT_WRITE(*__digitalPinToPortReg(P), __digitalPinToBit(P), (V)); \
|
||||
} else { \
|
||||
NonConstantsUsedForDigitalWriteFast(); \
|
||||
}
|
||||
# else
|
||||
#define digitalWriteFast(P, V) \
|
||||
if (__builtin_constant_p(P)) { \
|
||||
BIT_WRITE(*__digitalPinToPortReg(P), __digitalPinToBit(P), (V)); \
|
||||
} else { \
|
||||
digitalWrite((P), (V)); \
|
||||
}
|
||||
# endif // defined(THROW_ERROR_IF_NOT_FAST)
|
||||
# else
|
||||
#define digitalWriteFast digitalWrite
|
||||
# endif
|
||||
|
@ -482,6 +342,19 @@ if (__builtin_constant_p(P)) { \
|
|||
|
||||
#if !defined(pinModeFast)
|
||||
# if (defined(__AVR__) || defined(ARDUINO_ARCH_AVR)) && defined(__digitalPinToPortReg)
|
||||
# if defined(THROW_ERROR_IF_NOT_FAST)
|
||||
#define pinModeFast(P, V) \
|
||||
if (__builtin_constant_p(P) && __builtin_constant_p(V)) { \
|
||||
if (V == INPUT_PULLUP) {\
|
||||
BIT_CLEAR(*__digitalPinToDDRReg(P), __digitalPinToBit(P)); \
|
||||
BIT_SET(*__digitalPinToPortReg(P), __digitalPinToBit(P)); \
|
||||
} else { \
|
||||
BIT_WRITE(*__digitalPinToDDRReg(P), __digitalPinToBit(P), (V)); \
|
||||
} \
|
||||
} else { \
|
||||
NonConstantsUsedForPinModeFast(); \
|
||||
}
|
||||
# else
|
||||
#define pinModeFast(P, V) \
|
||||
if (__builtin_constant_p(P) && __builtin_constant_p(V)) { \
|
||||
if (V == INPUT_PULLUP) {\
|
||||
|
@ -493,6 +366,7 @@ if (__builtin_constant_p(P) && __builtin_constant_p(V)) { \
|
|||
} else { \
|
||||
pinMode((P), (V)); \
|
||||
}
|
||||
# endif // defined(THROW_ERROR_IF_NOT_FAST)
|
||||
# else
|
||||
#define pinModeFast pinMode
|
||||
# endif
|
||||
|
@ -500,12 +374,21 @@ if (__builtin_constant_p(P) && __builtin_constant_p(V)) { \
|
|||
|
||||
#if !defined(digitalReadFast)
|
||||
# if (defined(__AVR__) || defined(ARDUINO_ARCH_AVR)) && defined(__digitalPinToPINReg)
|
||||
# if defined(THROW_ERROR_IF_NOT_FAST)
|
||||
#define digitalReadFast(P) ( (int) __digitalReadFast((P)) )
|
||||
// since we have return values, it is easier to implement it by ?:
|
||||
#define __digitalReadFast(P ) \
|
||||
(__builtin_constant_p(P) ) ? \
|
||||
(( BIT_READ(*__digitalPinToPINReg(P), __digitalPinToBit(P))) ? HIGH:LOW ) : \
|
||||
NonConstantsUsedForDigitalReadFast()
|
||||
# else
|
||||
#define digitalReadFast(P) ( (int) __digitalReadFast((P)) )
|
||||
// since we have return values, it is easier to implement it by ?:
|
||||
#define __digitalReadFast(P ) \
|
||||
(__builtin_constant_p(P) ) ? \
|
||||
(( BIT_READ(*__digitalPinToPINReg(P), __digitalPinToBit(P))) ? HIGH:LOW ) : \
|
||||
digitalRead((P))
|
||||
# endif // defined(THROW_ERROR_IF_NOT_FAST)
|
||||
# else
|
||||
#define digitalReadFast digitalRead
|
||||
# endif
|
||||
|
@ -513,12 +396,21 @@ if (__builtin_constant_p(P) && __builtin_constant_p(V)) { \
|
|||
|
||||
#if !defined(digitalToggleFast)
|
||||
# if (defined(__AVR__) || defined(ARDUINO_ARCH_AVR)) && defined(__digitalPinToPINReg)
|
||||
# if defined(THROW_ERROR_IF_NOT_FAST)
|
||||
#define digitalToggleFast(P) \
|
||||
if (__builtin_constant_p(P)) { \
|
||||
BIT_SET(*__digitalPinToPINReg(P), __digitalPinToBit(P)); \
|
||||
} else { \
|
||||
NonConstantsUsedForDigitalToggleFast(); \
|
||||
}
|
||||
# else
|
||||
#define digitalToggleFast(P) \
|
||||
if (__builtin_constant_p(P)) { \
|
||||
BIT_SET(*__digitalPinToPINReg(P), __digitalPinToBit(P)); \
|
||||
} else { \
|
||||
digitalWrite(P, ! digitalRead(P)); \
|
||||
}
|
||||
# endif // defined(THROW_ERROR_IF_NOT_FAST)
|
||||
# else
|
||||
#define digitalToggleFast(P) digitalWrite(P, ! digitalRead(P))
|
||||
# endif
|
||||
|
|
|
@ -0,0 +1,496 @@
|
|||
/*
|
||||
* ir_BangOlufsen.hpp
|
||||
*
|
||||
* Contains functions for receiving and sending Bang & Olufsen IR and Datalink '86 protocols
|
||||
* To receive B&O and ENABLE_BEO_WITHOUT_FRAME_GAP is NOT defined, you must set RECORD_GAP_MICROS to
|
||||
* at least 16000 to accommodate the unusually long 3. start space.
|
||||
*
|
||||
* This file is part of Arduino-IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
|
||||
*
|
||||
************************************************************************************
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2022-2023 Daniel Wallner and 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.
|
||||
*
|
||||
************************************************************************************
|
||||
*/
|
||||
#ifndef _IR_BANG_OLUFSEN_HPP
|
||||
#define _IR_BANG_OLUFSEN_HPP
|
||||
|
||||
//==============================================================================
|
||||
//
|
||||
//
|
||||
// Bang & Olufsen
|
||||
//
|
||||
//
|
||||
//==============================================================================
|
||||
// https://www.mikrocontroller.net/attachment/33137/datalink.pdf
|
||||
// https://www.mikrocontroller.net/articles/IRMP_-_english#B&O
|
||||
|
||||
// This protocol is unusual in two ways:
|
||||
|
||||
// 1. The carrier frequency is 455 kHz
|
||||
|
||||
// You can build your own receiver as Bang & Olufsen did (check old schematics) or use a TSOP7000
|
||||
// Vishay stopped producing TSOP7000 since 2009 so you will probably only find counterfeits:
|
||||
// https://www.vishay.com/files/whatsnew/doc/ff_FastFacts_CounterfeitTSOP7000_Dec72018.pdf
|
||||
// It is also likely that you will need an oscilloscope to debug a counterfeit TSOP7000
|
||||
// The specimen used to test this code was very noisy and had a very low output current
|
||||
// A somewhat working fix was to put a 4n7 capacitor across the output and ground followed by a pnp emitter follower
|
||||
// Other examples may require a different treatment
|
||||
// This particular receiver also did receive lower frequencies but rather poorly and with a lower delay than usual
|
||||
// If you need to parallel a receiver with another one you may need to delay the signal to get in phase with the other receiver
|
||||
|
||||
// 2. A stream of messages can be sent back to back with a new message immediately following the previous stop space
|
||||
|
||||
// It might be that this only happens over IR and not on the datalink protocol
|
||||
// You can choose to support this or not:
|
||||
|
||||
// Mode 1: Mode with gaps between frames
|
||||
// Set RECORD_GAP_MICROS to at least 16000 to accept the unusually long 3. start space
|
||||
// Can only receive single messages. Back to back repeats will result in overflow
|
||||
|
||||
// Mode 2: Break at start mode
|
||||
// Define ENABLE_BEO_WITHOUT_FRAME_GAP and set RECORD_GAP_MICROS to less than 15000
|
||||
// to treat the 3. start space of 15.5 ms as a gap between messages, which makes decoding easier :-).
|
||||
// The receiving of a transmission will then result in a dummy decode of the first 2 start bits with 0 bits data
|
||||
// followed by a 15.5 ms gap and a data frame with one start bit (originally sent as 4. start bit).
|
||||
// If the receiver is not resumed within a ms or so, partial messages will be decoded
|
||||
// Debug printing in the wrong place is very likely to break reception
|
||||
// Make sure to check the number of bits to filter dummy and incomplete messages
|
||||
|
||||
// !!! We assume that the real implementations never set the official first header bit to anything other than 0 !!!
|
||||
// !!! We therefore use 4 start bits instead of the specified 3 and in turn ignore the first header bit of the specification !!!
|
||||
|
||||
// IR messages are 16 bits long. Datalink messages have different lengths.
|
||||
// This implementation supports up to 40 bits total length split into 8 bit data/command and a header/address of variable length
|
||||
// Header data with more than 16 bits is stored in decodedIRData.extra
|
||||
|
||||
// B&O is a pulse distance protocol, but it has 3 bit values 0, 1 and (equal/repeat) as well as a special start and trailing bit.
|
||||
//
|
||||
// MSB first, 4 start bits + 8 to 16? bit address + 8 bit command + 1 special trailing bit + 1 stop bit.
|
||||
// Address can be longer than 8 bit.
|
||||
|
||||
/*
|
||||
* Options for this decoder
|
||||
*
|
||||
*/
|
||||
#define ENABLE_BEO_WITHOUT_FRAME_GAP // Requires additional 30 bytes program memory. Enabled by default, see https://github.com/Arduino-IRremote/Arduino-IRremote/discussions/1181
|
||||
//#define SUPPORT_BEO_DATALINK_TIMING_FOR_DECODE // This also supports headers up to 32 bit. Requires additional 150 bytes program memory.
|
||||
#if defined(DECODE_BEO)
|
||||
# if defined(ENABLE_BEO_WITHOUT_FRAME_GAP)
|
||||
# if RECORD_GAP_MICROS > 15000
|
||||
#warning If defined ENABLE_BEO_WITHOUT_FRAME_GAP, RECORD_GAP_MICROS must be set to <= 15000 by "#define RECORD_GAP_MICROS 13000"
|
||||
# endif
|
||||
# else
|
||||
# if RECORD_GAP_MICROS < 16000
|
||||
#error If not defined ENABLE_BEO_WITHOUT_FRAME_GAP, RECORD_GAP_MICROS must be set to a value >= 16000 by "#define RECORD_GAP_MICROS 16000"
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#define BEO_DATA_BITS 8 // Command or character
|
||||
|
||||
#define BEO_UNIT 3125 // All timings are in microseconds
|
||||
|
||||
#define BEO_IR_MARK 200 // The length of a mark in the IR protocol
|
||||
#define BEO_DATALINK_MARK (BEO_UNIT / 2) // The length of a mark in the Datalink protocol
|
||||
|
||||
#define BEO_PULSE_LENGTH_ZERO BEO_UNIT // The length of a one to zero transition
|
||||
#define BEO_PULSE_LENGTH_EQUAL (2 * BEO_UNIT) // 6250 The length of an equal bit
|
||||
#define BEO_PULSE_LENGTH_ONE (3 * BEO_UNIT) // 9375 The length of a zero to one transition
|
||||
#define BEO_PULSE_LENGTH_TRAILING_BIT (4 * BEO_UNIT) // 12500 The length of the stop bit
|
||||
#define BEO_PULSE_LENGTH_START_BIT (5 * BEO_UNIT) // 15625 The length of the start bit
|
||||
// It is not allowed to send two ones or zeros, you must send a one or zero and a equal instead.
|
||||
|
||||
//#define BEO_LOCAL_DEBUG
|
||||
//#define BEO_LOCAL_TRACE
|
||||
|
||||
#ifdef BEO_LOCAL_DEBUG
|
||||
# define BEO_DEBUG_PRINT(...) Serial.print(__VA_ARGS__)
|
||||
# define BEO_DEBUG_PRINTLN(...) Serial.println(__VA_ARGS__)
|
||||
#else
|
||||
# define BEO_DEBUG_PRINT(...) void()
|
||||
# define BEO_DEBUG_PRINTLN(...) void()
|
||||
#endif
|
||||
|
||||
#ifdef BEO_LOCAL_TRACE
|
||||
# undef BEO_TRACE_PRINT
|
||||
# undef BEO_TRACE_PRINTLN
|
||||
# define BEO_TRACE_PRINT(...) Serial.print(__VA_ARGS__)
|
||||
# define BEO_TRACE_PRINTLN(...) Serial.println(__VA_ARGS__)
|
||||
#else
|
||||
# define BEO_TRACE_PRINT(...) void()
|
||||
# define BEO_TRACE_PRINTLN(...) void()
|
||||
#endif
|
||||
|
||||
/************************************
|
||||
* Start of send and decode functions
|
||||
************************************/
|
||||
|
||||
/*
|
||||
* TODO aNumberOfRepeats are handled not correctly if ENABLE_BEO_WITHOUT_FRAME_GAP is defined
|
||||
*/
|
||||
void IRsend::sendBangOlufsen(uint16_t aHeader, uint8_t aData, int_fast8_t aNumberOfRepeats, int8_t aNumberOfHeaderBits) {
|
||||
for (int_fast8_t i = 0; i < aNumberOfRepeats + 1; ++i) {
|
||||
sendBangOlufsenRaw((uint32_t(aHeader) << 8) | aData, aNumberOfHeaderBits + 8, i != 0);
|
||||
}
|
||||
}
|
||||
|
||||
void IRsend::sendBangOlufsenDataLink(uint32_t aHeader, uint8_t aData, int_fast8_t aNumberOfRepeats, int8_t aNumberOfHeaderBits) {
|
||||
for (int_fast8_t i = 0; i < aNumberOfRepeats + 1; ++i) {
|
||||
sendBangOlufsenRawDataLink((uint64_t(aHeader) << 8) | aData, aNumberOfHeaderBits + 8, i != 0, true);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* @param aBackToBack If true send data back to back, which cannot be decoded if ENABLE_BEO_WITHOUT_FRAME_GAP is NOT defined
|
||||
*/
|
||||
void IRsend::sendBangOlufsenRaw(uint32_t aRawData, int_fast8_t aBits, bool aBackToBack) {
|
||||
#if defined(USE_NO_SEND_PWM) || defined(SEND_PWM_BY_TIMER) || BEO_KHZ == 38 // BEO_KHZ == 38 is for unit test which runs the B&O protocol with 38 kHz
|
||||
|
||||
/*
|
||||
* 455 kHz PWM is currently only supported with SEND_PWM_BY_TIMER defined, otherwise maximum is 180 kHz
|
||||
*/
|
||||
# if !defined(USE_NO_SEND_PWM)
|
||||
# if defined(SEND_PWM_BY_TIMER)
|
||||
enableHighFrequencyIROut (BEO_KHZ);
|
||||
# elif (BEO_KHZ == 38)
|
||||
enableIROut (BEO_KHZ); // currently only for unit test
|
||||
# endif
|
||||
# endif
|
||||
|
||||
// AGC / Start - 3 bits + first constant 0 header bit described in the official documentation
|
||||
if (!aBackToBack) {
|
||||
mark(BEO_IR_MARK);
|
||||
}
|
||||
space(BEO_PULSE_LENGTH_ZERO - BEO_IR_MARK);
|
||||
mark(BEO_IR_MARK);
|
||||
space(BEO_PULSE_LENGTH_ZERO - BEO_IR_MARK);
|
||||
mark(BEO_IR_MARK);
|
||||
space(BEO_PULSE_LENGTH_START_BIT - BEO_IR_MARK);
|
||||
|
||||
// First bit of header is assumed to be a constant 0 to have a fixed state to begin with the equal decisions.
|
||||
// So this first 0 is treated as the last bit of AGC
|
||||
mark(BEO_IR_MARK);
|
||||
space(BEO_PULSE_LENGTH_ZERO - BEO_IR_MARK);
|
||||
bool tLastBitValueWasOne = false;
|
||||
|
||||
// Header / Data
|
||||
uint32_t mask = 1UL << (aBits - 1);
|
||||
for (; mask; mask >>= 1) {
|
||||
if (tLastBitValueWasOne && !(aRawData & mask)) {
|
||||
mark(BEO_IR_MARK);
|
||||
space(BEO_PULSE_LENGTH_ZERO - BEO_IR_MARK);
|
||||
tLastBitValueWasOne = false;
|
||||
} else if (!tLastBitValueWasOne && (aRawData & mask)) {
|
||||
mark(BEO_IR_MARK);
|
||||
space(BEO_PULSE_LENGTH_ONE - BEO_IR_MARK);
|
||||
tLastBitValueWasOne = true;
|
||||
} else {
|
||||
mark(BEO_IR_MARK);
|
||||
space(BEO_PULSE_LENGTH_EQUAL - BEO_IR_MARK);
|
||||
}
|
||||
}
|
||||
|
||||
// Stop
|
||||
mark(BEO_IR_MARK);
|
||||
space(BEO_PULSE_LENGTH_TRAILING_BIT - BEO_IR_MARK);
|
||||
mark(BEO_IR_MARK);
|
||||
|
||||
#else
|
||||
(void) aRawData;
|
||||
(void) aBits;
|
||||
(void) aBackToBack;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* Version with 64 bit aRawData, which can send both timings, but costs more program memory
|
||||
* @param aBackToBack If true send data back to back, which cannot be decoded if ENABLE_BEO_WITHOUT_FRAME_GAP is NOT defined
|
||||
* @param aUseDatalinkTiming if false it does the same as sendBangOlufsenRaw()
|
||||
*/
|
||||
void IRsend::sendBangOlufsenRawDataLink(uint64_t aRawData, int_fast8_t aBits, bool aBackToBack, bool aUseDatalinkTiming) {
|
||||
#if defined(USE_NO_SEND_PWM) || BEO_KHZ == 38 // BEO_KHZ == 38 is for unit test which runs the B&O protocol with 38 kHz instead 0f 455 kHz
|
||||
uint16_t tSendBEOMarkLength = aUseDatalinkTiming ? BEO_DATALINK_MARK : BEO_IR_MARK;
|
||||
|
||||
/*
|
||||
* 455 kHz PWM is currently not supported, maximum is 180 kHz
|
||||
*/
|
||||
#if !defined(USE_NO_SEND_PWM)
|
||||
enableIROut (BEO_KHZ);
|
||||
#endif
|
||||
|
||||
// AGC / Start - 3 bits + first constant 0 header bit described in the official documentation
|
||||
if (!aBackToBack) {
|
||||
mark(tSendBEOMarkLength);
|
||||
}
|
||||
space(BEO_PULSE_LENGTH_ZERO - tSendBEOMarkLength);
|
||||
mark(tSendBEOMarkLength);
|
||||
space(BEO_PULSE_LENGTH_ZERO - tSendBEOMarkLength);
|
||||
mark(tSendBEOMarkLength);
|
||||
space(BEO_PULSE_LENGTH_START_BIT - tSendBEOMarkLength);
|
||||
|
||||
// First bit of header is assumed to be a constant 0 to have a fixed state to begin with the equal decisions.
|
||||
// So this first 0 is treated as the last bit of AGC
|
||||
mark(tSendBEOMarkLength);
|
||||
space(BEO_PULSE_LENGTH_ZERO - tSendBEOMarkLength);
|
||||
bool tLastBitValueWasOne = false;
|
||||
|
||||
// Header / Data
|
||||
uint32_t mask = 1UL << (aBits - 1);
|
||||
for (; mask; mask >>= 1) {
|
||||
if (tLastBitValueWasOne && !(aRawData & mask)) {
|
||||
mark(tSendBEOMarkLength);
|
||||
space(BEO_PULSE_LENGTH_ZERO - tSendBEOMarkLength);
|
||||
tLastBitValueWasOne = false;
|
||||
} else if (!tLastBitValueWasOne && (aRawData & mask)) {
|
||||
mark(tSendBEOMarkLength);
|
||||
space(BEO_PULSE_LENGTH_ONE - tSendBEOMarkLength);
|
||||
tLastBitValueWasOne = true;
|
||||
} else {
|
||||
mark(tSendBEOMarkLength);
|
||||
space(BEO_PULSE_LENGTH_EQUAL - tSendBEOMarkLength);
|
||||
}
|
||||
}
|
||||
|
||||
// Stop
|
||||
mark(tSendBEOMarkLength);
|
||||
space(BEO_PULSE_LENGTH_TRAILING_BIT - tSendBEOMarkLength);
|
||||
mark(tSendBEOMarkLength);
|
||||
|
||||
#else
|
||||
(void) aRawData;
|
||||
(void) aBits;
|
||||
(void) aUseDatalinkTiming;
|
||||
(void) aBackToBack;
|
||||
#endif
|
||||
}
|
||||
|
||||
#define BEO_MATCH_DELTA (BEO_UNIT / 2 - MICROS_PER_TICK)
|
||||
static bool matchBeoLength(uint16_t aMeasuredTicks, uint16_t aMatchValueMicros) {
|
||||
const uint16_t tMeasuredMicros = aMeasuredTicks * MICROS_PER_TICK;
|
||||
return aMatchValueMicros - BEO_MATCH_DELTA < tMeasuredMicros && tMeasuredMicros < aMatchValueMicros + BEO_MATCH_DELTA;
|
||||
}
|
||||
|
||||
bool IRrecv::decodeBangOlufsen() {
|
||||
#if defined(ENABLE_BEO_WITHOUT_FRAME_GAP)
|
||||
if (decodedIRData.rawlen != 6 && decodedIRData.rawlen < 36) { // 16 bits minimum
|
||||
#else
|
||||
if (decodedIRData.rawlen < 44) { // 16 bits minimum
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
#if defined(SUPPORT_BEO_DATALINK_TIMING_FOR_DECODE)
|
||||
uint16_t protocolMarkLength = 0; // contains BEO_IR_MARK or BEO_DATALINK_MARK depending of 4. mark received
|
||||
uint64_t tDecodedRawData = 0;
|
||||
#else
|
||||
uint32_t tDecodedRawData = 0;
|
||||
#endif
|
||||
uint8_t tLastDecodedBitValue = 0; // the last start bit is assumed to be zero
|
||||
uint8_t tPulseNumber = 0;
|
||||
uint8_t tBitNumber = 0;
|
||||
|
||||
BEO_TRACE_PRINT(F("Pre gap: "));
|
||||
BEO_TRACE_PRINT(decodedIRData.initialGap * 50);
|
||||
BEO_TRACE_PRINT(F(" raw len: "));
|
||||
BEO_TRACE_PRINTLN(decodedIRData.rawlen);
|
||||
|
||||
#if defined(ENABLE_BEO_WITHOUT_FRAME_GAP)
|
||||
/*
|
||||
* Check if we have the AGC part of the first frame, i.e. start bit 1 and 2.
|
||||
*/
|
||||
if (decodedIRData.rawlen == 6) {
|
||||
if ((matchMark(decodedIRData.rawDataPtr->rawbuf[3], BEO_IR_MARK)
|
||||
|| matchMark(decodedIRData.rawDataPtr->rawbuf[3], BEO_DATALINK_MARK))
|
||||
&& (matchSpace(decodedIRData.rawDataPtr->rawbuf[4], BEO_PULSE_LENGTH_ZERO - BEO_IR_MARK)
|
||||
|| matchSpace(decodedIRData.rawDataPtr->rawbuf[4], BEO_PULSE_LENGTH_ZERO - BEO_DATALINK_MARK))) {
|
||||
BEO_TRACE_PRINT(::getProtocolString(BANG_OLUFSEN));
|
||||
BEO_TRACE_PRINTLN(F("B&O: AGC only part (start bits 1 + 2 of 4) detected"));
|
||||
} else {
|
||||
return false; // no B&O protocol
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
* Check if leading gap is trailing bit of first frame
|
||||
*/
|
||||
if (!matchSpace(decodedIRData.initialGap, BEO_PULSE_LENGTH_START_BIT)) {
|
||||
BEO_TRACE_PRINT(::getProtocolString(BANG_OLUFSEN));
|
||||
BEO_TRACE_PRINTLN(F(": Leading gap is wrong")); // Leading gap is trailing bit of first frame
|
||||
return false; // no B&O protocol
|
||||
}
|
||||
|
||||
if (matchMark(decodedIRData.rawDataPtr->rawbuf[1], BEO_IR_MARK)) {
|
||||
# if defined(SUPPORT_BEO_DATALINK_TIMING_FOR_DECODE)
|
||||
protocolMarkLength = BEO_IR_MARK;
|
||||
} else if (matchMark(decodedIRData.rawDataPtr->rawbuf[1], BEO_DATALINK_MARK)) {
|
||||
protocolMarkLength = BEO_DATALINK_MARK;
|
||||
# endif
|
||||
} else {
|
||||
BEO_TRACE_PRINT(::getProtocolString(BANG_OLUFSEN));
|
||||
BEO_TRACE_PRINTLN(F(": mark length is wrong"));
|
||||
return false;
|
||||
}
|
||||
|
||||
// skip first zero header bit
|
||||
for (uint8_t tRawBufferMarkIndex = 3; tRawBufferMarkIndex < decodedIRData.rawlen; tRawBufferMarkIndex += 2) {
|
||||
#else
|
||||
for (uint8_t tRawBufferMarkIndex = 1; tRawBufferMarkIndex < decodedIRData.rawlen; tRawBufferMarkIndex += 2) {
|
||||
#endif // defined(ENABLE_BEO_WITHOUT_FRAME_GAP)
|
||||
|
||||
uint16_t markLength = decodedIRData.rawDataPtr->rawbuf[tRawBufferMarkIndex];
|
||||
uint16_t spaceLength = decodedIRData.rawDataPtr->rawbuf[tRawBufferMarkIndex + 1];
|
||||
|
||||
BEO_TRACE_PRINT(tPulseNumber);
|
||||
BEO_TRACE_PRINT(' ');
|
||||
BEO_TRACE_PRINT(markLength * MICROS_PER_TICK);
|
||||
BEO_TRACE_PRINT(' ');
|
||||
BEO_TRACE_PRINT(spaceLength * MICROS_PER_TICK);
|
||||
BEO_TRACE_PRINT(F(" ("));
|
||||
BEO_TRACE_PRINT((markLength + spaceLength) * MICROS_PER_TICK);
|
||||
BEO_TRACE_PRINTLN(F(") "));
|
||||
|
||||
#if !defined(ENABLE_BEO_WITHOUT_FRAME_GAP)
|
||||
/*
|
||||
* Handle the first 4 start bits
|
||||
* Check if the 3. bit is the long start bit. If we see the long start bit earlier, synchronize bit counter.
|
||||
*/
|
||||
if (tPulseNumber < 4) {
|
||||
if (tPulseNumber < 2) {
|
||||
// bit 0 and 1
|
||||
if (matchSpace(spaceLength, BEO_PULSE_LENGTH_START_BIT - BEO_IR_MARK)) {
|
||||
BEO_TRACE_PRINTLN(F(": detected long start bit -> synchronize state now"));
|
||||
tPulseNumber = 2;
|
||||
}
|
||||
} else {
|
||||
if (tPulseNumber == 3) {
|
||||
if (matchMark(markLength, BEO_IR_MARK)) {
|
||||
# if defined(SUPPORT_BEO_DATALINK_TIMING_FOR_DECODE)
|
||||
protocolMarkLength = BEO_IR_MARK;
|
||||
} else if (matchMark(markLength, BEO_DATALINK_MARK)) {
|
||||
protocolMarkLength = BEO_DATALINK_MARK;
|
||||
# endif
|
||||
} else {
|
||||
BEO_DEBUG_PRINT(::getProtocolString(BANG_OLUFSEN));
|
||||
BEO_DEBUG_PRINTLN(F(": 4. (start) mark length is wrong"));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// bit 2 and 3
|
||||
if (!matchBeoLength(markLength + spaceLength,
|
||||
(tPulseNumber == 2) ? BEO_PULSE_LENGTH_START_BIT : BEO_PULSE_LENGTH_ZERO)) {
|
||||
BEO_DEBUG_PRINT(::getProtocolString(BANG_OLUFSEN));
|
||||
BEO_DEBUG_PRINTLN(F(": Start length is wrong"));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
#endif // !defined(ENABLE_BEO_WITHOUT_FRAME_GAP)
|
||||
|
||||
/*
|
||||
* Decode header / data
|
||||
* First check for length of mark
|
||||
*/
|
||||
#if defined(SUPPORT_BEO_DATALINK_TIMING_FOR_DECODE)
|
||||
if (!matchMark(markLength, protocolMarkLength)) {
|
||||
#else
|
||||
if (!matchMark(markLength, BEO_IR_MARK)) {
|
||||
#endif
|
||||
BEO_DEBUG_PRINT(::getProtocolString(BANG_OLUFSEN));
|
||||
BEO_DEBUG_PRINTLN(F(": Mark length is wrong"));
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Check for stop after receiving at least 8 bits for data and 4 bits for header
|
||||
*/
|
||||
if (tBitNumber > BEO_DATA_BITS + 4) {
|
||||
if (matchBeoLength(markLength + spaceLength, BEO_PULSE_LENGTH_TRAILING_BIT)) {
|
||||
BEO_DEBUG_PRINT(::getProtocolString(BANG_OLUFSEN));
|
||||
BEO_DEBUG_PRINTLN(F(": Trailing bit detected"));
|
||||
break;
|
||||
}
|
||||
#if !defined(ENABLE_BEO_WITHOUT_FRAME_GAP)
|
||||
if (tRawBufferMarkIndex >= decodedIRData.rawlen - 3) { // (rawlen - 3) is index of trailing bit mark
|
||||
BEO_DEBUG_PRINT(::getProtocolString(BANG_OLUFSEN));
|
||||
BEO_DEBUG_PRINTLN(F(": End of buffer, but no trailing bit detected"));
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* Decode bit
|
||||
*/
|
||||
if (tLastDecodedBitValue == 0 && matchBeoLength(markLength + spaceLength, BEO_PULSE_LENGTH_ONE)) {
|
||||
tLastDecodedBitValue = 1;
|
||||
} else if (tLastDecodedBitValue == 1 && matchBeoLength(markLength + spaceLength, BEO_PULSE_LENGTH_ZERO)) {
|
||||
tLastDecodedBitValue = 0;
|
||||
} else if (!matchBeoLength(markLength + spaceLength, BEO_PULSE_LENGTH_EQUAL)) {
|
||||
BEO_DEBUG_PRINT(::getProtocolString(BANG_OLUFSEN));
|
||||
BEO_DEBUG_PRINT(F(": Index="));
|
||||
BEO_DEBUG_PRINT(tRawBufferMarkIndex);
|
||||
BEO_DEBUG_PRINT(F(" Length "));
|
||||
BEO_DEBUG_PRINT((markLength + spaceLength) * MICROS_PER_TICK);
|
||||
BEO_DEBUG_PRINTLN(F(" is wrong"));
|
||||
return false;
|
||||
}
|
||||
tDecodedRawData <<= 1;
|
||||
tDecodedRawData |= tLastDecodedBitValue;
|
||||
++tBitNumber;
|
||||
BEO_TRACE_PRINT(F("Bits "));
|
||||
BEO_TRACE_PRINT(tBitNumber);
|
||||
BEO_TRACE_PRINT(F(" "));
|
||||
BEO_TRACE_PRINT(uint32_t(tDecodedRawData >> BEO_DATA_BITS), HEX);
|
||||
BEO_TRACE_PRINT(F(" "));
|
||||
BEO_TRACE_PRINTLN(uint8_t(tDecodedRawData & ((1 << BEO_DATA_BITS) - 1)), HEX);
|
||||
// End of bit decode
|
||||
#if !defined(ENABLE_BEO_WITHOUT_FRAME_GAP)
|
||||
}
|
||||
|
||||
#else
|
||||
/*
|
||||
* Check for last bit after decoding it
|
||||
*/
|
||||
if (tRawBufferMarkIndex >= decodedIRData.rawlen - 3) { // (rawlen - 3) is index of last bit mark
|
||||
BEO_TRACE_PRINT(::getProtocolString(BANG_OLUFSEN));
|
||||
BEO_TRACE_PRINTLN(F(": Last bit reached"));
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
++tPulseNumber;
|
||||
}
|
||||
#if defined(ENABLE_BEO_WITHOUT_FRAME_GAP)
|
||||
}
|
||||
#endif
|
||||
|
||||
decodedIRData.protocol = BANG_OLUFSEN;
|
||||
decodedIRData.address = tDecodedRawData >> BEO_DATA_BITS; // lower header tBitNumber
|
||||
decodedIRData.command = tDecodedRawData & ((1 << BEO_DATA_BITS) - 1); // lower 8 tBitNumber
|
||||
decodedIRData.extra = tDecodedRawData >> (BEO_DATA_BITS + 16); // upper header tBitNumber
|
||||
decodedIRData.numberOfBits = tBitNumber;
|
||||
decodedIRData.flags = IRDATA_FLAGS_IS_MSB_FIRST;
|
||||
decodedIRData.decodedRawData = tDecodedRawData;
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif // _IR_BANG_OLUFSEN_HPP
|
|
@ -9,10 +9,11 @@
|
|||
#ifndef _IR_BOSEWAVE_HPP
|
||||
#define _IR_BOSEWAVE_HPP
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
//#define DEBUG // Activate this for lots of lovely debug output from this decoder.
|
||||
#include "IRremoteInt.h" // evaluates the DEBUG for IR_DEBUG_PRINT
|
||||
#if defined(DEBUG) && !defined(LOCAL_DEBUG)
|
||||
#define LOCAL_DEBUG
|
||||
#else
|
||||
//#define LOCAL_DEBUG // This enables debug output only for this file
|
||||
#endif
|
||||
|
||||
/** \addtogroup Decoder Decoders and encoders for different protocols
|
||||
* @{
|
||||
|
@ -29,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!)
|
||||
|
@ -41,55 +42,54 @@
|
|||
#define BOSEWAVE_ZERO_SPACE 468 // 468 are 18 clock periods
|
||||
#define BOSEWAVE_ONE_SPACE 1468 // 1468(measured), 1456 are 56 clock periods
|
||||
|
||||
#define BOSEWAVE_REPEAT_PERIOD 75000
|
||||
#define BOSEWAVE_REPEAT_SPACE 50000
|
||||
#define BOSEWAVE_REPEAT_PERIOD 75000
|
||||
#define BOSEWAVE_REPEAT_DISTANCE 50000
|
||||
#define BOSEWAVE_MAXIMUM_REPEAT_DISTANCE 62000
|
||||
|
||||
//+=============================================================================
|
||||
struct PulseDistanceWidthProtocolConstants BoseWaveProtocolConstants = { BOSEWAVE, BOSEWAVE_KHZ, BOSEWAVE_HEADER_MARK,
|
||||
BOSEWAVE_HEADER_SPACE, BOSEWAVE_BIT_MARK, BOSEWAVE_ONE_SPACE, BOSEWAVE_BIT_MARK, BOSEWAVE_ZERO_SPACE, PROTOCOL_IS_LSB_FIRST
|
||||
, (BOSEWAVE_REPEAT_PERIOD / MICROS_IN_ONE_MILLI), NULL };
|
||||
|
||||
void IRsend::sendBoseWave(uint8_t aCommand, uint_fast8_t aNumberOfRepeats) {
|
||||
/************************************
|
||||
* Start of send and decode functions
|
||||
************************************/
|
||||
|
||||
void IRsend::sendBoseWave(uint8_t aCommand, int_fast8_t aNumberOfRepeats) {
|
||||
|
||||
// send 8 command bits and then 8 inverted command bits LSB first
|
||||
uint16_t tData = ((~aCommand) << 8) | aCommand;
|
||||
sendPulseDistanceWidth(BOSEWAVE_KHZ, BOSEWAVE_HEADER_MARK, BOSEWAVE_HEADER_SPACE, BOSEWAVE_BIT_MARK, BOSEWAVE_ONE_SPACE,
|
||||
BOSEWAVE_BIT_MARK, BOSEWAVE_ZERO_SPACE, tData, BOSEWAVE_BITS, PROTOCOL_IS_LSB_FIRST, SEND_STOP_BIT,
|
||||
BOSEWAVE_REPEAT_PERIOD / MICROS_IN_ONE_MILLI, aNumberOfRepeats);
|
||||
sendPulseDistanceWidth(&BoseWaveProtocolConstants, tData, BOSEWAVE_BITS, aNumberOfRepeats);
|
||||
}
|
||||
|
||||
//+=============================================================================
|
||||
bool IRrecv::decodeBoseWave() {
|
||||
|
||||
// Check header "mark"
|
||||
if (!matchMark(decodedIRData.rawDataPtr->rawbuf[1], BOSEWAVE_HEADER_MARK)) {
|
||||
// no debug output, since this check is mainly to determine the received protocol
|
||||
if (!checkHeader(&BoseWaveProtocolConstants)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check we have enough data +4 for initial gap, start bit mark and space + stop bit mark
|
||||
if (decodedIRData.rawDataPtr->rawlen != (2 * BOSEWAVE_BITS) + 4) {
|
||||
if (decodedIRData.rawlen != (2 * BOSEWAVE_BITS) + 4) {
|
||||
IR_DEBUG_PRINT(F("Bose: "));
|
||||
IR_DEBUG_PRINT(F("Data length="));
|
||||
IR_DEBUG_PRINT(decodedIRData.rawDataPtr->rawlen);
|
||||
IR_DEBUG_PRINT(decodedIRData.rawlen);
|
||||
IR_DEBUG_PRINTLN(F(" is not 36"));
|
||||
return false;
|
||||
}
|
||||
// Check header "space"
|
||||
if (!matchSpace(decodedIRData.rawDataPtr->rawbuf[2], BOSEWAVE_HEADER_SPACE)) {
|
||||
IR_DEBUG_PRINT(F("Bose: "));
|
||||
IR_DEBUG_PRINTLN(F("Header space length is wrong"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!decodePulseDistanceData(BOSEWAVE_BITS, 3, BOSEWAVE_BIT_MARK, BOSEWAVE_ONE_SPACE, BOSEWAVE_ZERO_SPACE,
|
||||
PROTOCOL_IS_LSB_FIRST)) {
|
||||
IR_DEBUG_PRINT(F("Bose: "));
|
||||
IR_DEBUG_PRINTLN(F("Decode failed"));
|
||||
if (!decodePulseDistanceWidthData(&BoseWaveProtocolConstants, BOSEWAVE_BITS)) {
|
||||
#if defined(LOCAL_DEBUG)
|
||||
Serial.print(F("Bose: "));
|
||||
Serial.println(F("Decode failed"));
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
// Stop bit
|
||||
if (!matchMark(decodedIRData.rawDataPtr->rawbuf[3 + (2 * BOSEWAVE_BITS)], BOSEWAVE_BIT_MARK)) {
|
||||
IR_DEBUG_PRINT(F("Bose: "));
|
||||
IR_DEBUG_PRINTLN(F("Stop bit mark length is wrong"));
|
||||
#if defined(LOCAL_DEBUG)
|
||||
Serial.print(F("Bose: "));
|
||||
Serial.println(F("Stop bit mark length is wrong"));
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -100,22 +100,24 @@ bool IRrecv::decodeBoseWave() {
|
|||
uint8_t tCommandInverted = tDecodedValue >> 8;
|
||||
// parity check for command. Use this variant to avoid compiler warning "comparison of promoted ~unsigned with unsigned [-Wsign-compare]"
|
||||
if ((tCommandNotInverted ^ tCommandInverted) != 0xFF) {
|
||||
IR_DEBUG_PRINT(F("Bose: "));
|
||||
IR_DEBUG_PRINT(F("Command and inverted command check failed"));
|
||||
#if defined(LOCAL_DEBUG)
|
||||
Serial.print(F("Bose: "));
|
||||
Serial.println(F("Command and inverted command check failed"));
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
decodedIRData.command = tCommandNotInverted;
|
||||
decodedIRData.numberOfBits = BOSEWAVE_BITS;
|
||||
decodedIRData.protocol = BOSEWAVE;
|
||||
|
||||
// check for repeat
|
||||
if (decodedIRData.rawDataPtr->rawbuf[0] < ((BOSEWAVE_REPEAT_SPACE + (BOSEWAVE_REPEAT_SPACE / 4)) / MICROS_PER_TICK)) {
|
||||
decodedIRData.flags = IRDATA_FLAGS_IS_REPEAT | IRDATA_FLAGS_IS_LSB_FIRST;
|
||||
}
|
||||
|
||||
decodedIRData.command = tCommandNotInverted;
|
||||
decodedIRData.protocol = BOSEWAVE;
|
||||
decodedIRData.numberOfBits = BOSEWAVE_BITS;
|
||||
checkForRepeatSpaceTicksAndSetFlag(BOSEWAVE_MAXIMUM_REPEAT_DISTANCE / MICROS_PER_TICK);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/** @}*/
|
||||
#if defined(LOCAL_DEBUG)
|
||||
#undef LOCAL_DEBUG
|
||||
#endif
|
||||
#endif // _IR_BOSEWAVE_HPP
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue