Skip to main content

Introduction

Responds to complicated button presses across multiple buttons and repeated button presses. Given a set of buttons, presses can be recognized as belonging to any of those buttons, or to any subset of those buttons. Distinguishes between short presses and long presses, which may be combined in any order. Also recognizes an extra-long press, which may not be followed by additional presses.

Builds upon Adafruit's excellent adafruit_debouncer library to provide an alternative to that library's Button class.

Dependencies

This package depends on:

  • Adafruit-CircuitPython-Debouncer
  • Adafruit-Blinka

Usage Example

import time
import board  # provided by Adafruit-Blinka
from multibutton_debouncer import MultiButton

keep_on_ticking = True
def stop_ticking():
    nonlocal keep_on_ticking
    keep_on_ticking = False

buttons = MultiButton(board.D18, board.D5)

# a short press
buttons.set_callback([board.D18], ".", lambda: print("boop"))
buttons.set_callback([board.D5], ".", lambda: print("beep"))

# a long press
buttons.set_callback([board.D18], "_", lambda: print("boooop"))
buttons.set_callback([board.D5], "_", lambda: print("beeeep"))

# repeated presses
buttons.set_callback([board.D18], "...___...", lambda: print("SOS"))  repea

# repeated presses across multiple buttons
buttons.set_callback([board.D18, board.D5], "_..__", lambda: print("Two Bits!"))

# an extra-long press across multiple buttons
buttons.set_callback([board.D18, board.D5], "~", stop_ticking)

while keep_on_ticking:
    time.sleep(1/60)

    # `poll()` MUST be called frequently to update state
    # (this will be familiar to users of Adafruit-Debouncer)
    buttons.poll()

Updates and Feedback

The documentation is pretty limited. That'll be fixed presently, but until then, you may wish to look at the public methods of MultiButton as well as the Press enumeration.

This is my first contribution to the Python ecosystem. I will be grateful for any feedback you may have.

Metadata

Release files for multibutton-debouncer 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for multibutton-debouncer 0.0.1
File Size Uploaded Provenance Actions
multibutton-debouncer-0.0.1.tar.gz 5.8 kB Without provenance Details for multibutton-debouncer-0.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for multibutton-debouncer 0.0.1
File Interpreter ABI Platform Actions
multibutton_debouncer-0.0.1-py3-none-any.whl Python 3 none any Details for multibutton_debouncer-0.0.1-py3-none-any.whl

Total release size: 12.0 kB

Release files / multibutton-debouncer-0.0.1.tar.gz

Download URL multibutton-debouncer-0.0.1.tar.gz
Size 5.8 kB
Tags Source
SHA-256 checksum
How to use checksums
194fcf7cbc5172ae5fc58276c9bb4d922c87f6bf2274d27f8eb35dea76eaa05d
BLAKE2b-256 checksum
How to use checksums
2c9bd11885c656de168115f5190588e33acc0dd0307825ec52d89df58a232ac6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.2

Release files / multibutton_debouncer-0.0.1-py3-none-any.whl

Download URL multibutton_debouncer-0.0.1-py3-none-any.whl
Size 6.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e88a6096cad87a078dbd23ff82ea605249e0719d413f53a9124cbf620f1f6e01
BLAKE2b-256 checksum
How to use checksums
7d649091feea0cd785ca2c917e7476a7895d82c63999852ecc45751b03468d23
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.2

Security for multibutton-debouncer 0.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page