Skip to content

Commit

Permalink
RCSwitch: update transmit function
Browse files Browse the repository at this point in the history
The raspberry pi has a pretty inaccurate hardware clock.
In order to even out irregularities instead of a single sleep interval of n*length, make it n intervals.
  • Loading branch information
xkonni committed Nov 24, 2012
1 parent bad09fe commit 38e6b6b
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions RCSwitch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,10 +344,14 @@ void RCSwitch::transmit(int nHighPulses, int nLowPulses) {
this->disableReceive();
disabled_Receive = true;
}
digitalWrite(this->nTransmitterPin, HIGH);
delayMicroseconds( this->nPulseLength * nHighPulses);
digitalWrite(this->nTransmitterPin, LOW);
delayMicroseconds( this->nPulseLength * nLowPulses);
for(int i=0; i<nHighPulses; i++) {
digitalWrite(this->nTransmitterPin, HIGH);
delayMicroseconds( this->nPulseLength);
}
for(int i=0; i<nLowPulses; i++) {
digitalWrite(this->nTransmitterPin, LOW);
delayMicroseconds( this->nPulseLength);
}
if(disabled_Receive){
this->enableReceive(nReceiverInterrupt_backup);
}
Expand Down

0 comments on commit 38e6b6b

Please sign in to comment.