Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PWMLED doesn't pulse until function returns when called via button press #111

Open
dwhweb opened this issue Aug 25, 2023 · 0 comments
Open
Labels
bug Something isn't working

Comments

@dwhweb
Copy link

dwhweb commented Aug 25, 2023

Describe the bug
As per the title, if you attempt to pulse a PWMLED via callback associated with a button press, the LED doesn't actually start pulsing until after the function returns. I'd assume this is something to do with how callbacks are handled within the library, as the function works as expected if you call it directly. blink() displays similar behaviour, in that the LED is initially illuminated when the function is called but doesn't actually start blinking until after the function returns.

To Reproduce
Run the following code (obviously GPIO pins need to be changed as appropriate) and press your button.

from picozero import Button, PWMLED
import time

switch = Button(15) 
green_led = PWMLED(13)
green_led.value = 0

def pulse_led():
    print("Pulsing LED...")
    green_led.pulse(fade_in_time=0.25)
    time.sleep(5)
    print("Returning...")

switch.when_pressed = pulse_led

Expected behaviour
I'd expect the LED to start pulsing as soon as the first statement is printed and before the function returns.

System information:

  • OS: Arch Linux (6.4.11-arch2-1)
  • Development environment: Thonny
  • Picozero version: 0.4.2
  • Micropython version: 1.20.0
  • Development board: Raspberry Pi Pico W
@dwhweb dwhweb added the bug Something isn't working label Aug 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant