Update board and code to use a scan matrix. This is cheaper, has a smaller footprint, and is at least as performant as the multiplexer approach.
This commit is contained in:
parent
28c135140c
commit
35098e12a6
BIN
flight-panel-2021-11/Flight Panel 2021-11 Board.pdf
Normal file
BIN
flight-panel-2021-11/Flight Panel 2021-11 Board.pdf
Normal file
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -1,75 +1,82 @@
|
||||||
#include <Joystick.h>
|
#include <Joystick.h>
|
||||||
#include <Mux.h>
|
#include <Matrix.h>
|
||||||
|
|
||||||
Joystick joystick(false);
|
Joystick joystick(false);
|
||||||
|
|
||||||
// These defines match the board schematic
|
// These defines match the board schematic
|
||||||
#define ENC1 2, 3
|
#define ENC1 2, 4
|
||||||
#define ENC2 4, 5
|
#define ENC2 3, 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
|
// Matrix defines
|
||||||
#define BTN10 0
|
#define R0 6
|
||||||
#define BTN11 1
|
#define R1 7
|
||||||
#define BTN12 2
|
#define R2 8
|
||||||
#define BTN13 3
|
#define R3 9
|
||||||
#define BTN14 4
|
#define R4 10
|
||||||
#define BTN15 5
|
#define C0 A3
|
||||||
#define BTN16 6
|
#define C1 A2
|
||||||
#define BTN17 7
|
#define C2 A1
|
||||||
#define BTN18 8
|
#define C3 A0
|
||||||
#define BTN19 9
|
|
||||||
#define BTN20 10
|
#define BTN1 R0,C0
|
||||||
#define BTN21 11
|
#define BTN2 R1,C0
|
||||||
#define BTN22 12
|
#define BTN3 R2,C0
|
||||||
#define KBTN1 13
|
#define BTN4 R3,C0
|
||||||
#define KBTN2 14
|
#define BTN5 R4,C0
|
||||||
#define KBTN3 15
|
#define BTN6 R0,C1
|
||||||
|
#define BTN7 R1,C1
|
||||||
|
#define BTN8 R2,C1
|
||||||
|
#define BTN9 R3,C1
|
||||||
|
#define BTN10 R0,C2
|
||||||
|
#define BTN11 R1,C2
|
||||||
|
#define BTN12 R2,C2
|
||||||
|
#define BTN13 R3,C2
|
||||||
|
#define BTN14 R0,C3
|
||||||
|
#define BTN15 R1,C3
|
||||||
|
#define BTN16 R2,C3
|
||||||
|
#define BTN17 R3,C3
|
||||||
|
#define KBTN1 R4,C1
|
||||||
|
#define KBTN2 R4,C2
|
||||||
|
#define KBTN3 R4,C3
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
// Encoders
|
// Encoders
|
||||||
joystick.AddEncoder(ENC1, ENCODER_PULSED_SPLIT);
|
joystick.AddEncoder(ENC1, ENCODER_PULSED_SPLIT);
|
||||||
joystick.AddEncoder(ENC2, ENCODER_PULSED_SPLIT);
|
joystick.AddEncoder(ENC2, ENCODER_PULSED_SPLIT);
|
||||||
|
|
||||||
// // Power switches
|
// We will add the 2-stage "key buttons" in a slightly odd order
|
||||||
joystick.AddButton(BTN1, BUTTON_PULSED_DOUBLE_ACTION_SPLIT);
|
// in order to keep columns together for faster scanning.
|
||||||
joystick.AddButton(BTN2, BUTTON_PULSED_DOUBLE_ACTION_SPLIT);
|
Matrix* matrix = new Matrix({C0, C1, C2, C3}, 4);
|
||||||
joystick.AddButton(BTN3, BUTTON_PULSED_DOUBLE_ACTION_SPLIT);
|
|
||||||
joystick.AddButton(BTN4, BUTTON_PULSED_DOUBLE_ACTION_SPLIT);
|
|
||||||
|
|
||||||
// // HUD modes
|
// Flight modes
|
||||||
joystick.AddButton(BTN5, BUTTON_PASSTHRU);
|
joystick.AddMatrixButton(BTN1, matrix, BUTTON_PASSTHRU);
|
||||||
joystick.AddButton(BTN6, BUTTON_PASSTHRU);
|
joystick.AddMatrixButton(BTN2, matrix, BUTTON_PASSTHRU);
|
||||||
joystick.AddButton(BTN7, BUTTON_PASSTHRU);
|
joystick.AddMatrixButton(BTN3, matrix, BUTTON_PASSTHRU);
|
||||||
|
joystick.AddMatrixButton(BTN4, matrix, BUTTON_PASSTHRU);
|
||||||
|
|
||||||
// // Mining Modules
|
// Lights and Doors
|
||||||
joystick.AddButton(BTN8, BUTTON_PASSTHRU);
|
joystick.AddMatrixButton(BTN5, matrix, BUTTON_PULSED_DOUBLE_ACTION);
|
||||||
joystick.AddButton(BTN9, BUTTON_PASSTHRU);
|
joystick.AddMatrixButton(BTN6, matrix, BUTTON_PULSED_DOUBLE_ACTION_SPLIT);
|
||||||
joystick.AddButton(BTN10, BUTTON_PASSTHRU, true, mux);
|
joystick.AddMatrixButton(BTN7, matrix, BUTTON_PULSED_DOUBLE_ACTION_SPLIT);
|
||||||
|
|
||||||
// // Flight Modes
|
// Mining modules (plus first keybutton)
|
||||||
joystick.AddButton(BTN11, BUTTON_PASSTHRU, true, mux);
|
joystick.AddMatrixButton(BTN8, matrix, BUTTON_PASSTHRU);
|
||||||
joystick.AddButton(BTN12, BUTTON_PASSTHRU, true, mux);
|
joystick.AddMatrixButton(BTN9, matrix, BUTTON_PASSTHRU);
|
||||||
joystick.AddButton(BTN13, BUTTON_PASSTHRU, true, mux);
|
joystick.AddMatrixButton(KBTN1, matrix, BUTTON_PASSTHRU);
|
||||||
joystick.AddButton(BTN14, BUTTON_PASSTHRU, true, mux);
|
joystick.AddMatrixButton(BTN10, matrix, BUTTON_PASSTHRU);
|
||||||
|
|
||||||
// // Doors & Lights
|
// HUD modes
|
||||||
joystick.AddButton(BTN15, BUTTON_PULSED_DOUBLE_ACTION, true, mux);
|
joystick.AddMatrixButton(BTN11, matrix, BUTTON_PASSTHRU);
|
||||||
joystick.AddButton(BTN16, BUTTON_PULSED_DOUBLE_ACTION_SPLIT, true, mux);
|
joystick.AddMatrixButton(BTN12, matrix, BUTTON_PASSTHRU);
|
||||||
joystick.AddButton(BTN17, BUTTON_PULSED_DOUBLE_ACTION_SPLIT, true, mux);
|
joystick.AddMatrixButton(BTN13, matrix, BUTTON_PASSTHRU);
|
||||||
|
|
||||||
// // Emergency Panel
|
// Flight modes (and latter 2 keybuttons)
|
||||||
joystick.AddButton(KBTN1, BUTTON_PASSTHRU);
|
joystick.AddMatrixButton(KBTN2, matrix, BUTTON_PASSTHRU);
|
||||||
joystick.AddButton(KBTN2, BUTTON_PASSTHRU);
|
joystick.AddMatrixButton(BTN14, matrix, BUTTON_PULSED_DOUBLE_ACTION_SPLIT);
|
||||||
joystick.AddButton(KBTN3, BUTTON_PASSTHRU);
|
joystick.AddMatrixButton(BTN15, matrix, BUTTON_PULSED_DOUBLE_ACTION_SPLIT);
|
||||||
|
joystick.AddMatrixButton(BTN16, matrix, BUTTON_PULSED_DOUBLE_ACTION_SPLIT);
|
||||||
|
joystick.AddMatrixButton(BTN17, matrix, BUTTON_PULSED_DOUBLE_ACTION_SPLIT);
|
||||||
|
joystick.AddMatrixButton(KBTN3, matrix, BUTTON_PASSTHRU);
|
||||||
|
|
||||||
joystick.Init();
|
joystick.Init();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user