| 703 | } |
| 704 | |
| 705 | void RCSwitch::handleInterrupt() { |
| 706 | |
| 707 | static unsigned int duration; |
| 708 | static unsigned int changeCount; |
| 709 | static unsigned long lastTime; |
| 710 | static unsigned int repeatCount; |
| 711 | |
| 712 | |
| 713 | long time = system_get_time(); //micros(); |
| 714 | duration = time - lastTime; |
| 715 | |
| 716 | if (duration > RCSwitch::nSeparationLimit && diff(duration, RCSwitch::timings[0]) < 200) { |
| 717 | repeatCount++; |
| 718 | changeCount--; |
| 719 | if (repeatCount == 2) { |
| 720 | for(unsigned int i = 1; i <= numProto; i++ ) { |
| 721 | if (receiveProtocol(i, changeCount)) { |
| 722 | // receive succeeded for protocol i |
| 723 | break; |
| 724 | } |
| 725 | } |
| 726 | repeatCount = 0; |
| 727 | } |
| 728 | changeCount = 0; |
| 729 | } else if (duration > RCSwitch::nSeparationLimit) { |
| 730 | changeCount = 0; |
| 731 | } |
| 732 | |
| 733 | if (changeCount >= RCSWITCH_MAX_CHANGES) { |
| 734 | changeCount = 0; |
| 735 | repeatCount = 0; |
| 736 | } |
| 737 | RCSwitch::timings[changeCount++] = duration; |
| 738 | lastTime = time; |
| 739 | } |
| 740 | #endif |
| 741 | |
| 742 | /** |
nothing calls this directly
no test coverage detected