Skip to content
Snippets Groups Projects
Commit 59883d4d authored by sui77's avatar sui77
Browse files

Merge pull request #15 from rotv/issue14

Solution for issue #14, reduced the cut-off/ignore time limit
parents 94d25fce 0f081f24
No related branches found
No related tags found
No related merge requests found
...@@ -35,6 +35,10 @@ unsigned int RCSwitch::nReceivedBitlength = 0; ...@@ -35,6 +35,10 @@ unsigned int RCSwitch::nReceivedBitlength = 0;
unsigned int RCSwitch::nReceivedDelay = 0; unsigned int RCSwitch::nReceivedDelay = 0;
unsigned int RCSwitch::nReceivedProtocol = 0; unsigned int RCSwitch::nReceivedProtocol = 0;
int RCSwitch::nReceiveTolerance = 60; int RCSwitch::nReceiveTolerance = 60;
const unsigned int RCSwitch::nSeparationLimit = 4600;
// separationLimit: minimum microseconds between received codes, closer codes are ignored.
// according to discussion on issue #14 it might be more suitable to set the separation
// limit to the same time as the 'low' part of the sync signal for the current protocol.
#endif #endif
unsigned int RCSwitch::timings[RCSWITCH_MAX_CHANGES]; unsigned int RCSwitch::timings[RCSWITCH_MAX_CHANGES];
...@@ -362,7 +366,7 @@ char* RCSwitch::getCodeWordC(char sFamily, int nGroup, int nDevice, boolean bSta ...@@ -362,7 +366,7 @@ char* RCSwitch::getCodeWordC(char sFamily, int nGroup, int nDevice, boolean bSta
* *
* @param sGroup Name of the switch group (A..D, resp. a..d) * @param sGroup Name of the switch group (A..D, resp. a..d)
* @param nDevice Number of the switch itself (1..3) * @param nDevice Number of the switch itself (1..3)
* @param bStatus Wether to switch on (true) or off (false) * @param bStatus Whether to switch on (true) or off (false)
* *
* @return char[13] * @return char[13]
*/ */
...@@ -788,7 +792,7 @@ void RCSwitch::handleInterrupt() { ...@@ -788,7 +792,7 @@ void RCSwitch::handleInterrupt() {
long time = micros(); long time = micros();
duration = time - lastTime; duration = time - lastTime;
if (duration > 5000 && duration > RCSwitch::timings[0] - 200 && duration < RCSwitch::timings[0] + 200) { if (duration > RCSwitch::nSeparationLimit && duration > RCSwitch::timings[0] - 200 && duration < RCSwitch::timings[0] + 200) {
repeatCount++; repeatCount++;
changeCount--; changeCount--;
if (repeatCount == 2) { if (repeatCount == 2) {
...@@ -802,7 +806,7 @@ void RCSwitch::handleInterrupt() { ...@@ -802,7 +806,7 @@ void RCSwitch::handleInterrupt() {
repeatCount = 0; repeatCount = 0;
} }
changeCount = 0; changeCount = 0;
} else if (duration > 5000) { } else if (duration > RCSwitch::nSeparationLimit) {
changeCount = 0; changeCount = 0;
} }
......
...@@ -132,6 +132,7 @@ class RCSwitch { ...@@ -132,6 +132,7 @@ class RCSwitch {
static unsigned int nReceivedBitlength; static unsigned int nReceivedBitlength;
static unsigned int nReceivedDelay; static unsigned int nReceivedDelay;
static unsigned int nReceivedProtocol; static unsigned int nReceivedProtocol;
const static unsigned int nSeparationLimit;
#endif #endif
/* /*
* timings[0] contains sync timing, followed by a number of bits * timings[0] contains sync timing, followed by a number of bits
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment