Skip to content

Commit

Permalink
Fixed Arduino sketches for v1.1 board
Browse files Browse the repository at this point in the history
Fixes issue #1
  • Loading branch information
rasmusb committed Apr 5, 2017
1 parent b0da162 commit c6667a5
Show file tree
Hide file tree
Showing 5 changed files with 119 additions and 72 deletions.
5 changes: 3 additions & 2 deletions Psion-Keyboard-Firmware/Psion-Keyboard-Firmware.ino
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*/

#include "board.h"
#include "Keyboard.h"
#include "PsionKeymapUSB.h"

#define SERIAL_ENABLED 0
Expand Down Expand Up @@ -119,7 +120,7 @@ void sendKeys ( int pressedArray [] [NCOLS], int previousArray [] [NCOLS] ) {
Serial.println(" pressed");
};

Keyboard.press_sc(keyScancode[row][col]);
Keyboard.press(keyScancode[row][col]);
}
else if ( pressedArray[row][col] < previousArray[row][col] ) {

Expand All @@ -128,7 +129,7 @@ void sendKeys ( int pressedArray [] [NCOLS], int previousArray [] [NCOLS] ) {
Serial.println(" released");
};

Keyboard.release_sc(keyScancode[row][col]);
Keyboard.release(keyScancode[row][col]);

}
}
Expand Down
61 changes: 60 additions & 1 deletion Psion-Keyboard-Firmware/PsionKeymapUSB.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,72 @@
/*
PsionKeymapUSB.h
Maps the keys to USB scancodes
Maps the keys to ASCII symbols as shown here:
https://www.arduino.cc/en/Reference/KeyboardModifiers
Note that the "Fn" and "Menu" keys are
mapped to AltGr and Alt respectively.
This is to make some kind of Plug 'n Play
possible.
*/

#define KEY_A 0x61
#define KEY_B 0x62
#define KEY_C 0x63
#define KEY_D 0x64
#define KEY_E 0x65
#define KEY_F 0x66
#define KEY_G 0x67
#define KEY_H 0x68
#define KEY_I 0x69
#define KEY_J 0x6A
#define KEY_K 0x6B
#define KEY_L 0x6C
#define KEY_M 0x6D
#define KEY_N 0x6E
#define KEY_O 0x6F
#define KEY_P 0x70
#define KEY_Q 0x71
#define KEY_R 0x72
#define KEY_S 0x73
#define KEY_T 0x74
#define KEY_U 0x75
#define KEY_V 0x76
#define KEY_W 0x77
#define KEY_X 0x78
#define KEY_Y 0x79
#define KEY_Z 0x7A

#define KEY_0 0x30
#define KEY_1 0x31
#define KEY_2 0x32
#define KEY_3 0x33
#define KEY_4 0x34
#define KEY_5 0x35
#define KEY_6 0x36
#define KEY_7 0x37
#define KEY_8 0x38
#define KEY_9 0x39

#define KEY_ENTER 0xB0
#define KEY_ESC 0xB1
#define KEY_BACKSPACE 0xB2
#define KEY_TAB 0xB3
#define KEY_SPACE 0x20
#define KEY_APOSTROPHE 0x27
#define KEY_COMMA 0x2C
#define KEY_PERIOD 0x2E
#define KEY_RIGHT 0xD7
#define KEY_LEFT 0xD8
#define KEY_DOWN 0xD9
#define KEY_UP 0xDA
#define KEY_CTRL 0x80 // Right CTRL
#define KEY_LSHIFT 0x81
#define KEY_MENU 0x87 // Mapped as RIGHT_GUI
#define KEY_RSHIFT 0x85
#define KEY_FN 0x82 // Mapped as Alt

/* Old scancode map. This does not work anymore.
#define KEY_A 0x04
#define KEY_B 0x05
#define KEY_C 0x06
Expand Down Expand Up @@ -64,6 +122,7 @@
#define KEY_MENU 0xE2 // Mapped as AltGr
#define KEY_RSHIFT 0xE5
#define KEY_FN 0xE6 // Mapped as Alt
*/

static int keyScancode [NROWS] [NCOLS] = {
{ 0 ,KEY_SPACE ,KEY_UP ,KEY_COMMA ,KEY_LEFT ,KEY_RIGHT ,KEY_LSHIFT ,0 ,0 ,0 ,0 ,0 },
Expand Down
66 changes: 20 additions & 46 deletions Psion-Keyboard-Firmware/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,27 @@
#define NROWS 8
#define NCOLS 12

#define ROW_01 7 // , 1
#define ROW_02 20 //A2 , 38
#define ROW_03 5 // , 31
#define ROW_04 13 // , 32
#define ROW_05 18 //A0 , 36
#define ROW_06 21 //A3 , 39
#define ROW_07 22 //A4 , 40
#define ROW_08 23 //A5 , 41
#define ROW_01 22
#define ROW_02 20
#define ROW_03 5
#define ROW_04 13
#define ROW_05 18
#define ROW_06 21
#define ROW_07 7
#define ROW_08 23

#define COL_1 19 //A1 , 37
#define COL_2 10 // , 30
#define COL_6 12 // , 26
#define COL_5 6 // , 27
#define COL_4 8 // , 28
#define COL_3 9 // , 29
#define COL_7 4 // , 25
#define COL_8 1 // , 21
#define COL_9 11 // , 12
#define COL_10 0 // , 20
#define COL_11 2 // , 19
#define COL_12 3 // , 18
#define COL_1 19
#define COL_2 10
#define COL_3 9
#define COL_4 8
#define COL_5 6
#define COL_6 12
#define COL_7 4
#define COL_8 30
#define COL_9 3
#define COL_10 1
#define COL_11 0
#define COL_12 2

int Rows [NROWS] = {
ROW_01,
Expand All @@ -56,29 +56,3 @@ int Cols [NCOLS] = {
COL_11,
COL_12
};


// Old mapping for the breadboard prototype
/*
#define ROW_01 0
#define ROW_02 4
#define ROW_03 8
#define ROW_04 7
#define ROW_05 6
#define ROW_06 3
#define ROW_07 2
#define ROW_08 1
#define COL_1 5
#define COL_2 9
#define COL_3 13
#define COL_4 12
#define COL_5 11
#define COL_6 10
#define COL_7 18
#define COL_8 19
#define COL_9 23
#define COL_10 20
#define COL_11 21
#define COL_12 22
*/
8 changes: 7 additions & 1 deletion ScanTheMatrix/ScanTheMatrix.ino
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ ScanTheMatrix
*/

#include "board.h"
#define LED_PIN 11


void setup() {
Expand All @@ -18,6 +19,7 @@ void setup() {
for (int i = 0; i < NPINS; i++) {
pinMode(Pin[i], INPUT);
}
pinMode(LED_PIN, OUTPUT);
}


Expand All @@ -26,7 +28,7 @@ void loop() {

if ( Serial.available() ) {
Serial.println("Pin mapping:");
for (int i = 0; i < 24; i++) {
for (int i = 0; i <= 30; i++) {
Serial.print(i);
Serial.print(": ");
Serial.println(pinName[i]);
Expand Down Expand Up @@ -67,6 +69,8 @@ void loop() {
Serial.print(pinName[Pin[j]]);
Serial.println(")");

digitalWrite(LED_PIN, HIGH);

while (digitalRead(Pin[i]) == LOW);

/*
Expand All @@ -78,6 +82,8 @@ void loop() {
digitalWrite(Pin[j], LOW);
pinMode(Pin[j], INPUT);

digitalWrite(LED_PIN, LOW);

}
}

Expand Down
51 changes: 29 additions & 22 deletions ScanTheMatrix/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,44 +20,51 @@ int Pin [NPINS] = {
8,
9,
10,
11,
12,
13,
18,
19,
20,
21,
22,
23
23,
30
};

// This is the name of the keyboard signal that each
// pin is connected to. Make sure to include unused
// pins in this list as well!
// This list must be sorted in numerical order.
// This list MUST be in numerical pin order.
char* pinName[] = {
"COL_10", // PIN0
"COL_8", // PIN1
"COL_11", // PIN2
"COL_12", // PIN3
"COL_7", // PIN4
"COL_11", // PIN0
"COL_10", // PIN1
"COL_12", // PIN2
"COL_09", // PIN3
"COL_07", // PIN4
"ROW_03", // PIN5
"COL_4", // PIN6
"ROW_01", // PIN7
"COL_5", // PIN8
"COL_6", // PIN9
"COL_2", // PIN10
"COL_9", // PIN11
"COL_3", // PIN12
"COL_05", // PIN6
"ROW_07", // PIN7
"COL_04", // PIN8
"COL_03", // PIN9
"COL_02", // PIN10
"-", // PIN11 (LED)
"COL_06", // PIN12
"ROW_04", // PIN13
"-", // PIN14 - unused
"-", // PIN15 - unused
"-", // PIN16 - unused
"-", // PIN17 - unused
"-", // PIN14 - MISO
"-", // PIN15 - SCK
"-", // PIN16 - MOSI
"-", // PIN17 - SS
"ROW_05", // PIN18
"COL_1", // PIN19
"COL_01", // PIN19
"ROW_02", // PIN20
"ROW_06", // PIN21
"ROW_08", // PIN22
"ROW_07" // PIN23
"ROW_01", // PIN22
"ROW_08", // PIN23
"-", // PIN24
"-", // PIN25
"-", // PIN26
"-", // PIN27
"-", // PIN28
"-", // PIN29
"COL_08" // PIN30
};

0 comments on commit c6667a5

Please sign in to comment.