Teensy coding, or lack thereof...

asura

08 Apr 2013, 20:46

So, I've got this old ALPS keyboard plate and PCB with cream tee mount switches. And I've traced from the 20 pins (one's ground and three are for an extra switch) over the PCB and with a bit of playing around with grids and tables I have my 8X8 matrix.

@ a A b B c C d D e E f F g G
h H i I j J k K l L m M n N o O
p P q Q r R s S t T u U v V w W
x X y Y z Z
0 1 ! 2 " 3 # 4 $ 5 % 6 & 7 '
8 ( 9 ) : * ; + ,< = _ . > / ?
ENTER CLEAR BREAK UP DOWN LEFT RIGHT SPACE
L SHIFT R SHIFT
Now to some of you, I'm sure, this would be the difficult and tedious bit over, for me it's the beginning of the end... I've looked though Soarer and Hasu's teensy codes and PJRC's site, but my brain quite simply says "Nope, not doin' it!" I might just be over-tired, but this isn't really the sort of thing I excel in at the best of times.

I know I'm not writing something from scratch, but even at that, simply knowing which file to start modifying would be a start. I really am that clueless at the moment, drowned by too much input perhaps, but stumped regardless.

HELP!

User avatar
BimboBB

09 Apr 2013, 10:23

Yes, some n00b-guide how to code a teensy for a new matrix would be nice.

yeeeargh

09 Apr 2013, 16:38

you might take a look at the tmk firmware. there are quite a few projects already done with a teensy with a bit of documentation.
link to the tmk-site: https://github.com/tmk/tmk_keyboard
link to a one of the projekts done with a teensy: https://github.com/tmk/tmk_keyboard/tre ... board/hhkb
link to a diagram how he wired the controller: https://github.com/tmk/tmk_keyboard/blo ... c/HHKB.txt
link to the keymap: https://github.com/tmk/tmk_keyboard/blo ... b/keymap.c

there are plenty of other projects which were done with this firmware, just browse through their github-site. maybe there are even better documented ones.

edit: Sorry, didn't see that you already took a look at it. Most of the work might be editing the keymap.c to reflect your matrix. That's all I can say for now, because I haven't made a new project with it myself and just took a brief look at it.

asura

24 Apr 2013, 02:13

Ok, so I've played about with matrix.c and keymap.c quite a bit and along the way I've; destroyed it, and started from scratch, I've altered one part to suit my keyboard and it's broken a section, I'd amended the now faulty code and etcetera, I've made err, putting K_45 down twice and K_54 not at all... each step I've figured out a bit more about how the whole things put together, but I'm now stumped...

For the opening and closing of the brackets around any of the altered keymaps e.g.
KEYMAP_ANSI(
1, 2, 3, 4, 5, 6, 7, 8, 9, 0, NUBS, EQL, ESC, \
UP, Q, W, E, R, T, Y, U, I, O, P, FN0, LEFT, RIGHT, \
DOWN, A, S, D, F, G, H, J, K, L, SLSN, ENT, BSPC, \
LSFT, Z, X, C, V, B, N, M, COMM, DOT, SLSH, RSFT, \
SPC),
};
I get a massive amount of warnings (see spoiler) and if I cut all the keymaps but one, I get a much shorter...
keymap.c:97: error: expected '}' before 'KC_5'
keymap.c:92: error: expected '}' before '{' token
make: *** [obj_gh60_lufa/keymap.o] Error 1
Spoiler:
keymap.c:113: warning: braces around scalar initializer
keymap.c:113: warning: (near initialization for 'keymaps[0][4][7]')
keymap.c:113: warning: braces around scalar initializer
keymap.c:113: warning: (near initialization for 'keymaps[0][4][7]')
keymap.c:113: warning: excess elements in scalar initializer
keymap.c:113: warning: (near initialization for 'keymaps[0][4][7]')
keymap.c:113: warning: excess elements in scalar initializer
keymap.c:113: warning: (near initialization for 'keymaps[0][4][7]')
keymap.c:113: warning: excess elements in scalar initializer
keymap.c:113: warning: (near initialization for 'keymaps[0][4][7]')
keymap.c:113: warning: excess elements in scalar initializer
keymap.c:113: warning: (near initialization for 'keymaps[0][4][7]')
keymap.c:113: warning: excess elements in scalar initializer
keymap.c:113: warning: (near initialization for 'keymaps[0][4][7]')
keymap.c:113: warning: excess elements in scalar initializer
keymap.c:113: warning: (near initialization for 'keymaps[0][4][7]')
keymap.c:113: warning: excess elements in scalar initializer
keymap.c:113: warning: (near initialization for 'keymaps[0][4][7]')
keymap.c:113: warning: braces around scalar initializer
keymap.c:113: warning: (near initialization for 'keymaps[0][4][7]')
keymap.c:113: warning: excess elements in scalar initializer
keymap.c:113: warning: (near initialization for 'keymaps[0][4][7]')
keymap.c:113: warning: excess elements in scalar initializer
keymap.c:113: warning: (near initialization for 'keymaps[0][4][7]')
keymap.c:113: warning: excess elements in scalar initializer
keymap.c:113: warning: (near initialization for 'keymaps[0][4][7]')
keymap.c:113: warning: excess elements in scalar initializer
keymap.c:113: warning: (near initialization for 'keymaps[0][4][7]')
keymap.c:113: warning: excess elements in scalar initializer
keymap.c:113: warning: (near initialization for 'keymaps[0][4][7]')
keymap.c:113: warning: excess elements in scalar initializer
keymap.c:113: warning: (near initialization for 'keymaps[0][4][7]')
keymap.c:113: warning: excess elements in scalar initializer
keymap.c:113: warning: (near initialization for 'keymaps[0][4][7]')
keymap.c:113: warning: excess elements in scalar initializer
keymap.c:113: warning: (near initialization for 'keymaps[0][4][7]')
keymap.c:113: warning: braces around scalar initializer
keymap.c:113: warning: (near initialization for 'keymaps[0][4][7]')
keymap.c:113: warning: excess elements in scalar initializer
keymap.c:113: warning: (near initialization for 'keymaps[0][4][7]')
keymap.c:113: warning: excess elements in scalar initializer
keymap.c:113: warning: (near initialization for 'keymaps[0][4][7]')
keymap.c:113: warning: excess elements in scalar initializer
keymap.c:113: warning: (near initialization for 'keymaps[0][4][7]')
keymap.c:113: warning: excess elements in scalar initializer
keymap.c:113: warning: (near initialization for 'keymaps[0][4][7]')
keymap.c:113: warning: excess elements in scalar initializer
keymap.c:113: warning: (near initialization for 'keymaps[0][4][7]')
keymap.c:113: warning: excess elements in scalar initializer
keymap.c:113: warning: (near initialization for 'keymaps[0][4][7]')
keymap.c:113: warning: excess elements in scalar initializer
keymap.c:113: warning: (near initialization for 'keymaps[0][4][7]')
keymap.c:113: warning: excess elements in scalar initializer
keymap.c:113: warning: (near initialization for 'keymaps[0][4][7]')
keymap.c:113: warning: braces around scalar initializer
keymap.c:113: warning: (near initialization for 'keymaps[0][4][7]')
keymap.c:113: warning: excess elements in scalar initializer
keymap.c:113: warning: (near initialization for 'keymaps[0][4][7]')
keymap.c:113: warning: excess elements in scalar initializer
keymap.c:113: warning: (near initialization for 'keymaps[0][4][7]')
keymap.c:113: warning: excess elements in scalar initializer
keymap.c:113: warning: (near initialization for 'keymaps[0][4][7]')
keymap.c:113: warning: excess elements in scalar initializer
keymap.c:113: warning: (near initialization for 'keymaps[0][4][7]')
keymap.c:113: warning: excess elements in scalar initializer
keymap.c:113: warning: (near initialization for 'keymaps[0][4][7]')
keymap.c:113: warning: excess elements in scalar initializer
keymap.c:113: warning: (near initialization for 'keymaps[0][4][7]')
keymap.c:113: warning: excess elements in scalar initializer
keymap.c:113: warning: (near initialization for 'keymaps[0][4][7]')
keymap.c:113: warning: excess elements in scalar initializer
keymap.c:113: warning: (near initialization for 'keymaps[0][4][7]')
keymap.c:113: warning: braces around scalar initializer
keymap.c:113: warning: (near initialization for 'keymaps[0][4][7]')
keymap.c:113: warning: excess elements in scalar initializer
keymap.c:113: warning: (near initialization for 'keymaps[0][4][7]')
keymap.c:113: warning: excess elements in scalar initializer
keymap.c:113: warning: (near initialization for 'keymaps[0][4][7]')
keymap.c:113: warning: excess elements in scalar initializer
keymap.c:113: warning: (near initialization for 'keymaps[0][4][7]')
keymap.c:113: warning: excess elements in scalar initializer
keymap.c:113: warning: (near initialization for 'keymaps[0][4][7]')
keymap.c:118: error: expected '}' before 'KC_5'
keymap.c:118: warning: excess elements in scalar initializer
keymap.c:118: warning: (near initialization for 'keymaps[0][4][7]')
keymap.c:113: error: expected '}' before '{' token
keymap.c:113: warning: excess elements in scalar initializer
keymap.c:113: warning: (near initialization for 'keymaps[0][4][7]')
keymap.c:121: error: invalid initializer
make: *** [obj_gh60_lufa/keymap.o] Error 1
Now I've tried putting a } before KC_5, but that only makes things worse, resulting in...
keymap.c:97:1: error: pasting "KC_" and "}" does not give a valid preprocessing
token
keymap.c:97: error: expected '}' before 'KC_'
keymap.c:92: error: expected '}' before numeric constant
keymap.c:92: error: expected '}' before '{' token
keymap.c:98: error: expected identifier or '(' before '}' token
make: *** [obj_gh60_lufa/keymap.o] Error 1
So there's probably something wrong with how I've noted something down somewhere, but for the life of me I can't see it - I've been swapping back and forth between my modified mess and the original GH60 code till my eyes are crossed... and I think I'm going to bin it and start again, again... again(?) so...

Help!

User avatar
Muirium
µ

24 Apr 2013, 14:48

I am not a lawyer. Or even much of a coder, but here goes…

From what I see in keymap.c the:
KEYMAP(whole, bunch, of, keys, go, here),
statements are all arrays within an array. (Do not sue me if "array" is not the right word here. Please!) The code is formatted for ease of reading, but what's actually going into the compiler is one huge long line of code which consists of several keyboard matrices (coded as one dimensional arrays) all shoved in a row. There's one for the main map and then a bunch of fancy pants alternate layers like HHKB mode, which don't matter unless you want them.

But! I think the only one that needs touched is this one:
#define KEYMAP( \
K31, K30, K00, K10, K11, K20, K21, K40, K41, K60, K61, K70, K71, K50, K51, \
K32, K01, K02, K13, K12, K23, K22, K42, K43, K62, K63, K73, K72, K52, \
K33, K04, K03, K14, K15, K24, K25, K45, K44, K65, K64, K74, K53, \
K34, K05, K06, K07, K16, K17, K26, K46, K66, K76, K75, K55, K54, \
K35, K36, K37, K57, K56 \
) \
It's the definition that kicks the rest off. Those numbers will be the actual row and column information. The rest are all about what to assign to them (for layers) once the physical matrix is defined.

So, while you are at it: do not use {curly brackets}, do not use semicolons; and do not try to alter anything outside of the (brackets). I think the idea is to type in your matrix rows and columns into that bit up top, and hope for the best. It should compile at least! A bit of documentation seems to be needed up there.

Oh, and I am still not a lawyer, or that much of a coder!

User avatar
hasu

25 Apr 2013, 05:36

The more info you give, the more help you get.
Pics!! the more the better. At least I prefer pic to read English. :)

These infos will be very useful to help you.
- keyboard switch matrix(you already have, nice)
- physical key layout(picture will help)
- PCB has diodes?(pics will help again)
- how you connect controller to matrix
- your source code(matrix.c and keymap.c at least)

User avatar
bearcat

27 Apr 2013, 08:15

hasu's probably going to answer your question better than I could, but, in brief, you should consider posting your code to github, or at the very least, one of the pastebin sites. Diagnosing C code from a prose-description will be really hard :?

Post Reply

Return to “Workshop”