Update documentation.

This commit is contained in:
Anna Rose 2021-11-24 06:04:21 +00:00
parent 2ce994677a
commit 557aec4644

View File

@ -12,18 +12,22 @@ This is a library that builds and sends USB HID Joystick reports, making it easy
arduino-cli lib install "Analog-Digital Multiplexers"
2. Put the arduino-joystick directory into your Arduino libraries directory.
## Compiling and running the example code via SimulIDE
1. Run `make` from the `example` directory.
2. Load `example.simu` in SimulIDE.
3. Right-click on the Arduino component, and click "load firmware". Select the `.hex` file created in the `example/` directory.
4. Click the red `Power Circuit` icon at the top of the SimulIDE window.
## Usage
1. In your arduino sketch, add the includes:
1. In your arduino sketch, add the include:
#include <Joystick.h>
2. Create a Joystick object:
Joystick joystick(true);
3. Add buttons and axes in setup() with Joystick::AddButton(), and call Joystick::Update() in loop().
3. Add buttons and axes in `setup()` with the `Add*` functions from `Joystick.h`. Call `joystick.Update()` in your `loop()` function. Also call `joystick.Init()` during `setup()`.
4. Upload the sketch, connect to the serial monitor (at 115200 baud) and test the buttons.
5. Set the joystick's `debug` parameter to `false` and re-upload the sketch. The arduino will NOT work in joystick mode with debug set to `true`!
6. Flash the `arduino-big-joystick` firmware onto the USB Controller.
### Advanced usage: multiplexers
### Advanced usage: multiplexers, matrices
If you need more buttons than your board has pins, multiplexers (such as [this one](https://www.sparkfun.com/products/13906) and [this one](https://www.sparkfun.com/products/9056)) are a popular solution. This library supports multiplexers! To use them, you need to do some extra work.
Call the `AddMux()` method and pass it the pins the multiplexer is connected to. You'll need to `#include <Mux.h>` to access `admux::Pinset`. `AddMux()` will return a `mux_id` for subsequently passing to `AddButton()`. The `pin` parameter for all multiplexed buttons should be the same as the multiplexer's `signal_pin`.
If you need more buttons than your board has pins, this library supports keyboard-style scan matrices as well as multiplexers. **(FIXME: multiplexers aren't working yet)** See the example sketch in the `example/` directory for usage details. Note that, for matrices, the *rows* are the inputs that will be read, and the *columns* are the outputs that will sink the current. Current should flow (via diodes) from the rows to the columns. See the `example.simu` SimulIDE file for an example circuit.