https://github.com/elehobica/pico_buttons
Button handling library for Raspberry Pi Pico / Pico 2
https://github.com/elehobica/pico_buttons
raspberry-pi-pico raspberry-pi-pico-2
Last synced: 7 days ago
JSON representation
Button handling library for Raspberry Pi Pico / Pico 2
- Host: GitHub
- URL: https://github.com/elehobica/pico_buttons
- Owner: elehobica
- License: bsd-2-clause
- Created: 2023-08-15T11:09:57.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2025-04-20T10:30:50.000Z (2 months ago)
- Last Synced: 2025-04-20T11:56:19.499Z (2 months ago)
- Topics: raspberry-pi-pico, raspberry-pi-pico-2
- Language: C++
- Homepage:
- Size: 24.4 KB
- Stars: 3
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Buttons handling library for Raspberry Pi Pico / Pico 2
## Overview
This project is a library for handling multiple buttons on Raspberry Pi Pico / Pico 2This project features to detect:
* Single Push event
* Repeated Single Push event
* Multiple Push event (exclusive with Repeated Single)
* Long (Long) Push event (exclusive with Repeated Single)
* Switch On/Off events## Notes
* If Multiple detection enabled, time lag defined by 'actFinishCnt' is needed to determine action
* Repeat count information of Repeated Single detection is served for UI items to accelerate something by continuous button push
* Use NewButtonConfig() for customizing button detection parameters other than default configurations## Supported Board and Device
* Raspberry Pi Pico
* Raspberry Pi Pico 2## How to build
* See ["Getting started with Raspberry Pi Pico"](https://datasheets.raspberrypi.org/pico/getting-started-with-pico.pdf)
* Put "pico-sdk", "pico-examples" and "pico-extras" on the same level with this project folder.
* Set environmental variables for PICO_SDK_PATH, PICO_EXTRAS_PATH and PICO_EXAMPLES_PATH
* Confirmed with Pico SDK 2.1.1
```
> git clone -b 2.1.1 https://github.com/raspberrypi/pico-sdk.git
> cd pico-sdk
> git submodule update -i
> cd ..
> git clone -b sdk-2.1.1 https://github.com/raspberrypi/pico-examples.git
>
> git clone -b sdk-2.1.1 https://github.com/raspberrypi/pico-extras.git
>
> git clone -b main https://github.com/elehobica/pico_buttons.git
```
### Windows
* Build is confirmed with Developer Command Prompt for VS 2022 and Visual Studio Code on Windows environment
* Confirmed with cmake-3.27.2-windows-x86_64 and gcc-arm-none-eabi-10.3-2021.10-win32
* Lanuch "Developer Command Prompt for VS 2022"
```
> cd pico_buttons\example
> mkdir build && cd build
> cmake -G "NMake Makefiles" .. ; (for Raspberry Pi Pico 1 series)
> cmake -G "NMake Makefiles" -DPICO_PLATFORM=rp2350 -DPICO_BOARD=pico2 .. ; (for Raspberry Pi Pico 2)
> nmake
```
* Put "*.uf2" on RPI-RP2 or RP2350 drive
### Linux
* Build is confirmed with [pico-sdk-dev-docker:sdk-2.1.1-1.0.0]( https://hub.docker.com/r/elehobica/pico-sdk-dev-docker)
* Confirmed with cmake-3.22.1 and arm-none-eabi-gcc (15:10.3-2021.07-4) 10.3.1
```
$ cd pico_buttons/example
$ mkdir build && cd build
$ cmake .. # (for Raspberry Pi Pico 1 series)
$ cmake -DPICO_PLATFORM=rp2350 -DPICO_BOARD=pico2 .. # (for Raspberry Pi Pico 2)
$ make -j4
```
* Download "*.uf2" on RPI-RP2 or RP2350 drive