geekhack

geekhack Projects => Making Stuff Together! => Topic started by: hasu on Wed, 03 April 2013, 19:51:33

Title: TMK keyboard firmware
Post by: hasu on Wed, 03 April 2013, 19:51:33
I hope that this thread become a place to get bug report, feedback and suggestion from the community.

Source code repository
https://github.com/tmk/tmk_keyboard (https://github.com/tmk/tmk_keyboard)


You are using QMK?
QMK has already great and helpful community and will help you. You can ask there.

- https://github.com/jackhumbert/qmk_firmware
- https://www.reddit.com/r/olkb/



NEED HELP?

Read wiki pages first.
https://github.com/tmk/tmk_keyboard/wiki


Use this if you have problem on building firmware.
https://github.com/tmk/tmk_keyboard/wiki/Build-firmware-on-VirtualBox


Your keyboard/converter doesn't work?
Frist, post schematics or pics of your hardware and wriring this really saves our time. Don't save your time by omitting this.

If you edit code
Post your code. Don't hesitate to show your dirty code!

And other infos you can provide
- Which OS are you using?



UPDATE
2013/07  NKRO on LUFA is supported
2014/03  FAQ and Keymap Editor are added
2014/12  updated USB to USB converter (https://geekhack.org/index.php?topic=41989.msg1558449#msg1558449)
2015/01  Added Infinity support(mbed based) (https://geekhack.org/index.php?topic=41989.msg1586196#msg1586196)
2015/03  Updated for Infinity 'production' model (https://geekhack.org/index.php?topic=41989.msg1688544#msg1688544)
2015/04  Changed location of core library to 'tmk_core' directory.
More
Update your Makefile to change variable name TOP_DIR to TMK_DIR and location of core library.
Code: [Select]
TMK_DIR = ../../tmk_core
https://github.com/tmk/tmk_keyboard#20150422

2015/09  NeXT converter LED control fix (https://geekhack.org/index.php?topic=41989.msg1869980#msg1869980)
2016/02  flabbergast's Chibios protocol was merged
2016/06  Added XT to USB converter. Thank you, @papodaca. https://github.com/tmk/tmk_keyboard/pull/355
2017/05  Fixed Modifier/Layer key stuck problem. https://github.com/tmk/tmk_keyboard/tree/master/tmk_core#20170530

README
https://github.com/tmk/tmk_keyboard/blob/master/README.md (https://github.com/tmk/tmk_keyboard/blob/master/README.md)


Build
https://github.com/tmk/tmk_keyboard/blob/master/tmk_core/doc/build.md (https://github.com/tmk/tmk_keyboard/blob/master/tmk_core/doc/build.md)


Customize Keymap
https://github.com/tmk/tmk_keyboard/blob/master/tmk_core/doc/keymap.md (https://github.com/tmk/tmk_keyboard/blob/master/tmk_core/doc/keymap.md)


FAQ/WIKI
https://github.com/tmk/tmk_keyboard/wiki/FAQ
https://github.com/tmk/tmk_keyboard/wiki


Keymap Editor
http://tmk.github.io/tmk_keyboard/editor/index.html



TMK own projects
You can find under: https://github.com/tmk

Keyobard:
Alternative controller for HHKB (https://geekhack.org/showwiki.php?title=Island:12047)
Alps64 - PCB for Alps SKCM/L (https://geekhack.org/index.php?topic=69666.0)
Happy Buckling Keyboard(Model M 60% mod) (https://geekhack.org/index.php?topic=29483.0)
PCB cut 60% mod(retired) (https://geekhack.org/showwiki.php?title=Island:11930)
GH60 (https://github.com/tmk/tmk_keyboard/tree/master/keyboard/gh60)(unofficial)
Infinity Ergodox (https://github.com/tmk/infinity_ergodox)(unofficial)
Infinity 60chibios (https://github.com/tmk/tmk_keyboard/tree/master/keyboard/infinity_chibios) mbed (https://github.com/tmk/tmk_keyboard/tree/master/keyboard/infinity)(unofficial)

Converter:
PS/2(Code Set 2) (https://geekhack.org/showwiki.php?title=Island:14618)
ADB(Apple Desktop Bus) (https://geekhack.org/showwiki.php?title=Island:14290)
M0110(Apple Machintosh 128K/512K/Plus) (https://geekhack.org/showwiki.php?title=Island:24965)
NEWS(Sony workstation) (https://geekhack.org/showwiki.php?title=Island:25759)
X68K(Sharp X68000) (https://geekhack.org/showwiki.php?title=Island:29060)
IBM 4704 (https://geekhack.org/index.php?topic=54706.0)
USB to USB (https://geekhack.org/index.php?topic=41989.msg1558449#msg1558449)
Sun(Sun Microsystems) (https://github.com/tmk/tmk_keyboard/tree/master/converter/sun_usb)
PC98(NEC) (https://github.com/tmk/tmk_keyboard/tree/master/converter/pc98_usb)
NeXT(Non ADB) (https://github.com/tmk/tmk_keyboard/tree/master/converter/next_usb) pic (http://i.imgur.com/kgIzoVah.jpg) contribution from bcg(https://github.com/tmk/tmk_keyboard/pull/92)
XT(Code Set 1) (https://github.com/tmk/tmk_keyboard/tree/master/converter/xt_usb) contribution from papodaca(https://github.com/tmk/tmk_keyboard/pull/355)

TMK Products
HHKB Alt Controller
https://geekhack.org/index.php?topic=71517.0

TMK Converters
https://geekhack.org/index.php?topic=72052.0

Alps64
https://geekhack.org/index.php?topic=69740.0
Title: Re: TMK keyboard firmware
Post by: hasu on Wed, 03 April 2013, 19:51:47
Previously Asked Questions

NKRO doesn't work
http://geekhack.org/index.php?topic=41989.msg1244834#msg1244834

What is the meaning of "TMK"?
http://geekhack.org/index.php?topic=41989.msg1230017#msg1230017
Title: TMK keyboard firmware
Post by: jdcarpe on Wed, 03 April 2013, 20:43:14
Do you have any instruction on how to make a Fn layer toggle on and off, rather than only switching layers while a Fn key is pressed?

I really like your FW!
Title: Re: TMK keyboard firmware
Post by: nano on Thu, 04 April 2013, 03:15:00
Do you have any instruction on how to make a Fn layer toggle on and off, rather than only switching layers while a Fn key is pressed?
Look at doc/keymap.md. All layer actions are documented there.

As I’ve said before in the gh60 thread, that code is plain awesome and understandable. I really like your how you implement the keymap and how easy it is to make it fit your own needs.

I’ve already forked your repo here  (https://github.com/femtoo/tmk_keyboard/tree/kbedit)and started toying around a bit ;D
Title: Re: TMK keyboard firmware
Post by: agodinhost on Thu, 04 April 2013, 09:27:52
Hi Hasu, thanks very much for this opportunity to learn more about your firmware
and thanks very much for sharing it!

Quote from: hasu date=2013-04-03
You'll have to write a 'host side protocol' module to add support for BT HID.
I didn't understood why we will need a "host" side module. It wouldn't be one simple slave? (according to what I saw at the Bluetooth HID Lite (https://www.bluetooth.org/docman/handlers/DownloadDoc.ashx?doc_id=41207&vId=43270) documentation).

Quote from: hasu date=2013-04-03
My firmware has a module using Bluegiga iWRAP4 for BT(and V-USB for USB), you can find this under protocol/iwrap/ directory. But it is very old code and not supported actively now. I don't know even whether it works with new updated firmware base. Though, I think it is still a good start point for BT module. Also LUFA 'host side protocol' module will be worth looking into. It is located on protocol/lufa/.
Yup I saw both of these folders there. I'll have to buy this BlueGiga module to test it further - just waiting for the best day of my credit card. I were already planning to get one of these and the RN-42 anyway.

-> Reference papers for those willing to touch Hasu's code:
    TMK keyboard firmware collection (http://deskthority.net/workshop-f7/tmk-keyboard-firmware-collection-t4478.html)
         Hasu's deskthority previous topic.
    Bluetooth HID Lite (https://www.bluetooth.org/docman/handlers/DownloadDoc.ashx?doc_id=41207&vId=43270)
         HID Lite = HID Keyboard Boot mode, could it be one easier option to our GH60 Bluetooth keyboard?
    Human Interface Device Profile 1.1 (https://www.bluetooth.org/docman/handlers/downloaddoc.ashx?doc_id=246761)
         Official HID 1.1 profile documentation
    HID Profile, Bluetooth HID Tutorial (http://www.palowireless.com/infotooth/tutorial/n7_hid.asp)
         Awesome tutorial

-> For discussion:
    LUFA BT HID not 100% done (https://groups.google.com/forum/?fromgroups=#!topic/lufa-support/J3gBK1-iE_8)
         See the last message, by Dean Camera.
    "LUFA has bluetooth hid support (https://forum.sparkfun.com/viewtopic.php?f=13&t=22013)" (unknow guy)
         "... you can port OSS host stack - maybe BlueZ(the linux stack) or lwBT (the latter designed for low memory usage for embedded systems)."
    Btstack AVR on google code (http://code.google.com/p/btstack-avr/)
         Seems to be one Bluetooth HID stack but I'm not sure of it - it's complete? Too little code there.

-> Reference code:
    Dean Camera Bluetooth Explorer bot (http://www.fourwalledcubicle.com/ExplorerBot.php) (LUFA based, with a partial HID/L2CAP/SDP layers)
         This project acts as a Bluetooth host receiving joystick movements and as a device, sending sensor data to one PC. This PC has one USB HID driver installed to parse the bot messages.

Gosh, too much stuff to read and learn!!!
Title: Re: TMK keyboard firmware
Post by: hasu on Thu, 04 April 2013, 18:58:45
Do you have any instruction on how to make a Fn layer toggle on and off, rather than only switching layers while a Fn key is pressed?

I really like your FW!
Thanks! Updated keymap document and my fist post with hoping this helps you and other.
https://github.com/tmk/tmk_keyboard/blob/master/doc/keymap.md#32-toggle-switching



As I’ve said before in the gh60 thread, that code is plain awesome and understandable. I really like your how you implement the keymap and how easy it is to make it fit your own needs.

I’ve already forked your repo here  (https://github.com/femtoo/tmk_keyboard/tree/kbedit)and started toying around a bit ;D
Looks great. Impressive keymap :) I'll look into it later.
Happy to see someone forks my code and starts his own project!
Title: Re: TMK keyboard firmware
Post by: hasu on Thu, 04 April 2013, 19:20:35
Hi agodinhost,
My terminology 'host side' may be a bit confusing because in my firmware keyboard and converter projects share same core base.
Keyboard projects have a USB protocol(host side) to communicate with host while converters have 'keyboard side' protocol such as PS/2, ADB, ... to hook up to target keyboard in addition to 'host side' protocol.

You are right. It is totally a slave or client, neither server nor host.
With this 'host side protocol' module l wanted to mean a client implementation of BT HID in keyboard firmware. Confusing :)
While 'keyboard side protocol' module means host side implementation of the keyboard protocol.

Hi Hasu, thanks very much for this opportunity to learn more about your firmware
and thanks very much for sharing it!

Quote from: hasu date=2013-04-03
You'll have to write a 'host side protocol' module to add support for BT HID.
I didn't understood why we will need a "host" side module. It wouldn't be one simple slave? (according to what I saw at the Bluetooth HID Lite (https://www.bluetooth.org/docman/handlers/DownloadDoc.ashx?doc_id=41207&vId=43270) documentation).

Quote from: hasu date=2013-04-03
My firmware has a module using Bluegiga iWRAP4 for BT(and V-USB for USB), you can find this under protocol/iwrap/ directory. But it is very old code and not supported actively now. I don't know even whether it works with new updated firmware base. Though, I think it is still a good start point for BT module. Also LUFA 'host side protocol' module will be worth looking into. It is located on protocol/lufa/.
Yup I saw both of these folders there. I'll have to buy this BlueGiga module to test it further - just waiting for the best day of my credit card. I were already planning to get one of these and the RN-42 anyway.
Title: Re: TMK keyboard firmware
Post by: Glissant on Mon, 08 April 2013, 04:09:30
Hey, hasu. Excellent firmware, and I wanted to thank you for all the work that you have put into it. I am extremely impressed to see how easy it is to re-configure the layout.

I am having an issue understanding how to add keys to the layout though. I've tried to add keys by changing out NO with K31 and K3C respectively in keymap.c. Then I added a keystroke for each of the keys in keymap_poker.h .
Anyway, it's safe to say that I couldn't figure it out by myself, so I am asking for help =).
Title: Re: TMK keyboard firmware
Post by: hasu on Mon, 08 April 2013, 06:05:45
Hi, Glissant.
I assume you are talking about GH60 keymap and you want to define KEYMAP_ISO() instead of KEYMAP_ANSI().

To define the macro you'll also need to add K31 and K3C in first part in addition to replace NO with those keys in second part.
Code: [Select]
#define KEYMAP_ISO( \
... first part ...(arguments)
} KEYMAP (\
... second part...(definition)
)

Or you can define all keys available on GH60 with KEYMAP() macro.
Title: Re: TMK keyboard firmware
Post by: Glissant on Mon, 08 April 2013, 06:11:35
Hasu =),
I actually just want to turn my shift keys into two keys. But I'll look into it again after work =). Look at my latest gh60 pictures in the Post your GH60-thread to see the key setup.  I'll link it here if need be but it will have to be after work.

Edit http://geekhack.org/index.php?topic=39702.msg831294#msg831294 (http://geekhack.org/index.php?topic=39702.msg831294#msg831294)


EDIT2:
I finally figured it out. I had to add my new keys to all of the KEYMAP() macros in keymap.h, which makes perfect sense.
This firmware is almost just too perfect. Thanks again!
Title: Re: TMK keyboard firmware
Post by: metalliqaz on Mon, 08 April 2013, 08:11:45
Good stuff.  Props for supporting 3 USB libraries!
Title: Re: TMK keyboard firmware
Post by: regack on Mon, 08 April 2013, 08:57:06
I just wanted to say thank you for all your hard work and making it availble to all of us.
Title: Re: TMK keyboard firmware
Post by: Tranquilite on Mon, 08 April 2013, 15:07:30
I've been using this firmware for my Phantom, and find it to be incredibly functional. I hacked in a few adjustments to mine such that one of my LEDs now shows the status of my "numpad" layer. I also have it set up to automatically turn on numlock when that layer is active. I also really like nkro over usb even though I have never needed more than 6kro :|
if I ever get around to opening my keyboard again I think I might replace my mx lock switch with a regular one because of the new(ish) layer toggle functionality.

Looking forward to putting this firmware on my GH60 when I get one.
Title: Re: TMK keyboard firmware
Post by: metalliqaz on Mon, 08 April 2013, 15:55:22
What method does hasu use for supporting N-key rollover?  The multi-keyboard method or the generic HID method?
Title: Re: TMK keyboard firmware
Post by: hasu on Mon, 08 April 2013, 18:22:46
I use 'bitmap' method which assigns a bit per key. I'm not sure about HID terminology for this.
Using 16 byte report size it can send 128 keys at once in fact, it is enough number in most cases.

Multi-keyboard method isn't  used to support NKRO itself, but you'll see two keyboards/endpoints, one for normal 6KRO and other for NKRO to avoid compatibility issue.

Note that NKRO is supported only with PJRC stack at the moment.
Title: Re: TMK keyboard firmware
Post by: domoaligato on Mon, 03 June 2013, 11:54:25
I have wired a alps keyboard following the lowpoly method and I want to use your firmware with my teensy 2.0 controller.

how to I attach my matrix to my teensy to work with your firmware?
Which pins get the rows and which get the columns?
I won't be using a capslock led or any led's in fact but a basic understanding of this would be very cool as well.

Sorry for the noob questions but I guess I have to start somewhere.


edit: the post editor is messing with me.
Title: Re: TMK keyboard firmware
Post by: alaricljs on Mon, 03 June 2013, 12:06:12
domo, Hasu's FW is very flexible in that regard since you can do matrix pin assignments as well as the keymap->matrix assignments on a per-KB basis.

The macway might be your best starting point.
Title: Re: TMK keyboard firmware
Post by: domoaligato on Mon, 03 June 2013, 12:35:13
ok so I am looking at https://github.com/tmk/tmk_keyboard/blob/master/keyboard/macway/config.h

it states

Code: [Select]
/* matrix size */
#define MATRIX_ROWS 9
#define MATRIX_COLS 8

in what file to I actually map the pins to rows/columns ?
Title: Re: TMK keyboard firmware
Post by: alaricljs on Mon, 03 June 2013, 12:38:58
https://github.com/tmk/tmk_keyboard/blob/master/keyboard/macway/matrix.c
Title: Re: TMK keyboard firmware
Post by: domoaligato on Mon, 03 June 2013, 12:48:31
for the 9 rows (I can't believe I missed this)
Code: [Select]
Line 176    // Output low(DDR:1, PORT:0) to select
Line 177    // row: 0    1    2    3    4    5    6    7    8
Line 178    // pin: PD0, PD5, PD7, PF6, PD6, PD1, PD2, PC6, PF7
Line 178-215

which lines have the cols?
Title: Re: TMK keyboard firmware
Post by: alaricljs on Mon, 03 June 2013, 12:51:21
near line 155+  all of Port B
Title: Re: TMK keyboard firmware
Post by: domoaligato on Mon, 03 June 2013, 12:54:23
near line 155+  all of Port B

Thank you for being so patient with me!

what is portb ?
Title: Re: TMK keyboard firmware
Post by: kmiller8 on Mon, 03 June 2013, 12:57:23
what is portb ?

Every pin with "PBx" (Port, B, Pin#)
Title: Re: TMK keyboard firmware
Post by: domoaligato on Mon, 03 June 2013, 13:04:14
what is portb ?

Every pin with "PBx" (Port, B, Pin#)

am I correct to assume that it col 1 = PB0 col2 = PB1 col3 = PB2 etc etc...?
Title: Re: TMK keyboard firmware
Post by: alaricljs on Mon, 03 June 2013, 13:06:24
columns 0-7, but yes.
Title: Re: TMK keyboard firmware
Post by: domoaligato on Mon, 03 June 2013, 13:13:30
lol yes of course :D matrix starts at 0 - derp @ me!

You guys rock! thanks again. I will post pictures of my project as soon as I get the 20 pin connectors I ordered from pjrc last week.
since they are in portland and I live in the seattle area it should arrive in the next couple days.

keep in mind that this omron/alps iso winkeyless project is a experiment to learn on. I bought the board from a used pc shop and it was very dirty. I have not really cleaned it. it is just to dev and play with :D
Title: Re: TMK keyboard firmware
Post by: domoaligato on Mon, 03 June 2013, 17:46:40
Edit: This is information based on a teensy. I have a teensy 2.0 this is garbage for what I am doing.

I decided that the gh60 firmware was closer to what I needed then the macway device matrix.
based on that... below is the pinouts from the matrix.
would PC0-PC5 be unused pins that I could use for col:14 ?
I have one more column in my matrix then the gh60 due to the way that I hardwired it.


/* Column pin configuration
 * col: 0   1   2   3   4   5   6   7   8   9   10  11  12  13
 * pin: F0  F1  E6  C7  C6  B6  D4  B1  B0  B5  B4  D7  D6  B3
 */
 
 /* Row pin configuration
 * row: 0   1   2   3   4
 * pin: D0  D1  D2  D3  D5
 */
 
L = Left side of Teensy
R = Right Side of Teensy
* = I was unable to find if it is a used PIN.

#   L         #   wire    #   R   #   Wire
#   PB7   #   *           #   PB6   #   col5
#   PD0   #   row0   #   PB5   #   col9
#   PD1   #   row1   #   PB4   #   col10
#   PD2   #   row2   #   PB3   #   col13
#   PD3   #   row3   #   PB2   #   *
#   PD4   #   col6   #   PB1   #   col7
#   PD5   #   row4   #   PB0   #   col8
#   PD6   #   col12   #   PE7   #   *
#   PD7   #   col11   #   PE6   #   col2
#   PE0   #   *      #   GND   #   *
#   PE1   #   *      #   AREF   #   *
#   PC0   #   *      #   PF0   #   col0
#   PC1   #   *      #   PF1   #   col1
#   PC2   #   *      #   PF2   #   *
#   PC3   #   *      #   PF3   #   *
#   PC4   #   *      #   PF4   #   *
#   PC5   #   *      #   PF5   #   *
#   PC6   #   col4   #   PF6   #   *
#   PC7   #   col3   #   PF7   #   *

Title: Re: TMK keyboard firmware
Post by: alaricljs on Mon, 03 June 2013, 22:38:34
I only recommended macway as it directly uses the teensy :)
Title: Re: TMK keyboard firmware
Post by: hasu on Tue, 04 June 2013, 00:15:39
What is your matrix size? 5x15? Pics'll be very helpful to know your configuration.

I think you can use PC0-5 safely.
Note that Teensy has LED on PD6, so you won't be able to use this pin for matrix scan.
Title: Re: TMK keyboard firmware
Post by: domoaligato on Tue, 04 June 2013, 02:12:46
yeah it is 5x15 :(
here is some pics.

edit: please laugh :D
I am using this to learn.
if I need to rewire the matrix a little I am open to suggestions.
Title: Re: TMK keyboard firmware
Post by: domoaligato on Tue, 04 June 2013, 09:26:51
after some sleep...  i can add some cols together...
Title: Re: TMK keyboard firmware
Post by: esoomenona on Tue, 04 June 2013, 21:03:00
That's pretty damn sexy! I only laugh at big ass enter. But it fits with the hipster Alps theme.
Title: Re: TMK keyboard firmware
Post by: domoaligato on Wed, 05 June 2013, 00:39:54
it is not pretty but i am just using it to learn the firmware/layouts until i get the gh60
Title: Re: TMK keyboard firmware
Post by: domoaligato on Wed, 05 June 2013, 21:28:42
What is your matrix size? 5x15? Pics'll be very helpful to know your configuration.

I think you can use PC0-5 safely.
Note that Teensy has LED on PD6, so you won't be able to use this pin for matrix scan.

I am using a teensy 2.0 sorry I should have said this in the beginning.
http://www.pjrc.com/teensy/card2a.pdf

I originally messed up my pinouts.
here is my new updated pinouts.
please let me know what you think.

Edit: I pasted the wrong revision.... here is the corrected version...

L   |   Wire   |   R   |   wire    #
GND   |   *   |   VCC   |   *
PB0   |   row0   |   PF0   |   col6
PB1   |   row1   |   PF1   |   col7
PB2   |   row2   |   PF4   |   col8
PB3   |   row3   |   PF5   |   col9
PB7   |   row4   |   PF6   |   col10
PD0   |   col0   |   PF7   |   col11
PD1   |   col1   |   PB6   |   col12
PD2   |   col2   |   PB5   |   *
PD3   |   col3   |   PB4   |   *
PC6   |   col4   |   PD7   |   *
PC7   |   col5   |   PD6   |   *



Title: Re: TMK keyboard firmware
Post by: domoaligato on Wed, 05 June 2013, 23:58:42
ok I have edited the macway matrix.c
here is a pastebin.
http://paste.ubuntu.com/5737818/

can someone Please show me what I am doing wrong?
Title: Re: TMK keyboard firmware
Post by: hasu on Thu, 06 June 2013, 02:12:55
It looks read_cols() is good.

You need to edit unselecte_rows() to make row pins(PB0-3,7) Hi-Z state. To make a pin Hi-Z, you need to unset correstpond bits of both DDR and PORT register, in this case DDRB and PORTB.

And select_row() need to be fixed. Use correct register names.

Then, At line 64 in matrix init() you need to configure all column pins as Input with pull-up.



You can access documentation of the controller here: http://www.atmel.com/devices/atmega32u4.aspx?tab=documents
At least you must have this datasheet in hand: http://www.atmel.com/Images/doc7766.pdf

See chapter 10 of the datasheet for control of I/O port. I'll try explain how to use I/O port here, If you can't got this plz feel free to refer to datasheet or use google :)

AVR I/O port is comprised of 8 pins and controlled with some 8bit registers. Some ports have less than 8 pins depending pin configurations of the chip, like PortC and PortF in ATMega32U4.


Pin name convention:
First pin of PortB is named as PB0, second as PB1, ... eighth as PB7.


You can use an I/O pin as either input or output line, first you must configure state of the pin, input or output before use. In fact AVR I/O pin can take four states: Hi-Z, Input with pull-up, Output Lo and Output High. You can decide I/O state per pin, so one port can have input pins and output at same time.

Pin state:
Input(Hi-Z), Input with pull-up, Output Lo, Output Hi

To control pin state you can use DDR*, PORT*, PIN* registers which comprised of 8bit correspond to pin number, where * is port name such like B, D, C or F.

Say you want to make PB2 Hi-Z state, then you should configure correstponding bit of DDRB and PORTB.
                   
    DDRB  &= ~0b00000100;   // clear bit
    PORTB &= ~0b00000100;   // clear bit
                   
To make PB0-3 output lo and PB4-7 Hi-Z state
                   
    DDRB  = 0b00001111;
    PORTB = 0b00000000;
                   
To know PB5 line logic(hi/lo) you should configure it input(with pull-up) then read PINB.
                   
    DDRB  &= ~0b00100000;   // clear bit
    PORTB |=  0b00100000;   // clear bit
                   
    if (PINB & 0b00100000) ... // read corresponding bit of PINB
                   
                   
Pin state configure:       
State               DDR     PORT
---------------------------------
Input(Hi-Z)         0       0
Input pull-up       0       1
Output Lo           1       0
Output Hi           1       1

Title: Re: TMK keyboard firmware
Post by: damorgue on Fri, 28 June 2013, 00:44:14
I didn't know until very recently that macro functionality had been added. Holy crap is it amazing. I think I have everything set up the way I want it now. Some examples of things I have done and inspiration of things which you could do too:

type out emails, addresses, names, phone numbers and other common things

type out username, tab, password, enter

type volume up key a couple of times in a row for other people who like me are annoyed by the 1% increase in volume per click normally

open your music player normalized, eg "shortcut to open program, volume down*100, volume up *30" to always have it start at volume 30, no matter what the volume is set to before


This firmware now has everything that I want from one. Thank you hasu, sincerely.
(if there was one thing I would still like, it would be that macros are aware of the caps lock state of the OS to not make it type out my email in capitals if I have caps lock on. Cherry's firmware has this. I would imagine a simple extra if statement where the macro is defined and it has two macros defined, one if caps lock is OFF and one if it is ON where I would add a simple T(CAPS) at the beginning and at the end)

Edit: If I can understand it enough to use it, then so can everyone else.
Title: Re: TMK keyboard firmware
Post by: Sifo on Fri, 28 June 2013, 00:49:18
Yeah man hasu's firmware is the best :D
Title: Re: TMK keyboard firmware
Post by: damorgue on Fri, 28 June 2013, 01:27:02
For some reason, T(VOLU) refuses to register in macros. Is that because the media control keys are different and defined in a different way than the letters?

Edit: Also, you added LCAP to complement CAPS. Could you perhaps add LSLC to complement SLCK in the same way to support MX Lock there as well?
Title: Re: TMK keyboard firmware
Post by: yeeeargh on Fri, 28 June 2013, 04:03:08
Quote from: hasu
OK. Now, I'd like to ask someone else to confirm whether the latest firmware(with my fix) works or not. Can someone check it?

I have a hid_liber built into my filco. not sure what the bug was and how it could be reproduced before the change of the debouncing algorithm but as far as I can tell, the new version works quite well. But I had no problems with debouncing even before the patch though. So if you explain the problem a bit further I can check that for you.
Title: Re: TMK keyboard firmware
Post by: hasu on Fri, 28 June 2013, 09:06:15
yeeeargh, thanks. Very helpful!

Great. Seems that my debouncing fix works. No need to check it further.

Previous algorithm could miss release event and cause a stuck key with typing a key very quickly in some situations.
So I recommend to stick with the latest firmware even if you had no problem so far.



damorgue,
OK. Ah, it liekly has a problem with that media keys. I'll check T(VOLU) later.
And I'll add 'mechanical locking switch support for ScrollLock and NumLock' to my TODO list.
Title: Re: TMK keyboard firmware
Post by: samwisekoi on Fri, 28 June 2013, 09:20:30
I didn't know until very recently that macro functionality had been added. Holy crap is it amazing. I think I have everything set up the way I want it now. Some examples of things I have done and inspiration of things which you could do too:

type out emails, addresses, names, phone numbers and other common things

type out username, tab, password, enter

type volume up key a couple of times in a row for other people who like me are annoyed by the 1% increase in volume per click normally

open your music player normalized, eg "shortcut to open program, volume down*100, volume up *30" to always have it start at volume 30, no matter what the volume is set to before


This firmware now has everything that I want from one. Thank you hasu, sincerely.
(if there was one thing I would still like, it would be that macros are aware of the caps lock state of the OS to not make it type out my email in capitals if I have caps lock on. Cherry's firmware has this. I would imagine a simple extra if statement where the macro is defined and it has two macros defined, one if caps lock is OFF and one if it is ON where I would add a simple T(CAPS) at the beginning and at the end)

Edit: If I can understand it enough to use it, then so can everyone else.

Wow!  This will be awesome to use on the GH75 in its full 24-function-key glory!  Twelve normal function keys on the top and another twelve on the left:

(http://geekhack.org/index.php?action=dlattach;topic=43450.0;attach=24184;image)
Re: GH75 Extending the GH60 to 65% and 75% (http://geekhack.org/index.php?topic=43450.msg915012#msg915012)

 - Ron | samwisekoi
(http://www.samwisekoi.com/pixelart/GH75.png)
Title: Re: TMK keyboard firmware
Post by: TD22057 on Sun, 07 July 2013, 21:45:42
I'm building a teensy based keyboard (6x16 matrix) so I started from the macway directory as a base and I'm a little confused on how to define a few of my keys.  In my Fn layer (layer 1), I want to have keys that send normally shifted characters (/*{}-+:" etc).  I can define my KEYMAP ok for the default layer, but how add a shifted key to my Fn layer?  For example, I want to have the U key (normal qwerty) send a shifted left bracket { in the Fn layer.

Do I assign those as FN## keys in the KEYMAP and then do something like:

Code: [Select]
static const uint16_t PROGMEM fn_actions[] = {
   ...
   ACTION_MODS_KEY(MOD_LSFT, KC_LBRACKET),
   };

If that is the answer, I may end up running out of function keys...
Title: Re: TMK keyboard firmware
Post by: hasu on Sun, 07 July 2013, 22:47:40
I'm building a teensy based keyboard (6x16 matrix) so I started from the macway directory as a base and I'm a little confused on how to define a few of my keys.  In my Fn layer (layer 1), I want to have keys that send normally shifted characters (/*{}-+:" etc).  I can define my KEYMAP ok for the default layer, but how add a shifted key to my Fn layer?  For example, I want to have the U key (normal qwerty) send a shifted left bracket { in the Fn layer.

Do I assign those as FN## keys in the KEYMAP and then do something like:

Code: [Select]
static const uint16_t PROGMEM fn_actions[] = {
   ...
   ACTION_MODS_KEY(MOD_LSFT, KC_LBRACKET),
   };

If that is the answer, I may end up running out of function keys...

You got right answer yourself unfortunately :( No easy way  to define those keymap such like atm. You must use many FN definitions while only 32 FN keys are available.

I thnk your problem shares the same root with this issue. Seems like there are some of demands for this and I should offer something of solution... I'll put this on my TODO list.
https://github.com/tmk/tmk_keyboard/issues/24
Title: Re: TMK keyboard firmware
Post by: TD22057 on Mon, 08 July 2013, 00:02:06
Ok, thanks. I should be ok with 32 function keys for now.

Are there any examples of how to configure key maps with macro recording keys? I have didn't see any in the current keyboards....
Title: Re: TMK keyboard firmware
Post by: hasu on Mon, 08 July 2013, 00:43:27
Macro feature is premature, still in development and not documented much. HHKB keymap and source code is only clue this moment.

Macro recording(on the fly) will not be implemented near future, you need to define macros in keymap code and compile it.
Title: Re: TMK keyboard firmware
Post by: TD22057 on Wed, 10 July 2013, 20:30:24
One more question hasu - for now anyway :)

I'm making a split hand keyboard using a teensy and IO extender (similar to the ergodox).  I was thinking about using your source as a base which seems pretty straightforward.  The Arduino library includes a nice API for using I2C devices (http://arduino.cc/en/Reference/Wire) as well as nice API's for reading and writing the various pins.  Is there any reason not to use the Arduino code in my keyboard module?
Title: Re: TMK keyboard firmware
Post by: hasu on Wed, 10 July 2013, 21:23:58
Arduino libraries are supposed to well tested and engineered by wise people.
Reading them and understand I2C will be optimal for starting point. But I think it might not be easy to use the source with my firmware you should port some arduino core codes the library depends on. I had some hassles to use Arduino USB host library, bothered by name collisions, dependency and different build policy. You can see my struggle at protocol/usb_hid/ and converter/usb_usb/ :)

Try using the library but if you find some difficulty on it I'd recommend to write/rewrite it yourself for you purpose.
Title: Re: TMK keyboard firmware
Post by: hasu on Wed, 10 July 2013, 22:20:27
And this also discusses about I2C. It may help you.
https://github.com/tmk/tmk_keyboard/issues/27
Title: Re: TMK keyboard firmware
Post by: damorgue on Thu, 11 July 2013, 07:41:36
Are there any numpad keys available?
Title: Re: TMK keyboard firmware
Post by: alaricljs on Thu, 11 July 2013, 07:44:18
This?

https://github.com/tmk/tmk_keyboard/blob/master/common/keycode.h (https://github.com/tmk/tmk_keyboard/blob/master/common/keycode.h)
Code: [Select]
/* Keypad */
#define KC_P1 KC_KP_1
#define KC_P2 KC_KP_2
#define KC_P3 KC_KP_3
#define KC_P4 KC_KP_4
#define KC_P5 KC_KP_5
#define KC_P6 KC_KP_6
#define KC_P7 KC_KP_7
#define KC_P8 KC_KP_8
#define KC_P9 KC_KP_9
#define KC_P0 KC_KP_0
#define KC_PDOT KC_KP_DOT
#define KC_PCMM KC_KP_COMMA
#define KC_PSLS KC_KP_SLASH
#define KC_PAST KC_KP_ASTERISK
#define KC_PMNS KC_KP_MINUS
#define KC_PPLS KC_KP_PLUS
#define KC_PEQL KC_KP_EQUAL
#define KC_PENT KC_KP_ENTER
Title: Re: TMK keyboard firmware
Post by: damorgue on Thu, 11 July 2013, 08:00:52
This?

Thanks
Title: Re: TMK keyboard firmware
Post by: hasu on Thu, 11 July 2013, 08:17:24
I setup repository for my converter KiCad project.
https://github.com/tmk/keyboard_converter

(http://i.imgur.com/6MVPreKl.jpg)
Title: Re: TMK keyboard firmware
Post by: Findecanor on Thu, 11 July 2013, 21:16:42
A choice of mini-USB and micro-USB out. Nice!
Title: Re: TMK keyboard firmware
Post by: damorgue on Fri, 12 July 2013, 09:59:45
I think I found another small bug
http://i.imgur.com/5lPPRFE.png
The default layout in 'keymap_iso.h' is not actually iso in the second layer. The first layer has the correct number of entries, but the second is a bit messed up. I first thought I had ghosting from a faulty diode. The same is true for' keymap_iso_150.h' by the way.

Edit: I get very dim leds until I change 'led.c' per a suggestion to:
Code: [Select]
void led_set(uint8_t usb_led)
{
    if (usb_led & (1<<USB_LED_CAPS_LOCK))
    {
        // Output high.
        DDRB |= (1<<6);
        DDRB |= (1<<6);
    }
    else
    {
        // Output low.
        DDRB &= ~(1<<6);
        DDRB &= ~(1<<6);
    }

    if (usb_led & (1<<USB_LED_SCROLL_LOCK))
    {
        // Output high.
        DDRB &= ~(1<<7);
        DDRB |= (1<<7);
    }
    else
    {
        // Output low.
        DDRB &= ~(1<<7);
        DDRB &= ~(1<<7);
    }
}
It doesn't make much sense to me, as there are a couple of duplicate lines there, but it works.
Title: Re: TMK keyboard firmware
Post by: Wraul on Fri, 12 July 2013, 11:48:11
I think I found another small bug
http://i.imgur.com/5lPPRFE.png
The default layout in 'keymap_iso.h' is not actually iso in the second layer. The first layer has the correct number of entries, but the second is a bit messed up. I first thought I had ghosting from a faulty diode. The same is true for' keymap_iso_150.h' by the way.

Thank you for testing the ISO layout and finding these errors.
I have corrected the layout files and will send hasu a pull request soon.

Edit: I get very dim leds until I change 'led.c' per a suggestion to:

The leds are working perfectly fine here.

Just to check a few things.

You are using the latest version that looks like this?
Code: [Select]
void led_set(uint8_t usb_led)
{
    if (usb_led & (1<<USB_LED_CAPS_LOCK))
    {
        // Output high.
        DDRB |= (1<<6);
        PORTB |= (1<<6);
    }
    else
    {
        // Output low.
        DDRB &= ~(1<<6);
        PORTB &= ~(1<<6);
    }

    if (usb_led & (1<<USB_LED_SCROLL_LOCK))
    {
        // Output high.
        DDRB |= (1<<7);
        PORTB |= (1<<7);
    }
    else
    {
        // Output low.
        DDRB &= ~(1<<7);
        PORTB &= ~(1<<7);
    }
}

You have the LED_BRIGHTNESS in config.h set to a sufficiently large number? Max being 255.

You have soldered the leds in the correct direction?
Title: Re: TMK keyboard firmware
Post by: damorgue on Fri, 12 July 2013, 12:11:53
You are using the latest version that looks like this?

Your code snippet works as well, so I must have been using an old led.c
Title: Re: TMK keyboard firmware
Post by: Wraul on Fri, 12 July 2013, 12:46:28
You are using the latest version that looks like this?

Your code snippet works as well, so I must have been using an old led.c

Sweet. Glad you got it working :D
Title: Re: TMK keyboard firmware
Post by: TD22057 on Fri, 12 July 2013, 16:37:07
So I'm trying to understand the debouncing algorithm that's in most of the matrix.c files (they all seem pretty similar).  It it's not too much trouble, could someone explain it in words?  The cherry switch spec says the debounce time is ~5ms.  It seems like most of the keyboards are doing something like this:
Code: [Select]
- for each row
   - energize row
   - wait 3-30 ms
   - read columns

Shouldn't the wait time built in to the loops mean that there isn't really a need for the debounce code?  I'm guessing it's necessary and I'm just missing something...
Title: Re: TMK keyboard firmware
Post by: TD22057 on Fri, 12 July 2013, 17:19:12
OK - I think I understand debouncing a little better now (maybe).  It's the activation count that's important - not so much the total delay in sampling.  It seems like it might be more robust to keep a debounce count or a timer count for each key.  Has anyone experimented with that kind of approach?
Title: Re: TMK keyboard firmware
Post by: TD22057 on Fri, 12 July 2013, 18:07:34
So I'm trying to understand the debouncing algorithm that's in most of the matrix.c files (they all seem pretty similar).  It it's not too much trouble, could someone explain it in words?  The cherry switch spec says the debounce time is ~5ms.  It seems like most of the keyboards are doing something like this:
Code: [Select]
- for each row
   - energize row
   - wait 3-30 ms
   - read columns

Shouldn't the wait time built in to the loops mean that there isn't really a need for the debounce code?  I'm guessing it's necessary and I'm just missing something...

I realize now I misread that code - the delay in the reading loops are micro-seconds, not milli-seconds...
Title: Re: TMK keyboard firmware
Post by: hasu on Fri, 12 July 2013, 18:15:19
There was a discuss about debouncing a while back. Maybe uselful for you.
http://geekhack.org/index.php?topic=42385.0

My deboucing code is very simple and premitive,  but it works :) I didn't care about debouncing method much, though, you will be able to find very elegant interesting algorithms and strategies on the net.
Title: Re: TMK keyboard firmware
Post by: TD22057 on Fri, 12 July 2013, 18:45:57
There was a discuss about debouncing a while back. Maybe uselful for you.
http://geekhack.org/index.php?topic=42385.0

My deboucing code is very simple and premitive,  but it works :) I didn't care about debouncing method much, though, you will be able to find very elegant interesting algorithms and strategies on the net.

Thanks - I realize I'm probably changing something that isn't broken.  Hard to resist the urge to tinker...
Title: Re: TMK keyboard firmware
Post by: Charger on Sat, 13 July 2013, 01:28:50
Hmmmm I am so lost trying to figure out how to configure this. There wouldn't happen to be a detailed walk thought on how to set this up anywhere would there?.

Anyways I guess the main thing I am trying to figure out is how to configure the matrix and and pin out for a teensy 2. I assume that I can use the common files to make a new keyboard setup or one of the other keyboards that are on there but i don't know how to change the number of rows and columns. This may take me longer then making the keyboard at this rate lol
Title: Re: TMK keyboard firmware
Post by: domoaligato on Sat, 13 July 2013, 02:39:33
Hmmmm I am so lost trying to figure out how to configure this. There wouldn't happen to be a detailed walk thought on how to set this up anywhere would there?.

Anyways I guess the main thing I am trying to figure out is how to configure the matrix and and pin out for a teensy 2. I assume that I can use the common files to make a new keyboard setup or one of the other keyboards that are on there but i don't know how to change the number of rows and columns. This may take me longer then making the keyboard at this rate lol


the following is assuming your using the gh60 folder as a base to edit.
edit config.h for this area...
/* key matrix size */
#define MATRIX_ROWS 5
#define MATRIX_COLS 14


look at the matrix.c in the gh60 folder. it was the most straightforward one for me to look at.
assign your pins to the row/cols
one of the functions automatically determines the amount of keys are in your matrix based on the assignment.

then edit the keymap.c
you will see this...

#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,                     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_NO,    KC_##K4A, KC_##K4B, KC_##K4C, KC_##K4D }  \
}

add the keymap definition's to this area.

then

edit keymap_plain.h to match your key mappings/layout.

and do not forget to change the pinout assignment in led.c to either your pins for your led's if you have them....

void led_set(uint8_t usb_led)
{
    if (usb_led & (1<<USB_LED_CAPS_LOCK)) {
        // output low
        DDRB |= (1<<2);
        PORTB &= ~(1<<2);
    } else {
        // Hi-Z
        DDRB &= ~(1<<2);
        PORTB &= ~(1<<2);
    }
}
Title: Re: TMK keyboard firmware
Post by: yeeeargh on Sat, 13 July 2013, 05:04:16
you might take a look at this thread over on deskthority where someone goes through the same process. there might be some answers for problems you might walk into:
http://deskthority.net/workshop-f7/filco-minila-swap-alt-and-win-key-teensy-my-best-bet-t5751-90.html
Title: Re: TMK keyboard firmware
Post by: TD22057 on Sat, 13 July 2013, 09:41:19
I'm working on a small TeensyPin class that encapsulates the direction, port, and pin registers for each pin.  The idea would be that you can then define your rows and columns like this:

Code: [Select]
static TeensyPin rows[MATRIX_ROWS] = {
   TPIN(F,0), TPIN(F,1), TPIN(F,4), TPIN(F,5),
   TPIN(F,6), TPIN(F,7),
};

static TeensyPin cols[MATRIX_COLS] = {
   TPIN(B,0), TPIN(B,1), TPIN(B,2), TPIN(B,3),
   TPIN(B,7), TPIN(D,2), TPIN(D,3), TPIN(C,6),
};

and that's all the code changes that would be required in matrix.c for a basic teensy layout (obviously you still have to customize led.c and keymap.c for your layout).  I'm hoping to have something working in the next week or so at which point you're welcome to look at it.  It won't be the most efficient way to do things but I think it will be a lot easier to read.  I don't think absolute efficiency matters that much and I have a better chance of understanding the code when I look at it next year and have forgotten everything I've learned about bit manipulation.
Title: Re: TMK keyboard firmware
Post by: bueller on Sat, 13 July 2013, 13:41:50
I'm working on a small TeensyPin class that encapsulates the direction, port, and pin registers for each pin.  The idea would be that you can then define your rows and columns like this:

Code: [Select]
static TeensyPin rows[MATRIX_ROWS] = {
   TPIN(F,0), TPIN(F,1), TPIN(F,4), TPIN(F,5),
   TPIN(F,6), TPIN(F,7),
};

static TeensyPin cols[MATRIX_COLS] = {
   TPIN(B,0), TPIN(B,1), TPIN(B,2), TPIN(B,3),
   TPIN(B,7), TPIN(D,2), TPIN(D,3), TPIN(C,6),
};

and that's all the code changes that would be required in matrix.c for a basic teensy layout (obviously you still have to customize led.c and keymap.c for your layout).  I'm hoping to have something working in the next week or so at which point you're welcome to look at it.  It won't be the most efficient way to do things but I think it will be a lot easier to read.  I don't think absolute efficiency matters that much and I have a better chance of understanding the code when I look at it next year and have forgotten everything I've learned about bit manipulation.


Definitely check in and let us know when you're done, anything to make life easier for people on their first run!
Title: Re: TMK keyboard firmware
Post by: TD22057 on Sun, 14 July 2013, 23:32:04
So I have my C++ TeensyPin class working (see prev post) and I'd like to see how much it slows things down.  I'm using the gh60 directory as a test bed (my teensy is on a bread board so I don't have an actual keyboard to try anything with).  Using arrays of variables to store the ports vs raw bit manipulation of the registers is much easier to read, but it's definitely slower.

hasu - what's the best way to generate timing information?  I added code in matrix_scan() that calls timer_read32() every 500'th call and prints the difference.  Is that timer call returning a millisecond counter?  Is there a better way to find the overall keyboard scan rate? 

If it is a millisecond timer and my math is right (both BIG assumptions at this point), it looks like the normal gh60 code is calls matrix_scan() at ~3290 Hz and my modified version using arrays of column and row variables calls matrix_scan() at ~1710 Hz.  Both of those seem really fast but maybe that's normal...

EDIT: After some simple optimizations (-O3, unselect a single pin instead of all of them), the scan rate is up to 2200 Hz.
Title: Re: TMK keyboard firmware
Post by: agodinhost on Mon, 15 July 2013, 08:01:29
So I have my C++ TeensyPin class working (see prev post) and I'd like to see how much it slows things down.  I'm using the gh60 directory as a test bed (my teensy is on a bread board so I don't have an actual keyboard to try anything with).  Using arrays of variables to store the ports vs raw bit manipulation of the registers is much easier to read, but it's definitely slower.
Could you share your code man?
I'm still working on my PCB and I couldn't touch any code yet ...
Title: Re: TMK keyboard firmware
Post by: alaricljs on Mon, 15 July 2013, 08:58:26
They may be both really fast on their own, but yours leaves less headroom for adding other features that eat CPU time.
Title: Re: TMK keyboard firmware
Post by: hasu on Mon, 15 July 2013, 09:11:05
So I have my C++ TeensyPin class working (see prev post) and I'd like to see how much it slows things down.  I'm using the gh60 directory as a test bed (my teensy is on a bread board so I don't have an actual keyboard to try anything with).  Using arrays of variables to store the ports vs raw bit manipulation of the registers is much easier to read, but it's definitely slower.

hasu - what's the best way to generate timing information?  I added code in matrix_scan() that calls timer_read32() every 500'th call and prints the difference.  Is that timer call returning a millisecond counter?  Is there a better way to find the overall keyboard scan rate? 

If it is a millisecond timer and my math is right (both BIG assumptions at this point), it looks like the normal gh60 code is calls matrix_scan() at ~3290 Hz and my modified version using arrays of column and row variables calls matrix_scan() at ~1710 Hz.  Both of those seem really fast but maybe that's normal...

Right. timer_read32() returns 32bit value in milli second. If you need finer granularity you can use other spare timer.

I think your code is fast enough to scan matrix and do debouncing.

Title: Re: TMK keyboard firmware
Post by: TD22057 on Mon, 15 July 2013, 10:19:32
They may be both really fast on their own, but yours leaves less headroom for adding other features that eat CPU time.

Agreed - that's why I'm testing.  There is still some chance I can optimize my code to get better speed but it's never going to be as efficient as direct register manipulation.  So of course I'm not suggesting that everyone should switch to using my pin class - but for people who aren't programmers or who don't want to learn teensy bit manipulations, the pin class + hasu's firmware can make it a lot simpler for someone to build their own firmware.

Right. timer_read32() returns 32bit value in milli second. If you need finer granularity you can use other spare timer.

I think your code is fast enough to scan matrix and do debouncing.

Thanks for all your help.  From what I can find, most commercial keyboards are scanning at 100-200 Hz and I think Ben said the ergodox was running at 150 Hz so 1000 Hz seems like plenty even with debouncing.  I might try the same measurement w/ the ergodox code just to make sure I'm comparing the same quantities...
Title: Re: TMK keyboard firmware
Post by: bueller on Mon, 15 July 2013, 10:35:37
I'm hoping someone more knowledgeable might be able to help. I've purchased the micro-controller (http://www.ebay.com.au/itm/360552830045?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1497.l2649) below with the ATMEGA32U4 on board, can anyone advise whether I'll be able to use it with the TMK firmware? It supports the Arduino IDE if that's helps at all, hopefully I won't have any problems using it with Atmel's software.

Not really sure how I'd go about identifying what each pin would be called when modifying hasu's code as well, anyone got any ideas?

EDIT: Actually I think I've figured the pins out, I should have been lookng at the actual board and not the text next to it in the image. From what I can tell all the pins on the Teensy are available on my board (ie B0-B7 etc.)

(http://i.imgur.com/q2Uf3xp.png)
Title: Re: TMK keyboard firmware
Post by: alaricljs on Mon, 15 July 2013, 11:31:59
This is functionally identical to a teensy, just with a different PCB and a different packaging for the chip.

So you are correct that you use the pin IDs silk-screened to the PCB.
Title: Re: TMK keyboard firmware
Post by: bueller on Mon, 15 July 2013, 12:00:08
Cheers! I'm eyeing off another board that's identical except for having headers for the usb port, might pick a 5 pack of those up for future builds and then wire up a proper USB connector.
Title: Re: TMK keyboard firmware
Post by: agodinhost on Mon, 15 July 2013, 12:11:13
Cheers! I'm eyeing off another board that's identical except for having headers for the usb port, might pick a 5 pack of those up for future builds and then wire up a proper USB connector.
There are at least 4 I know of, all atmega32u4 based:
- The Official Arduino Micro (http://arduino.cc/en/Main/ArduinoBoardMicro)
- The Freeduino on ebay (http://www.ebay.com/itm/Freaduino-Micro-ATmega32u4-Arduino-Mirco-100-compatible-/111118862940?pt=LH_DefaultDomain_0&hash=item19df334a5c)
- The Unofficial Leonardo Pro Micro (it uses the Arduino Mini footprint) on ebay (http://www.ebay.com/itm/2PCS-Leonardo-Pro-Micro-ATmega32U4-Arduino-IDE-Bootloader-replace-Pro-Mini-328P-/200935818980?pt=LH_DefaultDomain_0&hash=item2ec8b546e4)
- The old EWS Breakout Board on ebay (http://www.ebay.com/itm/EWS-ATmega32U4-Breakout-Board-/251192714781?pt=LH_DefaultDomain_0&var=&hash=item3a7c40a61d) too.
Title: Re: TMK keyboard firmware
Post by: domoaligato on Mon, 15 July 2013, 13:13:30
link to the adafruit one.
http://www.adafruit.com/products/296

edit: and it is a different boot loader as well. you have to flash it with avrdude

http://ladyada.net/products/atmega32u4breakout/
Title: Re: TMK keyboard firmware
Post by: hasu on Mon, 15 July 2013, 19:30:01
I'm hoping someone more knowledgeable might be able to help. I've purchased the micro-controller (http://www.ebay.com.au/itm/360552830045?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1497.l2649) below with the ATMEGA32U4 on board, can anyone advise whether I'll be able to use it with the TMK firmware? It supports the Arduino IDE if that's helps at all, hopefully I won't have any problems using it with Atmel's software.

It will works with the firmware without problem. But you should note that Leonardo has LEDs on PD0 and PD1 while Teensy has PD6, these may has some affections on matrix scan. You had better avoid using those pin to sense matrix(using as input), however,  I think you can use them for driving matrix line(as output).
And one thing to be warned, Leonardo bootloader is very tricky to work with... to be honest, it sucks from my experience.

TMK has no Arduino support so you cannot use it from Arduino IDE.


Deskthority has thread about alternatives to Teensy.
http://deskthority.net/workshop-f7/teensy-2-0-alternatives-atmega32u4-t4253.html
Title: Re: TMK keyboard firmware
Post by: bueller on Mon, 15 July 2013, 20:11:49
Cheers! I'm eyeing off another board that's identical except for having headers for the usb port, might pick a 5 pack of those up for future builds and then wire up a proper USB connector.
There are at least 4 I know of, all atmega32u4 based:
- The Official Arduino Micro (http://arduino.cc/en/Main/ArduinoBoardMicro)
- The Freeduino on ebay (http://www.ebay.com/itm/Freaduino-Micro-ATmega32u4-Arduino-Mirco-100-compatible-/111118862940?pt=LH_DefaultDomain_0&hash=item19df334a5c)
- The Unofficial Leonardo Pro Micro (it uses the Arduino Mini footprint) on ebay (http://www.ebay.com/itm/2PCS-Leonardo-Pro-Micro-ATmega32U4-Arduino-IDE-Bootloader-replace-Pro-Mini-328P-/200935818980?pt=LH_DefaultDomain_0&hash=item2ec8b546e4)
- The old EWS Breakout Board on ebay (http://www.ebay.com/itm/EWS-ATmega32U4-Breakout-Board-/251192714781?pt=LH_DefaultDomain_0&var=&hash=item3a7c40a61d) too.

Here (http://www.mattairtech.com/index.php/development-boards/atmega32u4-usb-development-board-arduino-compatible.html) is the one I'm looking at, seems to be really customisable considering the price.

I'm hoping someone more knowledgeable might be able to help. I've purchased the micro-controller (http://www.ebay.com.au/itm/360552830045?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1497.l2649) below with the ATMEGA32U4 on board, can anyone advise whether I'll be able to use it with the TMK firmware? It supports the Arduino IDE if that's helps at all, hopefully I won't have any problems using it with Atmel's software.

It will works with the firmware without problem. But you should note that Leonardo has LEDs on PD0 and PD1 while Teensy has PD6, these may has some affections on matrix scan. You had better avoid using those pin to sense matrix(using as input), however,  I think you can use them for driving matrix line(as output).
And one thing to be warned, Leonardo bootloader is very tricky to work with... to be honest, it sucks from my experience.

TMK has no Arduino support so you cannot use it from Arduino IDE.


Deskthority has thread about alternatives to Teensy.
http://deskthority.net/workshop-f7/teensy-2-0-alternatives-atmega32u4-t4253.html

Cheers for your help and all your hard work on the firmware! So if I'm understanding correctly I should be able to get rid of the Leonardo bootloader and write a more compatible one to the ATMEGA23U4?

Title: Re: TMK keyboard firmware
Post by: agodinhost on Mon, 15 July 2013, 20:31:31
Here (http://www.mattairtech.com/index.php/development-boards/atmega32u4-usb-development-board-arduino-compatible.html) is the one I'm looking at, seems to be really customisable considering the price.
It seems to be one EWS breakout board, the footprint of this board is  kinda weird - double pin rows and the pos of the pins are not "arduino compatible". This board is kinda old, you can get cheaper versions on ebay, just do a search using "atmega32u4".
I don't know this one, have you tried ebay? There are a lot of China made arduinos there per a decent price.
Title: Re: TMK keyboard firmware
Post by: TD22057 on Mon, 15 July 2013, 21:36:49
Could you share your code man?
I'm still working on my PCB and I couldn't touch any code yet ...

I've submitted a first cut at a sample simplified teensy firmware (based on gh60) at my fork of hasu's firmware. (https://github.com/TD22057/tmk_keyboard/tree/master/keyboard/teensy)

The files of interest are the matrix.cpp (https://github.com/TD22057/tmk_keyboard/blob/master/keyboard/teensy/matrix.cpp) and TeensyPin.hpp (https://github.com/TD22057/tmk_keyboard/blob/master/keyboard/teensy/TeensyPin.hpp) files.    The main idea is to make something that allows people to edit the row and column pin assignments in matrix.cpp and not touch anything else in that file (obviously you still have to edit keymap.c, maybe led.c, and the Makefile).   In the original file, you would need to add your pin assignments and set/clear the correct bits in init_cols(), read_cols(), unselect_rows() and select_row(). 

This is still in the prototype stage so there may still be problems with it.  Feel free to suggest improvements or name changes...
Title: Re: TMK keyboard firmware
Post by: agodinhost on Mon, 15 July 2013, 22:25:32
I've submitted a first cut at a sample simplified teensy firmware (based on gh60) at my fork of hasu's firmware. (https://github.com/TD22057/tmk_keyboard/tree/master/keyboard/teensy)

The files of interest are the matrix.cpp (https://github.com/TD22057/tmk_keyboard/blob/master/keyboard/teensy/matrix.cpp) and TeensyPin.hpp (https://github.com/TD22057/tmk_keyboard/blob/master/keyboard/teensy/TeensyPin.hpp) files.    The main idea is to make something that allows people to edit the row and column pin assignments in matrix.cpp and not touch anything else in that file (obviously you still have to edit keymap.c, maybe led.c, and the Makefile).   In the original file, you would need to add your pin assignments and set/clear the correct bits in init_cols(), read_cols(), unselect_rows() and select_row(). 

This is still in the prototype stage so there may still be problems with it.  Feel free to suggest improvements or name changes...
My 5 cents:

Your matrix_scan function does not settle any device address - so it is assuming that you do have only one I2C device. In my scenario I'll have 3: the 2 keyboard parts and one keypad - all using different addresses and configurations. I didn't saw any "setCurrentDeviceAddress" kind of function too.
The device address seems to be at the TeensyPin row/col arrays ...

Would not be better to use the two arrays (rowPins, colPins) as some sort of parameters ? It would help the "multiple devices" support and it would keep the responsibility/scope of your matrix class more clear (your matrix class is not responsible per the configuration data - it only uses it right?).

I think that the first and unique responsibility of your matrix class is to provide access to the keyboard matrix AND to make this access easier.

I need to put my hands in some piece of code - this is the kind of thing that is better to be done than said.

GOSH, so much stuff to do!!!
I need a day with 36 hours!!!
AHHHHHHHHHHHHHHHHHHHHHHhhhhh
My wife is calling me to bed ...
cya
Title: Re: TMK keyboard firmware
Post by: TD22057 on Mon, 15 July 2013, 23:25:45
I think you've misunderstood what my first commit is for - there is no matrix class, no I2C, and no multi-device encapsulation.  I'm 1) learning how hasu's firmware works, and 2) trying to provide a way for people who aren't programmers to easily write the matrix scanning function.  I'm going to add I2C support and encapsulate each device as much as possible but that's going to take longer (and I'll probably start a new thread to stop pseudo-hijacking this one...).
Title: Re: TMK keyboard firmware
Post by: bueller on Tue, 16 July 2013, 00:10:28

GOSH, so much stuff to do!!!
I need a day with 36 hours!!!
AHHHHHHHHHHHHHHHHHHHHHHhhhhh
My wife is calling me to bed ...
cya

This is me pretty much every night. Gets to midnight and I'm like "I'll just finish this up writing this class", next thing I know it's 4am. Hate the fact that I write my best code while everyone else is sleeping!
Title: Re: TMK keyboard firmware
Post by: hasu on Tue, 16 July 2013, 01:35:10
Cheers for your help and all your hard work on the firmware! So if I'm understanding correctly I should be able to get rid of the Leonardo bootloader and write a more compatible one to the ATMEGA23U4?

Right. You can replace bootloader with ISP programmer hardware like AVRISP mkII. You can pick LUFA DFU or CDC bootloader for this pupose. But if you don't want to pay for AVRISP mkII it is important to get a board with good bootloader.

IMO,
- Teensy Loader is the easiest way for first timer. Good document/tutorial with picures is useful.
- Atmel stock bootloader is OK. No problem.
- LUFA bootloader is good. I've never had a problem with LUFA DFU bootloader.
- Leonardo bootloader is not what you want.

If you already have Teensy, Atmel stock or LUFA bootloader you dont need to replace it. Just use it. But I'm completely sure you're frustrated with Leonardo bootloader. If you use it just once you may be OK, though, You cannot bear with it for several times.

LUFA is actually only one option if you need to replace bootloader. Atmel stock bootloader and PJRC Teensy bootloader is closed sourcen and no binaries available.


Following is memo of the bootloaders.
                                                                                                 
### LUFA DFU/HID/CDC bootloader
Open source bootloaders offered by LUFA.
         
Size: 4KB
Tool: dfu-programmer(DFU), Atmel FLIP(DFU), avrdude(HID,CDC), hid_bootloader(HID)
         
- http://fourwalledcubicle.com/blog/2013/03/the-new-lufa-bootloader/
- https://github.com/abcminiuser/lufa/tree/master/Bootloaders
         
         
         
### Atmel DFU bootloader
This is a stock bootloader from Atmel and factory default for AVR USB chips.
         
0. No source and binary available.
1. FLIP - Atmel prorietary GUI/CUI tool
2. dfu-programmer - Open source tool
         
Size: 4KB
Tool: FLIP, dfu-programmer
         
- http://www.atmel.com/Images/doc7618.pdf
         
         
         
### PJRC Teensy bootloader - halfKay
Extreme user friendly bootloader. You can get this loader Only by buying Teensy from PJRC.
         
0. No specific driver is needed using HID standard class.
1. Nice GUI tool. CUI command is also available.
2. Amazingly small foot print it occupies only 512 Bytes.
3. Can't handle EEPROM.
4. Closed source. Not avaiable source and binary.
         
Size: 512B
Tool: PJRC TeensyLoader(open source)
         
- http://www.pjrc.com/teensy/loader.html
- http://www.pjrc.com/teensy/halfkay_protocol.html
         
         
         
### Arduino Leonardo - caterina
Bootloader accompany with Arduino Leonardo. Not useful without Arduino IDE.
         
0. Open source. Derived from LUFA CDC bootloader.
1. Work with Arduino IDE.
2. Needs some extra procedure to program.
         
Size: 4KB
Tool: Arduino IDE, avrdude
         
- https://github.com/arduino/Arduino/tree/master/hardware/arduino/bootloaders/caterina
Title: Re: TMK keyboard firmware
Post by: bueller on Tue, 16 July 2013, 02:36:18
Cheers for your help and all your hard work on the firmware! So if I'm understanding correctly I should be able to get rid of the Leonardo bootloader and write a more compatible one to the ATMEGA23U4?

Right. You can replace bootloader with ISP programmer hardware like AVRISP mkII. You can pick LUFA DFU or CDC bootloader for this pupose. But if you don't want to pay for AVRISP mkII it is important to get a board with good bootloader.

IMO,
- Teensy Loader is the easiest way for first timer. Good document/tutorial with picures is useful.
- Atmel stock bootloader is OK. No problem.
- LUFA bootloader is good. I've never had a problem with LUFA DFU bootloader.
- Leonardo bootloader is not what you want.

If you already have Teensy, Atmel stock or LUFA bootloader you dont need to replace it. Just use it. But I'm completely sure you're frustrated with Leonardo bootloader. If you use it just once you may be OK, though, You cannot bear with it for several times.

LUFA is actually only one option if you need to replace bootloader. Atmel stock bootloader and PJRC Teensy bootloader is closed sourcen and no binaries available.


Following is memo of the bootloaders.
                                                                                                 
### LUFA DFU/HID/CDC bootloader
Open source bootloaders offered by LUFA.
         
Size: 4KB
Tool: dfu-programmer(DFU), Atmel FLIP(DFU), avrdude(HID,CDC), hid_bootloader(HID)
         
- http://fourwalledcubicle.com/blog/2013/03/the-new-lufa-bootloader/
- https://github.com/abcminiuser/lufa/tree/master/Bootloaders
         
         
         
### Atmel DFU bootloader
This is a stock bootloader from Atmel and factory default for AVR USB chips.
         
0. No source and binary available.
1. FLIP - Atmel prorietary GUI/CUI tool
2. dfu-programmer - Open source tool
         
Size: 4KB
Tool: FLIP, dfu-programmer
         
- http://www.atmel.com/Images/doc7618.pdf
         
         
         
### PJRC Teensy bootloader - halfKay
Extreme user friendly bootloader. You can get this loader Only by buying Teensy from PJRC.
         
0. No specific driver is needed using HID standard class.
1. Nice GUI tool. CUI command is also available.
2. Amazingly small foot print it occupies only 512 Bytes.
3. Can't handle EEPROM.
4. Closed source. Not avaiable source and binary.
         
Size: 512B
Tool: PJRC TeensyLoader(open source)
         
- http://www.pjrc.com/teensy/loader.html
- http://www.pjrc.com/teensy/halfkay_protocol.html
         
         
         
### Arduino Leonardo - caterina
Bootloader accompany with Arduino Leonardo. Not useful without Arduino IDE.
         
0. Open source. Derived from LUFA CDC bootloader.
1. Work with Arduino IDE.
2. Needs some extra procedure to program.
         
Size: 4KB
Tool: Arduino IDE, avrdude
         
- https://github.com/arduino/Arduino/tree/master/hardware/arduino/bootloaders/caterina

Thank you SO much for that hasu, I'm sure that took ages to type! I'm pretty interested in mucking around with micro-controllers so I might just pick up an ISP programmer to change the bootloader on this but I'll make sure I get models without the Arduino bootloader in future. Cheers!
Title: Re: TMK keyboard firmware
Post by: agodinhost on Tue, 16 July 2013, 06:54:38
I think you've misunderstood what my first commit is for - there is no matrix class, no I2C, and no multi-device encapsulation.  I'm 1) learning how hasu's firmware works, and 2) trying to provide a way for people who aren't programmers to easily write the matrix scanning function.  I'm going to add I2C support and encapsulate each device as much as possible but that's going to take longer (and I'll probably start a new thread to stop pseudo-hijacking this one...).
Sorry, I should have read more of your code before posting my comments.
So, can we start another thread? This topic is going to grow up soon and we are hijacking this one already!
 :)
Title: Re: TMK keyboard firmware
Post by: agodinhost on Tue, 16 July 2013, 07:09:06
...
### PJRC Teensy bootloader - halfKay
...
2. Amazingly small foot print it occupies only 512 Bytes.
...
512 Bytes only???
I bet it's done in assembly!
Sadly it's not open source ...
Title: Re: TMK keyboard firmware
Post by: alaricljs on Tue, 16 July 2013, 08:46:10
Thank you SO much for that hasu, I'm sure that took ages to type! I'm pretty interested in mucking around with micro-controllers so I might just pick up an ISP programmer to change the bootloader on this but I'll make sure I get models without the Arduino bootloader in future. Cheers!

If you want to DIY you can put together an ISP using a Teensy and some wires.  Amusingly enough the easiest ISP software to stick on it is an arduino sketch.  I've used my teensy to program several MCUs this way. 

http://dorkbotpdx.org/wiki/teensy_2_0_as_avr_isp_programmer
Title: Re: TMK keyboard firmware
Post by: hasu on Mon, 22 July 2013, 18:25:46
For some reason, T(VOLU) refuses to register in macros. Is that because the media control keys are different and defined in a different way than the letters?

This commit fixed this issue. Now media control and power keys are supported in macro.
Try latest version.

https://github.com/tmk/tmk_keyboard/commit/5b425731c5b662d107ba0f970a7ae7c7fe97d01b
Title: Re: TMK keyboard firmware
Post by: damorgue on Mon, 22 July 2013, 18:30:13
For some reason, T(VOLU) refuses to register in macros. Is that because the media control keys are different and defined in a different way than the letters?

This commit fixed this issue. Now media control and power keys are supported in macro.
Try latest version.

https://github.com/tmk/tmk_keyboard/commit/5b425731c5b662d107ba0f970a7ae7c7fe97d01b


Neato. Currently AFK (away from my phantom at least), but I trust it works. Thanks
Title: Re: TMK keyboard firmware
Post by: Charger on Mon, 22 July 2013, 20:32:38
Hmmm I wonder if there is a way to turn on an led based on what layer I'm on as it seems like it would be a nice thing that have the number row show the layer number
Title: Re: TMK keyboard firmware
Post by: TD22057 on Tue, 23 July 2013, 13:29:25
Hmmm I wonder if there is a way to turn on an led based on what layer I'm on as it seems like it would be a nice thing that have the number row show the layer number

I think the right approach is to define a function action that sets the LED and then modifies the layer.  See examples here: HHKB keymap.c (https://github.com/tmk/tmk_keyboard/blob/master/keyboard/hhkb/keymap.c).  You'll have to hunt around to figure out what the layer change macros do now and repeat those calls in your function after setting the LED.

Something I would like to be able to do is flash an LED in a pattern of some kind.  This could be used to indicate the layer (3 flashes = layer 3), to communicate information like if you adjust the debounce settings via macro, or maybe to indicate a macro recording mode.  It could be done with some simple led/wait/led/wait type code but the keyboard wouldn't work while that was happening.  It could also be done in the matrix scan function by checking the timer value and after a certain elapsed time, toggle the LED state. 

I might work on a small class to encapsulate some functionality like this.  Anyone know of a better way to handle elapsed time actions?  Is there a timer callback somewhere that would work for this?
Title: Re: TMK keyboard firmware
Post by: TD22057 on Tue, 23 July 2013, 14:24:05
Found this timer code for the teensy which supports interrupts which might be used to flash the LED.  Not sure how that overlaps with hasu's timer module (no interrupts). 

http://www.pjrc.com/teensy/td_libs_TimerOne.html

Title: Re: TMK keyboard firmware
Post by: hasu on Tue, 23 July 2013, 20:53:35
Callback  for timer interrupt or evnets like layer change and etc ? Interesting.

I use Timer0 as counter at milli second resolution in common/timer.h. You might be able to add timer callback to this.  Or you can also use other spare timer for callback.

And you may want to use hardware PWM to control LED better. I used PWM for sleep breathing LED in common/sleep_led.c.
Title: Re: TMK keyboard firmware
Post by: tjweir on Wed, 24 July 2013, 10:46:52
I've used TMK to program my HID_liberation board and now I'd like to use it on my MX MINI.

Has anyone tried this yet?  I see a KMAC project, shall I start with that?

Thanks!
Title: Re: TMK keyboard firmware
Post by: domoaligato on Thu, 25 July 2013, 14:36:16
when compiling the gh60 hex for the actual gh60 to flash with atmel flip...
I use the Makefile for lufa right?
Title: Re: TMK keyboard firmware
Post by: hasu on Thu, 25 July 2013, 19:53:26
when compiling the gh60 hex for the actual gh60 to flash with atmel flip...
I use the Makefile for lufa right?

Both lufa and pjrc stack works well for gh60, though I recommend lufa from now on. I won't update pjrc stack code for new features.

Compiling process doesn't depend on what flash method you use.

Use Makefile.lufa.
Title: Re: TMK keyboard firmware
Post by: domoaligato on Thu, 25 July 2013, 20:14:55
when compiling the gh60 hex for the actual gh60 to flash with atmel flip...
I use the Makefile for lufa right?

Both lufa and pjrc stack works well for gh60, though I recommend lufa from now on. I won't update pjrc stack code for new features.

Compiling process doesn't depend on what flash method you use.

Use Makefile.lufa.


Thanks!

I have tested it with lufa now and it works great compiling the latest version with winavr.
I am typing this on it now using your firmware and it works perfectly.

I am working on a c# gui to work as a layout editor for your firmware on windows for the gh60.

I will start small with basic poker functionality but later wish to implement the mousekeys and macro functions into the layout editor.
more to come soon.
Title: Re: TMK keyboard firmware
Post by: oTurtlez on Sat, 27 July 2013, 12:56:24
Hey there, just got everything all configured and got the firmware on my phantom but I've just got 1 question. It appears that my NKRO isn't working. I uncommented the NKRO_ENABLED line and remade the firmware, then proceeded to reprogram but it still only has 6kro. Any ideas? Thanks!

Also, is there any wake-over-usb function?
Title: Re: TMK keyboard firmware
Post by: alaricljs on Sat, 27 July 2013, 14:13:34
Far as I remember there is a command combo to enable NKRO that needs to be pressed.  It is not the default behavior of the keyboard.
Title: Re: TMK keyboard firmware
Post by: Soarer on Sat, 27 July 2013, 14:39:40
IIRC, NKRO is only impemented for the PJRC USB code, not for LUFA (it could be done with LUFA, but I don't think it's been written yet).
Title: Re: TMK keyboard firmware
Post by: oTurtlez on Sat, 27 July 2013, 14:51:42
IIRC, NKRO is only impemented for the PJRC USB code, not for LUFA (it could be done with LUFA, but I don't think it's been written yet).

I'm using the PJRC Makefile for the Teensy, so it theoretically should work.

And I did see somewhere there was a "Magic Command" for the letter "n" which enabled NKRO, but I couldn't find anything else on Magic Commands
Title: Re: TMK keyboard firmware
Post by: hasu on Sat, 27 July 2013, 21:13:03
Thanks guys, you are right.

To get NKRO feature available you need to compile with PJRC stack and press Magic command 'n'.(LShift + RShift +n)

oTurtlez, you're totally on the right way. But some system seems to cache your device configuration, your new configuration won't work until clearing old cache. At least Windows does chache.

If you are on those OSs try another physical USB port or remove driver completey in Device Manager.

BTW, I was struggling with NKRO on LUFA this weekend and it kind of works now after long stuck. It will be possible to make the code public shortly.
Title: Re: TMK keyboard firmware
Post by: hasu on Sun, 28 July 2013, 11:00:52
NKRO on LUFA was implemented at this commit: https://github.com/tmk/tmk_keyboard/commit/893ff0a799d7d42452cd8d09934380e90d8d3935
Title: Re: TMK keyboard firmware
Post by: bueller on Fri, 02 August 2013, 08:03:26
Would any kind soul out there check my config.h (http://pastebin.com/ESPNyZ8K) and keymap.c (http://pastebin.com/XWYU7PBh) files to make sure I haven't screwed anything up? Used the latest versions from the GH60 folder and stripped out the stuff I don't need, I only ever code in Java so hopefully I haven't stuffed it.
Title: Re: TMK keyboard firmware
Post by: oTurtlez on Fri, 02 August 2013, 08:51:05
Would any kind soul out there check my config.h (http://pastebin.com/ESPNyZ8K) and keymap.c (http://pastebin.com/XWYU7PBh) files to make sure I haven't screwed anything up? Used the latest versions from the GH60 folder and stripped out the stuff I don't need, I only ever code in Java so hopefully I haven't stuffed it.

For the keymap at least, I'd make sure it's in a straight grid. See how your letters shift to the left? Make them line up. Not sure if necessary but it's been how I've been doing it and it works haha.

It also appears you have an extra TRNS in the top two rows of your function layer
Title: Re: TMK keyboard firmware
Post by: bueller on Fri, 02 August 2013, 08:59:33
Would any kind soul out there check my config.h (http://pastebin.com/ESPNyZ8K) and keymap.c (http://pastebin.com/XWYU7PBh) files to make sure I haven't screwed anything up? Used the latest versions from the GH60 folder and stripped out the stuff I don't need, I only ever code in Java so hopefully I haven't stuffed it.

For the keymap at least, I'd make sure it's in a straight grid. See how your letters shift to the left? Make them line up. Not sure if necessary but it's been how I've been doing it and it works haha.

It also appears you have an extra TRNS in the top two rows of your function layer

Cool I'll modify the keymap, wasn't sure if I was supposed to be following the logical layout of the columns based on my wiring or not.

The extra TRNS is because I actually have a 15 column setup for a 65% board.
Title: Re: TMK keyboard firmware
Post by: bueller on Fri, 02 August 2013, 09:08:14
Oh wait, did you mean the extra spaces between the spacebar and mods etc? That shouldn't pose a problem, whitespaces are ignored by the compiler.
Title: Re: TMK keyboard firmware
Post by: oTurtlez on Fri, 02 August 2013, 09:15:42
Oh wait, did you mean the extra spaces between the spacebar and mods etc? That shouldn't pose a problem, whitespaces are ignored by the compiler.

Nah, I was talking about the TRNS between F2 and F3, and then the extra TRNS on the row beneath that. I've only used this for a phantom layout which is a bit easier to follow as it's more standard haha.
Title: Re: TMK keyboard firmware
Post by: bueller on Fri, 02 August 2013, 09:25:15
Ah cool, I totally missed that! Keymap.c (http://pastebin.com/XWYU7PBh) has been modified again to reflect the changes, also spaced it out a bit more clearly to illustrate the layout.
Title: Re: TMK keyboard firmware
Post by: oTurtlez on Fri, 02 August 2013, 09:51:18
Ah cool, I totally missed that! Keymap.c (http://pastebin.com/XWYU7PBh) has been modified again to reflect the changes, also spaced it out a bit more clearly to illustrate the layout.

(http://i.imgur.com/H6fvq.png)

This is a layout of a GH60, it appears that you can only have 14 keys in the top row and you have 15? How did you plan on doing that 65% design?
Title: Re: TMK keyboard firmware
Post by: Tranquilite on Fri, 02 August 2013, 10:03:19
Wouldn't be surprised if top row supported split backspace.
Title: Re: TMK keyboard firmware
Post by: oTurtlez on Fri, 02 August 2013, 10:03:57
Wouldn't be surprised if top row supported split backspace.

As of the GH60 thread final prototype PCB pics, it doesn't.
Title: Re: TMK keyboard firmware
Post by: alaricljs on Fri, 02 August 2013, 10:06:49
OP in that thread hasn't been updated, JD is busy... split BS is there in rev B(final):  http://geekhack.org/index.php?topic=34959.msg954327#msg954327 (http://geekhack.org/index.php?topic=34959.msg954327#msg954327)

Title: Re: TMK keyboard firmware
Post by: bueller on Fri, 02 August 2013, 10:08:10
I'm not actually building a GH60, this is for a custom build that I'm working on. Isn't it just a matter of setting the number of rows and columns in the config.h file?
Title: Re: TMK keyboard firmware
Post by: Tranquilite on Fri, 02 August 2013, 10:08:42
Yeah I just verified that split backspace is supported in final prototype as well.

In the time it took me to go check the latest final prototype images, there have been two posts. This thread is rather active.
Title: Re: TMK keyboard firmware
Post by: oTurtlez on Fri, 02 August 2013, 10:09:47
OP in that thread hasn't been updated, JD is busy... split BS is there in rev B(final):  http://geekhack.org/index.php?topic=34959.msg954327#msg954327

Ahh. Well, other than the top row, a 15 column design like he proposed is still not possible. If you'd like to stick to an ANSI layout, I whipped this up for ya. http://pastebin.com/kg7mx9QE

I'm not actually building a GH60, this is for a custom build that I'm working on. Isn't it just a matter of setting the number of rows and columns in the config.h file?

OHHHHH. *facepalm* Sorry man, I saw you used the GH60 file and thought you were building a GH60.
Title: Re: TMK keyboard firmware
Post by: alaricljs on Fri, 02 August 2013, 10:10:47
There's a whole lot more to getting a new design up and running than fiddling with the keymap..  Either you duplicate an existing matrix or you have to get the matrix details into matrix.c (which handles which pins are connected to which rows/columns) and also keymap.c:#define KEYMAP which maps the keymap into the matrix.

ed: and yes, as you noted there's a tiny bit about the matrix in config.h as well.
Title: Re: TMK keyboard firmware
Post by: bueller on Fri, 02 August 2013, 10:12:37
There's a whole lot more to getting a new design up and running than fiddling with the keymap..  Either you duplicate an existing matrix or you have to get the matrix details into matrix.c (which handles which pins are connected to which rows/columns) and also keymap.c:#define KEYMAP which maps the keymap into the matrix.

Yeah that's not a problem, haven't bothered with the matrix changes yet as I'm wiring everything up tomorrow. Just want to get as much of a headstart as possible so that when it's wired up I can just plug and play.

EDIT: Here's a potato shot to show you what I'm working with.

(http://imgur.com/5kVBuB0.jpg)
Title: Re: TMK keyboard firmware
Post by: domoaligato on Fri, 02 August 2013, 10:42:52
looks great!
Title: Re: TMK keyboard firmware
Post by: bueller on Fri, 02 August 2013, 10:55:14
Getting there, here's hoping my atrocious soldering skills don't hold me back tomorrow. I did upgrade do a decent soldering iron recently so hopefully that should make life easier.

OHHHHH. *facepalm* Sorry man, I saw you used the GH60 file and thought you were building a GH60.

No problem man, appreciate your help!
Title: Re: TMK keyboard firmware
Post by: domoaligato on Fri, 02 August 2013, 12:46:01
are you doing the lowpoly hardwiring method?
If so....
even though you can just solder the diode wires together for the rows. it is a lot easier and cleaner if you wrap the diodes around a piece of solid core wire like displayed in this wiki page...
http://wiki.geekhack.org/index.php?title=Hard-Wiring_How-To

It is of course all personal preference. I just found it easier for me.
Title: Re: TMK keyboard firmware
Post by: bueller on Fri, 02 August 2013, 12:53:29
are you doing the lowpoly hardwiring method?
If so....
even though you can just solder the diode wires together for the rows. it is a lot easier and cleaner if you wrap the diodes around a piece of solid core wire like displayed in this wiki page...
http://wiki.geekhack.org/index.php?title=Hard-Wiring_How-To

It is of course all personal preference. I just found it easier for me.

Yup, lowpoly all the way! That's a decent idea with the diodes, I'm buying some bare tinned wire tomorrow so I might just do that.
Title: Re: TMK keyboard firmware
Post by: domoaligato on Fri, 02 August 2013, 13:14:05
I did it with alps switches not to long ago and it was a lot of fun.
I am sure you will get quickly realize why pcb's are preferred over hardwiring.
It is a lot of soldering :'(
Title: Re: TMK keyboard firmware
Post by: Charger on Fri, 02 August 2013, 13:27:28
I did it with alps switches not to long ago and it was a lot of fun.
I am sure you will get quickly realize why pcb's are preferred over hardwiring.
It is a lot of soldering :'(
ummmmm i would say same amount of soldering as with a pcb as without you still need to solder the switches, diodes, controller unless it is built into the pcb. it is how ever more work then just dropping in parts and soldering like it would be on a pcb
Title: Re: TMK keyboard firmware
Post by: domoaligato on Fri, 02 August 2013, 13:32:26
with hard wiring I had to use helping hands a lot. it added quite a bit to the total time required.
Title: Re: TMK keyboard firmware
Post by: Charger on Fri, 02 August 2013, 13:39:04
with hard wiring I had to use helping hands a lot. it added quite a bit to the total time required.
I was able to so it without helping hands in my build only thing that really slowed me down was stripping wire so it would only be exposed at the solder joint (more of an aesthetic choice then anything) that took a long time. I do think its far more time consuming in general then with a pcb unless you have to design the pcb have it made or made it yourself and then solder it all together that would still take more time then just hard wiring i think.
Title: Re: TMK keyboard firmware
Post by: agor on Thu, 08 August 2013, 13:16:52
Is it somehow possible to ignore the OS' language settings?
I want German ISO as default and a toggled layer with British ISO
Any ideas?
Title: Re: TMK keyboard firmware
Post by: alaricljs on Thu, 08 August 2013, 13:30:33
Mostly no.  You can probably programatically force it but no one has written a firmware that makes it easy.  For instance:  shift+comma and shift+period produce difference results for German QWERTZ vs British QWERTY, however the keyboard is not sending different data.  The OS language setting is what determines the output of those key combos.
Title: Re: TMK keyboard firmware
Post by: agor on Thu, 08 August 2013, 14:52:56
Thats what I thought :(
Title: Re: TMK keyboard firmware
Post by: TD22057 on Thu, 08 August 2013, 15:09:18
Is it somehow possible to ignore the OS' language settings?
I want German ISO as default and a toggled layer with British ISO
Any ideas?

I think you need a combination keyboard/OS solution:    Have the toggle key send a key you're not using (one of the media keys or maybe pause or scroll lock), then run a macro app in your OS that toggles the language when that key is sent. 
Title: Re: TMK keyboard firmware
Post by: bueller on Thu, 15 August 2013, 05:34:42
Would anyone mind taking a look at my keymap.c (http://pastebin.com/XWYU7PBh) file and to see why I'm getting the error below? I've modified the GH60 code to allow an extra column for my 65% design but I've obviously made a mess of it.

Code: [Select]
keymap.c:79:89: error: macro "KEYMAP_ANSI" requires 66 arguments, but only 62 given
keymap.c:74: error: 'KEYMAP_ANSI' undeclared here (not in a function)

Other files
config.h (http://pastebin.com/ESPNyZ8K)
matrix.c (http://pastebin.com/p5zQQDvh)
makefile.lufa (http://pastebin.com/XDkSzfYW)
Title: Re: TMK keyboard firmware
Post by: bueller on Thu, 15 August 2013, 10:09:40
Ughhhh, I give up for the night. 3 hours playing around with this thing, restarted twice from scratch and every time I get more errors than my original post. Is there a base code simpler than the GH60 that I should be working off? I only need one default layer with a secondary layer for functions but I can't seem to get this working because the GH60 code is confusing the hell out of me.

EDIT: Here's my wiring diagram if it helps any.

(http://i.imgur.com/fDkf2Bj.png)
Title: Re: TMK keyboard firmware
Post by: alaricljs on Thu, 15 August 2013, 10:38:00
Lines 74-78 you are missing a trailing comma on the last key definition.

Code: [Select]
           ESC, 1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   MINS,EQL, BSPC, PSCR      \
           TAB,  Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,   LBRC,RBRC,BSLS, DEL      \
           LCTL,  A,   S,   D,   F,   G,   H,   J,   K,   L,   SCLN,  QUOT,   ENT,  6       \
           LSFT,   Z,   X,   C,   V,   B,   N,   M, COMM, DOT, SLSH,    RSFT,  UP,  APP     \
           LWIN,LALT,            SPC,                       CAPS,  FN0, LEFT, DOWN, RGHT),
should be:
Code: [Select]
           ESC, 1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   MINS,EQL, BSPC, PSCR,      \
           TAB,  Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,   LBRC,RBRC,BSLS, DEL,      \
           LCTL,  A,   S,   D,   F,   G,   H,   J,   K,   L,   SCLN,  QUOT,   ENT,  6,       \
           LSFT,   Z,   X,   C,   V,   B,   N,   M, COMM, DOT, SLSH,    RSFT,  UP,  APP,     \
           LWIN,LALT,            SPC,                       CAPS,  FN0, LEFT, DOWN, RGHT),
Title: Re: TMK keyboard firmware
Post by: oTurtlez on Thu, 15 August 2013, 10:43:23
Lines 74-78 you are missing a trailing comma on the last key definition.

Code: [Select]
           ESC, 1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   MINS,EQL, BSPC, PSCR      \
           TAB,  Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,   LBRC,RBRC,BSLS, DEL      \
           LCTL,  A,   S,   D,   F,   G,   H,   J,   K,   L,   SCLN,  QUOT,   ENT,  6       \
           LSFT,   Z,   X,   C,   V,   B,   N,   M, COMM, DOT, SLSH,    RSFT,  UP,  APP     \
           LWIN,LALT,            SPC,                       CAPS,  FN0, LEFT, DOWN, RGHT),
should be:
Code: [Select]
           ESC, 1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   MINS,EQL, BSPC, PSCR,      \
           TAB,  Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,   LBRC,RBRC,BSLS, DEL,      \
           LCTL,  A,   S,   D,   F,   G,   H,   J,   K,   L,   SCLN,  QUOT,   ENT,  6,       \
           LSFT,   Z,   X,   C,   V,   B,   N,   M, COMM, DOT, SLSH,    RSFT,  UP,  APP,     \
           LWIN,LALT,            SPC,                       CAPS,  FN0, LEFT, DOWN, RGHT),

That would account for the four missing switches! Good eye! Can't believe I missed that :))
Title: Re: TMK keyboard firmware
Post by: bueller on Thu, 15 August 2013, 10:46:12
Cheers guys, we have lift off! I've actually had another error as well regarding the windows key, I had it mapped as LWIN but I'm guessing it should be LGUI instead. Got it compiled anyway so fingers crossed it works after I upload it :)
Title: Re: TMK keyboard firmware
Post by: alaricljs on Thu, 15 August 2013, 10:54:20
Ya, that's LGUI.  Windows is trademarked and such ;)
Title: Re: TMK keyboard firmware
Post by: bueller on Thu, 15 August 2013, 11:08:42
Well it works, kind of. Seems like I'm getting some weird shorts all over the place :(

Biggest problem at the moment seems to be that when I hit any letter in bottom alpha row I get characters displayed from all rows in that column. So B produces %TGB etc. Should I just desolder the whole row and start again?

EDIT: More problems than I first thought, looks like my shift is always on and for some reason my left shift is acting as a TAB key.
Title: Re: TMK keyboard firmware
Post by: hasu on Thu, 15 August 2013, 11:45:48
Is there a base code simpler than the GH60 that I should be working off?

1x1 matrix keyboard :) This may help.
https://github.com/tmk/tmk_keyboard/tree/onekey/keyboard/onekey
Title: Re: TMK keyboard firmware
Post by: bueller on Thu, 15 August 2013, 11:48:06
Is there a base code simpler than the GH60 that I should be working off?

1x1 matrix keyboard :) This may help.
https://github.com/tmk/tmk_keyboard/tree/onekey/keyboard/onekey

All good mate, I've got it going now  ;D

Just played around with the wiring on my micro-controller and it appears to just be a dodgy solder joint so hopefully I should get this fixed tomorrow!
Title: Re: TMK keyboard firmware
Post by: oTurtlez on Thu, 15 August 2013, 12:59:17
Any thoughts of supporting Ergo-Dox's?
Title: Re: TMK keyboard firmware
Post by: TD22057 on Thu, 15 August 2013, 13:26:49
Any thoughts of supporting Ergo-Dox's?

I started add I2C support but it was really slow (on my keyboard, it dropped the matrix scan from 1700 Hz to below 100 Hz).  I think I'm doing something wrong as Ben's ergodox firmware does better than that but I can't figure out what it is.  I decided to just direct wire the two halves together (using 2 ultra thin 30ga cat 5 cables) so I'm not working on the I2C anymore.  I'd be happy to let someone else take over my code if they want to try to make it work.  I started from Ben's code and mixed in some of the lufa/twi code (in hasu's drivers directory) with my own take on the UI. 

Title: Re: TMK keyboard firmware
Post by: StrikeEagleCC on Tue, 03 September 2013, 07:58:09
Has anyone implemented this firmware for a 104/105 key board? I'm trying to understand how to utilize the num lock, but I've been unable to find any examples. I know I can just define a separate layer or two and use a fn key to switch to it, but isn't this different from the traditional (OEM) implementation, since the OS is normally aware of the num lock status as it is with caps or scroll lock? Is there a way to do it that can be set by the BIOS/UEFI e.g., "Num-Lock status on POST"? I'll save configuring the LEDs for later.
Title: Re: TMK keyboard firmware
Post by: domoaligato on Tue, 03 September 2013, 08:08:41
From keycode.h
 #define KC_NLCK KC_NUMLOCK

Sorry on phone tapatalk...
Title: Re: TMK keyboard firmware
Post by: jdcarpe on Tue, 03 September 2013, 08:27:19
As domo said, you simply define your keymap.c to include the NLCK key in its normal position in the keymap. If the BIOS sets NUMLOCK to ON on POST, it should work the same with any keyboard firmware, including the TMK firmware.
Title: Re: TMK keyboard firmware
Post by: StrikeEagleCC on Tue, 03 September 2013, 08:34:07
Thanks Domo. That's not exactly what I'm looking for though. Let's say that my default keypad layer looks like this in keymap.c:

NLCK,PSLS,PAST,PMNS,
  P7,  P8,  P9,
  P4,  P5,  P6,PPLS,
  P1,  P2,  P3,
  P0     ,PDOT,PENT,


If num lock is off, and I use these keys, will the OS/firmware automatically use them for home/end, pgup/pgdn, del/ins without having to define a separate layer? Is that what the keypad specific keycodes are for?
Title: Re: TMK keyboard firmware
Post by: jdcarpe on Tue, 03 September 2013, 08:44:47
Thanks Domo. That's not exactly what I'm looking for though. Let's say that my default keypad layer looks like this in keymap.c:

NLCK,PSLS,PAST,PMNS,
  P7,  P8,  P9,
  P4,  P5,  P6,PPLS,
  P1,  P2,  P3,
  P0     ,PDOT,PENT,


If num lock is off, and I use these keys, will the OS/firmware automatically use them for home/end, pgup/pgdn, del/ins without having to define a separate layer? Is that what the keypad specific keycodes are for?

Yes, that is correct. They will behave as normal for numpad keys.
Title: Re: TMK keyboard firmware
Post by: StrikeEagleCC on Tue, 03 September 2013, 08:50:58
Great. Thank you!
Title: Re: TMK keyboard firmware
Post by: StrikeEagleCC on Wed, 04 September 2013, 09:46:22
Thanks for all the help so far. I have a couple more questions though. What is the MATRIX_HAS_GHOST function (not sure if that's the right term)? I see it in the config.h and the matrix.c files for the different keyboard projects, so I looked it up in keyboard.c in the common directory. Some keyboard projects have this commented out in config.h, some don't. What does it do and how do I know if I need it?
Code: [Select]
#ifdef MATRIX_HAS_GHOST
static bool has_ghost_in_row(uint8_t row)
{
    matrix_row_t matrix_row = matrix_get_row(row);
    // No ghost exists when less than 2 keys are down on the row
    if (((matrix_row - 1) & matrix_row) == 0)
        return false;

    // Ghost occurs when the row shares column line with other row
    for (uint8_t i=0; i < MATRIX_ROWS; i++) {
        if (i != row && (matrix_get_row(i) & matrix_row))
            return true;
    }
    return false;
}
#endif

My second question is about the available pins on the Teensy++ 2.0. Are there any other pins beside PE2 (ALE) that I shouldn't use for my matrix or LEDs? I know PD6 is connected to the onboard LED, which precludes it's use unless I want the light flashing.
Title: Re: TMK keyboard firmware
Post by: hasu on Wed, 04 September 2013, 12:30:23
Thanks for all the help so far. I have a couple more questions though. What is the MATRIX_HAS_GHOST function (not sure if that's the right term)? I see it in the config.h and the matrix.c files for the different keyboard projects, so I looked it up in keyboard.c in the common directory. Some keyboard projects have this commented out in config.h, some don't. What does it do and how do I know if I need it?
It checks ghost and blocks its phantom keys on the matrix. You don't need this option if your matrix is 'what we call' NKRO with full of diodes. Some of cheap mechanical boards and most of mebrane boards are not NKRO and they need this option.

Quote
My second question is about the available pins on the Teensy++ 2.0. Are there any other pins beside PE2 (ALE) that I shouldn't use for my matrix or LEDs? I know PD6 is connected to the onboard LED, which precludes it's use unless I want the light flashing.
I think you are right. All other pins can be used except for those two.
Title: Re: TMK keyboard firmware
Post by: StrikeEagleCC on Sat, 07 September 2013, 04:58:05
Well, I have the keyboard working now, and I've only come across one issue I haven't been able to figure out: If the keyboard is plugged in when the computer is restarted (or shut down and powered up), windows ignores the input. I can use hid_listen and watch all the debug info, so I know the keyboard is working, windows just seems to be ignoring it. I can also duplicate this behavior on my laptop. Both computers are running Windows 7 x64. Unplugging the keyboard and plugging it back in restores it's full functionality. This problem does not happen if I boot with Ubuntu.

Has this happened to anyone else? Where should I begin looking for a solution to this?
Title: Re: TMK keyboard firmware
Post by: hasu on Sun, 08 September 2013, 00:08:59
To be hoest, I didn't test my firmware under boot/reboot, BIOS or boot selector like ntldr, grub and etc, and my code is not completely conformed to USB/HID spec, this may cause this problem on Windows. So I'm sure problems like this can remain to exist in my code.

In this moment I don't have no computers to reboot and test handily, I'll try to confirm this later.
Debuging during boot time is cumbersome :(
Title: Re: TMK keyboard firmware
Post by: StrikeEagleCC on Sun, 08 September 2013, 00:32:26
I have 3 computers to play with, and a range of windows versions to choose from, so let me know if I can be of any help. I can confirm that the keyboard works fine on POST and in the BIOS/UEFI of all three, it just seems to be a problem with windows. I can even access the OS boot options via F8 (e.g. "Safe Mode"), but once windows has loaded, it ignores the input until the keyboard is rebooted.

Though my coding/debugging skills are EXTREMELY elementary, I'd be happy to help in any way I can.

EDIT: Rebuilding with the LUFA stack instead of PJRC has eliminated this problem.
Title: Re: TMK keyboard firmware
Post by: domoaligato on Sun, 08 September 2013, 11:33:08
I have 3 computers to play with, and a range of windows versions to choose from, so let me know if I can be of any help. I can confirm that the keyboard works fine on POST and in the BIOS/UEFI of all three, it just seems to be a problem with windows. I can even access the OS boot options via F8 (e.g. "Safe Mode"), but once windows has loaded, it ignores the input until the keyboard is rebooted.

Though my coding/debugging skills are EXTREMELY elementary, I'd be happy to help in any way I can.

EDIT: Rebuilding with the LUFA stack instead of PJRC has eliminated this problem.



I am glad to hear that you got it fixed.
Title: Re: TMK keyboard firmware
Post by: StrikeEagleCC on Sun, 08 September 2013, 11:46:17
How can I make an LED light when a specific layer is active?
Title: Re: TMK keyboard firmware
Post by: agor on Mon, 09 September 2013, 05:03:06
Is it possible to use all 4 LED's on a Phantom for different purposes? I currently only use the in-key-LED's for ScrLk and CapsLock, but the two additional LED slots could also be used for my Function Layers.
Title: Re: TMK keyboard firmware
Post by: hasu on Mon, 09 September 2013, 07:03:02
TMK itself doesn't support any keyboard specific LEDs except for statndard indicators defined in HID spec such like Caps lock Scroll lock and Num lock.

It is possible if you write code for those LEDs yourself.
Title: Re: TMK keyboard firmware
Post by: StrikeEagleCC on Mon, 09 September 2013, 07:24:00
If anyone has done this and is willing to share, I'd be very interested in seeing it.

Does there exist a function that will return the number of the active layer? If such a function existed, let's call it get_layer(), couldn't I just add in led.c something like this to turn on an LED on PB0 when layer 1 is active?
Code: [Select]
if (get_layer()==1)
    {
        // Output high.
        DDRB |= (1<<0);
        PORTB |= (1<<0);
    }
    else
    {
        // Output low.
        DDRB &= ~(1<<0);
        PORTB &= ~(1<<0);
    }

Could pgm_read_byte() be used for this purpose?
Title: Re: TMK keyboard firmware
Post by: hasu on Mon, 09 September 2013, 07:57:12
Thanks StrikeEagleCC,

I filed this problem on github issue tracker for the sake of other users and myself.

EDIT: Rebuilding with the LUFA stack instead of PJRC has eliminated this problem.
Title: Re: TMK keyboard firmware
Post by: hasu on Mon, 09 September 2013, 08:18:22
Does there exist a function that will return the number of the active layer? If such a function existed, let's call it get_layer(), couldn't I just add in led.c something like this to turn on an LED on PB0 when layer 1 is active?
You can get current state of keymap layers from 'default_layer_state' and 'layer_state' in action_layer.h.

The problem is how and where you should update those layer LEDs. At this time I cannot come up with suitable hassle-free solution for this. I think you need to change codes of common/ directory.

led_set() in led.c is called only when CapsLock, NumLock or ScrollLock state of OS change. It is not useful  for this purpose.
Title: Re: TMK keyboard firmware
Post by: Tranquilite on Fri, 13 September 2013, 16:20:25
When I added LED layer indication to my Phantom, I used the following code snippet:
Code: [Select]
void led_set(uint8_t usb_led)
{
    if (biton32(layer_state) == 2)
    {
        // Output high.
        DDRB |= (1<<6);
        PORTB |= (1<<6);
    }
    else
    {
        // Output low.
        DDRB &= ~(1<<6);
        PORTB &= ~(1<<6);
    }

    if (biton32(layer_state) == 1)
    {
        // Output high.
        DDRB &= ~(1<<7);
        PORTB |= (1<<7);
    }
    else
    {
        // Output low.
        DDRB &= ~(1<<7);
        PORTB &= ~(1<<7);
    }
}

You will also want to include action_layer.h as well. Also what Hasu said about when/where to call led_set being a problem is definitely true. I think I just hacked up a messy solution where keyboard_task would always call keybaord_set_leds. It works well enough for me, but it is hardly an elegant solution.
Title: Re: TMK keyboard firmware
Post by: Sifo on Sat, 21 September 2013, 12:54:07
For the HID_Liberation Device when I try to make I get this about half way through:

(http://i.imgur.com/NpLyiQ2.png)

Was working fine before..

Now I'm getting Error 1's and my mkdir keeps crashing. etc.
Title: Re: TMK keyboard firmware
Post by: hasu on Sat, 21 September 2013, 18:04:57
Umm, I'm not sure but your toolchain appears to suck. Need to reinstall?
I could compile hid_liber with WINAVR toolchain.
Title: Re: TMK keyboard firmware
Post by: Sifo on Sat, 21 September 2013, 18:09:06
Tried reinstalling 5 times ... I don't know exactly what's wrong lol

I was able to compile my hid_liber before as well on this same machine, I don't know what caused the change.
Title: Re: TMK keyboard firmware
Post by: hasu on Sat, 21 September 2013, 18:16:15
What is your PATH setting?
Do you have other toolchain like Atmel Toolchain, AVR Studio or Atmel Studio?
Those tools probably can cause this error.

Title: Re: TMK keyboard firmware
Post by: Sifo on Sun, 22 September 2013, 17:17:40
I don't know whta happened but it seems to have fixed itself for some boards (GH60 works) but phantom/HID_Liber doesn't..... weird.
Title: Re: TMK keyboard firmware
Post by: oaklandishh on Wed, 09 October 2013, 01:21:13
I posted this in another thread and was directed here. I am mostly looking for examples, and possibly a list of all the names of keys or things a key can do?
Quote
Is there any guide or help file on how to program macros? I have everything working except I am unsure on how to make macros work. I saw somewhere in this thread someone used MACRO(MD(KEY),D(KEY2),END)  does this work? is there a way to have it type something without making each key a D(KEY)? Thanks
Modify message
Title: Re: TMK keyboard firmware
Post by: hasu on Wed, 09 October 2013, 03:36:36
You can use T(KEY) instead of D(KEY) and UP(KEY).
https://github.com/tmk/tmk_keyboard/blob/master/doc/keymap.md#23-macro-action

Note that all of Macro is on preliminary phase and not designed well at this moment, I have to rewrite it some time.
Title: Re: TMK keyboard firmware
Post by: oaklandishh on Wed, 09 October 2013, 10:12:55
Thanks! so I guess typing something long will be bulky to write at this point. I also found https://github.com/tmk/tmk_keyboard/blob/master/doc/keycode.txt which I was looking for!
Title: Re: TMK keyboard firmware
Post by: Al3xG on Thu, 10 October 2013, 09:44:47
There is any chance to support the new Kitten Paw controller for Filco 104 keys from bpiphany?

http://deskthority.net/wiki/Kitten_Paw

I've one and I can help with testing  ;)
Title: Re: TMK keyboard firmware
Post by: sean4star on Fri, 18 October 2013, 10:09:30
Code: [Select]
[0] = ACTION_LAYER_TAP_KEY(2, KC_SCLN)
So, with this code the Fn0 key registers the ( ; ) key if tapped and momentarily switches to layer 2 if held.  I have 2 questions:

1. If you are pressing the shift key and then tap Fn0, will it register ( : )?

2. Could this be made to work the opposite way?  For example, if you had something like:
Code: [Select]
[0] = ACTION_LAYER_TAP_KEY(KC_LCTL, 2) If you tap Fn0 it will toggle layer 2 on, another tap will toggle layer 2 off.  But holding the key would register as holding the left Ctrl key.  I think this would be useful since I rarely just tap Ctrl.  I usually hold it while I press C or V or whatever.  I guess it also depends on how long a press has to be to not be a tap...


I'm a complete newbie to code and programming.  But I'm very interested in building my own custom keyboard.  This firmware is awesome!  Thanks for reading.


Edit:  Reading more of the keymap.md...Looks like I could get the action I want from #2 above by using the ACTION_MODS_TAP_KEY?

Code: [Select]
[0] = ACTION_MOD_TAP_KEY(KC_LCTL, KC_FN1)
[1] = ACTION_LAYER_TOGGLE(2)

Does this look right?  Of course this takes up 2 Fn keys, but with 32 available I should be just fine.
Title: Re: TMK keyboard firmware
Post by: hasu on Fri, 18 October 2013, 15:01:17
There is any chance to support the new Kitten Paw controller for Filco 104 keys from bpiphany?

http://deskthority.net/wiki/Kitten_Paw

I've one and I can help with testing  ;)
Bpiphany did nice work again!
I don't any Filco and won't get his controller but I can help someone to port ;)
Title: Re: TMK keyboard firmware
Post by: hasu on Fri, 18 October 2013, 15:16:01
1. Yes
2. Not supported. But it is possible technically.
You will be able to define that action in 'action_function'(common/action.h).

Code: [Select]
[0] = ACTION_LAYER_TAP_KEY(2, KC_SCLN)
So, with this code the Fn0 key registers the ( ; ) key if tapped and momentarily switches to layer 2 if held.  I have 2 questions:

1. If you are pressing the shift key and then tap Fn0, will it register ( : )?

2. Could this be made to work the opposite way?  For example, if you had something like:
Code: [Select]
[0] = ACTION_LAYER_TAP_KEY(KC_LCTL, 2) If you tap Fn0 it will toggle layer 2 on, another tap will toggle layer 2 off.  But holding the key would register as holding the left Ctrl key.  I think this would be useful since I rarely just tap Ctrl.  I usually hold it while I press C or V or whatever.  I guess it also depends on how long a press has to be to not be a tap...


I'm a complete newbie to code and programming.  But I'm very interested in building my own custom keyboard.  This firmware is awesome!  Thanks for reading.


Edit:  Reading more of the keymap.md...Looks like I could get the action I want from #2 above by using the ACTION_MODS_TAP_KEY?

Code: [Select]
[0] = ACTION_MOD_TAP_KEY(KC_LCTL, KC_FN1)
[1] = ACTION_LAYER_TOGGLE(2)

Does this look right?  Of course this takes up 2 Fn keys, but with 32 available I should be just fine.

This won't work. ACTION_MOD_TAP_KEY doen't accept KC_FN*, only normal keycodes are required.
Title: Re: TMK keyboard firmware
Post by: sean4star on Mon, 21 October 2013, 14:20:35
This won't work. ACTION_MOD_TAP_KEY doen't accept KC_FN*, only normal keycodes are required.

I'm assuming this is true for the other ACTION_* commands as well?  No Fn keys?  Do normal keycodes include modifiers, mousekeys, system/media keys?  Or just the normal keys as documented in the keymap.md file section 1.1?


Also, I would like to use the Teensy++ 2.0, or maybe the smaller Teensy 2.0 depending on the final number of pins I need.  Do I have to use the PJRC stack or can I use the LUFA stack?  I don't fully understand the difference, but I did see you said you wouldn't be supporting the PJRC stack anymore.
Title: Re: TMK keyboard firmware
Post by: metalliqaz on Mon, 21 October 2013, 16:08:32
I only ever use the LUFA stack.  It supports both of those devices.
Title: Re: TMK keyboard firmware
Post by: hasu on Mon, 21 October 2013, 18:07:21
This won't work. ACTION_MOD_TAP_KEY doen't accept KC_FN*, only normal keycodes are required.

I'm assuming this is true for the other ACTION_* commands as well?  No Fn keys?  Do normal keycodes include modifiers, mousekeys, system/media keys?  Or just the normal keys as documented in the keymap.md file section 1.1?
All other keys should work except for Fn key. I'm not sure my code works that way but I'll fix if it doesn't work. Hmm, at a glance my code doesn't work for mouse keys?

Quote
Also, I would like to use the Teensy++ 2.0, or maybe the smaller Teensy 2.0 depending on the final number of pins I need.  Do I have to use the PJRC stack or can I use the LUFA stack?  I don't fully understand the difference, but I did see you said you wouldn't be supporting the PJRC stack anymore.
PJRC stack is still supproted at this time but LUFA is recommended.
As metalliqaz said, LUFA works well on all of Teensy, Teensy++ or other boards with USB AVR. In terms of TMK firmware functions both stacks has no difference, but LUFA makes firmware size a bit bigger. You can use both stacks interchangeably any time, don't bother.

All my own keyboards and converters works with LUFA now and I use PJRC only for testing purpose now.
Title: Re: TMK keyboard firmware
Post by: CarVac on Mon, 28 October 2013, 13:35:06
hasu:

Can you explain how to get into debug mode (as in outputs the matrix and keys to hid_listen)? I can't seem to figure out how the bootmagic keys are supposed to work.

This is to figure out what's going wrong in my keyboard: I've reverse-engineered the matrix of this laptop keyboard but it's getting random stuff wrong: the escape key (or what normally would be escape) is acting like something else, some keys don't seem to do anything, some keys have switched positions for no reason, the right arrow key results in a rapid rightleft (!), and mysteriously every single alphanumeric key works perfectly. The most mysterious one is the escape key: that's (1,1) in the matrix and in the keymap so it really couldn't be mixed up rows and columns without screwing up everything else in either the row or column.
Title: Re: TMK keyboard firmware
Post by: StrikeEagleCC on Mon, 28 October 2013, 17:30:35
CarVac,

Start by downloading hid_listen.exe from the PJRC site. Then, check your config.h to verify your magic key combo (mine is L-shift + R-shift). Then, run hid_listen, and press your magic key combo + "x". This should put your keyboard into matrix debug mode. hid_listen should show a matrix of zeros representing the matrix positions of your keyboard. Each time the state of a key changes, the display will update with a new representation of the matrix (an update for press, and another for release). Check the README.md in the tmk_keyboard-master root directory for more cool stuff you can do.

Make sure your magic keys are keys that are working correctly. If they are currently set to l+r shift, but those keys aren't working, rebuild your firmware with the magic keys changed to keys you know work correctly.
Title: Re: TMK keyboard firmware
Post by: hasu on Mon, 28 October 2013, 18:23:24
Exactly what StrikeEagleCC explained.
If your keyboard almost works well  bootmagic and command key combo can kick up debug mode. But you seem to need build hex with enabling debug mode.

Unfortunately there is no easy way to enable debug mode atm, though I'll work on better debug mode control later.
You need to place these lines in matrix_init() of matrix.c or anywhere proper to enable matrix debug:
Code: [Select]
#include "debug_config.h"
debug_config.enable = true; // enable debug print
debug_config.matrix = true; // enable matrix debug
debug_config.keyboard = false; // enable keyboard report debug
debug_config.mouse = false;  // enable mouse report debug
Title: Re: TMK keyboard firmware
Post by: sean4star on Fri, 01 November 2013, 15:19:35
I have my SLSH key (/ and ?) setup as a momentary layer switching Fn key - like so:

Code: [Select]
[12] = ACTION_LAYER_TAP_KEY(2, KC_SLSH),
Because of my layout it would be nicer if I could somehow do this with just the ?, so Shift+SLSH.  Is this possible?  I know there is this code:
Code: [Select]
ACTION_MODS_KEY(MOD_LSFT, KC_SLSH)
but then I am missing the layer switching...

I would like to do something like this:
Code: [Select]
[12] = ACTION_LAYER_TAP_KEY(2, MOD_LSFT | KC_SLSH),or something similar... Does it make sense what I'm trying to do?

Any suggestions?

Title: Re: TMK keyboard firmware
Post by: hasu on Sun, 03 November 2013, 01:00:45
not possible in current keymap framework.

ACTION_FUNCTION_TAP may work for you but it is not documented and finalized in design yet.
Title: Re: TMK keyboard firmware
Post by: metalliqaz on Sun, 03 November 2013, 01:25:33
Man, the stuff people come up with... two key presses to then access the Fn layer?  Crazy.
Title: Re: TMK keyboard firmware
Post by: sean4star on Sun, 03 November 2013, 09:50:26
Hmm...wells it's not a deal breaker if I can't make it work.

How does ACTION_FUNCTION_TAP work, what does it do?
Title: Re: TMK keyboard firmware
Post by: hasu on Sun, 03 November 2013, 16:11:42
with ACTION_FUNCTION_TAP you can define your own complex action in action_function() of keymap.c. see keyboard/hhkb/keymap.c for a example.
Title: Re: TMK keyboard firmware
Post by: sean4star on Tue, 05 November 2013, 11:01:45
I'm not a programmer and barely understand code, so I apologize in advance if I say or ask anything stupid here...

Right now I have this:
Code: [Select]
static const uint16_t PROGMEM fn_actions[] = {
[12] = ACTION_LAYER_TAP_KEY(2, KC_SLSH),          // layer 2 with tap / and ?
};

and call the FN12 key in my keymap macro.

If I tap the FN12 key I get /, if I tap it while holding shift I get ?, and if I hold it I momentarily activate layer 2.


Okay, now instead I want it to work like this: a tap registers a ? and a hold still momentarily switches to layer 2.  If I use ACTION_FUNCTION_TAP, does this look right for everything I need to add?


Code: [Select]
/*
 * Fn action definition
 */

//change Fn12 to:
[12] = ACTION_LAYER_MOMENTARY(2)                          // not quite sure how to call the layer in the ACTION_FUNCTION_TAP - see below

//add this:
[13] = ACTION_FUNCTION_TAP(LAYER2_QMARK),         // Function: Layer 2 with tap ?


// add everything below:
/* id for user defined functions */
enum function_id {
    LAYER2_QMARK,
};

/*
 * user defined action function
 */
void action_function(keyrecord_t *record, uint8_t id, uint8_t opt)
{
    keyevent_t event = record->event;
    tap_t tap = record->tap;

    switch (id) {
        case LAYER2_QMARK:                                       // Layer 2 + tap '?'
            if (event.pressed) {
                if (tap.count == 0 || tap.interrupted) {       // will this work with a press and hold, like for momentary layer switching?
                    host_add_key(KC_FN12);                   // Can I call a Fn key with this function?  How else would I switch the layer on?
                } else {
                    host_add_mods(MOD_BIT(KC_LSHIFT));
                    host_add_key(KC_SLSH);
                    host_send_keyboard_report();
                    host_del_mods(MOD_BIT(KC_LSHIFT));
                    host_del_key(KC_SLSH);
                    host_send_keyboard_report();
                }
            } else {
                if (tap.count == 0 || tap.interrupted) {
                    host_del_key(KC_FN12);
                }
            }
            break;
    }
}

I'm confused on how to call the layer.  I'm sure I'm doing this wrong...Also, will the tap.count work if it's not a tap, but a press and hold?  Is that what the 0 stands for...it registers the key pressed but not "tapped"???

Does  [if (tap.count == 0] mean that I could setup different actions for a different number of taps?  For example, 0 taps (press and hold) momentarily switches layers, 1 tap registers a character, and 2 taps toggles a layer?  I'm assuming it would just be a nested if statement?

Code: [Select]
if (tap.count == 0 || tap.interrupted) {
              momentary switch layer
} elseif (tap.count == 2 || tap.interrupted) {
              toggle layer
} else {
             register character

Thanks for all the great help!  I'm consistently amazed at all the functionality included in your firmware.
Title: Re: TMK keyboard firmware
Post by: harifun07 on Tue, 05 November 2013, 21:29:21
thanks for you fw. i was wondering whether you used the ack or crc function in that i found that there may happened data miss when transforming data.
Title: Re: TMK keyboard firmware
Post by: CarVac on Tue, 05 November 2013, 21:40:16
Has anyone else had the problem of the KP_MENU reporting as the Sun Props key?

I actually use the menu key because I have it software-mapped to toggle maximization on my computers and would like to duplicate that.
Title: Re: TMK keyboard firmware
Post by: StrikeEagleCC on Tue, 05 November 2013, 22:20:14
Do you mean KC_APP, the application key?
Title: Re: TMK keyboard firmware
Post by: CarVac on Tue, 05 November 2013, 22:26:49
Oops, I meant KC_MENU, not KP_MENU. It's typically between the ctrl and alt keys on the right...
Title: Re: TMK keyboard firmware
Post by: StrikeEagleCC on Tue, 05 November 2013, 23:09:54
Yup, KC_APP is the key code you need to use.
Title: Re: TMK keyboard firmware
Post by: CarVac on Tue, 05 November 2013, 23:57:34
Yup, KC_APP is the key code you need to use.

Perfect. Thanks!
Title: Re: TMK keyboard firmware
Post by: hasu on Wed, 06 November 2013, 00:21:23
sean4star, I think you are on the right track and close to your goal.

1) Use new API add_key/mods(), del_key/mods() and send_keyboard_report() instead of host_*(). See action_util.h. You may need to add this at the end of #include block.
Code: [Select]
#include "action_util.h"

2) Some special keycodes including KC_FN*(,mousekey and mediakeys) should not be used with add_key() and del_key() [at least at this time]. Instead you should use layer_on() and layer_off() to switch to new layer. You may need to add this at the end of #include block.
Code: [Select]
#include "action_layer.h"


And yes, you can use tap.count for that purpose.
tap.count=0 means normal press/release(not tap), you can also know first tap with 1, second tap with 2 and so on. tap. You also can use tap.interrupted to know whether some other key is pressed while tapping.
Title: Re: TMK keyboard firmware
Post by: hasu on Wed, 06 November 2013, 00:29:40
harifun07,
No, I don't use any CRC check on my firmware. With "data miss" you mean that your keyboard misses key stroke? Or missing charactors on debug output?

I've found charactor drops of debug message print and put aside for long time. I'll work on this issue later but not soon, it is not critical.

If you get keystroke drops describe more detail.
Title: Re: TMK keyboard firmware
Post by: harifun07 on Wed, 06 November 2013, 08:08:52
harifun07,
No, I don't use any CRC check on my firmware. With "data miss" you mean that your keyboard misses key stroke? Or missing charactors on debug output?

I've found charactor drops of debug message print and put aside for long time. I'll work on this issue later but not soon, it is not critical.

If you get keystroke drops describe more detail.
Thanks for you reply. I found that my design would lost the code 00 00 00 00 00 00 00 00 some times, then the PC could not receive the button up code.  I was wondering whether the usb lost my data but I didn't know.
Title: Re: TMK keyboard firmware
Post by: hasu on Wed, 06 November 2013, 08:27:49
hmm,
I doubt USB stack is culprit. LUFA and Atmel hardware USB engine are reliable enough.
Atmega USB engine uses CRC in low level USB packet with confroming with USB spec.

If you need more help your codes and info/pics of your keyboard may be useful to us.

EDIT: With poor USB cable I had similar problems like key stuck and missing.
Title: Re: TMK keyboard firmware
Post by: harifun07 on Wed, 06 November 2013, 08:37:56
hmm,
I doubt USB stack is culprit. LUFA and Atmel hardware USB engine are reliable enough.
Atmega USB engine uses CRC in low level USB packet with confroming with USB spec.

If you need more help your codes and info/pics of your keyboard may be useful to us.

EDIT: With poor USB cable I had similar problems like key stuck and missing.
I found that you told about low level USB packet, but I know you used usb 2.0 protocol.

I used C8051F320 in that it's much cheaper and I got some in hand.
I was wondering whether the MCU was not reliable enough for the design.
And I was not good at C++, so I used C only.  It's polite for me to trouble you too much.
Title: Re: TMK keyboard firmware
Post by: sean4star on Wed, 06 November 2013, 12:38:04
You may need to add this at the end of #include block.
Code: [Select]
#include "action_util.h"
Code: [Select]
#include "action_layer.h"

So, add these to the #include block in my keymap.c file, correct?


How about this:
Code: [Select]
/*
 * Fn action definition
 */

//change Fn12 to:
[12] = ACTION_FUNCTION_TAP(LAYER2_QMARK),             // Function: Layer 2 with tap ?


// add everything below:

/* id for user defined functions */
enum function_id {
    LAYER2_QMARK,
};

/*
 * user defined action function
 */
void action_function(keyrecord_t *record, uint8_t id, uint8_t opt)
{
    keyevent_t event = record->event;
    tap_t tap = record->tap;

    switch (id) {
        case LAYER2_QMARK:                                      // Layer 2 + tap '?'
            if (event.pressed) {
                if (tap.count == 0 || tap.interrupted) {
                    layer_on(2);
                } else {
                    add_mods(KC_LSHIFT);                        // Does this still need the MOD_BIT() coding?
                    add_key(KC_SLSH);
                    send_keyboard_report();
                    del_mods(KC_LSHIFT);                        // Does this still need the MOD_BIT() coding?
                    del_key(KC_SLSH);
                    send_keyboard_report();
                }
            } else {
                if (tap.count == 0 || tap.interrupted) {
                    layer_off(2);
                }
            }
            break;
    }
}

Then I would just use FN12 in my keymap like normal, correct?
What about the add_mods() code...Do I still need the mod_bit() or did I do this right?  I'm not really sure what the mod_bit() does...


I just got my diodes and switches in the mail.  So this idea is about to start coming of the screen and into the real world.  Hopefully I can get everything wired together (at least well enough to test) maybe by this weekend.  This will be my first time wiring a keyboard matrix...hell, my first time to wire anything freestyle...so wish me luck!
Title: Re: TMK keyboard firmware
Post by: hasu on Wed, 06 November 2013, 18:50:39
So, add these to the #include block in my keymap.c file, correct?
Right. Add them at *end* of block, or you may get minor errors during compiling.

Quote
Then I would just use FN12 in my keymap like normal, correct?
What about the add_mods() code...Do I still need the mod_bit() or did I do this right?  I'm not really sure what the mod_bit() does...
You still need to use MOD_BIT() macro in add/del_mods(). It looks OK except for that.
MOD_BIT() converts modifier keycode into modifier bit and add/del_mods() takes modifier bits not keycode.
Title: Re: TMK keyboard firmware
Post by: sean4star on Thu, 07 November 2013, 13:18:58
Does this look right for my matrix file:

Code: [Select]
/* Column pin configuration
 * col: 0   1   2   3   4   5   6   7   8   9
 * pin: E1  C0  C1  C2  C3  E6  F0  F1  F2  F3
 */
static void  init_cols(void)
{
    // Input with pull-up(DDR:0, PORT:1)
    DDRC  &= ~(1<<0 | 1<<1 | 1<<2 | 1<<3);
    PORTC |=  (1<<0 | 1<<1 | 1<<2 | 1<<3);
    DDRE  &= ~(1<<1 | 1<<6);
    PORTE |=  (1<<1 | 1<<6);
    DDRF  &= ~(1<<0 | 1<<1 | 1<<2 | 1<<3);
    PORTF |=  (1<<0 | 1<<1 | 1<<2 | 1<<3);
}

static matrix_row_t read_cols(void)
{
    return (PINE&(1<<1) ? 0 : (1<<0)) |
           (PINC&(1<<0) ? 0 : (1<<1)) |
           (PINC&(1<<1) ? 0 : (1<<2)) |
           (PINC&(1<<2) ? 0 : (1<<3)) |
           (PINC&(1<<3) ? 0 : (1<<4)) |
           (PINE&(1<<6) ? 0 : (1<<5)) |
           (PINF&(1<<0) ? 0 : (1<<6)) |
           (PINF&(1<<1) ? 0 : (1<<7)) |
           (PINF&(1<<2) ? 0 : (1<<8)) |
           (PINF&(1<<3) ? 0 : (1<<9)) ;
}

/* Row pin configuration
 * row: 0   1   2   3   4   5   6   7
 * pin: C4  C5  C6  C7  F4  F5  F6  F7
 */
static void unselect_rows(void)
{
    // Hi-Z(DDR:0, PORT:0) to unselect
    DDRC  &= ~0b11110000;
    PORTC &= ~0b11110000;
    DDRF  &= ~0b11110000;
    PORTF &= ~0b11110000;
}

static void select_row(uint8_t row)
{
    // Output low(DDR:1, PORT:0) to select
    switch (row) {
        case 0:
            DDRC  |= (1<<4);
            PORTC &= ~(1<<4);
            break;
        case 1:
            DDRC  |= (1<<5);
            PORTC &= ~(1<<5);
            break;
        case 2:
            DDRC  |= (1<<6);
            PORTC &= ~(1<<6);
            break;
        case 3:
            DDRC  |= (1<<7);
            PORTC &= ~(1<<7);
            break;
        case 4:
            DDRF  |= (1<<4);
            PORTF &= ~(1<<4);
            break;
        case 5:
            DDRF  |= (1<<5);
            PORTF &= ~(1<<5);
            break;
        case 6:
            DDRF  |= (1<<6);
            PORTF &= ~(1<<6);
            break;
        case 7:
            DDRF  |= (1<<7);
            PORTF &= ~(1<<7);
            break;
    }
}

I didn't understand the matrix file in the hhkb directory, so I used the GH60 as an example.  Should this work?  Why is the hhkb matrix file so different?  I don't see any of the columns/rows information in the hhkb version...


Also, I'm using a teensy 2++.  Just curious, why is there no E2 or E3 pin?  Are these the GND and REF pins in the middle on the right?

On the subject of LED's...I see the hhkb files use this:
Code: [Select]
void led_set(uint8_t usb_led)
{
    if (usb_led & (1<<USB_LED_CAPS_LOCK)) {
        DDRD |= (1<<6);
        PORTD |= (1<<6);
    } else {
        DDRD |= (1<<6);
        PORTD &= ~(1<<6);
    }
}

This means the led on the Teensy will light up, correct?  So no LED's on the actual hhkb, just using the built in one on the chip...


And one last thing:  I successfully compiled the firmware for my keyboard!  Only received one warning:
../../common/action_tapping.c:328: warning "waiting_buffer_has_anykey_pressed" defined but not used
Should I do anything about this?  It doesn't sound too bad...
Title: Re: TMK keyboard firmware
Post by: hasu on Thu, 07 November 2013, 16:19:35
1) your matrix.c looks ok to me.
2) HHKB has capacitive switches and unusual matrix(which uses multiplexers to select col/row lines and  sensor chip to see switch state).
3) PE2,3 have special functions, not so useful for general I/O use.
4) As for led, you are right. But I don't remember whether it works or not in my HHKB :)
5) you can safely ignore that warning, I'll fix it later.
Title: Re: TMK keyboard firmware
Post by: sean4star on Sun, 10 November 2013, 17:22:29
Just a quick update:  I wired up a 2 key testing keyboard.  So far everything works as expected.  It was pretty cool hitting a key switch (bare with no keycap) that I had just soldered up to a few wires and a diode and have letters pop up on my monitor.

4) As for led, you are right. But I don't remember whether it works or not in my HHKB :)

I can confirm that using the Teensy's built-in LED for the Caps Lock light works perfectly, at least with my hacked together 2 key test board.  So good, that I'm not going to bother wiring up an LED on my final board.


It will probably take me a while longer to get my keyboard built and working the way I want, but I will post back here when I do.  With any luck, I will have something to report/show-off in the next week or two.

Thanks for all the help!!!
Title: Re: TMK keyboard firmware
Post by: sean4star on Mon, 11 November 2013, 15:40:36
Back again so soon?

Sorry, one thing I'm trying is just not working.  I'm sure it's my lack of C experience.

The design I'm working on is using a very limited number of keys.  All of my layer switching is currently done using ACTION_LAYER_TAP_KEY.  So every layer key also doubles as a regular key.  I just don't have space on my board for a key that only works as a layer toggle.

But...I would really like a toggle key...And then I discover ACTION_FUNCTION_TAP...Cool! But, urgh...I can't get it to work!  I want the key to toggle layers only if it is tapped 3 times.  I don't want to accidentally switch to the other layer during normal typing.  If it is tapped only once or twice it will register the regular key.  I tried lots of variations on the same code.  Everything else I tried would register the regular tapped key, but would not toggle layers, no matter how fast or how many times I tapped it.  This is the only one that would actually switch layers:

Code: [Select]
        case TAP3LAY1_T:                                        // Layer 1 toggle on and tap T
                if (tap.count != 3) {
                    add_key(KC_T);
                    send_keyboard_report();
                    del_key(KC_T);
                    send_keyboard_report();
                } else {
                    layer_on(1);
                }
                break;

But a single tap registers "tt" instead of just "t".  So what is happening is I tap once and have "tt", then tap again and have "tttt", then tap a third time and the layers switch.  Why is the T registering twice for each tap?!

Once I solve that, I'm pretty sure I can just add:
Code: [Select]
                } else {
                    add_key(KC_BSPC);
                    send_keyboard_report();
                    del_key(KC_BSPC);
                    send_keyboard_report();
                    add_key(KC_BSPC);
                    send_keyboard_report();
                    del_key(KC_BSPC);
                    send_keyboard_report();
                    layer_on(1);
to get rid of the first two taps before the layers switch.  So a single tap would give you "t", then another tap "tt" then a thrid tap and both "tt" delete and the layers switch.  But first I need to fix whatever is causing it to register twice for each tap...
Title: Re: TMK keyboard firmware
Post by: hasu on Tue, 12 November 2013, 01:05:28
You should handle release event properly too. Does this work? I didn't compile and test it at all.

Code: [Select]
if (event.pressed) {
    if (tap.count < 3) {
        register_code(KC_T);
    } else {
    }
} else {
   if (tap.count < 3) {
        unregister_code(KC_T)
   } else if (tap.count == 3) {
        register_code(KC_BSPC);
        unregister_code(KC_BSPC);
        register_code(KC_BSPC);
        unregister_code(KC_BSPC);
        layer_invert(1);
   }
}

I'm not sure  this is useful actually for you, this may work on text editor but not on web browser. If you type 'ttt' to change layer then you will get two page history back.
Title: Re: TMK keyboard firmware
Post by: sean4star on Tue, 12 November 2013, 08:21:38
I'm not sure  this is useful actually for you, this may work on text editor but not on web browser. If you type 'ttt' to change layer then you will get two page history back.

Really?!  Which browser does this?  I just tried it on IE8 and Chrome but nothing happened.  Maybe I'm not using the shortcut correctly.

Thanks for the coding help.  I know it may be a silly idea.  Right now I'm just experimenting with different layouts and Fn keys to see what works.
Title: Re: TMK keyboard firmware
Post by: sean4star on Tue, 12 November 2013, 22:37:38
Just in case anyone else is following this...

I had some issues with the code as written from hasu.  It would only register 1 T then nothing until I did a quick triple tap to switch layers.  I think it may have had something to do with having the "unregister_code" nesting in another IF statement.  The following code works perfect:

Code: [Select]
        case TAP3LAY1_T:                                        // Layer 1 toggle on and tap T
            if (event.pressed) {
                if (tap.count != 3) {
                    register_code(KC_T);
                    unregister_code(KC_T);
                } else if (tap.count == 3) {
                    register_code(KC_BSPC);
                    unregister_code(KC_BSPC);
                    register_code(KC_BSPC);
                    unregister_code(KC_BSPC);
                    layer_on(1);
                }
            }
        break;

It's yet to be seen whether this feature will make it in my final board.  I still need an actual board to test my ideas on.  Right now I just have 2 keys wired up so I can test to make sure my mod of the firmware works.  Who knows if I will like using it!  I'm procrastinating on wiring up my board, mainly because I'm not sure if I really like the plate I have.  Another "for parts" vintage board is coming in the mail - should get here tomorrow - so I may start my build then.

As always, thanks for all the help!
Sean
Title: Re: TMK keyboard firmware
Post by: harifun07 on Tue, 19 November 2013, 05:51:31
Excuse me, may I ask a question what this code is used for.

Keyboard.c--void keyboard_task

for (uint8_t c = 0; c < MATRIX_COLS; c++) {
                if (matrix_change & ((matrix_row_t)1<<c)) {
                    action_exec((keyevent_t){
                        .key = (key_t){ .row = r, .col = c },
                        .pressed = (matrix_row & ((matrix_row_t)1<<c)),
                        .time = (timer_read() | 1) /* time should not be 0 */
                    });

I am wondering what is the time used for? Filtering or other use?
Title: Re: TMK keyboard firmware
Post by: hasu on Tue, 19 November 2013, 06:40:07
.time is used to know elapse of key event by Tapping. Tap key(Dual role key) needs time lapse and its behaviour depends on time factors between key events.
https://github.com/tmk/tmk_keyboard/blob/master/doc/keymap.md#4-tapping
http://geekhack.org/index.php?topic=41685.0

You can find this use of .time In common/action_tapping.c. messy code, though...
I'm not sure I could answer your question, ask me again if you need.
Title: Re: TMK keyboard firmware
Post by: sean4star on Tue, 26 November 2013, 18:34:51
I have a minor problem...

I used PEQL in my keymap. The firmware builds just fine, but my computer doesn't register anything when I press that key. Any ideas?  The key is in a secondary layer, but all the other tenkey codes (like PMNS, PCMM, P1, etc) work just fine.  Thanks for any help!
Title: Re: TMK keyboard firmware
Post by: hasu on Tue, 26 November 2013, 20:06:59
PEQL indicates = on keypad. Look PC keyboards, you will find they don't have it. So I guess your computer is  Windows and it doesn't support the key from historical reason.

Try other OS if you should use keypad =, otherwise you can just normal =.
Title: Re: TMK keyboard firmware
Post by: metalliqaz on Tue, 26 November 2013, 20:07:32
I have a minor problem...

I used PEQL in my keymap. The firmware builds just fine, but my computer doesn't register anything when I press that key. Any ideas?  The key is in a secondary layer, but all the other tenkey codes (like PMNS, PCMM, P1, etc) work just fine.  Thanks for any help!

Keypad equals is not supported in Windows according to Microsoft's Keyboard Scan Code Specification (http://msdn.microsoft.com/en-us/library/windows/hardware/gg463372.aspx#E4), unless I'm reading it wrong.  You may have to just map it to the Equals/Plus key

Edit: Darn, ninja'd by Hasu  :))
Title: Re: TMK keyboard firmware
Post by: IvanIvanovich on Sat, 07 December 2013, 20:23:49
Hi,
I wanted to try out the updated firmware on my GH60 rev. A. I still using very old one from first days... anyway I am not understanding all the changes. What do I need to do to this to make it work in current?
Code: [Select]
static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
    /*
     * GH60
     */
    /* Keymap 0: Default Layer
     */
    KEYMAP_ANSI(
        ESC, 1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   MINS,EQL, BSPC, \
        TAB, Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,   LBRC,RBRC,BSLS, \
        CAPS,A,   S,   D,   F,   G,   H,   J,   K,   L,   SCLN,QUOT,     ENT,  \
        LSFT,Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, SLSH,          RSFT, \
        LCTL,LALT,NO,          SPC,                     FN0, RGUI,APP, RCTL),
    /* Overlay 1: Fn mode
     */
    KEYMAP_ANSI(
GRV, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12, TRNS, \
TRNS,TRNS, UP,  TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PSCR,PAUS,VOLU,VOLD,MUTE, \
TRNS,LEFT,DOWN,RGHT,TRNS,TRNS,TRNS,TRNS,TRNS,INS,HOME, PGUP,      TRNS, \
TRNS,TRNS, MPRV,MPLY,MNXT,TRNS,TRNS,TRNS,DEL,END,PGDN,           TRNS, \
TRNS,TRNS,NO,          TRNS,                     FN0, TRNS,TRNS,TRNS)
};

static const uint8_t PROGMEM overlays[][MATRIX_ROWS][MATRIX_COLS] = {};

/*
 * Fn action definition
 */
static const uint16_t PROGMEM fn_actions[] = {
    [0] = ACTION_KEYMAP_MOMENTARY(1),
};
#endif



#define KEYMAPS_SIZE    (sizeof(keymaps) / sizeof(keymaps[0]))
#define OVERLAYS_SIZE   (sizeof(overlays) / sizeof(overlays[0]))
#define FN_ACTIONS_SIZE (sizeof(fn_actions) / sizeof(fn_actions[0]))

/* translates key to keycode */
uint8_t keymap_key_to_keycode(uint8_t layer, key_t key)
{
    /* Overlay: 16-31(OVERLAY_BIT(0x10) | overlay_layer) */
    if (layer & OVERLAY_BIT) {
        layer &= OVERLAY_MASK;
        if (layer < OVERLAYS_SIZE) {
            return pgm_read_byte(&overlays[(layer)][(key.row)][(key.col)]);
        } else {
            // XXX: this may cuaes bootlaoder_jump incositent fail.
            //debug("key_to_keycode: overlay "); debug_dec(layer); debug(" is invalid.\n");
            return KC_TRANSPARENT;
        }
    }
    /* Keymap: 0-15 */
    else {
        if (layer < KEYMAPS_SIZE) {
            return pgm_read_byte(&keymaps[(layer)][(key.row)][(key.col)]);
        } else {
            // XXX: this may cuaes bootlaoder_jump incositent fail.
            //debug("key_to_keycode: base "); debug_dec(layer); debug(" is invalid.\n");
            // fall back to layer 0
            return pgm_read_byte(&keymaps[0][(key.row)][(key.col)]);
        }
    }
}

/* translates Fn keycode to action */
action_t keymap_fn_to_action(uint8_t keycode)
{
    action_t action;
    if (FN_INDEX(keycode) < FN_ACTIONS_SIZE) {
        action.code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]);
    } else {
        action.code = ACTION_NO;
    }
    return action;
}
Sorry, but I know nothing about these things and just don't really get these topics.
Title: Re: TMK keyboard firmware
Post by: jorgenslee on Sat, 07 December 2013, 21:45:30
@hasu
Please forgive my newbie question, but is there a way to flash your firmware to Poker 2? IF not, are you planning to support it in the future?
Title: Re: TMK keyboard firmware
Post by: hasu on Sat, 07 December 2013, 21:52:20
Ah, it is old.

1. Copy keymap_plain.c to your own like keymap_ivan.c.
2. just replace keymap(KEYMAP_ANSI) with yours in keymap_ivan.c.
3. place ACTION_LAYER_MOMENTARY(1)  in fn_actions of keymap_ivan.c.
4. run 'make KEYMAP=ivan'

Other code except for keymaps, fn_actions is not needed in keymap_ivan.c now.
Title: Re: TMK keyboard firmware
Post by: hasu on Sat, 07 December 2013, 21:57:16
@jorgenslee
Maybe No and no.
I don't know actually what conroller Poker2 has, whether it is programmable and whether its toolchain is available free to public.
Title: Re: TMK keyboard firmware
Post by: jorgenslee on Sat, 07 December 2013, 23:43:16
@jorgenslee
Maybe No and no.
I don't know actually what conroller Poker2 has, whether it is programmable and whether its toolchain is available free to public.

Ahh I see Thanks for the quick response. I really like the idea of SpaceFN which your firmware supports. Hope it could be supported in nearly not that distant future...  ^-^
Title: Re: TMK keyboard firmware
Post by: sean4star on Tue, 10 December 2013, 11:47:23
I'm revisiting this:

Code: [Select]
        case LAYER2_QMARK:                                      // Layer 2 momentary with tap '?'
            if (event.pressed) {
                if (tap.count == 0 || tap.interrupted) {
                    layer_on(2);
                } else {
                    add_mods(MOD_BIT(KC_LSFT));
                    add_key(KC_SLSH);
                    send_keyboard_report();
                    del_mods(MOD_BIT(KC_LSFT));
                    del_key(KC_SLSH);
                    send_keyboard_report();
                }
            } else {
                if (tap.count == 0 || tap.interrupted) {
                    layer_off(2);
                }
            }
        break;

This works great.  But I'm wondering if it would be possible to add another IF statement in here to register something else if SHIFT is pressed.  For example, could I make the key register " ? " when pressed by itself and " / " when pressed with SHIFT?  So the opposite of the standard key...

Also, it doesn't have to include the layer switching.  I'm just experimenting with different layouts that don't use the standard shift keys.
Title: Re: TMK keyboard firmware
Post by: hasu on Tue, 10 December 2013, 12:32:19
You can see if SHIFT is down with inspecting 'keyboard_report' of action_util.h.

Like:
    keyobard_report->mods & (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT))

See report.h for definition of keyboard_report.


EDIT: s/&&/&/; replaced logical conditional with bit operator.
Title: Re: TMK keyboard firmware
Post by: sean4star on Tue, 10 December 2013, 15:38:07
I'm sorry...I'm really not sure what this means.  Keep in mind that I know very little programming.

In action_util.h I see this:
Code: [Select]
/* inspect */
uint8_t has_anykey(void);
uint8_t has_anymod(void);
uint8_t get_first_key(void);

This is the same file that the "add_mods", "add_key", "del_mods", etc are defined.  But I don't understand how the inspect items are used...

And I *really* don't understand the report.h file.  Looks like it defines the media and system buttons and the NKRO protocol.  Then I see this:
Code: [Select]
typedef union {
    uint8_t raw[REPORT_SIZE];
    struct {
        uint8_t mods;
        uint8_t reserved;
        uint8_t keys[REPORT_KEYS];
    };
#ifdef NKRO_ENABLE
    struct {
        uint8_t mods;
        uint8_t bits[REPORT_BITS];
    } nkro;
#endif
} __attribute__ ((packed)) report_keyboard_t;
/*
typedef struct {
    uint8_t mods;
    uint8_t reserved;
    uint8_t keys[REPORT_KEYS];
} __attribute__ ((packed)) report_keyboard_t;
*/

typedef struct {
    uint8_t buttons;
    int8_t x;
    int8_t y;
    int8_t v;
    int8_t h;
} __attribute__ ((packed)) report_mouse_t;

Which I have no clue what it does...And there is that bit in the middle commented out.

Any additional hand holding would be greatly appreciated.  Can you give me an example of how to inspect the keyboard report?
Title: Re: TMK keyboard firmware
Post by: sean4star on Tue, 10 December 2013, 15:39:50
Also, a few misc questions:

1. What are weak mod keys?
2. What are oneshot keys?
3. What are the 3-5 mouse buttons?  1 and 2 are the left and right buttons, not sure about the rest.

Thanks for all the help!
Title: Re: TMK keyboard firmware
Post by: metalliqaz on Tue, 10 December 2013, 17:14:23
Also, a few misc questions:

1. What are weak mod keys?
2. What are oneshot keys?
3. What are the 3-5 mouse buttons?  1 and 2 are the left and right buttons, not sure about the rest.

Thanks for all the help!

I think weak mods are just a concept used internally for the modmap that can be overridden by other things going on

Oneshot mods are described here (https://github.com/tmk/tmk_keyboard/blob/master/doc/keymap.md)

Windows supports mice with more than 2 buttons.  You probably already know button-3, clicking the scroll wheel on your mouse.  4 and 5 are less common but there are applications that support functions for those button events.

EDIT: mistakes
Title: Re: TMK keyboard firmware
Post by: hasu on Tue, 10 December 2013, 19:26:06
You can see current key state recognized by host with 'keyboard_report'.
'keyboard_report' is defined in action_util.c/h and you can find its structure in report.h. See this.
Code: [Select]
    struct {
        uint8_t mods;
        uint8_t reserved;
        uint8_t keys[REPORT_KEYS];
    };

keyboard_report is actually 8-byte arrary of USB keyboard report defined in its spec. (REPORT_KEYS=6) 'mods' retains modifier state, 'reserved' is unused, and 'keys' is 6-byte array which can retain 6 keys pressed at most.
Code: [Select]
0       |1       |2       |3       |4       |5       |6       |7
--------+--------+--------+--------+--------+--------+--------+--------
mods    |reserved|keys[0] |keys[1] |keys[2] |keys[3] |keys[4] |keys[5]

keyboard_report->mods is comprised of 8bits indicate modifier key each like:
Code: [Select]
0       |1       |2       |3       |4       |5       |6       |7
--------+--------+--------+--------+--------+--------+--------+--------
Lcontrol|Lshift  |Lalt    |Lgui    |Rcontrol|Rshift  |Ralt    |Rgui

So you can see if SHIFT keys are pressed down by
Code: [Select]
if ( keyboard_report->mods & (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) )



Also, a few misc questions:

1. What are weak mod keys?
2. What are oneshot keys?
3. What are the 3-5 mouse buttons?  1 and 2 are the left and right buttons, not sure about the rest.

Weak mod are used by internal action or macro which does not accompany with real user key action. Not well designed yet, ignore at the moment.

Oneshot mod: My English is always confusing but you'll get it.
https://github.com/tmk/tmk_keyboard/blob/master/doc/keymap.md#43-oneshot-modifier


Traditionally mouse has 3 buttons and button 3 is middle button. As metalliqaz said, more than that it has no common usage convetion, I think.

tmk_keyboard supports 5 buttons with its mouse report descriptor. In my Xorg environment I can use BTN1-3 as conventional left, right and middle buttons but BTN4-5 are recognized as button 8 and 9 interestingly :) Meanwhile vertical and horizontal wheel motion is interpreted as button 4-7 in Xorg :o

In windows I don't know how they are handled, but I can use both wheels and button 4,5 as expected. Button 4 and 5 do browser back and forward.
Title: Re: TMK keyboard firmware
Post by: jeffgran on Tue, 10 December 2013, 21:10:43
hasu: I have been using the "ACTION_MODS_TAP_KEY" and I like it, but I wanted to change the behavior because it's too slow for me. I would like to change the behavior so that the "hold" modifier activates even if you release the modifier key before, as long as you hold it down for long enough first (maybe 100-200ms?). Could you point me in the right direction? I am happy to hack on the code myself but I'm not that good with C so if you tell me where to look I can try it...
Title: Re: TMK keyboard firmware
Post by: hasu on Wed, 11 December 2013, 00:51:57
jeffgran,
Only one configurable parameter of tap key(dual role key) is TAPPING_TERM, which is 200ms by default and defined in common/action_tapping.h. You can change TAPPING_TERM in your config.h, my setting is 300ms in keyboard/hhkb/config.h(and my typing speed is 70wpm at most in typeracer.com), by the way.

To tweak other behaviour of tap key you need to fiddle with my dirty code. You can find tapping logic in common/action_tapping.c.



Hmm, TAPPING_TERM may mitigate your problem but it doesn't seem to be a true solution. I think you need to tweak code to change behaviour as you expect.

My dual role implementation is optimized to place additional role on normal key without explicit conscious. Meanwhile you likely want to give other role on modifier key. I think this two variants of dual role key need different optimized behaviour.

At this time tmk_keyboard is optimized for former variant only. I'll try to implement to support both of two variants later, but it'll take long.

Title: Re: TMK keyboard firmware
Post by: IvanIvanovich on Wed, 11 December 2013, 17:38:56
OK so if I understood it right I am supposed to end up with this?
Code: [Select]
const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
    /* 0: qwerty */
    KEYMAP_ANSI(
        ESC, 1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   MINS,EQL, BSPC, \
        TAB, Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,   LBRC,RBRC,BSLS, \
        CAPS,A,   S,   D,   F,   G,   H,   J,   K,   L,   SCLN,QUOT,     ENT,  \
        LSFT,Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, SLSH,          RSFT, \
        LCTL,LALT,NO,          SPC,                     FN0, RGUI,APP, RCTL),
    /* Overlay 1: Fn mode
     */
    KEYMAP_ANSI(
GRV, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12, TRNS, \
TRNS,TRNS, UP,  TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PSCR,PAUS,VOLU,VOLD,MUTE, \
TRNS,LEFT,DOWN,RGHT,TRNS,TRNS,TRNS,TRNS,TRNS,INS,HOME, PGUP,      TRNS, \
TRNS,TRNS, MPRV,MPLY,MNXT,TRNS,TRNS,TRNS,DEL,END,PGDN,           TRNS, \
TRNS,TRNS,NO,          TRNS,                     FN0, TRNS,TRNS,TRNS)
};
const uint16_t PROGMEM fn_actions[] = ACTION_LAYER_MOMENTARY(1);

It compiles OK. I had some troubles getting to flash but was able to do so after erasing first. First layer is mostly OK, but it have ~` instead ESC like I want for some reason. 2nd layer is all wrong, have those all over in places I didn't specify. I don't know what wrong.
Title: Re: TMK keyboard firmware
Post by: jeffgran on Wed, 11 December 2013, 18:34:55
Thanks hasu!

I have been playing with the code and trying to understand my problem. I have identified 3 different issues that I have below:
1.
Code: [Select]
Space(tap)/Layer5(hold)  ~~~~~~~~~~~~~_______~~~~~~~~~~~~~
f(Layer0)/=(Layer5)      ~~~~~~~~~~~~~~~____~~~~~~~~~~~~~~~
TAPPING_TERM                         |----------|

expected output: "="
got:             " f"
2.
Code: [Select]
Space(tap)/Layer5(hold)  ~~~~~~~___~~~_________~~~~~___~~~
f(Layer0)/=(Layer5)      ___~~~~~~~~~~~~_____~~~~~~~~~~~~~
TAPPING_TERM                         |----------|

expected output: "f = "
got:             "f  f "
3.
Code: [Select]
t                        ~______~~~~~~~~~~~~~~~~~~~~~~~~~~
h                        ~~~~~~______~~~~~~~~~~~~~~~~~~~~~
i(tap)/ Layer8(hold)     ~~~~~~~~~~~______~~~~~~~~~~~~~~~~
s(Layer0)/ { (layer5)    ~~~~~~~~~~~~~~~~______~~~~~~~~~~~
Space(tap)/Layer5(hold)  ~~~~~~~~~~~~~~~~~~~~~_______~~~~~
TAPPING_TERM                        |----------|

expected output: "this "
got:             "thi{"

1. I was able to solve by using lines 100-111 in action_tapping.c (I commented out the `#if TAPPING_TERM >= 500` and `#endif` lines)
2. I have not been able to figure out which branch of code this case falls into or how to make it process this as a hold rather than a tap. But even if I hold "space" down longer than the TAPPING_TERM, the fact that I tapped it right before that seems to make it impossible to layer shift. I have to wait until it times out in between a tap and a hold.
3. I think this was caused by my "fix" for 1. It seems like it just needs to take into account which tap/hold key was pressed, because in my case one layer switch key was pressed and then a different one was pressed, but the second one seems to be the one that affected the middle key...

Hope that makes sense. I saw your issue #49 in github to refactor that tapping code. I think it would be helpful to make a state machine out of it or something. I think I may try to refactor it maybe in the next few weeks, just to see if I can do it. Unless you are already working on that? If I came up with something would you be willing to look at it and merge it in if you like it?
Title: Re: TMK keyboard firmware
Post by: hasu on Wed, 11 December 2013, 22:39:45
IvanIvanovich,
I don't know why you got ` intead of esc clearly. But boot magic may causes those problem. Try disabling boot magic build option. And you have wrong fn_actions, note that it is array.

EDIT: In fact you cannot omit '{}', I mean.
Title: Re: TMK keyboard firmware
Post by: domoaligato on Wed, 11 December 2013, 23:41:34
I have no idea what revision I am on but on my gh60 rev. a with your firmware I have ` instead of esc everytime I plug it in. I have just dealt with it and pressed fn + q to change it every time I plug in my keyboard assuming that was the default behavior.
Title: Re: TMK keyboard firmware
Post by: hasu on Thu, 12 December 2013, 00:09:58
jeffgran,
great diagram, it clearly make sense to me. Interesting test cases.

Frist, tuning of dual role key all has trade-off and depends on one's fingering, typing habit and speed. No configuration can handle every cases perfectly. We will have to compromise some points. That being said, we can pursue better configuration or implementation of dual role key. IMO.

1. This option allows you to access hold action(=) preferentially. Meanwhile it may prevent you from typing fast, you always must release space bar before releaseing f key to get " f". This is exactly the trade-off you cannot get both.
I'll make this option cofigurable in config.h.

2. hmm, I didn't find this case. My implementation offers key repeat with 'tap and hold'(sequential tap). This repeat likely causes this problem. If you press a key within TAPPING_TERM after tap, the key is recognaized as tap action(space) immediately.
It may exist better implementation of this and I should add configure option for 'tap and hold' repeat, too.
https://github.com/tmk/tmk_keyboard/blob/master/common/action_tapping.c#L231

3. Wierd. I may be a bug. Or buffer overflow may cause this situation. What if you increase WAITTING_BUFFER_SIZE of action_tapping.h?


My code is full of bug fixes and heuristic rules derived from my experience and preference. No apparent theory. It is very confusing even to me :) It certainly needs refactoring or rewrite from scratch. I don't statrt to work at all yet because that is no little job and its complexity scares me.
If you work on this it would be very helpful.
Title: Re: TMK keyboard firmware
Post by: hasu on Thu, 12 December 2013, 00:15:31
I have no idea what revision I am on but on my gh60 rev. a with your firmware I have ` instead of esc everytime I plug it in. I have just dealt with it and pressed fn + q to change it every time I plug in my keyboard assuming that was the default behavior.

Did you try clear eeprom? You can do this with dfu-programmer, I think.
Or did you try boot magic configuration clear? I guess space+backspace or Fn+backspace, it depends on you configure.h.

EDIT: I guess your eeprom was wrongly programmed and it causes this problem, to solve you will need clear the eeprom with either ways.

1. run 'make dfu-ee'
2. plug in pressing space and backspace
Title: Re: TMK keyboard firmware
Post by: jeffgran on Thu, 12 December 2013, 20:36:53
Thanks for you help hasu!

My bug #3 has not been happening any more -- it must have been a problem with something I did the other day. Did not have that problem all day today.

I started working on rewriting action_tapping -- you're right, it's complicated. :) I'll see if I can get it to work. Do you have a way of doing automated tests or anything? If I get it to work for my use case it will be hard to know whether I broke other peoples' use cases..
Title: Re: TMK keyboard firmware
Post by: showvim on Fri, 13 December 2013, 03:10:58
Please~ I want to this function,How to do ? Thank you very much!
normal esc = esc,
fn + esc = ~,
fn + shift + esc = `
Do you understand me ? My English is poor,So sorry~
Title: Re: TMK keyboard firmware
Post by: domoaligato on Fri, 13 December 2013, 09:01:10
I have no idea what revision I am on but on my gh60 rev. a with your firmware I have ` instead of esc everytime I plug it in. I have just dealt with it and pressed fn + q to change it every time I plug in my keyboard assuming that was the default behavior.

Did you try clear eeprom? You can do this with dfu-programmer, I think.
Or did you try boot magic configuration clear? I guess space+backspace or Fn+backspace, it depends on you configure.h.

EDIT: I guess your eeprom was wrongly programmed and it causes this problem, to solve you will need clear the eeprom with either ways.

1. run 'make dfu-ee'
2. plug in pressing space and backspace


thanks i will try tha this weekend when i have a chance.
Title: Re: TMK keyboard firmware
Post by: IvanIvanovich on Fri, 13 December 2013, 14:57:48
showvim, you can look from code I posted. It's how I have mine to work.

IvanIvanovich,
I don't know why you got ` intead of esc clearly. But boot magic may causes those problem. Try disabling boot magic build option. And you have wrong fn_actions, note that it is array.

EDIT: In fact you cannot omit '{}', I mean.
Thanks. I guess instead of telling me I had error, it was using keymap from another like Poker or something??? Weird.
I thought new was supposed to have NKRO? I still only have 6.
Title: Re: TMK keyboard firmware
Post by: hasu on Fri, 13 December 2013, 19:58:59
Thanks for you help hasu!

My bug #3 has not been happening any more -- it must have been a problem with something I did the other day. Did not have that problem all day today.

I started working on rewriting action_tapping -- you're right, it's complicated. :) I'll see if I can get it to work. Do you have a way of doing automated tests or anything? If I get it to work for my use case it will be hard to know whether I broke other peoples' use cases..

Yea, that is what I am thinking of, but I don't start it yet. I think it needs C unit test framework and various test cases. The tapping code can be tested on PC because most of it doesn't depend on AVR specific function.
Title: Re: TMK keyboard firmware
Post by: hasu on Fri, 13 December 2013, 20:15:48
showvim,
You can't do that easily with placing keycodes. You need to write code in keymap function action.
https://github.com/tmk/tmk_keyboard/blob/master/doc/keymap.md#24-function-action
Spec of function action is not fixed and not documented yet. If you want to try this you need to read code yourself.

Ivan, NKRO need to be enable explicitly with command. LShift+RShift+N, probably.
https://github.com/tmk/tmk_keyboard#magic-comannds

Title: Re: TMK keyboard firmware
Post by: codyeatworld on Fri, 13 December 2013, 20:48:54
Is it possible to use this firmware on a 38gt pcb? It uses an aikon controller 2.7b

Being able to use the keyboard in the bios is a big feature for me, asI multiboot different operating systems frequently.
Your firmware is the only one that lets me do this, I run a bit older motherboard, an asus x58, but I don't think thats the problem.

I actually bust out an old ps/2 keyboard just to press the arrow key to select windows/mac when I turn on my computer.

Keyboards that do not work in bios for me:

Keyboards that work in bios for me:

Thanks for the kickass firmware and hard work everybody too!
Title: Re: TMK keyboard firmware
Post by: hasu on Fri, 13 December 2013, 22:25:10
Good to hear tmk works for you.
I for one rarely use my keyboard on BIOS and bootloaders such like grub and  I didn't test it thoroughly.

I think you can use tmk_keyboard built with V-USB on Aikon hardware, but it seems to be difficult to access schematic and code of the keyboard.
Title: Re: TMK keyboard firmware
Post by: codyeatworld on Sat, 14 December 2013, 15:11:17
I'm not really sure what you mean build with v-usb?

This is the only thing I've found about an aikon schematic, and it is almost two years old:
http://deskthority.net/workshop-f7/building-and-using-the-aikon-controller-t15.html

I'm not sure if things have changed since then, but I might be able to get the new information if it has changed.
Title: Re: TMK keyboard firmware
Post by: hasu on Sat, 14 December 2013, 18:37:24
V-USB is one of USB stack used in tmk_keyboard. tmk supports three USB stack LUFA, PJRC and V-USB. gh60 uses LUFA by default.
http://www.obdev.at/products/vusb/index.html

If you want to port the firmware to 38gt, you need to do theese
1) look into matrix circuit with multimeter unless it is open
2) wirte code in matrix.c
3) build with V-USB stack
Title: Re: TMK keyboard firmware
Post by: sean4star on Fri, 20 December 2013, 23:16:07
You can see if SHIFT keys are pressed down by
Code: [Select]
if ( keyboard_report->mods & (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) )

This works great! 

Another question: is there a way to find the state of CAPS?  Not just whether it is currently pressed, but if the caps lock is on or not?

I would like to use the CAPS state in an IF statement.
Title: Re: TMK keyboard firmware
Post by: hasu on Sat, 21 December 2013, 17:38:39
What you can know is only LED state of Caps lock, it can be checked with host_keyboard_leds() like:

    if (host_keyboard_leds() | (1<<USB_LED_CAPS_LOCK))

But you can't know actual host state of Caps lock.
Host may send command to keyboard to control LED indicator but may not. It depends on OS/application implementation. Applicaton can send LED command to keyboard regardless of host state. Or imagine you have two keyboards on a host and you press capslock key, some OS sends LED command to all keyboards but other sends only to the keyboard.
Title: Re: TMK keyboard firmware
Post by: hasu on Thu, 02 January 2014, 23:28:22
Added my first project in this year, this is not a serious keyboard for daily use. TRS-80 model 100 is supported now. This old tiny but complete computer has serial terminal software in its ROM, this application sends out ASCII codes for keys. This project is a converter which translates ASCII into USB HID and makes the lovely comp revived as keyboard hooked up to modern computer.

(http://i.imgur.com/aF3cqmT.jpg)

https://github.com/tmk/tmk_keyboard/tree/master/converter/ascii_usb
Title: Re: TMK keyboard firmware
Post by: sean4star on Fri, 03 January 2014, 16:30:29
That's a cool looking mod!

FYI, matt3o over at deskthority put together a nice simple tutorial for using your firmware.
HERE (http://deskthority.net/workshop-f7/how-to-build-your-very-own-keyboard-firmware-t7177.html)


Also, I'm having a good time creating my own key functions using the ACTION_FUNCTION_TAP.  This gives the user huge flexibility in making any custom design they can dream up.


Quick question:  I've used the layer_on(X) and layer_off(X) events, but is there a similar toggle event?
Title: Re: TMK keyboard firmware
Post by: hasu on Fri, 03 January 2014, 19:26:37
Nice write up, subscribed the thread.

When you use ACTION_FUNCTION, no API for toggling layer. Just use layer_on, _off or _invertert, there are many ways to implement toggle feature. For example,
On originate layer you just do layer_invert(x) [or layer_on(x)] on *release* event of a key and  do nothing on press. On destination layer(x) you also do layer_invert(x) [or layer_off(x)] on release and do nothing on press. Voila!
This is just what ACTION_LAYER_TOGGLE does.
Title: Re: TMK keyboard firmware
Post by: hydrospell on Sun, 05 January 2014, 09:12:03
hasu I know you probably heard this more than a couple of times already, but...

I made a keyboard from scratch and managed to load tmk_keyboard into a Teensy to use it as firmware. So a fully functional keyboard was born today from components thanks to your excellent firmware!!  :thumb:

Thanks once again for the awesome, easy to use code.
Title: Re: TMK keyboard firmware
Post by: hasu on Sun, 05 January 2014, 22:34:40
hydrospell, thanks
it feels nice to get feedback on my work in particular if it is positive :D

and congrats on success of your project!
Title: Re: TMK keyboard firmware
Post by: bcg on Thu, 09 January 2014, 00:13:41
Hasu,

What is the best way to tell which layer(s) are active?  Right now I have configured 2 layers, 1 default and the other a momentary layer activated by one of two function keys.  I'm thinking of making one of the function keys a "lock" for that layer and I want to have an LED as an indicator... so I'd like to be able to tell if the second layer is active at some point and turn on/off the LED appropriately

BTW thank you for merging in my NeXT converter code... so far the firmware is working great and makes the board really nice to use.  Its only 2KRO but it is made with black Alps switches and nice doubleshot caps, and I'm guessing is kind of rare because I don't think there could have been that many NeXT computers made... and its fun to think that the web might have been invented on that keyboard because Tim Berners-Lee invented HTTP and the first web browser on a NeXT station :)  Anyhow I'm hoping to post some details on it soon but I've just been so busy lately.

Thanks for your help
Title: Re: TMK keyboard firmware
Post by: hasu on Thu, 09 January 2014, 01:47:12
Hi,
You can see active layers on layer_state and default_layer_state of action_layer.h. To get real state of layers you need to see both.

    uint32_t real_state = (layer_state | default_layer_state);

Each bit indicates state of a layer; bit0 has state of layer0, bit31 has layer31 and 0/1 means off/on.


Ah, it is you! I didn't find it on github :D
I've not got my hands on any NeXT keyboard yet, it looks attractive and inrigues me. Occasionally I can find them here but its price is steep.
Looking forward to your post about it. Anyway, great job!

FYI, you can access his non-ADB NeXT converter here.
https://github.com/tmk/tmk_keyboard/tree/master/converter/next_usb
Title: Re: TMK keyboard firmware
Post by: yakitysax on Thu, 09 January 2014, 02:15:09
Hi,
You can see active layers on layer_state and default_layer_state of action_layer.h. To get real state of layers you need to see both.

    uint32_t real_state = (layer_state | default_layer_state);

Each bit indicates state of a layer; bit0 has state of layer0, bit31 has layer31 and 0/1 means off/on.


Ah, it is you! I didn't find it on github :D
I've not got my hands on any NeXT keyboard yet, it looks attractive and inrigues me. Occasionally I can find them here but its price is steep.
Looking forward to your post about it. Anyway, great job!

FYI, you can access his non-ADB NeXT converter here.
https://github.com/tmk/tmk_keyboard/tree/master/converter/next_usb
Do you have anywhere where we can throw some cash your way as thanks for making this firmware available, Hasu?
Title: Re: TMK keyboard firmware
Post by: hydrospell on Fri, 10 January 2014, 02:39:13
hydrospell, thanks
it feels nice to get feedback on my work in particular if it is positive :D

and congrats on success of your project!

thank YOU! :)
I'll do a proper write-up with nice pictures once I'm done with the busy period at work, and I will post the link for you here.
Title: Re: TMK keyboard firmware
Post by: bcg on Fri, 10 January 2014, 14:41:15
Hi,
You can see active layers on layer_state and default_layer_state of action_layer.h. To get real state of layers you need to see both.

    uint32_t real_state = (layer_state | default_layer_state);

Each bit indicates state of a layer; bit0 has state of layer0, bit31 has layer31 and 0/1 means off/on.


Ah, it is you! I didn't find it on github :D
I've not got my hands on any NeXT keyboard yet, it looks attractive and inrigues me. Occasionally I can find them here but its price is steep.
Looking forward to your post about it. Anyway, great job!

FYI, you can access his non-ADB NeXT converter here.
https://github.com/tmk/tmk_keyboard/tree/master/converter/next_usb

Thanks for the encouragement, I really appreciate the compliment.  Your firmware makes it really easy to focus on the keyboard-specific details so this was a fun and educational project.

NeXT keyboards seem really expensive but I think they may hold value over time well as collectors items... NeXT was a truly innovative system and the popularity of Steve Jobs should help the collectible appeal I think.

My next project will probably be to implement the XT protocol and build a converter for my Model F XT.  Soarer's converter works well but I want mousekeys :)
Title: Re: TMK keyboard firmware
Post by: sean4star on Sat, 11 January 2014, 12:15:10
How would I add more Fn keys?  I see the keycode.h file defines FN_MAX as KC_FN31.  But the file also defines the name and location of the keys:

Code: [Select]
enum internal_special_keycodes {
    KC_FN0              = 0xC0,
    KC_FN1,
      :
      :
    KC_FN30,
    KC_FN31,            /* 0xDF */

Looks like you are using 0x00 through 0xFF.  What would I need to do to expand this?  Is it as simple as adding more to the end?


You may be asking, why would I need more than 32 Fn keys?!?  Well, 32 isn't very much if you are creating custom keys and changing the shift layer of your number keys AND using layers AND using dual function keys!  Sounds crazy and maybe it is, but I set myself a design goal of compacting an entire 104 keyboard into 2 tenkey number pads!!  I have it working with the 32 Fn keys, but was hoping to also add in mouse and media keys, which will put me over the 32 Fn max.
Title: Re: TMK keyboard firmware
Post by: hasu on Sat, 11 January 2014, 21:32:42
yakitysax, sometime I'll make some converters and controllers and get my beer expenses from its sales. Beer makes my fingers smooth, it is essential for coding :D

sean4star, to expand Fn more than 32 is very difficult, keycode is 8bit code and most of codes out of 0-0xFF are already used. It looks like 0xBB-BF and 0xE8-EF only can be used. With them you will able to add 13 extra Fn keys theoretically, but to implement may not be so easy actually. You can get only 13 extras at most and not sure those are enough for you.

Instead of extra Fn keys I can sugest two routes to circumvent your problem.
1. design your own action
Add useful action code and action implementation yourself in action_code.h or action.c.

2. use 'actioncode map' instead of keymap(keycode map)
Action code is 16bit code and can indicate all of key actions with its 16bit. So you don't have to use any Fn key to indicate special actions like keymap does. Its downside is that it needs twice memory space due to 16bit vs 8bit code.

In both way no documentation exists :)
Title: Re: TMK keyboard firmware
Post by: jacobolus on Sun, 12 January 2014, 04:10:24
sean4star: You’re starting to hit some fundamental limitations with the current design. [Note, I think hasu’s work is wonderful and amazing and I’m not trying to diminish it!] Ideally, the whole project could be re-architected a bit to support a more generic explicit state machine, with some kind of declarative way to define states and transitions. The current code limits flexibility w/r/t chording/layers/macros/other fancy tricks in a number of ways, because it was designed with particular use cases and modes of operation in mind, and I can imagine several interesting features that don’t quite fit the mold.

As one example, I was successfully able to add a bunch of keys which would type Alt + 4 numpad digits, for typing accented letters on windows, so that my parents could plug a teensy-upgraded Apple M0116 into any windows computer and have an easy means of typing words in spanish without needing to change the windows keyboard layout or adapt their typing to each different computer they might plug it in to. I had enough function keys to do this using tmk keyboard firmware, because I only needed to support 2 FN layers + 8 special characters [w/ some ugly big conditional blocks in my macro definitions for detecting the shift key]. But if I had wanted to do something similar and support a large number of special characters [e.g. the greek alphabet + some useful math symbols, or something], then the same method would never scale that far.

Anyhow, I think ultimately I’m going to have to make some firmware from scratch built around a bit more abstracted model [partly just want to do this as a learning exercise], but I think I’ll try to write it for ARM for e.g. a Teensy 3.0/3.1. And it probably won’t happen for at least a few months, since I have other code to write, and work on physical keyboard prototyping to do in the mean time.
Title: Re: TMK keyboard firmware
Post by: codyeatworld on Sun, 12 January 2014, 09:28:45
V-USB is one of USB stack used in tmk_keyboard. tmk supports three USB stack LUFA, PJRC and V-USB. gh60 uses LUFA by default.
http://www.obdev.at/products/vusb/index.html

If you want to port the firmware to 38gt, you need to do theese
1) look into matrix circuit with multimeter unless it is open
2) wirte code in matrix.c
3) build with V-USB stack

I found the pin map, but I'm not really sure where to go from here: https://mediacru.sh/ioFxNWxH2oED.png
Title: Re: TMK keyboard firmware
Post by: hasu on Sun, 12 January 2014, 10:11:33
Nice, it looks like usual V-USB circuit and I think tmk works for this without problem.
Next, you need to know matrix circuit, you can start with 1) as I previously posted.

I'm not sure what you need because I don't know your electronics knowledge and C programming skills.
Do you want to know about how tmk_keyboard works? If so I can help.
If you need to learn how matrix circuit works or C language you can teach yourself with great keyboard resources on the net.
Title: Re: TMK keyboard firmware
Post by: codyeatworld on Sun, 12 January 2014, 10:29:11
Nice, it looks like usual V-USB circuit and I think tmk works for this without problem.
Next, you need to know matrix circuit, you can start with 1) as I previously posted.

I'm not sure what you need because I don't know your electronics knowledge and C programming skills.
Do you want to know about how tmk_keyboard works? If so I can help.
If you need to learn how matrix circuit works or C language you can teach yourself with great keyboard resources on the net.

Basically what would be the first step in writing code in matrix.c, I don't really understand this file yet.

I have very basic knowledge in electronics, but I've been programing for over a year in Ruby. I can catch on pretty quick usually :D
I'm not positive how the matrix works so I'm gonna look into that more later on.
Title: Re: TMK keyboard firmware
Post by: Hzza on Mon, 13 January 2014, 02:45:31
http://deskthority.net/workshop-f7/how-to-build-your-very-own-keyboard-firmware-t7177.html

Would that help at all?
Title: Re: TMK keyboard firmware
Post by: hasu on Mon, 13 January 2014, 21:22:02
Yes, that is nice tutorial by matt3o, very helpful.

To learn about keyboard matrix this will be useful as well.
http://www.dribin.org/dave/keyboard/one_html/

And komar also has good blog post, he is GH60 designer as you know.
http://blog.komar.be/how-to-make-a-keyboard-the-matrix/
Title: Re: TMK keyboard firmware
Post by: codyeatworld on Mon, 13 January 2014, 21:41:30
Yeah the matt3o tutorial is very helpful, just what I needed, and I'll check out the matrix links.
 
I have a couple 38gts incoming, I will give this a shot soon.

Does tmk support full led?
Title: Re: TMK keyboard firmware
Post by: hasu on Mon, 13 January 2014, 22:59:30
All LED indicators defined in spec are supported. If you mean backlight, maybe answer is yes/no.
Wraul added backlight interface(common/backlight.h) to support KMAC some back. But I'm not sure it works for you. At least it does not support fancy illumination fucntions.

Title: Re: TMK keyboard firmware
Post by: codyeatworld on Tue, 14 January 2014, 12:46:43
All LED indicators defined in spec are supported. If you mean backlight, maybe answer is yes/no.
Wraul added backlight interface(common/backlight.h) to support KMAC some back. But I'm not sure it works for you. At least it does not support fancy illumination fucntions.



The 38gt with aikon uses the dipswitch under the pcb to turn on/off the leds for every key.

I don't really care for fancy led functions, I would just want to light up every key. It looks like I could modify the KMAC backlight.h to light up all the keys though.
Title: Re: TMK keyboard firmware
Post by: Melvang on Tue, 21 January 2014, 11:29:13
Would this matrix be possible with using a hand wired matrix on a Teensy 2.0?  Or would I need the ++ edition for extra pins?  I have one pad on my Teensy for this with a lifted pad and don't feel comftorable to attempt to repair that so I am down one pin on the Teensy.  The missing pad is on pin C6.  If I can still make this work what pins would the rows and columns hook up to?

It is 19 columns x 6 rows.
[attach=1]
Title: Re: TMK keyboard firmware
Post by: hasu on Tue, 21 January 2014, 11:51:53
I don't remember how many ports Teensy2.0 has.
Just simple math; if your Teensy still has 25(19+6) ports you can use it.

You can use any available IO ports for the purpose and matrix wiring totally depends on how you write code for matrix scan.
Title: Re: TMK keyboard firmware
Post by: Melvang on Tue, 21 January 2014, 11:54:06
Thanks Hasu.  I would assume that anything with a number in the pin designation can be used then?
Title: Re: TMK keyboard firmware
Post by: Tarzan on Tue, 21 January 2014, 12:00:11
Thanks Hasu.  I would assume that anything with a number in the pin designation can be used then?

Not to jump queue, but I think the Teensy 2.0 controller can use up to 26 pins.  This does count the pin used for the on-board LED, based on other comments it doesn't impact the usage of the controller to assign a row/column to that pin.  Excludes Power, Ground, and E6.
Title: Re: TMK keyboard firmware
Post by: Melvang on Tue, 21 January 2014, 12:29:18
Thanks Hasu.  I would assume that anything with a number in the pin designation can be used then?

Not to jump queue, but I think the Teensy 2.0 controller can use up to 26 pins.  This does count the pin used for the on-board LED, based on other comments it doesn't impact the usage of the controller to assign a row/column to that pin.  Excludes Power, Ground, and E6.

I am probably wrong on this but I am only counting 24.

Counting from top left with USB port on left side on top I get

Code: [Select]
1 F0
2 F1
3 F4
4 F5
5 F6
6 F7
7 B6
8 B5
9 B4
10 D7
11 D6
12 D4
13 D5
14 C7
15 C6 Lifted top pad on mine.
16 D3
17 D2
18 D1
19 D0
20 B7
21 B3
22 B2
23 B1
24 B0

So looking at this I don't have enough pins even with including my lifted pad. 

Also looking at PJRC's website it has 25 IO pins.  I am guessing that would be E6. 

And it looks like with this layout I am going to need every pin for the matrix.  Well, looks like I am going to use my new teensy and just buy another one for when I get ready to wire up my Brushed Behemoth.

Edit:  I apologize if these are noobie questions but I am still pretty new to electronics.  I do understand some basics but not a lot of specifics especially with these controllers and such.
Title: Re: TMK keyboard firmware
Post by: Tarzan on Tue, 21 January 2014, 12:51:09
Thanks Hasu.  I would assume that anything with a number in the pin designation can be used then?

Not to jump queue, but I think the Teensy 2.0 controller can use up to 26 pins.  This does count the pin used for the on-board LED, based on other comments it doesn't impact the usage of the controller to assign a row/column to that pin.  Excludes Power, Ground, and E6.

I am probably wrong on this but I am only counting 24.

Counting from top left with USB port on left side on top I get

Code: [Select]
1 F0
2 F1
3 F4
4 F5
5 F6
6 F7
7 B6
8 B5
9 B4
10 D7
11 D6
12 D4
13 D5
14 C7
15 C6 Lifted top pad on mine.
16 D3
17 D2
18 D1
19 D0
20 B7
21 B3
22 B2
23 B1
24 B0

So looking at this I don't have enough pins even with including my lifted pad. 

Also looking at PJRC's website it has 25 IO pins.  I am guessing that would be E6. 

And it looks like with this layout I am going to need every pin for the matrix.  Well, looks like I am going to use my new teensy and just buy another one for when I get ready to wire up my Brushed Behemoth.

Edit:  I apologize if these are noobie questions but I am still pretty new to electronics.  I do understand some basics but not a lot of specifics especially with these controllers and such.

I stand corrected!  I think I was adding in the Reset pin to get my previous total.   ;D

I've got two Teensy++ controllers for just this situation, as I found it pretty complicated to hard-wire a full 104-key keyboard to fit a Teensy 2.0.  I guess it can be done, but it involved a lot of double runs, and even then I couldn't include F8.  Not that I ever used it, mind...   :))
Title: Re: TMK keyboard firmware
Post by: Melvang on Tue, 21 January 2014, 13:07:43
Now my question is this.  When using the TMK firmware does it use the rows or columns as an input?  Trying to figure out which way I need to point my diodes.

Looking at the 10th picture here (http://geekhack.org/index.php?topic=20898.0) it would appear that the black band would go toward the row and uses the columns as an output from the teensy and the rows as the input. 

Comments or suggestions?
Title: Re: TMK keyboard firmware
Post by: hydrospell on Tue, 21 January 2014, 15:15:12
Think the columns are the inputs. I copied matt3os wiring in the brown fox build, loaded the /keyboards/gh60 code and it worked.
Title: Re: TMK keyboard firmware
Post by: hasu on Tue, 21 January 2014, 18:30:59
Yes. In tmk you shall see columns as input, this is just from conventional reason. Note that 'column' and 'row' are just name and interchangeable each other if you change your point of view.

In your matrix you can read 19 columns as input but to retain that data you need to 32bit(uint32_t) variable and waste 13 bits space in vain. Instead, you can use 8bit(uint8_t) variable with treating your 6 'rows' as input, that is, 'column' in tmk. Confusing :)

Right, looks like lowpoly's M0110 mod uses 'rows' as input. Wait, lean your head 90deg. Voila, row is column now!
Title: Re: TMK keyboard firmware
Post by: nebo on Fri, 24 January 2014, 00:35:40
I might not be understanding layers correctly, but this all looks right to me. What I'm expecting to happen is when I hit 'F12', the navigation cluster becomes a numpad but I can't figure out why it doesn't. I tried it as layer 2 since I assumed they started at 0 but I guess not.

Code: [Select]
// Phantom ANSI 150
static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
    /* 0: qwerty */
    KEYMAP_ANSI_150(\
        ESC,      F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, FN2,       PSCR,NLCK,BRK,  \
        GRV, 1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   MINS,EQL, BSPC,      INS, HOME,PGUP, \
        TAB, Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,   LBRC,RBRC,BSLS,      DEL, END, PGDN, \
        CAPS, A,   S,   D,   F,   G,   H,   J,   K,   L,   SCLN,QUOT,     ENT,       TRNS,TRNS,TRNS, \
        LSFT,     Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, SLSH,     RSFT,      TRNS, UP, TRNS, \
        LCTL,LGUI,LALT,               SPC,                     RALT,FN1,RCTL,       LEFT,DOWN,RGHT),
/* 1: number keys */
    KEYMAP_ANSI_150(\
        TRNS,     TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,     PSCR,NLCK,BRK,  \
        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,     PSLS,PAST,PMNS, \
        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,     P7,   P8,  P9,  \
        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,     TRNS,     P4,   P5,  P6,  \
        TRNS,     TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,     TRNS,     P1,   P2,  P3,  \
        TRNS,TRNS,TRNS,               TRNS,                    TRNS,TRNS, TRNS,    P0,  PDOT,PPLS),
    /* 2: media keys */
    KEYMAP_ANSI_150(\
        TRNS,     TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,      TRNS,TRNS,SLEP, \
        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,      TRNS,TRNS,TRNS, \
        TRNS,MPLY,MPRV,MNXT,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,      TRNS,TRNS,TRNS, \
        TRNS,MUTE,VOLD,VOLU,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,     TRNS,      TRNS,TRNS,TRNS, \
        TRNS,     TRNS,TRNS,CALC,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,     TRNS,      TRNS,TRNS,TRNS, \
        TRNS,TRNS,TRNS,               TRNS,                   TRNS,TRNS, TRNS,      TRNS,TRNS,TRNS)
};
static const uint16_t PROGMEM fn_actions[] = {
        [0] = ACTION_LAYER_MOMENTARY(1),                  // FN0
        [1] = ACTION_LAYER_TAP_KEY(2, KC_RGUI),           // FN1
        [2] = ACTION_LAYER_TOGGLE(3)                      // FN2
};

Title: Re: TMK keyboard firmware
Post by: hasu on Fri, 24 January 2014, 06:16:23
Your numpad layer is placed at layer[1]. But You define FN2 as toggle non exist layer[3] instead of 1.

Replace 3 with 1 in your FN2 definition.
Title: Re: TMK keyboard firmware
Post by: jeffgran on Fri, 24 January 2014, 12:50:15
Yes. In tmk you shall see columns as input, this is just from conventional reason. Note that 'column' and 'row' are just name and interchangeable each other if you change your point of view.

In your matrix you can read 19 columns as input but to retain that data you need to 32bit(uint32_t) variable and waste 13 bits space in vain. Instead, you can use 8bit(uint8_t) variable with treating your 6 'rows' as input, that is, 'column' in tmk. Confusing :)

Right, looks like lowpoly's M0110 mod uses 'rows' as input. Wait, lean your head 90deg. Voila, row is column now!

LOL :)
Title: Re: TMK keyboard firmware
Post by: sean4star on Fri, 24 January 2014, 13:57:18
Which IBM keyboards are supported with the existing converters?  And which converter should be used?

For example, I am the proud new owner of a Model M #1390120.  And I have an XT Model F (out of an IBM 5155 Portable PC system) on the way as well.  I don't know much about scan code sets, so I couldn't tell you which one's are used.  Which converters would I use for these?  And are there instuctions on how to set them up?
Title: Re: TMK keyboard firmware
Post by: nebo on Fri, 24 January 2014, 14:19:47
Ok, one more question. I can't seem to find where (I assumed it be in common/) that the led's are bound to a key. My end goal is to have it so that pressing a key that switches layers causes a led to be switched on for when the non-default layer is selected.
Title: Re: TMK keyboard firmware
Post by: hasu on Fri, 24 January 2014, 21:06:25
sean4star, I don't know which scan code set #1390120 uses. You can use ps2_usb for scan code set 2 or terminal_usb for set 3. Unfortunately tmk_keyboard does not support XT(set 1) atm.

nebo, leds are bound for system status indicators(Capslock, Numlock and ...) by defaut and what you want is not supported. You can write your own function in keymap to control your led, but not documented enough and you need to read lot of dirty cocde to understand.
https://github.com/tmk/tmk_keyboard/blob/master/doc/keymap.md#24-function-action
Title: Re: TMK keyboard firmware
Post by: sean4star on Sat, 25 January 2014, 01:27:57
Are there any plans to add XT (scan code set 1) support in the future?  What all is involved in developing the code for a converter?
Title: Re: TMK keyboard firmware
Post by: jacobolus on Sat, 25 January 2014, 01:57:02
Would this matrix be possible with using a hand wired matrix on a Teensy 2.0?  [...] It is 19 columns x 6 rows.

You know you don’t have to wire all the rows and columns in exactly straight lines, right? :)

You should be able to handle your layout with a 10x11 or 11x11 matrix, you just might have to make the rows and columns zig zag or skip a bit.
Title: Re: TMK keyboard firmware
Post by: hasu on Sat, 25 January 2014, 03:09:24
I don't have any XT keyboard and no plan myself at the momemnt. But I think bcg may have a plan for his future project.
http://geekhack.org/index.php?topic=41989.msg1188141#msg1188141
Title: Re: TMK keyboard firmware
Post by: Melvang on Sat, 25 January 2014, 17:26:05
Would this matrix be possible with using a hand wired matrix on a Teensy 2.0?  [...] It is 19 columns x 6 rows.

You know you don’t have to wire all the rows and columns in exactly straight lines, right? :)

You should be able to handle your layout with a 10x11 or 11x11 matrix, you just might have to make the rows and columns zig zag or skip a bit.

True but with this being my first hand matrix with an odd layout which will require a custom firmware I want to keep he matrix as simple as possible.  With what I have been reading I can do the matrix as is with a Teensy 2.0.  But I just have to use my new one instead of the used one due to pulling a pad when I pulled the old one.
Title: Re: TMK keyboard firmware
Post by: gropingmantis on Sat, 01 February 2014, 03:05:20
Having an issue with my phantom at the moment. When I plug it into my computer (arch linux, X11, dwm) it kills my kbmap which means that ~# and |\ (uk iso layout) dont work until i reset my kbmap. Is there a way to make the board identify as uk iso or is this an issue with my setup?
Title: Re: TMK keyboard firmware
Post by: hasu on Sat, 01 February 2014, 06:50:38
What is kbmap? How do you reset you kbmap?
Show your keymap.c, it may help.

hmm, I'm not sure what your problem is, honestly. Can anyone help him?
Title: Re: TMK keyboard firmware
Post by: tuxsavvy on Sat, 01 February 2014, 08:45:32
I don't think gropingmantis was referring to kbmap. With the information provided it sounds like gropingmantis is referring to something specifically within the X environment, it could be xmodmap, xkbmap or something like that.

Though at the same time gropingmantis needs to be more specific on the issue. If it was exactly as I mentioned above then it has nothing to do with the keyboard firmware but rather the mapping used on the computer. I have had encountered similar situations before but I have not really found the root cause of it all. In my cases I have keyboards with varying layouts (big-ass enter, JIS and DE ISO) and am also running archlinux.

Big-ass enter keyboard was the most easiest to setup, setting up JIS was a little harder but xmodmap and having to issue the command a few times ensured that the map would stay up a little longer. The problem by then was really xmodmap when it seems to lack certain keys it will randomly map mod on its own (mod keys that is). The real issue was (and still is getting DE ISO) to work. My archlinux was more or less setup on ANSI keyboard hence it assumes keyboards being in use are ANSI or ANSI related. This poses some issues which I have mixed results.

If gropingmantis was previously using a layout that was not set/defined at start, the system may automatically assume a specific layout to be used. For now a really dirty hack I would suggest (which only seems to work under X11 environment) is to use setxkbmap tool. Here are some potential pointers for getting it to work: https://wiki.archlinux.org/index.php/Keyboard_Configuration_in_Xorg

I have personally taken a different approach (until I can find a more better way somehow) into trying to rectify the issue and for now a very ugly hack seems to be doing the trick for DE ISO:
Code: [Select]
while true; do setxkbmap -layout de && sleep 1; doneI do not personally condone the use of this hack that I made nor do I take any responsibilities for any damages may arise from the use of the hack. Until I can find a nice solution that can work with my constant keyboard switching (along with their specific switches and their layouts) I am more or less going to have to tackle it in various ways. xmodmap seems to work wonders for both the two former keyboards but not so well for the DE ISO (yet).

Also I tend to think that there is no easy way for Xorg to know which keyboard with exactly which layout is plugged in, especially this is true with PS/2 or DIN connector type keyboards. They do not have an ID and are labelled as "AT Translated Set 2 keyboard" via xinput tool.

Title: Re: TMK keyboard firmware
Post by: gropingmantis on Sat, 01 February 2014, 12:56:17
tuxsavy is corrct. In my xinitrc I have the line
Code: [Select]
setxkbmap gbHowever when I plug my phantom in it resets back to the default US X11 mapping. Its not a problem I saw with my Filco with HID liberation or any other keyboard.
Nothing comes up in dmesg when I plug it in either and all the keys work fine they are just mapped incorrectly. I will say that this issue is not present every time but most times. Also it is only in X that the keymap is reset. In a standard terminal $KEYMAP is not altered.
Title: Re: TMK keyboard firmware
Post by: tuxsavvy on Mon, 03 February 2014, 22:35:44
In some ways I need to know more information about your other boards (including your Filco). If they are all ANSI layout it would be reset to correct keyboard map. However, in some ways I tend to want to think that setxkbmap is a temporary means of telling X your layout is X over say Y or even Z.

A possible dirty hack would be to write your own Xorg.conf file specifically implying to use GB ISO layout instead of ANSI. I think the issue might be related to the fact that writing Xorg.conf has been somewhat deprecated for the "plug-and-play" ideals. Then again the settings might be set in when Xorg is told to use a config file specified by the user rather than leaving say udev, hal or whatever to detect and "assume" the layout. Heck even Xorg itself.

Then again writing your own Xorg.conf file I guess would restrict to maybe a keyboard. I am not sure how it would work with one having multiple keyboards with multiple layouts, even worse is if one having multiple keyboard and their specific layouts but are all connected via PS/2, DIN, etc (anything but USB). That would be even more of a nightmare to "segment" out individual non-USB keyboards whom all share the same ID as "AT Translated Set 2 keyboard". Some PS/2 to USB adapters would show different ID but again if same USB adapters were to be used they would produce the same ID.
Title: Re: TMK keyboard firmware
Post by: gropingmantis on Wed, 05 February 2014, 02:05:18
All my keyboards are UK ISO and they all connect over USB. I had the aforementioned Filco with HID Liberation using TMK. An IBM Model M with a Teensy Converter running Soarer's. And two wireless Logitech boards that share a unifying receiver. The Phantom is the only board that displays this behaviour so my conclusion is that it is something to do with the firmware/teensy setup somehow as TMK+HID Lib works and Soarers+Teensy works.
Title: Re: TMK keyboard firmware
Post by: hasu on Wed, 05 February 2014, 14:57:30
Your X11 recognizes Phantom as US layout for some reason. But how?
Other window manager has same problem? How about Windows and Mac?

Just my wild guess is that  X11 sees Phantom VID/PID and decides layout. Just change VID/PID then build and test its firmware.
Title: Re: TMK keyboard firmware
Post by: gropingmantis on Thu, 06 February 2014, 02:18:42
Ah ha I've fixed it! It was not hasu's wonderful firmware but my own X settings.
Code: [Select]
setxkbmapis only ever temporary, instead I should have used
Code: [Select]
# localectl set-x11-keymapwhich creates a new file
Code: [Select]
/etc/X11/xorg.conf.d/00-keyboard.confand now everything is permanent and fixed. YAY!
Title: Re: TMK keyboard firmware
Post by: wuqe on Thu, 06 February 2014, 09:00:40
Yay indeed! Thanks for the update; the internet is smarter now. :)
Title: Re: TMK keyboard firmware
Post by: wcass on Mon, 10 February 2014, 21:44:37
Let's say that i have two keys that both have alternate functions associated with them. If i need to make a chord that uses both keys but from different layers - is there a way to define which keys come from which layers?

For example, if i wanted to select text from the cursor position to the end of the line, i might type shift+end. But I want to make (Fn+shift=caps_lock) AND (Fn+right_arrow=end).  So, how do i make sure that Fn+shift+right_arrow=shift+end (with no caps lock)? Is the only solution to move caps lock to some other combo?

Thanks!
Title: Re: TMK keyboard firmware
Post by: AKmalamute on Mon, 10 February 2014, 23:18:41
For example, if i wanted to select text from the cursor position to the end of the line, i might type shift+end. But I want to make (Fn+shift=caps_lock) AND (Fn+right_arrow=end).  So, how do i make sure that Fn+shift+right_arrow=shift+end (with no caps lock)? Is the only solution to move caps lock to some other combo?
Thanks!

 I haven't played with this firmware, so I'm mostly speaking from 1st-hand experience of my HHKB-lite2, which has a function layer, but ...

 No, you can't call keystrokes from two separate layers at the same time. You can have a key be "transparent" so it will fall through to the next  not-transparent definition (recalling that description from Massdrop's firmware creator, but I can visualize it, again, because of my own keyboard) but that means that "This is the shift key" regardless of which layer is being called elsewhere.
Title: Re: TMK keyboard firmware
Post by: hasu on Tue, 11 February 2014, 00:19:21
wcass,
Seems like you can use "dual-role key"(TAP_KEY in tmk) to have both Shift and Caps on that layer.
But I'd say moving Caps is a reasonable solution.
Title: Re: TMK keyboard firmware
Post by: plainbriny on Tue, 11 February 2014, 07:50:44
Hi hasu, first of all, thanks for your greatest ever firmware. I have been using it for a couple of months, and it is just amazing.

However, recently I upgraded my PC to a new one with UEFI. The problem is, if I use lufa, the computer behave strangely, either stuck in the "press del for setup" screen (I can enter the setup and the keyboard is working fine there), or when pass that screen sometimes, the linux kernel will report "CPU[123] not responding" and reboot. If I wait after computer booting complete, then plug the keyboard, everything works fine.

Therefore, I am now using pjrc stack and it works, no above mentioned problem. But I can't help to wonder what might be the problem and whether it can be fixed.
Title: Re: TMK keyboard firmware
Post by: hasu on Tue, 11 February 2014, 14:38:07
Thank you for your feedback.
I filed the issue on github. Maybe it is HID spec compliance problem.
Unfortunately I can't fix this in a short time, I'll work on it later when I have a mcuh time.
https://github.com/tmk/tmk_keyboard/issues/93
Title: Re: TMK keyboard firmware
Post by: domoaligato on Fri, 14 February 2014, 22:51:56
Hi hasu, first of all, thanks for your greatest ever firmware. I have been using it for a couple of months, and it is just amazing.

However, recently I upgraded my PC to a new one with UEFI. The problem is, if I use lufa, the computer behave strangely, either stuck in the "press del for setup" screen (I can enter the setup and the keyboard is working fine there), or when pass that screen sometimes, the linux kernel will report "CPU[123] not responding" and reboot. If I wait after computer booting complete, then plug the keyboard, everything works fine.

Therefore, I am now using pjrc stack and it works, no above mentioned problem. But I can't help to wonder what might be the problem and whether it can be fixed.


have you tired to see if you might have a bios update to install?
Title: Re: TMK keyboard firmware
Post by: Hubbert on Sat, 15 February 2014, 12:03:09
I've been away for a while.  I browsed the documentation, and have a few basic questions before diving in:

1) Are all Hasu's converters & controllers packaged under the "TMK" umbrella?
2) What is the meaning of "TMK"?
3) Are the hardware requirements documented, e.g., which versions of Teensy work?

Thanks!

PS:
4) What are the limitations on the matrix size?  Ideally, I'd like to use one controller to control a 104-key keyboard and an external 10-key together.
Title: Re: TMK keyboard firmware
Post by: phatdood9 on Sun, 16 February 2014, 18:41:13
Can someone spot any error in this?

Somehow my bottom row doesn't seem to be working. I don't think its a hardware issue.

Is there any sort of debug logger I can use?

Code: [Select]
#include "keymap_common.h"

#define KEYMAP( \
    K0A, K0B, K0C, K0D, \
    K1A, K1B, K1C, K1D, \
    K2A, K2B, K2C, K2D, \
    K3A, K3B, K3C, K3D, \
    K4A, K4B, K4C, K4D \
) { \
    { KC_##K0A, KC_##K0B, KC_##K0C, KC_##K0D }, \
    { KC_##K1A, KC_##K1B, KC_##K1C, KC_##K1D }, \
    { KC_##K2A, KC_##K2B, KC_##K2C, KC_##K2D }, \
    { KC_##K3A, KC_##K3B, KC_##K3C, KC_##K3D }, \
    { KC_##K4A, KC_##K4B, KC_##K4C, KC_##K4D }, \
}

#ifdef KEYMAP_SECTION_ENABLE
const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] __attribute__ ((section (".keymap.keymaps"))) = {
#else
const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = {
#endif
    [0] = KEYMAP(
        NLCK,PSLS, PAST, PMNS, \
        P7,  P8,   P9,   PPLS, \
        P4,  P5,   P6,   NO,   \
        P1,  P2,   P3,   ENT,  \
        P0,  P0,   PDOT, NO)
};

#ifdef KEYMAP_SECTION_ENABLE
const uint16_t fn_actions[] __attribute__ ((section (".keymap.fn_actions"))) = {
#else
const uint16_t fn_actions[] PROGMEM = {
#endif
};

config.h
Code: [Select]
#ifndef CONFIG_H
#define CONFIG_H


/* USB Device descriptor parameter */
#define VENDOR_ID       0xFEED
#define PRODUCT_ID      0x6060
#define DEVICE_VER      0x0001
#define MANUFACTURER    geekhack
#define PRODUCT         GHPAD
#define DESCRIPTION     t.m.k. keyboard firmware for GHPAD

/* key matrix size */
#define MATRIX_ROWS 5
#define MATRIX_COLS 4

/* define if matrix has ghost */
//#define MATRIX_HAS_GHOST

/* Set 0 if debouncing isn't needed */
#define DEBOUNCE    5

/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */
#define LOCKING_SUPPORT_ENABLE
/* Locking resynchronize hack */
#define LOCKING_RESYNC_ENABLE

/* key combination for command */
#define IS_COMMAND() ( \
    keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \
)


#endif
Title: Re: TMK keyboard firmware
Post by: hasu on Sun, 16 February 2014, 19:20:25
I've been away for a while.  I browsed the documentation, and have a few basic questions before diving in:

1) Are all Hasu's converters & controllers packaged under the "TMK" umbrella?
2) What is the meaning of "TMK"?
3) Are the hardware requirements documented, e.g., which versions of Teensy work?

Thanks!

PS:
4) What are the limitations on the matrix size?  Ideally, I'd like to use one controller to control a 104-key keyboard and an external 10-key together.

1) Yes.
2) Tokyo Mushy Ki-bo-do, Truely Maccho Keyboard or anything. I didn't decide yet.
T: [Tokyo|The|Truely|...]
M: [Maccho|Massive|Minimalist|...]
K: [Keyboard|Kompany|Kogyo|...]
3) It will work on AVR controller with USB engine like: ATmega32u4, ATmega16u2, AT90USB*. Flash size more 32KB is recommended.
So you can use Teensy2.0 and Teensy2.0++.  Also Teensy1.0 and Teensy1.0++ probably.
4) It will depend on memory size. I think 16x16=256-key keyboard will work without problem.
Title: Re: TMK keyboard firmware
Post by: hydrospell on Mon, 17 February 2014, 07:32:00
Truly Massive Kogyo ... I like.
Title: Re: TMK keyboard firmware
Post by: wuqe on Mon, 17 February 2014, 09:03:39
True Media Keys? I know that was the draw for many Ergodox owners.
Title: Re: TMK keyboard firmware
Post by: Melvang on Mon, 17 February 2014, 09:56:27
Is it possible to have a hard drive activity LED powered by the Teensy?  Or is it not able to read through the same USB for that?
Title: Re: TMK keyboard firmware
Post by: clickclack123 on Sat, 22 February 2014, 08:43:15
I have a question:

In my layout, I have an action function that prints a message to hid_listen.exe when I toggle layouts:
Code: [Select]
ACTION_FUNCTION(DUMBTHUMBS), // FN14 - activate/disable left hand for testing

<snip>

    else if (id == DUMBTHUMBS) {
        if (event.pressed) {
            if (layer_state & 1<<11) { // layer 11 is already on
                print("enabling left thumbs...\n");
                layer_off(11);
            } else {
                print("disabling left thumbs...\n");
                layer_on(11);
            }
        }
    }

Is there a way to have the same function, except only activated momentarily?

I know I can use ACTION_LAYER_MOMENTARY(11), but how can I print a message to hid_listen when using that?
Title: Re: TMK keyboard firmware
Post by: wuqe on Sat, 22 February 2014, 09:26:44
Is there a way to have the same function, except only activated momentarily?

The key is the event.pressed flag; when it's not true, then the event is a key-up. Just disable the layer once you see an event from that key with event.pressed set to false.
Title: Re: TMK keyboard firmware
Post by: clickclack123 on Sat, 22 February 2014, 11:18:05
Is there a way to have the same function, except only activated momentarily?

The key is the event.pressed flag; when it's not true, then the event is a key-up. Just disable the layer once you see an event from that key with event.pressed set to false.

Great, thanks, worked perfectly:
Code: [Select]
    else if (id == DUMBTHUMBSMOMENTARY) {
        if (event.pressed) {
            {
                print("disabling left thumbs momentarily...\n");
                layer_on(11);
            }
        } else {
                print("enabling left thumbs momentarily...\n");
                layer_off(11);
}
    }

That'll be good for having notifications of what layer is enabled using hid_listen. Thanks again wuqe!
Title: Re: TMK keyboard firmware
Post by: jgrade on Sat, 01 March 2014, 11:33:21
Hi,

I am assembling a tenkeyless keyboard with a matrix:
(http://i297.photobucket.com/albums/mm228/johnny88_bucket/2014-02-16110825.jpg)

(http://i297.photobucket.com/albums/mm228/johnny88_bucket/2014-02-22202632.jpg)

and now its time to program the controller. i have a Teensy 2.0 and was thinking of uploading the phantom teensy firmware.
Is it compatible with this type of keyboards? (i've tried it and had no luck)
What do you recommend?
Title: Re: TMK keyboard firmware
Post by: hasu on Sat, 01 March 2014, 12:13:19
Maybe not compatible. You will need to write your own matrix.c. See matt3o's nice write up.
http://deskthority.net/workshop-f7/how-to-build-your-very-own-keyboard-firmware-t7177.html
Title: Re: TMK keyboard firmware
Post by: xSpartanCx on Sat, 01 March 2014, 12:42:23
I can't get the MXLOCK locking caps lock to work for my phantom. I use CAPS and it works like a normal caps lock, which isn't very effective for MXLOCK. I try LCAP, and it doesn't even turn caps lock on. I've added the #define LOCKING_SUPPORT_ENABLE and #define LOCKING_RESYNC_ENABLE to the top of config.h
Title: Re: TMK keyboard firmware
Post by: hasu on Sat, 01 March 2014, 14:03:49
Hmm, it looks your configuration is right, it should work. Did you do 'make clean' after change config.h?
Title: Re: TMK keyboard firmware
Post by: jgrade on Sat, 01 March 2014, 17:38:02
Maybe not compatible. You will need to write your own matrix.c. See matt3o's nice write up.
http://deskthority.net/workshop-f7/how-to-build-your-very-own-keyboard-firmware-t7177.html

thanks hash!!! all is working now  :thumb:
Title: Re: TMK keyboard firmware
Post by: xSpartanCx on Sun, 02 March 2014, 20:07:34
Hmm, it looks your configuration is right, it should work. Did you do 'make clean' after change config.h?

Yes... It seems to me like it's not even recognizing the changes in my config.h. The LED brightness doesn't change, even when I set it as low as 20, either.
My config.h: http://pastebin.com/7hB9jatE <-- the define bootloader was an attempt to get a teensy program button to work, for some reason that doesn't work either.
My keymap_ansi.h: http://pastebin.com/N0wTL3wA

I'm using the command "make -f Makefile.lufa ansi clean" and then "make -f Makefile.lufa ansi"
Title: Re: TMK keyboard firmware
Post by: hasu on Sun, 02 March 2014, 20:38:50
Are you sure you can program(flash) your controller correctly?

EDIT: I confirmed 'LOCKING_SUPPORT_ENABLE' works as expected on my HHKB.
I don't know about LED brightness, I don't have a Phantom. People of Phantom thread may help you.
Title: Re: TMK keyboard firmware
Post by: xSpartanCx on Sun, 02 March 2014, 21:27:49
I might not be? All I've been doing is putting the .hex file into the teensy programmer, which is how I think I'm supposed to do it.
Title: Re: TMK keyboard firmware
Post by: Melvang on Sun, 02 March 2014, 23:07:45
Ok, I have a question here.  Fair warning I am a total programming nooblet.  While I realize it is a totally different hardware architecture and possibly software architecture, but how difficult would it be to port this over to work on a Teensy 3.0 or 3.1?
Title: Re: TMK keyboard firmware
Post by: sean4star on Mon, 03 March 2014, 10:43:58
I'm not getting NKRO to work.  Maybe there's something wrong in my makefile?  I downloaded a current copy of the source from Git this morning and recompiled.  I'm on Windows 7  and my makefile has this:

Code: [Select]
# Build Options
#   comment out to disable the options.
#
BOOTMAGIC_ENABLE = yes  # Virtual DIP switch configuration(+1000)
MOUSEKEY_ENABLE = yes   # Mouse keys(+4700)
EXTRAKEY_ENABLE = yes   # Audio control and System control(+450)
CONSOLE_ENABLE = yes    # Console for debug(+400)
COMMAND_ENABLE = yes    # Commands for debug and configuration
SLEEP_LED_ENABLE = yes  # Breathing sleep LED during USB suspend
NKRO_ENABLE = yes       # USB Nkey Rollover - not yet supported in LUFA

When I use these:
Code: [Select]
Tools for testing NKRO
----------------------
Browser App:
http://www.microsoft.com/appliedsciences/content/projects/KeyboardGhostingDemo.aspx
http://random.xem.us/rollover.html

I only get max of 6KRO.


Anything else I should be doing to fix this?
Title: Re: TMK keyboard firmware
Post by: Hzza on Mon, 03 March 2014, 11:51:22
You have to press "magic key" and N, by default it should be both shifts. So you hold down both shifts, press N and release and you should have NKRO. Took me a while to figure that out too.
Title: Re: TMK keyboard firmware
Post by: sean4star on Mon, 03 March 2014, 12:00:58
I see...that works!  I hadn't paid attention to the magic key commands before now.


So is this something that has to be selected each time my kb is turned on?  Whenever I unplug the kb and plug it back in the NKRO is off.  Is there a way to default it to on?  Or, is there a reason not to have it default to on?
Title: Re: TMK keyboard firmware
Post by: wuqe on Mon, 03 March 2014, 14:52:52
You can turn it on by default in common/host.c (my commit: https://github.com/shayneholmes/tmk_keyboard/commit/b8375a0)

The main reason not to is that it breaks compatibility with some implementations, like your BIOS.
Title: Re: TMK keyboard firmware
Post by: hasu on Mon, 03 March 2014, 17:32:57
Thanks guys.
I didn't find NKRO is not documented, I'll fix it some later. And filed the issue.

https://github.com/tmk/tmk_keyboard/issues/100
https://github.com/tmk/tmk_keyboard/wiki/FAQ#wiki-nkro-doesnt-work
Title: Re: TMK keyboard firmware
Post by: bcg on Mon, 03 March 2014, 23:04:13
Ok, I have a question here.  Fair warning I am a total programming nooblet.  While I realize it is a totally different hardware architecture and possibly software architecture, but how difficult would it be to port this over to work on a Teensy 3.0 or 3.1?

Probably not TOO difficult, but definitely tedious.  PJRC has already ported some of the Arduino libraries so the AVR to ARM must be at least somewhat feasible... but there are a lot of things in TMK firmware that are AVR specific so you would have to account for those.  The USB stack would be completely different too, Teensy 3.x doesn't have hardware USB AFAIK and the libraries that TMK uses probably won't work
Title: Re: TMK keyboard firmware
Post by: Melvang on Mon, 03 March 2014, 23:18:55
Ok, I have a question here.  Fair warning I am a total programming nooblet.  While I realize it is a totally different hardware architecture and possibly software architecture, but how difficult would it be to port this over to work on a Teensy 3.0 or 3.1?

Probably not TOO difficult, but definitely tedious.  PJRC has already ported some of the Arduino libraries so the AVR to ARM must be at least somewhat feasible... but there are a lot of things in TMK firmware that are AVR specific so you would have to account for those.  The USB stack would be completely different too, Teensy 3.x doesn't have hardware USB AFAIK and the libraries that TMK uses probably won't work

Gotcha thanks.  Couple other questions.
1.  With the pins on the 2.0 using the 32U4 chip is the number of pins on the board limited by the chip? 
2.  Would this firmware be compatible with the Teensy++ using the AT90USB1286 8 bit AVR 16 MHz chip? 
3.  Is the TMK firmware capable of outputting signal for HDD activity LED?
Title: Re: TMK keyboard firmware
Post by: hasu on Mon, 03 March 2014, 23:42:40
1. Circuit schematic or datasheet will answer you.. https://www.pjrc.com/teensy/schematic.html
2. YES
3. NO

EDIT: HaaTa's firmware supports Teensy3, look into if you are interested.
https://gitorious.org/kiibohd-controller
Title: Re: TMK keyboard firmware
Post by: Melvang on Tue, 11 March 2014, 01:03:54
1. Circuit schematic or datasheet will answer you.. https://www.pjrc.com/teensy/schematic.html
2. YES
3. NO

EDIT: HaaTa's firmware supports Teensy3, look into if you are interested.
https://gitorious.org/kiibohd-controller

Thanks for that info there.  One more quick question. 

Is it possible for the Teensy 2.0 or the ++2.0 to due a keyboard matrix and USB pass through for one extra port to facilitate plugging in a mouse?

The reason I ask is because I have an AEK II that I want to mod into teensy powered but I want to keep all the original functionality of plugging the mouse into the keyboard and having it pass through to the PC.  Or would I need to add a USB hub inside the keyboard and just plug the Teensy into one port with the Mouse into the other port?
Title: Re: TMK keyboard firmware
Post by: clickclack123 on Tue, 11 March 2014, 19:28:50
Thanks for that info there.  One more quick question. 

Is it possible for the Teensy 2.0 or the ++2.0 to due a keyboard matrix and USB pass through for one extra port to facilitate plugging in a mouse?

The reason I ask is because I have an AEK II that I want to mod into teensy powered but I want to keep all the original functionality of plugging the mouse into the keyboard and having it pass through to the PC.  Or would I need to add a USB hub inside the keyboard and just plug the Teensy into one port with the Mouse into the other port?

I'd be very surprised if the teensy was capable of this. The hub is your best solution IMO.
Title: Re: TMK keyboard firmware
Post by: strict on Tue, 11 March 2014, 21:58:54
Hi,

I am assembling a tenkeyless keyboard with a matrix:
Show Image
(http://i297.photobucket.com/albums/mm228/johnny88_bucket/2014-02-16110825.jpg)


Show Image
(http://i297.photobucket.com/albums/mm228/johnny88_bucket/2014-02-22202632.jpg)


and now its time to program the controller. i have a Teensy 2.0 and was thinking of uploading the phantom teensy firmware.
Is it compatible with this type of keyboards? (i've tried it and had no luck)
What do you recommend?

Are those ... futaba switches??
Title: Re: TMK keyboard firmware
Post by: jacobolus on Tue, 11 March 2014, 22:32:10
Is it possible for the Teensy 2.0 or the ++2.0 to due a keyboard matrix and USB pass through for one extra port to facilitate plugging in a mouse?
Just use the USB hub. You could probably figure out a way to get it to work otherwise, but it’s way more trouble than it’s worth.
Title: Re: TMK keyboard firmware
Post by: Melvang on Tue, 11 March 2014, 22:36:24
Is it possible for the Teensy 2.0 or the ++2.0 to due a keyboard matrix and USB pass through for one extra port to facilitate plugging in a mouse?
Just use the USB hub. You could probably figure out a way to get it to work otherwise, but it’s way more trouble than it’s worth.

Yeah, that's what I was figuring.  Just take the hub out of whatever case it is in and take the plugs off the PCB and wire up to the pads.
Title: Re: TMK keyboard firmware
Post by: plainbriny on Wed, 26 March 2014, 01:13:35
Thank you for your feedback.
I filed the issue on github. Maybe it is HID spec compliance problem.
Unfortunately I can't fix this in a short time, I'll work on it later when I have a mcuh time.
https://github.com/tmk/tmk_keyboard/issues/93

Hi, along my attempt to make trackpoint working in my ergodox, I found in the firmware ported by cub, the Makefile missing a line
Code: [Select]
include $(TOP_DIR)/protocol.mk
After adding this line, lufa is now working, no boot problem as mentioned earlier.
However, I also disabled a lot of functions, like boot magic/console/command/nkro etc. Therefore I can not be sure whether the issue is completely resolved or not.
I will test further later, and report back.

UPDATE:
The issue may be caused by console, because when I comment console, it function normally. Don't know what to check next though, any pointer?
Title: Re: TMK keyboard firmware
Post by: hasu on Wed, 26 March 2014, 19:18:09
Hmm, it is not what I expected, my guess was that keyboard itself has spec conformity problem. Mousekey and NKRO build option are not guitly? I don't know why Console causes the problem at this point. Anyway thank you for reporting back, it is helpful to narrow the problem
Title: Re: TMK keyboard firmware
Post by: metalliqaz on Wed, 26 March 2014, 19:20:18
Hmm, it is not what I expected, my guess was that keyboard itself has spec conformity problem. Mousekey and NKRO build option are not guitly? I don't know why Console causes the problem at this point. Anyway thank you for reporting back, it is helpful to narrow the problem

His PC's firmware could be software that's out of spec, for all we know.
Title: Re: TMK keyboard firmware
Post by: plainbriny on Wed, 26 March 2014, 20:06:40
Hmm, it is not what I expected, my guess was that keyboard itself has spec conformity problem. Mousekey and NKRO build option are not guitly? I don't know why Console causes the problem at this point. Anyway thank you for reporting back, it is helpful to narrow the problem

His PC's firmware could be software that's out of spec, for all we know.

I only comment out console, so NKRO and mousekey supports are included.

And it is true that perhaps the PC firmware caused all these strange behavior. However there's currently no updates for the firmware and I don't expect the manufacturer (asus) will provide fix for my keyboard.

Anyway, thanks for the great firmware and I really appreciate all your help.
Title: Re: TMK keyboard firmware
Post by: Melvang on Mon, 31 March 2014, 23:18:00
When using this firmware to do a small 3x3 matrix what do I put into this section for the unused ports?  Currently I am using ports B5 B6 and F7 for cols 0, 1, and 2 respectively and pins D0, D1, and D2 for rows 0, 1, and 2 respectively?

More
Code: [Select]
/* Column pin configuration
 * col: 0   1   2
 * pin: B5  B6  F7  (Rev.A)
 */
static void  init_cols(void)
{
    // Input with pull-up(DDR:0, PORT:1)
    DDRF  &= ~(1<<7);
    PORTF |=  (1<<7);
    DDRE  &= ~(1<<0);
    PORTE |=  (1<<0);
    DDRD  &= ~(1<<0);
    PORTD |=  (1<<0);
    DDRC  &= ~(1<<7 | 1<<6);
    PORTC |=  (1<<7 | 1<<6);
    DDRB  &= ~(1<<6 | 1<<5);
    PORTB |=  (1<<6 | 1<< 5);
}

static matrix_row_t read_cols(void)
{
    return (PINF&(1<<0) ? 0 : (1<<0)) |
           (PINF&(1<<1) ? 0 : (1<<1)) |
           (PINE&(1<<6) ? 0 : (1<<2)) |
           (PINC&(1<<7) ? 0 : (1<<3)) |
           (PINC&(1<<6) ? 0 : (1<<4)) |
           (PINB&(1<<6) ? 0 : (1<<5)) |
           (PIND&(1<<4) ? 0 : (1<<6)) |
           (PINB&(1<<1) ? 0 : (1<<7)) |
           ((PINB&(1<<0) && PINB&(1<<7)) ? 0 : (1<<) |     // Rev.A and B
           (PINB&(1<<5) ? 0 : (1<<9)) |
           (PINB&(1<<4) ? 0 : (1<<10)) |
           (PIND&(1<<7) ? 0 : (1<<11)) |
           (PIND&(1<<6) ? 0 : (1<<12)) |
           (PINB&(1<<3) ? 0 : (1<<13));
}

Edit:

Ok I got past that part and now I am stuck at the part of building the actual keympa in keymap_common.h.  I am using Matt3o's tutorial found here (http://deskthority.net/workshop-f7/how-to-build-your-very-own-keyboard-firmware-t7177.html#p141386)  Here is a piece of the code I have now.

Code: [Select]
/* GH60 keymap definition macro
 * K2C, K31 and  K3C are extra keys for ISO
 */
#define KEYMAP( \
    K00, K01, K02, \
    K10, K11, K12, \
    K20, K21, K22, \
    ) { \
    { KC_##K00, KC_##K01, KC_##K02 }, \
    { KC_##K10, KC_##K11, KC_##K12 }, \
    { KC_##K20, KC_##K21, KC_##K22 }, \
   
}

/* ANSI valiant. No extra keys for ISO */
#define KEYMAP_ANSI( \
    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,      K2D, \
    K30, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B,           K3D, \
    K40, K41, K42,           K45,                     K4A, K4B, K4C, K4D  \
) 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, NO,  K2D, \
    K30, NO,  K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, NO,  K3D, \
    K40, K41, K42,           K45,                NO,  K4A, K4B, K4C, K4D  \
)


#define KEYMAP_HHKB( \
    K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D, K49,\
    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,      K2D, \
    K30, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B,      K3D, K3C, \
    K40, K41, K42,           K45,                     K4A, K4B, K4C, K4D  \
) 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, NO,  K2D, \
    K30, NO,  K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3C, K3D, \
    K40, K41, K42,           K45,                K49, K4A, K4B, K4C, K4D  \
)

#endif

I realize that this is probably childs play for you guys but this is my first real programming experience.  Just need to know what I need to do from here?  I am in the middle of the "Defining the matrix" section in Part 2.
Title: Re: TMK keyboard firmware
Post by: zeroni13 on Wed, 02 April 2014, 00:50:57
I just got the teensy controller working with the TMK FW and I love how easy it is to use, but i came across a strange keycode. What does KC_MEDIA_SELECT do? I did not include it in my layout because I could not figure out what it was or did.
Title: Re: TMK keyboard firmware
Post by: jacobolus on Wed, 02 April 2014, 05:10:15
I just got the teensy controller working with the TMK FW and I love how easy it is to use, but i came across a strange keycode. What does KC_MEDIA_SELECT do? I did not include it in my layout because I could not figure out what it was or did.
Pretty sure it’s for something like a TV remote, where you want to choose between the FM tuner, the DVD player, and the cable box.
Title: Re: TMK keyboard firmware
Post by: jacobolus on Wed, 02 April 2014, 05:30:58
Melvang: I don’t understand what you’re trying to do and what you’re getting stuck on.
Title: Re: TMK keyboard firmware
Post by: zeroni13 on Wed, 02 April 2014, 05:32:44
I just got the teensy controller working with the TMK FW and I love how easy it is to use, but i came across a strange keycode. What does KC_MEDIA_SELECT do? I did not include it in my layout because I could not figure out what it was or did.
Pretty sure it’s for something like a TV remote, where you want to choose between the FM tuner, the DVD player, and the cable box.
So it's totally useless on a computer then, thanks.
Title: Re: TMK keyboard firmware
Post by: jacobolus on Wed, 02 April 2014, 06:16:45
So it's totally useless on a computer then, thanks.
Well, all of these keys depend on operating system / other software support. Some computers might interpret “media select” to do something useful?

Keep in mind, USB and similar specs were designed to meet lots of different use cases, so there’s lots of stuff in there that’s not used by every device / system.
Title: Re: TMK keyboard firmware
Post by: zeroni13 on Wed, 02 April 2014, 06:36:22
Well, all of these keys depend on operating system / other software support. Some computers might interpret “media select” to do something useful?

Keep in mind, USB and similar specs were designed to meet lots of different use cases, so there’s lots of stuff in there that’s not used by every device / system.
Yeah, but I have no use for it then, I only use VOLD, VOLU, MUTE, MPLY, MSTP, MNXT and MPRV.

Anyway, does anyone know why  MS_U, MS_D, MS_L, MS_R, BTN1 and BTN2 doesn't work? I tried to map the mouse movements to WASD and the mouse buttons to Q and E trough the FN layer, but it doesn't work. Any help to get on this?
Title: Re: TMK keyboard firmware
Post by: plainbriny on Wed, 02 April 2014, 06:57:25
Did you enable MOUSEKEY in your Makefile?
Code: [Select]
MOUSEKEY_ENABLE = yes # Mouse keys
Title: Re: TMK keyboard firmware
Post by: zeroni13 on Thu, 03 April 2014, 01:17:52
Did you enable MOUSEKEY in your Makefile?
Code: [Select]
MOUSEKEY_ENABLE = yes # Mouse keys
It was enabled, but commented out, now it works! Thanks! =D
Title: Re: TMK keyboard firmware
Post by: clickclack123 on Thu, 03 April 2014, 08:21:43
It was enabled, but commented out, now it works! Thanks! =D

How can it be enabled if it is commented out?  :-X
Title: Re: TMK keyboard firmware
Post by: metalliqaz on Thu, 03 April 2014, 08:28:31
It was enabled, but commented out, now it works! Thanks! =D

How can it be enabled if it is commented out?  :-X

We all understand what he meant.
Title: Re: TMK keyboard firmware
Post by: sean4star on Thu, 03 April 2014, 14:10:06
Can I get some help on the led and backlight code?  I have 3 main questions:

1. I don't understand what the difference is between |= and &= or what the ~ is doing.  Sorry, I'm a programming noob...
Code: [Select]
    if (usb_led & (1<<USB_LED_CAPS_LOCK)) {
        DDRD |= (1<<6);
        PORTD |= (1<<6);
    } else {
        DDRD |= (1<<6);
        PORTD &= ~(1<<6);
    }
And what is Hi-Z?  I was assuming output high and output low just mean 5V or 0V, right?


2. And I was only able to find 1 backlight example in the kmac project folder.
Code: [Select]
void backlight_set(uint8_t level)
{
    // Set as output.
    DDRB |= (1<<1) | (1<<2) | (1<<3) | (1<<4);
    DDRD |= (1<<7);

    // F-row
    if(level & (1<<0))
    {
        PORTB |= (1<<1);
    }
    else
    {
        PORTB &= ~(1<<1);
    }
    // WASD
    if(level & (1<<1))
    {
        PORTB &= ~(1<<4);
        PORTB &= ~(1<<2);
        PORTB &= ~(1<<3);
        PORTD &= ~(1<<7);
    }
    else
    {
        PORTB |= (1<<4);
        PORTB |= (1<<2);
        PORTB |= (1<<3);
        PORTD |= (1<<7);
    }
}

The syntax is obviously similar to the led code, but what does this do?
Code: [Select]
if(level & (1<<1))
How many "levels" are there?


3. And lastly, is it possible to use
Code: [Select]
backlight_toggle()as part of a user defined action function?  Does anything go in the parenthesis?


Thanks for all the help!
Title: Re: TMK keyboard firmware
Post by: metalliqaz on Thu, 03 April 2014, 15:55:14
If you're not a programmer, you may want to look into an 'easier' option ...
Title: Re: TMK keyboard firmware
Post by: wuqe on Thu, 03 April 2014, 16:59:31
Whew, that's a lot of questions! For starters, check out Bitwise operations in C on Wikipedia (https://en.wikipedia.org/wiki/Bitwise_operations_in_C).

I'm not familiar with this part of TMK's codebase, so my help will have to stop here.
Title: Re: TMK keyboard firmware
Post by: clickclack123 on Thu, 03 April 2014, 17:02:01
It was enabled, but commented out, now it works! Thanks! =D

How can it be enabled if it is commented out?  :-X

We all understand what he meant.

Yeah, I was just being a pedant. This is a geek forum, right?

Whew, that's a lot of questions! For starters, check out Bitwise operations in C on Wikipedia (https://en.wikipedia.org/wiki/Bitwise_operations_in_C).

I'm not familiar with this part of TMK's codebase, so my help will have to stop here.

Haha I was linking to that myself, and got the message "Warning - while you were typing a new reply has been posted. You may wish to review your post."

I don't know if that will solve sean4star's problems, but it's a good start...

1. I don't understand what the difference is between |= and &= or what the ~ is doing.  Sorry, I'm a programming noob...
Code: [Select]
    if (usb_led & (1<<USB_LED_CAPS_LOCK)) {
        DDRD |= (1<<6);
        PORTD |= (1<<6);
    } else {
        DDRD |= (1<<6);
        PORTD &= ~(1<<6);
    }

Well I'm no expert either, but << is a bitwise left shift, so (1<<6) means take a binary 1 and shift it to the left 6 places, ie binary 1000000.

|= is a compound operator, basically a shortcut. | means OR. "DDRD |= (1<<6);" is the same as "DDRD = (DDRD | (1<<6));", which OR's each bit of DDRD with the corresponding bit of "(1<<6)".

DDRD is the direction for the pins on Port D, so "DDRD |= (1<<6);" makes sure that pin 6 on Port D is set as an output, then "PORTD |= (1<<6);" actually sets pin 6 on port D high, which lights the LED connected to pin 6 on port D.

~ means invert, so "PORTD &= ~(1<<6);" sets pin 6 on port D low, which will turn off the LED.

I'm not super confident with bitwise stuff myself, I mostly play around with java.
Title: Re: TMK keyboard firmware
Post by: abjr on Thu, 03 April 2014, 17:14:11
1. I don't understand what the difference is between |= and &= or what the ~ is doing.  Sorry, I'm a programming noob...

Try looking at this: http://en.wikipedia.org/wiki/Bitwise_operations_in_C
Title: Re: TMK keyboard firmware
Post by: sean4star on Thu, 03 April 2014, 17:19:24
Thanks guys!  Starting with your links I eventually found this:

https://en.wikipedia.org/wiki/Bit_manipulation (https://en.wikipedia.org/wiki/Bit_manipulation)
It has a pretty clear explanation of |= and &= in the last section.

And sorry about the big question dump.  It just felt like the questions all flowed together...I'll try a few things and post back here if I still have questions.
Title: Re: TMK keyboard firmware
Post by: clickclack123 on Thu, 03 April 2014, 17:40:50
Thanks guys!  Starting with your links I eventually found this:

https://en.wikipedia.org/wiki/Bit_manipulation (https://en.wikipedia.org/wiki/Bit_manipulation)
It has a pretty clear explanation of |= and &= in the last section.

And sorry about the big question dump.  It just felt like the questions all flowed together...I'll try a few things and post back here if I still have questions.

I just edited my previous answer with an explanation of how I understand the LED code works.

I assume that an expert will correct me if I've made any mistakes.
Title: Re: TMK keyboard firmware
Post by: sean4star on Fri, 04 April 2014, 00:12:51
Thanks!  I also found this:
http://www.pjrc.com/teensy/pins.html (http://www.pjrc.com/teensy/pins.html)

I was able to get the LED's for CAPS and NUM Lock to work.  For some reason Scroll Lock is being stubborn and won't work even though I'm setting it up the same as the others...

Backlight is also working now too!  It helps knowing that my config file needed BACKLIGHT_ENABLE.  The template file I used didn't have this in it to start with so I didn't know it was an option...Once I added that it finally started to work.


I created my own ACTION_FUNCTION_TAP key to hijack the backlight.  Now, when I toggle on my Fn layer it also toggles on the backlight LED, so it's acting like an indicator!  I love this firmware.  You can make it do just about anything!
Title: Re: TMK keyboard firmware
Post by: Melvang on Fri, 04 April 2014, 00:30:33
Now if I could get mine to work.  Don't want to muddle this thread up with tons of newbie questions and such so I will post a link to my thread.

http://geekhack.org/index.php?topic=56751.0
Title: Re: TMK keyboard firmware
Post by: zeroni13 on Fri, 04 April 2014, 01:49:21
When i found out that I only had 6KRO I figured out that I could just do
Code: [Select]
bool keyboard_nkro = true; in "host.c" and it worked, but i see now that I can enable it with Magic + N. What key is the Magic key? Is it something that is predefined or is it something that you define yourself? How do i use this Magic key?

Edit:

So i found this:
Code: [Select]
/* key combination for command */
#define IS_COMMAND() ( \
    keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \
)

#endif

That means that I have to press LSHIFT and RSHIFT at the same time to activate the magic key?
So if I want to enable NKRO I have to press LSHIFT + RSHIFT + N is that right?
Title: Re: TMK keyboard firmware
Post by: hasu on Fri, 04 April 2014, 04:31:12
U are right.
Also see this.
https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
Title: Re: TMK keyboard firmware
Post by: zeroni13 on Fri, 04 April 2014, 05:10:29
So if I change it to be:

Code: [Select]
keyboard_report->mods == (MOD_BIT(KC_HOME) | MOD_BIT(KC_PGUP)) \
It would allow me to use HOME + PGUP as Magic?

Edit:
Magic works with LSHIFT and RSHIFT, When i change it to HOME + PGUP it doesn't work.
Maybe I should wait until i actually mount my keyswitches so I can properly puch the buttons.
Title: Re: TMK keyboard firmware
Post by: wuqe on Fri, 04 April 2014, 16:10:20
The mods in that code snippet need to actually be mods, i.e. Ctrl, Alt, Shift, or Gui keys. Pick any combination. :)
Title: Re: TMK keyboard firmware
Post by: zeroni13 on Sat, 05 April 2014, 05:43:29
The mods in that code snippet need to actually be mods, i.e. Ctrl, Alt, Shift, or Gui keys. Pick any combination. :)
Wow, that actually makes much more sense now.
It works now, thanks!

Any way to use other keys?
Title: Re: TMK keyboard firmware
Post by: plainbriny on Sat, 05 April 2014, 06:08:20
Don't know whether this would work, but maybe you can try
Code: [Select]
ACTION_MODS_TAP_KEY(MOD_RSFT, KC_GRV);
This will make the grave key (`) work as right shift.

I think it may be even possible to use something like this:
Code: [Select]
ACTION_MODS_TAP_KEY(MOD_RSFT | MOD_LSFT, KC_HOME);
To send both right and left shift when you hold HOME.

However, I didn't try these myself, don't know whether they will work as expected.

https://github.com/tmk/tmk_keyboard/blob/master/doc/keymap.md
Title: Re: TMK keyboard firmware
Post by: abjr on Mon, 07 April 2014, 13:04:32
I've wired up a really tiny keyboard on a breadboard and am trying to see if I can have 4 layers with only 2 function keys. I'm not sure if I missed it in the documentation somewhere, but is it possible to do something like this?

none         -> layer 0 (default)
Fn0           -> layer 1
Fn1           -> layer 2
Fn0 & Fn1 -> layer 3

Thanks.
Title: Re: TMK keyboard firmware
Post by: zeroni13 on Mon, 07 April 2014, 14:50:02
I'm having some troubles here, my FN2 button is not activating the layer. FN2 activates layer 3 right?

So if I have 4 layers (0-3) and I want to activate the media keys in layer 3 I need to use FN2 right?

Here is my keymap_iso.h : https://drive.google.com/file/d/0B0Hi55n4CaCKdjMydWdwcFlmcXc

Edit: Got it working using FN0, but I'm kinda confused now, why does this work? o.o
Title: Re: TMK keyboard firmware
Post by: wuqe on Mon, 07 April 2014, 15:09:52
So, in this code...

static const uint16_t PROGMEM fn_actions[] = {
    ACTION_LAYER_MOMENTARY(3),               // FN2
};


fn_actions[] is really just an array, and the first item is number zero. Even though you have a comment saying FN2, that first item is still FN0: the compiler doesn't even read that comment. If you move the actions around in the list, you need to update the comments accordingly, for your own sanity!
Title: Re: TMK keyboard firmware
Post by: DamienG on Mon, 07 April 2014, 15:11:57
Here's my TMK that I branched to add a few new features:
https://github.com/damieng/tmk_keyboard/commits/master

[)amien
Title: Re: TMK keyboard firmware
Post by: zeroni13 on Mon, 07 April 2014, 15:34:03
So, in this code...

static const uint16_t PROGMEM fn_actions[] = {
    ACTION_LAYER_MOMENTARY(3),               // FN2
};


fn_actions[] is really just an array, and the first item is number zero. Even though you have a comment saying FN2, that first item is still FN0: the compiler doesn't even read that comment. If you move the actions around in the list, you need to update the comments accordingly, for your own sanity!
Yeah, yeah, I know the comment's doesn't do anything. My first guess on how it worked was actually what you said, I just wanted to confirm it.
And thank you for reminding me of that comment, totally forgot to change that, haha.
Title: Re: TMK keyboard firmware
Post by: hasu on Mon, 07 April 2014, 20:32:52
I've wired up a really tiny keyboard on a breadboard and am trying to see if I can have 4 layers with only 2 function keys. I'm not sure if I missed it in the documentation somewhere, but is it possible to do something like this?

none         -> layer 0 (default)
Fn0           -> layer 1
Fn1           -> layer 2
Fn0 & Fn1 -> layer 3

Thanks.



abjr, yes it is possible.

In fact you can define five layers.
none: layer0
KeyA: layer1
KeyB: layer2
KeyA+B: layer3
KeyB+A: layer4



In tmk layer action is essentially a bit operation of 'layer_state' variable. Each layer has own bit in the variable and it indicates current state of the layer. For example:

Code: [Select]
Layer   Layer bit
---------------------------------
L0      000x   (default layer)
L1      001x
L2      01xx
L3      1xxx
0: off, 1: on, x: dont' care

See action_layer.c, action_code.h and action.c in common directory if documentation is not enough.

Apparently key has down and up event but note that these evnents do not necessarily occur in same layer. In particular 'layer switcing' key will have down and up envent on different layers.


You can define your keymap in following four ways at least. Each way has a bit different behavior, so you may want to select and combinate them.

1) you can define like this:
Code: [Select]
       |KeyA                |KeyB
Layer  |Down    Up          |Down   Up
-------+--------------------+--------------------
L0     |L1_on   N/A         |L2_on  N/A
L1     |N/A     L1_off      |L3_on  N/A
L2     |L4_on   N/A         |N/A    L2_off
L3     |N/A     L1_off      |N/A    L3_off
L4     |N/A     L4_off      |N/A    L2_off

Fn      Press   Relese      Action
---------------------------------------------------------------
FN0     L1_on   ---         ACTION_LAYER_ON(1, ON_PRESS)
FN1     L2_on   ---         ACTION_LAYER_ON(2, ON_PRESS)
FN2     L3_on   ---         ACTION_LAYER_ON(3, ON_PRESS)
FN3     L4_on   ---         ACTION_LAYER_ON(4, ON_PRESS)
FN4     ---     L1_off      ACTION_LAYER_OFF(1, ON_RELESE)
FN5     ---     L2_off      ACTION_LAYER_OFF(2, ON_RELESE)
FN6     ---     L3_off      ACTION_LAYER_OFF(3, ON_RELESE)
FN7     ---     L4_off      ACTION_LAYER_OFF(4, ON_RELESE)

Keymap          KeyA    KeyB
----------------------------
KEYMAP_L0:      FN0     FN1
KEYMAP_L1:      FN4     FN2
KEYMAP_L2:      FN3     FN5
KEYMAP_L3:      FN4     FN6
KEYMAP_L4:      FN7     FN5



2) Using ACTION_LAYER_ON_OFF you will be able to omit some Fn keys.
Code: [Select]
Fn      Press   Relese      Action
---------------------------------------------------------------
FN0     L1_on   L1_off      ACTION_LAYER_ON_OFF(1)
FN1     L2_on   L2_off      ACTION_LAYER_ON_OFF(2)
FN2     L3_on   L3_off      ACTION_LAYER_ON_OFF(3)
FN3     L4_on   L4_off      ACTION_LAYER_ON_OFF(4)

Keymap          KeyA    KeyB
----------------------------
KEYMAP_L0:      FN0     FN1
KEYMAP_L1:      FN0     FN2
KEYMAP_L2:      FN3     FN1
KEYMAP_L3:      FN0     FN2
KEYMAP_L4:      FN3     FN1


3) Or using ACTION_LAYER_SET you can define layer transition table instead of bit operation.
Code: [Select]
       |KeyA                |KeyB
Layer  |Down    Up          |Down   Up
-------+--------------------+--------------------
L0     |to_L1   N/A         |to_L2  N/A
L1     |N/A     to_L0       |to_L3  N/A
L2     |to_L3   N/A         |N/A    to_L0
L3     |N/A     to_L2       |N/A    to_L1


Fn      Press   Relese      Action
---------------------------------------------------------------
FN0     to_L1               ACTION_LAYER_SET(1, ON_PRESS)
FN1     to_L2               ACTION_LAYER_SET(2, ON_PRESS)
FN2     to_L3               ACTION_LAYER_SET(3, ON_PRESS)
FN3     ---     to_L0       ACTION_LAYER_SET(0, ON_RELESE)
FN4     ---     to_L1       ACTION_LAYER_SET(1, ON_RELESE)
FN5     ---     to_L2       ACTION_LAYER_SET(2, ON_RELESE)

Keymap          KeyA    KeyB
----------------------------
KEYMAP_L0:      FN0     FN1
KEYMAP_L1:      FN3     FN2
KEYMAP_L2:      FN2     FN3
KEYMAP_L3:      FN5     FN4

4) Also you can use ACTION_LAYER_SET_CLEAR
Code: [Select]
       |KeyA                |KeyB
Layer  |Down    Up          |Down   Up
-------+--------------------+--------------------
L0     |to_L1   N/A         |to_L2  N/A 
L1     |N/A     to_L0       |to_L3  N/A 
L2     |to_L3   N/A         |N/A    to_L0
L3     |N/A     to_L0       |N/A    to_L0


Fn      Press   Relese      Action
---------------------------------------------------------------
FN0     to_L1   to_L0       ACTION_LAYER_SET_CLEAR(1)
FN1     to_L2   to_L0       ACTION_LAYER_SET_CLEAR(2)
FN2     to_L3   to_L0       ACTION_LAYER_SET_CLEAR(3)


Keymap          KeyA    KeyB
----------------------------
KEYMAP_L0:      FN0     FN1
KEYMAP_L1:      FN0     FN2
KEYMAP_L2:      FN2     FN1
KEYMAP_L3:      FN2     FN2

Not tested but it should work.
Title: Re: TMK keyboard firmware
Post by: wuqe on Mon, 07 April 2014, 21:20:52
Gee hasu, thanks! That there is a gold mine of layer-tinkering info. I did my similar functionality with ACTION_FUNCTION() and code behind it. The plus of doing it in code is that you can get by with just the one FNx action. The negative to it is complexity, and you have to mess with the layer_on() methods, which feels a little dangerous.  :aiee:

My relevant commit:

https://github.com/shayneholmes/tmk_keyboard/commit/5eaff58a11052bd6446825d59e195ae07efa5723
Title: Re: TMK keyboard firmware
Post by: clickclack123 on Tue, 08 April 2014, 01:15:35
Wow! Talk about flexible (and complicated)!

That's five different ways to achieve the same layer-switching result!

Thanks hasu and wuqe.
Title: Re: TMK keyboard firmware
Post by: hasu on Tue, 08 April 2014, 02:54:33
Haha, yes it is complicated and confusing but flexible.
This is really trade-off and we need good compromise :D


Title: Re: TMK keyboard firmware
Post by: hasu on Tue, 08 April 2014, 03:09:05
So, in this code...

static const uint16_t PROGMEM fn_actions[] = {
    ACTION_LAYER_MOMENTARY(3),               // FN2
};


fn_actions[] is really just an array, and the first item is number zero. Even though you have a comment saying FN2, that first item is still FN0: the compiler doesn't even read that comment. If you move the actions around in the list, you need to update the comments accordingly, for your own sanity!

Exactly.

Luckily we are using great GCC, so with taking advantage of its C language extenstion we can write like this instead of keeping comment updated.

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


MAY GCC BE WITH YOU
Title: Re: TMK keyboard firmware
Post by: wuqe on Tue, 08 April 2014, 09:39:15
So, in this code...

static const uint16_t PROGMEM fn_actions[] = {
    ACTION_LAYER_MOMENTARY(3),               // FN2
};


fn_actions[] is really just an array, and the first item is number zero. Even though you have a comment saying FN2, that first item is still FN0: the compiler doesn't even read that comment. If you move the actions around in the list, you need to update the comments accordingly, for your own sanity!

Exactly.

Luckily we are using great GCC, so with taking advantage of its C language extenstion we can write like this instead of keeping comment updated.

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


MAY GCC BE WITH YOU

:jawdrop: Noice!
Title: Re: TMK keyboard firmware
Post by: abjr on Tue, 08 April 2014, 10:01:59
abjr, yes it is possible.

Wow. Thank you for such a detailed explanation and such great firmware! Let's hope I can figure out how to implement at least one of those options :)

-abjr
Title: Re: TMK keyboard firmware
Post by: Melvang on Tue, 08 April 2014, 10:10:23
Any suggestions for getting this to compile on Windows 8.1?  Winavr seems to be broke on it.  I keep getting application failed to load error but when I compiled on the wifes computer with windows 7 it came out just fine.
Title: Re: TMK keyboard firmware
Post by: wuqe on Tue, 08 April 2014, 11:47:37
I have it running on Windows 8.1, using WinAVR-20100110; can't say for sure exactly how I got it that way, since I set it up almost a year ago. Nonetheless, it can work! :)

Without a specific error message, it's hard to guess, but my first instinct is .NET dependencies, since those don't always get installed out of the box.
Title: Re: TMK keyboard firmware
Post by: Melvang on Tue, 08 April 2014, 11:55:39
When I go to the command prompt to make I get an error message that is a standard windows pop up error with number 0xc0000142 and something about the application failed to load.  I get the same issue with running cmd as admin.
Title: Re: TMK keyboard firmware
Post by: wuqe on Tue, 08 April 2014, 12:46:49
Hmm, the error code sounds familiar... :looking:

Aha!

http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&p=1113986

Links to http://www.madwizard.org/download/electronics/msys-1.0-vista64.zip, where you can get an updated msys.bin file. Copy it to C:\WinAVR-20100110\utils\bin, and presto!

I think this has to do with 64 bit Windows not playing nicely by default.
Title: Re: TMK keyboard firmware
Post by: Smasher816 on Sun, 13 April 2014, 13:15:13
Hey Hasu, hopefully you can help me with this little issue.

I started with the normal keymap_hhkb.c and have been adding various features. I tried adding the parentheses dual role to the shift keys, so I copied code from your keymap_hasu.c file. After I compile the new code pressing the shift keys does make a "(" or ")" correctly, but I cannot write any shifted characters. Ex: Shift+a does nothing when it should make a capital "A".

I changed the shift keys to FN3 and FN4. Here is the relevant code:
http://ix.io/bEu
Title: Re: TMK keyboard firmware
Post by: hasu on Sun, 13 April 2014, 13:44:41
Those macro and action_function implement same feature in two different methods for reference. So you need only either one of the two,  you can remove another.

That action_function has accidentaly temporary test code. This patch will fix your problem.
Code: [Select]
@@ -225,8 +253,7 @@ void action_function(keyrecord_t *record, uint8_t id, uint8_t opt)
             // NOTE: cant use register_code to avoid conflicting with magic key bind
             if (event.pressed) {
                 if (tap.count == 0 || tap.interrupted) {
-                    //add_mods(MOD_BIT(KC_LSHIFT));
-                    layer_on(1);
+                    add_mods(MOD_BIT(KC_LSHIFT));
                 } else {
                     add_mods(MOD_BIT(KC_LSHIFT));
                     add_key(KC_9);
@@ -237,8 +264,7 @@ void action_function(keyrecord_t *record, uint8_t id, uint8_t opt)
                 }
             } else {
                 if (tap.count == 0 || tap.interrupted) {
-                    //del_mods(MOD_BIT(KC_LSHIFT));
-                    layer_off(1);
+                    del_mods(MOD_BIT(KC_LSHIFT));
                 }
             }
             break;
Title: Re: TMK keyboard firmware
Post by: Smasher816 on Sun, 13 April 2014, 14:04:04
Thanks. That fixed it :)

Perhaps that should be fixed online?
Title: Re: TMK keyboard firmware
Post by: Smasher816 on Fri, 18 April 2014, 09:43:36
Thanks. That fixed it :)

Perhaps that should be fixed online?

After using this for a few days I noticed some strange things happening. Luckily I was able to figure out the cause.

I opened up a linux terminal and ran "xkbwatch". If I hold shift and then press a letter then the shift modifier remains on even after releasing the shift key. This causes lots of little annoyances like preventing me from scrolling in chromium or causing mouse clicks to select text. Once I tap the shift any key again then the modifier is cleared and everything works correctly. I'm sure this is due to some error in my implementation of the dual role shift keys you were helping me with earlier.

Edit: I'm not sure if this is the intended behavior but when holding down the shift key the shift modifier is not set until I press another key. After reading the SpaceFN guide I would think that after some time (ex: 500ms) it should be safe to say the key was not tapped and should instead do its held function.
Title: Re: TMK keyboard firmware
Post by: eviltobz on Tue, 22 April 2014, 11:10:54
I've been trying the TMK firmware on my ErgoDox (with thanks to cub-uanic for his initial porting work) and have found an odd problem. With the keyboard (and a mouse) plugged into a simple usb hub then into one of the usb3 ports on my Macbook pro running Mavericks, it seems to be working pretty correctly with fancy things like the keyboard being able to wake the mac from sleeping and whatnot. However, when the usb hub is instead plugged into a usb3(ish) port on my belkin thunderbolt hub and into the mac, the keyboard will work fine until the mac sleeps, but then won't work at all until it is unplugged/replugged. The mouse on the same usb hub is fine, and being a laptop I can obviously wake the pooter with the built-in keyboard, but the dox is as dead as a dodo. With ic07's firmware the keyboard remains usable throughout multiple sleep cycles, but of course loses the TMK features that I was after like the ability to wake the mac itself, full media keys, NKRO etc.

Anyone else seen anything similar? Any ideas about what might be causing the problem or how to fix it?

Title: Re: TMK keyboard firmware
Post by: hasu on Tue, 22 April 2014, 13:39:59
what is "the pooter"?

Pull fixes of issue #114 and #115 from my repository at github and report the result.
Title: Re: TMK keyboard firmware
Post by: AKmalamute on Tue, 22 April 2014, 13:45:30
I'm afraid I can't help you directly, eviltobz, but I can say that it doesn't surprise me. The thunderbolt protocol is different than the USB, so what's going on it TMK's exact usage of the USB protocol is getting lost in the shuffle somehow. But IC07's code (or included libraries? Are you using LUFA or something else that's different between the two?) is doing something different about being a USB device, and the translating hub is better able to keep track of things attached.

 It might be a limitation of the hub, too. I have a USB hub that only works on first detection -- so if I add a keyboard or USB stick to it, it won't show up until I un, re -plug the hub itself regardless of how many times I re-plug my device into the hub.
</shrug>

HTH and good luck.

hasu: 'the pooter' is a phoenetic contraction of "the computer" -- he's typing what he's saying, and you (the reader) are supposed to guess correctly by saying it out loud and realizing "oh! that's what he said."
Title: Re: TMK keyboard firmware
Post by: metalliqaz on Tue, 22 April 2014, 13:50:45
I have run into strange stuff with my own work.  There seems to be a lot of variety in the USB support of various peripherals.  Who knows what assumptions were made, but exotic keyboards tend to confuse them.
Title: Re: TMK keyboard firmware
Post by: hasu on Tue, 22 April 2014, 21:54:28
Smasher816,

That behaviour is intended but the result is not intended :D I'm not a user of that 'Shift/parenthesis' key so that code was almost untested in real typing.

Try this codelet. I think this is nearly what you want. Except for delay(TAPPIG_TERM) before registering Shift.(But I think it is not so problem for normal typing due to a 'trick') This is a limitation of current tmk's dual role key implementation.

Dual role key can be two variants, one whose main role is 'key' and sub role is 'modifier' and vice versa. Tmk's dual role key implementation is optimized for the former and my personal typing habits so that I can place the function on Space, Semicolon and Slash key. Meanwhile you want the latter, unfortunately tmk deosn't offer enough configuration option for you at this time.

Code: [Select]
        case LSHIFT_LPAREN:
            // LShft + tap '('
            if (event.pressed) {
                dprint("P: ");
                if (record->tap.count > 0) {
                    if (record->tap.interrupted) {
                        dprint("tap interrupted\n");
                        record->tap.count = 0;  // ad hoc: cancel tap
                        register_mods(MOD_BIT(KC_LSHIFT));
                    } else {
                        dprint("tap\n");
                        add_weak_mods(MOD_BIT(KC_LSHIFT));
                        send_keyboard_report();
                        register_code(KC_9);
                    }
                } else {
                    dprint("no tap\n");
                    register_mods(MOD_BIT(KC_LSHIFT));
                }   
            } else {
                dprint("R: ");
                if (record->tap.count > 0) {
                    dprint("tap\n");
                    del_weak_mods(MOD_BIT(KC_LSHIFT));
                    send_keyboard_report();
                    unregister_code(KC_9);
                } else {
                    dprint("no tap\n");
                    unregister_mods(MOD_BIT(KC_LSHIFT));
                }   
            }       
            break;
Title: Re: TMK keyboard firmware
Post by: eviltobz on Wed, 23 April 2014, 04:29:38
thanks hasu & AK, and apologies for confusing you with my abuse of language :)

@hasu - i'll give those fixes a go and see what happens.

@AK - and yup, ic07's firmware is based on PJRC, but hasu has said that LUFA is the preferred stack for TMK now. hmmm, mebe I should try compiling it back on the PJRC code as well and see if that has any effect too.
Title: Re: TMK keyboard firmware
Post by: Smasher816 on Wed, 23 April 2014, 17:28:54
Hasu,

That "codelet" works well. Tapping the shift key produces a parentheses and holding sets shift. Writing capital letters works fine and the shift modifier is removed correctly. The only issue I found is - if I tap shift a few times then hold it I will get (((((((((, but that's not too big of a deal and I don't think it will happen in actual use. Thanks for the help :)

Dual role key can be two variants, one whose main role is 'key' and sub role is 'modifier' and vice versa. Tmk's dual role key implementation is optimized for the former and my personal typing habits so that I can place the function on Space, Semicolon and Slash key. Meanwhile you want the latter, unfortunately tmk deosn't offer enough configuration option for you at this time.

Maybe I am confused but I don't see the big difference between the "two variants". Both produce a 'key' when tapped and a 'modifier' when held. Can the "Shift" key not be thought of as a main role "(" key that acts as "LSHIFT" when held? (Similar to the slash key producing a mod when held). Perhaps I don't understand how the main/sub role works and why shift cannot be thought of with a main role key, and sub role modifier.

Hopefully what I said makes some sense.
Title: Re: TMK keyboard firmware
Post by: hasu on Wed, 23 April 2014, 19:00:49
Hasu,

That "codelet" works well. Tapping the shift key produces a parentheses and holding sets shift. Writing capital letters works fine and the shift modifier is removed correctly. The only issue I found is - if I tap shift a few times then hold it I will get (((((((((, but that's not too big of a deal and I don't think it will happen in actual use. Thanks for the help :)

It is what i call "tap and hold repeat" trick. Dual role key essentially can't have normal key repeat function. I usually need that trick and it is useful to me, but may not to others.
Fortunately you can remove this trick with changing the codelet.

And I found it yields unexpected '9' occasionally after repeat like '((((((((9'. You may need this fix; changes keyboard report order.
Code: [Select]
                dprint("R: ");
                if (record->tap.count > 0) {
                    dprint("tap\n");
*                   unregister_code(KC_9);
*                   del_weak_mods(MOD_BIT(KC_LSHIFT));
*                   send_keyboard_report();
                } else {


Quote
Dual role key can be two variants, one whose main role is 'key' and sub role is 'modifier' and vice versa. Tmk's dual role key implementation is optimized for the former and my personal typing habits so that I can place the function on Space, Semicolon and Slash key. Meanwhile you want the latter, unfortunately tmk deosn't offer enough configuration option for you at this time.

Maybe I am confused but I don't see the big difference between the "two variants". Both produce a 'key' when tapped and a 'modifier' when held. Can the "Shift" key not be thought of as a main role "(" key that acts as "LSHIFT" when held? (Similar to the slash key producing a mod when held). Perhaps I don't understand how the main/sub role works and why shift cannot be thought of with a main role key, and sub role modifier.

Hopefully what I said makes some sense.
You are right about general idea of  dual role key. But its implementation and optimization can be varied greately. This codelet is optimzed for mod(main)/key(sub) and you'll be frustrated if it is place on alpha key area. You'll ofetn get 'mod' instead of 'key' despite your intention.

Try to get '(z' *quickly*(like normal typing speed) with your LShift key, you'll get 'Z'. With your custom LShift key you have to press z key *after* releasing LShift key, while in normal typing people press 'z' key *before* releasing 'LShift' key. This is annoyning if you assume your LShift is key'(' intead of mod 'Shift'.

Dual role key is all of compromize and trade-off between 'key' and 'mod'. The two never be consistent with each other at the same time. Optimization is important and it depends on your typing habits.
Title: Re: TMK keyboard firmware
Post by: technomancy on Thu, 24 April 2014, 13:06:25
My apologies if this has been covered elsewhere (it's a long thread), but I wonder if you could explain the reasoning behind using three different ports for inputs along the columns. It also seems strange that you don't read from consecutive pins. Is there some rationale behind the pin layout used? It seems to jump around randomly.
Title: Re: TMK keyboard firmware
Post by: hasu on Thu, 24 April 2014, 14:07:58
Not sure which keyobard you are talking about but the reason is probably the chip or teensy's pinout. See following pictures. Unfortunately pins are not completely consective.
Yes, consective pin usage is easier for programming if possible.
(http://www.pjrc.com/teensy/pinout2a.png)
(http://i.imgur.com/6SXxrZY.png)
Title: Re: TMK keyboard firmware
Post by: eviltobz on Sun, 27 April 2014, 05:05:08
... TMK firmware ... ErgoDox ... thunderbolt hub ... sleep/wake ... dead keyboard ...

... Are you using LUFA or something else that's different between the two?...

Well, I've been able to stick the PJRC build of TMK on and whilst the keyboard still won't wake my mac from sleep mode, the keyboard will continue to work once it has been woken, so it's an improvement :)

I've not had a chance to try pulling hasu's suggested fixes yet to see if that makes a difference to either stack, but it is certainly far more usable now so I'm in less of a rush.
Title: Re: TMK keyboard firmware
Post by: hasu on Mon, 28 April 2014, 03:05:59
eviltobz, if you are using PJRC stack, try this fix.
https://github.com/tmk/tmk_keyboard/issues/121

With this fix I can wake PC several times in a row. Not tested thouroughly but this fix may work for you.
Title: Re: TMK keyboard firmware
Post by: eviltobz on Mon, 28 April 2014, 03:31:10
Thanks hasu :) I'll try to crack open the code soon and see how those fixes all add up.
Title: Re: TMK keyboard firmware
Post by: eviltobz on Tue, 29 April 2014, 02:54:33
Well, I had a go with fix 121, and it did wake the mac back up :) but then the keyboard was completely dead for further typing. and moving my mouse (that's on the same hub) around made weird things happen too :(

I noticed that there are other things that have changed between the version of that file that I have and the current state of it when your fix was applied, so I'll have to spend a bit of time sorting out getting all your fixes & changes merged in so I can test it all properly.
Title: Re: TMK keyboard firmware
Post by: admiralvorian on Fri, 16 May 2014, 12:03:15
Hasu,

That "codelet" works well. Tapping the shift key produces a parentheses and holding sets shift. Writing capital letters works fine and the shift modifier is removed correctly. The only issue I found is - if I tap shift a few times then hold it I will get (((((((((, but that's not too big of a deal and I don't think it will happen in actual use. Thanks for the help :)

Dual role key can be two variants, one whose main role is 'key' and sub role is 'modifier' and vice versa. Tmk's dual role key implementation is optimized for the former and my personal typing habits so that I can place the function on Space, Semicolon and Slash key. Meanwhile you want the latter, unfortunately tmk deosn't offer enough configuration option for you at this time.

Maybe I am confused but I don't see the big difference between the "two variants". Both produce a 'key' when tapped and a 'modifier' when held. Can the "Shift" key not be thought of as a main role "(" key that acts as "LSHIFT" when held? (Similar to the slash key producing a mod when held). Perhaps I don't understand how the main/sub role works and why shift cannot be thought of with a main role key, and sub role modifier.

Hopefully what I said makes some sense.


How can I remove the tap-shift-( functionality completely and set the shift key to a standard LShift?
Title: Re: TMK keyboard firmware
Post by: Smasher816 on Fri, 16 May 2014, 13:27:04
How can I remove the tap-shift-( functionality completely and set the shift key to a standard LShift?

The stock HHKB layout does not have it. However, it's pretty easy to modify the layout.

Replace "FN5" to the left of the Z key with "LSFT". If the right shift is also modded then replace whatever "FN*" it is with "RSFT"
Title: Re: TMK keyboard firmware
Post by: admiralvorian on Fri, 16 May 2014, 16:38:47
I had to modify keymap_hasu.c making changes to keymap_hhkb didn't help, nor did making my own keymap
Title: Re: TMK keyboard firmware
Post by: hasu on Fri, 16 May 2014, 18:36:38
You'll need 'make clean'  when you change 'KEYMAP' option.
Doing 'make clean` before build firmware is always a good habit if you are not sure about 'make' command and TMK build system.

https://github.com/tmk/tmk_keyboard/wiki/FAQ#do-make-clean-before-make
Title: Re: TMK keyboard firmware
Post by: Slavfot on Sun, 18 May 2014, 15:49:55
Hi, i have a phantom keyboard with tmk_firmware.
Is it possible to make the scroll lock led shine when i have layer 2 active?
Title: Re: TMK keyboard firmware
Post by: skebitz on Tue, 27 May 2014, 03:02:05
Hi Hasu! :)

First, thanks a bunch for the TMK firmware! I've been using it on my custom keyboard project. Once you get to know it a bit it's pretty easy peasy, and the documentation is really nice!

I've been using the mouse keys alot, which I really like. Been tweaking the settings some in common/mousekey.h, but it takes time to build and reflash for every tweak. Is it possible to bind keys to be able to tweak these parameters on the fly?

(I've tried ACL0, ACL1 and ACL3 but they don't seem to make any difference)
Title: Re: TMK keyboard firmware
Post by: hasu on Tue, 27 May 2014, 07:02:21
Hi,

I wrote some code for tweak mousekey parameters on the fly but it was not completed. Its interface is very primitive and parameters are not stored in eeprom.

If you built firmware with command and console feature, you can try this in  'hid_listen'.

To get help press magic+'h'. First enter console mode with magic+'c', then push 'm' to mousekey parameter tweak mode.  Select a parameter with number keys and change value with up, down, page up and down. EDIT: to quit the mode push 'q' or ESC twice.

Try changing parameter values and see cursor speed.

Code: [Select]
----- Command Help -----
c:      enter console mode
d:      toggle debug enable
x:      toggle matrix debug
k:      toggle keyboard debug
m:      toggle mouse debug
v:      print device version & info
t:      print timer count
s:      print status
e:      print eeprom config
n:      toggle NKRO
0/F10:  switch to Layer0
1/F1:   switch to Layer1
2/F2:   switch to Layer2
3/F3:   switch to Layer3
4/F4:   switch to Layer4
PScr:   power down/remote wake-up
Caps:   Lock Keyboard(Child Proof)
Paus:   jump to bootloader
                 
                 
----- Console Help -----
ESC/q:  quit     
m:      mousekey
                 
Enter Console Mode
C>               
                 
----- Mousekey Parameters Help -----
ESC/q:  quit     
1:      select mk_delay(*10ms)
2:      select mk_interval(ms)
3:      select mk_max_speed
4:      select mk_time_to_max
5:      select mk_wheel_max_speed
6:      select mk_wheel_time_to_max
p:      print prameters
d:      set default values
up:     increase prameters(+1)
down:   decrease prameters(-1)
pgup:   increase prameters(+10)
pgdown: decrease prameters(-10)
                 
speed = delta * max_speed * (repeat / time_to_max)
where delta: cursor=5, wheel=1
See http://en.wikipedia.org/wiki/Mouse_keys
                 
Enter Mousekey Console
M0>             
                 
----- Mousekey Parameters -----
1: mk_delay(*10ms): 30
2: mk_interval(ms): 50
3: mk_max_speed: 10
4: mk_time_to_max: 20
5: mk_wheel_max_speed: 8
6: mk_wheel_time_to_max: 40
M0> ????         
Quit Mousekey Console
C>               
Quit Console Mode

(While you hold ACL* key mouse cursor move with constant speed.)
Title: Re: TMK keyboard firmware
Post by: skebitz on Tue, 27 May 2014, 07:56:45
Ah, thanks! :)
Title: Re: TMK keyboard firmware
Post by: bitemyweewee on Sat, 31 May 2014, 04:42:53
Heya!

I've been following the guide by matt3o over at deskthority on how to use your code for teensy to build yourself a new keyboard.
What I'm actually doing is converting an old terminal keyboard to usb just by soldering onto it's IC because I believe the protocol is unknown.
Here's the original thread: http://deskthority.net/keyboards-f2/adds-1010-green-alps-teardown-t7984.html


Here's what I've configured so far:

Matrix:
(http://imgur.com/ZphrfCG.jpg)

config.h:
Code: [Select]
/* key matrix size */
#define MATRIX_ROWS 9
#define MATRIX_COLS 13

matrix.c
Code: [Select]
static void  init_cols(void)
{
    // Input with pull-up(DDR:0, PORT:1)
    DDRD  &= ~(1<<1 | 1<<2 | 1<<3 | 1<<4 | 1<<5 | 1<<6 | 1<<7);
    PORTD |=  (1<<1 | 1<<2 | 1<<3 | 1<<4 | 1<<5 | 1<<6 | 1<<7);
    DDRE  &= ~(1<<0 | 1<<1);
    PORTE |=  (1<<0 | 1<<1);
    DDRC  &= ~(1<<0 | 1<<1 | 1<<2 | 1<<3 | 1<<4);
    PORTC |=  (1<<0 | 1<<1 | 1<<2 | 1<<3 | 1<<4);
}

static matrix_row_t read_cols(void)
{
    return (PIND&(1<<1) ? 0 : (1<<0)) |
           (PIND&(1<<2) ? 0 : (1<<1)) |
           (PIND&(1<<3) ? 0 : (1<<2)) |
           (PIND&(1<<4) ? 0 : (1<<3)) |
           (PIND&(1<<5) ? 0 : (1<<4)) |
           (PIND&(1<<7) ? 0 : (1<<5)) |
           (PINE&(1<<0) ? 0 : (1<<6)) |
           //((PINB&(1<<0) && PINB&(1<<7)) ? 0 : (1<<8)) |     // Rev.A and B
           (PINE&(1<<1) ? 0 : (1<<7)) |
           (PINC&(1<<0) ? 0 : (1<<8)) |
           (PINC&(1<<1) ? 0 : (1<<9)) |
           (PINC&(1<<2) ? 0 : (1<<10)) |
           (PINC&(1<<3) ? 0 : (1<<11)) |
           (PINC&(1<<4) ? 0 : (1<<12));
}

/* Row pin configuration
 * row: 0   1   2   3   4
 * pin: D0  D1  D2  D3  D5
 */
static void unselect_rows(void)
{
    // Hi-Z(DDR:0, PORT:0) to unselect
    DDRB  &= ~0b11111111;
    PORTB &= ~0b11111111;
    DDRD  &= ~0b00000001;
    PORTD &= ~0b00000001;
}

static void select_row(uint8_t row)
{
    // Output low(DDR:1, PORT:0) to select
    switch (row) {
        case 0:
            DDRB  |= (1<<0);
            PORTB &= ~(1<<0);
            break;
        case 1:
            DDRB  |= (1<<1);
            PORTB &= ~(1<<1);
            break;
        case 2:
            DDRB  |= (1<<2);
            PORTB &= ~(1<<2);
            break;
        case 3:
            DDRB  |= (1<<3);
            PORTB &= ~(1<<3);
            break;
        case 4:
            DDRB  |= (1<<4);
            PORTB &= ~(1<<4);
            break;
        case 5:
            DDRB  |= (1<<5);
            PORTB &= ~(1<<5);
            break;
        case 6:
            DDRB  |= (1<<6);
            PORTB &= ~(1<<6);
            break;
        case 7:
            DDRB  |= (1<<7);
            PORTB &= ~(1<<7);
            break;
        case 8:
            DDRD  |= (1<<0);
            PORTD &= ~(1<<0);
            break;   
    }
}

led.c:
Code: [Select]
void led_set(uint8_t usb_led)
{
    if (usb_led & (1<<USB_LED_CAPS_LOCK)) {
        // output low
        DDRD |= (1<<6);
        PORTD &= ~(1<<6);
    } else {
        // Hi-Z
        DDRD &= ~(1<<6);
        PORTD &= ~(1<<6);
    }
}

keymap_common.h:
Code: [Select]
#define KEYMAP( \
    K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, \
    K10, K11, K12, K13,      K15, K16, K17, K18, K19, K1A, \
    K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, \
    K30, K31, K32,      K34, K35, K36, K37, K38, K39, K3A, \
    K40, K41, K42, K43, K44, K45, K46, K47,      K49, K4A, \
                                                           K5B, K5C, \
    K60, K61, K62, K63, K64, K65, K66, K67, K68, \
    K70, K71, K72, K73, K74, K75, K76, K77, K78, \
    K80, K81, K82, K83, K84, K85, K86, K87, K88, K89\                                                       
) { \
    { KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07, KC_##K08, KC_##K09, KC_##K0A }, \
    { KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_NO   , KC_##K15, KC_##K16, KC_##K17, KC_##K18, KC_##K19, KC_##K1A }, \
    { KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_##K27, KC_##K28, KC_##K29, KC_##K2A }, \
    { KC_##K30, KC_##K31, KC_##K32, KC_NO   , KC_##K34, KC_##K35, KC_##K36, KC_##K37, KC_##K38, KC_##K39, KC_##K3A }, \
    { KC_##K40, KC_##K41, KC_##K42, KC_##K43, KC_##K44, KC_##K45, KC_##K46, KC_##K47, KC_NO   , KC_##K49, KC_##K4A }, \
    { KC_NO   , KC_NO   , KC_NO   , KC_NO   , KC_NO   , KC_NO   , KC_NO   , KC_NO   , KC_NO   , KC_NO   , KC_NO   , KC_##5B , KC_5C }, \
    { KC_##K60, KC_##K61, KC_##K62, KC_##K63, KC_##K64, KC_##K65, KC_##K66, KC_##K67, KC_##K68 }, \
    { KC_##K70, KC_##K71, KC_##K72, KC_##K73, KC_##K74, KC_##K75, KC_##K76, KC_##K77, KC_##K78 }, \
    { KC_##K80, KC_##K81, KC_##K82, KC_##K83, KC_##K84, KC_##K85, KC_##K86, KC_##K87, KC_##K88, KC_##K89 }, \
}

I don't know what the names are for the extended keys when making a KEYMAP() in the keymap_poker.c file, as the guide's only for 60% keyboards.
I hope I've been as transparent as possible, I'm not sure what other information to include.

Thanks!
Title: Re: TMK keyboard firmware
Post by: hasu on Sat, 31 May 2014, 16:01:13
I think you give enough code and pics, but not sure your problem exactly.

KEYMAP is just a macro or syntax sugar to define keymap array which have keycode each matrix slot.

Read README.md and doc/keymap.md yet?
https://github.com/tmk/tmk_keyboard/blob/master/README.md
https://github.com/tmk/tmk_keyboard/blob/master/doc/keymap.md

And see code of other keyboards like phantom, lightsaber or kmac, they have more keys than gh60.
Title: Re: TMK keyboard firmware
Post by: bitemyweewee on Sun, 01 June 2014, 03:09:47
Thanks for the links,

Here's what I've been able to come up with:
keymap_poker.c:
Code: [Select]
const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
    /* 0: qwerty */
    KEYMAP(KC_0, KC_EQL, KC_MINS, KC_GRV, KC_BSPC, KC_F1, KC_F2, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, \
           KC_O, KC_P, KC_LBRC, KC_RBRC, KC_LGUI, KC_LALT, KC_7, KC_8, KC_9, KC_PMNS, \
           KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, KC_UP, KC_DOWN, KC_P4, KC_P5, KC_P6, KC_COMM, \
           KC_COMM, KC_DOT, KC_SLSH, KC_BSLS, KC_LEFT, KC_RGHT, KC_P1, KC_P2, KC_P3, KC_PENT, KC_ENT, \
           KC_M, KC_N, KC_B, KC_V, KC_C, KC_X, KC_Z, KC_SPC, KC_P0, KC_PDOT, \
           KC_LSFT, KC_LCTL, \
           KC_J, KC_H, KC_G, KC_F, KC_D, KC_S, KC_A, KC_CAPS, KC_DEL, \
           KC_I, KC_U, KC_Y, KC_T, KC_R, KC_E, KC_W, KC_Q, KC_TAB, \
           KC_9, KC_8, KC_7, KC_6, KC_5, KC_4, KC_3, KC_2, KC_1, KC_ESC),
};

const uint16_t PROGMEM fn_actions[] = {

};

Though when I run make -f Makefile in the gh60 dir i get the error:
Code: [Select]
-------- begin --------
sh: 1: avr-gcc: not found
make: *** [gccversion] Error 127
And it creates a dir named obj_gh60_lufa instead of a hex file
Title: Re: TMK keyboard firmware
Post by: eviltobz on Sun, 01 June 2014, 04:28:07
looks to me like you need to get the avr gcc cross compiler for your platform (or if you have installed it, make sure it's in your path). i'm on a mac, so i use http://www.obdev.at/products/crosspack/index.html if you're on windows, linux, or something else exotic you'll need to find an appropriate one elsewhere
Title: Re: TMK keyboard firmware
Post by: bitemyweewee on Sun, 01 June 2014, 05:15:21
Thanks for that! Got the compiler, it now compiles.

but...
Code: [Select]
mkdir -p obj_gh60_lufa
Compiling C: keymap_poker.c
avr-gcc -c -mmcu=at90usb1287 -gdwarf-2 -DF_CPU=16000000UL -DINTERRUPT_CONTROL_ENDPOINT -DBOOTLOADER_SIZE=4096 -DF_USB=16000000UL -DARCH=ARCH_AVR8 -DUSB_DEVICE_ONLY -DUSE_FLASH_DESCRIPTORS -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)" -DFIXED_CONTROL_ENDPOINT_SIZE=8  -DFIXED_NUM_CONFIGURATIONS=1 -DPROTOCOL_LUFA -DBOOTMAGIC_ENABLE -DMOUSEKEY_ENABLE -DMOUSE_ENABLE -DEXTRAKEY_ENABLE -DCONSOLE_ENABLE -DCOMMAND_ENABLE -DVERSION=unknown -Os -funsigned-char -funsigned-bitfields -ffunction-sections -fno-inline-small-functions -fpack-struct -fshort-enums -fno-strict-aliasing -Wall -Wstrict-prototypes -Wa,-adhlns=obj_gh60_lufa/keymap_poker.lst -I. -I../.. -I../../protocol/lufa -I../../protocol/lufa/LUFA-120730 -I../../common -std=gnu99 -include config.h -MMD -MP -MF .dep/obj_gh60_lufa_keymap_poker.o.d  keymap_poker.c -o obj_gh60_lufa/keymap_poker.o
keymap_poker.c:1:5: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘:’ token
In file included from /usr/lib/gcc/avr/4.7.2/include/stdint.h:3:0,
                 from keymap_common.h:20,
                 from keymap_poker.c:2:
/usr/lib/gcc/avr/4.7.2/../../../avr/include/stdint.h:159:1: error: unknown type name ‘int8_t’
/usr/lib/gcc/avr/4.7.2/../../../avr/include/stdint.h:213:1: error: unknown type name ‘int8_t’
In file included from keymap_common.h:26:0,
                 from keymap_poker.c:2:
../../common/report.h:141:5: error: unknown type name ‘int8_t’
../../common/report.h:142:5: error: unknown type name ‘int8_t’
../../common/report.h:143:5: error: unknown type name ‘int8_t’
../../common/report.h:144:5: error: unknown type name ‘int8_t’
In file included from keymap_common.h:28:0,
                 from keymap_poker.c:2:
../../common/print.h:75:25: error: unknown type name ‘int8_t’
In file included from keymap_poker.c:2:0:
keymap_common.h:49:53: warning: backslash and newline separated by space [enabled by default]
keymap_poker.c:14:72: error: macro "KEYMAP" passed 84 arguments, but takes just 82
keymap_poker.c:6:5: error: ‘KEYMAP’ undeclared here (not in a function)
make: *** [obj_gh60_lufa/keymap_poker.o] Error 1

I don't know how to debug this unfortunately, I'm not a programmer. What does it mean?
Title: Re: TMK keyboard firmware
Post by: domoaligato on Sun, 01 June 2014, 12:39:08
Please compile the base firmware without edits first to make sure the compiler is working correctly with the code.
Title: Re: TMK keyboard firmware
Post by: bcg on Sun, 01 June 2014, 13:10:26
Thanks for that! Got the compiler, it now compiles.

but...
Code: [Select]
mkdir -p obj_gh60_lufa
Compiling C: keymap_poker.c
avr-gcc -c -mmcu=at90usb1287 -gdwarf-2 -DF_CPU=16000000UL -DINTERRUPT_CONTROL_ENDPOINT -DBOOTLOADER_SIZE=4096 -DF_USB=16000000UL -DARCH=ARCH_AVR8 -DUSB_DEVICE_ONLY -DUSE_FLASH_DESCRIPTORS -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)" -DFIXED_CONTROL_ENDPOINT_SIZE=8  -DFIXED_NUM_CONFIGURATIONS=1 -DPROTOCOL_LUFA -DBOOTMAGIC_ENABLE -DMOUSEKEY_ENABLE -DMOUSE_ENABLE -DEXTRAKEY_ENABLE -DCONSOLE_ENABLE -DCOMMAND_ENABLE -DVERSION=unknown -Os -funsigned-char -funsigned-bitfields -ffunction-sections -fno-inline-small-functions -fpack-struct -fshort-enums -fno-strict-aliasing -Wall -Wstrict-prototypes -Wa,-adhlns=obj_gh60_lufa/keymap_poker.lst -I. -I../.. -I../../protocol/lufa -I../../protocol/lufa/LUFA-120730 -I../../common -std=gnu99 -include config.h -MMD -MP -MF .dep/obj_gh60_lufa_keymap_poker.o.d  keymap_poker.c -o obj_gh60_lufa/keymap_poker.o
keymap_poker.c:1:5: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘:’ token
In file included from /usr/lib/gcc/avr/4.7.2/include/stdint.h:3:0,
                 from keymap_common.h:20,
                 from keymap_poker.c:2:
/usr/lib/gcc/avr/4.7.2/../../../avr/include/stdint.h:159:1: error: unknown type name ‘int8_t’
/usr/lib/gcc/avr/4.7.2/../../../avr/include/stdint.h:213:1: error: unknown type name ‘int8_t’
In file included from keymap_common.h:26:0,
                 from keymap_poker.c:2:
../../common/report.h:141:5: error: unknown type name ‘int8_t’
../../common/report.h:142:5: error: unknown type name ‘int8_t’
../../common/report.h:143:5: error: unknown type name ‘int8_t’
../../common/report.h:144:5: error: unknown type name ‘int8_t’
In file included from keymap_common.h:28:0,
                 from keymap_poker.c:2:
../../common/print.h:75:25: error: unknown type name ‘int8_t’
In file included from keymap_poker.c:2:0:
keymap_common.h:49:53: warning: backslash and newline separated by space [enabled by default]
keymap_poker.c:14:72: error: macro "KEYMAP" passed 84 arguments, but takes just 82
keymap_poker.c:6:5: error: ‘KEYMAP’ undeclared here (not in a function)
make: *** [obj_gh60_lufa/keymap_poker.o] Error 1

I don't know how to debug this unfortunately, I'm not a programmer. What does it mean?

It means that your keymap has 2 extra keys defined in it that shouldn't be there.  You have specified 84 keys but only 82 are supported for your board.
Title: Re: TMK keyboard firmware
Post by: Smasher816 on Sun, 01 June 2014, 15:10:47
I made a simple c file to test the rn-42 bluesmirf HID module. This connects to my phone and writes out messages just fine. See here http://ix.io/cKq

I am now attempting to use the TMK firware to talk to this module. My first simple test is making main.c call "serial_send('a');" in a loop. When plugging this into my uart->usb and examining the output I am getting '�' instead of the letter 'a'. I assume that this means my serial configuration is incorrect.

The RN-42 is specified as follows. However hardware flow control not needed and the device will function fine with only Vcc,GND,RX,TX connected.
Code: [Select]
• Baud rate 115,200
• 8 bits
• No Parity
• 1 stop bit
• Hardware flow control enabled

and this is my code from config.h
Code: [Select]
/* USART configuration
 *     asynchronous, 115200baud, 8-data bit, non parity, 1-stop bit, no flow control
 */
#define SERIAL_UART_BAUD       115200
#define SERIAL_UART_DATA       UDR1
#define SERIAL_UART_UBRR       ((F_CPU/(16UL*SERIAL_UART_BAUD))-1)
#define SERIAL_UART_RXD_VECT   USART1_RX_vect
#define SERIAL_UART_TXD_READY  (UCSR1A&(1<<UDRE1))
#define SERIAL_UART_INIT()     do { \
    UBRR1L = (uint8_t) SERIAL_UART_UBRR;       /* baud rate */ \
    UBRR1H = (uint8_t) (SERIAL_UART_UBRR>>8);  /* baud rate */ \
    UCSR1B = (1<<TXEN1);                /* TX: enable */ \
    UCSR1C = (0<<UPM11) | (0<<UPM10) | /* parity: none(00), even(01), odd(11) */ \
             (0<<UCSZ12) | (1<<UCSZ11) | (1<<UCSZ10); /* data-8bit(011) */ \
    sei(); \
} while(0)

I know that this UART code will work http://www.pjrc.com/teensy/uart.html, but I am not sure how to use Hasu's files.

Thanks for the help.
Title: Re: TMK keyboard firmware
Post by: abjr on Mon, 02 June 2014, 21:23:06
I'm missing something here .... if I have a keymap like:

KEYMAP(ESC, ..., ..., RSFT, FN0);

How can I do (like a Leopold):

1) FN0 + ESC ==  `
2) RSFT + ESC == ~

I know I could put GRV on the top level and do FN0+GRV == ESC or even leave ESC on the default layer and do

1) FN0 + ESC == `
2) FN0 + RSFT + ESC == ~

but I'd like ESC on the default layer and I'd like to avoid using 2 modifiers for one character.

Thanks.

-abjr

Title: Re: TMK keyboard firmware
Post by: hasu on Tue, 03 June 2014, 09:23:51
See converter/pc98_usb/matrix.c if you want to know how to use protocol/serial_uart.c.
It should be noted that serial_recv() is non-blocking receive while serial_receiv2() is blocking version. Ya, bad naming :D


I know that this UART code will work http://www.pjrc.com/teensy/uart.html, but I am not sure how to use Hasu's files.

Title: Re: TMK keyboard firmware
Post by: hasu on Tue, 03 June 2014, 09:32:29
abjr, you can write your own 'Function Action' for that ESC behaviour. But documentation is very sparse and you will need to look into source codes. If you want to try start with seeing keyboard/hhkb/keymap_hasu.c which has a sample 'Function'.
https://github.com/tmk/tmk_keyboard/blob/master/doc/keymap.md#24-function-action
Title: Re: TMK keyboard firmware
Post by: Smasher816 on Tue, 03 June 2014, 09:32:46
I looked at that file. I see stuff like serial_send(0x96) which is all I need (no receiving). Unfortunately trying to send a simple character such as serial_send('a'); does not output correctly to the computer. When using my example code with the teensy library it works fine. I assume this means that I did not set up the UART configuration for your functions correctly. Although I am not sure what is wrong...
Title: Re: TMK keyboard firmware
Post by: hasu on Tue, 03 June 2014, 09:37:53
hmm, I don't know why. At least your configuration seems to be correct.
If you can provide your source code repository on github or somewhere, I'll check more.
Title: Re: TMK keyboard firmware
Post by: Smasher816 on Tue, 03 June 2014, 09:41:19
Thanks Hasu. I'll upload it once I am home.
Title: Re: TMK keyboard firmware
Post by: hasu on Fri, 20 June 2014, 09:12:02
CortexM/mbed port is coming.
PS/2 converter works like a charm now. Too many todo but promising.

(http://i.imgur.com/ICjSpCSl.jpg)
Title: Re: TMK keyboard firmware
Post by: bcg on Fri, 20 June 2014, 20:19:52
This is going to be awesome.

BTW what is the black keyboard on left?
Title: Re: TMK keyboard firmware
Post by: hasu on Fri, 20 June 2014, 21:44:58
Poker X :) I use this to test my converter, it can speak PS/2.
Title: Re: TMK keyboard firmware
Post by: Leimi on Mon, 30 June 2014, 03:12:52
Hey,

I'm having trouble seeing if keyboards with Topre switchs (I actually have the Leopold FC660C in mind) would work with the PS/2 <> USB adapter?
Title: Re: TMK keyboard firmware
Post by: Eszett on Sat, 05 July 2014, 02:44:30
(delete)
Title: Re: TMK keyboard firmware
Post by: l_b on Mon, 07 July 2014, 16:01:28
Thanks for the firmware!

I have something in mind but I don't know if it's possible with the current firmware:

keydown + other key = momentary layer switching
tap = toggle layer

It sounds a bit like ACTION_LAYER_TAP_TOGGLE() but without the 5 taps.

Does anyone know how I can achieve this? I can set TAPPING_TOGGLE to 1 but it feels a bit nasty. Is it made for the behaviour I want?
Title: Re: TMK keyboard firmware
Post by: hasu on Mon, 07 July 2014, 21:24:01
hmm,
if you set TAPPING_TOGGLE to 1 you will get what you want.
Or you can write code for yourself in keymap.c.
Title: Re: TMK keyboard firmware
Post by: l_b on Tue, 08 July 2014, 01:43:09
Thanks. I'll first try with setting TAPPING_TOGGLE to 1. I was just confused because of the default value of 5 which doesn't make sense to me. But maybe my brain is just wired differently :)
Title: Re: TMK keyboard firmware
Post by: wuqe on Tue, 08 July 2014, 13:59:55
I set mine to 2 so it's a little more easily accessible but not triggered by accident. I've left it that way for six months now, and it rarely (though occasionally) turns on without my meaning to.
Title: Re: TMK keyboard firmware
Post by: l_b on Sat, 12 July 2014, 18:18:49
Thanks for the help. I wrote a custom action_function() and it's working beautifully now. I now have this in the fn_actions[]:

Code: [Select]
ACTION_FUNCTION_TAP(CUSTOM_LAYER_TAP_TOGGLE),
Code: [Select]
        case CUSTOM_LAYER_TAP_TOGGLE:
            xprintf("\n\ntap.count: %d", record->tap.count);
            xprintf("\n\nevent.pressed: %d", record->event.pressed);

            if (record->tap.count > 0) {
                if (record->event.pressed) {
                    print("\nlayer_invert");
                    layer_invert(1);
                }
            } else {
                if (record->event.pressed) {
                    print("\nlayer_on");
                    layer_on(1);
                } else {
                    print("\nlayer_off");
                    layer_off(1);
                }
            }
            break;

What would be a good way to make the layer (1) more configurable? Can I do something like

Code: [Select]
ACTION_FUNCTION_TAP(CUSTOM_LAYER_TAP_TOGGLE, 1),
ACTION_FUNCTION_TAP(CUSTOM_LAYER_TAP_TOGGLE, 2),

Or should I put the functionality from inside the switch statement in a separate function and do something like:

Code: [Select]
        case CUSTOM_LAYER_TAP_TOGGLE_1:
            my_custom_function(1, record);
        break;
        case CUSTOM_LAYER_TAP_TOGGLE_2:
            my_custom_function(2, record);
        break;
Title: Re: TMK keyboard firmware
Post by: kako on Sun, 13 July 2014, 21:27:26
.
Title: Re: TMK keyboard firmware
Post by: xauser on Fri, 18 July 2014, 13:33:05
Hello,

I'm looking for a way to control num lock state from tmk firmware. In detail I want some kind of action function to enable / disable num lock state. Something like.... "if I press 'k' switch to layer 4 and activate num lock".

Any idea?
Title: Re: TMK keyboard firmware
Post by: Smasher816 on Fri, 18 July 2014, 14:30:17
Hello,

I'm looking for a way to control num lock state from tmk firmware. In detail I want some kind of action function to enable / disable num lock state. Something like.... "if I press 'k' switch to layer 4 and activate num lock".

Any idea?

I believe according to the USB HID protocol the numlock state is controlled by the computer OS. The keyboard just says "Hey I want to toggle numlock" and the computer then replies with if it is enabled or not. For instance I can run a command line program that changed the numlock state (and turns on/off the led) without physically pressing that button. It is the same deal with capslock and is why pressing the capslock key on my external keyboard turns on the led on my laptop (since the OS keeps them both synced together).
Title: Re: TMK keyboard firmware
Post by: xauser on Fri, 18 July 2014, 14:42:09

I believe according to the USB HID protocol the numlock state is controlled by the computer OS. The keyboard just says "Hey I want to toggle numlock" and the computer then replies with if it is enabled or not. For instance I can run a command line program that changed the numlock state (and turns on/off the led) without physically pressing that button. It is the same deal with capslock and is why pressing the capslock key on my external keyboard turns on the led on my laptop (since the OS keeps them both synced together).

That makes sense, yet the os will trigger all this after it received NUMLOCK keycode I guess. So I want to have an fn action function to send this keycode and then do some kind of layer switching.

Title: Re: TMK keyboard firmware
Post by: Smasher816 on Fri, 18 July 2014, 14:47:11
The TMK firmware lets you write your own custom function for different keys. You should be able to accomplish what you want with that.
Title: Re: TMK keyboard firmware
Post by: xauser on Sat, 19 July 2014, 14:41:39
Just want to report that I got what I was looking for. I use a much better mapping for the numpad now. My lightsaber gets better and better. Thank you hasu!
Title: Re: TMK keyboard firmware
Post by: thp777 on Fri, 25 July 2014, 21:24:55
Im having trouble getting my code to build. Giving errors relating to the keymap.c file and keycap_common.h file.
Not really a programmer so im not sure what im doing wrong.
Ive followed guides and triplechecked everything.
its a 6 column 5 row matrix connected to a teesnsy 2.0
Can someone check my code for me and share the Hex if you can get it to successfully compile?
heres the code built under the gh60 folder https://www.dropbox.com/sh/04ayndkwkn87yq4/AAA_IO-XEigpclsuowHF7_gza (https://www.dropbox.com/sh/04ayndkwkn87yq4/AAA_IO-XEigpclsuowHF7_gza)
Title: Re: TMK keyboard firmware
Post by: hasu on Fri, 25 July 2014, 22:13:43
It would be helpful in general to also post "error output" in addtion to source.

In many case error messages is not intuitive and dificult to understand, but still very useful to fix your code. Reading them carefully is better than checking code yourself five times :D To understand error messages you will need a lot of exeprience and patience unfortunately.

With these three fixes I could compiled your source. Try this patch. Good luck with your project!

Code: [Select]
diff --git a/keymap_common.h b/keymap_common.h
index 3ad9b6a..1645eea 100644
--- a/keymap_common.h
+++ b/keymap_common.h
@@ -40,7 +40,7 @@ extern const uint16_t fn_actions[];
     K10, K11, K12, K13, K14, K15, \
     K20, K21, K22, K23, K24, K25, \
     K30, K31, K32, K33, K34, K35, \
-       K40, K41, K42, K43, K44, K45, \
+       K40, K41, K42, K43, K44, K45 \
        ) \
 { \
        { KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05}, \
diff --git a/keymap_poker.c b/keymap_poker.c
index 9c2e8ab..4a28c8e 100644
--- a/keymap_poker.c
+++ b/keymap_poker.c
@@ -7,7 +7,7 @@ const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
         LCTL,Z,   X,   C,   V,   B, \
         LALT,PAUS,CAPS, FN0, FN1, SPC),
     KEYMAP(ESC, F1, F2, F3,  F4,  F5,  \
-        TRNS,TRNS, UP, TRNS,VOLU,PGUP. \
+        TRNS,TRNS, UP, TRNS,VOLU,PGUP, \
         TRNS,LEFT,DOWN,RGHT,VOLD,PGDN, \
         TRNS,TRNS, TRNS,TRNS,MUTE,DEL, \
         TRNS,LGUI,TRNS,TRNS,TRNS,TRNS),
diff --git a/matrix.c b/matrix.c
index 50ef81e..927ef9a 100644
--- a/matrix.c
+++ b/matrix.c
@@ -154,7 +154,7 @@ static matrix_row_t read_cols(void)
            (PINF&(1<<5) ? 0 : (1<<2)) |
            (PINF&(1<<4) ? 0 : (1<<3)) |
            (PINF&(1<<1) ? 0 : (1<<4)) |
-           (PINF&(1<<0) ? 0 : (1<<5)) |
+           (PINF&(1<<0) ? 0 : (1<<5));
 
 }
Title: Re: TMK keyboard firmware
Post by: thp777 on Fri, 25 July 2014, 23:09:32
Thank you so much. That worked and i realize where i messed up at. Now this is built and working after only 8 hours. 
edit: it seems the top key on each row activates the entire row. hmm not sure whats going on there guess its time to look over my code and wiring again
(http://i.imgur.com/a4ShboTh.jpg)
Title: Re: TMK keyboard firmware
Post by: hasu on Fri, 25 July 2014, 23:51:31
Great.
Photo of DIY keyboard always  amuse me Thanks.
Title: Re: TMK keyboard firmware
Post by: thp777 on Fri, 25 July 2014, 23:56:40
Figured it out. thanks so much
Title: Re: TMK keyboard firmware
Post by: Melvang on Sat, 26 July 2014, 01:12:35
Just wondering but what programming language is the source files written in?
Title: Re: TMK keyboard firmware
Post by: hasu on Sat, 26 July 2014, 02:14:48
Most part is written in C. Also C++ is used a little.
Title: Re: TMK keyboard firmware
Post by: Melvang on Sat, 26 July 2014, 03:08:59
Thanks hash.  I am currently teaching myself C but my uncle sent me an older C++ book and was wondering how relevant they would be. 

Would it be possible to write the program to get the requisite .hex file from something that was programmed in a different language such as Python?
Title: Re: TMK keyboard firmware
Post by: hasu on Sat, 26 July 2014, 07:08:34
I dont think you can use Python to get MCU binary, but you can write firmware with languages other than C, for example, BASIC at least.

I found this. You can also use Ada!
http://sourceforge.net/projects/avr-ada/

EDIT: hmm, after reading several times I'm not sure I can understand what you said now. Too complex English sentence to me :D
Title: Re: TMK keyboard firmware
Post by: Melvang on Sat, 26 July 2014, 07:59:47
You understood correct hash.  A lot of people have told me that C is fairly difficult to understand for a first language to learn programming.  I was wondering if any other languages would work for the job.  It isn't that I don't want to learn it, just wondering if there was options.  Just wondering but what does MCU stand for.  I am guessing Machine Code something.
Title: Re: TMK keyboard firmware
Post by: hasu on Sat, 26 July 2014, 21:21:13
Certainly C is not the easiest lang but I'm pretty sure it is the first lang you should learn when you want to play with MCU(microcontroller unit) like AVR or Cortex. I think difficulty of learning C is that you need to know underlying hardware to some extent, while high-level lang like Python offers far better abstraction layer of underlying system and you can forget hardware. But device with MCU like keyboard is very small system comprised of few of simple peripherals and relatively comprehesible unlike huge modern computer system, such as PC.

So I'd say, C on MCU is not so hard as on PC. Good luck!

I'm never a computer language savvy, just my humble opinion.
Title: Re: TMK keyboard firmware
Post by: Melvang on Sat, 26 July 2014, 21:29:08
Certainly C is not the easiest lang but I'm pretty sure it is the first lang you should learn when you want to play with MCU(microcontroller unit) like AVR or Cortex. I think difficulty of learning C is that you need to know underlying hardware to some extent, while high-level lang like Python offers far better abstraction layer of underlying system and you can forget hardware. But device with MCU like keyboard is very small system comprised of few of simple peripherals and relatively comprehesible unlike huge modern computer system PC.

So I'd say, C on MCU is not so hard as on PC. Good luck!

I'm never a computer language savvy, just my humble opinion.

Thank you for the insight hasu.  I have a physical book and a PDF version of another book that I am using for C and my uncle sent me a book that he used when learning C++.  I guess I was just wondering if there was any other options. 

In the future if I wanted to make a program with a GUI that a person could use for custom layouts and such I am guessing I will want to use something like python for the interface to output to C or C++ program and then that would compile into the .hex file.  But that won't be for quite a while.
Title: Re: TMK keyboard firmware
Post by: sakai4eva on Sat, 23 August 2014, 15:22:57
OK. I'm gonna dive in to the TMK firmware because I feel that it's time to do this already.

So... assuming I only use Windows 8 for spreadsheet and gaming, what do I have to do to get started with this?
Title: Re: TMK keyboard firmware
Post by: abjr on Sat, 23 August 2014, 16:43:46
OK. I'm gonna dive in to the TMK firmware because I feel that it's time to do this already.

So... assuming I only use Windows 8 for spreadsheet and gaming, what do I have to do to get started with this?

Start with this: http://deskthority.net/workshop-f7/how-to-build-your-very-own-keyboard-firmware-t7177.html
Title: Re: TMK keyboard firmware
Post by: sakai4eva on Sun, 24 August 2014, 04:49:53
OK. I'm gonna dive in to the TMK firmware because I feel that it's time to do this already.

So... assuming I only use Windows 8 for spreadsheet and gaming, what do I have to do to get started with this?

Start with this: http://deskthority.net/workshop-f7/how-to-build-your-very-own-keyboard-firmware-t7177.html

Thanks. I'll be back once I hit another hiccup :P
Title: Re: TMK keyboard firmware
Post by: yakitysax on Thu, 28 August 2014, 20:05:01
Thank you so much. That worked and i realize where i messed up at. Now this is built and working after only 8 hours. 
edit: it seems the top key on each row activates the entire row. hmm not sure whats going on there guess its time to look over my code and wiring again
Show Image
(http://i.imgur.com/a4ShboTh.jpg)


I use one of the 3DConnexion products as well, can you show how you have hooked the 3d mouse in the keyboard? Do you use it in the firmware at all or what?
Title: Re: TMK keyboard firmware
Post by: yakitysax on Thu, 28 August 2014, 20:06:19
.
Title: Re: TMK keyboard firmware
Post by: yicaoyimu on Fri, 12 September 2014, 21:30:28
A question about TMK firmware. Is it possible to remap ctrl+x to alt+x? The closest thing I've found is key action, which could assign strokes of modifiers and a key to one key. But what I want is assign strokes of a modifier and a key to strokes of another modifier and a key.
Title: Re: TMK keyboard firmware
Post by: Charger on Sat, 13 September 2014, 04:30:19
I really wish i could figure out how to do makefiles again since although i was able to compile my first keyboard i had problems compiling on my desktop but was able to do it on my laptop as i recall however now i cant seem to get either to work

even when i try and do it to unedited files i get this

More
C:\Users\k\Desktop\tmk_keyboard-master\keyboard\gh60>make -f makefile
      0 [main] sh 7908 sync_with_child: child 5812(0x164) died before initializa
tion with status code 0xC0000142
    235 [main] sh 7908 sync_with_child: *** child state waiting for longjmp
/usr/bin/sh: fork: Resource temporarily unavailable
      0 [main] sh 12776 sync_with_child: child 2928(0x164) died before initializ
ation with status code 0xC0000142
    244 [main] sh 12776 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 9952 sync_with_child: child 7584(0x15C) died before initializa
tion with status code 0xC0000142
    411 [main] sh 9952 sync_with_child: *** child state waiting for longjmp
/usr/bin/sh: fork: Resource temporarily unavailable

mkdir -p obj_gh60_lufa
Compiling C: keymap_poker.c
avr-gcc -c -mmcu=atmega32u4 -gdwarf-2 -DF_CPU=16000000UL -DINTERRUPT_CONTROL_END
POINT -DBOOTLOADER_SIZE=4096 -DF_USB=16000000UL -DARCH=ARCH_AVR8 -DUSB_DEVICE_ON
LY -DUSE_FLASH_DESCRIPTORS -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB
_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)" -DFIXED_CONTROL_ENDPOINT_SIZE=8  -DFIXED_N
UM_CONFIGURATIONS=1 -DPROTOCOL_LUFA -DBOOTMAGIC_ENABLE -DMOUSEKEY_ENABLE -DMOUSE
_ENABLE -DEXTRAKEY_ENABLE -DCONSOLE_ENABLE -DCOMMAND_ENABLE -DVERSION= -Os -funs
igned-char -funsigned-bitfields -ffunction-sections -fno-inline-small-functions
-fpack-struct -fshort-enums -fno-strict-aliasing -Wall -Wstrict-prototypes -Wa,-
adhlns=obj_gh60_lufa/keymap_poker.lst -I. -I../.. -I../../protocol/lufa -I../../
protocol/lufa/LUFA-120730 -I../../common -std=gnu99 -include config.h -MMD -MP -
MF .dep/obj_gh60_lufa_keymap_poker.o.d  keymap_poker.c -o obj_gh60_lufa/keymap_p
oker.o
make: *** [obj_gh60_lufa/keymap_poker.o] Error -1073741502
Title: Re: TMK keyboard firmware
Post by: hasu on Sat, 13 September 2014, 05:19:07
A question about TMK firmware. Is it possible to remap ctrl+x to alt+x? The closest thing I've found is key action, which could assign strokes of modifiers and a key to one key. But what I want is assign strokes of a modifier and a key to strokes of another modifier and a key.

It is not supported in normal keymap definition.
You may be able to use action_function() of keymap.c to implement that function, but I'm not sure.
Title: Re: TMK keyboard firmware
Post by: hasu on Sat, 13 September 2014, 05:32:52
WinAVR seems to have troubles with some later versions of windows. Google knows its solution.

I really wish i could figure out how to do makefiles again since although i was able to compile my first keyboard i had problems compiling on my desktop but was able to do it on my laptop as i recall however now i cant seem to get either to work

Title: Re: TMK keyboard firmware
Post by: Charger on Sat, 13 September 2014, 06:50:01
WinAVR seems to have troubles with some later versions of windows. Google knows its solution.

I really wish i could figure out how to do makefiles again since although i was able to compile my first keyboard i had problems compiling on my desktop but was able to do it on my laptop as i recall however now i cant seem to get either to work

If only i had these magic google powers it would seem that I'm lacking. because the few things i have found and tried did not work. I have now tried re-installing winavr, uninstalling that and installing mhv avr but that tells me that "the system can not find the path specified" although it is in the path variable and mhv adds it as far as i can tell, tried the same on my laptop with no luck still so i guess at this point i will have to dig out an old xp laptop and try that
Title: Re: TMK keyboard firmware
Post by: hasu on Sat, 13 September 2014, 09:04:16
MHV has no shell for some reason so you have to install shell with cygwin or msys/mingw. TMK needs shell to build firmware, I'd change Makefile to build without shell some future but it needs at this time.

I think following setup will work on Windows, at least for me on Windows 7 64bit.
1. Install one of toolchains like WinAVR, MHV AVR Tools or Atmel AVR ToolChain
2. Install Cygwin or MSYS
3. Setup shell with path of toolchain

Title: Re: TMK keyboard firmware
Post by: Charger on Sat, 13 September 2014, 14:39:18
MHV has no shell for some reason so you have to install shell with cygwin or msys/mingw. TMK needs shell to build firmware, I'd change Makefile to build without shell some future but it needs at this time.

I think following setup will work on Windows, at least for me on Windows 7 64bit.
1. Install one of toolchains like WinAVR, MHV AVR Tools or Atmel AVR ToolChain
2. Install Cygwin or MSYS
3. Setup shell with path of toolchain
after hours of trying to get it to work on windows 8.1 and windows 7 i tired xp and installed winavr worked first try and my code worked first try lol
Title: Re: TMK keyboard firmware
Post by: domoaligato on Mon, 15 September 2014, 10:55:44
I compile with winavr on my system just fine. you need to download this patch for vista+
info on why and what you are downloading
http://www.madwizard.org/electronics/articles/winavrvista

the modified msys-1.0.dll that fixes the issue.
http://www.madwizard.org/electronics/articles/winavrvista
Title: Re: TMK keyboard firmware
Post by: Charger on Mon, 15 September 2014, 12:20:40
the dll fix didn't work for me i have tried it and i tried it again with the one from that site and still nothing
Title: Re: TMK keyboard firmware
Post by: domoaligato on Mon, 15 September 2014, 12:45:55
the dll fix didn't work for me i have tried it and i tried it again with the one from that site and still nothing

from your quoted command output....
make -f makefile


that is not the correct usage of the makefile... to compile the gh60 firmware you need to type..
for gh60
make KEYMAP=poker
or
make KEYMAP=plain
etc etc...

please see the readme.md from here
https://github.com/tmk/tmk_keyboard/tree/master/keyboard/gh60


the gh60 make usage is different from say the phantom
https://github.com/tmk/tmk_keyboard/tree/master/keyboard/phantom

for phantom
make -f Makefile.pjrc or make -f Makefile.lufa
Title: Re: TMK keyboard firmware
Post by: Charger on Mon, 15 September 2014, 13:11:48
the dll fix didn't work for me i have tried it and i tried it again with the one from that site and still nothing

from your quoted command output....
make -f makefile


that is not the correct usage of the makefile... to compile the gh60 firmware you need to type..
for gh60
make KEYMAP=poker
or
make KEYMAP=plain
etc etc...

please see the readme.md from here
https://github.com/tmk/tmk_keyboard/tree/master/keyboard/gh60


the gh60 make usage is different from say the phantom
https://github.com/tmk/tmk_keyboard/tree/master/keyboard/phantom

for phantom
make -f Makefile.pjrc or make -f Makefile.lufa

It is the same as make -f makefile.lufa for the gh60 it just doesn't have the .lufa. it has worked for 2 keyboards so far, does the poker keymap  and is how http://deskthority.net/workshop-f7/how-to-build-your-very-own-keyboard-firmware-t7177.html#p141386 tells you to do it

oh you may have thought i ment it does not thing which isnt the case i meant there was no change from what posted on the last page

also tried your way and it does the same thing as with make -f makefile
Title: Re: TMK keyboard firmware
Post by: domoaligato on Mon, 15 September 2014, 16:32:56
are you opening a administrator cmd prompt? make clean?

sorry I know that I had this same issue and i thought it was because the makefile needed a keymap specified. when I get home I will look at my batch files I setup and post again with what I have in them.
Title: Re: TMK keyboard firmware
Post by: Charger on Mon, 15 September 2014, 17:20:16
are you opening a administrator cmd prompt? make clean?

sorry I know that I had this same issue and i thought it was because the makefile needed a keymap specified. when I get home I will look at my batch files I setup and post again with what I have in them.

I do make clean every time and just tried running cmd as administrator with no change to what it does

I do appreciate you trying to help even though i have programmed what i was trying to at the time with an xp laptop it would be nice to get it to work on my main computer instead of digging out an old laptop so any help is welcomed.
Title: Re: TMK keyboard firmware
Post by: domoaligato on Mon, 15 September 2014, 19:57:53
no idea bro... here is what I have for my gh60_build.bat

make clean
make KEYMAP=poker


edit:
Are you compiling the files without modification first to verify your build environment? try compiling the default gh60 files without editing them with the command above.

and did you overwrite the existing msys-1.0.dll in the utils\bin subdirectory of your WinAVR directory?
Title: Re: TMK keyboard firmware
Post by: Charger on Mon, 15 September 2014, 21:22:34
no idea bro... here is what I have for my gh60_build.bat

make clean
make KEYMAP=poker


edit:
Are you compiling the files without modification first to verify your build environment? try compiling the default gh60 files without editing them with the command above.

and did you overwrite the existing msys-1.0.dll in the utils\bin subdirectory of your WinAVR directory?
Yes I'm testing on the unedited files from a few of the keyboards and yes i replaced the dll in that folder even though i think my version should have the fixed dll with it based on the site you posted.

I also like the idea of using a bat file to run it lol
Title: Re: TMK keyboard firmware
Post by: domoaligato on Mon, 15 September 2014, 21:38:05

I also like the idea of using a bat file to run it lol

My batch file also has git sync and some other stuffs. :D
Title: Re: TMK keyboard firmware
Post by: ComradeSniper on Mon, 15 September 2014, 21:47:16
So I'm trying to run my Apple M0110 with the specified firmware and this is really confusing me.

I run:
make clean
make KEYMAP=hasu

then I program the resulting m0110_lufa.hex file to the teensy using the teensy loader app, then reboot the teensy. My understanding is that at this point it should function, but it doesn't.

Is it just an issue with my soldering, or did I miss something?
Title: Re: TMK keyboard firmware
Post by: Charger on Tue, 16 September 2014, 01:50:39

I also like the idea of using a bat file to run it lol

My batch file also has git sync and some other stuffs. :D

magically i finally got it to compile after uninstall / reinstall, and the dll swap for the 4th time so now its time to figure out how to write a batch file to do it when i want to lol  done
Title: Re: TMK keyboard firmware
Post by: domoaligato on Tue, 16 September 2014, 10:07:13
So I'm trying to run my Apple M0110 with the specified firmware and this is really confusing me.

I run:
make clean
make KEYMAP=hasu

then I program the resulting m0110_lufa.hex file to the teensy using the teensy loader app, then reboot the teensy. My understanding is that at this point it should function, but it doesn't.

Is it just an issue with my soldering, or did I miss something?

did you follow this?

https://github.com/tmk/tmk_keyboard/blob/master/converter/m0110_usb/README.md
Title: Re: TMK keyboard firmware
Post by: ComradeSniper on Tue, 16 September 2014, 11:03:22
So I'm trying to run my Apple M0110 with the specified firmware and this is really confusing me.

I run:
make clean
make KEYMAP=hasu

then I program the resulting m0110_lufa.hex file to the teensy using the teensy loader app, then reboot the teensy. My understanding is that at this point it should function, but it doesn't.

Is it just an issue with my soldering, or did I miss something?

did you follow this?

https://github.com/tmk/tmk_keyboard/blob/master/converter/m0110_usb/README.md

I tried to stick to that as well as I could, but this is all totally new to me so I was honestly having some difficulty understanding it  :-[

Just running the code in the box built the firmware, but then it seemed to have no effect when I installed it.
Title: Re: TMK keyboard firmware
Post by: esoomenona on Tue, 16 September 2014, 11:36:51
There's a layout maker for the M0110 in the OP. Easy as pie, and outputs firmware.

If trying to do it yourself, can it be lufa? If it's a teensy, doesn't it need to be the pjrc make?
Title: Re: TMK keyboard firmware
Post by: hasu on Tue, 16 September 2014, 18:04:47
So I'm trying to run my Apple M0110 with the specified firmware and this is really confusing me.

I run:
make clean
make KEYMAP=hasu

then I program the resulting m0110_lufa.hex file to the teensy using the teensy loader app, then reboot the teensy. My understanding is that at this point it should function, but it doesn't.

Is it just an issue with my soldering, or did I miss something?

I remember my coverter worked several months ago at least.

Wrong connection or soldering can cause your problem. If you are not sure post clear detailed photos as possible in M0110 converter thread so that I and other people can check out.
http://geekhack.org/index.php?topic=24965.0
Title: Re: TMK keyboard firmware
Post by: ComradeSniper on Tue, 16 September 2014, 19:47:17
There's a layout maker for the M0110 in the OP. Easy as pie, and outputs firmware.

If trying to do it yourself, can it be lufa? If it's a teensy, doesn't it need to be the pjrc make?

That would make sense. I redid the firmware building process using the pjrc makefile. Still doesn't seem to work when I program it and reboot it, so I think it must be a soldering issue.

So I'm trying to run my Apple M0110 with the specified firmware and this is really confusing me.

I run:
make clean
make KEYMAP=hasu

then I program the resulting m0110_lufa.hex file to the teensy using the teensy loader app, then reboot the teensy. My understanding is that at this point it should function, but it doesn't.

Is it just an issue with my soldering, or did I miss something?

I remember my coverter worked several months ago at least.

Wrong connection or soldering can cause your problem. If you are not sure post clear detailed photos as possible in M0110 converter thread so that I and other people can check out.
http://geekhack.org/index.php?topic=24965.0

I will do this, thank you.
Title: Re: TMK keyboard firmware
Post by: hasu on Tue, 16 September 2014, 20:03:59
You can either PJRC or LUFA USB stack but I recommend to use LUFA even with Teensy.

Looks like you did right on building and uploading firmware.

There's a layout maker for the M0110 in the OP. Easy as pie, and outputs firmware.

If trying to do it yourself, can it be lufa? If it's a teensy, doesn't it need to be the pjrc make?

That would make sense. I redid the firmware building process using the pjrc makefile. Still doesn't seem to work when I program it and reboot it, so I think it must be a soldering issue.

Title: Re: TMK keyboard firmware
Post by: hasu on Wed, 24 September 2014, 15:40:08
I got a Next keyboard finally, and made Next converter. Thank you, bcg!
http://geekhack.org/index.php?topic=41989.msg1188141#msg1188141

(http://i.imgur.com/txopcvPl.jpg)
Title: Re: TMK keyboard firmware
Post by: primitiveType on Sat, 27 September 2014, 15:18:57
Is it possible with TMK to map a key to both a modifier and temporary layer?

I ask because I use dvorak but I want it to switch to qwerty when I hold down ctrl. I haven't been able to figure out how to do it in tmk though.

Hopefully this is the right place to get help  :-[
Title: Re: TMK keyboard firmware
Post by: hasu on Sun, 28 September 2014, 20:38:47
yes, this is right place.

Try this and give me feedback.
https://github.com/tmk/tmk_keyboard/commit/821c719e98f310938e2bb3f2ad3e6a726bd8b03e

I think this is what you want probably.
https://github.com/tmk/tmk_keyboard/blob/action_fix/doc/keymap.md#35-momentary-switching-with-modifiers
Title: Re: TMK keyboard firmware
Post by: Moralless on Thu, 02 October 2014, 11:21:19
Hello, I actually posted a thread about my problem here (http://geekhack.org/index.php?topic=63467.0) before seeing this thread and was wondering if anyone has had any similar problems as me and how they solved it.
Title: Re: TMK keyboard firmware
Post by: zeroni13 on Sun, 05 October 2014, 05:54:59
Hi, I just got ny numberpad and i program med it with regack's TMK based firmware and changed the layout a bit. Bit i can't het keys like "CALC" and "MPLY" etc. To work. It works fine om my Phantom with TMK witch is in the same TMK master folder. Som i don't understand what I'm missing.
What do i do?
Title: Re: TMK keyboard firmware
Post by: hasu on Sun, 05 October 2014, 06:32:36
You built with option EXTRAKEY_ENABLE? To use audio and system control keys you need this build option.

What's your OS? Some os doesnt recognize some key codes. And where is regack's code repository?
Title: Re: TMK keyboard firmware
Post by: zeroni13 on Sun, 05 October 2014, 10:31:47
You built with option EXTRAKEY_ENABLE? To use audio and system control keys you need this build option.

What's your OS? Some os doesnt recognize some key codes. And where is regack's code repository?

Where do I enable that? I forgot so much about how to configure the firmware after I stopped tweaking it and just started using it.

Here's regack's code: https://github.com/regack/4x6/tree/GHpad

Edit: found it in the makefile, I'll try to compile it now. Thanks!
Edit 2: Works! Thank you! =D
Title: Re: TMK keyboard firmware
Post by: Lubed Up Slug on Mon, 06 October 2014, 14:29:37
How do you convert the firmware into a hex file that can be uploaded to the teensy?
Title: Re: TMK keyboard firmware
Post by: domoaligato on Mon, 06 October 2014, 14:56:27
How do you convert the firmware into a hex file that can be uploaded to the teensy?


you have to "compile" the sourcecode.
Title: Re: TMK keyboard firmware
Post by: Lubed Up Slug on Mon, 06 October 2014, 14:59:06
How do you convert the firmware into a hex file that can be uploaded to the teensy?


you have to "compile" the sourcecode.

And you do that with the make file right?
Title: Re: TMK keyboard firmware
Post by: strict on Mon, 06 October 2014, 14:59:43
How do you convert the firmware into a hex file that can be uploaded to the teensy?

https://github.com/tmk/tmk_keyboard/blob/master/doc/build.md
Title: Re: TMK keyboard firmware
Post by: Lubed Up Slug on Mon, 06 October 2014, 15:33:55
How do you convert the firmware into a hex file that can be uploaded to the teensy?

https://github.com/tmk/tmk_keyboard/blob/master/doc/build.md

thank you. you are a god
Title: Re: TMK keyboard firmware
Post by: domoaligato on Mon, 06 October 2014, 16:20:23
sorry my message above was missing the link to the readme. you should read all of this. not just the build part.


https://github.com/tmk/tmk_keyboard/blob/master/README.md
Title: Re: TMK keyboard firmware
Post by: epicepee on Mon, 06 October 2014, 22:58:25
Exactly what microcontrollers will this work with?  Earlier I read that it would only work with AVRs with built-in USB, but the previous thread about this firmware mentioned ATMega328 with v-usb.  Would that work?  How about a Mega2560?
Title: Re: TMK keyboard firmware
Post by: fog on Tue, 07 October 2014, 00:42:47
...I'd like ESC on the default layer and I'd like to avoid using 2 modifiers for one character.

abjr, you can write your own 'Function Action' for that ESC behaviour. But documentation is very sparse and you will need to look into source codes. If you want to try start with seeing keyboard/hhkb/keymap_hasu.c which has a sample 'Function'.
https://github.com/tmk/tmk_keyboard/blob/master/doc/keymap.md#24-function-action

I took a first pass at this and have it working on my HHKB (Esc=Esc, Shift+Esc=~). I doubt that my initial draft is perfect. I tossed up my sandbox repo (a bit out of date off of Hasu's actual github repo, fyi) with the relevant sample code and keymaps here:

https://github.com/altercation/tmk_firrmware_hhkb_teensy2/blob/master/keyboard/hhkb/keymap_es.c

Hasu seems to be making a lot of good revisions to the code base right now, however, so there might be better ways to do this now or down the road.
Title: Re: TMK keyboard firmware
Post by: hasu on Tue, 07 October 2014, 02:01:23
Exactly what microcontrollers will this work with?  Earlier I read that it would only work with AVRs with built-in USB, but the previous thread about this firmware mentioned ATMega328 with v-usb.  Would that work?  How about a Mega2560?

ATMega328 and 168 will work with V-USB, at least they worked a year ago. Also MCU V-USB supports will work but you will need 16KB at least, 32KB is preferable. But I don't use V-USB base hardware myself now so it is not actively supported in TMK.

If possible you better get megaAVR MCU with hardware USB Controller like; ATMega32U4, ATMega32U2, AT90USB646, and AT90USB1286.

http://www.atmel.com/ja/jp/products/microcontrollers/avr/megaavr.aspx
Title: Re: TMK keyboard firmware
Post by: Moralless on Fri, 10 October 2014, 05:39:26
So I recently rewired my custom keyboard (the wires I was using previously were too thick) and now I'm running into some problems.

Initially I rewired the columns like this:
[attach=1]

Then re-did it to make it look like this:
[attach=2]

Here's what's been happening:
Initially when I did the first rewiring this is what happened:
When I press grv it says that I've pressed grv + tab
When I press 1 it says that I also press grv + tab
When I press 2 it say I pressed LCTRL (I placed the LCTRL where caps lock usually is
When I press 3 it says I pressed LShift
When I press 4 it say I pressed the LWIN key.

Then I rewired it (the second pic) and the same thing above happens except for when I pressed grv it says I pressed grv and when I pressed 1 it says I pressed tab only - everything else stayed the same. I then attempted to rewrite the firmware since I suck at reading the code and finding my mistakes and when I finished doing that, it improve a little bit.

Here's a pic of the keys that registered after using the newer firmware:
[attach=3]

The majority of the keys are jumbled up and the only one working as intended are the Enter, semi colon, O and S keys. Everything else is either jumbled up or not working (interestingly, the GRV, 1, 2 and 4 keys no longer register as anything despite it registering with the older firmware). I am absolutely lost right now, since I have no access to a multimeter at the moment (I'm planning to get one soon) I cannot check the continuity of the columns and rows and check for shorts. Whilst I plan to get a multimeter for the hardware aspect if any of you could check through my modified code to find any silly mistakes that I've made (I think the way I wired up the matrix has confused me) I would be extremely grateful.

Here's the matrix of how I hooked it up to the teensy vs the real life picture of it(please note that the real life picture is mirrored to the paint version so the side where the teensy is the side of the ENTER key):
[attach=4] [attach=1]

And here's the code of only the parts I've modified:

matrix.c: (dropbox link (https://www.dropbox.com/s/fwsjbes7p0y8fj5/matrix.c?dl=0))
Quote from: moralles
/* Column pin configuration
* col: 0 1 2 3 4 5 6 7 8 9 10 11 12 13
* pin: F0 F1 E6 C7 C6 B6 D4 B1 B0 B5 B4 D7 D6 B3 (Rev.A)
* pin: B7 (Rev.B)
*/
static void init_cols(void)
{
// Input with pull-up(DDR:0, PORT:1)
DDRF &= ~(1<<7 | 1<<6 | 1<<5 | 1<<4 | 1<<1 | 1<<0);
PORTF |= (1<<7 | 1<<6 | 1<<5 | 1<<4 | 1<<1 | 1<<0);
DDRD &= ~(1<<7 | 1<<5 | 1<<4 | 1<<3);
PORTD |= (1<<7 | 1<<5 | 1<<4 | 1<<3);
DDRC &= ~(1<<6);
PORTC |= (1<<6);
DDRB &= ~(1<<6 | 1<< 5 | 1<<4);
PORTB |= (1<<6 | 1<< 5 | 1<<4);
}

static matrix_row_t read_cols(void)
{
return (PINC&(1<<6) ? 0 : (1<<0)) |
(PIND&(1<<5) ? 0 : (1<<1)) |
(PIND&(1<<3) ? 0 : (1<<2)) |
(PIND&(1<<4) ? 0 : (1<<3)) |
(PIND&(1<<7) ? 0 : (1<<4)) |
(PINB&(1<<4) ? 0 : (1<<5)) |
(PINB&(1<<5) ? 0 : (1<<6)) |
(PINB&(1<<6) ? 0 : (1<<7)) |
(PINF&(1<<7) ? 0 : (1<<8 )) | 
(PINF&(1<<6) ? 0 : (1<<9)) |
(PINF&(1<<5) ? 0 : (1<<10)) |
(PINF&(1<<4) ? 0 : (1<<11)) |
(PINF&(1<<1) ? 0 : (1<<12)) |
(PINF&(1<<0) ? 0 : (1<<13));
}

/* Row pin configuration
* row: 0 1 2 3 4
* pin: D0 D1 D2 D3 D5
*/
static void unselect_rows(void)
{
// Hi-Z(DDR:0, PORT:0) to unselect
DDRD &= ~0b00000111;
PORTD &= ~0b00000111;
DDRB &= ~0b00000011;
PORTB &= ~0b00000011;
}

static void select_row(uint8_t row)
{
// Output low(DDR:1, PORT:0) to select
switch (row) {
case 0:
DDRD |= (1<<2);
PORTD &= ~(1<<2);
break;
case 1:
DDRD |= (1<<1);
PORTD &= ~(1<<1);
break;
case 2:
DDRD |= (1<<0);
PORTD &= ~(1<<0);
break;
case 3:
DDRB |= (1<<0);
PORTB &= ~(1<<0);
break;
case 4:
DDRB |= (1<<1);
PORTB &= ~(1<<1);
break;
}
}

Keymap_common.h (dropbox link (https://www.dropbox.com/s/sjra306dojeppe2/keymap_common.h?dl=0)):
Quote from: moralles
#include "keymap_common.h"

const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
/* 0: qwerty */
KEYMAP(
GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, \
TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS, \
LCTL,A, S, D, F, G, H, J, K, L, SCLN,QUOT, ENT, \
LSFT,Z, X, C, V, B, N, M, COMM,DOT, SLSH, RSFT, \
LGUI,LALT, SPC, FN0, SPC, PAUS, FN1),

/* 1: FN 1 */
KEYMAP(
ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, DEL, \
TRNS,TRNS, UP, TRNS,TRNS,TRNS,TRNS,VOLU,VOLD,TRNS,PSCR,TRNS,INS,TRNS, \
TRNS,LEFT,DOWN,RGHT,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS, TRNS, \
TRNS,TRNS, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS, \
CAPS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS),

/* 2: FN 2 */
KEYMAP(
ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, DEL, \
TRNS,TRNS, UP, TRNS,TRNS,TRNS,TRNS,VOLU,VOLD,TRNS,PSCR,TRNS,INS,TRNS, \
TRNS,LEFT,DOWN,RGHT,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS, TRNS, \
TRNS,TRNS, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS, \
CAPS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS),
};
const uint16_t PROGMEM fn_actions[] = {
/* Poker Layout */
   
= ACTION_LAYER_MOMENTARY(6), // to Fn overlay
[1] = ACTION_LAYER_TOGGLE(4), // toggle arrow overlay
};

Keymap_poker.c (dropbox link (https://www.dropbox.com/s/xj45sz0v5mesirx/keymap_poker.c?dl=0))
Quote from: moralles
#include "keymap_common.h"

const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
/* 0: qwerty */
KEYMAP(
GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, \
TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS, \
LCTL,A, S, D, F, G, H, J, K, L, SCLN,QUOT, ENT, \
LSFT,Z, X, C, V, B, N, M, COMM,DOT, SLSH, RSFT, \
LGUI,LALT, SPC, FN0, SPC, PAUS, FN1),

/* 1: FN 1 */
KEYMAP(
ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, DEL, \
TRNS,TRNS, UP, TRNS,TRNS,TRNS,TRNS,VOLU,VOLD,TRNS,PSCR,TRNS,INS,TRNS, \
TRNS,LEFT,DOWN,RGHT,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS, TRNS, \
TRNS,TRNS, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS, \
CAPS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS),

/* 2: FN 2 */
KEYMAP(
ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, DEL, \
TRNS,TRNS, UP, TRNS,TRNS,TRNS,TRNS,VOLU,VOLD,TRNS,PSCR,TRNS,INS,TRNS, \
TRNS,LEFT,DOWN,RGHT,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS, TRNS, \
TRNS,TRNS, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS, \
CAPS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS),
};
const uint16_t PROGMEM fn_actions[] = {
/* Poker Layout */
   
= ACTION_LAYER_MOMENTARY(6), // to Fn overlay
[1] = ACTION_LAYER_TOGGLE(4), // toggle arrow overlay
};
Title: Re: TMK keyboard firmware
Post by: hasu on Fri, 10 October 2014, 06:58:14
When you want to use PF4-PF7 as IO ports you have to disable JTAG function. Check datasheet and these codes.
https://github.com/tmk/tmk_keyboard/search?utf8=%E2%9C%93&q=JTD&type=Code

And add thse lines at matrix_init() to enable matrix debug print. See if your matrix works as what you expect.
Code: [Select]
debug_enable = true;
debug_matrix = true;
Title: Re: TMK keyboard firmware
Post by: Moralless on Fri, 10 October 2014, 08:19:49
When you want to use PF4-PF7 as IO ports you have to disable JTAG function. Check datasheet and these codes.
https://github.com/tmk/tmk_keyboard/search?utf8=%E2%9C%93&q=JTD&type=Code

And add thse lines at matrix_init() to enable matrix debug print. See if your matrix works as what you expect.
Code: [Select]
debug_enable = true;
debug_matrix = true;

Hello, thank you for your help, it has improved its usability a great amount, but it still has a few problems. Since I am very very inexperienced with programming I could only understand some of what you said, with a quick google search I learnt what a JTAG function is but I don't know what you meant by the datasheet (I google'd jtag datasheet atmega32 and found this (http://www.atmel.com/Images/2503s.pdf) but it didn't have anything on the F ports.

 Also I looked at the link you posted and couldn't really understand what it did so I just chucked the code under keyboard/phantom/matrix.c and the 2 lines of code in your comment into the void matrix_init(void) in matrix.c:
Quote from: moralles
void matrix_init(void)
{
    MCUCR |= (1<<JTD);
    MCUCR |= (1<<JTD);
    debug_enable = true;
    debug_matrix = true;      
    // initialize row and col
    unselect_rows();
    init_cols();

    // initialize matrix state: all keys off
    for (uint8_t i=0; i < MATRIX_ROWS; i++) {
        matrix = 0;
        matrix_debouncing = 0;
    }
}

[attach=1]

After I did this I compiled it again and installed it onto my teensy and I went on aquakeytester again. Row 2 (going by my matrix) was working as intended from the left control registering from the caps lock to the enter key registering as enter. Row 1 and Row 3 seemed to be switched as tab is registering as right shift, and right shift is registering as tab. However as you can see from the image, majority of the num row isn't being registered, the only Fn button that works is print screen and GRV/esc. Also when I start typing with my other keyboard (corsair k65) the majority of the keys on my custom don't register anymore until I unplug it and plug it back in.
Title: Re: TMK keyboard firmware
Post by: hasu on Fri, 10 October 2014, 11:37:45
Datasheet of ATMega32U4 has explanation of how to disable JTAG function. (26.5.1)
http://www.atmel.com/Images/doc7766.pdf
In the end you need those two lines in matrix_init(), you did right. Now you can use Port F as normal IO ports.
And TMK FAQ has an entry about this.
https://github.com/tmk/tmk_keyboard/wiki/FAQ#using-pf4-7-pins-of-usb-avr


I guess you have problems on your matrix wiring, matrix code or keymap code, perhaps all of them. At first you have to see how your matrix works you can see debug print of matrix array with 'hid_listen' command.

Check your Makefile has these two lines and which are not commented out.
Code: [Select]
CONSOLE_ENABLE = yes            # Console for debug
COMMAND_ENABLE = yes            # Commands for debug and configuration

And run PJRC's 'hid_listen' command on your Windows command prompt, you wil see current status of matrix array. This will be helpful to debug you matrix wiring and code. (PJRC is manufacturer of Teensy board. you can download the command there. https://www.pjrc.com/)
Code: [Select]
r/c 01234567
00: 00000000
01: 00000000
02: 00000000
03: 00000000
04: 00000000
05: 00000000
06: 00000000
07: 00000000

r/c 01234567
00: 00000000
01: 00000000
02: 00000000
03: 00000000
04: 00000100
05: 00000000
06: 00000000
07: 00000000

r/c 0123457
00: 00000000
01: 00000000
02: 00000000
03: 00000000
04: 00000000
05: 00000000
06: 00000000
07: 00000000
Title: Re: TMK keyboard firmware
Post by: Moralless on Fri, 10 October 2014, 12:13:04
Datasheet of ATMega32U4 has explanation of how to disable JTAG function. (26.5.1)
http://www.atmel.com/Images/doc7766.pdf
In the end you need those two lines in matrix_init(), you did right. Now you can use Port F as normal IO ports.
And TMK FAQ has an entry about this.
https://github.com/tmk/tmk_keyboard/wiki/FAQ#using-pf4-7-pins-of-usb-avr


I guess you have problems on your matrix wiring, matrix code or keymap code, perhaps all of them. At first you have to see how your matrix works you can see debug print of matrix array with 'hid_listen' command.

Check your Makefile has these two lines and which are not commented out.
Code: [Select]
CONSOLE_ENABLE = yes            # Console for debug
COMMAND_ENABLE = yes            # Commands for debug and configuration

And run PJRC's 'hid_listen' command on your Windows command prompt, you wil see current status of matrix array. This will be helpful to debug you matrix wiring and code. (PJRC is manufacturer of Teensy board. you can download the command there. https://www.pjrc.com/)
Code: [Select]
r/c 01234567
00: 00000000
01: 00000000
02: 00000000
03: 00000000
04: 00000000
05: 00000000
06: 00000000
07: 00000000

r/c 01234567
00: 00000000
01: 00000000
02: 00000000
03: 00000000
04: 00000100
05: 00000000
06: 00000000
07: 00000000

r/c 0123457
00: 00000000
01: 00000000
02: 00000000
03: 00000000
04: 00000000
05: 00000000
06: 00000000
07: 00000000

Thank you  for everything hasu, can't describe how greatful I am for you help  :thumb: and would've had a much harder time with this project.
Title: Re: TMK keyboard firmware
Post by: robskillz on Fri, 10 October 2014, 12:36:32
I have a question about the capabilities of this firmware.

I'm putting a microcontroller in a Commodore 64 keyboard which has different symbols above the number keys to a 'normal' PC keyboard.
e.g. above the 6 is the &
above the 7 is the '
above the 8 is (
etc.

Is this something I can remap with TMK firmware?
I.e. remap Shift+6 to Shift+7 to get the &?
I have successfully done it with Soarer's firmware but his firmware doesn't let me do other things I want to :(

Any advice or alternatives welcome. Thanks!
Title: Re: TMK keyboard firmware
Post by: hasu on Fri, 10 October 2014, 14:27:50
TMK doesn't support mapping like that unfortunately.


Parhaps you can use this but it is not merged to master branch and not documented enough.
http://geekhack.org/index.php?topic=41989.msg1484439#msg1484439
Title: Re: TMK keyboard firmware
Post by: robskillz on Sun, 12 October 2014, 17:38:16
Thanks for the tip :)
Title: Re: TMK keyboard firmware
Post by: primitiveType on Wed, 15 October 2014, 15:13:38
yes, this is right place.

Try this and give me feedback.
https://github.com/tmk/tmk_keyboard/commit/821c719e98f310938e2bb3f2ad3e6a726bd8b03e

I think this is what you want probably.
https://github.com/tmk/tmk_keyboard/blob/action_fix/doc/keymap.md#35-momentary-switching-with-modifiers

Sorry for disappearing, and thanks for the crazy fast response. I should have mentioned that I'm using an ergodox. Previously I was using Cub's ergodox rewrite, and it doesn't seem like there's a simple way of integrating the ergodox support with the changes you made.

I haven't taken the time to get intimately familiar with the code as I imagine it would take me some time, but how do you think I should proceed? Is it feasible for me to try and write ergodox support into standart TMK, or perhaps try to merge Cub's changes with yours? sorry I'm not involved enough  :-[

EDIT: ok, I'm a fool. Managed to get your changes merged with the ergodox branch pretty easily once I looked at the change log. The feature works, but unfortunately it behaves like CTRL is pressed permamently once I press it. There doesn't seem to be a way to undo it when it gets that way either. I understand that there's a chance that this is because I slapped your code into cub's branch, but if you think it might actually be another issue please let me know. I'm going to investigate a bit on my own for now.

EDIT2: alright I just noticed in your documentation:
 ACTION_LAYER_MODS(2, MOD_LSFT | MOD_LALT)
Does this mean that the function doesn't support MOD_LCTRL ? If so, is there a way to give it support? CTRL is the main mod that I was hoping to use with this feature
Title: Re: TMK keyboard firmware
Post by: hasu on Fri, 17 October 2014, 01:59:04
Thanks for your feedback.

It supports all modifiers, so you can write like ACTION_LAYER_MODS(1, MOD_LCTL).

Quote
The feature works, but unfortunately it behaves like CTRL is pressed permamently once I press it. There doesn't seem to be a way to undo it when it gets that way either. I understand that there's a chance that this is because I slapped your code into cub's branch, but if you think it might actually be another issue please let me know. I'm going to investigate a bit on my own for now.
It looks like modifier stuck problem. Do you place an action to unregister the CTRL on destination layer?
Generally you have to place 'TRNS' on same position of destination layer for the ACTION_LAYER_MODS.
See this.(It still needs to be described well but better than nothing.)
https://github.com/tmk/tmk_keyboard/wiki/FAQ#modifierlayer-stuck
Title: Re: TMK keyboard firmware
Post by: primitiveType on Fri, 17 October 2014, 11:05:32
Thanks Hasu, I'm sure that's the problem. I should really read the documentation more carefully!

I'll give it another go today. Confident that that is the problem though  ;D
Title: Re: TMK keyboard firmware
Post by: xybre on Sun, 19 October 2014, 15:07:15
Is this firmware compatible with the new Duck Eagle (or Viper)? It's a 60% and doesn't have all the same keys as the Lightsaber/Lightsaver, so I'm assuming the default configuration won't work for it at the very least.
Title: Re: TMK keyboard firmware
Post by: primitiveType on Tue, 21 October 2014, 17:49:56
Tried it out today, the new changes work great! you're the man Hasu!
Title: Re: TMK keyboard firmware
Post by: zeroni13 on Thu, 23 October 2014, 05:15:44
Hello, I see TMK Has support for Bpiphany's Kitten Paw, Could anyone convert or help me convert it so it works with the Ghost Squid aswell?

Kitten Paw FW: https://github.com/tmk/tmk_keyboard/tree/master/keyboard/kitten_paw
Schematics: http://deskthority.net/w/images/1/1b/Costar_Replacement_Controllers_Schematics.PNG

I'm clueless to where to start and I would really love using TMK on my QuickFire XT.

Thanks.
Title: Re: TMK keyboard firmware
Post by: blackbox on Thu, 23 October 2014, 05:17:43
Hello, I see TMK Has support for Bpiphany's Kitten Paw, Could anyone convert or help me convert it so it works with the Ghost Squid aswell?

Kitten Paw FW: https://github.com/tmk/tmk_keyboard/tree/master/keyboard/kitten_paw
Schematics: http://deskthority.net/w/images/1/1b/Costar_Replacement_Controllers_Schematics.PNG

I'm clueless to where to start and I would really love using TMK on my QuickFire XT.

Thanks.

I would also love to have TMK on my ghost squid.
Title: Re: TMK keyboard firmware
Post by: xauser on Thu, 23 October 2014, 12:44:22
Hello, I see TMK Has support for Bpiphany's Kitten Paw, Could anyone convert or help me convert it so it works with the Ghost Squid aswell?

Kitten Paw FW: https://github.com/tmk/tmk_keyboard/tree/master/keyboard/kitten_paw
Schematics: http://deskthority.net/w/images/1/1b/Costar_Replacement_Controllers_Schematics.PNG

I'm clueless to where to start and I would really love using TMK on my QuickFire XT.

Thanks.

If I remember right then all costar boards share the same matrix. The controllers only differ in row/column selection. Which firmware are you currently using on your controller (link)? And what are your compile options?

For a quality tmk port you'll need the actual board and the controller to do the final testing.
Title: Re: TMK keyboard firmware
Post by: blackbox on Thu, 23 October 2014, 13:31:25
Hello, I see TMK Has support for Bpiphany's Kitten Paw, Could anyone convert or help me convert it so it works with the Ghost Squid aswell?

Kitten Paw FW: https://github.com/tmk/tmk_keyboard/tree/master/keyboard/kitten_paw
Schematics: http://deskthority.net/w/images/1/1b/Costar_Replacement_Controllers_Schematics.PNG

I'm clueless to where to start and I would really love using TMK on my QuickFire XT.

Thanks.

If I remember right then all costar boards share the same matrix. The controllers only differ in row/column selection. Which firmware are you currently using on your controller (link)? And what are your compile options?

For a quality tmk port you'll need the actual board and the controller to do the final testing.

Hello. We have the stock controller and the xt. Since we have not used the ghost squid yet we have no compile options. The compile options for the kitten paw should work in the port. As I see it the only thing that needs to be done is to correct the pinout.
Title: Re: TMK keyboard firmware
Post by: xauser on Thu, 23 October 2014, 14:04:40

Hello. We have the stock controller and the xt. Since we have not used the ghost squid yet we have no compile options. The compile options for the kitten paw should work in the port. As I see it the only thing that needs to be done is to correct the pinout.

Looks like it! The QuickFire XT seems to be a fullsize board like the filco. Doesn't bpiphany provide the firmware for the Ghost Squid controller?
Title: Re: TMK keyboard firmware
Post by: blackbox on Thu, 23 October 2014, 14:58:52

Hello. We have the stock controller and the xt. Since we have not used the ghost squid yet we have no compile options. The compile options for the kitten paw should work in the port. As I see it the only thing that needs to be done is to correct the pinout.

Looks like it! The QuickFire XT seems to be a fullsize board like the filco. Doesn't bpiphany provide the firmware for the Ghost Squid controller?

These should be compatible:
http://deskthority.net/wiki/Costar_replacement_controllers#Firmwares (http://deskthority.net/wiki/Costar_replacement_controllers#Firmwares)

But we wanted to know if someone could make a port of tmk.
Title: Re: TMK keyboard firmware
Post by: xauser on Thu, 23 October 2014, 15:03:12
I can't find the the controller "Ghost Squid" in bpiphany git repository that's why I'm asking which firmware bpiphany provides for these controllers.

Edit: I can offer to port TMK firmware to the "Ghost Squid" controller for free if someone will send me the board with a ghost squid controller for the time of porting.
Title: Re: TMK keyboard firmware
Post by: zeroni13 on Thu, 23 October 2014, 17:28:45
I can't find the the controller "Ghost Squid" in bpiphany git repository that's why I'm asking which firmware bpiphany provides for these controllers.

Edit: I can offer to port TMK firmware to the "Ghost Squid" controller for free if someone will send me the board with a ghost squid controller for the time of porting.
Wouldn't it be possible to port it just by looking at the pin difference in these schematics? http://deskthority.net/w/images/1/1b/Costar_Replacement_Controllers_Schematics.PNG

Edit:
If not, and you need the controller for the job i would gladly send mine to you, but that kinda depends on where you are located at. I don't want to pay too much for shipping it back and forth.

Another option would be to try and help me port it because I have the controller.
Title: Re: TMK keyboard firmware
Post by: xauser on Fri, 24 October 2014, 09:54:28
Wouldn't it be possible to port it just by looking at the pin difference in these schematics? http://deskthority.net/w/images/1/1b/Costar_Replacement_Controllers_Schematics.PNG

At least I would not release a firmware that I haven't tested. Maybe others will volunteer.

If not, and you need the controller for the job i would gladly send mine to you, but that kinda depends on where you are located at. I don't want to pay too much for shipping it back and forth.

Another option would be to try and help me port it because I have the controller.

I'm located in Germany. Remote debugging is very time consuming but If you want to try yourself there is a great howto from matt3o over at deskthority.

http://deskthority.net/workshop-f7/how-to-build-your-very-own-keyboard-firmware-t7177.html
Title: Re: TMK keyboard firmware
Post by: phatdood9 on Sun, 26 October 2014, 00:54:51
Is this firmware compatible with the new Duck Eagle (or Viper)? It's a 60% and doesn't have all the same keys as the Lightsaber/Lightsaver, so I'm assuming the default configuration won't work for it at the very least.

I was looking at  this today, and it seems to be a bit complicated w my limited knowledge ... the lightsaber appears to use 2 74HC237D 3-8bit multiplexers. The viper that I have in front of me just has one.

It looks straightforward enough to do simple matrix wiring, but this pcb appears to be quite complex. I recall loading a custom firmware in the past that would give me a full dump of all the actions pressed, maybe that would be a way to go about reverse engineering the matrix.

Any tips for figuring this out xauser? (iirc you did the lightsaber :))


Title: Re: TMK keyboard firmware
Post by: xauser on Sun, 26 October 2014, 10:41:21
I would start with pen, paper and a multimeter to analyse the circuit.
Title: Re: TMK keyboard firmware
Post by: Lubed Up Slug on Sat, 01 November 2014, 17:16:39
So I wanted to do a Pure layout with my board, but with different key assignments.

Is this the right way to do the key assignments?
Code: [Select]
#include "keymap_common.h"

const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
 keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
    /* 0: qwerty */
    KEYMAP_ANSI(
        ESC, 1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   MINS,EQL, BSPC, \
        TAB, Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,   LBRC,RBRC,BSLS, \
        CAPS,A,   S,   D,   F,   G,   H,   J,   K,   L,   SCLN,QUOT,     ENT,  \
        LSFT,Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, SLSH,RSFT,     FN1, \
        LCTL,LGUI,LALT,          SPC,                     FN2, RGUI,APP, RCTL),

    /* 1: FN1 */
    KEYMAP_ANSI(
        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \
        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \
        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,     TRNS, \
        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,UP,       FN1, \
        TRNS,TRNS,TRNS,          TRNS,                    TRNS,LEFT,DOWN,RGHT),
   
    /* 2: FN2 */
    KEYMAP_ANSI(
        GRV, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12, DEL, \
        TRNS,TRNS,VOLU,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \
        TRNS,TRNS,VOLD,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,     TRNS, \
        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,     TRNS, \
        TRNS,TRNS,TRNS,          TRNS,                    TRNS,TRNS,TRNS,TRNS),



};

const uint16_t PROGMEM fn_actions[] = {
[1] = ACTION_LAYER_TOGGLE(1)
[2] = ACTION_LAYER_TOGGLE(2)
};


Is this the correct way to put the layout into the matrix? Really the only parts changed are on the lines beginning K30.
Code: [Select]
/* ANSI valiant. No extra keys for ISO */
#define KEYMAP_ANSI( \
    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,      K2D, \
    K30, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3D,      K3E, \
    K40, K41, K42,           K45,                     K4A, K4B, K4C, K4D  \
) 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, NO,  K2D, \
    K30, NO,  K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3D, K3E, \
    K40, K41, K42,           K45,                NO,  K4A, K4B, K4C, K4D  \
)

Do I need to change any of this part?
Code: [Select]
#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 }  \
}
Title: Re: TMK keyboard firmware
Post by: hasu on Sat, 01 November 2014, 21:23:03
Hmm, I'm not sure what you are doing.

what is your keyobard actually?
which code are you working on, your own or existent project?
Title: Re: TMK keyboard firmware
Post by: Lubed Up Slug on Sun, 02 November 2014, 00:40:36
Hmm, I'm not sure what you are doing.

what is your keyobard actually?
which code are you working on, your own or existent project?

Perhaps I should give a little more explanation. My layout is essentially a poker with an extra key on the 4th row from the top, to the right of the right shift. I was hoping to edit the gh60 file, by changing the matrix file (keymap_common.h) to add the extra key and then change the poker layout file(keymap_poker.c) to the layout I wanted. I think I didn't do the matrix correctly.

I actually worked it all out, except that my spacebar doesn't work, I think it could be a soldering issue or maybe the switch. Thank you so much for this firmware almost everything is working exactly as I want it to.
Title: Re: TMK keyboard firmware
Post by: kapish on Wed, 05 November 2014, 20:29:52
I might have miss out something when checking the keycode.c file, but cant seems to the keycode for pipe ( | ). Using it alot for work, had to keep on alternating with laptop keyboard. Anyone know the keycode for pipe?
Title: Re: TMK keyboard firmware
Post by: Lubed Up Slug on Wed, 05 November 2014, 21:45:06
I might have miss out something when checking the keycode.c file, but cant seems to the keycode for pipe ( | ). Using it alot for work, had to keep on alternating with laptop keyboard. Anyone know the keycode for pipe?

Well I'm not sure if you can make a single key pipe but the code for the backslash (\) key which is pipe when you hit shift is BSLS
Title: Re: TMK keyboard firmware
Post by: kapish on Thu, 06 November 2014, 01:18:53
I might have miss out something when checking the keycode.c file, but cant seems to the keycode for pipe ( | ). Using it alot for work, had to keep on alternating with laptop keyboard. Anyone know the keycode for pipe?

Well I'm not sure if you can make a single key pipe but the code for the backslash (\) key which is pipe when you hit shift is BSLS

Didnt notice that as I remap the second layer of backslash to another function. Fixed that and its working now. Thank you  ;D
Title: Re: TMK keyboard firmware
Post by: feizor on Fri, 14 November 2014, 17:20:26
Can I use the tmk firmware on a otd cheat?
Title: Re: TMK keyboard firmware
Post by: f00000 on Sun, 16 November 2014, 15:00:43
hi hasu! what a wonderful project!

can you help me please? i'm using ps2_usb with ibm m on mac (⌘ as LGUI, ⌥ as RALT) and i'm lost in C ... I need to map:

1) PrS directly to LSFT+LGUI+3
2) ScL directly to × (multiplication sign U+00D7)
Title: Re: TMK keyboard firmware
Post by: hasu on Mon, 17 November 2014, 13:18:30
TMK basically requires a little knowledge of C and programming, unfortunately you need to learn unless you already have yet.

1) Not supported directly. With using ACTION_LAYER_MODS and Function you will be able to implement.
https://github.com/tmk/tmk_keyboard/blob/master/doc/keymap.md#35-momentary-switching-with-modifiers
https://github.com/tmk/tmk_keyboard/blob/master/doc/keymap.md#24-function-action

2) With using Macro or Function you can implement. How to input unicode char depends on your OS.
https://github.com/tmk/tmk_keyboard/blob/master/doc/keymap.md#23-macro-action
Title: Re: TMK keyboard firmware
Post by: neverused on Sun, 23 November 2014, 13:25:50
I read on another build log that columns/rows greater than 16 in number are hard to implement on your firmware, is this true? I will likely have about 20 columns and 5 rows on my teensy ++ but would like to use your firmware.
Title: Re: TMK keyboard firmware
Post by: hasu on Sun, 23 November 2014, 18:26:32
I read on another build log that columns/rows greater than 16 in number are hard to implement on your firmware, is this true? I will likely have about 20 columns and 5 rows on my teensy ++ but would like to use your firmware.

I don't think large matrix on TMK is so hard. It depends mainly on your C knowledge and skill. You better note that C has some pitfalls around int size on the MCU and integer promotion. To be honest I myself needed some trials and errors and to learn C a bit more, but it was fun totally in my case.
Title: Re: TMK keyboard firmware
Post by: VinnyCordeiro on Wed, 26 November 2014, 16:38:55
Searched about it, didn't find anything: is it possible in TMK to assign to a key the CEDILLA ( Ç )?
Title: Re: TMK keyboard firmware
Post by: hasu on Wed, 26 November 2014, 17:33:18
Yes, you can use MACRO for the purpose. See this post, it'll help you greatly.
http://deskthority.net/workshop-f7/tmk-keyboard-firmware-collection-t4478-120.html#p195620

Note that to input lang specific chars depends on your OS and its keyboard layout and USB HID spec doesn't define it as far as I know.
Title: Re: TMK keyboard firmware
Post by: Moralless on Thu, 27 November 2014, 06:51:10
Hasu I sent you a pm about this, but I guess it's relevant to this thread.

I'm currently planning to build a 70-key keyboard and I'm interested in adding a LED for each individual key. However, with how the matrix would be structured I would need to use 21 of the 24 pins available to the teensy, so I'm unsure if it's possible to be able to connect all the LEDs to 1-3 pins as I also want to have a few LEDs that toggles to indicate things such as caps lock, fuction layers being activated. I cam across  this (https://www.adafruit.com/products/1427) in another thread and was wondering if your firmware would be able to support this and if it does how would i go about connecting this board to a teensy?

Thanks for any help :).
Title: Re: TMK keyboard firmware
Post by: hasu on Thu, 27 November 2014, 19:16:27
TMK doesn't support that LED driver at this time, of course. But I think you can add support to your firmwaare with using TMK. And you may want to connect the driver to I2C pins of Teensy but any pins can be used with software I2C library.
Title: Re: TMK keyboard firmware
Post by: idollar on Tue, 02 December 2014, 18:14:07
Searched about it, didn't find anything: is it possible in TMK to assign to a key the CEDILLA ( Ç )?

Hi,

This is what I would do:

Set the  OS to "us international with dead-keys". CEDILLA "ć" will span if you type ' followed by c.

Add the following to the keyboard matrix definition:

Code: [Select]
/*
 * Macro definition
 */
enum macro_id {
    CEDILLA,
};

const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
{
    keyevent_t event = record->event;
    //uint8_t tap_count = record->tap_count;

    switch (id) {
        case CEDILLA:
            return (event.pressed ?
                    MACRO(  T(QUOT), W(100), T(C), END ) :
                    MACRO( END ) );
    }
    return MACRO_NONE;
}


const uint16_t PROGMEM fn_actions[] = {
    [0] = ACTION_MACRO(CEDILLA),
};
GRV

Once this is added, you should add "FN0" in the matrix were you want to the the CEDILLA

NOTE: I have not tested the code above. PM if needed. I

i$K
Title: Re: TMK keyboard firmware
Post by: Euf0ria on Tue, 09 December 2014, 01:42:58
About the LED backlighting, I'm building my own keyboard ("TANK 93" @ DT) right now and will implement a second matrix for the leds. They will be 100% individually controllable giving the ability to add cool effects and cluster light for functionality.
I will be using hasus code for the switch matrix in an Teensy++ 2.0 and then connect 2pcs of Texas instruments TLC5940 for the led matrix.  http://www.ti.com/product/TLC5940/samplebuy#topsidemarking (http://www.ti.com/product/TLC5940/samplebuy#topsidemarking)

Well, this is the plan right now but as I learn as I go there might be changes along the way. I also have help from a programmer and hope he will be able to support me all the way in programming the missing pieces for controlling the TLC5940s  triggered from actions in hasus code.

He already made this demo for me:
http://youtu.be/q_Rq5RtNolk (http://youtu.be/q_Rq5RtNolk)

Edit. Sorry for the bad youtube-link. Feel free to inform me on how to paste it properly;)
Title: Re: TMK keyboard firmware
Post by: hasu on Wed, 10 December 2014, 10:20:52
USB-USB converter was updated and now supports USB Hub, I confirmed HHKB pro2(which has internal hub) works.
https://github.com/tmk/tmk_keyboard/commit/b47450da9ffc1c296b3ba6ecd189fced0b7b8ed9

This update is first for two years since initial release :D
http://deskthority.net/workshop-f7/is-remapping-a-usb-keyboard-using-teensy-possible-t2841-30.html#p74854

Try it if interested.


EDIT:
Hardware requirement for USB-USB converter

Arduino Leonardo                                                                                               
    http://arduino.cc/en/Main/ArduinoBoardLeonardo                                                             
   
Circuit@Home USB Host Shield 2.0                                                                               
    https://www.circuitsathome.com/products-page/arduino-shields/usb-host-shield-2-0-for-arduino-assembled/
   
Buying Arduino Leonardo and USB Host Shield 2.0(from Circuit@home) will be the easiest way, you won't need even soldering iron.
Arduino's Shield will also work well but I think Sparkfun's needs to be modified.                             
   
    http://arduino.cc/en/Main/ArduinoUSBHostShield                                                             
    https://www.sparkfun.com/products/9947                                                                     
   
Also Pro Micro 3.3V(not Mini) or Teensy with mini host shield will work with some fixes on signal/power routing.
    https://www.circuitsathome.com/products-page/arduino-shields/usb-host-shield-for-arduino-pro-mini         
    https://www.sparkfun.com/products/12587                                                                   
    https://www.pjrc.com/teensy/td_libs_USBHostShield.html

And see README.
    https://github.com/tmk/tmk_keyboard/tree/master/converter/usb_usb

USB power and capacitance:
    http://www.pjrc.com/teensy/td_libs_USBHostShield.html#capacitance
Title: Re: TMK keyboard firmware
Post by: agodinhost on Sat, 03 January 2015, 09:51:47
Yesterday I added a portion of code to write de keyconf byte according to the Makefile.lufa configuration.
This code will enable NKRO by default.

I tested it into my keyboard with hid_listen and it worked fine. However I do not use the other "bootmagic / dip switch" features ...
I added the command 'W' to rewrite the eeprom with the new defaults - the previous version just wrote 0.

Couln't make my git work then I made the diff below.

Code: [Select]
common/avr/eeconfig.c          |  2 +-
 common/command.c               |  5 ++++
 common/eeconfig.h              | 58 ++++++++++++++++++++++++++++++++++++++++++
 keyboard/phantom/Makefile.lufa | 16 +++++++++---
 4 files changed, 77 insertions(+), 4 deletions(-)

diff --git a/common/avr/eeconfig.c b/common/avr/eeconfig.c
index 5bd47dc..8c8bbca 100644
--- a/common/avr/eeconfig.c
+++ b/common/avr/eeconfig.c
@@ -8,7 +8,7 @@ void eeconfig_init(void)
     eeprom_write_word(EECONFIG_MAGIC,          EECONFIG_MAGIC_NUMBER);
     eeprom_write_byte(EECONFIG_DEBUG,          0);
     eeprom_write_byte(EECONFIG_DEFAULT_LAYER,  0);
-    eeprom_write_byte(EECONFIG_KEYMAP,         0);
+    eeprom_write_byte(EECONFIG_KEYMAP,         EECONFIG_KEYMAP_DEFAULTS);
     eeprom_write_byte(EECONFIG_MOUSEKEY_ACCEL, 0);
 #ifdef BACKLIGHT_ENABLE
     eeprom_write_byte(EECONFIG_BACKLIGHT,      0);
diff --git a/common/command.c b/common/command.c
index 1a507e3..6ab844e 100644
--- a/common/command.c
+++ b/common/command.c
@@ -125,6 +125,7 @@ static void command_common_help(void)
     print("t: print timer count\n");
     print("s: print status\n");
     print("e: print eeprom config\n");
+    print("w: write eeprom config\n");
 #ifdef NKRO_ENABLE
     print("n: toggle NKRO\n");
 #endif
@@ -191,6 +192,10 @@ static bool command_common(uint8_t code)
             print_eeconfig();
             break;
 #endif
+        case KC_W:
+            eeconfig_init();
+ print("eeprom written\n");
+            break;
         case KC_CAPSLOCK:
             if (host_get_driver()) {
                 host_driver = host_get_driver();
diff --git a/common/eeconfig.h b/common/eeconfig.h
index 3cd1a17..41aa88b 100644
--- a/common/eeconfig.h
+++ b/common/eeconfig.h
@@ -49,6 +49,64 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #define EECONFIG_KEYMAP_SWAP_BACKSLASH_BACKSPACE    (1<<6)
 #define EECONFIG_KEYMAP_NKRO                        (1<<7)
 
+/* keyconf bit defaults */
+#ifdef SWAP_CONTROL_CAPSLOCK
+#define SWAP_CONTROL_CAPSLOCK_DEFAULT EECONFIG_KEYMAP_SWAP_CONTROL_CAPSLOCK
+#else
+#define SWAP_CONTROL_CAPSLOCK_DEFAULT 0
+#endif
+
+#ifdef CAPSLOCK_TO_CONTROL
+#define CAPSLOCK_TO_CONTROL_DEFAULT EECONFIG_KEYMAP_CAPSLOCK_TO_CONTROL
+#else
+#define CAPSLOCK_TO_CONTROL_DEFAULT 0
+#endif
+
+#ifdef SWAP_LALT_LGUI
+#define SWAP_LALT_LGUI_DEFAULT EECONFIG_KEYMAP_SWAP_LALT_LGUI
+#else
+#define SWAP_LALT_LGUI_DEFAULT 0
+#endif
+
+#ifdef SWAP_RALT_RGUI
+#define SWAP_RALT_RGUI_DEFAULT EECONFIG_KEYMAP_SWAP_RALT_RGUI
+#else
+#define SWAP_RALT_RGUI_DEFAULT 0
+#endif
+
+#ifdef NO_GUI
+#define NO_GUI_DEFAULT EECONFIG_KEYMAP_NO_GUI
+#else
+#define NO_GUI_DEFAULT 0
+#endif
+
+#ifdef SWAP_GRAVE_ESC
+#define SWAP_GRAVE_ESC_DEFAULT EECONFIG_KEYMAP_SWAP_GRAVE_ESC
+#else
+#define SWAP_GRAVE_ESC_DEFAULT 0
+#endif
+
+#ifdef SWAP_BACKSLASH_BACKSPACE
+#define SWAP_BACKSLASH_BACKSPACE_DEFAULT EECONFIG_KEYMAP_SWAP_BACKSLASH_BACKSPACE
+#else
+#define SWAP_BACKSLASH_BACKSPACE_DEFAULT 0
+#endif
+
+#ifdef NKRO_ENABLE
+#define NKRO_ENABLE_DEFAULT EECONFIG_KEYMAP_NKRO
+#else
+#define NKRO_ENABLE_DEFAULT 0
+#endif
+
+#define EECONFIG_KEYMAP_DEFAULTS \
+ SWAP_CONTROL_CAPSLOCK_DEFAULT | \
+ CAPSLOCK_TO_CONTROL_DEFAULT | \
+ SWAP_LALT_LGUI_DEFAULT | \
+ SWAP_RALT_RGUI_DEFAULT | \
+ NO_GUI_DEFAULT | \
+ SWAP_GRAVE_ESC_DEFAULT | \
+ SWAP_BACKSLASH_BACKSPACE_DEFAULT | \
+ NKRO_ENABLE_DEFAULT
 
 bool eeconfig_is_enabled(void);
 
diff --git a/keyboard/phantom/Makefile.lufa b/keyboard/phantom/Makefile.lufa
index 97756de..d77eb8d 100644
--- a/keyboard/phantom/Makefile.lufa
+++ b/keyboard/phantom/Makefile.lufa
@@ -101,10 +101,20 @@ BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000)
 #MOUSEKEY_ENABLE = yes # Mouse keys(+4700)
 EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
 CONSOLE_ENABLE = yes # Console for debug(+400)
-COMMAND_ENABLE = yes    # Commands for debug and configuration
-#SLEEP_LED_ENABLE = yes  # Breathing sleep LED during USB suspend
-#NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA
+COMMAND_ENABLE = yes # Commands for debug and configuration
+#SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend
 
+#
+# keyconf bit defaults
+#
+#SWAP_CONTROL_CAPSLOCK = yes
+#CAPSLOCK_TO_CONTROL = yes
+#SWAP_LALT_LGUI = yes
+#SWAP_RALT_RGUI = yes
+#NO_GUI = yes
+#SWAP_GRAVE_ESC = yes
+#SWAP_BACKSLASH_BACKSPACE = yes
+NKRO_ENABLE = yes # USB Nkey Rollover - supported ONLY in LUFA
 
 # Boot Section Size in bytes
 #   Teensy halfKay   512

I hope it helps.
Title: Re: TMK keyboard firmware
Post by: hasu on Thu, 08 January 2015, 10:47:10
I added initial support for Masdrop Infinity which based on mbed(cortex-M) and is not full fucinton yet; mouse keys, media keys, NKRO and etc.
https://github.com/tmk/tmk_keyboard/tree/master/keyboard/infinity

I don't think many users are around here yet, but if you have it try this.
Title: Re: TMK keyboard firmware
Post by: Hzza on Thu, 08 January 2015, 12:05:11
I added initial support for Masdrop Infinity which based on mbed(cortex-M) and is not full fucinton yet; mouse keys, media keys, NKRO and etc.
https://github.com/tmk/tmk_keyboard/tree/master/keyboard/infinity

I don't think many users are around here yet, but if you have it try this.

Brilliant, I'll give this a go when I get mine.
Title: Re: TMK keyboard firmware
Post by: spiceBar on Mon, 19 January 2015, 17:20:51
I added initial support for Masdrop Infinity which based on mbed(cortex-M) and is not full fucinton yet; mouse keys, media keys, NKRO and etc.
https://github.com/tmk/tmk_keyboard/tree/master/keyboard/infinity

I don't think many users are around here yet, but if you have it try this.

Has anyone confirmed that the TMK firmware works fine with the Infinity keyboard?

Had I known that TMK would be adapted to it, I would have purchased one. Now I have to wait for the next drop.
Title: Re: TMK keyboard firmware
Post by: loudaslife on Mon, 19 January 2015, 19:34:37
Sorry if this is a noob question, but all 18 of the Pro Micro (https://www.sparkfun.com/products/12640)'s IO pins can be used for the matrix, correct? Only 12 of the pins are labeled as digital IO, the rest are either ADC or Serial connections. The firmware will still work and treat them all as normal DIO pins?

So, to make a keyboard with a Pro Micro, I would first have to take a pin label from the Pro Micro (TX0, for example), reference the Pro Micro's schematic (http://dlnmh9ip6v2uc.cloudfront.net/datasheets/Dev/Arduino/Boards/Pro_Micro_v13.pdf) to find the MCU's pin label (PD3 TX), then reference the Teensy 2.0's Schematic (https://www.pjrc.com/teensy/schematic2.gif) to find the corresponding Teensy pin label (D3), which I can then FINALLY type into matrix.c

Is everything I've said in this post correct?
Title: Re: TMK keyboard firmware
Post by: hasu on Wed, 21 January 2015, 07:21:16
You can use all pins, but note that you may have problem with PB0 because of LED.

I have to know pin names like PD3 in Pro Micro schematic, you can forget Teensy. Pin name PD3 means third pin of port D and in source code you have to use register names like DDRD, PORTD and PIND(in case of port D).
Title: Re: TMK keyboard firmware
Post by: kirkvomit on Fri, 23 January 2015, 14:55:27
Can somebody explain how I can flash my keyboard over USB?
I installed TMK on my NerD 60 using USBasp programmer and avrdude.
Keyboard seems to work fine with TMK software.

When I press LShift+RShift+B (I changed KC_PAUSE to KC_B in common/command.c file),  keyboard stops to register any inputs for a few seconds, so I guess jump to bootloader is working.

I tried to flash keyboard using dfu-programmer and avrdude and have no success with them:

~$ sudo dfu-programmer atmega32u4 erase
dfu-programmer: no device present.

-----------------------------------------------------------------------------

~$ sudo avrdude -p atmega32u4 -c avr109 -P /dev/tty0 -U flash:w:nerd_lufa.hex -vvvv

avrdude: Version 6.0.1, compiled on Oct 21 2013 at 15:55:32
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is "/etc/avrdude.conf"
         User configuration file is "/home/trofimoff/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : /dev/tty0
         Using Programmer              : avr109
         AVR Part                      : ATmega32U4
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PA0
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom        65    20     4    0 no       1024    4      0  9000  9000 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           flash         65     6   128    0 yes     32768  128    256  4500  4500 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           lfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           hfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           efuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           lock           0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

         Programmer Type : butterfly
         Description     : Atmel AppNote AVR109 Boot Loader

Connecting to programmer: .avrdude: Send: . [1b]
avrdude: Send: S [53]
avrdude: ser_recv(): programmer is not responding
avrdude: butterfly_recv(): programmer is not responding

-------------------------------------------------------------------------------------------

Can somebody explain what I'm doing wrong?
Title: Re: TMK keyboard firmware
Post by: zarquon on Sat, 24 January 2015, 17:26:23
I'm using the tmk firmware and quite enjoying it:)
I'm keep refining my fn keys and ran into this: I an fn key which is, let's say: ACTION_MODS_KEY(MOD_RALT, KC_F) so basically a dedicated [ button.
But I would like to make it a dual role dedicated [ button, which types [ if I tap it, but switches to layer 5 if I hold it down (momentary switching).
So I'd like to have a combo of ACTION_LAYER_TAP_KEY where the key is an ACTION_MODS_KEY.
Is there a solution for this I'm not aware of or it's only possible with a custom function?
I'm not very good at C, I barely understand it.
Title: Re: TMK keyboard firmware
Post by: hasu on Sat, 24 January 2015, 18:11:00
zarquon,
unfortunately you have to develop your C skill, it is not possible to realize that function without writing code.

kirkvomit,
Hmm, I'm not sure what you are doing and I don't know about that keyboard at all.
So I have to do wild guess totally...

What does NerD 60 has controller? Really ATMega32U4? What does the keyboard have bootloader?
Tmk does not include bootloader nor remove/change bootloader. I think you can program it with same method that you programmed it the frist time.

Not that to make bootloader jump work correctlly you need to set correct bootloader size in config.h.

Title: Re: TMK keyboard firmware
Post by: kirkvomit on Sun, 25 January 2015, 06:08:26
Hasu,

Yes, controller is ATMega32U4, before flashing board with TMK firmware I changed its bootloader for ATMega32U4-usbdevice_dfu-1_0_0.hex from this page http://www.atmel.com/devices/atmega32u4.aspx?tab=documents (http://www.atmel.com/devices/atmega32u4.aspx?tab=documents).

I think the problem is that I'm using wrong serial port - Arduino Leonardo board creates /dev/ttyACM0 device in my system, but there is no any new /dev/tty device when Nerd 60 is connected...

About bootloader size, did you mean "OPT_DEFS += -DBOOTLOADER_SIZE=4096" from Makefile?
Title: Re: TMK keyboard firmware
Post by: xauser on Sun, 25 January 2015, 06:12:59
When I press LShift+RShift+B (I changed KC_PAUSE to KC_B in common/command.c file),  keyboard stops to register any inputs for a few seconds, so I guess jump to bootloader is working.

If you jump to bootloader by software keyboard stops registering key presses as long as you don't start application code again. If your keyboards just stops for a few seconds then you have to debug why and what is happening instead. If keyboard is at bootloader you'll see an Atmega device listed in your usb stack instead of a NerD TMK keyboard.

NerD 60 and 80 have ATMega32U4 controllers and were tested with Atmel DFU loader. All those details are in the Makefile. (This post was written with NerD 60 and tmk firmware)

@hasu, would you please merge my latest pull request for NerD project it fixes an important keymap issue.
Title: Re: TMK keyboard firmware
Post by: kirkvomit on Sun, 25 January 2015, 15:41:49
When I press LShift+RShift+B (I changed KC_PAUSE to KC_B in common/command.c file),  keyboard stops to register any inputs for a few seconds, so I guess jump to bootloader is working.

If you jump to bootloader by software keyboard stops registering key presses as long as you don't start application code again. If your keyboards just stops for a few seconds then you have to debug why and what is happening instead. If keyboard is at bootloader you'll see an Atmega device listed in your usb stack instead of a NerD TMK keyboard.

NerD 60 and 80 have ATMega32U4 controllers and were tested with Atmel DFU loader. All those details are in the Makefile. (This post was written with NerD 60 and tmk firmware)

@hasu, would you please merge my latest pull request for NerD project it fixes an important keymap issue.

Can you please say what are values of your fuse and lock bits?
And can you explain how can I debug TMK software?
Title: Re: TMK keyboard firmware
Post by: samwisekoi on Sun, 25 January 2015, 17:21:49
Prepping a dev environment to build a version of tmk for the JD45 and SD-60.  LMDE with gcc-avr and all dependencies installed. 

Testing compiler and environment with compiles of stock projects, I am able to make non-pjrc sucessfully, but for both phantom and gh60, Makefile.pjrc results in a compile error:

Code: [Select]
ron@silence:~/Downloads/tmk_keyboard-master_20150125/keyboard/gh60$ make -f Makefile clean
ron@silence:~/Downloads/tmk_keyboard-master_20150125/keyboard/gh60$ make -f Makefile
...
Size after:
   text    data     bss     dec     hex filename
  23634      56     178   23868    5d3c gh60_lufa.elf

-------- end --------
ron@silence:~/Downloads/tmk_keyboard-master_20150125/keyboard/gh60$ make -f Makefile.pjrc clean
ron@silence:~/Downloads/tmk_keyboard-master_20150125/keyboard/gh60$ make -f Makefile.pjrc
...
../../protocol/pjrc/main.c: In function ‘main’:
../../protocol/pjrc/main.c:60:5: warning: implicit declaration of function ‘sleep_led_init’ [-Wimplicit-function-declaration]
     sleep_led_init();
     ^
../../protocol/pjrc/main.c:64:13: error: too many arguments to function ‘suspend_power_down’
             suspend_power_down(WDTO_120MS);
             ^
In file included from ../../protocol/pjrc/main.c:36:0:
../../common/suspend.h:9:6: note: declared here
 void suspend_power_down(void);
      ^
make: *** [obj_gh60_pjrc/protocol/pjrc/main.o] Error 1

Identical behavior with the phantom.

This is the latest version of the package; downloaded and extracted today.  Should I try an older version?  My assumption is that both the gh60 and phantom code are long-established and clean.

Any thoughts, firmware people?

Thanks in advance,

 - Ron | samwisekoi
Sig auto-typed by my GH36 LH keypad.
Title: Re: TMK keyboard firmware
Post by: abjr on Sun, 25 January 2015, 17:53:38
You get this error because suspend_power_down() is called with a parameter when the function isn't defined to take one. I'm not sure there is a need to use the Makefile.pjrc, but you can fix this in 2 ways:

Code: [Select]

1)  In tmk_keyboard/protocol/pjrc/main.c change suspend_power_down(WDTO_120MS); to suspend_power_down();

OR

2)  In tmk_keyboard/common/suspend.h: change void suspend_power_down(void); to void suspend_power_down(uint8_t wdto);
    In tmk_keyboard/common/avr/suspend.c rewrite the suspend_power_down() function to:
    void suspend_power_down(uint8_t wdto)
    {
         power_down(wdto);
    }

#2 will break the LUFA Makefile though. The PJRC calls the function with a parameter while the LUFA code doesn't so the inconsistency would need to be fixed as the suspend.c code is common to both.
Title: Re: TMK keyboard firmware
Post by: hasu on Sun, 25 January 2015, 20:30:05
samwisekoi and abjr,
Fixed the error in master branch with method #1.
Thanks for your reporting and fix.
Title: Re: TMK keyboard firmware
Post by: samwisekoi on Sun, 25 January 2015, 20:34:45
Thanks very much!  I took option #1, and it compiled clean.

Absent a GH60, there is no way to tell if it worked, however!  Hmmm.  Time to finally build my Phantom?

Anyhow, thank you very much.

The odd thing is that I did not have this problem a month or so ago.

Hey, wait!  Someone just checked a fix in!

 - Ron | samwisekoi

[edit]
    It was hasu being fast as lightning!  Thank you sir!
[/edit]
Title: Re: TMK keyboard firmware
Post by: xauser on Mon, 26 January 2015, 13:30:38
Can you please say what are values of your fuse and lock bits?
And can you explain how can I debug TMK software?

I have no programmer attached to the NerD pcb now, so I can't read the fuses at the moment. You should keep all fuses the way they were set by GON unless you're sure about what you're doing!

You can place printf everywhere you like in tmk firmware. These get visible by pressing both shifts and d. You'll see them in hid_listen. But these debugs will be in application code not in bootloader.
Title: Re: TMK keyboard firmware
Post by: primitiveType on Tue, 27 January 2015, 13:36:58
Quick question ... Does TMK/Teensy support 104-key?
Title: Re: TMK keyboard firmware
Post by: Melvang on Tue, 27 January 2015, 14:00:49
Quick question ... Does TMK/Teensy support 104-key?

Technically yes, but the electrical layout is not going to match the physical row and column layout.  There just is not enough pins.  Though you should be able to use a Teensy 2.0++ version for extra pins and work just fine.  For example a full size layout will be 22 columns and 6 rows which is 28 pins plus 4 for 3 lock LEDs.  The standard Teensy does not have that many pins, but if you are creative with the electrical layout you can go 10x11 matrix for a total of 110 switches possible.
Title: Re: TMK keyboard firmware
Post by: abjr on Tue, 27 January 2015, 14:44:23
samwisekoi and abjr,
Fixed the error in master branch with method #1.
Thanks for your reporting and fix.

 :thumb:
Title: Re: TMK keyboard firmware
Post by: primitiveType on Tue, 27 January 2015, 15:03:49
Quick question ... Does TMK/Teensy support 104-key?

Technically yes, but the electrical layout is not going to match the physical row and column layout.  There just is not enough pins.  Though you should be able to use a Teensy 2.0++ version for extra pins and work just fine.  For example a full size layout will be 22 columns and 6 rows which is 28 pins plus 4 for 3 lock LEDs.  The standard Teensy does not have that many pins, but if you are creative with the electrical layout you can go 10x11 matrix for a total of 110 switches possible.

ok, I've never handwired a board before so that's slightly intimidating, but I think I understand what you mean and feel like I can probably do it with a bit of stumbling.

So when I make the keymap for TMK, I will have to write it out as it is logically- and TMK will work with the 10x11 matrix. I imagine it will be a bit painful writing it out like that without getting confused, but that's ok.
Title: Re: TMK keyboard firmware
Post by: Kaibz on Wed, 28 January 2015, 08:10:55
May is ask if that would be possible (if using a Teensy 2.0++) to output the Layer status and caps lock status to an LCD ?(16X2 connected to the Teensy 2.0++)

I mean i understand it would require code modifications to the firmware, but would it be really hard to do for a beginner and would it potentially compromise the responsiveness of the keyboard?
Title: Re: TMK keyboard firmware
Post by: xauser on Sat, 31 January 2015, 08:44:55
I have a problem when using the combination of layer tap key and layer toggle. If I do

FN0 = ACTION_LAYER_TAP_KEY(2, RGUI) -> FN1 = ACTION_LAYER_TOGGLE(1)

I expect that I toggled layer 1 after FN0 is released but instead I'm trapped in layer 2. Seems the first macro does not work as I expect. I'm back to momentary layer switching for now as this works:

FN0 = ACTION_LAYER_MOMENTARY(2) -> FN1 =  ACTION_LAYER_TOGGLE(1)
Title: Re: TMK keyboard firmware
Post by: hasu on Sat, 31 January 2015, 09:40:07
Hmm, I can't understand your problem.

Can you show all your keymap layers and key sequence you typed in fact?
You mean you typed like FN0(down), FN0(up), FN1(down) and FN1(up)?

BTW, RGUI is modifier and it is not useful to tap modifier in most cases.

Title: Re: TMK keyboard firmware
Post by: vicibz on Mon, 23 February 2015, 14:01:44
I'm trying to implement The Pegasus Hoof support and almost got it right except for a few double keystrokes and a few more non-working keys.
I'll have to debug and double check the matrix and layout, but in case someone wants to help, here's my commit:
https://github.com/vpont/tmk_keyboard/compare/tmk:master...master

Thanks!

Edit: Found and fixed. It's 100% working now :)
Title: Re: TMK keyboard firmware
Post by: vicibz on Tue, 24 February 2015, 04:34:21
I'm messing with layers and I'm obtaining weird behaviour:
First things first: My keymap (https://github.com/vpont/tmk_keyboard/blob/master/keyboard/pegasus_hoof/keymap.h)

As you see I have three layers defined:
Layer 1 is activated by pressing Fn0
Layer 2 is activated by pressing Fn0 + RgtCtl

It works fine but i.e. when I press Fn0 + RgtCtl + Esc I get the calculator and then I release all three keys and press Esc again the calculator opens up again, when I should be back in Layer 0.

What's wrong?
Thanks!
Title: Re: TMK keyboard firmware
Post by: spiceBar on Tue, 24 February 2015, 05:16:58
I'm messing with layers and I'm obtaining weird behaviour:
First things first: My keymap (https://github.com/vpont/tmk_keyboard/blob/master/keyboard/pegasus_hoof/keymap.h)

As you see I have three layers defined:
Layer 1 is activated by pressing Fn0
Layer 2 is activated by pressing Fn0 + RgtCtl

It works fine but i.e. when I press Fn0 + RgtCtl + Esc I get the calculator and then I release all three keys and press Esc again the calculator opens up again, when I should be back in Layer 0.

What's wrong?
Thanks!


Yeah, it happened to me as well.

If you release FN0 first, then RCTL, a key release for FN1 is never generated, because there is no FN1 in the first layer.
Title: Re: TMK keyboard firmware
Post by: vicibz on Tue, 24 February 2015, 05:35:41
Yeah, it happened to me as well.

If you release FN0 first, then RCTL, a key release for FN1 is never generated, because there is no FN1 in the first layer.

Thanks for confirming, looks like we did hit a bug then, didn't we?
Shouldn't all keys that don't belong to a layer after layer change be released?
Title: Re: TMK keyboard firmware
Post by: spiceBar on Tue, 24 February 2015, 07:17:19
Yeah, it happened to me as well.

If you release FN0 first, then RCTL, a key release for FN1 is never generated, because there is no FN1 in the first layer.

Thanks for confirming, looks like we did hit a bug then, didn't we?
Shouldn't all keys that don't belong to a layer after layer change be released?

I'm pretty sure Hasu knows about this, and there may be a sensible reason for this behavior.

I believe the correct thing would be to send a release event for all previous pending key press events sent by that key, but there may be corner cases for which this would fail.

At this point, you should avoid putting modifiers or layer change keys in secondary layers. If you do it anyway, these keys must have the same function and name in all the layers: this way the key release event is always correctly sent.

Or maybe Hasu has a special way to deal with this?
Title: Re: TMK keyboard firmware
Post by: hasu on Tue, 24 February 2015, 07:27:33

If you release FN0 before Fn1 it'll happen. In that case Layer 1 is already disabled  when right bottom key is released and the key is interpreted as RCtl not Fn1 then, Layer 2 is stuck in the end.

Place Fn1 on Layer 2 also.
Title: Re: TMK keyboard firmware
Post by: hasu on Tue, 24 February 2015, 07:56:24
Ah, as spiceBar said you better place Fn1 on Layer 0.
You can not place modifier and Fn on same key, practically.

It is by desgin not bug but current keymap system inroduces some limitations and not-intuitive behaviours. I hope next keymap system fixes these limitations.
Title: Re: TMK keyboard firmware
Post by: ladoga on Tue, 24 February 2015, 17:52:32
Hi.

Just chiming in to ask if someone has hacked support for using Caps Lock/Scroll Lock LEDs for Fn Lock? (LED on when FN layer is active)
Title: Re: TMK keyboard firmware
Post by: araif on Thu, 26 February 2015, 05:28:07
Hello,
I'm trying to implement backlight with a bunch of leds connected to a single pin and trying to control voltage and so backlight intensity, I've copied code from the lightsaber keyboard and removed all but one pin config, but I'm unable to have different backlights intensities, only one is available. What are the steps to get this working? thanks
Title: Re: TMK keyboard firmware
Post by: hasu on Thu, 26 February 2015, 18:05:16
ladoga, check FAQ which has an related entry, IIRC.

araif, I think it depneds on your hardware design. Doing a wild guess, maybe you need PWM?
Title: Re: TMK keyboard firmware
Post by: araif on Thu, 26 February 2015, 19:17:24
araif, I think it depneds on your hardware design. Doing a wild guess, maybe you need PWM?

I saw the sleep led example and I was able to get something similar working, with a bit of work in that direction I should get something usable,

another question is this, I have a trackpoint module that is connected to PD5 for clock and PD4 for data, I'm copying code from onekey and using busywait method, what I see is that the keyboard that is controlled from the same teensy lags really hard for various keys, they are recognized only if I fire multiple events holding a key, maybe the problem is the ps2 events from the mouse spamming the interrupts or something, I was trying also to use the ps2 interrupt version with no success, how can I fix this, is more info needed to debug this on your side? thanks

Title: Re: TMK keyboard firmware
Post by: hasu on Thu, 26 February 2015, 19:41:17
another question is this, I have a trackpoint module that is connected to PD5 for clock and PD4 for data, I'm copying code from onekey and using busywait method, what I see is that the keyboard that is controlled from the same teensy lags really hard for various keys, they are recognized only if I fire multiple events holding a key, maybe the problem is the ps2 events from the mouse spamming the interrupts or something, I was trying also to use the ps2 interrupt version with no success, how can I fix this, is more info needed to debug this on your side? thanks

Send me your keyboard if you want me to debug :)
At first you have to find exactly where your problem are located on, you'll be able to use debug print of timer for this purpose.
Title: Re: TMK keyboard firmware
Post by: araif on Thu, 26 February 2015, 21:19:18
Send me your keyboard if you want me to debug :)
At first you have to find exactly where your problem are located on, you'll be able to use debug print of timer for this purpose.

:D that's not exactly what I intended but thanks anyway, that keyboard is a standard atomic short space keyboard with this pinout I'm doing (not sure if there is a standard, I connected them based on comfort while soldering)

Code: [Select]
/* Column pin configuration
 * col: 14 13 12 11 10 9  8  7  6  5  4  3  2  1  0
 * pin: F0 F1 F4 F5 F6 F7 B6 B5 B4 D7 B0 B1 B2 B3 B7
 */

/* Row pin configuration
 * row: 0  1  2  3 4
 * pin: D1 D0 D2 D3 C6
 */



#ifdef PS2_USE_BUSYWAIT
#   define PS2_CLOCK_PORT  PORTD
#   define PS2_CLOCK_PIN   PIND
#   define PS2_CLOCK_DDR   DDRD
#   define PS2_CLOCK_BIT   5
#   define PS2_DATA_PORT   PORTD
#   define PS2_DATA_PIN    PIND
#   define PS2_DATA_DDR    DDRD
#   define PS2_DATA_BIT    4
#endif


regarding the interrupt mode, should I do something particular to make it work? would that be better than busy wait in terms of power and resources usage?

EDIT:
with hid_listen I see a *LOT* and fast of events like this, is this normal?

Code: [Select]
5680d ps2_mouse raw: [08|00 00]
5691d ps2_mouse raw: [08|00 00]
5703d ps2_mouse raw: [08|00 00]
5714d ps2_mouse raw: [08|00 00]
5725d ps2_mouse raw: [08|00 00]
5737d ps2_mouse raw: [08|0000]
5748d ps2_mouse raw: [08|00 00]
5760d ps2_mouse raw: [08|00 00]

Title: Re: TMK keyboard firmware
Post by: hasu on Thu, 26 February 2015, 21:33:20
I don't use PS/2 mouse or TrackPoint long time so I don't remmeber it is normal. You have to source code and see whether it is just a info message or error message.


Did you already see my PM?
Quote
I don't think it doesn't work with ps2_interrupt.c but I didn't try it myself.

You'll need to place proper interrupt configuration on PD5 with editting PS2_INT_INIT of config.h.
I use INT1 interrupt on PD1 while you are using PD5 which has different interrupt PCINT5, you need different intialized code for that.
Title: Re: TMK keyboard firmware
Post by: araif on Thu, 26 February 2015, 21:54:13
I don't use PS/2 mouse or TrackPoint long time so I don't remmeber it is normal. You have to source code and see whether it is just a info message or error message.


Did you already see my PM?
Quote
I don't think it doesn't work with ps2_interrupt.c but I didn't try it myself.

You'll need to place proper interrupt configuration on PD5 with editting PS2_INT_INIT of config.h.
I use INT1 interrupt on PD1 while you are using PD5 which has different interrupt PCINT5, you need different intialized code for that.

sorry I missed the pm, no it's not an error, it is printed in ps2_mouse when executing the ps2_mouse_task, I think that the trackpoint floods with events  (maybe due to polling?), and other key events for the keyboard cannot be delivered, so the original problem.

For the reset code I'm trying with this but this leads to nothing working anymore...

Code: [Select]

/* PS/2 mouse interrupt version */
#ifdef PS2_USE_INT
/* uses INT1 for clock line(ATMega32U4) */
#define PS2_CLOCK_PORT  PORTD
#define PS2_CLOCK_PIN   PIND
#define PS2_CLOCK_DDR   DDRD
#define PS2_CLOCK_BIT   5
#define PS2_DATA_PORT   PORTD
#define PS2_DATA_PIN    PIND
#define PS2_DATA_DDR    DDRD
#define PS2_DATA_BIT    4

#define PS2_INT_INIT()  do {    \
    EICRA |= ((1<<ISC11) |      \
              (0<<ISC10));      \
} while (0)
#define PS2_INT_ON()  do {      \
    EIMSK |= (1<<PCINT5);         \
} while (0)
#define PS2_INT_OFF() do {      \
    EIMSK &= ~(1<<PCINT5);        \
} while (0)
#define PS2_INT_VECT    INT1_vect
#endif

Title: Re: TMK keyboard firmware
Post by: araif on Thu, 26 February 2015, 22:24:22
ok I resoldered and isolated few components I had flying for testing and this ps2<->keyboard "ghosting" seems disappeared, for today I declare it as gone, I'll check better tomorrow :) . If you have more pointers on how to configure the interrupt version though that will be really welcome (I feel that it should be the way to go instead of busy waiting).
Title: Re: TMK keyboard firmware
Post by: hasu on Thu, 26 February 2015, 23:15:38
This code prints these message and which indicates pollings are occured each 11ms and no mouse movement. hmm, it takes too long for iteration?

https://github.com/tmk/tmk_keyboard/blob/master/protocol/ps2_mouse.c#L88-L92

Ignore 'd'.
Quote
5680d ps2_mouse raw: [08|00 00]
5691d ps2_mouse raw: [08|00 00]
5703d ps2_mouse raw: [08|00 00]
5714d ps2_mouse raw: [08|00 00]
5725d ps2_mouse raw: [08|00 00]
5737d ps2_mouse raw: [08|0000]
5748d ps2_mouse raw: [08|00 00]
5760d ps2_mouse raw: [08|00 00]

You are using stream mode and 'busy wait' impl? I don't think this combination works well.

You may want to know how long this part of code takes. This part can take long time in some situation.
https://github.com/tmk/tmk_keyboard/blob/master/protocol/ps2_mouse.c#L79-L83

Because ps2_host_recv_response() can block 25ms in the worst case.
https://github.com/tmk/tmk_keyboard/blob/master/protocol/ps2_busywait.c#L124



To eanble 'interrupt' impl...

AVR interrupt PCINT and INT is not same you'll have to use different initialize code. My original code is for INT and doesn't not work with PCINT.

Consult with datasheet of your MCU(ATMega32u4?). Registers EICRA and EIMSK are used only for INT, you have to find register names for PCINT in the document.
Title: Re: TMK keyboard firmware
Post by: araif on Fri, 27 February 2015, 08:36:20
are you sude PD5 is pcint5 ? on the datasheet I see (XCK1/CTS) PD5 http://www.atmel.com/images/doc7766.pdf  , is that even possible to use interrupts on that pin?
Title: Re: TMK keyboard firmware
Post by: hasu on Fri, 27 February 2015, 09:02:18
Ah, PCINT5 is for PB5. PD5 cannot be used with pin interrupt, perhaps.
Title: Re: TMK keyboard firmware
Post by: araif on Fri, 27 February 2015, 09:05:19
then maybe I can use usart there with pd5 on clock and pd4 for data? How should I modify the implementation you have on onekey to get this working?

as you probably understood I'm no expert here.

EDIT:
also, maybe to use the interrupt version I can switch a pin used for the keyboard matrix (used for the third row now) that it's on PD1 and continue using PD4 for data from the trackpoint, would that work? So using PD1 for clock, PD4 for data , and PD5 for third row of the keyboard matrix.
Title: Re: TMK keyboard firmware
Post by: hasu on Fri, 27 February 2015, 09:20:47
You need to use PD2 for data (RXD) in case of UART .
Title: Re: TMK keyboard firmware
Post by: araif on Fri, 27 February 2015, 09:28:40
must I use pd2 also in case of interrupt version? and so given I have to switch a pin that now is used for the keyboard matrix, is that better to use the interrupt version or usart?

the two options would be:
1) int version: pd1 for clock, pd4 for data , pd5 for keyboard row
2) usart version: pd5 for clock, pd2 for data, pd4 for keyboard row

also, thanks for the answers, you are really helping me out!
Title: Re: TMK keyboard firmware
Post by: hasu on Fri, 27 February 2015, 09:48:07
Yes. You're right. In UART PD2 as Data and PD5 as Clock have to be used.  In interrupt mode you can use any pin as Data and any INT or PCINT pin as Clock.
Title: Re: TMK keyboard firmware
Post by: araif on Fri, 27 February 2015, 10:06:32
ok, should I choose the interrupt version or usart? what is better?

thanks again.
Title: Re: TMK keyboard firmware
Post by: araif on Fri, 27 February 2015, 12:57:42
.
Title: Re: TMK keyboard firmware
Post by: hasu on Fri, 27 February 2015, 19:08:27
hmm, USART version reduces intterupts in comparison to the other but no perceivable difference, I think.
I'd use Interrupt version, it is more flexible in terms of pin configuration.
Title: Re: TMK keyboard firmware
Post by: p3lim on Sun, 01 March 2015, 20:48:17
Finished soldering my keyboard yesterday, flashed the firmware on it today (Teensy2) with gh60 (before changing the matrix), it would fire random media keys at it's own will (calculator, browser, email, mute my sound etc).
After I changed the required parts in matrix.c it doesn't do anything at all.

I tried using PJRC's hid_listen, it finds the device but it doesn't print out anything at all.

Are there any other debug steps I could take, or could any of you help me? I'm on IRC (same username).

Relevant parts:
More
My keyboard's physical matrix:
http://www.keyboard-layout-editor.com/#/layouts/830542b7fea07184e3a44d58e00292fa

matrix.c
Code: [Select]
static void init_cols(void)
{
DDRF &= ~(1<<7 | 1<<6 | 1<<5 | 1<<4 | 1<<1 | 1<<0);
PORTF |= (1<<7 | 1<<6 | 1<<5 | 1<<4 | 1<<1 | 1<<0);
DDRB &= ~(1<<6 | 1<<5 | 1<<4);
PORTB |= (1<<6 | 1<<5 | 1<<4);
DDRD &= ~(1<<7 | 1<<3 | 1<<2);
PORTD |= (1<<7 | 1<<3 | 1<<2);
DDRC &= ~(1<<7 | 1<<6);
PORTC |= (1<<7 | 1<<6);
}

static matrix_row_t read_cols(void)
{
return (PINF&(1<<0) ? 0 : (1<<0)) |
(PINF&(1<<1) ? 0 : (1<<1)) |
(PINF&(1<<4) ? 0 : (1<<2)) |
(PINF&(1<<5) ? 0 : (1<<3)) |
(PINF&(1<<6) ? 0 : (1<<4)) |
(PINF&(1<<7) ? 0 : (1<<5)) |
(PINB&(1<<6) ? 0 : (1<<6)) |
(PINB&(1<<5) ? 0 : (1<<7)) |
(PINB&(1<<4) ? 0 : (1<<8)) |
(PIND&(1<<7) ? 0 : (1<<9)) |
(PIND&(1<<2) ? 0 : (1<<10)) |
(PIND&(1<<3) ? 0 : (1<<11)) |
(PINC&(1<<6) ? 0 : (1<<12)) |
(PINC&(1<<7) ? 0 : (1<<13));
}

static void unselect_rows(void)
{
DDRB &= ~0b10001111;
PORTB &= ~0b10001111;
}

static void select_row(uint8_t row)
{
switch (row) {
case 0:
DDRB  |= (1<<0);
PORTB &= ~(1<<0);
break;
case 1:
DDRB  |= (1<<1);
PORTB &= ~(1<<1);
break;
case 2:
DDRB  |= (1<<2);
PORTB &= ~(1<<2);
break;
case 3:
DDRB  |= (1<<3);
PORTB &= ~(1<<3);
break;
case 4:
DDRB  |= (1<<7);
PORTB &= ~(1<<7);
break;
}
}

keymap_common.h
Code: [Select]
#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, \
K30, K31, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B,      K3D, \
K40, K41, K42,                K46,           K49, K4A, K4B,      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_NO    }, \
{ 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_NO,    KC_##K3D }, \
{ KC_##K40, KC_##K41, KC_##K42, KC_NO,    KC_NO,    KC_NO,    KC_##K46, KC_NO,    KC_NO,    KC_##K49, KC_##K4A, KC_##K4B, KC_NO,    KC_##K4D } \
}

keymap_plain.c (I modified the Makefile to use this as default)
Code: [Select]
#include "keymap_common.h"

const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
/* 0: qwerty */
KEYMAP(ESC, 1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   MINS,EQL, BSPC, \
   TAB, Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,   LBRC,RBRC,ENT, \
   CAPS,A,   S,   D,   F,   G,   H,   J,   K,   L,   SCLN,QUOT,BSLS,  \
   LSFT,Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, SLSH,RSFT,DEL, \
   LCTL,LGUI,LALT,          SPC,                     RALT,RGUI,APP, RCTL),
};
const uint16_t PROGMEM fn_actions[] = {};

Also changed the boot section size in the Makefile to match the Teensy halfKay (512 bytes).

Title: Re: TMK keyboard firmware
Post by: vicibz on Mon, 02 March 2015, 05:41:54
Also changed the boot section size in the Makefile to match the Teensy halfKay (512 bytes).

In a quick "review" those code bits look fine to me.
I would start by leaving the boot section as it was, with the LUFA bootloader (OPT_DEFS += -DBOOTLOADER_SIZE=4096).
Title: Re: TMK keyboard firmware
Post by: p3lim on Mon, 02 March 2015, 05:59:55
Also changed the boot section size in the Makefile to match the Teensy halfKay (512 bytes).

In a quick "review" those code bits look fine to me.
I would start by leaving the boot section as it was, with the LUFA bootloader (OPT_DEFS += -DBOOTLOADER_SIZE=4096).

Which would be the default setting for the gh60 driver, which I flashed unmodified first as a test.
As an update I've tested the teensy with different stuff PJRC provides from their website, and they all work fine. Later today I'll get my multimeter out and verify every connection for continuity, just to eliminate any faults in my soldering.
Title: Re: TMK keyboard firmware
Post by: hasu on Mon, 02 March 2015, 10:21:41
Multimeter is the best tool and first thing to do when it comes to DIY hardware :D

You will need 'debug_enable=yes' in matrix_init() unless your matrix works well.
https://github.com/tmk/tmk_keyboard/wiki/FAQ#cant-get-message-on-console

If you are on Windows, just replug in another USB ports.
https://github.com/tmk/tmk_keyboard/wiki/FAQ-Build#edit-configuration-but-not-change

And check this. I think this is not needed if you are using Teensy, though.
https://github.com/tmk/tmk_keyboard/wiki/FAQ#using-pf4-7-pins-of-usb-avr


Finished soldering my keyboard yesterday, flashed the firmware on it today (Teensy2) with gh60 (before changing the matrix), it would fire random media keys at it's own will (calculator, browser, email, mute my sound etc).
After I changed the required parts in matrix.c it doesn't do anything at all.

I tried using PJRC's hid_listen, it finds the device but it doesn't print out anything at all.

Are there any other debug steps I could take, or could any of you help me? I'm on IRC (same username).
Title: Re: TMK keyboard firmware
Post by: p3lim on Mon, 02 March 2015, 10:45:40
Just went over with a multimeter to test the diodes and continuity, everything works well, even tested the pins on the teensy (with a driver from PJRC and shorting the pins), all of that works well.
I'll take a look at those links you provided and come back to you.

Edit: checked the properties for the keyboard, found this:

(http://i.imgur.com/40cIzBh.png)
Title: Re: TMK keyboard firmware
Post by: wowmate on Wed, 04 March 2015, 02:22:43
Im 100% illiterate when it comes to coding and I wondering how I could have pwm control for a single pin for leds. I also looked at the led.c file of multiple builds but can't figure out why some have "DDR", "PORT", "|". or "&" there are too many variations  I don't understand.
I would like it to just be toggleable. Thanks in advance.
Title: Re: TMK keyboard firmware
Post by: hasu on Wed, 04 March 2015, 03:27:55
p3lim,
Ive never seen that message actually(is it on windows8?) but it just smells like very Windows driver cache problem. Just try another ports, removing driver of keyboard completely or using new VIDID pair.
Title: Re: TMK keyboard firmware
Post by: hasu on Wed, 04 March 2015, 03:38:15
Post your schematic to let us know how you connect the LEDs.
and forget PWM for a while, looks like you need to learn some things to use it.  At first learn how you can turn on a LED solid.


Im 100% illiterate when it comes to coding and I wondering how I could have pwm control for a single pin for leds. I also looked at the led.c file of multiple builds but can't figure out why some have "DDR", "PORT", "|". or "&" there are too many variations  I don't understand.
I would like it to just be toggleable. Thanks in advance.
Title: Re: TMK keyboard firmware
Post by: p3lim on Wed, 04 March 2015, 05:42:09
p3lim,
Ive never seen that message actually(is it on windows8?) but it just smells like very Windows driver cache problem. Just try another ports, removing driver of keyboard completely or using new VIDID pair.

I found it was corrupted drivers, had to run Windows in safe-mode to delete them (uninstalling would not do it, it would just reinstall the same corrupted drivers), that sorted it for me. And yes, it was on Windows 8 (.1).
Title: Re: TMK keyboard firmware
Post by: tlem on Wed, 04 March 2015, 08:24:03
Im 100% illiterate when it comes to coding and I wondering how I could have pwm control for a single pin for leds. I also looked at the led.c file of multiple builds but can't figure out why some have "DDR", "PORT", "|". or "&" there are too many variations  I don't understand.
I would like it to just be toggleable. Thanks in advance.

If you want to learn it yourself, check out these
http://en.wikipedia.org/wiki/Bitwise_operations_in_C (http://en.wikipedia.org/wiki/Bitwise_operations_in_C)
https://www.youtube.com/watch?v=ZhIRRyhfhLM (https://www.youtube.com/watch?v=ZhIRRyhfhLM)
You will also want to read the datasheet for your chip
Title: Re: TMK keyboard firmware
Post by: wowmate on Wed, 04 March 2015, 09:40:55
Post your schematic to let us know how you connect the LEDs.
and forget PWM for a while, looks like you need to learn some things to use it.  At first learn how you can turn on a LED solid.


Im 100% illiterate when it comes to coding and I wondering how I could have pwm control for a single pin for leds. I also looked at the led.c file of multiple builds but can't figure out why some have "DDR", "PORT", "|". or "&" there are too many variations  I don't understand.
I would like it to just be toggleable. Thanks in advance.

The reason why I want or rather need pwm is because I would like to use 50ish leds and pin number D6  on a teensy 2.0 for pwm.

I have stock files from tmk

Title: Re: TMK keyboard firmware
Post by: hasu on Wed, 04 March 2015, 15:27:23
I don't know how you can control the 50ish LEDs with one PWM pin. You have idea or reference of design?
Title: Re: TMK keyboard firmware
Post by: wowmate on Wed, 04 March 2015, 17:35:00
I don't know how you can control the 50ish LEDs with one PWM pin. You have idea or reference of design?

just in parallel pin12  and ground or i need to split the pins thats ok too. i just want full backlighting with pwm or otherwise i wouldn't have enough current
Title: Re: TMK keyboard firmware
Post by: p3lim on Mon, 09 March 2015, 07:55:18
Is it possible to add a repeating action as a function?
As an example: if key A is held, send the A key every 50ms.
Title: Re: TMK keyboard firmware
Post by: QuiGonJinn on Mon, 09 March 2015, 08:53:50
Quick question ... Does TMK/Teensy support 104-key?

Technically yes, but the electrical layout is not going to match the physical row and column layout.  There just is not enough pins.  Though you should be able to use a Teensy 2.0++ version for extra pins and work just fine.  For example a full size layout will be 22 columns and 6 rows which is 28 pins plus 4 for 3 lock LEDs.  The standard Teensy does not have that many pins, but if you are creative with the electrical layout you can go 10x11 matrix for a total of 110 switches possible.

ok, I've never handwired a board before so that's slightly intimidating, but I think I understand what you mean and feel like I can probably do it with a bit of stumbling.

So when I make the keymap for TMK, I will have to write it out as it is logically- and TMK will work with the 10x11 matrix. I imagine it will be a bit painful writing it out like that without getting confused, but that's ok.

Actually I find it much easier to use some kind of decoding technique,  and control for example 16 matrix rows with 4 controller pins.
Title: Re: TMK keyboard firmware
Post by: l_b on Wed, 11 March 2015, 16:49:06
I added initial support for Masdrop Infinity which based on mbed(cortex-M) and is not full fucinton yet; mouse keys, media keys, NKRO and etc.
https://github.com/tmk/tmk_keyboard/tree/master/keyboard/infinity

I don't think many users are around here yet, but if you have it try this.

Do you think media keys (and nkro) will be implemented? I'd love to use the tmk firmware with the infinity. Using it on my ergodox was awesome.
Title: Re: TMK keyboard firmware
Post by: hasu on Wed, 11 March 2015, 17:05:10
I'll implement those functions for cortex controller finally in some point of future, but I don't know when.
Title: Re: TMK keyboard firmware
Post by: swill on Wed, 11 March 2015, 17:44:01
Is it possible to add a repeating action as a function?
As an example: if key A is held, send the A key every 50ms.

If he does add this functionality, I would recommend actually implementing it like this.

If a key is held for more than 500ms, then start repeating the key every 50ms (or whatever configurable value).

This will reduce the illusion of debounce if people don't press and release quickly.  This is how most keyboards handle that...
Title: Re: TMK keyboard firmware
Post by: admiralvorian on Wed, 11 March 2015, 18:49:41
I am trying to customize the keymap for kairyu's custom firmware (supports backlight) for an abostudio ghpad (red scarf I) but no matter what changes i make on the keymap, they do not appear after flashing the device.

first i clone https://github.com/kairyu/tmk_keyboard_custom

then edit /leyboard/ghpad/keymap_redscarf.c and make it look like this: http://pastebin.com/GX7qtyZs (http://pastebin.com/GX7qtyZs) all number keys are "1" for testing

then I run
Code: [Select]

make KEYMAP=redscarf VERBOSE=1

here is the terminal output : http://pastebin.com/XShRpHQg (http://pastebin.com/XShRpHQg) here

then I do


Code: [Select]
sudo make dfu

which runs "sudo dfu-programmer atmega32u4 erase; sudo dfu-programmer atmega32u4 flash ghpad_lufa.hex; sudo dfu-programmer atmega32u4 reset" and all commands appear to execute successfully.

*note: I also copy any keymap file to "keymap_custom.c" edit that and compile with KEYMAP=custom; still the same result, keymap on device does not change after flashing

I know this is a modified version of your firmware, if i should talk to someone else please let me know.
Title: Re: TMK keyboard firmware
Post by: hasu on Wed, 11 March 2015, 19:21:00
I'm not much interested in developing gaming functions, but in assisting people having difficultiy with normal keyboard.
That said, OS repeating config seems to do fairly good job in both Mac and Windows.

Repeating in firmware will be a bit of a work with referencing timer. It is difficult or impossible to implement in keymap file at this time.

Is it possible to add a repeating action as a function?
As an example: if key A is held, send the A key every 50ms.

If he does add this functionality, I would recommend actually implementing it like this.

If a key is held for more than 500ms, then start repeating the key every 50ms (or whatever configurable value).

This will reduce the illusion of debounce if people don't press and release quickly.  This is how most keyboards handle that...

Title: Re: TMK keyboard firmware
Post by: swill on Wed, 11 March 2015, 19:23:11


I'm not much interested in developing gaming functions, but in assisting people having difficultiy with normal keyboard.
That said, OS repeating config seems to do fairly good job in both Mac and Windows.

Repeating in firmware will be a bit of a work with referencing timer. It is difficult or impossible to implement in keymap file at this time.

Is it possible to add a repeating action as a function?
As an example: if key A is held, send the A key every 50ms.

If he does add this functionality, I would recommend actually implementing it like this.

If a key is held for more than 500ms, then start repeating the key every 50ms (or whatever configurable value).

This will reduce the illusion of debounce if people don't press and release quickly.  This is how most keyboards handle that...

Makes sense. So we should be able to get repeating support through our OS. Makes total sense not to add it then. :)
Title: Re: TMK keyboard firmware
Post by: hasu on Wed, 11 March 2015, 19:36:58
admiralvorian,

build process seems to be OK. Did default keymap works for you?

You better do 'make clean' if you have trouble in built frimware.
https://github.com/tmk/tmk_keyboard/wiki/FAQ-Build#do-make-clean-before-make

Also check this if you are on windows
https://github.com/tmk/tmk_keyboard/wiki/FAQ-Build#edit-configuration-but-not-change


(And make sure your numlock status, note that '1' on pad may work as 'End'.)
Title: Re: TMK keyboard firmware
Post by: p3lim on Wed, 11 March 2015, 19:58:01
Is it possible to add a repeating action as a function?
As an example: if key A is held, send the A key every 50ms.

If he does add this functionality, I would recommend actually implementing it like this.

If a key is held for more than 500ms, then start repeating the key every 50ms (or whatever configurable value).

This will reduce the illusion of debounce if people don't press and release quickly.  This is how most keyboards handle that...

Windows (at least) does a fine job at executing repeating actions like you described, what I want is something that does not behave like that, but not for the whole keyboard, just one key.
Title: Re: TMK keyboard firmware
Post by: l_b on Thu, 12 March 2015, 02:56:40
I'll implement those functions for cortex controller finally in some point of future, but I don't know when.
Ok, awesome. I'm going to try out the current firmware this week.
Title: Re: TMK keyboard firmware
Post by: hasu on Thu, 12 March 2015, 03:20:51
I'll implement those functions for cortex controller finally in some point of future, but I don't know when.
Ok, awesome. I'm going to try out the current firmware this week.

Nice. let me know if you have trouble on compiling or something.
Also pre-compiled firmware is available here.
https://geekhack.org/index.php?topic=69231.msg1667956#msg1667956

Title: Re: TMK keyboard firmware
Post by: regack on Thu, 12 March 2015, 07:46:09
hasu,

This might be a kind of basic question, but when updating to the latest version, do I basically just  copy my /keyboard/[design] into the new firmware /keyboard directory and recompile? 
Title: Re: TMK keyboard firmware
Post by: admiralvorian on Thu, 12 March 2015, 10:46:31
admiralvorian,

build process seems to be OK. Did default keymap works for you?

You better do 'make clean' if you have trouble in built frimware.
https://github.com/tmk/tmk_keyboard/wiki/FAQ-Build#do-make-clean-before-make

Also check this if you are on windows
https://github.com/tmk/tmk_keyboard/wiki/FAQ-Build#edit-configuration-but-not-change


(And make sure your numlock status, note that '1' on pad may work as 'End'.)

Thank you hasu! I do 'make clean' between every compile, I'm doing this on ubuntu 14.04.1. I even removed the entire directory and re-cloned from github.

I will let you guys know if I find out what's happening.
Title: Re: TMK keyboard firmware
Post by: hasu on Thu, 12 March 2015, 15:47:15
regack,
Yes, copying will work.
But many people including myself ues 'git' tool to update source codes, it is useful for tracking changes.
Title: Re: TMK keyboard firmware
Post by: BlueNalgene on Thu, 12 March 2015, 16:13:05
Hasu,

I'm trying to adapt your code to the Vic-20.  I'd love to have your input on a few problems I'm having.

https://geekhack.org/index.php?topic=69470.0 (https://geekhack.org/index.php?topic=69470.0)
Title: Re: TMK keyboard firmware
Post by: p3lim on Thu, 12 March 2015, 17:41:38
Just in case people here don't follow the issue tracker (https://github.com/tmk/tmk_keyboard/issues/173) on Github, it's entirely possible to embed tmk_keyboard instead of modifying it (e.g adding/changing stuff inside /keyboard or /converter).
I used git submodules (http://www.git-scm.com/book/en/v2/Git-Tools-Submodules), but you could just as well use git subtrees (http://blogs.atlassian.com/2013/05/alternatives-to-git-submodule-git-subtree/) or hard-embed it.

https://github.com/p3lim/keyboard_firmware

Also, since I use Sublime Text as my preferred IDE, I've set up a project file that adds the compiling and flashing to a keybind inside the editor (among other things).
https://github.com/p3lim/keyboard_firmware/blob/master/.sublime-project
Title: Re: TMK keyboard firmware
Post by: admiralvorian on Fri, 13 March 2015, 13:28:48
admiralvorian,

build process seems to be OK. Did default keymap works for you?

You better do 'make clean' if you have trouble in built frimware.
https://github.com/tmk/tmk_keyboard/wiki/FAQ-Build#do-make-clean-before-make

Also check this if you are on windows
https://github.com/tmk/tmk_keyboard/wiki/FAQ-Build#edit-configuration-but-not-change


(And make sure your numlock status, note that '1' on pad may work as 'End'.)

Thank you hasu! I do 'make clean' between every compile, I'm doing this on ubuntu 14.04.1. I even removed the entire directory and re-cloned from github.

I will let you guys know if I find out what's happening.

I commented the following line in the makefile and everything started working as expected:

Code: [Select]
#KEYMAP_IN_EEPROM_ENABLE = yes # Read keymap from eeprom
Title: Re: TMK keyboard firmware
Post by: phishy on Sat, 14 March 2015, 21:09:15
Just want to confirm that I'm not the only one here that doesn't understand at all how to use this....lol
Title: Re: TMK keyboard firmware
Post by: eprst on Sun, 15 March 2015, 23:40:11
Hi

I'm playing with TMK on my ergodox, and there seems to be a problem with system suspend: I see the keyboard boot up after resume (it blinks all leds), then it goes back to sleep with that slowly breathing led. The only way to fix it is to replug. Is it a known issue?
I'm running linux 3.19

Update: can't reproduce anymore.. sorry for the noise. Will show magic-v/s output if it happens again.
Title: Re: TMK keyboard firmware
Post by: hasu on Mon, 16 March 2015, 01:48:24
What is your configuration actually? You can post output of magic 'v'.

And check issues on github.com, both tmk and cub-uniac.
Title: Re: TMK keyboard firmware
Post by: l_b on Tue, 17 March 2015, 17:23:44
hasu, I'm trying to compile the infinity tmk firmware but I get an error. I installed the mbed-sdk in tmk_keyboard/mbed-sdk. When running make in keyboard/infinity I get the following error:

Code: [Select]
In file included from matrix.c:3:0:
../../mbed-sdk/libraries/mbed/hal/gpio_api.h:19:20: fatal error: device.h: No such file or directory
 #include "device.h"
                    ^
compilation terminated.
mbed-infinity/cmsis_nvic.c:31:24: fatal error: cmsis_nvic.h: No such file or directory
 #include "cmsis_nvic.h"
                        ^
compilation terminated.
main.cpp:1:20: fatal error: MK20D5.h: No such file or directory
 #include "MK20D5.h"
                    ^
compilation terminated.
make: *** [build/matrix.o] Error 1
make: *** [build/mbed-infinity/cmsis_nvic.o] Error 1
make: *** [build/main.o] Error 1
mbed-infinity/system_MK20D5.c:43:20: fatal error: MK20D5.h: No such file or directory
 #include "MK20D5.h"
                    ^
compilation terminated.
make: *** [build/mbed-infinity/system_MK20D5.o] Error 1
In file included from ../../mbed-sdk/libraries/mbed/api/mbed.h:21:0,
                 from ../../mbed-sdk/libraries/USBDevice/USBDevice/USBHAL.h:22,
                 from mbed-infinity/USBHAL_KL25Z.cpp:21:
../../mbed-sdk/libraries/mbed/api/platform.h:21:20: fatal error: device.h: No such file or directory
 #include "device.h"
                    ^
compilation terminated.
make: *** [build/mbed-infinity/USBHAL_KL25Z.o] Error 1

Do you have any idea what could be wrong? Why is the mbed-sdk not included as a .gitmodule? Has that something to with licensing?
Title: Re: TMK keyboard firmware
Post by: l_b on Tue, 17 March 2015, 17:42:44
Ok, I fixed it.

I checked the mbed-sdk out @2f63fa7d78a2 (as mentioned in mbed-infinity/README). Next was that the 'gcc-arm-none-eabi' package in Ubuntu 14.04 doesn't provice c++ headers (https://bugs.launchpad.net/ubuntu/+source/gcc-arm-none-eabi/+bug/1293024). After installing the ppa:terry.guo/gcc-arm-embedded ppa, reinstalling gcc-arm-none-eabi, doing a make clean the error was fixed!
Title: Re: TMK keyboard firmware
Post by: hasu on Tue, 17 March 2015, 17:51:39
Great.

Yes, I use  this github repo and my local revision is 2f63fa7d78a264b (Dec 25, 2014).
https://github.com/mbedmicro/mbed.git
Again, yes I use that PPA compiler, I'll add notes on those in README.

You had the compile problem with the latest revision of SDK? I'll check mbed again if I have time.
And I'll add mbed SDK as a submodule or subtree later, I don't think it has problem with GPL.
Title: Re: TMK keyboard firmware
Post by: TheNoobySpartan on Wed, 18 March 2015, 09:46:26
Hey there Hasu! I am currently in the planning phase of making a 2 cherry MX key controller for the game osu. Is there a way for me to add reactive LED backlighting to the keys and a breath light that changes color based on the keypresses per minute? Keep in mind I am pretty much a noob at both the hardware and software side of things so I may be a bit dense...
Title: Re: TMK keyboard firmware
Post by: l_b on Wed, 18 March 2015, 16:21:43
hasu, I fixed the (compile) errors with the updated mbed-sdk: https://github.com/LeonB/tmk_keyboard/commit/83a7ff9

When that was done I tried a `make program` which at first seemed like it worked but the orange light on the keyboard kept burning. Then I rolled back to your version (and the older mbed-sdk) and the same happened: flashing seemingly went ok but the orange light on the keyboard (dfu mode?) kept burning.

dfu-util didn't bring up anything weird:

Code: [Select]
dfu-util 0.8

Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2014 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to dfu-util@lists.gnumonks.org

dfu-util: Invalid DFU suffix signature
dfu-util: A valid DFU suffix will be required in a future dfu-util release!!!
Opening DFU capable USB device...
ID 1c11:b007
Run-time device DFU version 0110
Claiming USB DFU Interface...
Setting Alternate Setting #0 ...
Determining device status: state = dfuIDLE, status = 0
dfuIDLE, continuing
DFU mode device DFU version 0110
Device returned transfer size 1024
Copying data from PC to DFU device
Download [=========================] 100%        12684 bytes
Download done.
state(7) = dfuMANIFEST, status(0) = No error condition is present
dfu-util: unable to read DFU status after completion

Any idea on how to debug this? dfu-utild -D kiibohd.dfu.bin worked like a champ.
Title: Re: TMK keyboard firmware
Post by: hasu on Wed, 18 March 2015, 21:23:04
 l_b,
Did you rollback to old one completely? And try 'make clean' and check if all build files is removed.
Maybe, firmware goes wrong with something like memory map or startup.

This is part of diff of keyboard/infinity/mbed-infinity.mk in your commit. You have to use my 'mbed-infinity' version for Infinity since Infinity is differently confgured from mbed Freescale board. Vector address and clock configuration should be changed in fact.

Code: [Select]
- $(OBJDIR)/mbed-infinity/cmsis_nvic.o \
- $(OBJDIR)/mbed-infinity/system_MK20D5.o \
- $(OBJDIR)/mbed-infinity/USBHAL_KL25Z.o \
+ $(OBJDIR)/libraries/mbed/targets/cmsis/TARGET_Freescale/TARGET_K20XX/TARGET_K20D50M/cmsis_nvic.o \
+ $(OBJDIR)/libraries/mbed/targets/cmsis/TARGET_Freescale/TARGET_K20XX/TARGET_K20D50M/system_MK20D5.o \
+ $(OBJDIR)/libraries/USBDevice/USBDevice/USBHAL_KL25Z.o \
Title: Re: TMK keyboard firmware
Post by: hasu on Wed, 18 March 2015, 21:46:57
TheNoobySpartan,
You will need to learn about AVR programming, timer(for count strokes) and PWM(for LED), begin with Arduino or Teensy with breadboards. Google and forums like AVRFreaks can offer enormous useful resources.

Hey there Hasu! I am currently in the planning phase of making a 2 cherry MX key controller for the game osu. Is there a way for me to add reactive LED backlighting to the keys and a breath light that changes color based on the keypresses per minute? Keep in mind I am pretty much a noob at both the hardware and software side of things so I may be a bit dense...
Title: Re: TMK keyboard firmware
Post by: l_b on Thu, 19 March 2015, 06:49:43
hasu, thanks for the explanation. I'll adjust the commit.

I'll also try to build your version starting from scratch tonight. Maybe I forgot to roll something back like you said.
Title: Re: TMK keyboard firmware
Post by: l_b on Thu, 19 March 2015, 15:25:44
Just tried it again but same issue: the dfu mode doesn't get turned off after programming the chip.

These are the steps I took:

Code: [Select]
mkdir test
cd test
git clone https://github.com/tmk/tmk_keyboard.git
cd tmk_keyboard
git submodule init
git submodule update
git clone https://github.com/mbedmicro/mbed.git mbed-sdk
cd mbed-sdk
git checkout 2f63fa7d78a264b
cd ../keyboard/infinity
make
sudo make program

I've attached the build log but I couldn't see anything wrong.
Title: Re: TMK keyboard firmware
Post by: hasu on Thu, 19 March 2015, 16:44:18
l_b,
Infinity goes into DFU mode if firmware is built incorrectly or work wrong.

I'd ask some,
0. your Infinity is 'prototype' or 'production' model?
      those two models have different matrix, define 'INFINITY_PROTOTYPE' in config.h for prototype
1. fimware you compiled with 2f63fa7d78a264b before worked for your Infinity?
      I confirmed it works for me with my prototype model just before this was written.
2. my prebuild binary works? https://geekhack.org/index.php?topic=41989.msg1677235#msg1677235
      This is built for production model.
3. Infinity official firmware works?
4. what version is your dfu-tool?
5. show me output of dfu-tool or make program
      This is likely your problem, the latest version of dfu-tool requires some integrity check or sth.




Title: Re: TMK keyboard firmware
Post by: l_b on Thu, 19 March 2015, 17:41:36
l_b,
Infinity goes into DFU mode if firmware is built incorrectly or work wrong.

I'd ask some,
0. your Infinity is 'prototype' or 'production' model?
      those two models have different matrix, define 'INFINITY_PROTOTYPE' in config.h for prototype
1. fimware you compiled with 2f63fa7d78a264b before worked for your Infinity?
      I confirmed it works for me with my prototype model just before this was written.
2. my prebuild binary works? https://geekhack.org/index.php?topic=41989.msg1677235#msg1677235
      This is built for production model.
3. Infinity official firmware works?
4. what version is your dfu-tool?
5. show me output of dfu-tool or make program
      This is likely your problem, the latest version of dfu-tool requires some integrity check or sth.

- my infinity is the production model
- no, none of the tmk firmwares worked on my infinity :(
- the prebuild binary doesn't work :( Same issue
- the normal infinity firmware works fine
- 0.5 (ubuntu provided) / 0.8 (linuxbrew)
- These are the outputs of the dfu-tool. In order: 0.5 prebuild tmk firmware, 0.8 prebuild tmk firmware, 0.8 official firmware

Code: [Select]
leon@lola:~$ sudo /usr/bin/dfu-util -D Downloads/infinity_spacefn.bin
dfu-util 0.5

(C) 2005-2008 by Weston Schmidt, Harald Welte and OpenMoko Inc.
(C) 2010-2011 Tormod Volden (DfuSe support)
This program is Free Software and has ABSOLUTELY NO WARRANTY

dfu-util does currently only support DFU version 1.0

Opening DFU USB device... ID 1c11:b007
Run-time device DFU version 0110
Found DFU: [1c11:b007] devnum=0, cfg=1, intf=0, alt=0, name="UNDEFINED"
Claiming USB DFU Interface...
Setting Alternate Setting #0 ...
Determining device status: state = dfuIDLE, status = 0
dfuIDLE, continuing
DFU mode device DFU version 0110
Device returned transfer size 1024
No valid DFU suffix signature
Warning: File has no DFU suffix
bytes_per_hash=253
Copying data from PC to DFU device
Starting download: [##################################################] finished!
state(7) = dfuMANIFEST, status(0) = No error condition is present
unable to read DFU status

Code: [Select]
leon@lola:~$ sudo /home/leon/.linuxbrew/bin/dfu-util -D Downloads/infinity_spacefn.bin
dfu-util 0.8

Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2014 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to dfu-util@lists.gnumonks.org

dfu-util: Invalid DFU suffix signature
dfu-util: A valid DFU suffix will be required in a future dfu-util release!!!
Opening DFU capable USB device...
ID 1c11:b007
Run-time device DFU version 0110
Claiming USB DFU Interface...
Setting Alternate Setting #0 ...
Determining device status: state = dfuIDLE, status = 0
dfuIDLE, continuing
DFU mode device DFU version 0110
Device returned transfer size 1024
Copying data from PC to DFU device
Download [=========================] 100%        12676 bytes
Download done.
state(7) = dfuMANIFEST, status(0) = No error condition is present
dfu-util: unable to read DFU status after completion

Code: [Select]
leon@lola:~$ sudo /home/leon/.linuxbrew/bin/dfu-util -D src/tmk_keyboard/keyboard/infinity/kiibohd.dfu.bin
dfu-util 0.8

Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2014 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to dfu-util@lists.gnumonks.org

dfu-util: Invalid DFU suffix signature
dfu-util: A valid DFU suffix will be required in a future dfu-util release!!!
Opening DFU capable USB device...
ID 1c11:b007
Run-time device DFU version 0110
Claiming USB DFU Interface...
Setting Alternate Setting #0 ...
Determining device status: state = dfuIDLE, status = 0
dfuIDLE, continuing
DFU mode device DFU version 0110
Device returned transfer size 1024
Copying data from PC to DFU device
Download [=========================] 100%        23452 bytes
Download done.
state(7) = dfuMANIFEST, status(0) = No error condition is present
dfu-util: unable to read DFU status after completion
Title: Re: TMK keyboard firmware
Post by: hasu on Thu, 19 March 2015, 18:43:16
It seems like your DFU output has no problem, hmm.
I thought difference between prototype and produciton is only matrix but I might be wrong. Also, bootloader may be changed between two model.

I'll check Infinity source code again.




My output of 'make program':
Code: [Select]
$ make program
dfu-util -D ./build/infinity.bin
dfu-util 0.5

(C) 2005-2008 by Weston Schmidt, Harald Welte and OpenMoko Inc.
(C) 2010-2011 Tormod Volden (DfuSe support)
This program is Free Software and has ABSOLUTELY NO WARRANTY

dfu-util does currently only support DFU version 1.0

Opening DFU USB device... ID 1c11:b007
Run-time device DFU version 0110
Found DFU: [1c11:b007] devnum=0, cfg=1, intf=0, alt=0, name="UNDEFINED"
Claiming USB DFU Interface...
Setting Alternate Setting #0 ...
Determining device status: state = dfuIDLE, status = 0
dfuIDLE, continuing
DFU mode device DFU version 0110
Device returned transfer size 1024
No valid DFU suffix signature
Warning: File has no DFU suffix
bytes_per_hash=252
Copying data from PC to DFU device
Starting download: [##################################################] finished!
state(7) = dfuMANIFEST, status(0) = No error condition is present
unable to read DFU status
Title: Re: TMK keyboard firmware
Post by: l_b on Thu, 19 March 2015, 18:47:50
Of you want I could setup a separate ssh account on a box for you to try out the production keyboard.
Title: Re: TMK keyboard firmware
Post by: hasu on Thu, 19 March 2015, 21:43:17
What I can look into with remote access will be very limited and not so helpful, I think.

I skimmed source changes and commits of Infinity and I'm suspecting watchdog timer but not sure.
This commit changed timing of watchdog configuration and I guess bootloader revision is diffrent on mine and yours.
https://github.com/kiibohd/controller/commit/2c7542e2e7f0b8a99edf563dc53164fe1a439483

I'll reflash my bootloader and see if your problem occurs later.
Title: Re: TMK keyboard firmware
Post by: Smasher816 on Thu, 19 March 2015, 22:55:51
I helped beta test the infinity and found an issue where flashing a bad binary would brick the device. Not even pressing the reset to bootloader button would fix it. To solve this issue Haata added some extra security code that would take the device to the bootlodaer if an arm lockup happened or the whatchdog timer was not disabled. Because of this any infinity firmware (with the production bootloader) requires the watchdog to be disabled at the start. It is what lets the board know that you meant to put the specific firmware on the keyboard.
Title: Re: TMK keyboard firmware
Post by: l_b on Fri, 20 March 2015, 16:03:24
Thanks Smasher816! I tried fixing it but I don't know enough of this stuff / C :(
Title: Re: TMK keyboard firmware
Post by: hasu on Fri, 20 March 2015, 20:33:55
Smasher816, thanks for the info.

l_b, I updated my Infinity with the latest bootloader and confirmed the problem you suffer! My old bootloader was build at Dec 31 before the commit. Probably your Infinity was shipped with installed with new bootloader.

Now I have to change my firmware to adapt to new bootloader, I'll enjoy looking into mbed startup code again :D
Title: Re: TMK keyboard firmware
Post by: BlueNalgene on Sat, 21 March 2015, 01:14:01
Anybody have any thoughts on taking a crack at using this with the Teensy LC?  I've got one coming, and I'm just wondering if I will end up being the guinea pig.
Title: Re: TMK keyboard firmware
Post by: Smasher816 on Sat, 21 March 2015, 05:58:42
@Hasu

I guess you just need lines 483-486, https://github.com/kiibohd/controller/commit/2c7542e2e7f0b8a99edf563dc53164fe1a439483#diff-2ad15298158822a548aea372d4abe75bR483.

That should disable the watchdog, I think? The rest are if statements to help it jump into the bootloader. I believe everything was in that commit, but I suppose their could be more. I am not sure.
Title: Re: TMK keyboard firmware
Post by: hasu on Sat, 21 March 2015, 20:54:30
I'm sure now that TMK Infinity firmware failed to disable watchdog in its startup sequence. Watchdog is timed out before disabling it and the controller is reset, then bootloader keeps in DFU mode.

It seems like mbed's startup sequence takes a bit long time before disabling watchdog, we have to do it in very early stage, instead.
I made workaround for this by changing mbed startup file.

https://github.com/tmk/tmk_keyboard/commit/0d222db31f599e90e5e281f80d21ce3c6af0fef8
Title: Re: TMK keyboard firmware
Post by: VinnyCordeiro on Sat, 21 March 2015, 23:06:29
Hello, there! Long post here.

I'm developing a prototype 20% keyboard for games, it's basically the WASD keys + some keys of the WASD neighborhood. Doing that to learn how to program the ATmega32U4 for another project. As I said, I'm using a ATmega32U4 directly (no Teensy here) and trying to program it using AVRDUDE & Adafruit's USBtinyISP. I already used this programmer in other projects using ATmega8, I know it works. But I'm not being able to program the 32U4.

I have compiled a custom firmware for this prototype using Matt3o's tutorial on Deskthority and it seems to be all right, no compilation errors. Now I'm trying to upload the firmware to the 32U4, with no success.

The command line I'm using is (I'm using avrdude 6.1):

Code: [Select]
avrdude -p m32u4 -c usbtiny -v -v -v -U flash:w:e:\gamer_lufa.hex:i
And I have this output:

Code: [Select]
avrdude: Version 6.1, compiled on Mar 13 2014 at 00:09:49
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "E:\Eletr¶nica, Arduino e afins\avrdude-6.1-mingw32\avrdude.conf"

         Using Port                    : usb
         Using Programmer              : usbtiny
avrdude: usbdev_open(): Found USBtinyISP, bus:device: bus-0:\\.\libusb0-0001--0x1781-0x0c9f
         AVR Part                      : ATmega32U4
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PA0
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom        65    20     4    0 no       1024    4      0  9000  9000 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           flash         65     6   128    0 yes     32768  128    256  4500  4500 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           lfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           hfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           efuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           lock           0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

         Programmer Type : USBtiny
         Description     : USBtiny simple USB programmer, http://www.ladyada.net/make/usbtinyisp/
avrdude: programmer operation not supported

avrdude: Using SCK period of 10 usec
CMD: [ac 53 00 00] [00 00 00 00]
CMD: [ac 53 00 00] [00 00 00 00]
avrdude: initialization failed, rc=-1
         Double check connections and try again, or use -F to override
         this check.


avrdude done.  Thank you.

As you can see, initialization failed. After adding -F to override, I get:

Code: [Select]
avrdude: Version 6.1, compiled on Mar 13 2014 at 00:09:49
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "E:\Eletr¶nica, Arduino e afins\avrdude-6.1-mingw32\avrdude.conf"

         Using Port                    : usb
         Using Programmer              : usbtiny
avrdude: usbdev_open(): Found USBtinyISP, bus:device: bus-0:\\.\libusb0-0001--0x1781-0x0c9f
         AVR Part                      : ATmega32U4
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PA0
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom        65    20     4    0 no       1024    4      0  9000  9000 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           flash         65     6   128    0 yes     32768  128    256  4500  4500 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           lfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           hfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           efuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           lock           0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

         Programmer Type : USBtiny
         Description     : USBtiny simple USB programmer, http://www.ladyada.net/make/usbtinyisp/
avrdude: programmer operation not supported

avrdude: Using SCK period of 10 usec
CMD: [ac 53 00 00] [00 00 00 00]
CMD: [ac 53 00 00] [00 00 00 00]
avrdude: initialization failed, rc=-1
avrdude: AVR device initialized and ready to accept instructions
avrdude: Device signature = 0x1e0000
avrdude: Expected signature for ATmega32U4 is 1E 95 87
avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed
         To disable this feature, specify the -D option.

avrdude done.  Thank you.

And now I have a mismatch on the device signature. Can anyone give a hand here? Thank you in advance.
Title: Re: TMK keyboard firmware
Post by: hasu on Sun, 22 March 2015, 01:06:02
VinnyCordeiro,
I think you have to check your connection related to ISP pins and power. You can post your circuit diagram so that we can double check for you.
And post pics of you keyboard! People really love to see custom keyboard works and you'll get more attentions and helps in the end.

Last but not least, why are you using ISP&avrdude instead of USB bootloader?
Title: Re: TMK keyboard firmware
Post by: VinnyCordeiro on Sun, 22 March 2015, 10:46:11
VinnyCordeiro,
I think you have to check your connection related to ISP pins and power. You can post your circuit diagram so that we can double check for you.
And post pics of you keyboard! People really love to see custom keyboard works and you'll get more attentions and helps in the end.

Last but not least, why are you using ISP&avrdude instead of USB bootloader?

Another mistake on the prototype, and the first big one: the ICSP connections are inverted!  :mad: Well, that's what prototypes are for, making mistakes. Thank you for the advice anyway.

Bootloaders occupy flash space. I know, it's minimum in this case, but in others it isn't. And I prefer to direct flash mcu's. :D

Photos:

The PCB's made by Gold Phoenix (http://goldphoenixpcb.biz/):
[attach=2]

The prototype almost finished (Cherry MX clears for alphas and linear Cherry MX gray on thumb spacebar):
[attach=1]
Title: Re: TMK keyboard firmware
Post by: hasu on Sun, 22 March 2015, 14:35:37
Nice work.

So your ICSP problem was resolved and you can flash firmware now, right?
Title: Re: TMK keyboard firmware
Post by: VinnyCordeiro on Sun, 22 March 2015, 14:44:07
Nice work.

So your ICSP problem was resolved and you can flash firmware now, right?

Not yet, I'll have to fix it. But not today, I have other things to do. :(
Title: Re: TMK keyboard firmware
Post by: l_b on Tue, 24 March 2015, 15:01:17
hasu, I didn't get a mail from geekhack there was an update so I didn't realize you already fixed the problem! I tried it out: the flashing went fine. The light that indicated dfu mode goes out.

However the keyboard after that won't work. I get these in my dmesg:

Code: [Select]
Mar 24 20:54:25 lola kernel: [279889.727369] usb 3-7: new full-speed USB device number 36 using xhci_hcd
Mar 24 20:54:25 lola kernel: [279889.855929] usb 3-7: unable to read config index 0 descriptor/start: -71
Mar 24 20:54:25 lola kernel: [279889.855931] usb 3-7: can't read configurations, error -71
Mar 24 20:54:25 lola kernel: [279889.967283] usb 3-7: new full-speed USB device number 37 using xhci_hcd
Mar 24 20:54:25 lola kernel: [279890.095861] usb 3-7: unable to read config index 0 descriptor/start: -71
Mar 24 20:54:25 lola kernel: [279890.095863] usb 3-7: can't read configurations, error -71
Mar 24 20:54:26 lola kernel: [279890.207183] usb 3-7: new full-speed USB device number 38 using xhci_hcd
Mar 24 20:54:26 lola kernel: [279890.223558] usb 3-7: device descriptor read/all, error -71
Mar 24 20:54:26 lola kernel: [279890.335175] usb 3-7: new full-speed USB device number 39 using xhci_hcd
Mar 24 20:54:26 lola kernel: [279890.351509] usb 3-7: device descriptor read/all, error -71
Mar 24 20:54:26 lola kernel: [279890.351545] usb usb3-port7: unable to enumerate USB device
Title: Re: TMK keyboard firmware
Post by: Baxter on Mon, 30 March 2015, 16:49:16
I have a spare teensy++ 2.0 I've just tried programming with the tml/tmk_keyboard gh60 layout, I set the MCU to at90usb1287 and when connected it goes wild outputting "=]" and random mouse commands, is this because of some incompatibility with the ++ 2.0 or just because I've got nothing connected and the input pins are floating?
Title: Re: TMK keyboard firmware
Post by: hasu on Mon, 30 March 2015, 17:16:30
l_b,  it seems like USB initialization or enumeration fail. I'll look into again later. I guess xhchi indicates USB3.0 and it is more fussy for timing and spec.

Baxter,
I don't think floting pin is problem they are internally pull-uped but not sure. Teensy++ has 1286 not 1287,  but again not sure this causes the madness. BTW, what is tml?
Title: Re: TMK keyboard firmware
Post by: Baxter on Mon, 30 March 2015, 17:50:01
I don't think floting pin is problem they are internally pull-uped but not sure. Teensy++ has 1286 not 1287,  but again not sure this causes the madness. BTW, what is tml?

sorry I meant https://github.com/tmk/tmk_keyboard.

Strangely I do get correct keystrokes if I short a row to a column and commenting out bootmagic seems to stop it in any case.
Title: Re: TMK keyboard firmware
Post by: hasu on Mon, 30 March 2015, 18:16:06
Ah, I see :D I just thought someone folked and made new repository.

I found Teensy has LED on PD6 which is used for key matrix sense in GH60. That column has = and ] key. This makes sense.
Title: Re: TMK keyboard firmware
Post by: Baxter on Mon, 30 March 2015, 18:39:05
Ah, damn, I saw that was lit and didn't think twice, always the obvious stuff, I'll poke the pin mappings a bit, thanks :)
Title: Re: TMK keyboard firmware
Post by: l_b on Wed, 01 April 2015, 16:49:50
hasu, should I check on a usb2 machine to see if there's a difference?
Title: Re: TMK keyboard firmware
Post by: hasu on Wed, 01 April 2015, 16:54:20
Yes, plz. It would be appreciated unless it bothers you much.
Title: Re: TMK keyboard firmware
Post by: l_b on Thu, 02 April 2015, 14:19:30
hasu, on usb2 they work fine! Would it be hard to fix that?
Title: Re: TMK keyboard firmware
Post by: hasu on Thu, 02 April 2015, 17:41:05
Thanks for the testing.
I don't have any USB3 port and don't know about it at all.
That said,  I can compare with official firmware at least. HaaTa's firmware uses PJRC USB stack while mine uses mbed.org.

Official firmware works well with USB 3, right?
Title: Re: TMK keyboard firmware
Post by: l_b on Thu, 02 April 2015, 18:10:25
Yeah, official firmware works fine with usb3. (But isn't as nice as tmk :))

If you're open for it I would be willing to donate a little sum for the project because I enjoy it very much.
Would something like implementing the media keys be doable for me (little c / embedded experience, but familiar with programming) for the infinity / mbed stack?
Title: Re: TMK keyboard firmware
Post by: Smasher816 on Thu, 02 April 2015, 19:07:18
Would something like implementing the media keys be doable for me (little c / embedded experience, but familiar with programming) for the infinity / mbed stack?

I'm pretty sure media key support already exists, you just have to put the buttons in your layout. I know I can change the volume with my HHKB using tmk.

These are the keys I believe you should use: https://github.com/tmk/tmk_keyboard/blob/6a97efcea94b2d1882ba2d58c4c016a45507fb3d/common/keycode.h#L137
Title: Re: TMK keyboard firmware
Post by: l_b on Fri, 03 April 2015, 15:18:33
I don't think so:

I added initial support for Masdrop Infinity which based on mbed(cortex-M) and is not full fucinton yet; mouse keys, media keys, NKRO and etc.
https://github.com/tmk/tmk_keyboard/tree/master/keyboard/infinity

I don't think many users are around here yet, but if you have it try this.

Also I tried it: https://github.com/LeonB/tmk_keyboard/blob/infinity_leonb/keyboard/infinity/keymap_leonb.c#L71 and it doesn't seem to work just yet.
Title: Re: TMK keyboard firmware
Post by: hasu on Sat, 04 April 2015, 17:49:38
OK. I'll look into HaaTa's USB code later when I get time. I think he changed PJRC USB code to remove bug and improve for full-fledged keyboard.

Thanks for the encouragement. I'm always open for that :D Buy me a beer, it is powerful driver for my project :p

I'm sure you can do that, though you'll need time quite a little to refer to USB spec and MCU datasheet. In the end, you need to implement functions of 'mbed driver' for media keys like send_consumer() and send_system().
https://github.com/tmk/tmk_keyboard/blob/master/protocol/mbed/mbed_driver.cpp

When I have spare time I will also tackle this but I don't know when. My Infinity is disassembled completely at this time.


Yeah, official firmware works fine with usb3. (But isn't as nice as tmk :))

If you're open for it I would be willing to donate a little sum for the project because I enjoy it very much.
Would something like implementing the media keys be doable for me (little c / embedded experience, but familiar with programming) for the infinity / mbed stack?
Title: Re: TMK keyboard firmware
Post by: l_b on Sun, 05 April 2015, 03:34:48
Thanks for the encouragement. I'm always open for that :D Buy me a beer, it is powerful driver for my project :p
Yeah, sure. Send me your PayPal address (or something) and I'll buy you a couple of round  :thumb:
Title: Re: TMK keyboard firmware
Post by: sypl on Thu, 09 April 2015, 11:56:51
Not sure if anyone has asked this before (22 pages is a lot to trawl through), but if anyone has and got an answer then just reply 'yes', and I will go back through the whole thread.

My question is, is it possible to get the oneshot functionality on a layer? I've become very fond of it for my shift layer, using it like so:

Code: [Select]
[28] = ACTION_MODS_ONESHOT(MOD_LSFT),
I have a lot of characters and numbers on another two layers, but I can only access them by holding down the function layer key. If these could be accessed via a oneshot that would be ideal.

Thanks in advance.

Title: Re: TMK keyboard firmware
Post by: hasu on Thu, 09 April 2015, 20:11:49
ACTION_LAYER_ONESHOT is not existent at this time but it looks interesting idea.
I think it is possible but quite a bit coding in library is needed.
Title: Re: TMK keyboard firmware
Post by: ctm on Mon, 13 April 2015, 20:14:14
Is there a way to have a dedicated ~ key?
Title: Re: TMK keyboard firmware
Post by: Rose on Mon, 13 April 2015, 21:52:06
What do these keycodes do?

KC_APP
KC_PCMM
KC_MAIL, KC_CALC, KC_MYCM for application launch
KC_WSCH, KC_WHOM, KC_WBAK, KC_WFWD, KC_WSTP, KC_WREF, KC_WFAV for web browser operation
Title: Re: TMK keyboard firmware
Post by: sypl on Tue, 14 April 2015, 00:20:07
Is there a way to have a dedicated ~ key?

Wouldn't this do it?

Code: [Select]
const uint16_t PROGMEM fn_actions[] = {   
   [0] = ACTION_MODS_KEY( MOD_LSFT, KC_GRV ),  // ~
}
Title: Re: TMK keyboard firmware
Post by: p3lim on Tue, 14 April 2015, 07:53:51
What do these keycodes do?

KC_APP
KC_PCMM
KC_MAIL, KC_CALC, KC_MYCM for application launch
KC_WSCH, KC_WHOM, KC_WBAK, KC_WFWD, KC_WSTP, KC_WREF, KC_WFAV for web browser operation

https://github.com/tmk/tmk_keyboard/blob/master/doc/keycode.txt

KC_APP = Right menu key (the key to the right of RWin on most keyboards)
KC_PCMM = Numpad comma key
KC_MAIL, KC_CALC, KC_MYCM = Starts mail, calc, explorer app
KC_WSCH, KC_WHOM, KC_WBAK, KC_WFWD, KC_WSTP, KC_WREF, KC_WFAV = Web navigation shortcuts: search, home, back, forward, stop, refresh and favorites (bookmarks)

All of these keys were designed for Windows (except for KC_PCMM), and might not work on other OSes.
Title: Re: TMK keyboard firmware
Post by: ctm on Tue, 14 April 2015, 09:19:52
Is there a way to have a dedicated ~ key?

Wouldn't this do it?

Code: [Select]
const uint16_t PROGMEM fn_actions[] = {   
   [0] = ACTION_MODS_KEY( MOD_LSFT, KC_GRV ),  // ~
}
Thank you!
Title: Re: TMK keyboard firmware
Post by: Rose on Tue, 14 April 2015, 15:48:13

https://github.com/tmk/tmk_keyboard/blob/master/doc/keycode.txt


Awesome.  Thank you.
Title: Re: TMK keyboard firmware
Post by: Rose on Wed, 15 April 2015, 17:12:01
KC_APP = Right menu key (the key to the right of RWin on most keyboards)
KC_PCMM = Numpad comma key
KC_MAIL, KC_CALC, KC_MYCM = Starts mail, calc, explorer app
KC_WSCH, KC_WHOM, KC_WBAK, KC_WFWD, KC_WSTP, KC_WREF, KC_WFAV = Web navigation shortcuts: search, home, back, forward, stop, refresh and favorites (bookmarks)

If KC_APP is that lower right menu key then what is KC_MENU?  Also, what is the difference between KC_F1 and KC_FN1?  Thank you!
Title: Re: TMK keyboard firmware
Post by: spiceBar on Wed, 15 April 2015, 17:40:54
KC_APP = Right menu key (the key to the right of RWin on most keyboards)
KC_PCMM = Numpad comma key
KC_MAIL, KC_CALC, KC_MYCM = Starts mail, calc, explorer app
KC_WSCH, KC_WHOM, KC_WBAK, KC_WFWD, KC_WSTP, KC_WREF, KC_WFAV = Web navigation shortcuts: search, home, back, forward, stop, refresh and favorites (bookmarks)

If KC_APP is that lower right menu key then what is KC_MENU?  Also, what is the difference between KC_F1 and KC_FN1?  Thank you!

KC_F1 is the standard F1 key on the keyboard.

KC_FN1 (and KC_FN2...) is an "Fn" key: a key you define to access another layer of functions. When you define such a key, you also have to give the full layer associated with it, and a little bit of glue code (a declaration) that links the key to its associated layer.

The TMK firmware allows you to define several Fn keys, to access several additional layers if necessary.

Look at the provided keymaps example to find out how.

I'm not sure about KC_MENU...
Title: Re: TMK keyboard firmware
Post by: hasu on Wed, 15 April 2015, 18:53:11
It is used in UNIX keyboard, though I don't know how it works.

Rose, check this.
10. Keyboard/Keypad Page(0x07) p.53
http://www.usb.org/developers/hidpage/Hut1_12v2.pdf
Title: Re: TMK keyboard firmware
Post by: skullydazed on Wed, 15 April 2015, 21:07:59
I just wired up my own keyboard and I'm afraid I'm not sure how to modify tmk for what I did. Here's my matrix:

(http://i.imgur.com/j5bBEpg.jpg)

(http://i.imgur.com/b5vYXUq.jpg)

(For this version I have simply connected each half with wires from each row/column. I will figure out how to multiplex over TRRS for V2.)

Since I have a vertical stagger my diodes were not long enough to reach horizontally, so I wired it up vertically. However, I don't understand how to modify tmk for this situation. I've modified the gh60 keyboard and put this in matrix.c:

https://gist.github.com/anonymous/c241385cfbe34e8ac454

However, when I plug the keyboard in this is what I get:

(http://i.imgur.com/WGoukc7.png)

Can anyone point me in the right direction here? Could software cause this, or do I definitely have a fault in my wiring?
Title: Re: TMK keyboard firmware
Post by: hasu on Wed, 15 April 2015, 21:25:37
It seems to me like that code works well, check your hardware again.
Title: Re: TMK keyboard firmware
Post by: skullydazed on Wed, 15 April 2015, 21:46:49
Thanks hasu, I'll look over the wiring again, see if I can isolate what's shorted.
Title: Re: TMK keyboard firmware
Post by: VinnyCordeiro on Fri, 17 April 2015, 15:20:00
Status update:

I was getting tired of waiting for the arrival of some components to make changes in my proof-of-concept keyboard and tried the firmware upload method described at the GH60 GB thread. This keyboard is based on the GH60, so I thought it might work.

And it did! :D

The ATmega32U4 was recognized by Windows 7, which proved 2 things: even being my first time soldering an SMD component, my 20+ years of experience in electronics proved useful :cool:; and that the microcontrollers I bought at AliExpress weren't fake.

Firmware upload using ATMEL Flip was painless. Now I have to debug it, because of course I couldn't make everything right at the first try. Rows 1 and 2 are ok, but at rows 3 and 4 the keys at the same column are being registered as being pressed at the same time. Also Left Shift isn't working.

Probably tomorrow I'll have time to take a look at the board and see if I made a design mistake. If everything is ok, it'll be time to take a look at the code. I'll probably post it here tomorrow, for some advice on it.

And I would like to thank hasu for a nice job. Without tmk, this keyboard wouldn't be alive so fast. :D

EDIT:
Status update 2:

Multimeter confirmed a short circuit connecting rows 3, 4 and 5 (used just for the thumb spacebar). Repeated measurements on a spare, unpopulated board, no shorts. My only guess is a short circuit at the ATmega32U4, connecting pins 20, 21 and 22 (used on said rows). That's going to be a pain in the butt to correct this. Even considering to solder a new board, reusing almost all components. That will be postponed to another day.  :(

Status update 3:

Bored to death at home, tried to fix the board. Soldering iron + solder wick solved the short circuit, now the keyboard is working as designed.  :thumb: Now comes the use test in games.  :))
Title: Re: TMK keyboard firmware
Post by: neverused on Mon, 20 April 2015, 12:36:36
Hello,

While executing

Code: [Select]
make -f Makefile
I get the error (http://i.imgur.com/j0EEKWf.png)

May I ask what may cause this and how to fix it?

I have both the Winavr and Teensyloader installed.

Thanks!


Here is a zip of my code in case anyone can help out:
https://drive.google.com/file/d/0ByOSi5aaJltDNkpfTlZ0TDFKRms/view?usp=sharing
Title: Re: TMK keyboard firmware
Post by: sypl on Mon, 20 April 2015, 15:08:01
Hello,

While executing

Code: [Select]
make -f Makefile
I get the error
Show Image
(http://i.imgur.com/j0EEKWf.png)


May I ask what may cause this and how to fix it?

I have both the Winavr and Teensyloader installed.

Thanks!


Here is a zip of my code in case anyone can help out:
https://drive.google.com/file/d/0ByOSi5aaJltDNkpfTlZ0TDFKRms/view?usp=sharing

You need to have make installed. What platform are you on? If windows you can download the package here: http://gnuwin32.sourceforge.net/packages/make.htm. Installation instructions are further down the page. Try it and come back if you have trouble.
Title: Re: TMK keyboard firmware
Post by: neverused on Mon, 20 April 2015, 16:50:17
Hello,

While executing

Code: [Select]
make -f Makefile
I get the error
Show Image
(http://i.imgur.com/j0EEKWf.png)


May I ask what may cause this and how to fix it?

I have both the Winavr and Teensyloader installed.

Thanks!


Here is a zip of my code in case anyone can help out:
https://drive.google.com/file/d/0ByOSi5aaJltDNkpfTlZ0TDFKRms/view?usp=sharing

You need to have make installed. What platform are you on? If windows you can download the package here: http://gnuwin32.sourceforge.net/packages/make.htm. Installation instructions are further down the page. Try it and come back if you have trouble.

Thank you, I downloaded the application and when I run the same command, I have the same issue.

What else should I try?

Thanks!
Title: Re: TMK keyboard firmware
Post by: hasu on Mon, 20 April 2015, 16:55:45
I believe WinAVR includes make command already.

neverused, read WinAVR document for installation and follow it. I think you don't set Path yet.
Title: Re: TMK keyboard firmware
Post by: hasu on Mon, 20 April 2015, 18:19:04
The ATmega32U4 was recognized by Windows 7, which proved 2 things: even being my first time soldering an SMD component, my 20+ years of experience in electronics proved useful :cool:; and that the microcontrollers I bought at AliExpress weren't fake.

Nice to hear. I've procrastinated to place a order on small vendor in China, but it it time now.
To get the MCU from trusty sources at proper price is getting more and more difficult recently :(

Which seller did you use?
Title: Re: TMK keyboard firmware
Post by: neverused on Mon, 20 April 2015, 18:22:46
I believe WinAVR includes make command already.

neverused, read WinAVR document for installation and follow it. I think you don't set Path yet.

In reading the documentation, I didn't see a path that needs to be set for WinAVR... I did see the need to navigate to the path in CMD, i.e. 'C:\Users\Chris\Desktop\tmk_keyboard-master\keyboard\gh60' but when I do that and execute a 'make' command I still get the same error.
Title: Re: TMK keyboard firmware
Post by: hasu on Mon, 20 April 2015, 18:51:59
I guess PATH env was not set during WINAVR installation process for some reason, so you need to set PATH env. If you are not familiar with this kind of things, reinstall it.

EDIT: This may help you? http://winavr.sourceforge.net/WinAVR-user-manual.html


Or try this route.
https://github.com/tmk/tmk_keyboard/blob/master/doc/build.md#download-and-install
Title: Re: TMK keyboard firmware
Post by: VinnyCordeiro on Mon, 20 April 2015, 19:46:26
The ATmega32U4 was recognized by Windows 7, which proved 2 things: even being my first time soldering an SMD component, my 20+ years of experience in electronics proved useful :cool:; and that the microcontrollers I bought at AliExpress weren't fake.

Nice to hear. I've procrastinated to place a order on small vendor in China, but it it time now.
To get the MCU from trusty sources at proper price is getting more and more difficult recently :(

Which seller did you use?
This one: http://www.aliexpress.com/item/5pcs-lot-ATMEGA32U4-AU-ATMEGA32U4-ATMEL-TQFP-44-IC-8-bit-Microcontroller-with-16-32K-Bytes/1877422430.html and now it's $5 cheaper than when I bought.
Title: Re: TMK keyboard firmware
Post by: U47 on Thu, 23 April 2015, 23:20:23
Just throwing this out there, has anyone tried/had any luck compiling the TMK firmware for a Teensy 3.1? I've got a box of them doing nothing, so I figured I'd see if I can put them to use.
Title: Re: TMK keyboard firmware
Post by: BlueNalgene on Fri, 24 April 2015, 01:50:06
Just throwing this out there, has anyone tried/had any luck compiling the TMK firmware for a Teensy 3.1? I've got a box of them doing nothing, so I figured I'd see if I can put them to use.

It won't work.  The 3.1 uses ARM architecture which isn't compatible with the AVR programming in the TMK.  If you would like to make an ARM variant, I would love to see it.  I am trying to make one now for the Teensy LC.
Title: Re: TMK keyboard firmware
Post by: hasu on Fri, 24 April 2015, 02:04:16
TMK works on ARM Cortex-M now, actually it runs on Infinity and NXP LPC board at least.
See keyboard/inifinity/ and tmk_core/tool/mbed/ directory. Not mature and clean enough  but it works.

TMK uses mbed.org SDK to support Cortex-M, so it will be easy to port MCU mbed.org supports theoretically. Teensy3.1 uses same family controller as Infinity and recently mbed.org added support of Teensy3.1. I think porting to Teensy is not so hard if you are familiar with mbed SDK.
Title: Re: TMK keyboard firmware
Post by: hasu on Fri, 24 April 2015, 09:30:43
l_b,
TMK includes the latest mbed SDK code now, so you don't need to download SDK separately. I didn't change my code actually but found current mbed SDK has a fix for Kinesis USB problem. It may cure the USB3 problem of TMK infinity.

I think it is worth trying again when you have a time.

FYI, the mbed SDK fix:
https://github.com/mbedmicro/mbed/commit/43113cf13ab02e1781755dd29140f93773dc6147

hasu, I didn't get a mail from geekhack there was an update so I didn't realize you already fixed the problem! I tried it out: the flashing went fine. The light that indicated dfu mode goes out.

However the keyboard after that won't work. I get these in my dmesg:

Code: [Select]
Mar 24 20:54:25 lola kernel: [279889.727369] usb 3-7: new full-speed USB device number 36 using xhci_hcd
Mar 24 20:54:25 lola kernel: [279889.855929] usb 3-7: unable to read config index 0 descriptor/start: -71
Mar 24 20:54:25 lola kernel: [279889.855931] usb 3-7: can't read configurations, error -71
Mar 24 20:54:25 lola kernel: [279889.967283] usb 3-7: new full-speed USB device number 37 using xhci_hcd
Mar 24 20:54:25 lola kernel: [279890.095861] usb 3-7: unable to read config index 0 descriptor/start: -71
Mar 24 20:54:25 lola kernel: [279890.095863] usb 3-7: can't read configurations, error -71
Mar 24 20:54:26 lola kernel: [279890.207183] usb 3-7: new full-speed USB device number 38 using xhci_hcd
Mar 24 20:54:26 lola kernel: [279890.223558] usb 3-7: device descriptor read/all, error -71
Mar 24 20:54:26 lola kernel: [279890.335175] usb 3-7: new full-speed USB device number 39 using xhci_hcd
Mar 24 20:54:26 lola kernel: [279890.351509] usb 3-7: device descriptor read/all, error -71
Mar 24 20:54:26 lola kernel: [279890.351545] usb usb3-port7: unable to enumerate USB device

Title: Re: TMK keyboard firmware
Post by: BlueNalgene on Fri, 24 April 2015, 11:32:38
TMK works on ARM Cortex-M now, actually it runs on Infinity and NXP LPC board at least.
See keyboard/inifinity/ and tmk_core/tool/mbed/ directory. Not mature and clean enough  but it works.

TMK uses mbed.org SDK to support Cortex-M, so it will be easy to port MCU mbed.org supports theoretically. Teensy3.1 uses same family controller as Infinity and recently mbed.org added support of Teensy3.1. I think porting to Teensy is not so hard if you are familiar with mbed SDK.

I know what my plans are this weekend!
Title: Re: TMK keyboard firmware
Post by: l_b on Fri, 24 April 2015, 15:37:11
Wow, big update hasu! I really like the changes to the README.

With a usb3 port it throws the same error:

Code: [Select]
Apr 24 22:34:03 lola kernel: [  130.501061] usb 3-7: new full-speed USB device number 8 using xhci_hcd
Apr 24 22:34:03 lola kernel: [  130.629611] usb 3-7: unable to read config index 0 descriptor/start: -71
Apr 24 22:34:03 lola kernel: [  130.629613] usb 3-7: can't read configurations, error -71
Apr 24 22:34:03 lola kernel: [  130.741050] usb 3-7: new full-speed USB device number 9 using xhci_hcd
Apr 24 22:34:03 lola kernel: [  130.869761] usb 3-7: unable to read config index 0 descriptor/start: -71
Apr 24 22:34:03 lola kernel: [  130.869764] usb 3-7: can't read configurations, error -71
Apr 24 22:34:03 lola kernel: [  130.981113] usb 3-7: new full-speed USB device number 10 using xhci_hcd
Apr 24 22:34:03 lola kernel: [  130.997964] usb 3-7: unable to read config index 0 descriptor/all
Apr 24 22:34:03 lola kernel: [  130.997967] usb 3-7: can't read configurations, error -71
Apr 24 22:34:04 lola kernel: [  131.165138] usb 3-7: new full-speed USB device number 11 using xhci_hcd
Apr 24 22:34:04 lola kernel: [  131.181429] usb 3-7: device descriptor read/all, error -71
Apr 24 22:34:04 lola kernel: [  131.181460] usb usb3-port7: unable to enumerate USB device
Title: Re: TMK keyboard firmware
Post by: worldspawn on Mon, 27 April 2015, 09:16:12
I can't figure out what I'm doing here...  I've tried to adapt this firmware to my project, and I had a C programmer try to assist me, and we've gotten nowhere, this is really damn confusing, I have the primary and 1 function layer. It just does nothing after it's flashed.  I'm using an Atmega32U4 (just the chip, not a teensy).  Can someone put this into something that would actually work since I clearly have no idea what I'm doing, and I've spent weeks on this.

 matrix pins:
 Column pin configuration
 col: 0   1   2   3   4   5   6   7   8   9   10  11 
 pin: B4  B5  D6  D7  C7  B6  D3  B3  B7  D0  D1  D2 

 Row pin configuration
 row: 0   1   2   3   4
 pin: D5  C6  E2  B0  E6


#define KEYMAP( \
               K03, K04,          K07, K08,              \
    K10, K11, K12, K13, K14, K15,      K17, K18, K19, K1A, K1B,  \
    K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B,  \
    K30, K31, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B,  \
    K40, K41, K42, K43, K44, K45, K46, K47, K48, K49, K4A, K4B,  \
) { \
    { KC_NO,    KC_NO,    KC_NO,    KC_##K03, KC_##K04, KC_NO,    KC_NO,    KC_##K07, KC_##K08, KC_NO,    KC_NO,    KC_NO    }, \
    { KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_NO,    KC_##K17, KC_##K18, KC_##K19, KC_##K1A, KC_##K1B }, \
    { 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_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_##K35, KC_##K36, KC_##K37, KC_##K38, KC_##K39, KC_##K3A, KC_##K3B }, \
    { KC_##K40, KC_##K41, KC_##K42, KC_##K43, KC_##K44, KC_##K45, KC_##K46, KC_##K47, KC_##K48, KC_##K49, KC_##K4A, KC_##K4B }  \
}


/* Keymap 0: Default Layer
     * ,---------------------------------------------------.
     * |             ESC|  \|             ;|  DEL          |
     * |---------------------------------------------------|
     * |   Q|  W|  E|  R|  T| ALT|        Y|  U|  I|  O|  P|
     * |---------------------------------------------------|
     * |   A|  S|  D|  F|  G| FN1| ENT|   H|  J|  K|  L|  '|
     * |---------------------------------------------------|
     * |  Z |  X|  C|  V|  B|LCTL|BSPC|   N|  M|  ,|  .|  /|
     * |---------------------------------------------------|
     * |   1|   2|  3|  4| 5| SPC|LSFT|   6|  7|  8|  9|  0|
     * `---------------------------------------------------'
     */
    KEYMAP(
                ESC,BSLS,          SCLN, DEL,                     \
        Q,   W,   E,   R,   T, ALT,        Y,   U,   I,   O,   P, \
        A,   S,   D,   F,   G, FN1, ENT,   H,   J,   K,   L,QUOT, \
        Z,   X,   C,   V,   B,LCTL,BSPC,   N,   M,COMM, DOT,SLSH, \
        1,   2,   3,   4,   5, SPC,LSFT,   6,   7,   8,   9,   0),
   
    /* Overlay 1
     * ,----------------------------------------------------------.
     * |             `|   -|                 =|  DEL              |
     * |----------------------------------------------------------|
     * |   Q|   W|   E|   R|  T| ALT|     PGUP|HOME|  UP| END|PSCR|
     * |----------------------------------------------------------|
     * |   A|   S|   D|   F|  G|    | ENT|PGDN|LEFT|DOWN|RGHT|   '|
     * |----------------------------------------------------------|
     * |  Z |   X|   C|   V|  B|LCTL| F12|   N|   M|   [|   ]|   /|
     * |----------------------------------------------------------|
     * |  F1|  F2|  F3|  F4| F5| F11|CAPS|  F6|  F7|  F8|  F9| F10|
     * `----------------------------------------------------------'
     */
    KEYMAP(
                     GRV,MINS,             EQL,BSPC,              \
        Q,   W,   E,   R,   T, ALT,     PGUP,HOME,  UP, END,PSCR, \
        A,   S,   D,   F,   G,TRNS, ENT,PGDN,LEFT,DOWN,RGHT,QUOT, \
        Z,   X,   C,   V,   B,LCTL, F12,   N,   M,LBRC,RBRC,SLSH, \
        F1,  F2,  F3,  F4,  F5, F11,CAPS,  F6,  F7,  F8,  F9, F10),


LEDs are on B1 and B2 for caps and Fn layer.
Command combo needs to be L Shift and alt(L Alt)
Title: Re: TMK keyboard firmware
Post by: skullydazed on Mon, 27 April 2015, 12:07:41
I can't figure out what I'm doing here...  I've tried to adapt this firmware to my project, and I had a C programmer try to assist me, and we've gotten nowhere, this is really damn confusing, I have the primary and 1 function layer. It just does nothing after it's flashed.  I'm using an Atmega32U4.  Can someone put this into something that would actually work since I clearly have no idea what I'm doing, and I've spent weeks on this.

What does your matrix.c look like? It took a bit for me to grok what was going on there, but once I did I was able to get my keyboard working, and when I had it wrong a plain teensy with nothing connected would show keys held down. You have to modify all 4 functions correctly or it won't scan and reset the pins properly.
Title: Re: TMK keyboard firmware
Post by: worldspawn on Mon, 27 April 2015, 14:18:30
I can't figure out what I'm doing here...  I've tried to adapt this firmware to my project, and I had a C programmer try to assist me, and we've gotten nowhere, this is really damn confusing, I have the primary and 1 function layer. It just does nothing after it's flashed.  I'm using an Atmega32U4.  Can someone put this into something that would actually work since I clearly have no idea what I'm doing, and I've spent weeks on this.

What does your matrix.c look like? It took a bit for me to grok what was going on there, but once I did I was able to get my keyboard working, and when I had it wrong a plain teensy with nothing connected would show keys held down. You have to modify all 4 functions correctly or it won't scan and reset the pins properly.

At this point, I have no idea since I handed it off to my programmer buddy who is equally stumped by it after trying all last weekend.

My last post included all the pins and necessary info (AFAIK, which is the problem), could someone who knows how this mess actually works put together the matrix, keyboard layout, and make files based on those?
Title: Re: TMK keyboard firmware
Post by: abjr on Mon, 27 April 2015, 14:52:54
Try this in your matrix.c. Hopefully I didn't make any mistakes.
Code: [Select]
/*
 matrix pins:
 col: 7  0  1  5  8    4    9   10  11  6  2  3
 pin: B3 B4 B5 B6 B7   C7   D0  D1  D2  D3 D6 D7
*/
static void  init_cols(void)
{
    // Input with pull-up(DDR:0, PORT:1)
    DDRB  &= ~(1<<3 | 1<<4 | 1<<5 | 1<<6 | 1<<7);
    PORTB |=  (1<<3 | 1<<4 | 1<<5 | 1<<6 | 1<<7);

    DDRC  &= ~(1<<7);
    PORTC |=  (1<<7);

    DDRD  &= ~(1<<0 | 1<<1 | 1<<2 | 1<<3 | 1<<6 | 1<<7);
    PORTD |=  (1<<0 | 1<<1 | 1<<2 | 1<<3 | 1<<6 | 1<<7);
}

static matrix_row_t read_cols(void)
{
    return (PINB&(1<<3) ? 0 : (1<< 7)) |
           (PINB&(1<<4) ? 0 : (1<< 0)) |
           (PINB&(1<<5) ? 0 : (1<< 1)) |
           (PINB&(1<<6) ? 0 : (1<< 5)) |
           (PINB&(1<<7) ? 0 : (1<< 8)) |

           (PINC&(1<<7) ? 0 : (1<< 4)) |

           (PIND&(1<<0) ? 0 : (1<< 9)) |
           (PIND&(1<<1) ? 0 : (1<<10)) |
           (PIND&(1<<2) ? 0 : (1<<11)) |
           (PIND&(1<<3) ? 0 : (1<< 6)) |
           (PIND&(1<<6) ? 0 : (1<< 2)) |
           (PIND&(1<<7) ? 0 : (1<< 3));
}

/*
 Row pin configuration
 row: 0   1   2   3   4
 pin: D5  C6  E2  B0  E6
*/
static void unselect_rows(void)
{
    // Hi-Z(DDR:0, PORT:0) to unselect
    DDRB  &= ~0b00000001;
    PORTB &= ~0b00000001;

    DDRC  &= ~0b01000000;
    PORTC &= ~0b01000000;

    DDRD  &= ~0b00100000;
    PORTD &= ~0b00100000;

    DDRE  &= ~0b01000100;
    PORTE &= ~0b01000100;
}

static void select_row(uint8_t row)
{
    // Output low(DDR:1, PORT:0) to select
    switch (row) {
        case 0:
            DDRD  |= (1<<5);
            PORTD &= ~(1<<5);
            break;
        case 1:
            DDRC  |= (1<<6);
            PORTC &= ~(1<<6);
            break;
        case 2:
            DDRE  |= (1<<2);
            PORTE &= ~(1<<2);
            break;
        case 3:
            DDRB  |= (1<<0);
            PORTB &= ~(1<<0);
            break;
        case 4:
            DDRE  |= (1<<6);
            PORTE &= ~(1<<6);
            break;
    }
}
Title: Re: TMK keyboard firmware
Post by: neverused on Tue, 28 April 2015, 14:16:50
Has any one built their firmware from a Raspberry Pi?  I am unfamiliar with Linux, so I do not know how to differentiate amongst distros or how that
would affect the ability to build the Makefile. 

Can anyone assist with this?

Thank you.
Title: Re: TMK keyboard firmware
Post by: metalliqaz on Tue, 28 April 2015, 14:27:49
Has any one built their firmware from a Raspberry Pi?  I am unfamiliar with Linux, so I do not know how to differentiate amongst distros or how that
would affect the ability to build the Makefile. 

Can anyone assist with this?

Thank you.

If you have the regular Raspbian install, that is more or less a regular Linux desktop, so you should be able to follow any instructions for compiling on Debian-based systems.
Title: Re: TMK keyboard firmware
Post by: SecretV on Fri, 08 May 2015, 12:57:26
I just wanted to thank you guys for this great firmware you've created. I was able to use this to get my de-pcb'd manually rewired AEKII working using the gh60 portion of this firmware.  :thumb:
Title: Re: TMK keyboard firmware
Post by: MontyElephant on Sat, 09 May 2015, 05:40:00
Can someone help me out or point me in the right direction?

I'm building a gamepad that has 8 columns and 5 rows. I've double checked all the hardware and everything seems to be fine.

However, when I plug the keyboard into the computer it will start printing random keystrokes. Here is a sample:

Code: [Select]
5tgb 5tgb 5tgb 5tgb 5tgb 5tgb 5ptlgm5tg5tgggggggggg5tg5tgplm5tgplm5tg5tg5tgplm5tg5tgplm5tg5tg5tg5tg5tg5tgplmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm5tg5tg5tg5tg5tg5tg5tg5tg5tg5tg5tg5tg5tg5tg5tg5tgplmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmplmplmplm5tg5tggggg5tg5tg5tg5tg5tg5tg5tg5tg5tg5tg5tg5tg5tg5tgg5tgv 5tgv 5tgv         5tgv 5tgv 5tgv 5tgv 5tgv 5tgv 5tgv 5tgv 5tgv 5tgv 5tgv 5tgv 5tgv 5tgv 5tgv 5tgv 5tgv 5tgv 5tgv 5tgv 5tgv 5tgv 5tgv 5tgv 5tgv 5tgv 5tgv 5tgv 5tgv 5tgv 5tgv 5tgv 5tgv 5tgv 5tgv 5tgv 5tgv 5tgv 5tgv 5tgv 5tgv 5tgv
What is curious about this is that all those characters are in the last two columns. These keys get printed sometimes randomly or sometimes if I press a key (at least it seems to be a keypress response). If I press a key sometimes it will just keep typing out random stuff. Also, the groups such as 5tgb get printed all at once. To me, the fact that they are all in the same column seems to imply that it might(?) be a hardware issue but I want to rule out software before I rewire everything (took me like 3 hours)...

Just to clarify rows have diodes (all connected end-to-end and then to a the teensy) and columns just have wires going up the column correct?

If someone could look over the code in my repository (there isn't very much) that'd really help! Thanks!
https://github.com/joshtsen/tmk_keyboard/tree/master/keyboard/gh60 (https://github.com/joshtsen/tmk_keyboard/tree/master/keyboard/gh60)

EDIT:

Okay so I've made some changes and now the last two columns work correctly but none of the other keys register output. All the keys in cols 6 and 7 (0-based) which are on PINB (whereas the rest are on PINF) work. However, there is one key on PINF7 row 3 that works. This caused me to think there might be something wrong with my init_cols or read_cols with PINF since PINB seems to work fine. I also tried changing the style of init_cols to the style of unselect_rows using binary:
Code: [Select]
static void  init_cols(void)
{
    // Input with pull-up(DDR:0, PORT:1)
    DDRF  &= ~0b11110011;
    PORTF |= ~0b11110011;
    DDRB  &= ~(1<<6 | 1<<5);
    PORTB |=  (1<<6 | 1<<5);
}

This makes it so that the last two columns still work fine but a keypress in any other column will print the entire column. So I'm pretty sure then the wiring is correct and it is software bug somewhere? helP?


EDIT2:

SO I think I've located part of the problem. I created a jumper wire to manually connect pins to each other and was able to recreate the entire matrix. Ok great. So then I started looking at the wiring again and it seems that only keys that pass through no more than 2 diodes work. I'm not sure if this has to do with my wiring the diodes wrong, or the pull-up on the controller?

EDIT3:

Well I'm an idiot. I guess I wired all the diodes wrong... good thing I have extras.... FML
Title: Re: TMK keyboard firmware
Post by: Rose on Sun, 10 May 2015, 11:28:22
I'm so close to finishing my project! Thank you so much for this wonderful open source firmware.

I have been following matt3o's guide.  I just ran "make -f Makefile" and got the following error:
usr/bin/sh: dfu-programmer: command not found

Then it found an error at just about every step.
[attach=2]

What may have caused this?
Thanks for your help!
Title: Re: TMK keyboard firmware
Post by: metalliqaz on Sun, 10 May 2015, 11:54:11
Always fix the first error first.  Sounds like your keymap_common.h has an error around the definition of K2E.  The failure to complete parsing that file is probably leading to all the other errors.

Check to see if K2E is defined twice.  I'm not really familiar with TMK code, so I can't really pinpoint it for you.  Good luck!
Title: Re: TMK keyboard firmware
Post by: Rose on Sun, 10 May 2015, 12:06:13
Wow thanks.  K2E was defined twice.   How could you see that?
I fixed that but still get a similar result. 
Title: Re: TMK keyboard firmware
Post by: Rose on Sun, 10 May 2015, 12:07:35
Always fix the first error first. 
is the "usr/bin/sh: dfu-programmer: command not found" not the first error?
Title: Re: TMK keyboard firmware
Post by: metalliqaz on Sun, 10 May 2015, 12:09:15
Always fix the first error first. 
is the "usr/bin/sh: dfu-programmer: command not found" not the first error?

That's not a compiler error, so it doesn't really matter yet.
Title: Re: TMK keyboard firmware
Post by: metalliqaz on Sun, 10 May 2015, 12:10:25
Wow thanks.  K2E was defined twice.   How could you see that?
I fixed that but still get a similar result.

Make sure your keymap_poker.c has the appropriate #include statements that it needs.  It can't find the definition of KEYMAP
Title: Re: TMK keyboard firmware
Post by: Rose on Sun, 10 May 2015, 12:22:05
Thank you so much for your help.  I was able to generate a .hex file.
On to the next step!
Title: Re: TMK keyboard firmware
Post by: Rose on Sun, 10 May 2015, 21:00:52
Yes!  Thank you hasu and everyone else.  My keyboard is working.  I pretty much followed matt3o's tutorial and had your firmware working in a day. Not bad for someone with zero C programming experience.

The only thing that I haven't figured out are my LEDs.  It was my intention to have one for capslock and one or two others for layer indicators.  After reading this entire thread it sounds like there is no simple way to setup the layer lights.  I thought I was setting up a capslock LED with matt3o's guide but that isn't lighting up either.  I am not 100% sure that I have things wired correctly.  Here is how they are wired:

Pin C7 goes to a resistor, then to the longer anode.
I have LEDs connected on D7 and F7 in the same way. 
Then I have a wire that goes from one of the ground pins on the teensy to each LED's cathode.
Is this the correct way to ground them?

I modified the led.c file to this:
Code: [Select]
#include <avr/io.h>
#include "stdint.h"
#include "led.h"

void led_set(uint8_t usb_led)
{
    if (usb_led & (1<<USB_LED_CAPS_LOCK)) {
        // output low
        DDRC |= (1<<7);
        PORTC &= ~(1<<7);
    } else {
        // Hi-Z
        DDRC &= ~(1<<7);
        PORTC &= ~(1<<7);
    }
}

I tested each LED so I know they are working.  What do you think?  Is my problem hardware or software?

Thank you so much everyone.  A few months ago I new nothing about keyboards and had never touched a mechanical one.  Now I've designed and built my own.  I'll share same pics after I'm done with a few finishing touches.
Title: Re: TMK keyboard firmware
Post by: hasu on Tue, 12 May 2015, 01:01:20
It looks like your LEDs are wired correctly but code is reversed. C7 should be high instead of low when LED turns on if the pin is connected to anode.

Not sure, I may miss something.

You can post pics, schematic and code to give us better understanding, some of us are not native to English and the language may not be the easiest nor fastest to understand, in particular between non-natives. Even if you are native and your English is decent posting photos will be useful sometime.
Title: Re: TMK keyboard firmware
Post by: Rose on Tue, 12 May 2015, 16:07:09
Thanks. I switched the order and also found a small syntax error.  Three '&'s and one '|' instead of two and two.  Now it works! Thank you.
Title: Re: TMK keyboard firmware
Post by: VinnyCordeiro on Fri, 15 May 2015, 10:42:39
At his Project Zeta post (https://geekhack.org/index.php?topic=71161.0), metalliqaz made an interesting use of a 4-to-16 demultiplexer to expand the number of outputs of the ATmega32U4. Is it possible to adapt this idea on TMK (the original code isn't open, unfortunately)?

I didn't studied TMK code deeply, just enough to make my proof-of-concept keyboard work, so I don't know if the demux use will be difficult or not (I know how to code, but I quit serious programming for almost 10 years now, for professional reasons). 74HC154 accepts HIGH signal inputs and gives LOW signal outputs, as a matter of fact.
Title: Re: TMK keyboard firmware
Post by: p3lim on Fri, 15 May 2015, 10:51:11
Any modifiers held when pressing a macro key will be used in that macro, which of course breaks my macros.
Is there any proper way of handling modifiers in macros? Was kind of hoping that they would have no effect in macros unless explicitly set.

Edit:

This change in common/action_macro.c allowed this to work properly:
Code: [Select]
index ba93fc8..91276a3 100644
--- a/common/action_macro.c
+++ b/common/action_macro.c
@@ -35,6 +35,11 @@ void action_macro_play(const macro_t *macro_p)
     uint8_t interval = 0;
 
     if (!macro_p) return;
+
+    uint8_t old_mods = get_mods();
+    clear_mods();
+    send_keyboard_report();
+
     while (true) {
         switch (MACRO_READ()) {
             case KEY_DOWN:
@@ -74,6 +79,8 @@ void action_macro_play(const macro_t *macro_p)
                 break;
             case END:
             default:
+                add_mods(old_mods);
+                send_keyboard_report();
                 return;
         }
         // interval
Title: Re: TMK keyboard firmware
Post by: tweis on Fri, 15 May 2015, 11:37:41
Are the media keys OS X friendly (if say iTunes is in the background)? I am thinking to build for ps2avrGB boards
Title: Re: TMK keyboard firmware
Post by: tjweir on Fri, 15 May 2015, 12:09:48
Are the media keys OS X friendly (if say iTunes is in the background)? I am thinking to build for ps2avrGB boards


I use volume up, down and mute, and play/pause, next track and previous track on OSX with no issues.
Title: Re: TMK keyboard firmware
Post by: tweis on Fri, 15 May 2015, 13:28:56
Are the media keys OS X friendly (if say iTunes is in the background)? I am thinking to build for ps2avrGB boards


I use volume up, down and mute, and play/pause, next track and previous track on OSX with no issues.
Ok, so this is looking like I am having an issue with Spotify (https://community.spotify.com/t5/Help-Desktop-Linux-Mac-and/Next-Previous-media-keys-don-t-work-on-3rd-Party-Keyboard-Play/m-p/593026). Can you check to see if Prev/Next keys work in Spotify?
Title: Re: TMK keyboard firmware
Post by: hasu on Sat, 16 May 2015, 05:44:51
This is not confirmed completely yet, try it.
https://github.com/tmk/tmk_keyboard/wiki/FAQ-Keymap#media-control-keys-in-mac-osx
https://github.com/tmk/tmk_keyboard/issues/195

What is Spotify in fact? Is it  a web app or native app?
Title: Re: TMK keyboard firmware
Post by: hasu on Sat, 16 May 2015, 05:56:58
You cannot do like this in macro currently at least, you have to change core code like you did. TMK macro is ad hoc and not full fledged, I'll have to improve macro syntax and function apparently.
Or you will be able to realize this with 'action functions' without changing core code.

Your patch looks reasonable for your need :thumb:


Any modifiers held when pressing a macro key will be used in that macro, which of course breaks my macros.
Is there any proper way of handling modifiers in macros? Was kind of hoping that they would have no effect in macros unless explicitly set.

Edit:

This change in common/action_macro.c allowed this to work properly:
Code: [Select]
index ba93fc8..91276a3 100644
--- a/common/action_macro.c
+++ b/common/action_macro.c
@@ -35,6 +35,11 @@ void action_macro_play(const macro_t *macro_p)
     uint8_t interval = 0;
 
     if (!macro_p) return;
+
+    uint8_t old_mods = get_mods();
+    clear_mods();
+    send_keyboard_report();
+
     while (true) {
         switch (MACRO_READ()) {
             case KEY_DOWN:
@@ -74,6 +79,8 @@ void action_macro_play(const macro_t *macro_p)
                 break;
             case END:
             default:
+                add_mods(old_mods);
+                send_keyboard_report();
                 return;
         }
         // interval

Title: Re: TMK keyboard firmware
Post by: p3lim on Sat, 16 May 2015, 06:12:49
What is Spotify in fact? Is it  a web app or native app?

Spotify is a music streaming application, it comes as a native app for every OS (including mobile), and also have a web version for people on the go.
Most people use the native versions though, the web app kinda sucks.
Title: Re: TMK keyboard firmware
Post by: hasu on Sat, 16 May 2015, 06:17:03
TMK does not include code for that exact chip but you can write code for that chip and use it with TMK.
I think it is general purpose logic IC and you can find sample code easily. So I think it is not difficult at all to use it with you keyboard.

I wrote firmware for HHKB which uses 3 to 8 demux 74LS145 to drive matrix lines, you may want to check.
https://github.com/tmk/tmk_keyboard/tree/master/keyboard/hhkb


At his Project Zeta post (https://geekhack.org/index.php?topic=71161.0), metalliqaz made an interesting use of a 4-to-16 demultiplexer to expand the number of outputs of the ATmega32U4. Is it possible to adapt this idea on TMK (the original code isn't open, unfortunately)?

I didn't studied TMK code deeply, just enough to make my proof-of-concept keyboard work, so I don't know if the demux use will be difficult or not (I know how to code, but I quit serious programming for almost 10 years now, for professional reasons). 74HC154 accepts HIGH signal inputs and gives LOW signal outputs, as a matter of fact.
Title: Re: TMK keyboard firmware
Post by: p3lim on Sat, 16 May 2015, 06:21:24
You cannot do like this in macro currently at least, you have to change core code like you did. TMK macro is ad hoc and not full fledged, I'll have to improve macro syntax and function apparently.
Or you will be able to realize this with 'action functions' without changing core code.

Your patch looks reasonable for your need :thumb:


Any modifiers held when pressing a macro key will be used in that macro, which of course breaks my macros.
Is there any proper way of handling modifiers in macros? Was kind of hoping that they would have no effect in macros unless explicitly set.

Edit:

This change in common/action_macro.c allowed this to work properly:

Could I override the function "action_macro_play" in my code without modifying the core? I don't know enough about C yet to answer this myself.
Title: Re: TMK keyboard firmware
Post by: hasu on Sat, 16 May 2015, 06:30:25
You can copy common/action_macro.c to your project directory and edit it to override core file. If same named file are in project directory it is used in preference to core file in build process.

Could I override the function "action_macro_play" in my code without modifying the core? I don't know enough about C yet to answer this myself.

Title: Re: TMK keyboard firmware
Post by: p3lim on Sat, 16 May 2015, 13:05:42
You can copy common/action_macro.c to your project directory and edit it to override core file. If same named file are in project directory it is used in preference to core file in build process.

Could I override the function "action_macro_play" in my code without modifying the core? I don't know enough about C yet to answer this myself.

Did not seem to work, I might have done something wrong though.
Title: Re: TMK keyboard firmware
Post by: hasu on Sat, 16 May 2015, 19:01:42
Create 'common' directory in project directory and place the file into the 'common' directory.
This is not clean but it works for me.
Title: Re: TMK keyboard firmware
Post by: mpigg on Sun, 17 May 2015, 06:38:35
I wired up a Teensy 2 to a PS/2 socket and installed ps2_usb on the board, but get no response from the keyboard. I'm confident that I have power hooked up right as the leds on the keyboard do their usual flash on power up. I'm pretty sure that I have Clock and Data correctly hooked up to PD0 and PD1. Any ideas on what to check next? Should I try reversing the clock and data lines? I don't have pull up resistors in there and am not clear on whether they're needed. Should I try adding those?

Update: I downloaded soarer's converter code to the Teensy and the interface worked fine. Is PD0 and PD1 the right connections for ps2_usb?

Update 2: Changed the PS2_DATA_BIT value to 0 in config.h and got it working. The README.md in ps2_usb is not in sync with the actual code.
Title: Re: TMK keyboard firmware
Post by: p3lim on Sun, 17 May 2015, 12:20:58
Create 'common' directory in project directory and place the file into the 'common' directory.
This is not clean but it works for me.

That worked, thank you.
Title: Re: TMK keyboard firmware
Post by: hasu on Mon, 18 May 2015, 00:02:02
Update 2: Changed the PS2_DATA_BIT value to 0 in config.h and got it working. The README.md in ps2_usb is not in sync with the actual code.

Thanks, i'll fix it later.


EDIT: Fixed at https://github.com/tmk/tmk_keyboard/commit/6014d1014e96a7b484699d4dd8c04292c0233b0e
Title: Re: TMK keyboard firmware
Post by: Spopepro on Mon, 18 May 2015, 18:18:57
Hasu,
I was wondering if you could point me in the right direction here.  I was trying to add some macros for my RedScarf III and broke it.  The stock firmware is from this fork: https://github.com/kairyu/tmk_keyboard_custom/tree/master/keyboard/RedScarfIII

I can't get even the "vanilla" firmware to load.  Make compiles it just fine, but loading it results in an "Unknown Device".  The RedScarf III is designed to use the LUFA Printer bootloader (http://fourwalledcubicle.com/blog/2013/03/the-new-lufa-bootloader/).

If I comment out the line:
Code: [Select]
KEYMAP_IN_EEPROM_ENABLE = yes # Read keymap from eeprom
and then load the hex file the device is recognized as a HID Keyboard, but nothing happens.  No keystrokes register, no lighting controls, nothing.  But it felt like progress.

I've tried to use the TMK build instructions, but I'm unsure if the printer bootloader requires some different settings.  I'm down for figuring this one out on my own... I just don't know where to look next.


***EDIT*** It's all good now--was just running out of memory.  I'm really surprised that the same toolchain on different computers result in different builds...  Now I just need to figure out the last bit about macros ( U(LALT) doesn't release the key currently).
Title: Re: TMK keyboard firmware
Post by: Spopepro on Wed, 27 May 2015, 16:09:11
I've fixed nearly all of my issues... and I sort of hesitate to ask this since I know Macros are a not-really-finished part of the firmware, but I'm having an issue where U(MOD) doesn't actually lift the modifier.  D(MOD) works just fine, and pressing the mod after the macro runs so the up registers clears things.  Anywhere I should look to see what's going on?

BTW, having dug around now more completely, this software is pretty awesome.  I really appreciate hasu's effort and making it available.
Title: Re: TMK keyboard firmware
Post by: hasu on Thu, 28 May 2015, 00:28:53
Macros are handled in action_macro.[ch], see those files in tmk_core/common/. It is very simple.

In design modifiers in macro should not be stuck even if you forget to do U(MOD).
What is your macro definition?

This macro worked.
Code: [Select]
                     
const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
{                                 
    switch (id) {                 
        case HELLO:               
            return (record->event.pressed ?
                    MACRO( D(LSFT), T(H), U(LSFT), T(E), T(L), T(L), T(O), END ) :
                    MACRO( U(LSFT), END ) );
Title: Re: TMK keyboard firmware
Post by: plegnic on Fri, 29 May 2015, 12:10:39
Have experience w/ uControllers but not w/ Atmel. Building using default planck files on Win 7x64.

All the guides say to use WinAVR but the tmk github page says "WINAVR is obsolete".

Tried Atmel studio and it just throws errors:

Quote
Updating goal targets....
Considering target file `all'.
 File `all' does not exist.
  Considering target file `begin'.
   File `begin' does not exist.
   Finished prerequisites of target file `begin'.
  Must remake target `begin'.
Creating temporary batch file C:\Users\~~\AppData\Local\Temp\make6088-1.bat
CreateProcess(C:\Users\~~\AppData\Local\Temp\make6088-1.bat,C:\Users\~~\AppData\Local\Temp\make6088-1.bat,...)
Putting child 0x01cd9380 (begin) PID 30156216 on the chain.
Live child 0x01cd9380 (begin) PID 30156216
ECHO is off.

... so for some reason it is trying to make a target file called "all" instead of running the "make all" macro? This result occurs whether or not I send it "make" or "make all" as a command. This is not at the top of the output, full file is attached... [attachurl=1]

Ideas? Should I just uninstall this thing and go for WinAVR even though it isn't recommended?
Title: Re: TMK keyboard firmware
Post by: wakko on Tue, 02 June 2015, 13:39:01
I have a 17x5 TKL matrix. It's all working as expected, thanks to hasu for the firmware and this community. I'm have one issue and I'm not sure if it's hardware related or something I missed in the firmware. 3 keys in my 16th column cause one of the adjacent keys in the 17th column to register. When I press home, end, and down like this:

home = home + page up
end = end + page up
down = down + right

i think it's the diodes but I'm not sure and thought to check here first.

Thanks.
Title: Re: TMK keyboard firmware
Post by: VinnyCordeiro on Tue, 02 June 2015, 14:31:54
I have a 17x5 TKL matrix. It's all working as expected, thanks to hasu for the firmware and this community. I'm have one issue and I'm not sure if it's hardware related or something I missed in the firmware. 3 keys in my 16th column cause one of the adjacent keys in the 17th column to register. When I press home, end, and down like this:

home = home + page up
end = end + page up
down = down + right

i think it's the diodes but I'm not sure and thought to check here first.

Thanks.
I had a similar issue and it was due unwanted solder jumpers shorting 3 pins of my microcontroller  (I directly soldered it on the board). Take a closer look on your solder joints, use a multimeter to confirm shorts and correct them.
Title: Re: TMK keyboard firmware
Post by: wakko on Wed, 03 June 2015, 00:34:53
Thanks. Will check.
Title: Re: TMK keyboard firmware
Post by: Yeitso on Thu, 04 June 2015, 09:54:19
Hey hasu, I see that you have a Serialmouse project ongoing. I Have a Trackball from kensington that goes on the same interface as the old Macintosh M0100 mouse. Do you think that your Serialmouse_USB would work for that?
Title: Re: TMK keyboard firmware
Post by: hasu on Thu, 04 June 2015, 16:54:59
I don't think so. But I don't know both of those protocols, to be honest.

Serialmouse code was contributed, the author is not me.
https://github.com/tmk/tmk_keyboard/pull/131

You will be able to know how Macintosh mouse works from this document. See page 17, the mice sends output of photo interrupters directly.
ftp://ftp.apple.asimov.net/pub/apple_II/documentation/macintosh/Mac%20Hardware%20Info%20-%20Mac%20128K.pdf


TIL: "Apple II, Apple III, Lisa and Macintosh mice are electrically identical."  from the doc


Hey hasu, I see that you have a Serialmouse project ongoing. I Have a Trackball from kensington that goes on the same interface as the old Macintosh M0100 mouse. Do you think that your Serialmouse_USB would work for that?
Title: Re: TMK keyboard firmware
Post by: VinnyCordeiro on Thu, 04 June 2015, 19:12:13
Can someone point me an example for backlighting? My Google-fu is failing me. What I need to know:
The few results that I found were a bit confusing for me.  :-[
Title: Re: TMK keyboard firmware
Post by: hasu on Thu, 04 June 2015, 20:33:24
It seems like Kairyu 's firmware for Redscarf has backlight function. You mgith want to check it.
https://github.com/kairyu/tmk_keyboard_custom/tree/master/keyboard/RedScarfIII
Title: Re: TMK keyboard firmware
Post by: VinnyCordeiro on Thu, 04 June 2015, 20:45:07
It seems like Kairyu 's firmware for Redscarf has backlight function. You mgith want to check it.
https://github.com/kairyu/tmk_keyboard_custom/tree/master/keyboard/RedScarfIII
Thank you, hasu.

If I understand it correctly, the assigned µcontroller pin act like a software PWM, am I right? So all I need is to connect this pin to a transistor/MOSFET/whatever and then drive the backlight, is that so?
Title: Re: TMK keyboard firmware
Post by: hasu on Thu, 04 June 2015, 20:58:40
I think you are right.
But I don't know about the keyboard, who designed and whether its design is open or not.
Probably you have to look into pics of PCB of the keyboard to know its design.
Title: Re: TMK keyboard firmware
Post by: VinnyCordeiro on Thu, 04 June 2015, 21:08:09
I think you are right.
But I don't know about the keyboard, who designed and whether its design is open or not.
Probably you have to look into pics of PCB of the keyboard to know its design.
The questions are for a keyboard I am designing, I don't think that will be a problem. :))
Title: Re: TMK keyboard firmware
Post by: hasu on Thu, 04 June 2015, 22:27:37
Ah no   I meant redscarf. I thought you have to know circuit design of the keyboard to understand exactly how firmware works.

But I also think it uses usual design to drive LEDs as you said.
Title: Re: TMK keyboard firmware
Post by: Yeitso on Fri, 05 June 2015, 01:45:58
Found this, its the same type of quadrature technology. Gonna see if i can get it to work :)

https://hackaday.io/project/5875-busmouse-to-usb-hid-conversion
Title: Re: TMK keyboard firmware
Post by: hasu on Fri, 05 June 2015, 02:13:26
Looks interesting projects! Keep us updated. I don't have any pointing device like that, I'm still very curious.

I didn't know the word quadrature and how busmouse works until today. Nice to know new things
Title: Re: TMK keyboard firmware
Post by: trauring on Sun, 07 June 2015, 11:29:38
I'm in the process of editing the keymap in TMK (the branch by jackhumbert for the Atomic), and I'm wondering how to proceed. There are photos of the keyboard in my build thread (https://geekhack.org/index.php?topic=71762) including a diagram of the matrix.

Looking back, I see perhaps I should have wired my matrix a little different to make it easier to customize the keymap, but since this is the first keyboard I've built, that's 20/20 hindsight. For one, I was looking at the back of the keyboard, since that's where I was working on soldering, etc. so I numbered it from left to right on the back side, when really it needs to be flipped.

The matrix in the current keymap is:

Code: [Select]
    [0] = KEYMAP_JCK(GRV,  1,    2,    3,    4,    5,    6,    7,    8,    9,    0,    MINS, EQL, BSPC, \
                     TAB,  Q,    W,    E,    R,    T,    Y,    U,    I,    O,    P,    LBRC, RBRC, BSLS, DEL, \
                     ESC,  A,    S,    D,    F,    G,    H,    J,    K,    L,    SCLN, QUOT,    ENT,     MPLY, \
                     LSFT, Z,    X,    C,    V,    B,    N,    M,    COMM, DOT,  SLSH,    RSFT,    VOLD, VOLU, \
                     LCTL,    LALT,  LGUI,          SPC,                         FN1,  LEFT, DOWN, UP,   RGHT),

In my matrix, the last key in the top row is linked to the last column, instead of the second-to-last, which might make more sense looking at it from the front side. Same with the other two 2u keys. At first I figured maybe I just need to add an extra comma where the column is skipped, but then I noticed there are no extra commas in the bottom row where the spacebar spans about 6 columns. While it's possible the matrix was wired such that there are no skipped columns on the bottom row, I find that unlikely.

So basically, how to I modify the keycap to reflect the skipped rows? Is this something I need to do elsewhere?

Thanks.
Title: Re: TMK keyboard firmware
Post by: a-c on Sun, 07 June 2015, 13:33:23
You will want to edit keymap_common.h to match the physical layout of your matrix.

Code: [Select]
// JCK: Semi-Standard layout
#define KEYMAP_JCK( \
    K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C,   K0E,    \
    K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, K1E, \
    K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B,    K2D,   K2E, \
    K30, K31, K32, K33, K34, K35, K36, K37, K38, K39, K3A,    K3C,   K3D, K3E, \
     K40,  K41,  K43,           K46,                  K4A, K4B, K4C, K4D, K4E  \
) { \
    { 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_NO,    KC_##K0E }, \
    { 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_##K1E }, \
    { 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_NO,    KC_##K2D, KC_##K2E }, \
    { KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_##K35, KC_##K36, KC_##K37, KC_##K38, KC_##K39, KC_##K3A, KC_NO,    KC_##K3C, KC_##K3D, KC_##K3E }, \
    { KC_##K40, KC_##K41, KC_NO,    KC_##K43, KC_NO,    KC_NO,    KC_##K46, KC_NO,    KC_NO,    KC_NO,    KC_##K4A, KC_##K4B, KC_##K4C, KC_##K4D, KC_##K4E }  \
}

The bottom section names each matrix position. The top assigns those positions to the keymap. You probably just need to rearrange the gaps in your matrix.

I think.
Title: Re: TMK keyboard firmware
Post by: Zukoi on Wed, 10 June 2015, 23:53:15
Sorry if this been asked before, but what is the difference between #define keymap and #define keycap_ansi functionally? I noticed that keycap_ansi lacks KC_##XX and they are differently ordered but I don't understand why. According to Matt3o's guide, you can ignore keycap_ansi but the issue is that I am modifying the Phantom firmware for a handwired TKL and the organization is different than gh60. In fact, I noticed different firmwares are organized differently and I makes it hard to mod them because I don't know why the variations exist.
Title: Re: TMK keyboard firmware
Post by: hasu on Thu, 11 June 2015, 04:04:14
No difference essentially. In tmk keymap is an array of byte(uint8_t) in the end, KEYMAP macros are just useful to define the keymap array intuitively in concise form, not necessarily essential. You can define the array directly without macro if you want.
Title: Re: TMK keyboard firmware
Post by: Zukoi on Thu, 11 June 2015, 11:39:35
No difference essentially. In tmk keymap is an array of byte(uint8_t) in the end, KEYMAP macros are just useful to define the keymap array intuitively in concise form, not necessarily essential. You can define the array directly without macro if you want.

I am guessing the reasons you have different keymap macros is to support different layouts?

Also, how do I begin to understand your code? I am a newbie at C and can understand basic stuff but your code is very overwhelming to understand especially since I don't even know where the code starts. I couldn't even find the main.c (maybe I am blind?).
Title: Re: TMK keyboard firmware
Post by: hasu on Thu, 11 June 2015, 18:21:49
Yes.

When you read/search/exploere unknown codes of large project it is very useful to setup code reference system like tag jump or GNU GLOBAL with your editor. You may like to make reference of codes incuding AVR Lib, this helped me a lot while coding for AVR.
main() is located in tmk_core/protocol/lufa/lufa.c. To be honest, TMK code is not well organized and is still just copy of my current working code, so it is not your fault :D


Probably you need to know a bit of AVR Lib, C preprocessor, GCC extension and GNU Make as well as basic C langueage syntax. You don't have to read through, just refer to or search them when you cannot understand it with C knowledge in your brain.

http://www.nongnu.org/avr-libc/user-manual/modules.html
https://gcc.gnu.org/onlinedocs/cpp/
https://gcc.gnu.org/onlinedocs/gcc/C-Extensions.html
http://www.gnu.org/software/make/manual/make.html
Title: Re: TMK keyboard firmware
Post by: Zukoi on Thu, 11 June 2015, 21:55:22
Yes.

When you read/search/exploere unknown codes of large project it is very useful to setup code reference system like tag jump or GNU GLOBAL with your editor. You may like to make reference of codes incuding AVR Lib, this helped me a lot while coding for AVR.
main() is located in tmk_core/protocol/lufa/lufa.c. To be honest, TMK code is not well organized and is still just copy of my current working code, so it is not your fault :D


Probably you need to know a bit of AVR Lib, C preprocessor, GCC extension and GNU Make as well as basic C langueage syntax. You don't have to read through, just refer to or search them when you cannot understand it with C knowledge in your brain.

http://www.nongnu.org/avr-libc/user-manual/modules.html
https://gcc.gnu.org/onlinedocs/cpp/
https://gcc.gnu.org/onlinedocs/gcc/C-Extensions.html
http://www.gnu.org/software/make/manual/make.html

If you ever want to give a newbie a panic attack, scroll down quickly on GNU documentation.

Anyway, I got my keyboard and KR on my desk, I think can make it out alive...
Title: Re: TMK keyboard firmware
Post by: ambergrismonger on Mon, 22 June 2015, 23:29:05
Hey, total noob here. I'm patiently awaiting parts from Jack to build a Quark and I went through matt3o's firmware guide on deskthority.  I'm at the point in his guide where I need to compile the firmware but I'm getting this error:

Code: [Select]
S:\Keyboard\tmk_keyboard-master\keyboard\gh60>make
/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_at90usb1287
Compiling C: keymap_poker.c
avr-gcc -c -mmcu=atmega32u4 -gdwarf-2 -DF_CPU=16000000UL -DINTERRUPT_CONTROL_END
POINT -DBOOTLOADER_SIZE=4096 -DF_USB=16000000UL -DARCH=ARCH_AVR8 -DUSB_DEVICE_ON
LY -DUSE_FLASH_DESCRIPTORS -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB
_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)" -DFIXED_CONTROL_ENDPOINT_SIZE=8  -DFIXED_N
UM_CONFIGURATIONS=1 -DPROTOCOL_LUFA -DBOOTMAGIC_ENABLE -DMOUSEKEY_ENABLE -DMOUSE
_ENABLE -DEXTRAKEY_ENABLE -DCONSOLE_ENABLE -DCOMMAND_ENABLE -DVERSION=unknown -O
s -funsigned-char -funsigned-bitfields -ffunction-sections -fdata-sections -fno-
inline-small-functions -fpack-struct -fshort-enums -fno-strict-aliasing -Wall -W
strict-prototypes -Wa,-adhlns=obj_at90usb1287/keymap_poker.lst -I. -I../../tmk_c
ore -I../../tmk_core/protocol/lufa -I../../tmk_core/protocol/lufa/LUFA-git -I../
../tmk_core/common -std=gnu99 -include config.h -MMD -MP -MF .dep/obj_at90usb128
7_keymap_poker.o.d  keymap_poker.c -o obj_at90usb1287/keymap_poker.o
keymap_poker.c:10: error: expected '}' before '{' token
make: *** [obj_at90usb1287/keymap_poker.o] Error 1

Below are all of the firmware files modified, any help would be greatly appreciated,

https://gist.github.com/anonymous/ca6c3c3292aeded67e5c (https://gist.github.com/anonymous/ca6c3c3292aeded67e5c)


Title: Re: TMK keyboard firmware
Post by: hasu on Tue, 23 June 2015, 04:23:54
It says the error occurred in keymap_poker. c. Basically you can believe GCC message and should check there 10 times until you discover it. The file includes keymap_common.c so you should also see there if you can't find the error in first place.

That's exactly what I do during debug.
Title: Re: TMK keyboard firmware
Post by: lifow on Tue, 23 June 2015, 14:25:08
Hi there, I'm trying to put TMK on a teensy 2.0 to control my hhkb and have been following this guide: https://geekhack.org/index.php?topic=57008

It's all good until the talk about changing matrix.c to reflect differences in wiring, the code that I'm supposed to be changing seems to have moved to hhkb_avr.h but it's also changed quite a bit so I'm not totally sure what changes I'm supposed to be making...

I did some googling but that seems to be the most recent guide. Any pointers in the right direction would be much appreciated.
Title: Re: TMK keyboard firmware
Post by: hasu on Thu, 25 June 2015, 19:54:14
Hmm, it doesn't seem to be so changed, I think it is still logically equivalent and you can just do the same way.

Or just change connection in origial TMK way you will be able to use default source code.
https://github.com/tmk/tmk_keyboard/blob/master/keyboard/hhkb/doc/HHKB.txt#L33-L52
Quote

    HHKB connector lines:
    JP   Pro2   Pro     Function    Description                               TMK pin usage
    --------------------------------------------------------------------------------------------
                 1      Vcc(5V)                                               5V
     1    1      2      Vcc(5V)                                               5V
     2    2      3      Vcc(5V)                                               5V
     3    3      4      TP1684      ~KEY: Low(0) when key is pressed          PD7 input(with pullup)
     4    4      5      TP1684      HYS: High(1) when key is pressed          PB7 output
     5    5      6      HC4051      A(bit0)\                                  PB0 output
     6    6      7      HC4051      B(bit1) > select row 0-7                  PB1 output
     7    7      8      HC4051      C(bit2)/                                  PB2 output
     8    8      9      LS145       A(bit0)\                                  PB3 output
     9    9     10      LS145       B(bit1) > select column 0-7               PB4 output
    10   10     11      LS145       C(bit2)/                                  PB5 output
    11   11     12      LS145       ~D(enable) Low(0) enables selected column PB6 output
    12   12     13      GND                                                   GND
    13   13     14      GND                                                   GND
                15      GND
    14                  HC4051(Z2)  ~Enable of Z2   row0-7                    PC6
    15                  HC4051(Z3)  ~Enable of Z3   row8-15                   PC7

    NOTE: Probably HYS changes threshold for upstroke and makes hysteresis in the result.
    NOTE: HYS should be given High(1) when previous KEY state is Low(0).
    NOTE: 1KOhm didn't work as pullup resistor on KEY. AVR internal pullup or 10KOhm resistor was OK.
    NOTE: JP has two HC4051(Z2,Z3) and line 5, 6 and 7 are connected to both of them.
Title: Re: TMK keyboard firmware
Post by: sth on Fri, 26 June 2015, 02:19:44
test post from hhkb pro1, great success! now to start changing layouts... thanks again hasu.
Title: Re: TMK keyboard firmware
Post by: QuiGonJinn on Sat, 11 July 2015, 08:31:14
I am in the process of building a custom keyboard and I have an arduino clone with the atmega328p MCU lying around. I tried compiling firmware for it using the Makefile.vusb from the HHKB project. The matric.c file is including lufa.h which is then including lufa/Drivers/USB/Core/USBMode.h and then I get the error message "The currently selected device or architecture is not supported under the USB component of the library" and then a bunch of other errors. Is there a straightforward way to compile keyboard software for my MCU? Excuse me for my ignorance.
Title: Re: TMK keyboard firmware
Post by: flabbergast on Sat, 11 July 2015, 08:35:38
First, AFAIK vusb library is not very well supported in TMK.

Second, even if you manage to compile TMK for atmega328p, arduino (and clones with very few exceptions) are not wired to USB the way vusb library requires - so the firmware wouldn't "work" anyway.

(Reason being that arduinos based on m328p use a serial-to-usb converter chip between the atmega328p and USB. So what talks to the computer's USB is actually that chip (usually FTDI or atmega16u2), and not m328p. So whatever you program into m328p, the arduino will still look like a serial port to the computer.)

EDIT: The only at least not-completely-home-wired product I've seen that uses m328p and is wired "correctly" for vusb is tinyusbboard: http://matrixstorm.com/avr/tinyusbboard/

EDIT2: if makefile.vusb tries to include lufa files, then it's completely broken. If vusb is used, then LUFA should not be included at all.
Title: Re: TMK keyboard firmware
Post by: QuiGonJinn on Sat, 11 July 2015, 08:42:16
Thanks for the quick reply. Lufa library is only supported for native USB MCUs?
Title: Re: TMK keyboard firmware
Post by: flabbergast on Sat, 11 July 2015, 08:43:17
Thanks for the quick reply. Lufa library is only supported for native USB MCUs?
Yep. Although it would be better to say that LUFA library only supports native USB chips ;)
Title: Re: TMK keyboard firmware
Post by: QuiGonJinn on Sat, 11 July 2015, 09:02:19
I see, thank for clarifying everything. Probably buying an arduino micro is the fastest alternative for me right now.
Title: Re: TMK keyboard firmware
Post by: flabbergast on Sat, 11 July 2015, 09:20:51
I see, thank for clarifying everything. Probably buying an arduino micro is the fastest alternative for me right now.
Yep. Or a teensy.
Title: Re: TMK keyboard firmware
Post by: QuiGonJinn on Sat, 11 July 2015, 10:03:12
Yes, I would buy a teensy, which I am using for another custom keyboard I am working on, but the greek market seems drained of teensys  :)
Title: Re: TMK keyboard firmware
Post by: hasu on Sat, 11 July 2015, 17:18:35
I am in the process of building a custom keyboard and I have an arduino clone with the atmega328p MCU lying around. I tried compiling firmware for it using the Makefile.vusb from the HHKB project. The matric.c file is including lufa.h which is then including lufa/Drivers/USB/Core/USBMode.h and then I get the error message "The currently selected device or architecture is not supported under the USB component of the library" and then a bunch of other errors. Is there a straightforward way to compile keyboard software for my MCU? Excuse me for my ignorance.

My HHKB controller project has no support for 328/168p series anymore.
I just fixed and added V-USB build process for ps2_usb and onekey project. You can see onekey if you are still interested.


As flabbergast said, USB AVR chip and LUFA is easier way.
Title: Re: TMK keyboard firmware
Post by: flabbergast on Sun, 12 July 2015, 01:52:43
My HHKB controller project has no support for 328/168p series anymore.
I just fixed and added V-USB build process for ps2_usb and onekey project. You can see onekey if you are still interested.
Thanks for the explanation! I didn't mean any disrespect when I said it's broken, sorry! I think TMK is a fine piece of software, thanks for maintaining it :thumb:
Title: Re: TMK keyboard firmware
Post by: Charger on Wed, 15 July 2015, 16:11:37
I was wondering if there is an easy way to add a layer indicator led into a layer? I have been wondering this for some time. I have used tmk on my main keyboard and numpad and I'm currently working on 3 other things that will be using tmk and wanted to add some leds to indicate the layer on one of them.
Title: Re: TMK keyboard firmware
Post by: hasu on Wed, 15 July 2015, 18:22:00
Probably you can add your code in common/action_layer.c. All layer change actions should be occured in static void default_layer_state_set(uint32_t state). See this PR. https://github.com/tmk/tmk_keyboard/pull/198

Or also you can define action_function() that changes layer and handles indicator at the same time in your keymap file.
Title: Re: TMK keyboard firmware
Post by: IBNobody on Wed, 15 July 2015, 20:05:56
I'm looking for some suggestions on how to implement a backlight solution that uses PWMs to control 4 LED rows of 6 LEDs each.

All the example keyboards with backlights defined appear to only use a handful of teensy I/O for the backlighting. That leads me to believe they aren't driving them with a PWM but instead are just turning them on (probably through a transistor). I don't want to just leave them on because that would consume way too much current and potentially violate the USB current spec.

I saw that the Planck fork of TMK DID use hardware PWMs, but it looked like they were also driving all keyboard LEDs through a single transistor. I'd still violate the current spec, but only for a fraction of a second.

Are there any other reference examples with multiple PWMs? Could I just fake it by adding in a backlight toggle to the matrix_scan function? (How often does that function run? Is it run at a specific fixed frequency?)
Title: Re: TMK keyboard firmware
Post by: hasu on Wed, 15 July 2015, 20:48:54
Are there any other reference examples with multiple PWMs? Could I just fake it by adding in a backlight toggle to the matrix_scan function? (How often does that function run? Is it run at a specific fixed frequency?)

I don't know much about PWM itself and how difficult to implement multiple PWMs, you can find many Arduino projects or something  to learn on the net.

matrix_scan() is called from while loop of main() actually, so not consistently periodic run.
I think you need to use timer interrupt if you want eaxact frequency or you are going to use software PWM.
Title: Re: TMK keyboard firmware
Post by: IBNobody on Wed, 15 July 2015, 21:13:32
I don't know much about PWM itself and how difficult to implement multiple PWMs, you can find many Arduino projects or something to learn on the net.

matrix_scan() is called from while loop of main() actually, so not consistently periodic run.
I think you need to use timer interrupt if you want eaxact frequency or you are going to use software PWM.

Ok. I'll try to dig into the Planck code (and the MCU datasheet) a little deeper and report back.

Though... I just had a thought. I probably only need 1 PWM. Having 4 PWMs and trying to drive all 4 LED banks separately (one bank on at a time) would mean that I'd be capped at a 25% duty cycle. I wonder how full-sized keyboards handle that current draw.
Title: Re: TMK keyboard firmware
Post by: a-c on Wed, 15 July 2015, 21:40:45
I don't know much about PWM itself and how difficult to implement multiple PWMs, you can find many Arduino projects or something to learn on the net.

matrix_scan() is called from while loop of main() actually, so not consistently periodic run.
I think you need to use timer interrupt if you want eaxact frequency or you are going to use software PWM.

Ok. I'll try to dig into the Planck code (and the MCU datasheet) a little deeper and report back.

Though... I just had a thought. I probably only need 1 PWM. Having 4 PWMs and trying to drive all 4 LED banks separately (one bank on at a time) would mean that I'd be capped at a 25% duty cycle. I wonder how full-sized keyboards handle that current draw.

The plank PCB isn't drawing more than 500ma. It has current limiting resistors on each LED. It draws about 3.5ma per LED (with white LED's). Total of about 168ma. Unless you want some incredibly bright output you can easily stay under 500ma.
Title: Re: TMK keyboard firmware
Post by: IBNobody on Wed, 15 July 2015, 22:11:55
The plank PCB isn't drawing more than 500ma. It has current limiting resistors on each LED. It draws about 3.5ma per LED (with white LED's). Total of about 168ma. Unless you want some incredibly bright output you can easily stay under 500ma.

Ahh. I wasn't sure how much current I should be drawing per LED (other than <= 20mA). When I get my LEDs in, I'll play around with my current limiting power supply and find the optimal brightness.
Title: Re: TMK keyboard firmware
Post by: Charger on Thu, 16 July 2015, 14:36:35
Probably you can add your code in common/action_layer.c. All layer change actions should be occured in static void default_layer_state_set(uint32_t state). See this PR. https://github.com/tmk/tmk_keyboard/pull/198

Or also you can define action_function() that changes layer and handles indicator at the same time in your keymap file.
ok so I think I got that working using his fork of tmk and building off that. Now I have another question I want to have a key that when tapped will toggle a layer but when pressed will do numlock and I'm wondering if that is possible. I seem to be able to get tap for key press and hold for momentary layer switching but couldn't see how to do what i wanted.
Title: Re: TMK keyboard firmware
Post by: hasu on Thu, 16 July 2015, 19:53:01
It is probably possible but not supported by default. You can define your own action in action_function(), though how to define is not well documented(or at all) and you'll have to read and look into core code.

You can find various action definitions in core/common/action.c.
https://github.com/tmk/tmk_keyboard/blob/master/tmk_core/common/action.c
Title: Re: TMK keyboard firmware
Post by: Charger on Fri, 17 July 2015, 19:36:36
It is probably possible but not supported by default. You can define your own action in action_function(), though how to define is not well documented(or at all) and you'll have to read and look into core code.

You can find various action definitions in core/common/action.c.
https://github.com/tmk/tmk_keyboard/blob/master/tmk_core/common/action.c
any suggestions on what to change or look at in action.c? I have tried changing some of the code with little result I couldn't even break the ACTION_LAYER_TAP_KEY I have set up when commenting out or changing parts of the code that i thought may have been related lol.
Title: Re: TMK keyboard firmware
Post by: hasu on Fri, 17 July 2015, 20:31:56
How did you change action.c? You can post here.
Did you try 'make clean' yet?
Title: Re: TMK keyboard firmware
Post by: Charger on Fri, 17 July 2015, 20:39:03
How did you change action.c? You can post here.
Did you try 'make clean' yet?
I use a batch file that does make clean and make -f makefile to compile it. As for what I edited was stuff under "case ACT_LAYER_TAP:" I was commenting things out and messing with stuff and recompiling and if I didn't notice any effect I would undo it so I don't really know what i changed but i thought I should have at least broken it if I was messing with the right things

Title: Re: TMK keyboard firmware
Post by: BlueNalgene on Sat, 18 July 2015, 21:35:57
Working on my Model M (8P5C connector) and I ran into some problems.

I did a make based on the ps2_usb converter with the following settings.

Code: [Select]

MCU = at90usb1286
F_CPU = 16000000
ARCH = AVR8
MOUSEKEY_ENABLE = yes # Mouse keys(+4700)
EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
CONSOLE_ENABLE = yes # Console for debug(+400)
COMMAND_ENABLE = yes    # Commands for debug and configuration
NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA

PS2_USE_INT = yes # uses external interrupt for falling edge of PS/2 clock pin


include $(TOP_DIR)/protocol.mk
include $(TOP_DIR)/protocol/pjrc.mk
include $(TOP_DIR)/common.mk
include $(TOP_DIR)/rules.mk


I omitted a bunch of the other stuff in the makefile, since I assume this is the relevant stuff.  Clock is set for D1, Data D0.  The hex makes, and I load it on my Teensy++.  When I power up, the 3 lock lights come on, then shut off after ~1s.  No keys are sent, and the lock lights don't change on the associated button press.  Where has it gone wrong?

The kicker: Soarer's XT/AT/PS2/Terminal 1.10 hex file for the Teensy++ works.  Not a hardware or wiring issue.
Title: Re: TMK keyboard firmware
Post by: hasu on Sat, 18 July 2015, 22:05:09
Are you sure your M speaks Code Set 2? My PS/2 converter supports only CS2 while his supports all CS1, 2 and 3.

If your keyboard is terminal type it speaks CS3. You can use my terminal converter instead of PS/2.
Title: Re: TMK keyboard firmware
Post by: BlueNalgene on Sat, 18 July 2015, 22:26:35
Are you sure your M speaks Code Set 2? My PS/2 converter supports only CS2 while his supports all CS1, 2 and 3.

If your keyboard is terminal type it speaks CS3. You can use my terminal converter instead of PS/2.

Oh, interesting point.  I don't have the original cable, so I can't check that way.  Next time I'm at that unit, I'll try the terminal version.
Title: Re: TMK keyboard firmware
Post by: henz on Fri, 24 July 2015, 15:18:41
Does TMK support KMAC happy? Will the normal TMK kmac work with the happy?
Title: Re: TMK keyboard firmware
Post by: IBNobody on Sat, 25 July 2015, 00:22:47
Ahh. I wasn't sure how much current I should be drawing per LED (other than <= 20mA). When I get my LEDs in, I'll play around with my current limiting power supply and find the optimal brightness.

So... Update...

I switched to using one PWM and was able to get 16 levels of brightness. Each LED pulls 6-7mA. I switch all LEDs through an NPN. I'm using ACTION_BACKLIGHT_TOGGLE, ACTION_BACKLIGHT_INCREASE, and ACTION_BACKLIGHT_DECREASE to control my states.

Everything works, but when I put my computer to sleep, the LEDs flicker on/off if I leave the backlight on.

I currently have the LED breathing option disabled.

Any idea why I'm seeing this behavior?
Title: Re: TMK keyboard firmware
Post by: TastaturenAuslese on Mon, 27 July 2015, 03:39:43
So I just finished defining a keymap for a new Planck that I'm getting in the mail. The previous owner already has the tmk firmware burned into the controller, and as such, I don't have any files besides the keymap I just wrote.

Can someone help me with what my next step should be? How do I make the makefile hex? I think this is the only step I don't understand. After I make the hex file, I can probably figure out how to load it unto the keyboard myself using the teensy loader. All help appreciated :D
Title: Re: TMK keyboard firmware
Post by: jorgenslee on Mon, 27 July 2015, 03:53:48
Hi hasu, is it possible to use TMK as a firmware for a arcade stick game controller?
Title: Re: TMK keyboard firmware
Post by: Zustiur on Tue, 28 July 2015, 09:54:54
I'm getting this error when I try to compile the tmk firmware:
Quote
D:\Programming\Shared Projects\tmk_keyboard\keyboard\ZusDox>make -f makefile
The system cannot find the path specified.
The system cannot find the path specified.
ECHO is off.
-------- 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.

-f was unexpected at this time.
make: *** [sizebefore] Error 255

Any clues as to what '-f was unexpected at this time' means? And why I'm getting "make: *** [sizebefore] Error 255"

I get the feeling it has something to do with winavr or windows rather than my code... I got the exact same error when I tried make -f makefile in the hhkb directory. I also googled a lot but came up with no helpful solutions.

I'll try a fresh install of WinAVR on a different machine tomorrow, but if anyone knows what's going on there I'd really appreciate the help!
Title: Re: TMK keyboard firmware
Post by: VinnyCordeiro on Tue, 28 July 2015, 10:07:31
I'm getting this error when I try to compile the tmk firmware:
Quote
D:\Programming\Shared Projects\tmk_keyboard\keyboard\ZusDox>make -f makefile
The system cannot find the path specified.
The system cannot find the path specified.
ECHO is off.
-------- 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.

-f was unexpected at this time.
make: *** [sizebefore] Error 255

Any clues as to what '-f was unexpected at this time' means? And why I'm getting "make: *** [sizebefore] Error 255"

I get the feeling it has something to do with winavr or windows rather than my code... I got the exact same error when I tried make -f makefile in the hhkb directory. I also googled a lot but came up with no helpful solutions.

I'll try a fresh install of WinAVR on a different machine tomorrow, but if anyone knows what's going on there I'd really appreciate the help!
If you run make in the same directory where the makefile is, the -f parameter is unnecessary, make always assumes that a run without parameter indicates that the makefile is in the current directory.

As for the Error 255, it means that make couldn't find a command for a particular rule. By your quote I assume you are running on Windows. I suggest you to install Cygwin (http://cygwin.com/), it makes easier to install GNU programs on Windows.
Title: Re: TMK keyboard firmware
Post by: BlueNalgene on Tue, 28 July 2015, 13:18:51
Are you sure your M speaks Code Set 2? My PS/2 converter supports only CS2 while his supports all CS1, 2 and 3.

If your keyboard is terminal type it speaks CS3. You can use my terminal converter instead of PS/2.

I almost forgot to report back.  The terminal converter wasn't playing along with my Model M either.  I really doubt that it uses CS3 or even CS1 though.  The original cable was SDL to PS2.  I tried both USART and interrupt wiring/code to no avail on both converters.

I'm not asking for a change in the code.  I just wanted to post a negative result in case someone else experiences a similar issue.  I'm just going to use Soarer's for this keyboard since I don't need anything too fancy and customized. 

-------

Unrelated question.  Why do you recommend USART in your code?  I don't entirely understand why that would be more robust than interrupt. 

Title: Re: TMK keyboard firmware
Post by: hasu on Tue, 28 July 2015, 19:25:58
I think Soarer's converter displays which code set is using and other useful infos on debug console(hid_listen?), if you are interested. I guess code set 1 is used only for XT keyboard.


---
Now that I don't think my PS/2 implementations(Interrupt/Busywait/USART) have much difference pratically in robustness but at that time my other two impl. was a bit iffy and I thought USART one could perform better. USART can handle most of signal process in hardware, not firmware and virtually never intterrupted by other events so it never miss PS/2 signal.(I think but I'm not 100% sure about AVR architecture)

But now I'd recommend 'Intterrupt' one due to its portability and readability. I think current 'Interrupt' and even 'Busywait' can perform enough and virtually don't miss the signal.
Title: Re: TMK keyboard firmware
Post by: Zustiur on Tue, 28 July 2015, 23:27:17
As for the Error 255, it means that make couldn't find a command for a particular rule. By your quote I assume you are running on Windows. I suggest you to install Cygwin (http://cygwin.com/), it makes easier to install GNU programs on Windows.
Thank you. It worked like a charm! I now have half a working keyboard. Time to solder up the other half!
Title: Re: TMK keyboard firmware
Post by: VinnyCordeiro on Tue, 28 July 2015, 23:31:28
As for the Error 255, it means that make couldn't find a command for a particular rule. By your quote I assume you are running on Windows. I suggest you to install Cygwin (http://cygwin.com/), it makes easier to install GNU programs on Windows.
Thank you. It worked like a charm! I now have half a working keyboard. Time to solder up the other half!
:thumb:
Title: Re: TMK keyboard firmware
Post by: njbair on Fri, 31 July 2015, 00:21:59
I didn't see this in the docs, but is there a way to change the timing threshold for tapping?
Title: Re: TMK keyboard firmware
Post by: a-c on Fri, 31 July 2015, 03:22:59
I didn't see this in the docs, but is there a way to change the timing threshold for tapping?

Look in common/action_tapping.h

Code: [Select]
/* period of tapping(ms) */
#ifndef TAPPING_TERM
#define TAPPING_TERM    200
#endif

/* tap count needed for toggling a feature */
#ifndef TAPPING_TOGGLE
#define TAPPING_TOGGLE  5
#endif
Title: Re: TMK keyboard firmware
Post by: njbair on Sat, 01 August 2015, 10:27:08
I didn't see this in the docs, but is there a way to change the timing threshold for tapping?

Look in common/action_tapping.h

Code: [Select]
/* period of tapping(ms) */
#ifndef TAPPING_TERM
#define TAPPING_TERM    200
#endif

/* tap count needed for toggling a feature */
#ifndef TAPPING_TOGGLE
#define TAPPING_TOGGLE  5
#endif

Wow, thanks. So I did some testing on this because I wasn't sure exactly how things worked.

Let's say I've got the spacebar set up with ACTION_LAYER_TAP_KEY(4, KC_SPC), and I leave TAPPING_TERM at its default 200ms. So as a modifier it enables Layer 4, and as a normal key it sends the scancode for Space.

I had expected that pressing it would enable Layer 4 immediately--so that if I held down the spacebar, then 100 milliseconds later pressed the Layer 4 key for F1 (number row 1 key, in my case), it would recognize it as a function action and not a normal keypress. But after some testing, it looks like the spacebar doesn't actually trigger Layer 4 until the 200ms period has occurred. So if I want to press F1, I have to hold down the spacebar for TAPPING_TERM before pressing the 1 key. So instead of sending the scancode for F1, the keyboard sends the scancodes for 1[space].

This creates a minor issue sometimes if I go too fast while trying to enter SpaceFn key combinations. But as I thought through this, I realized that this is really the only way to do it, because when we type our fingers don't always wait for the previous key to deactuate before actuating the next key (this is the whole premise behind NKRO).

With that said, 200ms seems like a pretty decent balance between the two. I'd like to do some testing to see if a slightly shorter TAPPING_TERM would work better for me, but with the need to recompile/reflash every time I'll really have to set aside some time to do that.

It would be really nice if you could set a key combination to increase/decrease the TAPPING_TERM on the fly. Something like ACTION_TAPPING_TERM_INC(x) and ACTION_TAPPING_TERM_DEC(x). While you're at it you can also have ACTION_TAPPING_TERM_SET(x), so if you know you prefer one speed for gaming and a different speed for office work, you can set key combinations to switch between them. Like Fn+G for Gaming Mode, Fn+W for Work Mode.

You would have to change TAPPING_TERM from a constant to a variable, and I'm not super familiar with embedded C code and the related memory constraints so I don't know how feasible this is. But it's something I'd be willing to work on if hasu approves.
Title: Re: TMK keyboard firmware
Post by: QuiGonJinn on Sat, 01 August 2015, 14:22:34
I have a question, not directly related to programming the microcontroller, but I need your experience. Is there a chance that the atmega32u4(of arduino micro) on my newly made keyboard ,gets overheated so it stops working?

After finishing the build today (and flashing of a gh60 code modification), it worked for 4 hours straight, and then it stopped working. I was getting some kernel messages about the device not accepting address(76 and 78 etc) and continuous connects and disconnects of the device. After leaving the keyboard in front of a fan to cool, and now using it with a fan on it, it's working fine. Mind, the temperature in my room was at 35°C a couple of hours ago. The mictocontroller is glued with hot silicon glue on the plastic case, but in my understanding, it is supposed to help conduct the heat to the case except for keeping it steady.
Title: Re: TMK keyboard firmware
Post by: njbair on Sat, 01 August 2015, 15:47:02
I have a question, not directly related to programming the microcontroller, but I need your experience. Is there a chance that the atmega32u4(of arduino micro) on my newly made keyboard ,gets overheated so it stops working?

After finishing the build today (and flashing of a gh60 code modification), it worked for 4 hours straight, and then it stopped working. I was getting some kernel messages about the device not accepting address(76 and 78 etc) and continuous connects and disconnects of the device. After leaving the keyboard in front of a fan to cool, and now using it with a fan on it, it's working fine. Mind, the temperature in my room was at 35°C a couple of hours ago. The mictocontroller is glued with hot silicon glue on the plastic case, but in my understanding, it is supposed to help conduct the heat to the case except for keeping it steady.

Was this previously working without issue before you reflashed it?
Title: Re: TMK keyboard firmware
Post by: QuiGonJinn on Sat, 01 August 2015, 17:29:54
I have a question, not directly related to programming the microcontroller, but I need your experience. Is there a chance that the atmega32u4(of arduino micro) on my newly made keyboard ,gets overheated so it stops working?

After finishing the build today (and flashing of a gh60 code modification), it worked for 4 hours straight, and then it stopped working. I was getting some kernel messages about the device not accepting address(76 and 78 etc) and continuous connects and disconnects of the device. After leaving the keyboard in front of a fan to cool, and now using it with a fan on it, it's working fine. Mind, the temperature in my room was at 35°C a couple of hours ago. The mictocontroller is glued with hot silicon glue on the plastic case, but in my understanding, it is supposed to help conduct the heat to the case except for keeping it steady.

Was this previously working without issue before you reflashed it?

I did not reflash the firmware. It just stopped responding and worked again without me touching anything. It has now been working again for 3 hours without any issues.
Title: Re: TMK keyboard firmware
Post by: njbair on Sat, 01 August 2015, 19:48:37
I have a question, not directly related to programming the microcontroller, but I need your experience. Is there a chance that the atmega32u4(of arduino micro) on my newly made keyboard ,gets overheated so it stops working?

After finishing the build today (and flashing of a gh60 code modification), it worked for 4 hours straight, and then it stopped working. I was getting some kernel messages about the device not accepting address(76 and 78 etc) and continuous connects and disconnects of the device. After leaving the keyboard in front of a fan to cool, and now using it with a fan on it, it's working fine. Mind, the temperature in my room was at 35°C a couple of hours ago. The mictocontroller is glued with hot silicon glue on the plastic case, but in my understanding, it is supposed to help conduct the heat to the case except for keeping it steady.

Was this previously working without issue before you reflashed it?

I did not reflash the firmware. It just stopped responding and worked again without me touching anything. It has now been working again for 3 hours without any issues.

Okay, sorry, I misunderstood. So you just finished building a new keyboard running on an Arduino Micro, which you've hot-glued to the case? If you've got the chip covered in hot glue that's your issue. Plastic doesn't conduct heat away. You should have that chip uncovered and facing out. Feel free to hot-glue the chip the other way, that shouldn't be an issue. But keep that chip facing the open air (whatever little there may be inside your keyboard.
Title: Re: TMK keyboard firmware
Post by: hasu on Sat, 01 August 2015, 20:32:07
Let's say I've got the spacebar set up with ACTION_LAYER_TAP_KEY(4, KC_SPC), and I leave TAPPING_TERM at its default 200ms. So as a modifier it enables Layer 4, and as a normal key it sends the scancode for Space.

I had expected that pressing it would enable Layer 4 immediately--so that if I held down the spacebar, then 100 milliseconds later pressed the Layer 4 key for F1 (number row 1 key, in my case), it would recognize it as a function action and not a normal keypress. But after some testing, it looks like the spacebar doesn't actually trigger Layer 4 until the 200ms period has occurred.

Yes, it is exactly how TMK tapping key works and limitation or compromise of TMK tapping key.
To get F1 you have to [1] hold space for TAPPING_TERM(but note that you can press 1 key anytime after pressing space) or [2] press and release 1 key before releasing space.


Quote
So if I want to press F1, I have to hold down the spacebar for TAPPING_TERM before pressing the 1 key. So instead of sending the scancode for F1, the keyboard sends the scancodes for 1[space].

 You don't have to wait 200ms *before* pressing 1 key, you can press 1 key anytime after holding down space, as said above,  just have to hold down space for 200ms([1]) or release 1 key before releasing space([2]).

You cannot get a complete modifier behaviour(and key behaviour) with tapping key, it is all of trade off or compromise. If you have better modifier behaviour you will have to accept more limitation on key behaviour. TMK tapping key is just one of dual roll key implementations and other can have a bit different behaviour and limitation. You have to accept some limitation anyway when you use tapping(dual role) key.


Quote
This creates a minor issue sometimes if I go too fast while trying to enter SpaceFn key combinations. But as I thought through this, I realized that this is really the only way to do it, because when we type our fingers don't always wait for the previous key to deactuate before actuating the next key (this is the whole premise behind NKRO).

EDIT: yes, you are right. the limitation of TMK is needed for better typing experience especially when typing fast.




Changing TAPPING_TERM parameter on the fly without compile would be useful when you find your value by trial and error. But I think at most several compile processes are needed to decide your proper value.
For gaming purpose you may want to change layer and use ACTION_LAYER_MOMENTARY() instead of ACTION_LAYER_TAP_KEY(). Even using small value doesn't resolve the tapping limitation essentially for gaming in particular.

I may implement these actions in next refactroing of keymap module but not sure.
Title: Re: TMK keyboard firmware
Post by: hasu on Sat, 01 August 2015, 20:44:34
You can post pics of your work and error messages as is to get more help from the community.

I have a question, not directly related to programming the microcontroller, but I need your experience. Is there a chance that the atmega32u4(of arduino micro) on my newly made keyboard ,gets overheated so it stops working?

After finishing the build today (and flashing of a gh60 code modification), it worked for 4 hours straight, and then it stopped working. I was getting some kernel messages about the device not accepting address(76 and 78 etc) and continuous connects and disconnects of the device. After leaving the keyboard in front of a fan to cool, and now using it with a fan on it, it's working fine. Mind, the temperature in my room was at 35°C a couple of hours ago. The mictocontroller is glued with hot silicon glue on the plastic case, but in my understanding, it is supposed to help conduct the heat to the case except for keeping it steady.

Title: Re: TMK keyboard firmware
Post by: njbair on Sat, 01 August 2015, 21:13:25
Changing TAPPING_TERM parameter on the fly without compile would be useful when you find your value by trial and error. But I think at most several compile processes are needed to decide your proper value.

The real pain with reflashing firmwares is that you need another keyboard to do it, because once you put the board in bootloader mode, you can't type the shell commands. I don't keep a spare keyboard here at home. I work around this by SSH'ing from my laptop, so not a huge deal but still kind of a pain.

For gaming purpose you may want to change layer and use ACTION_LAYER_MOMENTARY() instead of ACTION_LAYER_TAP_KEY(). Even using small value doesn't resolve the tapping limitation essentially for gaming in particular.

So basically just make a gamer layer. This is actually a really good idea. Thanks!

I may implement these actions in next refactroing of keymap module but not sure.

Not a high priority, for sure. But it would be kind of a neat feature. I'm assuming it's not possible to store the new TAPPING_TERM permanently, since AFAIK there is no flash memory on the chip.
Title: Re: TMK keyboard firmware
Post by: a-c on Sat, 01 August 2015, 23:34:56
It has EEPROM. That is where the virtual DIP switch settings are stored.
Title: Re: TMK keyboard firmware
Post by: flabbergast on Sun, 02 August 2015, 00:00:37
The real pain with reflashing firmwares is that you need another keyboard to do it, because once you put the board in bootloader mode, you can't type the shell commands. I don't keep a spare keyboard here at home. I work around this by SSH'ing from my laptop, so not a huge deal but still kind of a pain.

Yes, it is not very convenient, but depending on how reliably and fast you can enter the bootloader mode, in linux or os x's terminal you can do
Code: [Select]
sleep 10; <flashing command> which will wait for 10 seconds and then execute the flashing command without any keyboard assistance.
Title: Re: TMK keyboard firmware
Post by: QuiGonJinn on Sun, 02 August 2015, 03:16:58
I have a question, not directly related to programming the microcontroller, but I need your experience. Is there a chance that the atmega32u4(of arduino micro) on my newly made keyboard ,gets overheated so it stops working?

After finishing the build today (and flashing of a gh60 code modification), it worked for 4 hours straight, and then it stopped working. I was getting some kernel messages about the device not accepting address(76 and 78 etc) and continuous connects and disconnects of the device. After leaving the keyboard in front of a fan to cool, and now using it with a fan on it, it's working fine. Mind, the temperature in my room was at 35°C a couple of hours ago. The mictocontroller is glued with hot silicon glue on the plastic case, but in my understanding, it is supposed to help conduct the heat to the case except for keeping it steady.

Was this previously working without issue before you reflashed it?

I did not reflash the firmware. It just stopped responding and worked again without me touching anything. It has now been working again for 3 hours without any issues.

Okay, sorry, I misunderstood. So you just finished building a new keyboard running on an Arduino Micro, which you've hot-glued to the case? If you've got the chip covered in hot glue that's your issue. Plastic doesn't conduct heat away. You should have that chip uncovered and facing out. Feel free to hot-glue the chip the other way, that shouldn't be an issue. But keep that chip facing the open air (whatever little there may be inside your keyboard.

The chip may be making contact with the hot glue, it is hard for me to verify unless i take the whole keyboard apart right now, Still, while the hot glue is in contact with the case, by touch I don't feel irregular heat at the spot. I recompiled and flashed the firmware now, if issues come up again, I'll probably try replacing the glue.
Title: Re: TMK keyboard firmware
Post by: henz on Sun, 02 August 2015, 13:56:32
Just added KMAC happy support, made a pull request, and i need someone to test if it still works properly for the tkl models.
Title: Re: TMK keyboard firmware
Post by: njbair on Sun, 02 August 2015, 19:52:41
I have a question, not directly related to programming the microcontroller, but I need your experience. Is there a chance that the atmega32u4(of arduino micro) on my newly made keyboard ,gets overheated so it stops working?

After finishing the build today (and flashing of a gh60 code modification), it worked for 4 hours straight, and then it stopped working. I was getting some kernel messages about the device not accepting address(76 and 78 etc) and continuous connects and disconnects of the device. After leaving the keyboard in front of a fan to cool, and now using it with a fan on it, it's working fine. Mind, the temperature in my room was at 35°C a couple of hours ago. The mictocontroller is glued with hot silicon glue on the plastic case, but in my understanding, it is supposed to help conduct the heat to the case except for keeping it steady.

Was this previously working without issue before you reflashed it?

I did not reflash the firmware. It just stopped responding and worked again without me touching anything. It has now been working again for 3 hours without any issues.

Okay, sorry, I misunderstood. So you just finished building a new keyboard running on an Arduino Micro, which you've hot-glued to the case? If you've got the chip covered in hot glue that's your issue. Plastic doesn't conduct heat away. You should have that chip uncovered and facing out. Feel free to hot-glue the chip the other way, that shouldn't be an issue. But keep that chip facing the open air (whatever little there may be inside your keyboard.

The chip may be making contact with the hot glue, it is hard for me to verify unless i take the whole keyboard apart right now, Still, while the hot glue is in contact with the case, by touch I don't feel irregular heat at the spot. I recompiled and flashed the firmware now, if issues come up again, I'll probably try replacing the glue.

FYI you won't feel a hot spot on the case exterior because plastic is a poor heat conductor.
Title: Re: TMK keyboard firmware
Post by: hasu on Sun, 02 August 2015, 22:21:22
Great job!
This is his pull request.
https://github.com/tmk/tmk_keyboard/pull/237

KMAC happy and TKL users, try his/her branch and report back.
https://github.com/ageaenes/tmk_keyboard/tree/kmac_happy_support



BTW, I'll later create a wiki page and organize links to project using TMK by others. I'm doing refactoring of my codes and I basically won't merge projects contributed by others to my repository anymore. I'd want project owners to maintain their project on their own repository now. Of course, pull requests to core library part are welcomed as they were.
https://github.com/tmk/tmk_keyboard/issues/173


Just added KMAC happy support, made a pull request, and i need someone to test if it still works properly for the tkl models.
Title: Re: TMK keyboard firmware
Post by: henz on Mon, 03 August 2015, 00:34:21
Thanks for the support.


BTW, I'll later create a wiki page and organize links to project using TMK by others. I'm doing refactoring of my codes and I basically won't merge projects contributed by others to my repository anymore. I'd want project owners to maintain their project on their own repository now. Of course, pull requests to core library part are welcomed as they were.
https://github.com/tmk/tmk_keyboard/issues/173


Just added KMAC happy support, made a pull request, and i need someone to test if it still works properly for the tkl models.

Do you think that  this is a good idea? I know its hard to maintain everything yourself, but creating a bunch of subprojects with different owners will kill some layouts, like for instance if a owner decides to go afk.




My opinion:
I like the idea to have everything as it is now, instead making contributors to your project, giving frequent contributors, whos opinions you trust write acess.

Keeping everything as it is+ contributors will increase the sense of community that everyone can chip in.

Title: Re: TMK keyboard firmware
Post by: quantumfractal on Mon, 03 August 2015, 09:34:26
Hey there! I recently built my own 60% keyboard. Your code works excellently, even though I managed to screw up config stuff a few times :p. I have one issue and it's a strange one. My comma key does not work. I've checked to ensure the switch works electrically. And the config seems to be correct in my c files. When I debug the matrix there's nothing showing up. Any ideas why this one key wouldn't be working?

Thanks again!
Title: Re: TMK keyboard firmware
Post by: henz on Mon, 03 August 2015, 09:56:20
Hey there! I recently built my own 60% keyboard. Your code works excellently, even though I managed to screw up config stuff a few times :p. I have one issue and it's a strange one. My comma key does not work. I've checked to ensure the switch works electrically. And the config seems to be correct in my c files. When I debug the matrix there's nothing showing up. Any ideas why this one key wouldn't be working?

Thanks again!

Did you handwire it or is it your own pcb. please post all information you think might be of help like pictures of the wires/pcb(top and bottom) link to code etc.
Title: Re: TMK keyboard firmware
Post by: quantumfractal on Mon, 03 August 2015, 13:31:45
Sorry! I'm at work right now and thought I'd post it at a reasonable time. But yes it's handwired. The pins are setup correctly because everything except that key is working. I'm using a Teensy 2.0. As far as firmware, I'm using the SpaceFN layout and I've checked the matrix and keybind macro in keymap_common.h. I'll post it when I get home, thank you very much for your help!
Title: Re: TMK keyboard firmware
Post by: njbair on Tue, 04 August 2015, 08:00:45
Thanks for the support.


BTW, I'll later create a wiki page and organize links to project using TMK by others. I'm doing refactoring of my codes and I basically won't merge projects contributed by others to my repository anymore. I'd want project owners to maintain their project on their own repository now. Of course, pull requests to core library part are welcomed as they were.
https://github.com/tmk/tmk_keyboard/issues/173


Just added KMAC happy support, made a pull request, and i need someone to test if it still works properly for the tkl models.

Do you think that  this is a good idea? I know its hard to maintain everything yourself, but creating a bunch of subprojects with different owners will kill some layouts, like for instance if a owner decides to go afk.




My opinion:
I like the idea to have everything as it is now, instead making contributors to your project, giving frequent contributors, whos opinions you trust write acess.

Keeping everything as it is+ contributors will increase the sense of community that everyone can chip in.

The issue is kind of two-fold, though. It's not just about the maintenance, but the scope of the whole project. Let's say I try to contribute a layout for a custom board I wired up and there are only 3 in existence. It doesn't make sense for that to be in the central repo, but rather a fork maintained by me and the other 2 who own that board.

Forks can still pull in code from the parent project, so you don't really have to worry about fragmentation in that sense...but at a certain point hasu has to decide what is and isn't worth his time.
Title: Re: TMK keyboard firmware
Post by: quantumfractal on Tue, 04 August 2015, 08:07:09
Hey there! I recently built my own 60% keyboard. Your code works excellently, even though I managed to screw up config stuff a few times :p. I have one issue and it's a strange one. My comma key does not work. I've checked to ensure the switch works electrically. And the config seems to be correct in my c files. When I debug the matrix there's nothing showing up. Any ideas why this one key wouldn't be working?

Thanks again!

Did you handwire it or is it your own pcb. please post all information you think might be of help like pictures of the wires/pcb(top and bottom) link to code etc.


Hey there again, here's a link to the files I'm using to build it (the one's I've modified) https://www.dropbox.com/sh/k5bz49kqs1ga6nv/AABS8VV23DH0jZGdl6r18Z0Qa?dl=0 (https://www.dropbox.com/sh/k5bz49kqs1ga6nv/AABS8VV23DH0jZGdl6r18Z0Qa?dl=0)

And here's a picture of the wiring and of one with the comma key pointed to.
[attach=1]

[attach=2]
Title: Re: TMK keyboard firmware
Post by: henz on Tue, 04 August 2015, 08:35:03
hehe its the diode, its turned upside down
Title: Re: TMK keyboard firmware
Post by: sethk_ on Tue, 04 August 2015, 08:42:15
hehe its the diode, its turned upside down
Mr. Upside-down :P first the plate and now diode
Title: Re: TMK keyboard firmware
Post by: henz on Tue, 04 August 2015, 08:49:16
hehe its the diode, its turned upside down
Mr. Upside-down :P first the plate and now diode

im trying to figure out a funny anode side on the cathod side joke, but im drawing blanks!
Title: Re: TMK keyboard firmware
Post by: quantumfractal on Tue, 04 August 2015, 15:10:47
hehe its the diode, its turned upside down
Mr. Upside-down :P first the plate and now diode

im trying to figure out a funny anode side on the cathod side joke, but im drawing blanks!

You're f**king kidding me.... I checked EVERYTHING except for the diode fuuuuuuuuuuuu

Thank you guys for your help!
Title: Re: TMK keyboard firmware
Post by: bcg on Wed, 05 August 2015, 00:17:06
Hi hasu

I noticed today that mbed has come to Teensy 3.1 at long last

https://developer.mbed.org/platforms/teensy-3-1/

Seems like some people are having issues but works fine for me:

https://developer.mbed.org/forum/bugs-suggestions/topic/4671/?page=2

Do you think the mbed port of TMK could be made to work with this?  If so, what steps do you think that I would need to do to test this?  I'm not very familiar with mbed... if it is as simple as updating to the latest version of their abstraction libraries I can definitely give that a short.  I'd prefer to use Teensy 3.1 for my next project if possible

(BTW - I made some gluecode for using your firmware with bpiphany's costar controllers... I know TMK is already ported to a couple of his boards but this code should be usable for all of them - https://github.com/bgould/costar_tmk_keyboard)
Title: Re: TMK keyboard firmware
Post by: henz on Wed, 05 August 2015, 04:05:44
hehe its the diode, its turned upside down
Mr. Upside-down :P first the plate and now diode

im trying to figure out a funny anode side on the cathod side joke, but im drawing blanks!

You're f**king kidding me.... I checked EVERYTHING except for the diode fuuuuuuuuuuuu

Thank you guys for your help!

Np dude, hf with your keyboard, post some pics in the gh media.
Title: Re: TMK keyboard firmware
Post by: hasu on Wed, 05 August 2015, 18:33:14
Yes, I think TMK should work with the Teensy3.1 mbed port.
I don't check the latest SDK and TMK includes a bit old mbed SDK around Apr 24(https://github.com/mbedmicro/mbed/commit/7c21ce5110e451856e2574fff0447ad45199f2dd). You may want to update it.

TMK mbed support is not mature nor complete, I didn't decide how abstraction layer should be to support both AVR and mbed. So it is scattered and may be a bit messed up. TMK currently has two projects with mbed platform, keyboard/infinity and converter/ps2_usb. You can see these code for refrence during your development.

You will need to define these files first.

1) Makefile
   See converter/ps2_usb/Makefile.mbed or keyboard/infinity/Makefile.

2) File containing list of source files and linker script depending on MCU
   See core/tool/mbed/lpc1u35_501.mk or keyboard/inifinity/mbed-infinity.mk

3) main.cpp
   See converter/ps2_usb/main.cpp or keyboard/infinity/main.cpp.

I think you can base on infinity project codes to start your project. Because Inifinity is not supported in mbed I had to overwrite some mbed codes and create linker script for Infinity myself. Those files located in keyboard/infinity/mbed-infinity/ directory and you can ignore them if Teensy 3.1 is supported in mbed. You will be able to use mbed's linker script and wont' need to change any mbed code.
     

I don't think I can explain it enough here, feel free to ask :D


Hi hasu

I noticed today that mbed has come to Teensy 3.1 at long last

https://developer.mbed.org/platforms/teensy-3-1/

Seems like some people are having issues but works fine for me:

https://developer.mbed.org/forum/bugs-suggestions/topic/4671/?page=2

Do you think the mbed port of TMK could be made to work with this?  If so, what steps do you think that I would need to do to test this?  I'm not very familiar with mbed... if it is as simple as updating to the latest version of their abstraction libraries I can definitely give that a short.  I'd prefer to use Teensy 3.1 for my next project if possible

(BTW - I made some gluecode for using your firmware with bpiphany's costar controllers... I know TMK is already ported to a couple of his boards but this code should be usable for all of them - https://github.com/bgould/costar_tmk_keyboard)
Title: Re: TMK keyboard firmware
Post by: esplin2966 on Wed, 05 August 2015, 21:00:57
Hey everyone, I have been playing with hasu's controller in my hhkb and it's been awesome. I can make the keys do anything I want, except for one thing:

Is there a way to use a function key in a macro? For example:

I define FN5 to be a toggle to layer 4. I want to create a macro that taps FN5, and then does CTRL+SPACE right after.

What I have found is that nothing happens in the part of the macro that taps FN5, while the CTRL+SPACE part works fine.

Does anyone know how to do what I'm describing?

Title: Re: TMK keyboard firmware
Post by: njbair on Wed, 05 August 2015, 22:22:42
Hey everyone, I have been playing with hasu's controller in my hhkb and it's been awesome. I can make the keys do anything I want, except for one thing:

Is there a way to use a function key in a macro? For example:

I define FN5 to be a toggle to layer 4. I want to create a macro that taps FN5, and then does CTRL+SPACE right after.

What I have found is that nothing happens in the part of the macro that taps FN5, while the CTRL+SPACE part works fine.

Does anyone know how to do what I'm describing?

You don't have to emulate the Fn5 keypress. Just use ACTION_LAYER_ON() in your macro to enable your function layer.

https://github.com/tmk/tmk_keyboard/blob/master/doc/keymap.md#227-turn-on-layer
Title: Re: TMK keyboard firmware
Post by: Charger on Thu, 06 August 2015, 00:22:02
Quick question does tmk detect when a computer is turned off and go into a power saving mode that turns off things like the backlight? I'm wondering because I used that forked tmk with layer indicator LEDs and noticed the layer indicator stays on and I can even change layers to turn it on hand off with the computer off which is something I didn't expect lol.
Title: Re: TMK keyboard firmware
Post by: hasu on Thu, 06 August 2015, 01:30:38
You can't use FN key in your macro definition and you cannot define what you want with current TMK macro unfortunately.

You'll have to define 'action_function()' to realize it but documentation is sparse as always.
https://github.com/tmk/tmk_keyboard/blob/master/doc/keymap.md#24-function-action


Hey everyone, I have been playing with hasu's controller in my hhkb and it's been awesome. I can make the keys do anything I want, except for one thing:

Is there a way to use a function key in a macro? For example:

I define FN5 to be a toggle to layer 4. I want to create a macro that taps FN5, and then does CTRL+SPACE right after.

What I have found is that nothing happens in the part of the macro that taps FN5, while the CTRL+SPACE part works fine.

Does anyone know how to do what I'm describing?


Title: Re: TMK keyboard firmware
Post by: hasu on Thu, 06 August 2015, 01:35:16
Quick answer is maybe no.
You have to implement power saving  for you LEDs.

Quick question does tmk detect when a computer is turned off and go into a power saving mode that turns off things like the backlight? I'm wondering because I used that forked tmk with layer indicator LEDs and noticed the layer indicator stays on and I can even change layers to turn it on hand off with the computer off which is something I didn't expect lol.

Title: Re: TMK keyboard firmware
Post by: esplin2966 on Thu, 06 August 2015, 12:44:44
Ok, no problem. I will figure out action functions. Gives me something to do :)

You can't use FN key in your macro definition and you cannot define what you want with current TMK macro unfortunately.

You'll have to define 'action_function()' to realize it but documentation is sparse as always.
https://github.com/tmk/tmk_keyboard/blob/master/doc/keymap.md#24-function-action


Hey everyone, I have been playing with hasu's controller in my hhkb and it's been awesome. I can make the keys do anything I want, except for one thing:

Is there a way to use a function key in a macro? For example:

I define FN5 to be a toggle to layer 4. I want to create a macro that taps FN5, and then does CTRL+SPACE right after.

What I have found is that nothing happens in the part of the macro that taps FN5, while the CTRL+SPACE part works fine.

Does anyone know how to do what I'm describing?


Title: Re: TMK keyboard firmware
Post by: shaymdev on Thu, 06 August 2015, 16:58:03
...I'm wondering because I used that forked tmk with layer indicator LEDs...

I haven't been able to find a way to handle layer indicator LEDs but would love one on my current build. Can you point me to this fork?

@hasu is there any plan to implement this type of functionality? It seems like it would be appreciated by many.
Title: Re: TMK keyboard firmware
Post by: Charger on Thu, 06 August 2015, 17:22:08
...I'm wondering because I used that forked tmk with layer indicator LEDs...

I haven't been able to find a way to handle layer indicator LEDs but would love one on my current build. Can you point me to this fork?

@hasu is there any plan to implement this type of functionality? It seems like it would be appreciated by many.

hasu pointed me to the fork a page or so back

but here is a direct link to the fork https://github.com/jonhiggs/tmk_keyboard and the link below kind of tells you how to do it with this forked tmk build
 
Probably you can add your code in common/action_layer.c. All layer change actions should be occured in static void default_layer_state_set(uint32_t state). See this PR. https://github.com/tmk/tmk_keyboard/pull/198

Or also you can define action_function() that changes layer and handles indicator at the same time in your keymap file.
Title: Re: TMK keyboard firmware
Post by: ctm on Fri, 07 August 2015, 15:03:11
Is there a way to change mouse key behavior? I prefer to have the cursor move at constant speed when holding down the key, and move faster when double or triple tap on the key.
Title: Re: TMK keyboard firmware
Post by: bcg on Sun, 09 August 2015, 09:55:40
Is there a way to change mouse key behavior? I prefer to have the cursor move at constant speed when holding down the key, and move faster when double or triple tap on the key.

For sure you can change the mousekey constants in your config.h file by adding some #defines to override this constants:

https://github.com/tmk/tmk_keyboard/blob/master/tmk_core/common/mousekey.h#L25-L52

As far as the behavior you're describing, you probably could acheive something like that with an action fuction but it would most likely take a bit of effort to get working just right.

These are the mousekey constants that I use these days and I think they give decent results for both speed and precision:


/* faster mousekeys than the default */
#define MOUSEKEY_MOVE_DELTA           3
#define MOUSEKEY_WHEEL_DELTA          1
#define MOUSEKEY_DELAY                0
#define MOUSEKEY_INTERVAL            20
#define MOUSEKEY_MAX_SPEED           10
#define MOUSEKEY_TIME_TO_MAX         20
#define MOUSEKEY_WHEEL_MAX_SPEED     16
#define MOUSEKEY_WHEEL_TIME_TO_MAX   40
Title: Re: TMK keyboard firmware
Post by: bcg on Sun, 09 August 2015, 10:03:33

I think you can base on infinity project codes to start your project. Because Inifinity is not supported in mbed I had to overwrite some mbed codes and create linker script for Infinity myself. Those files located in keyboard/infinity/mbed-infinity/ directory and you can ignore them if Teensy 3.1 is supported in mbed. You will be able to use mbed's linker script and wont' need to change any mbed code.
     

I don't think I can explain it enough here, feel free to ask :D


Thanks hasu, I think your explanation is good, I will definitely give it a shot.  I forgot about the infinity keyboard, I was actually going to buy one of this but I've been so busy this summer that I knew I would have time to mess with it.  If I knew it was running TMK tho I would have snatched it up in a second :)  I love your firmware, I have it on every keyboard in my house and on my daily at work now now  :thumb:
Title: Re: TMK keyboard firmware
Post by: nephiel on Sun, 09 August 2015, 12:29:15
...I'm wondering because I used that forked tmk with layer indicator LEDs...

I haven't been able to find a way to handle layer indicator LEDs but would love one on my current build. Can you point me to this fork?

@hasu is there any plan to implement this type of functionality? It seems like it would be appreciated by many.

hasu pointed me to the fork a page or so back

but here is a direct link to the fork https://github.com/jonhiggs/tmk_keyboard and the link below kind of tells you how to do it with this forked tmk build
 
Probably you can add your code in common/action_layer.c. All layer change actions should be occured in static void default_layer_state_set(uint32_t state). See this PR. https://github.com/tmk/tmk_keyboard/pull/198

Or also you can define action_function() that changes layer and handles indicator at the same time in your keymap file.

FWIW, here's what I did to get LED layer indicators working on tmk.
More
Edit tmk_core/common/action.c and find this section:
Code: [Select]
#endif
        default:
            break;
    }
}




/*
 * Utilities for actions.
 */

Place this piece of code in there so it ends up like this:
Code: [Select]
#endif
        default:
            break;
    }

#ifndef NO_ACTION_LAYER
    // if this event is a layer action, update the leds
    switch (action.kind.id) {
        case ACT_LAYER:
        #ifndef NO_ACTION_TAPPING
        case ACT_LAYER_TAP:
        case ACT_LAYER_TAP_EXT:
        #endif
            led_set(host_keyboard_leds());
            break;
        default:
            break;
    }
#endif

}

/*
 * Utilities for actions.
 */

Then you can edit led_set function in led.c for your board and use checks like these to decide which LEDs to turn on.
Don't forget to #include action_layer.h in led.c as well.
Code: [Select]

    if (layer_state & (1<<3)) { // layer 3 is active
        // turn LED on here
    } else {
        // turn LED off here
    }

    if (biton32(layer_state) == 4) { // layer 4 is the highest active layer
        // turn LED on here
    } else {
        // turn LED off here
    }


This solution is not as neat as Jon Higgs', but it allows access to both usb_led and layer_state vars in led.c, to change status LEDs depending on which layers are active.
Title: Re: TMK keyboard firmware
Post by: shaymdev on Sun, 09 August 2015, 17:39:01
...I'm wondering because I used that forked tmk with layer indicator LEDs...

I haven't been able to find a way to handle layer indicator LEDs but would love one on my current build. Can you point me to this fork?

@hasu is there any plan to implement this type of functionality? It seems like it would be appreciated by many.

hasu pointed me to the fork a page or so back

but here is a direct link to the fork https://github.com/jonhiggs/tmk_keyboard and the link below kind of tells you how to do it with this forked tmk build
 
Probably you can add your code in common/action_layer.c. All layer change actions should be occured in static void default_layer_state_set(uint32_t state). See this PR. https://github.com/tmk/tmk_keyboard/pull/198

Or also you can define action_function() that changes layer and handles indicator at the same time in your keymap file.

FWIW, here's what I did to get LED layer indicators working on tmk.
More
Edit tmk_core/common/action.c and find this section:
Code: [Select]
#endif
        default:
            break;
    }
}




/*
 * Utilities for actions.
 */

Place this piece of code in there so it ends up like this:
Code: [Select]
#endif
        default:
            break;
    }

#ifndef NO_ACTION_LAYER
    // if this event is a layer action, update the leds
    switch (action.kind.id) {
        case ACT_LAYER:
        #ifndef NO_ACTION_TAPPING
        case ACT_LAYER_TAP:
        case ACT_LAYER_TAP_EXT:
        #endif
            led_set(host_keyboard_leds());
            break;
        default:
            break;
    }
#endif

}

/*
 * Utilities for actions.
 */

Then you can edit led_set function in led.c for your board and use checks like these to decide which LEDs to turn on.
Don't forget to #include action_layer.h in led.c as well.
Code: [Select]

    if (layer_state & (1<<3)) { // layer 3 is active
        // turn LED on here
    } else {
        // turn LED off here
    }

    if (biton32(layer_state) == 4) { // layer 4 is the highest active layer
        // turn LED on here
    } else {
        // turn LED off here
    }


This solution is not as neat as Jon Higgs', but it allows access to both usb_led and layer_state vars in led.c, to change status LEDs depending on which layers are active.
Awesome, I'll have to try that out too when I get a chance. Thanks for the code examples.
Title: your ALPS board -- can't compile
Post by: AKmalamute on Mon, 10 August 2015, 01:56:40
 Just downloaded the latest TMK .zip from GitHub, have programmed a keymap file for the alps64 board ... when when I say to 'make' it, I get these errors:

Code: [Select]
../../tmk_core/protocol/lufa/lufa.c: warning: implicit declaration of function clock_prescale_set
../../tmk_core/protocol/lufa/lufa.c: error: clock_div_1 undeclared

and looking at lufa.c, I find this sequence:


Code: [Select]
static void setup_mcu(void)
{
    /* Disable watchdog if enabled by bootloader/fuses */
    MCUSR &= ~(1 << WDRF);
    wdt_disable();

    /* Disable clock division */
    clock_prescale_set(clock_div_1);
}


Which is the only place that clock_div_1 shows up at all ... and I think I'm at a loss at this point.

edit: Going into another directory (kmac in this case) and issuing : make -f Makefile.lufa produces files, not errors. But both of the other keymap files in the alps64 directory yield the same error about setup_mcu.

DoubleEdit: if I arbitrarily set the MCU in the makefile to be the ever popular 32u4, it compiles fine.
But that's not what's on this board, I assume, so ...?
Title: Re: your ALPS board -- can't compile
Post by: nephiel on Mon, 10 August 2015, 14:13:14
Just downloaded the latest TMK .zip from GitHub, have programmed a keymap file for the alps64 board ... when when I say to 'make' it, I get these errors:

Code: [Select]
../../tmk_core/protocol/lufa/lufa.c: warning: implicit declaration of function clock_prescale_set
../../tmk_core/protocol/lufa/lufa.c: error: clock_div_1 undeclared

and looking at lufa.c, I find this sequence:


Code: [Select]
static void setup_mcu(void)
{
    /* Disable watchdog if enabled by bootloader/fuses */
    MCUSR &= ~(1 << WDRF);
    wdt_disable();

    /* Disable clock division */
    clock_prescale_set(clock_div_1);
}


Which is the only place that clock_div_1 shows up at all ... and I think I'm at a loss at this point.

edit: Going into another directory (kmac in this case) and issuing : make -f Makefile.lufa produces files, not errors. But both of the other keymap files in the alps64 directory yield the same error about setup_mcu.

DoubleEdit: if I arbitrarily set the MCU in the makefile to be the ever popular 32u4, it compiles fine.
But that's not what's on this board, I assume, so ...?

I just checked latest TMK .zip, alps64 makefile has MCU set to atmega32u4 by default. Gah, nevermind, evidently I can't read digits. See hasu's post below.
Title: Re: TMK keyboard firmware
Post by: hasu on Mon, 10 August 2015, 19:00:09
Alps64 PCB has "u2" microcontroller on board so you should compiled with atmega32u2 and default Makefile is configured correctly.

AKmalamute, it seems like your AVR libc is too old to build firmware for the controller. Try update to the latest one.
Title: Re: TMK keyboard firmware
Post by: ctm on Mon, 10 August 2015, 21:19:26
Is there a way to change mouse key behavior? I prefer to have the cursor move at constant speed when holding down the key, and move faster when double or triple tap on the key.

For sure you can change the mousekey constants in your config.h file by adding some #defines to override this constants:

https://github.com/tmk/tmk_keyboard/blob/master/tmk_core/common/mousekey.h#L25-L52

As far as the behavior you're describing, you probably could acheive something like that with an action fuction but it would most likely take a bit of effort to get working just right.

These are the mousekey constants that I use these days and I think they give decent results for both speed and precision:


/* faster mousekeys than the default */
#define MOUSEKEY_MOVE_DELTA           3
#define MOUSEKEY_WHEEL_DELTA          1
#define MOUSEKEY_DELAY                0
#define MOUSEKEY_INTERVAL            20
#define MOUSEKEY_MAX_SPEED           10
#define MOUSEKEY_TIME_TO_MAX         20
#define MOUSEKEY_WHEEL_MAX_SPEED     16
#define MOUSEKEY_WHEEL_TIME_TO_MAX   40

Thank you for sharing! This config works great! BTW I am also a Vim user  ;D
Title: Re: TMK keyboard firmware
Post by: njbair on Mon, 10 August 2015, 21:57:12
Is Boot Magic supposed to work on the Infinity? When I comment out BOOTMAGIC_ENABLE = yes, I get the following error while running make clean:

Code: [Select]
../../tmk_core/tool/mbed/common.mk:28: *** Not Supported.  Stop.
Any ideas?
Title: Re: TMK keyboard firmware
Post by: AKmalamute on Mon, 10 August 2015, 22:07:26
AKmalamute, it seems like your AVR libc is too old to build firmware for the controller. Try update to the latest one.

It hasn't updated since 2010. That's the one I have.

 Does this leave me SOL ?
Title: Re: TMK keyboard firmware
Post by: AKmalamute on Tue, 11 August 2015, 00:33:58
It hasn't updated since 2010.

okay, that's just the complete windows installer. If you don't mind jumping through atmel's hoops, you can get the windows toolchain. But whatever I d/l'd doesn't have make.exe so I'm using old & new at once. But the toolchain should be avr-gcc 3.4.5 or the like.

 Next step was a buncha reboots because I've never attached a 32u2 to my system and every time I'd plug my ergodox back in, none of the keys would do anything sensible. Got ahold of a open-source libUSB .inf generator, and ... tried to use teensy.exe. Oops.

Installed Flip, it actually wrote something this time (had mediocre to poor success last time I had to play with that program) and ... my new keyboard doesn't work.

I'm going to bed so it'll be a day before we can talk about what I screwed up, but I've defined three FN keys, all on the default layer. One is supposed to go to the next layer with F-keys, navigation, etc. One is a dual-function Fn0 / enter key ... the last has some more experimental stuff like mouse controls.

 The mouse controls layer is determined to be default. I don't have a way to switch out because it's not supposed to come up except as a momentary switch off a key in the actual default layer. But the few TRNS keys are going to the letter row, so I get a few numbers about that's close to it.

 Grr ... why did I start doing this, again?
Title: Re: TMK keyboard firmware
Post by: hasu on Tue, 11 August 2015, 05:30:29
Is Boot Magic supposed to work on the Infinity? When I comment out BOOTMAGIC_ENABLE = yes, I get the following error while running make clean:

Code: [Select]
../../tmk_core/tool/mbed/common.mk:28: *** Not Supported.  Stop.
Any ideas?
Not supported atm.
Cortex/mbed port is still on preliminary stage, media keys, mouse keys and etc. ain't  supported also.

But I hope I can take time to implement those functions before so long. Or if  someone can contribute it would be great.

Title: Re: TMK keyboard firmware
Post by: hasu on Tue, 11 August 2015, 05:45:01
Is there a way to change mouse key behavior? I prefer to have the cursor move at constant speed when holding down the key, and move faster when double or triple tap on the key.

For sure you can change the mousekey constants in your config.h file by adding some #defines to override this constants:

https://github.com/tmk/tmk_keyboard/blob/master/tmk_core/common/mousekey.h#L25-L52

As far as the behavior you're describing, you probably could acheive something like that with an action fuction but it would most likely take a bit of effort to get working just right.

These are the mousekey constants that I use these days and I think they give decent results for both speed and precision:


/* faster mousekeys than the default */
#define MOUSEKEY_MOVE_DELTA           3
#define MOUSEKEY_WHEEL_DELTA          1
#define MOUSEKEY_DELAY                0
#define MOUSEKEY_INTERVAL            20
#define MOUSEKEY_MAX_SPEED           10
#define MOUSEKEY_TIME_TO_MAX         20
#define MOUSEKEY_WHEEL_MAX_SPEED     16
#define MOUSEKEY_WHEEL_TIME_TO_MAX   40

Thank you for sharing! This config works great! BTW I am also a Vim user  ;D
And you may be able to use keycodes KC_MS_ACCEL0,1,2. Those keys provides fixed speed of mouse cursor during they are hold down. This is not exactly what you want though.
Title: Re: TMK keyboard firmware
Post by: njbair on Tue, 11 August 2015, 09:06:03
Is Boot Magic supposed to work on the Infinity? When I comment out BOOTMAGIC_ENABLE = yes, I get the following error while running make clean:

Code: [Select]
../../tmk_core/tool/mbed/common.mk:28: *** Not Supported.  Stop.
Any ideas?
Not supported atm.
Cortex/mbed port is still on preliminary stage, media keys, mouse keys and etc. ain't  supported also.

But I hope I can take time to implement those functions before so long. Or if  someone can contribute it would be great.

Got it. I actually noticed media keys not working on my Infinities but I hadn't gotten around to asking about it.

At least it's nice to know that these things are possible, just not done yet. I wish I knew enough about ARM to help out...
Title: Re: TMK keyboard firmware
Post by: nomaded on Tue, 11 August 2015, 11:47:11

 Next step was a buncha reboots because I've never attached a 32u2 to my system and every time I'd plug my ergodox back in, none of the keys would do anything sensible. Got ahold of a open-source libUSB .inf generator, and ... tried to use teensy.exe. Oops.

I'm going to bed so it'll be a day before we can talk about what I screwed up, but I've defined three FN keys, all on the default layer. One is supposed to go to the next layer with F-keys, navigation, etc. One is a dual-function Fn0 / enter key ... the last has some more experimental stuff like mouse controls.

 The mouse controls layer is determined to be default. I don't have a way to switch out because it's not supposed to come up except as a momentary switch off a key in the actual default layer. But the few TRNS keys are going to the letter row, so I get a few numbers about that's close to it.

 Grr ... why did I start doing this, again?

Can you post your keymap.c/keymap.h file?

Last week, I finally got around to installing Cub-uanic's port to my ErgoDox. I got the layout and layers to be the same as what I had with Ben Blazak's firmware, including hitting both shifts to toggle capslock and using the right-hand LEDs to indicate my layers.

I've been messing around with how I want to arrange mouse keys on the left hand, but I haven't come up with a layout I'm 100% happy with, yet.
Title: Re: TMK keyboard firmware
Post by: ambergrismonger on Fri, 14 August 2015, 15:30:18
Hello! I just finished wiring a Quark and now I'm trying to compile my firmware to flash to the teensy but I keep getting the error:

Quote
keymap_poker.c:13:55: error: macro "KEYMAP" passed 45 arguments, but takes just 44
keymap_poker.c:10: error: expected '}' before 'KEYMAP'
make: *** [obj_gh60_lufa/keymap_poker.o] Error 1

Here is the keymap file:

Quote
#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,   
  FN1,   LSFT,   Z,   X,   C,   V,   B,   N,   M,   COMM,   DOT,   LSFT,   
  LCTL,   LALT,   PAUSE,   FN2,   SPC,   FN1,   COPY,   PASTE,   UNDO)
/* 1: FN 1 */
  KEYMAP(TRNS,   1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   DEL,   
  TRNS,   VOLUP,   VOLDOWN,   MUTE,   TRNS,   LBRC,   RBRC,   BSLS,   MINS,   EQL,   TRNS,   
  TRNS,   TRNS,   TRNS,   TRNS,   TRNS,   GRAVE,   SCLN,   QUOT,   SLSH,   HOME,   PGUP,   TRNS,   
  TRNS,   TRNS,   TRNS,   TRNS,   TRNS,   TRNS,   END,   PGDN,   TRNS,)
/* 2: FN 2 */
  KEYMAP(TRNS,   F1,   F2,   F3,   F4,   F5,   F6,   F7,   F8,   F9,   F0,   TRNS,   
  TRNS,   TRNS,   TRNS,   TRNS,   TRNS,   TRNS,   TRNS,   TRNS,   TRNS,   TRNS,   TRNS,   
  TRNS,   TRNS,   TRNS,   TRNS,   TRNS,   TRNS,   TRNS,   TRNS,   TRNS,   TRNS,   UP,   TRNS,   
  TRNS,   LGUI,   TRNS,   TRNS,   TRNS,   TRNS,   LEFT,   DOWN,   RGHT)
};
 
const uint16_t PROGMEM fn_actions[] = {
 
  • = ACTION_LAYER_MOMENTARY(1),

};


And here is the keymap_common:

Quote
/* GH60 keymap definition macro
 * K2C, K31 and  K3C are extra keys for ISO
 */
#define KEYMAP( \
    K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, \
    K10, K11, K12, K13, K14, K15, K16,      K18, K19, K1A, K1B, \
    K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, \
    K30, K31, K32,      K34, K35,           K38, K39, K3A, K3B \
) { \
    { 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_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_NO, KC_##K18, KC_##K19, KC_##K1A, KC_##K1B }, \
    { 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_##K30, KC_##K31, KC_##K32, KC_NO, KC_##K34, KC_##K35, KC_NO, KC_NO, KC_##K38, KC_##K39, KC_##K3A, KC_##K3B }, \
}

Any help would be much appreciated!
Title: Re: TMK keyboard firmware
Post by: a-c on Fri, 14 August 2015, 15:35:47
Are you missing K17? That row only has 11 but should have 12.

hmmm. That's not it.

Fn1 bottom row last TRNS has an extra , at the end.
Title: Re: TMK keyboard firmware
Post by: ambergrismonger on Fri, 14 August 2015, 15:50:32
Ah, thanks!

Now I'm getting this error: