Update buttons readme

This commit is contained in:
mycognosist 2021-03-04 08:12:35 +00:00
parent a33a4ceb9b
commit 8ddb76b66b
1 changed files with 55 additions and 11 deletions

View File

@ -1,14 +1,14 @@
# peach-buttons
[![GitHub logo](/assets/github_logo.png "peach-buttons GitHub repository")](https://github.com/peachcloud/peach-buttons) [![Build Status](https://travis-ci.com/peachcloud/peach-buttons.svg?branch=master)](https://travis-ci.com/peachcloud/peach-buttons) ![Version badge](https://img.shields.io/badge/version-0.1.0-<COLOR>.svg)
[![GitHub logo](/assets/github_logo.png "peach-buttons GitHub repository")](https://github.com/peachcloud/peach-buttons) [![Build Status](https://travis-ci.com/peachcloud/peach-buttons.svg?branch=master)](https://travis-ci.com/peachcloud/peach-buttons) ![Version badge](https://img.shields.io/badge/version-0.1.3-<COLOR>.svg)
GPIO microservice module for handling button presses. `peach-buttons` implements a JSON-RPC server with [Publish-Subscribe extension](https://docs.rs/jsonrpc-pubsub/11.0.0/jsonrpc_pubsub/). 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 subscribes to `peach-buttons` in order to update the state of the menu after each button press.
In the case of PeachCloud, the `peach-menu` microservice ([repo](https://github.com/peachcloud/peach-menu)) 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._
### Directory Tree
## Directory Tree
```bash
.
@ -22,7 +22,7 @@ _Note: This module is relatively stable but is still a work-in-progress._
│ └── main.rs // init logger, call run() & catch application errors
```
### Pin to Button to Button Code Mappings
## Pin to Button to Button Code Mappings
```bash
4 => Center => 0,
@ -36,7 +36,21 @@ _Note: This module is relatively stable but is still a work-in-progress._
_Note: `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._
### Setup
## Environment
The JSON-RPC WS server address and port can be configured with the `PEACH_BUTTONS_SERVER` environment variable:
`export PEACH_BUTTONS_SERVER=127.0.0.1:5000`
When not set, the value defaults to `127.0.0.1:5111`.
Logging is made availabe with `env_logger`:
`export RUST_LOG=info`
Other logging levels include `debug`, `warn` and `error`.
## Setup
Clone this repo:
@ -51,16 +65,46 @@ Run the binary with sudo:
`sudo ./target/release/peach-buttons`
Logging is made availabe with `env_logger`:
## Debian Packaging
`sudo RUST_LOG=info ./target/release/peach-buttons`
A `systemd` service file and Debian maintainer scripts are included in the `debian` directory, allowing `peach-buttons` to be easily bundled as a Debian package (`.deb`). The `cargo-deb` [crate](https://crates.io/crates/cargo-deb) can be used to achieve this.
_Other logging levels include debug, warn and error._
Install `cargo-deb`:
### Testing Subscription
`cargo install cargo-deb`
Move into the repo:
`cd peach-buttons`
Build the package:
`cargo deb`
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 `apt-get remove`):
`sudo apt-get purge peach-buttons`
## Testing Subscription
Request:
`{"id":1,"jsonrpc":"2.0","method":"subscribe_buttons"}`
Response:
@ -71,6 +115,6 @@ Event:
`{"jsonrpc":"2.0","method":"button_press","params":[0]}`
### Licensing
## Licensing
AGPL-3.0