MCPcopy Create free account
hub / github.com/DanielOgorchock/ST_Anything / receiveProtocol1

Method receiveProtocol1

Arduino/libraries/RCSwitch/RCSwitch.cpp:642–676  ·  view source on GitHub ↗

* */

Source from the content-addressed store, hash-verified

640 *
641 */
642bool RCSwitch::receiveProtocol1(unsigned int changeCount){
643
644 unsigned long code = 0;
645 unsigned long delay = RCSwitch::timings[0] / 31;
646 unsigned long delayTolerance = delay * RCSwitch::nReceiveTolerance * 0.01;
647
648 for (int i = 1; i<changeCount ; i=i+2) {
649
650 if (RCSwitch::timings[i] > delay-delayTolerance && RCSwitch::timings[i] < delay+delayTolerance && RCSwitch::timings[i+1] > delay*3-delayTolerance && RCSwitch::timings[i+1] < delay*3+delayTolerance) {
651 code = code << 1;
652 } else if (RCSwitch::timings[i] > delay*3-delayTolerance && RCSwitch::timings[i] < delay*3+delayTolerance && RCSwitch::timings[i+1] > delay-delayTolerance && RCSwitch::timings[i+1] < delay+delayTolerance) {
653 code+=1;
654 code = code << 1;
655 } else {
656 // Failed
657 i = changeCount;
658 code = 0;
659 }
660 }
661 code = code >> 1;
662 if (changeCount > 6) { // ignore < 4bit values as there are no devices sending 4bit values => noise
663 RCSwitch::nReceivedValue = code;
664 RCSwitch::nReceivedBitlength = changeCount / 2;
665 RCSwitch::nReceivedDelay = delay;
666 RCSwitch::nReceivedProtocol = 1;
667 }
668
669 if (code == 0){
670 return false;
671 }else if (code != 0){
672 return true;
673 }
674
675
676}
677
678bool RCSwitch::receiveProtocol2(unsigned int changeCount){
679

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected