Better Buttons with Debouncing CircuitPython School

Поделиться
HTML-код
  • Опубликовано: 29 ноя 2024

Комментарии • 3

  • @profgallaugher
    @profgallaugher  3 месяца назад

    The reason why CTRL-Q, T didn't get out of Tio is because the actual command is CTRL-T, Q. Sorry about that!

  • @davidpulcifer3792
    @davidpulcifer3792 4 месяца назад

    Is having the pressed and released in separate if statements instead of an if/elif structure going to create any unexpected behavior that you know of?
    In my testing they operated the same, but I was curious if there were any edge cases I'm not thinking of.
    if buttonA.pressed:
    pixels.fill(TEAL)
    press_count_A += 1
    print(f"Press count A: {press_count_A}")

    if buttonA.released:
    pixels.fill(BLACK)

    • @profgallaugher
      @profgallaugher  4 месяца назад

      Good question. There is no special reason I didn’t put them in an if elif instead of two if’s. The difference is if it were in an elif then if the first if were true the second would not be evaluated two ifs will evaluate the second if even if the first is true. I don’t have equipment with me as I write this but the only case to consider is if you’d want to deal with simultaneous push but if so if put that in an if/and and treat it as a single condition. Cheers