Ok, what I've figured out so far is that the 'haywire' effect was caused by F5, F12, ctrl and shift being permanently held down. I've bypassed that by writing firmware where those keys are bound to 'safe' keys, numbers and letters. Yet, now when I plug in the board, nothing happens at all. Hmm.
Checking the teensy pins against my little excel table, all looks correct.
I found several errors in the matrix.c, particularly in this block:
static matrix_row_t read_cols(void)
{
return (PINB&(1<<0) ? 0 : (1<<0)) | //Col 0 = Pin
(PINB&(1<<1) ? 0 : (1<<1)) | //Col 1 = Pin and so on.
(PINB&(1<<2) ? 0 : (1<<2)) |
(PINB&(1<<3) ? 0 : (1<<3)) |
(PINB&(1<<7) ? 0 : (1<<4)) |
(PIND&(1<<1) ? 0 : (1<<5)) |
(PIND&(1<<2) ? 0 : (1<<6)) |
(PINC&(1<<7) ? 0 : (1<<7)) |
(PIND&(1<<5) ? 0 : (1<<
) |
(PIND&(1<<4) ? 0 : (1<<9)) |
(PIND&(1<<7) ? 0 : (1<<10)) |
(PINB&(1<<4) ? 0 : (1<<11)) |
(PINB&(1<<5) ? 0 : (1<<12)) |
(PINB&(1<<6) ? 0 : (1<<13));
}
Which is hardly surprising given how much I confused myself last night when I was editing that section. Here's a tip folks. Be consistent in you row and column naming. The firmware counts from 0, so should you!
I also had the rows in the wrong order in the 'select_row' section.
That would explain a lot really... and come to think of it, I think there was 6 stuck keys, so those were perhaps the first 6 keys to be polled before it hit the 6kro limit? *shrug*.
Recompile. Reload.
Still nothing. Wait... still nothing. No, I lie. Column 13 (14) works... except for in row 6 (7) where column 3 is the only key that works. Weird.
Thinking about that, row 6 is the only one where I had to get tricky with the diodes. I haven't mounted them all backwards have I??? I'm sure they're facing the same way as last time... v1 is at work so I can't physically check. I have photos.
Oh hellfire.
I couldn't really have got them any more wrong. No wonder they seemed to reach the distance more easily this time. Instead of connecting each to its own switch with one continuous wire of connection between them, I've connected them end to end.
This is going to take a HUGE amount of desoldering. Good bye neat work. Hello mess.
As tempting as it is to rush in and start making corrections, I should probably take some time to think this through carefully in case there's a way I can solve it without having to do too much work. I'd be upset, but the bad feeling is being mitigated by the pride of working out what the problem was.
...
Now imagine how frustrating this would be if I'd done a PCB, paid for its production, and had made the same mistake. I'm so glad that I gave up on that when I did.