Hi,
I've been following this guide (http://www.instructables.com/id/Make-Any-Vintage-Keyboard-Work-With-a-Modern-PC/) to convert an old laptop keyboard to USB using a Teensy LC.
I've managed to trace and record the keyboard matrix into a spreadsheet (here: https://pastebin.com/NL66Zg2v) but the configuration of the matrix that I have is a bit different from the one on the above guide.
The matrix is 12x12 but isn't symmetrical/sequential: pins 1,2,3,4,5,6,7,8,9,14,15,18 appear to be the rows, and pins 10,11,12,13,16,17,19,20,21,22,23,24 are the columns as opposed to the 8x16 matrix in the above guide which just uses pins 1-8 and 9-16 in sequential order.
I'm confused about how to visualise this and implement it in the code example from the above link. Also I am generally confused about how to "pad" the matrix in the code.
The code from the guide has:
[full source: https://pastebin.com/MkQiKWYy]
I can see that there is some padding to make each row contain 16 items but I don't follow the logic used to get there.
Here's my modified code:
[full source: https://pastebin.com/JpQjMTeR]
The zeroes are my attempt at making sense of how to pad it out to make 12 items on each row, and it doesn't work. Also, note the changed rowPins and colPins to reflect my pinout. Not sure if this is correct.
I had to change the keys variable from "char" to "const char *" to get this to compile, I think it's still doing the same job though?
Any help or insight into this would be greatly appreciated.
I've been following this guide (http://www.instructables.com/id/Make-Any-Vintage-Keyboard-Work-With-a-Modern-PC/) to convert an old laptop keyboard to USB using a Teensy LC.
I've managed to trace and record the keyboard matrix into a spreadsheet (here: https://pastebin.com/NL66Zg2v) but the configuration of the matrix that I have is a bit different from the one on the above guide.
The matrix is 12x12 but isn't symmetrical/sequential: pins 1,2,3,4,5,6,7,8,9,14,15,18 appear to be the rows, and pins 10,11,12,13,16,17,19,20,21,22,23,24 are the columns as opposed to the 8x16 matrix in the above guide which just uses pins 1-8 and 9-16 in sequential order.
I'm confused about how to visualise this and implement it in the code example from the above link. Also I am generally confused about how to "pad" the matrix in the code.
The code from the guide has:
Code:
#include <Keypad.h>
const byte ROWS = 8; //eight rows
const byte COLS = 16; //sixteen columns
char keys[ROWS][COLS] = {
{'1','2',KEY_ESC,'1',KEY_F4,KEY_G,KEY_PAGE_DOWN,KEY_H,KEY_F7,KEY_F10,KEY_QUOTE,KEY_PAGE_UP,'1',KEY_DOWN,'3','a'},
{'1',KEY_LEFT_SHIFT,KEY_TAB,KEY_F1,KEY_F3,KEY_T,KEY_RIGHT_BRACE,KEY_Y,KEY_F6,KEY_F9,KEY_LEFT_BRACE,KEY_UP,'1','2','3','a'},
{'1','2','3','1',KEY_F2,KEY_5,KEY_EQUAL,KEY_6,KEY_F5,KEY_F8,KEY_MINUS,'3','1',KEY_PRINTSCREEN,'3','a'},
{'1','2',KEY_1,KEY_2,KEY_3,KEY_4,KEY_LEFT,KEY_7,KEY_8,KEY_9,KEY_0,KEY_SCROLL_LOCK,'1','2','3','a'},
{'1','2',KEY_Q,KEY_W,KEY_E,KEY_R,KEY_EQUAL,KEY_U,KEY_I,KEY_O,KEY_P,'3',KEY_END,KEY_HOME,'3','a'},
{'1','2',KEY_A,KEY_S,KEY_D,KEY_F,'1',KEY_J,KEY_K,KEY_L,KEY_SEMICOLON,KEY_BACKSLASH,KEY_RIGHT,'2','3','a'},
{'1',KEY_RIGHT_SHIFT,KEY_Z,KEY_X,KEY_C,KEY_V,KEY_ENTER,KEY_M,KEY_COMMA,KEY_PERIOD,KEY_SLASH,'3','1','2','3','a'},
{'1','2',KEY_CAPS_LOCK,'1','2',KEY_B,KEY_SPACE,KEY_N,KEY_TILDE,KEY_INSERT,KEY_DELETE,KEY_BACKSPACE,'1','2',KEY_A,'z'}
};
byte rowPins[ROWS] = {1,2,3,4,5,6,7,8}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24}; //connect to the column pinouts of the keypad
I can see that there is some padding to make each row contain 16 items but I don't follow the logic used to get there.
Here's my modified code:
Code:
#include <Keypad.h>
const byte ROWS = 12; // 12 rows
const byte COLS = 12; // 12 columns
const char * keys [ROWS] [COLS] = {
{0,"KEY_ENTER",0,"KEYPAD_BACKSLASH","KEY_RIGHT_BRACE","KEY_QUOTE","KEYPAD_SLASH",0,0,"KEY_DOWN",0,0},
{"KEY_RIGHT","KEY_LEFT",0,"KEY_BACKSPACE","KEY_PRINTSCREEN","KEY_LEFT_BRACE","KEY_SEMICOLON","KEY_PERIOD",0,0,"MODIFIERKEY_RIGHT_CTRL","KEY_C"},
{"KEY_UP",0,0,0,"KEY_P","KEY_PLUS",0,"KEY_L","KEY_COMMA","KEY_X",0,"KEY_Z"},
{"KEY_INSERT","KEY_MINUS","KEY_O","KEY_K","KEY_M","KEY_N","KEY_B","KEY_V","KEY_S",0,0,0},
{"KEY_I","KEY_PAUSE","KEY_0","KEY_H","KEY_G","KEY_F","KEY_D","KEY_S","KEY_A","MODIFIERKEY_CTRL",0,0},
{"KEY_NUM_LOCK","KEY_9","KEY_U","KEY_Y","KEY_T","KEY_R","KEY_E","KEY_W","KEY_Q","KEY_TAB",0,0},
{"KEY_F10",0,"KEY_7","KEY_8","KEY_6","KEY_5","KEY_4","KEY_3","KEY_2","KEY_1","KEY_TILDE",0},
{"KEY_F8","KEY_F7","KEY_F6","KEY_F5","KEY_F4","KEY_F3","KEY_F2","KEY_F1","KEY_ESC",0,0,0},
{"KEY_DEL",0,0,0,0,0,"KEY_F9",0,0,0,0,0},
{"MODIFIERKEY_RIGHT_SHIFT",0,0,0,0,0,0,0,0,0,0,0},
{"MODIFIERKEY_LEFT_ALT",0,0,0,0,0,0,0,0,0,0,0},
{"KEY_CAPS_LOCK",0,"MODIFIERKEY_LEFT_SHIFT","MODIFIERKEY_RIGHT_ALT",0,"KEY_SPACE",0,0,0,0,0,0},
};
byte rowPins[ROWS] = {1,2,3,4,5,6,7,8,9,14,15,18}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {10,11,12,13,16,17,19,20,21,22,23,24}; //connect to the column pinouts of the keypad
The zeroes are my attempt at making sense of how to pad it out to make 12 items on each row, and it doesn't work. Also, note the changed rowPins and colPins to reflect my pinout. Not sure if this is correct.
I had to change the keys variable from "char" to "const char *" to get this to compile, I think it's still doing the same job though?
Any help or insight into this would be greatly appreciated.
Last edited: