Another bugfix, improve header documentation a bit.

This commit is contained in:
Anna Rose 2021-11-24 05:57:41 +00:00
parent a9c80c2ed5
commit 2ce994677a
3 changed files with 16 additions and 7 deletions

View File

@ -33,14 +33,19 @@ class Joystick {
void Init(); void Init();
void Update(); void Update();
// Add a button to the joystick. // Use these functions to add a button to the joystick.
// Button types are documented in the ButtonType enum. // Button types are documented in the ButtonType enum. See Button.h for details.
// If `pullup` is true, your button should connect the pin to ground. (also be sure that your board supports INPUT_PULLUP on that pin) // If 'pullup' is true, your button should connect the pin to ground. (also be sure that your board supports INPUT_PULLUP on that pin)
// If `pullup` is false, your button should connect the pin to VCC. // If 'pullup' is false, your button should connect the pin to VCC.
// Setting `analogOnly` to true indicates your button *must* be read with analog code, such as the A6 and A7 pins
// on the Arduino Nano. // Add a button connected directly to a pin on the microcontroller.
void AddButton(uint8_t pin, ButtonType type, bool pullup=true); void AddButton(uint8_t pin, ButtonType type, bool pullup=true);
// Add a button connected to a channel on a Multiplexer.
// FIXME: This doesn't currently work!
void AddMuxButton(uint8_t channel, Mux* mux, ButtonType type, bool pullup=true); void AddMuxButton(uint8_t channel, Mux* mux, ButtonType type, bool pullup=true);
// Add a button connected to a scan matrix.
void AddMatrixButton(uint8_t row, uint8_t col, Matrix* matrix, ButtonType type, bool pullup=true); void AddMatrixButton(uint8_t row, uint8_t col, Matrix* matrix, ButtonType type, bool pullup=true);
// Add a rotary encoder. ENCODER button types allow you to treat an encoder as a momentary button or an axis (TODO) // Add a rotary encoder. ENCODER button types allow you to treat an encoder as a momentary button or an axis (TODO)

View File

@ -19,7 +19,7 @@ uint8_t Reader::getMode(bool pullup) {
DirectReader::DirectReader(uint8_t pin, bool inverted) : Reader(inverted) { DirectReader::DirectReader(uint8_t pin, bool inverted) : Reader(inverted) {
uint8_t mode = getMode(inverted); uint8_t mode = getMode(inverted);
this->bouncer.attach(pin); this->bouncer.attach(pin, mode);
} }
bool DirectReader::Update() { bool DirectReader::Update() {

View File

@ -18,6 +18,7 @@ using namespace admux;
#define BTN2 5 #define BTN2 5
#define BTN3 6 #define BTN3 6
#define BTN4 7 #define BTN4 7
#define BTN5 A0
// pins 8-13 are attached to a 3x3 scanning input matrix. Pins 8-10 are the row pins, 11-13 are the column pins. // pins 8-13 are attached to a 3x3 scanning input matrix. Pins 8-10 are the row pins, 11-13 are the column pins.
#define MATRIX1 8,11 #define MATRIX1 8,11
@ -69,6 +70,9 @@ void setup() {
// One press will "press and hold" the button. The next press releases the button. // One press will "press and hold" the button. The next press releases the button.
js.AddButton(BTN4, BUTTON_LATCHED_MOMENTARY); js.AddButton(BTN4, BUTTON_LATCHED_MOMENTARY);
// This is a standard PASSTHRU button. It simply mirrors the actual state of the physical button.
js.AddButton(BTN5, BUTTON_PASSTHRU);
// One way to get more room for inputs is to use a scan matrix. // One way to get more room for inputs is to use a scan matrix.
// See http://blog.komar.be/how-to-make-a-keyboard-the-matrix/ for a very detailed discussion of how these work. // See http://blog.komar.be/how-to-make-a-keyboard-the-matrix/ for a very detailed discussion of how these work.
// This is a 3x3 example, so we can get 9 buttons out of 6 inputs. // This is a 3x3 example, so we can get 9 buttons out of 6 inputs.