Update code, in the process improving the board design.

This commit is contained in:
Anna Rose Wiggins 2021-11-18 15:48:29 -05:00
parent a9a08a9684
commit 1921829c90
4 changed files with 297 additions and 274 deletions

View file

@ -1,53 +1,75 @@
#include <Joystick.h>
#include <Mux.h>
Joystick joystick(false);
// These defines match the board schematic
#define ENC1 2, 3
#define ENC2 4, 5
#define BTN1 6
#define BTN2 7
#define BTN3 8
#define BTN4 9
#define BTN5 10
#define BTN6 11
#define BTN7 12
#define BTN8 13
#define BTN9 A0
// Buttons 10 and higher are all on A1 (the MUX signal pin), these are multiplexer channel IDs
#define BTN10 0
#define BTN11 1
#define BTN12 2
#define BTN13 3
#define BTN14 4
#define BTN15 5
#define BTN16 6
#define BTN17 7
#define BTN18 8
#define BTN19 9
#define BTN20 10
#define BTN21 11
#define BTN22 12
#define KBTN1 13
#define KBTN2 14
#define KBTN3 15
void setup() {
// for (uint8_t i = 0; i < 14; i++) {
// joystick.AddButton(i, BUTTON_PASSTHRU);
// }
// joystick.AddButton(A0, BUTTON_PASSTHRU);
// joystick.AddButton(A1, BUTTON_PASSTHRU);
// joystick.AddButton(A2, BUTTON_PASSTHRU);
// joystick.AddButton(A3, BUTTON_PASSTHRU);
// joystick.AddButton(A4, BUTTON_PASSTHRU);
// joystick.AddButton(A5, BUTTON_PASSTHRU);
// Encoders
joystick.AddEncoder(ENC1, ENCODER_PULSED_SPLIT);
joystick.AddEncoder(ENC2, ENCODER_PULSED_SPLIT);
// // Power switches
joystick.AddButton(2, BUTTON_PULSED_DOUBLE_ACTION_SPLIT);
joystick.AddButton(3, BUTTON_PULSED_DOUBLE_ACTION_SPLIT);
joystick.AddButton(4, BUTTON_PULSED_DOUBLE_ACTION_SPLIT);
joystick.AddButton(5, BUTTON_PULSED_DOUBLE_ACTION_SPLIT);
joystick.AddButton(BTN1, BUTTON_PULSED_DOUBLE_ACTION_SPLIT);
joystick.AddButton(BTN2, BUTTON_PULSED_DOUBLE_ACTION_SPLIT);
joystick.AddButton(BTN3, BUTTON_PULSED_DOUBLE_ACTION_SPLIT);
joystick.AddButton(BTN4, BUTTON_PULSED_DOUBLE_ACTION_SPLIT);
// // HUD modes
joystick.AddButton(8, BUTTON_PASSTHRU);
joystick.AddButton(7, BUTTON_PASSTHRU);
joystick.AddButton(6, BUTTON_PASSTHRU);
// // Encoders
// // FIXME: these seem to be wired wrong.
// // joystick.AddEncoder(10, 11, ENCODER_PULSED_SPLIT);
// // joystick.AddEncoder(12, 13, ENCODER_PULSED_SPLIT);
joystick.AddButton(BTN5, BUTTON_PASSTHRU);
joystick.AddButton(BTN6, BUTTON_PASSTHRU);
joystick.AddButton(BTN7, BUTTON_PASSTHRU);
// // Mining Modules
joystick.AddButton(9, BUTTON_PASSTHRU);
joystick.AddButton(10, BUTTON_PASSTHRU);
joystick.AddButton(11, BUTTON_PASSTHRU);
joystick.AddButton(BTN8, BUTTON_PASSTHRU);
joystick.AddButton(BTN9, BUTTON_PASSTHRU);
joystick.AddButton(BTN10, BUTTON_PASSTHRU, true, mux);
// // Flight Modes
joystick.AddButton(A1, BUTTON_PASSTHRU);
joystick.AddButton(A2, BUTTON_PASSTHRU);
joystick.AddButton(A3, BUTTON_PASSTHRU);
joystick.AddButton(A4, BUTTON_PASSTHRU);
joystick.AddButton(BTN11, BUTTON_PASSTHRU, true, mux);
joystick.AddButton(BTN12, BUTTON_PASSTHRU, true, mux);
joystick.AddButton(BTN13, BUTTON_PASSTHRU, true, mux);
joystick.AddButton(BTN14, BUTTON_PASSTHRU, true, mux);
// // Doors & Lights
// // TODO: Need multiplexer setup
joystick.AddButton(12, BUTTON_PULSED_DOUBLE_ACTION);
joystick.AddButton(A0, BUTTON_PULSED_DOUBLE_ACTION);
joystick.AddButton(BTN15, BUTTON_PULSED_DOUBLE_ACTION, true, mux);
joystick.AddButton(BTN16, BUTTON_PULSED_DOUBLE_ACTION_SPLIT, true, mux);
joystick.AddButton(BTN17, BUTTON_PULSED_DOUBLE_ACTION_SPLIT, true, mux);
// // Emergency Panel
// // TODO: Need multiplexer setup
joystick.AddButton(A5, BUTTON_PASSTHRU);
joystick.AddButton(KBTN1, BUTTON_PASSTHRU);
joystick.AddButton(KBTN2, BUTTON_PASSTHRU);
joystick.AddButton(KBTN3, BUTTON_PASSTHRU);
joystick.Init();
}