How to build your very own keyboard firmware

RtG

09 Oct 2015, 14:32

Now I feel stupid - why didn't I think of that myself.
Thank you

User avatar
HzFaq

09 Oct 2015, 14:48

No probs, I only recently found out how much useful stuff is in there myself ;).

Got any pics of what you're working on?

RtG

09 Oct 2015, 18:44

Sorry no pics at the moment, all parts are scattered all over the place.
But I am building on a PC-MOD. Its a PC but it looks like a Laptop.
The last two pieces are about to get in place. Display and Keyboard.

neverused

10 Oct 2015, 02:20

RtG wrote:Sorry no pics at the moment, all parts are scattered all over the place.
But I am building on a PC-MOD. Its a PC but it looks like a Laptop.
The last two pieces are about to get in place. Display and Keyboard.
Please update with pics!

RtG

10 Oct 2015, 08:34

I promise there will be pics.
My plan is to open a new tread with pics and explaining s.
Since a work accident I'm not the fastest worker any more. :(

wes1099

14 Oct 2015, 04:07

If I wanted to hand wire a numpad, could I just use the lightpad TMK firmware and use all of the same pins on a teensy? The Lightpad also uses ATmega32u4 right?

User avatar
flabbergast

14 Oct 2015, 10:09

wes1099 wrote: If I wanted to hand wire a numpad, could I just use the lightpad TMK firmware and use all of the same pins on a teensy? The Lightpad also uses ATmega32u4 right?
Yes. (It's specified in Makefile.lufa in the lightpad directory.) (You can read off the pins used in matrix.c.)

coltstrgj

27 Oct 2015, 05:16

Hey guys, Thanks for the help with this, all of you. I just wanted to show what I have so far, and hopefully I could inspire someone else to try. I have little to no experience with CAD software, and the code was very easy for me to change and modify to what I wanted.

The aperture on my phone is broken, so I apologize for the darkness of these images.
You can see the wires from the diodes are uncovered, but they do not contact the column wires (which are insulated by some sort of copper colored paint, so if they did contact, it would not matter any way. I took this insulation off the areas that I soldered to the switches). I am building a case for this as well, but for now (during testing) I am using motherboard standoffs. I also have a tip for anyone who is having trouble wiring the rows and columns to the teensy, you don't have to do it like I did, and send the wires to the end of each row/column you can hook them anywhere in that row/column. I just did it this way, and a lot of other people do too, because it was easier to trace the wires and figure out where they belong.
My Matrix (sorry about orientation)
Image

Closer picture of matrix. You can also see my plate. It is aluminum that has been bead blasted in my college shop. I made the plate with a 1/16th inch end mill with help from some people from the Mech department at my school.
Image

Here is image of my layout (or what it will be... also I just noticed the second "END" key... Will have to come up with something else to put there)The red outlined keys will be one color, and the green will be another. I am thinking Grey for the green section and a red for the red section. I have another design getting worked on right now, I will check back soon.
Image

I will post more pictures, and update this post as time goes on, but this is what I have for now. Thanks for checking it out.
----------------NINJA EDIT----------------------------
This was originally a help request... I made very silly mistakes in code. I had b's where d's should have been.

3veryman

29 Oct 2015, 22:54

Can someone please make the hex-file for me? :( i dont get it!

Thanks!
Attachments
gh60.rar
(16.18 KiB) Downloaded 171 times

User avatar
flabbergast

30 Oct 2015, 08:37

Well, you had a couple of typos in your sources. I'm attaching the fixed sources, and the dir also contains the compiled hex file. Not sure that it'll do what you expect it to do - I didn't actually check the C code, apart from fixing the typos that generated compilation error. Feel free to ask if there's more problems.
Attachments
gh60.7z
(25.06 KiB) Downloaded 154 times

Tiny

03 Nov 2015, 04:29

Can someone take a look at my files? For some reason I can"t seem to be able to type anything after flashing the micro.
Attachments
gh60.zip
(654.51 KiB) Downloaded 153 times

nexaddo@gmail.com

08 Nov 2015, 00:35

Hey guys,
I'm trying to make a small keyboard but I'm stuck at making the firmware. For some reason I get this error when I run make -f makefile
Error Makefile.JPG
Error Makefile.JPG (256.52 KiB) Viewed 6975 times
I've duble-triple checked all the code in the H60 folder but I don't seem to see any problem with it (considering that I mostly copy/paste-ed everyting....the tutorial was almost exactly with what I had in mind 15 columns and 5 rows.
gh60.zip
(17.8 KiB) Downloaded 155 times
I've attached the files if someone is nice enough to look at them and/or just compile them. Also I have Windows 10 installed so I'm not sure if that's the problem considering that make.exe had it's last update some 5 years ago.

User avatar
gogusrl

08 Nov 2015, 00:54

Hehe, a fellow romanian. I got stuck there as well earlier today and decided to try my luck with Soarer's (and failed there as well).

User avatar
joc

08 Nov 2015, 01:37

nexaddo@gmail.com wrote: Hey guys,
I'm trying to make a small keyboard but I'm stuck at making the firmware. For some reason I get this error when I run make -f makefile

I've duble-triple checked all the code in the H60 folder but I don't seem to see any problem with it (considering that I mostly copy/paste-ed everyting....the tutorial was almost exactly with what I had in mind 15 columns and 5

I've attached the files if someone is nice enough to look at them and/or just compile them. Also I have Windows 10 installed so I'm not sure if that's the problem considering that make.exe had it's last update some 5 years ago.

Code: Select all

keymap_common.h:44:68: error: parameter name missing
This line says the error is on line 44, column 68 in keymap_common.h. You either have a missing parameter or extra comma. Assuming it's an extra comma, removing the comma and recompiling gives this error:

Code: Select all

keymap_common.h:45:75: error: macro parameters must be comma-separated
Going to line 45, column 75 in keymap_common.h you'll notice that there's a missing comma between the K4D and K4E parameters. Adding the comma and recompiling gives this error:

Code: Select all

keymap_poker.c:25:1: error: expected '}' before 'RNS'
Going to line 25 in keymap_poker.c you'll notice that there's a space between the 'T' and 'RNS'. Removing the space allows the code to compile successfully.

nexaddo@gmail.com

08 Nov 2015, 03:05

well....I feel stupid...there I was trying to make a boot-able linux stick (which I plan on doing anyway just to have it)....Thank you joc, it actually worked.
@gogusrl...nice to see other keyboard-obsessed Romanians

Tomer

09 Nov 2015, 19:34

Hey, I keep getting these errors on the cmd when I compile, even when I try to compile the gh60 right from the source.

Code: Select all

Microsoft Windows [Version 10.0.10240]
(c) 2015 Microsoft Corporation. All rights reserved.

C:\Users\kagan>cd C:\Users\kagan\Desktop\tmk_keyboard-master\keyboard\gh60

C:\Users\kagan\Desktop\tmk_keyboard-master\keyboard\gh60>make -f Makefile.pjrc
      0 [main] sh 1604 sync_with_child: child 7596(0x170) died before initialization with status code 0xC0000142
    618 [main] sh 1604 sync_with_child: *** child state waiting for longjmp
/usr/bin/sh: fork: Resource temporarily unavailable
      0 [main] sh 2904 sync_with_child: child 5440(0x1B0) died before initialization with status code 0xC0000142
    347 [main] sh 2904 sync_with_child: *** child state waiting for longjmp
/usr/bin/sh: fork: Resource temporarily unavailable
      0 [main] sh 7480 sync_with_child: child 5996(0x1C) died before initialization with status code 0xC0000142
    238 [main] sh 7480 sync_with_child: *** child state waiting for longjmp
/usr/bin/sh: fork: Resource temporarily unavailable
      0 [main] sh 1816 sync_with_child: child 5876(0x1B8) died before initialization with status code 0xC0000142
    234 [main] sh 1816 sync_with_child: *** child state waiting for longjmp
/usr/bin/sh: fork: Resource temporarily unavailable

-------- begin --------
avr-gcc (WinAVR 20100110) 4.3.3
Copyright (C) 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

      0 [main] sh 5400 sync_with_child: child 2940(0x104) died before initialization with status code 0xC0000142
    222 [main] sh 5400 sync_with_child: *** child state waiting for longjmp
/usr/bin/sh: fork: Resource temporarily unavailable

mkdir -p obj_gh60_pjrc
Compiling C: keymap_poker.c
avr-gcc -c -mmcu=atmega32u4 -gdwarf-2 -DF_CPU=16000000UL -DBOOTLOADER_SIZE=4096 -DPROTOCOL_PJRC -DBOOTMAGIC_ENABLE -DMOUSEKEY_ENABLE -DMOUSE_ENABLE -DEXTRAKEY_ENABLE -DCONSOLE_ENABLE -DCOMMAND_ENABLE -DNKRO_ENABLE -DSLEEP_LED_ENABLE -DNO_SUSPEND_POWER_DOWN -DVERSION= -Os -funsigned-char -funsigned-bitfields -ffunction-sections -fdata-sections -fno-inline-small-functions -fpack-struct -fshort-enums -fno-strict-aliasing -Wall -Wstrict-prototypes -Wa,-adhlns=obj_gh60_pjrc/keymap_poker.lst -I. -I../../tmk_core -I../../tmk_core/protocol/pjrc -I../../tmk_core/common -std=gnu99 -include config.h -MMD -MP -MF .dep/obj_gh60_pjrc_keymap_poker.o.d  keymap_poker.c -o obj_gh60_pjrc/keymap_poker.o
keymap_poker.c:13: fatal error: opening dependency file .dep/obj_gh60_pjrc_keymap_poker.o.d: No such file or directory
compilation terminated.
make: *** [obj_gh60_pjrc/keymap_poker.o] Error 1

C:\Users\kagan\Desktop\tmk_keyboard-master\keyboard\gh60>
I tried this on multiple computers, tried uninstalling and reinstalling WinAVR, tried different sources...
Nothing! I have Windows 10 x64 bits if that matters.
Does anyone know what I should do?

User avatar
Halvar

09 Nov 2015, 20:19

Hi Tomer, welcome to DT!

Yes, that's a known problem. Solution is here:

http://www.avrfreaks.net/forum/windows- ... tion-error

Tomer

09 Nov 2015, 20:35

Halvar wrote: Hi Tomer, welcome to DT!

Yes, that's a known problem. Solution is here:

http://www.avrfreaks.net/forum/windows- ... tion-error
Hi Halvar, thank you for your welcome!
I tried the fix, and this is what I got:

Code: Select all

Microsoft Windows [Version 10.0.10240]
(c) 2015 Microsoft Corporation. All rights reserved.

C:\Users\kagan>cd C:\Users\kagan\Documents\Keyboard Software\tmk_keyboard-master\keyboard\gh60

C:\Users\kagan\Documents\Keyboard Software\tmk_keyboard-master\keyboard\gh60>make -f Makefile.pjrc
/usr/bin/sh: dfu-programmer: command not found
/usr/bin/sh: dfu-programmer: command not found

-------- begin --------
avr-gcc (WinAVR 20100110) 4.3.3
Copyright (C) 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


mkdir -p obj_gh60_pjrc
Compiling C: keymap_poker.c
avr-gcc -c -mmcu=atmega32u4 -gdwarf-2 -DF_CPU=16000000UL -DBOOTLOADER_SIZE=4096 -DPROTOCOL_PJRC -DBOOTMAGIC_ENABLE -DMOUSEKEY_ENABLE -DMOUSE_ENABLE -DEXTRAKEY_ENABLE -DCONSOLE_ENABLE -DCOMMAND_ENABLE -DNKRO_ENABLE -DSLEEP_LED_ENABLE -DNO_SUSPEND_POWER_DOWN -DVERSION=unknown -Os -funsigned-char -funsigned-bitfields -ffunction-sections -fdata-sections -fno-inline-small-functions -fpack-struct -fshort-enums -fno-strict-aliasing -Wall -Wstrict-prototypes -Wa,-adhlns=obj_gh60_pjrc/keymap_poker.lst -I. -I../../tmk_core -I../../tmk_core/protocol/pjrc -I../../tmk_core/common -std=gnu99 -include config.h -MMD -MP -MF .dep/obj_gh60_pjrc_keymap_poker.o.d  keymap_poker.c -o obj_gh60_pjrc/keymap_poker.o
keymap_poker.c:8: error: 'KC_F0' undeclared here (not in a function)
make: *** [obj_gh60_pjrc/keymap_poker.o] Error 1

C:\Users\kagan\Documents\Keyboard Software\tmk_keyboard-master\keyboard\gh60>

User avatar
Halvar

09 Nov 2015, 20:39

Is that with the unchanged source?

The error message

keymap_poker.c:8: error: 'KC_F0' undeclared here (not in a function)

looks like a pretty normal error in your keymap_poker.c file. If this is your code and you don't find the error, post your poker.c file.

Tomer

09 Nov 2015, 20:41

Halvar wrote: Is that with the unchenged source?

The error message

keymap_poker.c:8: error: 'KC_F0' undeclared here (not in a function)

looks like a pretty normal error in your keymap_poker.c file. If this is your code and you don't find the error, post your poker.c file.
Hey Halvar, thanks for your quick response. I tried that with my own source. Here is my poker.c file:

Code: Select all

#include "keymap_common.h"

const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
	/* 0: qwerty */
    KEYMAP(ESC,  Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,   BSPC, \
           TAB,  A,   S,   D,   F,   G,   H,   J,   K,   L,   ENT,       \
           LSFT, Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, RSFT,      \
           LCTL, LALT,F0,  F1,      SPC,       F2,   WHOM,RCTL,SLSH),
		   
	/* 1: FN 1 */
	KEYMAP(INS, 1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   DELETE, \
           TRNS,TRNS,TRNS,TRNS,GRV, MINS, EQL, LBRC,  RBRC,  BSLS, TRNS,  \
           TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, SCOLON, QUOT,TRNS,UP,TRNS,      \
           TRNS, TRNS,TRNS,  TRNS,    TRNS,    TRNS, LEFT,DOWN,RIGHT),
		   
	/* 2: FN 2 */
	KEYMAP(PSCR, 1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   DELETE, \
           CAPS,TRNS,TRNS,TRNS,GRV, MINS, EQL, LBRC,  RBRC,  BSLS, TRNS,   \
           TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, SCOLON, QUOT,TRNS,PGUP,TRNS,     \
           TRNS, TRNS,TRNS,  TRNS,    TRNS,    TRNS, CALC,PGDOWN,TRNS),


};

const uint16_t PROGMEM fn_actions[] = {
 [0] = ACTION_LAYER_MOMENTARY(3),
 [1] = ACTION_LAYER_TOGGLE(1),
 [2] = ACTION_LAYER_TOGGLE(2),
};

User avatar
Halvar

09 Nov 2015, 20:48

F0 in your first layer is an undefined keycode. Maybe you mean FN0?

You can look up the available codes in the file /common/keycode.h

Tomer

09 Nov 2015, 20:53

Halvar wrote: F0 in your first layer is an undefined keycode. Maybe you mean FN0?

You can look up the available codes in the file /common/keycode.h
Yes!!!
That was my mistake - I wrote my function keys as "Fx" instead of "FNx"!

Thank you, Halvar!

User avatar
Halvar

09 Nov 2015, 21:00

You're welcome! Does the keyboard work?

Tomer

11 Nov 2015, 11:05

Halvar wrote: You're welcome! Does the keyboard work?
After a few days of programming and re-soldering what apparently was a non-functioning diode, the keyboard works perfectly!
Thanks again for the help.
Now I need to figure out how to program toggle LEDs on my two toggle function keys and on my CAPS lock key.

zoomx19

24 Nov 2015, 02:45

I did all the steps and assigned everything correctly but for some reason all the keys arent mapped to the right switches, idk what to do help.

User avatar
Halvar

24 Nov 2015, 08:06

idk how to help help.

User avatar
rockosmodlife

15 Dec 2015, 06:38

hey guys, I have an issue that I cant seem to shake here.

Code: Select all

obj_gh60_lufa/common/keyboard.o: In function `keyboard_set_leds':
C:\Users\Administrator\Downloads\tmk_keyboard-master\tmk_keyboard-master\keyboard\gh60/../../tmk_core/common/keyboard.c:176: undefined reference to `led_set'
obj_gh60_lufa/common/keymap.o: In function `action_for_key':
C:\Users\Administrator\Downloads\tmk_keyboard-master\tmk_keyboard-master\keyboard\gh60/../../tmk_core/common/keymap.c:36: undefined reference to `keymap_fn_to_action'
make: *** [gh60_lufa.elf] Error 1
The above is what cmd spits out after trying to compile. I do not wish to include any LEDs or a FN layer. What items need to be edited to reflect a keyboard that does not have a FN layer or LED array?

I am no coder by any amount, but I assume that there are empty variables that are causing this error because I have not defined the led_set or a fn key or layer.

Thanks

User avatar
Halvar

15 Dec 2015, 11:25

Hi, welcome to DT!

Did you delete or edit the file led.c? Or the file keymap_common.c? Because these are the files where the function belong that cannot be found.

If you don`t want to use LEDs, you can empty the function led_set(), but you should not delete it.

Code: Select all

void led_set(uint8_t usb_led)
{
}


I would leave keymap_fn_to_action() untouched.

Code: Select all

/* translates Fn keycode to action */
action_t keymap_fn_to_action(uint8_t keycode)
{
    return (action_t){ .code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]) };
} 

User avatar
rockosmodlife

16 Dec 2015, 02:12

Halvar wrote: Hi, welcome to DT!

Did you delete or edit the file led.c? Or the file keymap_common.c? Because these are the files where the function belong that cannot be found.

If you don`t want to use LEDs, you can empty the function led_set(), but you should not delete it.

Code: Select all

void led_set(uint8_t usb_led)
{
}


I would leave keymap_fn_to_action() untouched.

Code: Select all

/* translates Fn keycode to action */
action_t keymap_fn_to_action(uint8_t keycode)
{
    return (action_t){ .code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]) };
} 

Thanks!

Now I get the following:

Code: Select all

keymap_common.c: In function 'keymap_fn_to_action':
keymap_common.c:29: error: 'fn_actions' undeclared (first use in this function)
keymap_common.c:29: error: (Each undeclared identifier is reported only once
keymap_common.c:29: error: for each function it appears in.)
make: *** [obj_gh60_lufa/keymap_common.o] Error 1

nicstreet

16 Dec 2015, 02:33

Good evening all, has anyone any experience using any of the other members of the Teensy family? or possibly with an Arduino? I have a Teensy 3.1 and an Arduino Mini Pro. Wondering if it's worth pursuing these or wait for a Teensy 2. As a side to this, has anyone developed Bluetooth capabilities? I have an RN42HID on its way which I'll hopefully look to integrate into a project next year.

Thanks

Nic

Post Reply

Return to “Workshop”