GPIO microservice module for handling button presses.
peach-buttons implements a JSON-RPC server with Publish-Subscribe extension. Each button press results in a JSON-RPC request being sent over websockets to any subscribers. A button code for the pressed button is sent with the request to subscribers, allowing state-specific actions to be taken by the subscriber.
In the case of PeachCloud, the
peach-menu microservice (repo) subscribes to
peach-buttons in order to update the state of the menu after each button press.
Note: This module is relatively stable but is still a work-in-progress.
. ├── Cargo.lock ├── Cargo.toml ├── README.md ├── src │ ├── error.rs // custom ButtonError type and From implementation │ ├── interrupt.rs // interrupt handler with GPIO polling │ ├── lib.rs // RPC server and pubsub handler, pin definitions │ └── main.rs // init logger, call run() & catch application errors
4 => Center => 0, 27 => Left => 1, 23 => Right => 2, 17 => Up => 3, 22 => Down => 4, 5 => A => 5, 6 => B => 6
peach-buttons utilizes the GPIO character device ABI. This API, stabilized with Linux v4.4, deprecates the legacy sysfs interface to GPIOs that is planned to be removed from the upstream kernel after year 2020.
The JSON-RPC WS server address and port can be configured with the
PEACH_BUTTONS_SERVER environment variable:
When not set, the value defaults to
Logging is made availabe with
Other logging levels include
Clone this repo:
git clone https://github.com/peachcloud/peach-buttons.git
Move into the repo and compile:
cargo build --release
Run the binary with sudo:
systemd service file and Debian maintainer scripts are included in the
debian directory, allowing
peach-buttons to be easily bundled as a Debian package (
cargo-deb crate can be used to achieve this.
cargo install cargo-deb
Move into the repo:
Build the package:
The output will be written to
target/debian/peach-buttons_0.1.0_arm64.deb (or similar).
Build the package (aarch64):
cargo deb --target aarch64-unknown-linux-gnu
Install the package as follows:
sudo dpkg -i target/debian/peach-buttons_0.1.0_arm64.deb
The service will be automatically enabled and started.
Uninstall the service:
sudo apt-get remove peach-buttons
Remove configuration files (not removed with
sudo apt-get purge peach-buttons