diff --git a/docs/changelog.rst b/docs/changelog.rst index eb5e05e..78a08eb 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -3,6 +3,12 @@ Change log .. currentmodule:: picozero +0.4.2 - 2023-05-12 +------------------ + ++ Bug fix relating to DigitalInputDevice bounce times ++ Updated tests after a change in micropython 1.20+ + 0.4.1 - 2022-12-22 ------------------ diff --git a/docs/conf.py b/docs/conf.py index 3afb34a..7438ce6 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -47,7 +47,7 @@ def __getattr__(cls, name): author = 'Raspberry Pi Foundation' # The full version, including alpha/beta/rc tags -release = '0.4.1' +release = '0.4.2' # -- General configuration --------------------------------------------------- diff --git a/picozero/__init__.py b/picozero/__init__.py index 8e8fb43..794583e 100644 --- a/picozero/__init__.py +++ b/picozero/__init__.py @@ -1,6 +1,6 @@ __name__ = "picozero" __package__ = "picozero" -__version__ = '0.4.1' +__version__ = '0.4.2' __author__ = "Raspberry Pi Foundation" from .picozero import ( diff --git a/picozero/picozero.py b/picozero/picozero.py index 5323602..e03ed01 100644 --- a/picozero/picozero.py +++ b/picozero/picozero.py @@ -596,7 +596,7 @@ def LED(pin, pwm=True, active_high=True, initial_value=False): :param int pin: The pin that the device is connected to. - :param int pin: + :param bool pwm: If `pwm` is :data:`True` (the default), a :class:`PWMLED` will be returned. If `pwm` is :data:`False`, a :class:`DigitalLED` will be returned. A :class:`PWMLED` can control the brightness of the LED but @@ -1598,7 +1598,7 @@ def _pin_change(self, p): while ticks_ms() < stop: # keep checking, reset the stop if the value changes if p.value() != last_state: - stop = ticks_ms() + self._bounce_time + stop = ticks_ms() + (self._bounce_time * 1000) last_state = p.value() # re-enable the interupt diff --git a/setup.py b/setup.py index 03755d7..73f6af5 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ __project__ = 'picozero' __packages__ = ['picozero'] __desc__ = 'A beginner-friendly library for using common electronics components with the Raspberry Pi Pico. ' -__version__ = '0.4.1' +__version__ = '0.4.2' __author__ = "Raspberry Pi Foundation" __author_email__ = 'learning@raspberrypi.org' __license__ = 'MIT' diff --git a/tests/test_picozero.py b/tests/test_picozero.py index f47ee5d..d1cbcd0 100644 --- a/tests/test_picozero.py +++ b/tests/test_picozero.py @@ -179,8 +179,10 @@ def test_pwm_output_device_alt_values(self): self.assertEqual(d.freq, 200) d.off() - # pwm returns 1 less than the duty_factor unless the duty is set to the maximum 65535 - self.assertEqual(d._pwm.duty_u16(), 9999) + # prior to micropython v1.20 PWM returned 1 less than the duty_factor + # unless the duty was set to the maximum 65535 + # self.assertEqual(d._pwm.duty_u16(), 9999) + self.assertEqual(d._pwm.duty_u16(), 10000) self.assertAlmostEqual(d.value, 0, places=2) d.on()