Welcome Guest ( Log In | Register )

Outline · [ Standard ] · Linear+

 The Scrap Keyboard, Ground up hardwired keyboard

views
     
ectt
post Aug 27 2014, 03:48 AM

Regular
******
Senior Member
1,049 posts

Joined: Apr 2012


QUOTE(faridr @ May 24 2014, 08:07 AM)
Part 6: Defining key matrix

1st step
And now, a little bit confusing part, in defining the function of key mapping. I havent finalized this part especially for the fn second layer function, as I'm waiting for my keycap. But the normal keyboard qwerty asdfg zxcvb is already coded and working fine.

I've open keymap_common.h file in the same gh60 directory and look for #define KEYMAP function. Here is the original code

CODE
#define KEYMAP( \
   K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D, \
   K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, \
   K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, K2D, \
   K30, K31, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3C, K3D, \
   K40, K41, K42,           K45,                K49, K4A, K4B, K4C, K4D  \
) { \
   { KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07, KC_##K08, KC_##K09, KC_##K0A, KC_##K0B, KC_##K0C, KC_##K0D }, \
   { KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17, KC_##K18, KC_##K19, KC_##K1A, KC_##K1B, KC_##K1C, KC_##K1D }, \
   { KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_##K27, KC_##K28, KC_##K29, KC_##K2A, KC_##K2B, KC_##K2C, KC_##K2D }, \
   { KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_##K35, KC_##K36, KC_##K37, KC_##K38, KC_##K39, KC_##K3A, KC_##K3B, KC_##K3C, KC_##K3D }, \
   { KC_##K40, KC_##K41, KC_##K42, KC_NO,    KC_NO,    KC_##K45, KC_NO,    KC_NO,    KC_NO,    KC_##K49, KC_##K4A, KC_##K4B, KC_##K4C, KC_##K4D }  \
}


My first reaction was watef*** is this. After further reading, this part is actually simple, though requires lots of attention.
What you see here is the layout design of each keyboard key, and the view is from the top, where all the letters and numbering will be.
Lets take K00 and K12 for example. In K00, the first 0 is for the row, and the second 0 is for the column. So for K12, its mean row 1 columns 2.
Notice that there's no K43, this is due to empty slot in gh60 pcb. K42 is basiccaly alt key, and k45 is spacebar key.

As the program use hex/binary or whatever computer instruction is, the numbering start from 0 till 9, then A, B, C... . Basically A = 10, B = 11, C = 12 and so on. And remember to add comma( , ) and blackslash ( \ ) at the end, and only backslash ( \ ) at the last keyboard layout, as shown in the default code.

Now the second part of the code, its still the same thing, same logic, except that unused slot has to be declare by putting KC_NO.

For my scrappy banger keyboard, since I use a different wiring from gh60 pcb, I've made changes. Forget all the previous numbering method to avoid confusion. I took a look at bottom layout of the keyboard and wiring.
user posted image

And the view of top part, remember that when you flip from bottom to top view and vice versa, you have make sure of the numbering. Notice the location of K00 and K0D between bottom and top view.
user posted image

And here is my final code for my scrap banger
» Click to show Spoiler - click again to hide... «


******************************** ONLY DO THIS PART IF THERE IS COMPILING ERROR DURING MAKEFILE (in last part)********************

According to matt30, #define KEYMAP_ANSI function can be ignored and no change is needed. But during my compilation of the code, there was lots of error preventing compilation, and log shows that the error comes from function in #define KEYMAP_ANSI , as there is conflict in layout. So I beg to differ, change needed  tongue.gif

So I copy the code from #define KEYMAP function, and paste the whole thing at #define KEYMAP_ANSI . Just copy the content, dont change the function name. This was the changes I've made.

» Click to show Spoiler - click again to hide... «


*****************************************************************************************************************************

2nd step
Now time to define what each key does smile.gif And there is no limitation, what each key does is up to you. As I use Poker 2 layout, I'll be using keymap_poker.c file. Other like keymap_hhkb.c , keymap_hasu.c and so on can also be use, depending on which code suit the keyboard design best.

I would suggest a read on matt3o guide in defining the layout part too as this part are usually comes down to own preferences.

I've made my keymap here, although its a little bit harder to explain, but I'll try my best.
3rd and final step  laugh.gif

Now its time to compile the code and flash it to teensy. I use Windows 8.1 in compiling and WinAvr need to be installed (refer to part 5 for link and fix). After installation, fire up command line console, and then navigate to gh60 folder, and I've compiled the code by typing make -f Makefile

user posted image

No compilation error, yaaaaay!. I navigate back to gh60 folder, and there it is,  gh60_lufa.hex  drool.gif  drool.gif  drool.gif

To finish it up, I connect the teensy to PC using mini usb to usb cable (the same adapter on you external hdd), load up teensy loader.
user posted image

Now to complete the process, I just press the tiny winnie button on teensy, click the auto button, and open the gh60_lufa.hex file in teensy loader. The loader then automatically flash the teensy and reboot teensy.

And for the moment of truth, I fire up notepad, and press the buttons on my scrap banger, and seeing the output on the screen..... ITS DONE! YAAAAAAAAAAY


To sum it up, this project might look complicated at first, but its actually quite do-able even for anyone without programming language background and can be completed within 1 day (took me 2 days because of my stupidity  not checking the firmware code before desoldering back the whole thing).

And you can actually make specific keyboard for specific function, for example like any game with its own specific design keyboard. Hoping that someone else with higher creativity level would come out with their own keyboard design, as this is just a base experiment and guidelines.
*
well done thumbup.gif
interesting
perhaps can supply you many mechanical switch later thumbup.gif


 

Change to:
| Lo-Fi Version
0.0218sec    0.63    6 queries    GZIP Disabled
Time is now: 16th December 2025 - 09:39 PM