Merge branch 'master' of github.com:marcmerlin/Arduino-IRremote

This commit is contained in:
Marc MERLIN
2017-03-31 22:33:16 -07:00
7 changed files with 42 additions and 43 deletions

View File

@@ -16,7 +16,7 @@ These are the active contributors of this project that you may contact if there
- [Sebazzz](https://github.com/sebazz): Contributor - [Sebazzz](https://github.com/sebazz): Contributor
- [lumbric](https://github.com/lumbric): Contributor - [lumbric](https://github.com/lumbric): Contributor
- [ElectricRCAircraftGuy](https://github.com/electricrcaircraftguy): Active Contributor - [ElectricRCAircraftGuy](https://github.com/electricrcaircraftguy): Active Contributor
- [henkel](https://github.com/henkel): Contributor - [philipphenkel](https://github.com/philipphenkel): Active Contributor
- [MCUdude](https://github.com/MCUdude): Contributor - [MCUdude](https://github.com/MCUdude): Contributor
Note: This list is being updated constantly so please let [z3t0](https://github.com/z3t0) know if you have been missed. Note: This list is being updated constantly so please let [z3t0](https://github.com/z3t0) know if you have been missed.

View File

@@ -8,7 +8,7 @@ This library enables you to send and receive using infra-red signals on an Ardui
Tutorials and more information will be made available on [the official homepage](http://z3t0.github.io/Arduino-IRremote/). Tutorials and more information will be made available on [the official homepage](http://z3t0.github.io/Arduino-IRremote/).
## Version - 2.2.1 ## Version - 2.2.3
## Installation ## Installation
1. Navigate to the [Releases](https://github.com/z3t0/Arduino-IRremote/releases) page. 1. Navigate to the [Releases](https://github.com/z3t0/Arduino-IRremote/releases) page.
@@ -65,7 +65,7 @@ Check [here](Contributing.md) for some guidelines.
## Contact ## Contact
Email: zetoslab@gmail.com Email: zetoslab@gmail.com
Please only email me if it is more appropriate than creating an Issue / PR. I **will** not respond to requests for adding support for particular boards, unless of course you are the creator of the board and would like to cooperate on the project. I will also **ignore** any emails asking me to tell you how to implement your ideas. However, if you have a private inquiry that you would only apply to you and you would prefer it to be via email, by all means. Please only email me if it is more appropriate than creating an Issue / PR. I **will** not respond to requests for adding support for particular boards, unless of course you are the creator of the board and would like to cooperate on the project. I will also **ignore** any emails asking me to tell you how to implement your ideas. However, if you have a private inquiry that you would only apply to you and you would prefer it to be via email, by all means.
## Contributors ## Contributors
Check [here](Contributors.md) Check [here](Contributors.md)

View File

@@ -1,3 +1,6 @@
## 2.2.3 - 2017/03/27
- Fix calculation of pause length in LEGO PF protocol [PR #427](https://github.com/z3t0/Arduino-IRremote/pull/427)
## 2.2.2 - 2017/01/20 ## 2.2.2 - 2017/01/20
- Fixed naming bug [PR #398](https://github.com/z3t0/Arduino-IRremote/pull/398) - Fixed naming bug [PR #398](https://github.com/z3t0/Arduino-IRremote/pull/398)

View File

@@ -1,6 +1,6 @@
/* /*
* LegoPowerFunctionsTest: LEGO Power Functions Tests * LegoPowerFunctionsTest: LEGO Power Functions Tests
* Copyright (c) 2016 Philipp Henkel * Copyright (c) 2016, 2017 Philipp Henkel
*/ */
#include <ir_Lego_PF_BitStreamEncoder.h> #include <ir_Lego_PF_BitStreamEncoder.h>
@@ -78,14 +78,14 @@ void testMessageBitCount(LegoPfBitStreamEncoder& bitStreamEncoder) {
logTestResult(bitCount == 18); logTestResult(bitCount == 18);
} }
boolean check(LegoPfBitStreamEncoder& bitStreamEncoder, int markDuration, int pauseDuration) { boolean check(LegoPfBitStreamEncoder& bitStreamEncoder, unsigned long markDuration, unsigned long pauseDuration) {
bool result = true; bool result = true;
result = result && bitStreamEncoder.getMarkDuration() == markDuration; result = result && bitStreamEncoder.getMarkDuration() == markDuration;
result = result && bitStreamEncoder.getPauseDuration() == pauseDuration; result = result && bitStreamEncoder.getPauseDuration() == pauseDuration;
return result; return result;
} }
boolean checkNext(LegoPfBitStreamEncoder& bitStreamEncoder, int markDuration, int pauseDuration) { boolean checkNext(LegoPfBitStreamEncoder& bitStreamEncoder, unsigned long markDuration, unsigned long pauseDuration) {
bool result = bitStreamEncoder.next(); bool result = bitStreamEncoder.next();
result = result && check(bitStreamEncoder, markDuration, pauseDuration); result = result && check(bitStreamEncoder, markDuration, pauseDuration);
return result; return result;
@@ -129,16 +129,16 @@ void testMessage407Repeated(LegoPfBitStreamEncoder& bitStreamEncoder) {
bool result = true; bool result = true;
result = result && check(bitStreamEncoder, 158, 1026); result = result && check(bitStreamEncoder, 158, 1026);
result = result && checkDataBitsOfMessage407(bitStreamEncoder); result = result && checkDataBitsOfMessage407(bitStreamEncoder);
result = result && checkNext(bitStreamEncoder, 158, 1026 + 5 * 16000 - 10844); result = result && checkNext(bitStreamEncoder, 158, 1026L + 5L * 16000L - 10844L);
result = result && checkNext(bitStreamEncoder, 158, 1026); result = result && checkNext(bitStreamEncoder, 158, 1026);
result = result && checkDataBitsOfMessage407(bitStreamEncoder); result = result && checkDataBitsOfMessage407(bitStreamEncoder);
result = result && checkNext(bitStreamEncoder, 158, 1026 + 5 * 16000 - 10844); result = result && checkNext(bitStreamEncoder, 158, 1026L + 5L * 16000L - 10844L);
result = result && checkNext(bitStreamEncoder, 158, 1026); result = result && checkNext(bitStreamEncoder, 158, 1026);
result = result && checkDataBitsOfMessage407(bitStreamEncoder); result = result && checkDataBitsOfMessage407(bitStreamEncoder);
result = result && checkNext(bitStreamEncoder, 158, 1026 + 8 * 16000 - 10844); result = result && checkNext(bitStreamEncoder, 158, 1026L + 8L * 16000L - 10844L);
result = result && checkNext(bitStreamEncoder, 158, 1026); result = result && checkNext(bitStreamEncoder, 158, 1026);
result = result && checkDataBitsOfMessage407(bitStreamEncoder); result = result && checkDataBitsOfMessage407(bitStreamEncoder);
result = result && checkNext(bitStreamEncoder, 158, 1026 + 8 * 16000 - 10844); result = result && checkNext(bitStreamEncoder, 158, 1026L + 8L * 16000L - 10844L);
result = result && checkNext(bitStreamEncoder, 158, 1026); result = result && checkNext(bitStreamEncoder, 158, 1026);
result = result && checkDataBitsOfMessage407(bitStreamEncoder); result = result && checkDataBitsOfMessage407(bitStreamEncoder);
result = result && checkNext(bitStreamEncoder, 158, 1026); result = result && checkNext(bitStreamEncoder, 158, 1026);
@@ -191,7 +191,3 @@ void testGetMessageLengthAllLow(LegoPfBitStreamEncoder& bitStreamEncoder) {
bitStreamEncoder.reset(0x0, false); bitStreamEncoder.reset(0x0, false);
logTestResult(bitStreamEncoder.getMessageLength() == 9104); logTestResult(bitStreamEncoder.getMessageLength() == 9104);
} }

View File

@@ -4,7 +4,7 @@
// L E E O O // L E E O O
// L EEEE E EEE O O // L EEEE E EEE O O
// L E E E O O LEGO Power Functions // L E E E O O LEGO Power Functions
// LLLLLL EEEEEE EEEE OOOO Copyright (c) 2016 Philipp Henkel // LLLLLL EEEEEE EEEE OOOO Copyright (c) 2016, 2017 Philipp Henkel
//============================================================================== //==============================================================================
//+============================================================================= //+=============================================================================
@@ -14,25 +14,25 @@ class LegoPfBitStreamEncoder {
private: private:
uint16_t data; uint16_t data;
bool repeatMessage; bool repeatMessage;
int messageBitIdx; uint8_t messageBitIdx;
int repeatCount; uint8_t repeatCount;
int messageLength; uint16_t messageLength;
// HIGH data bit = IR mark + high pause
// LOW data bit = IR mark + low pause
static const int LOW_BIT_DURATION = 421;
static const int HIGH_BIT_DURATION = 711;
static const int START_BIT_DURATION = 1184;
static const int STOP_BIT_DURATION = 1184;
static const int IR_MARK_DURATION = 158;
static const int HIGH_PAUSE_DURATION = HIGH_BIT_DURATION - IR_MARK_DURATION;
static const int LOW_PAUSE_DURATION = LOW_BIT_DURATION - IR_MARK_DURATION;
static const int START_PAUSE_DURATION = START_BIT_DURATION - IR_MARK_DURATION;
static const int STOP_PAUSE_DURATION = STOP_BIT_DURATION - IR_MARK_DURATION;
static const int MESSAGE_BITS = 18;
static const int MAX_MESSAGE_LENGTH = 16000;
public: public:
// HIGH data bit = IR mark + high pause
// LOW data bit = IR mark + low pause
static const uint16_t LOW_BIT_DURATION = 421;
static const uint16_t HIGH_BIT_DURATION = 711;
static const uint16_t START_BIT_DURATION = 1184;
static const uint16_t STOP_BIT_DURATION = 1184;
static const uint8_t IR_MARK_DURATION = 158;
static const uint16_t HIGH_PAUSE_DURATION = HIGH_BIT_DURATION - IR_MARK_DURATION;
static const uint16_t LOW_PAUSE_DURATION = LOW_BIT_DURATION - IR_MARK_DURATION;
static const uint16_t START_PAUSE_DURATION = START_BIT_DURATION - IR_MARK_DURATION;
static const uint16_t STOP_PAUSE_DURATION = STOP_BIT_DURATION - IR_MARK_DURATION;
static const uint8_t MESSAGE_BITS = 18;
static const uint16_t MAX_MESSAGE_LENGTH = 16000;
void reset(uint16_t data, bool repeatMessage) { void reset(uint16_t data, bool repeatMessage) {
this->data = data; this->data = data;
this->repeatMessage = repeatMessage; this->repeatMessage = repeatMessage;
@@ -43,9 +43,9 @@ class LegoPfBitStreamEncoder {
int getChannelId() const { return 1 + ((data >> 12) & 0x3); } int getChannelId() const { return 1 + ((data >> 12) & 0x3); }
int getMessageLength() const { uint16_t getMessageLength() const {
// Sum up all marks // Sum up all marks
int length = MESSAGE_BITS * IR_MARK_DURATION; uint16_t length = MESSAGE_BITS * IR_MARK_DURATION;
// Sum up all pauses // Sum up all pauses
length += START_PAUSE_DURATION; length += START_PAUSE_DURATION;
@@ -75,9 +75,9 @@ class LegoPfBitStreamEncoder {
} }
} }
int getMarkDuration() const { return IR_MARK_DURATION; } uint8_t getMarkDuration() const { return IR_MARK_DURATION; }
int getPauseDuration() const { uint32_t getPauseDuration() const {
if (messageBitIdx == 0) if (messageBitIdx == 0)
return START_PAUSE_DURATION; return START_PAUSE_DURATION;
else if (messageBitIdx < MESSAGE_BITS - 1) { else if (messageBitIdx < MESSAGE_BITS - 1) {
@@ -88,13 +88,13 @@ class LegoPfBitStreamEncoder {
} }
private: private:
int getDataBitPause() const { uint16_t getDataBitPause() const {
const int pos = MESSAGE_BITS - 2 - messageBitIdx; const int pos = MESSAGE_BITS - 2 - messageBitIdx;
const bool isHigh = data & (1 << pos); const bool isHigh = data & (1 << pos);
return isHigh ? HIGH_PAUSE_DURATION : LOW_PAUSE_DURATION; return isHigh ? HIGH_PAUSE_DURATION : LOW_PAUSE_DURATION;
} }
int getStopPause() const { uint32_t getStopPause() const {
if (repeatMessage) { if (repeatMessage) {
return getRepeatStopPause(); return getRepeatStopPause();
} else { } else {
@@ -102,12 +102,12 @@ class LegoPfBitStreamEncoder {
} }
} }
int getRepeatStopPause() const { uint32_t getRepeatStopPause() const {
if (repeatCount == 0 || repeatCount == 1) { if (repeatCount == 0 || repeatCount == 1) {
return STOP_PAUSE_DURATION + 5 * MAX_MESSAGE_LENGTH - messageLength; return STOP_PAUSE_DURATION + (uint32_t)5 * MAX_MESSAGE_LENGTH - messageLength;
} else if (repeatCount == 2 || repeatCount == 3) { } else if (repeatCount == 2 || repeatCount == 3) {
return STOP_PAUSE_DURATION return STOP_PAUSE_DURATION
+ (6 + 2 * getChannelId()) * MAX_MESSAGE_LENGTH - messageLength; + (uint32_t)(6 + 2 * getChannelId()) * MAX_MESSAGE_LENGTH - messageLength;
} else { } else {
return STOP_PAUSE_DURATION; return STOP_PAUSE_DURATION;
} }

View File

@@ -7,7 +7,7 @@
"type": "git", "type": "git",
"url": "https://github.com/z3t0/Arduino-IRremote.git" "url": "https://github.com/z3t0/Arduino-IRremote.git"
}, },
"version": "2.2.1", "version": "2.2.3",
"frameworks": "arduino", "frameworks": "arduino",
"platforms": "atmelavr", "platforms": "atmelavr",
"authors" : "authors" :

View File

@@ -1,5 +1,5 @@
name=IRremote name=IRremote
version=2.2.1 version=2.2.3
author=shirriff author=shirriff
maintainer=shirriff maintainer=shirriff
sentence=Send and receive infrared signals with multiple protocols sentence=Send and receive infrared signals with multiple protocols