Skip to content

Commit

Permalink
Merge pull request #38 from turbo-lab/master
Browse files Browse the repository at this point in the history
Improve receiving quality
  • Loading branch information
milaq authored Jan 23, 2019
2 parents 27532d4 + 3bbd31c commit 71fbe05
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions rpi_rf/rpi_rf.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def rx_callback(self, gpio):
duration = timestamp - self._rx_last_timestamp

if duration > 5000:
if duration - self._rx_timings[0] < 200:
if abs(duration - self._rx_timings[0]) < 200:
self._rx_repeat_count += 1
self._rx_change_count -= 1
if self._rx_repeat_count == 2:
Expand All @@ -231,11 +231,11 @@ def _rx_waveform(self, pnum, change_count, timestamp):
delay_tolerance = delay * self.rx_tolerance / 100

for i in range(1, change_count, 2):
if (self._rx_timings[i] - delay * PROTOCOLS[pnum].zero_high < delay_tolerance and
self._rx_timings[i+1] - delay * PROTOCOLS[pnum].zero_low < delay_tolerance):
if (abs(self._rx_timings[i] - delay * PROTOCOLS[pnum].zero_high) < delay_tolerance and
abs(self._rx_timings[i+1] - delay * PROTOCOLS[pnum].zero_low) < delay_tolerance):
code <<= 1
elif (self._rx_timings[i] - delay * PROTOCOLS[pnum].one_high < delay_tolerance and
self._rx_timings[i+1] - delay * PROTOCOLS[pnum].one_low < delay_tolerance):
elif (abs(self._rx_timings[i] - delay * PROTOCOLS[pnum].one_high) < delay_tolerance and
abs(self._rx_timings[i+1] - delay * PROTOCOLS[pnum].one_low) < delay_tolerance):
code <<= 1
code |= 1
else:
Expand Down

0 comments on commit 71fbe05

Please sign in to comment.