Refactor code substantially, moving buttons into separate classes and using a lot more pointers to conserve memory until it is needed.
This commit is contained in:
@ -9,6 +9,8 @@
|
||||
#include <Joystick.h>
|
||||
#include <Mux.h>
|
||||
|
||||
using namespace admux;
|
||||
|
||||
bool debug = false;
|
||||
Joystick joystick(debug);
|
||||
|
||||
@ -29,17 +31,17 @@ void setup() {
|
||||
joystick.AddButton(A0, BUTTON_PASSTHRU);
|
||||
|
||||
// to get more room for our inputs, we add an 8-bit multiplexer
|
||||
uint8_t mux = joystick.AddMux(A1, admux::Pinset(A2, A3, A4, A5), 4);
|
||||
Mux* mux = new Mux(Pin(A1, INPUT_PULLUP, PinType::Digital), Pinset(A2, A3, A4, A5));
|
||||
|
||||
// now we can add the rest of the buttons
|
||||
joystick.AddMuxButton(mux, 0, BUTTON_PASSTHRU);
|
||||
joystick.AddMuxButton(mux, 1, BUTTON_PASSTHRU);
|
||||
joystick.AddMuxButton(mux, 2, BUTTON_PASSTHRU);
|
||||
joystick.AddMuxButton(mux, 3, BUTTON_PASSTHRU);
|
||||
joystick.AddMuxButton(mux, 4, BUTTON_PASSTHRU);
|
||||
joystick.AddMuxButton(mux, 5, BUTTON_PASSTHRU);
|
||||
joystick.AddMuxButton(mux, 6, BUTTON_PASSTHRU);
|
||||
joystick.AddMuxButton(mux, 7, BUTTON_PASSTHRU);
|
||||
joystick.AddButton(0, BUTTON_PASSTHRU, true, mux);
|
||||
joystick.AddButton(1, BUTTON_PASSTHRU, true, mux);
|
||||
joystick.AddButton(2, BUTTON_PASSTHRU, true, mux);
|
||||
joystick.AddButton(3, BUTTON_PASSTHRU, true, mux);
|
||||
joystick.AddButton(4, BUTTON_PASSTHRU, true, mux);
|
||||
joystick.AddButton(5, BUTTON_PASSTHRU, true, mux);
|
||||
joystick.AddButton(6, BUTTON_PASSTHRU, true, mux);
|
||||
joystick.AddButton(7, BUTTON_PASSTHRU, true, mux);
|
||||
|
||||
joystick.Init();
|
||||
}
|
||||
|
Reference in New Issue
Block a user