diff --git a/RCSwitch.cpp b/RCSwitch.cpp index 29b861a21395870dee0b90dcd87a391d2dbd3a95..253273ce32848c727f4ea97e461217d4f836b9e2 100644 --- a/RCSwitch.cpp +++ b/RCSwitch.cpp @@ -256,7 +256,6 @@ void RCSwitch::send(char* sCodeWord) { i++; } this->sendSync(); - } } @@ -267,13 +266,10 @@ void RCSwitch::transmit(int nHighPulses, int nLowPulses) { if (this->nReceiverInterrupt != -1) { this->disableReceive(); } - - digitalWrite(this->nTransmitterPin, LOW); - delayMicroseconds( this->nPulseLength * nHighPulses); digitalWrite(this->nTransmitterPin, HIGH); - delayMicroseconds( this->nPulseLength * nLowPulses); + delayMicroseconds( this->nPulseLength * nHighPulses); digitalWrite(this->nTransmitterPin, LOW); - + delayMicroseconds( this->nPulseLength * nLowPulses); if (nRec != -1) { this->enableReceive(nRec, this->mCallback); } @@ -286,7 +282,7 @@ void RCSwitch::transmit(int nHighPulses, int nLowPulses) { * Waveform: | |___ */ void RCSwitch::send0() { - this->transmit(2,1); + this->transmit(1,3); } /** @@ -295,7 +291,7 @@ void RCSwitch::send0() { * Waveform: | |_ */ void RCSwitch::send1() { - this->transmit(1,2); + this->transmit(3,1); } @@ -335,7 +331,7 @@ void RCSwitch::sendTF() { * Waveform: | |_______________________________ */ void RCSwitch::sendSync() { - this->transmit(22,1); + this->transmit(1,31); } /** @@ -380,9 +376,9 @@ void RCSwitch::receiveInterrupt() { unsigned long delayTolerance = delay*0.3; for (int i = 1; i<changeCount ; i=i+2) { - if (timings[i] > delay-delayTolerance && timings[i] < delay+delayTolerance && timings[i+1] > delay*2-delayTolerance && timings[i+1] < delay*2+delayTolerance) { + if (timings[i] > delay-delayTolerance && timings[i] < delay+delayTolerance && timings[i+1] > delay*3-delayTolerance && timings[i+1] < delay*3+delayTolerance) { code = code << 1; - } else if (timings[i] > delay*2-delayTolerance && timings[i] < delay*+delayTolerance && timings[i+1] > delay-delayTolerance && timings[i+1] < delay+delayTolerance) { + } else if (timings[i] > delay*3-delayTolerance && timings[i] < delay*+delayTolerance && timings[i+1] > delay-delayTolerance && timings[i+1] < delay+delayTolerance) { code+=1; code = code << 1; } else {