Make sure bounce is always integer when passed to RPi.GPIO and RPIO, and
added some checks to make sure a negative bounce isn't specified either
This commit is contained in:
Dave Jones
2016-03-19 17:02:46 +00:00
parent 807bdff2e4
commit 9432046392
4 changed files with 14 additions and 2 deletions

View File

@@ -19,6 +19,7 @@ from ..exc import (
PinSetInput,
PinFixedPull,
PinInvalidPull,
PinInvalidBounce,
)
@@ -177,10 +178,12 @@ class RPIOPin(Pin):
return None if self._bounce is None else (self._bounce / 1000)
def _set_bounce(self, value):
if value is not None and value < 0:
raise PinInvalidBounce('bounce must be 0 or greater')
f = self.when_changed
self.when_changed = None
try:
self._bounce = None if value is None else (value * 1000)
self._bounce = None if value is None else int(value * 1000)
finally:
self.when_changed = f