Skip to content

Commit efbdb1d

Browse files
committed
New example IR2Keyboard
1 parent f9674f7 commit efbdb1d

File tree

8 files changed

+245
-162
lines changed

8 files changed

+245
-162
lines changed

.github/workflows/LibraryBuild.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ jobs:
6060
# With sketches-exclude you may exclude specific examples for a board. Use a comma separated list.
6161
#############################################################################################################
6262
include:
63+
- arduino-boards-fqbn: arduino:avr:uno
64+
sketches-exclude: IR2Keyboard
65+
6366
- arduino-boards-fqbn: arduino:avr:uno|USE_NEC_STANDARD
6467
sketches-exclude: IR2Keyboard
6568
build-properties: # the flags were put in compiler.cpp.extra_flags
@@ -70,6 +73,9 @@ jobs:
7073
build-properties: # the flags were put in compiler.cpp.extra_flags
7174
All: -DUSE_NO_SEND_PWM
7275

76+
- arduino-boards-fqbn: arduino:megaavr:nona4809:mode=off
77+
sketches-exclude: IR2Keyboard
78+
7379
- arduino-boards-fqbn: esp32:esp32:featheresp32:FlashFreq=80
7480
platform-url: https://dl.espressif.com/dl/package_esp32_index.json
7581
sketches-exclude: IR2Keyboard,LGACSendDemo # undefined reference to `TwoWire::onReceive(void (*)(int))'

changelog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
- Changed wrong return code signature of decodePulseDistanceData() and its handling.
55
- Removed Mitsubishi protocol, since the implementation is in contradiction with all documentation I could found and therefore supposed to be wrong.
66
- Removed AIWA implementation, since it is only for 1 device and at least sending implemented wrong.
7+
- Added Lego_PF decode.
8+
- Added new example IR2Keyboard.
79

810
## 2.7.0 2020/09
911
- Added ATmega328PB support.

examples/IR2Keyboard/IR2Keyboard.ino

Lines changed: 216 additions & 141 deletions
Large diffs are not rendered by default.

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ version=2.7.0
33
author=shirriff, z3t0 <[email protected]>
44
maintainer=Armin Joachimsmeyer <[email protected]>
55
sentence=Send and receive infrared signals with multiple protocols
6-
paragraph=Currently included protocols: Aiwa, BoseWave, Denon, Dish, JVC, Lego, LG, MagiQuest, NEC, Panasonic, RC5, RC6, Samsung, Sanyo, Sharp, Sony, Whynter, (Pronto).<br/><br/><b>New: </b>Major refactoring, new functions, repeat handling, NRF5 support.<br/>
6+
paragraph=Currently included protocols: BoseWave, Denon, Dish, JVC, Lego, LG, MagiQuest, NEC, Panasonic, RC5, RC6, Samsung, Sanyo, Sharp, Sony, Whynter, (Pronto).<br/><br/><b>New: </b>Major refactoring, new functions, repeat handling, NRF5 support.<br/>
77
category=Communication
88
url=https://github.com/z3t0/Arduino-IRremote
99
architectures=avr,megaavr,samd,esp32,mbed

src/IRremote.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ struct irparams_struct irparams; // the irparams instance
3434
// in a hope of finding out what is going on, but for now they will remain as
3535
// functions even in non-DEBUG mode
3636
//
37-
int MATCH(int measured, int desired) {
37+
int MATCH(unsigned int measured, unsigned int desired) {
3838
#if DEBUG
3939
Serial.print(F("Testing: "));
4040
Serial.print(TICKS_LOW(desired), DEC);
@@ -57,7 +57,7 @@ int MATCH(int measured, int desired) {
5757
//+========================================================
5858
// Due to sensor lag, when received, Marks tend to be 100us too long
5959
//
60-
int MATCH_MARK(int measured_ticks, int desired_us) {
60+
int MATCH_MARK(uint16_t measured_ticks, unsigned int desired_us) {
6161
#if DEBUG
6262
Serial.print(F("Testing mark (actual vs desired): "));
6363
Serial.print(measured_ticks * MICROS_PER_TICK, DEC);
@@ -86,7 +86,7 @@ int MATCH_MARK(int measured_ticks, int desired_us) {
8686
//+========================================================
8787
// Due to sensor lag, when received, Spaces tend to be 100us too short
8888
//
89-
int MATCH_SPACE(int measured_ticks, int desired_us) {
89+
int MATCH_SPACE(uint16_t measured_ticks, unsigned int desired_us) {
9090
#if DEBUG
9191
Serial.print(F("Testing space (actual vs desired): "));
9292
Serial.print(measured_ticks * MICROS_PER_TICK, DEC);

src/IRremote.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,9 @@ typedef enum {
162162
//------------------------------------------------------------------------------
163163
// Mark & Space matching functions
164164
//
165-
int MATCH(int measured, int desired);
166-
int MATCH_MARK(int measured_ticks, int desired_us);
167-
int MATCH_SPACE(int measured_ticks, int desired_us);
165+
int MATCH(unsigned int measured, unsigned int desired);
166+
int MATCH_MARK(uint16_t measured_ticks, unsigned int desired_us);
167+
int MATCH_SPACE(uint16_t measured_ticks, unsigned int desired_us);
168168

169169
/****************************************************
170170
* RECEIVING
@@ -174,15 +174,15 @@ int MATCH_SPACE(int measured_ticks, int desired_us);
174174
*/
175175
struct decode_results {
176176
decode_type_t decode_type; ///< UNKNOWN, NEC, SONY, RC5, ...
177-
unsigned int address; ///< Used by Panasonic & Sharp6 NEC_standard [16-bits]
178-
unsigned long value; ///< Decoded value / command [max 32-bits]
179-
int bits; ///< Number of bits in decoded value
180-
unsigned int magnitude; ///< Used by MagiQuest [16-bits]
177+
uint16_t address; ///< Used by Panasonic & Sharp6 NEC_standard [16-bits]
178+
uint32_t value; ///< Decoded value / command [max 32-bits]
179+
uint16_t bits; ///< Number of bits in decoded value
180+
uint16_t magnitude; ///< Used by MagiQuest [16-bits]
181181
bool isRepeat; ///< True if repeat of value is detected
182182

183183
// next 3 values are copies of irparams values - see IRremoteint.h
184-
unsigned int *rawbuf; ///< Raw intervals in 50uS ticks
185-
unsigned int rawlen; ///< Number of records in rawbuf
184+
uint16_t *rawbuf; ///< Raw intervals in 50uS ticks
185+
uint16_t rawlen; ///< Number of records in rawbuf
186186
bool overflow; ///< true if IR raw code too long
187187
};
188188

src/irPronto.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ static void dumpDuration(Stream& stream, uint16_t duration, uint16_t timebase) {
132132
dumpNumber(stream, (duration * MICROS_PER_TICK + timebase / 2) / timebase);
133133
}
134134

135-
static void dumpSequence(Stream& stream, const volatile unsigned int *data, size_t length, uint16_t timebase) {
135+
static void dumpSequence(Stream& stream, const volatile uint16_t *data, size_t length, uint16_t timebase) {
136136
for (unsigned int i = 0; i < length; i++)
137137
dumpDuration(stream, data[i], timebase);
138138

src/private/IRremoteInt.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ struct irparams_struct {
4848
uint8_t recvpin; ///< Pin connected to IR data from detector
4949
uint8_t blinkpin;
5050
uint8_t blinkflag; ///< true -> enable blinking of pin on IR processing
51-
unsigned int rawlen; ///< counter of entries in rawbuf
52-
unsigned int timer; ///< State timer, counts 50uS ticks.
53-
unsigned int rawbuf[RAW_BUFFER_LENGTH]; ///< raw data, first entry is the length of the gap between previous and current command
51+
uint16_t rawlen; ///< counter of entries in rawbuf
52+
uint16_t timer; ///< State timer, counts 50uS ticks.
53+
uint16_t rawbuf[RAW_BUFFER_LENGTH]; ///< raw data, first entry is the length of the gap between previous and current command
5454
uint8_t overflow; ///< Raw buffer overflow occurred
5555
};
5656

@@ -101,11 +101,11 @@ extern struct irparams_struct irparams;
101101
//#define TICKS_LOW(us) ((int)(((us)*LTOL/MICROS_PER_TICK)))
102102
//#define TICKS_HIGH(us) ((int)(((us)*UTOL/MICROS_PER_TICK + 1)))
103103
#if MICROS_PER_TICK == 50 && TOLERANCE == 25 // Defaults
104-
#define TICKS_LOW(us) ((int) ((us)/67 )) // (us) / ((MICROS_PER_TICK:50 / LTOL:75 ) * 100)
105-
#define TICKS_HIGH(us) ((int) ((us)/40 + 1)) // (us) / ((MICROS_PER_TICK:50 / UTOL:125) * 100) + 1
104+
#define TICKS_LOW(us) ((us)/67 ) // (us) / ((MICROS_PER_TICK:50 / LTOL:75 ) * 100)
105+
#define TICKS_HIGH(us) ((us)/40 + 1) // (us) / ((MICROS_PER_TICK:50 / UTOL:125) * 100) + 1
106106
#else
107-
#define TICKS_LOW(us) ((int) ((long) (us) * LTOL / (MICROS_PER_TICK * 100) ))
108-
#define TICKS_HIGH(us) ((int) ((long) (us) * UTOL / (MICROS_PER_TICK * 100) + 1))
107+
#define TICKS_LOW(us) ((uint16_t) ((long) (us) * LTOL / (MICROS_PER_TICK * 100) ))
108+
#define TICKS_HIGH(us) ((uint16_t) ((long) (us) * UTOL / (MICROS_PER_TICK * 100) + 1))
109109
#endif
110110

111111
//------------------------------------------------------------------------------

0 commit comments

Comments
 (0)