Skip to content

Commit 8deb5ea

Browse files
committed
refactored board specific code
1 parent 56bd4f5 commit 8deb5ea

37 files changed

+2285
-563
lines changed

.github/issue_template.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ If you have handling problems or questions, consider to open a discussion https:
1111
* [ ] Arduino SAMD board (Zero, MKR*)
1212
* [ ] ESP32 board - first check https://github.com/crankyoldgit/IRremoteESP8266
1313
* [ ] Teensy board
14+
* [ ] STM32F1 board (BluePill)
1415
* [ ] Other - please specify
1516

1617
<!-- Please specify board name if not included in board selection -->

.github/workflows/LibraryBuild.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,6 @@ jobs:
9797

9898
- arduino-boards-fqbn: arduino:samd:arduino_zero_native
9999
sketches-exclude: MinimalReceiver,IRDispatcherDemo
100-
build-properties: # the flags were put in compiler.cpp.extra_flags
101-
All: -DUSE_SOFT_SEND_PWM
102100

103101
- arduino-boards-fqbn: SparkFun:avr:promicro
104102
arduino-platform: arduino:avr,SparkFun:avr
@@ -144,8 +142,6 @@ jobs:
144142
- arduino-boards-fqbn: sandeepmistry:nRF5:BBCmicrobit
145143
platform-url: https://sandeepmistry.github.io/arduino-nRF5/package_nRF5_boards_index.json
146144
sketches-exclude: IR2Keyboard,IRDispatcherDemo,MicroGirs,MinimalReceiver # no tone()
147-
build-properties: # the flags were put in compiler.cpp.extra_flags
148-
All: -DUSE_SOFT_SEND_PWM
149145

150146
# Do not cancel all jobs / architectures if one job fails
151147
fail-fast: false

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ Modify it by commenting them out or in, or change the values if applicable. Or d
112112
| `EXCLUDE_EXOTIC_PROTOCOLS` | Before `#include <IRremote.h>` | disabled | If activated, BOSEWAVE, MAGIQUEST,WHYNTER and LEGO_PF are excluded in `decode()` and in sending with `IrSender.write()`. Saves up to 900 bytes program space. |
113113
| `MARK_EXCESS_MICROS` | Before `#include <IRremote.h>` | 20 | 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. |
114114
| `USE_NO_SEND_PWM` | Before `#include <IRremote.h>` | disabled | Use no carrier PWM, just simulate an active low receiver signal. |
115+
| `FEEDBACK_LED_IS_ACTIVE_LOW` | Before `#include <IRremote.h>` | disabled | Required on some boards (like my BluePill and my ESP8266 board), where the feedback LED is active low. |
115116
| `IR_INPUT_IS_ACTIVE_HIGH` | IRremoteInt.h | disabled | Enable it if you use a RF receiver, which has an active HIGH output signal. |
116117
| `RAW_BUFFER_LENGTH` | IRremoteint.h | 101 | Buffer size of raw input buffer. Must be odd! |
117118
| `DEBUG` | IRremoteInt.h | disabled | Enables lots of lovely debug output. |

changelog.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
## 3.1.0
22
- Replaced #define DECODE_NEC 1/0 by defining/not defining.
33
- USE_SOFT_SEND_PWM is active by default.
4+
- Refactored Board specific code.
5+
- Added STM32F1 by (by Roger Clark) support.
46
- Added stm32 (by ST) support. Thanks to Paolo Malaspina.
5-
- Added STM32F1 by (Roger Clark) support.
7+
- Refactored LED Feedback functions.
8+
- Renamed most irparams_struct values.
9+
- Implemented feedback for send.
10+
- Removed decode_results results.
611

712
## 3.0.2
813
- Bug fix for USE_OLD_DECODE.

examples/BoseWaveSendDemo/BoseWaveSendDemo.ino

Lines changed: 45 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,56 @@
11
/*
2-
* Based on IRremote: IRsendDemo by Ken Shirriff
2+
* BoseWaveSendDemo.cpp
33
*
44
* Prompt user for a code to send. Make sure your 940-950nm IR LED is
55
* connected to the default digital output. Place your Bose Wave Radio
66
* CD in the line of sight of your LED, and send commands!
7+
*
8+
* This file is part of Arduino-IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
9+
*
10+
************************************************************************************
11+
* MIT License
12+
*
13+
* Copyright (c) 2020 Thomas Koch
14+
*
15+
* Permission is hereby granted, free of charge, to any person obtaining a copy
16+
* of this software and associated documentation files (the "Software"), to deal
17+
* in the Software without restriction, including without limitation the rights
18+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
19+
* copies of the Software, and to permit persons to whom the Software is furnished
20+
* to do so, subject to the following conditions:
21+
*
22+
* The above copyright notice and this permission notice shall be included in all
23+
* copies or substantial portions of the Software.
24+
*
25+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
26+
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
27+
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
28+
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
29+
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
30+
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31+
*
32+
************************************************************************************
733
*/
8-
#include <IRremote.h>
34+
#include <Arduino.h>
935

36+
/*
37+
* Define macros for input and output pin etc.
38+
*/
39+
#include "PinDefinitionsAndMore.h"
1040

11-
//......................................................................
12-
//
13-
// Bose Wave Radio CD Remote Control
14-
// |-------------------------------------|
15-
// | On/Off Sleep VolUp |
16-
// | Play/Pause Stop VolDown |
17-
// | FM AM Aux |
18-
// | Tune Down Tune Up Mute |
19-
// | 1 2 3 |
20-
// | 4 5 6 |
21-
// |-------------------------------------|
41+
#include <IRremote.h>
42+
43+
//......................................................................
44+
//
45+
// Bose Wave Radio CD Remote Control
46+
// |-------------------------------------|
47+
// | On/Off Sleep VolUp |
48+
// | Play/Pause Stop VolDown |
49+
// | FM AM Aux |
50+
// | Tune Down Tune Up Mute |
51+
// | 1 2 3 |
52+
// | 4 5 6 |
53+
// |-------------------------------------|
2254
#define BOSE_CMD_ON_OFF 0x00
2355
#define BOSE_CMD_MUTE 0x01
2456
#define BOSE_CMD_VOL_UP 0x02
@@ -61,8 +93,6 @@ void setup() {
6193
prompt = true;
6294
}
6395

64-
65-
6696
void loop() {
6797
if (prompt) {
6898
prompt = false;
Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
/*
2+
* PinDefinitionsAndMore.h
3+
*
4+
* Contains pin definitions for IRremote examples for various platforms
5+
* as well as definitions for feedback LED and tone() and includes
6+
*
7+
* Copyright (C) 2021 Armin Joachimsmeyer
8+
9+
*
10+
* This file is part of IRMP https://github.com/Arduino-IRremote/Arduino-IRremote.
11+
*
12+
* IRMP is free software: you can redistribute it and/or modify
13+
* it under the terms of the GNU General Public License as published by
14+
* the Free Software Foundation, either version 3 of the License, or
15+
* (at your option) any later version.
16+
*
17+
* This program is distributed in the hope that it will be useful,
18+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
19+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20+
* GNU General Public License for more details.
21+
*
22+
* You should have received a copy of the GNU General Public License
23+
* along with this program. If not, see <http://www.gnu.org/licenses/gpl.html>.
24+
*
25+
*/
26+
27+
/*
28+
* Pin mapping table for different platforms
29+
*
30+
* Platform IR input IR output Tone
31+
* -----------------------------------------
32+
* DEFAULT/AVR 2 3 4
33+
* ATtinyX5 0 4 3
34+
* ATtin167 9 8 5 // Digispark pro number schema
35+
* ATtin167 3 2 7
36+
* ATtin3217 10 11 3 // TinyCore schema
37+
* SAMD21 3 4 5
38+
* ESP8266 14 // D5 12 // D6 %
39+
* ESP32 15 4 %
40+
* BluePill PA6 PA7 PA3
41+
* APOLLO3 11 12 5
42+
*/
43+
//#define IRMP_MEASURE_TIMING // For debugging purposes.
44+
//
45+
#if defined(ESP8266)
46+
#define FEEDBACK_LED_IS_ACTIVE_LOW // The LED on my board is active LOW
47+
#define IR_RECEIVE_PIN 14 // D5
48+
#define IR_SEND_PIN 12 // D6 - D4/2 is internal LED
49+
#define tone(a,b) void() // tone() inhibits receive timer
50+
#define noTone(a) void()
51+
#define TONE_PIN 42 // Dummy for examples using it
52+
#define IR_TIMING_TEST_PIN 13 // D7
53+
54+
#elif defined(ESP32)
55+
#define IR_RECEIVE_PIN 15 // D15
56+
#define IR_SEND_PIN 4 // D4
57+
#define tone(a,b) void() // no tone() available on ESP32
58+
#define noTone(a) void()
59+
#define TONE_PIN 42 // Dummy for examples using it
60+
61+
#elif defined(ARDUINO_ARCH_STM32) || defined(ARDUINO_ARCH_STM32F1)
62+
// BluePill in 2 flavors
63+
// Timer 3 of IRMP blocks PA6, PA7, PB0, PB1 for use by Servo or tone()
64+
#define IR_RECEIVE_PIN PA6
65+
#define IR_RECEIVE_PIN_STRING "PA6"
66+
#define IR_SEND_PIN PA7
67+
#define IR_SEND_PIN_STRING "PA7"
68+
#define TONE_PIN PA3
69+
#define IR_TIMING_TEST_PIN PA5
70+
71+
#elif defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__) || defined(__AVR_ATtiny87__) || defined(__AVR_ATtiny167__)
72+
//#include "ATtinySerialOut.h"
73+
# if defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__)
74+
# if defined(ARDUINO_AVR_DIGISPARK)
75+
#define LED_BUILTIN PB1
76+
# endif
77+
#define IR_RECEIVE_PIN 0
78+
#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.
79+
#define TONE_PIN 3
80+
//#define IR_TIMING_TEST_PIN 3
81+
82+
# else
83+
// ATtiny87 + ATtiny167 here. For ATtiny167 Pins PB6 and PA3 are usable as interrupt source.
84+
# if defined(ARDUINO_AVR_DIGISPARKPRO)
85+
#define LED_BUILTIN 1 // PB1 - on Digispark board labeled as pin 1 / for ATtinyCore lib use D9
86+
#define IR_RECEIVE_PIN 9 // PA3 - on Digispark board labeled as pin 9
87+
//#define IR_RECEIVE_PIN 14 // PB6 / INT0 is connected to USB+ on DigisparkPro boards
88+
#define IR_SEND_PIN 8 // PA2 - on Digispark board labeled as pin 8
89+
#define TONE_PIN 5 // PA7
90+
#define IR_TIMING_TEST_PIN 10 // PA4
91+
92+
# else
93+
#define IR_RECEIVE_PIN 3
94+
#define IR_SEND_PIN 2
95+
#define TONE_PIN 7
96+
# endif
97+
# endif
98+
99+
#elif defined(__AVR_ATtiny3217__)
100+
#define IR_RECEIVE_PIN 10
101+
#define IR_SEND_PIN 11
102+
#define TONE_PIN 3
103+
104+
#elif defined(ARDUINO_ARCH_APOLLO3)
105+
#define IR_RECEIVE_PIN 11
106+
#define IR_SEND_PIN 12
107+
#define TONE_PIN 5
108+
109+
#elif defined(ARDUINO_ARCH_MBED) // Arduino Nano 33 BLE
110+
#define IR_RECEIVE_PIN 3
111+
#define IR_SEND_PIN 4
112+
#define TONE_PIN 5
113+
#define IR_TIMING_TEST_PIN 6
114+
115+
#elif defined(TEENSYDUINO)
116+
#define IR_RECEIVE_PIN 3
117+
#define IR_SEND_PIN 4
118+
#define TONE_PIN 5
119+
#define IR_TIMING_TEST_PIN 6
120+
121+
#elif defined(__AVR__)
122+
#define IR_RECEIVE_PIN 2 // To be compatible with interrupt example, pin 2 is chosen here.
123+
#define IR_SEND_PIN 3
124+
#define TONE_PIN 4
125+
#define IR_TIMING_TEST_PIN 6
126+
127+
#elif defined(ARDUINO_ARCH_SAMD)
128+
#define IR_RECEIVE_PIN 2 // To be compatible with interrupt example, pin 2 is chosen here.
129+
#define IR_SEND_PIN 3
130+
#define TONE_PIN 4
131+
#define IR_TIMING_TEST_PIN 6
132+
133+
// On the Zero and others we switch explicitly to SerialUSB
134+
#define Serial SerialUSB
135+
136+
// Definitions for the Chinese SAMD21 M0-Mini clone, which has no led connected to D13/PA17.
137+
// Attention!!! D2 and D4 are switched on these boards!!!
138+
// If you connect the LED, it is on pin 24/PB11. In this case activate the next two lines.
139+
//#undef LED_BUILTIN
140+
//#define LED_BUILTIN 24 // PB11
141+
// 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.
142+
//#undef LED_BUILTIN
143+
//#define LED_BUILTIN 25 // PB03
144+
//#define FEEDBACK_LED_IS_ACTIVE_LOW // The RX LED on the M0-Mini is active LOW
145+
146+
#else
147+
#warning Board / CPU is not detected using pre-processor symbols -> using default values, which may not fit. Please extend PinDefinitionsAndMore.h.
148+
// Default valued for unidentified boards
149+
#define IR_RECEIVE_PIN 2
150+
#define IR_SEND_PIN 3
151+
#define TONE_PIN 4
152+
#define IR_TIMING_TEST_PIN 6
153+
#endif // defined(ESP8266)
154+
155+
/*
156+
* Helper macro for getting a macro definition as string
157+
*/
158+
#define STR_HELPER(x) #x
159+
#define STR(x) STR_HELPER(x)

0 commit comments

Comments
 (0)