31 unsigned long rcReceivedValue = 0; |
31 unsigned long rcReceivedValue = 0; |
32 unsigned int rcReceivedBitlength = 0; |
32 unsigned int rcReceivedBitlength = 0; |
33 unsigned int rcReceivedDelay = 0; |
33 unsigned int rcReceivedDelay = 0; |
34 unsigned int rcReceivedProtocol = 0; |
34 unsigned int rcReceivedProtocol = 0; |
35 int rcReceiveTolerance = 60; |
35 int rcReceiveTolerance = 60; |
36 int rcReceiverInterrupt = -1; |
36 int rcReceiverInterruptPin = -1; |
37 |
37 |
38 unsigned int timings[RCSWITCH_MAX_CHANGES]; |
38 unsigned int timings[RCSWITCH_MAX_CHANGES]; |
39 int rcTransmitterPin = -1; |
39 int rcTransmitterPin = -1; |
40 int rcPulseLength = 350; |
40 int rcPulseLength = 350; |
41 int rcRepeatTransmit = 10; |
41 int rcRepeatTransmit = 10; |
527 |
527 |
528 |
528 |
529 void transmit(int nHighPulses, int nLowPulses) |
529 void transmit(int nHighPulses, int nLowPulses) |
530 { |
530 { |
531 bool disabled_Receive = false; |
531 bool disabled_Receive = false; |
532 int nReceiverInterrupt_backup = rcReceiverInterrupt; |
532 int nReceiverInterrupt_backup = rcReceiverInterruptPin; |
533 |
533 |
534 if (rcTransmitterPin != -1) { |
534 if (rcTransmitterPin != -1) { |
535 if (rcReceiverInterrupt != -1) { |
535 if (rcReceiverInterruptPin != -1) { |
536 disableReceive(); |
536 disableReceive(); |
537 disabled_Receive = true; |
537 disabled_Receive = true; |
538 } |
538 } |
539 digitalWrite(rcTransmitterPin, HIGH); |
539 digitalWrite(rcTransmitterPin, HIGH); |
540 delayMicroseconds( rcPulseLength * nHighPulses); |
540 delayMicroseconds( rcPulseLength * nHighPulses); |
656 |
656 |
657 |
657 |
658 /* |
658 /* |
659 * Enable receiving data |
659 * Enable receiving data |
660 */ |
660 */ |
661 void enableReceiveIRQ(int interrupt) { |
661 void enableReceiveIRQ(int Pin) { |
662 rcReceiverInterrupt = interrupt; |
662 rcReceiverInterruptPin = Pin; |
663 enableReceive(); |
663 enableReceive(); |
664 } |
664 } |
665 |
665 |
666 void enableReceive(void) { |
666 void enableReceive(void) { |
667 if (rcReceiverInterrupt != -1) { |
667 if (rcReceiverInterruptPin != -1) { |
668 rcReceivedValue = 0; |
668 rcReceivedValue = 0; |
669 rcReceivedBitlength = 0; |
669 rcReceivedBitlength = 0; |
670 wiringPiISR(rcReceiverInterrupt, INT_EDGE_BOTH, &handleInterrupt); |
670 wiringPiISR(rcReceiverInterruptPin, INT_EDGE_BOTH, &handleInterrupt); |
671 } |
671 } |
672 } |
672 } |
673 |
673 |
674 |
674 |
675 |
675 |
676 /* |
676 /* |
677 * Disable receiving data |
677 * Disable receiving data |
678 */ |
678 */ |
679 void disableReceive() { |
679 void disableReceive() { |
680 // wiringPi disable interrupts ??? |
680 // wiringPi disable interrupts ??? |
681 rcReceiverInterrupt = -1; |
681 rcReceiverInterruptPin = -1; |
682 } |
682 } |
683 |
683 |
684 |
684 |
685 |
685 |
686 bool available(void) { |
686 bool available(void) { |