Skip to content

Add was_pressed method for button presses? #50

Closed
@seantibor

Description

@seantibor

The microbit version of micropython has two different methods for accessing button state. The first, is_pressed(), works much like the implementation in the cpx library, and is useful for getting the current button state. This is documented on Read The Docs

The second method, was_pressed(), returns True if the button has been pressed since the last time the method was called or since startup if this is the first time the method has been called.

The second method is useful for beginner programmers to detect button presses while the device may have been sleeping or performing other tasks. This also simplifies debounce and sustained presses.

Is it possible to add a method like this to the cpx library to ease the use of buttons?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions