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. Not a valid vimeo URL
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:

Quote
keymap_poker.c:10: error: expected '}' before '{' token
make: *** [obj_gh60_lufa/keymap_poker.o] Error 1
Title: Re: TMK keyboard firmware
Post by: ambergrismonger on Fri, 14 August 2015, 18:16:00
I figured it out! There were supposed to be comma's after each (...) on the poker_keymap. Time to flash, cross your fingers for me!
Title: Re: TMK keyboard firmware
Post by: ambergrismonger on Fri, 14 August 2015, 18:50:19
So, I flashed the firmware and the keyboard goes crazy firing random keys and freaking out in general. Here are all of the files that I edited. Thanks for any help!

https://gist.github.com/ambergrismonger/786fdb884f068cc09a1b (https://gist.github.com/ambergrismonger/786fdb884f068cc09a1b)
Title: Re: TMK keyboard firmware
Post by: a-c on Fri, 14 August 2015, 21:01:11
So, I flashed the firmware and the keyboard goes crazy firing random keys and freaking out in general. Here are all of the files that I edited. Thanks for any help!

https://gist.github.com/ambergrismonger/786fdb884f068cc09a1b (https://gist.github.com/ambergrismonger/786fdb884f068cc09a1b)

Missing D5 and D6 in your col port setup.

Ooops D5 and D4.
Title: Re: TMK keyboard firmware
Post by: njbair on Fri, 14 August 2015, 21:26: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?
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.

As someone with a strong programming background but no experience with ARM, where should I start reading if I want to help with mbed support?
Title: Re: TMK keyboard firmware
Post by: ambergrismonger on Sat, 15 August 2015, 14:06:47
Thank you so much for catching that a-c! The keyboard works now! But I am having an issue with the FN keypresses not registering correctly. When I press the FN1 key it registers as an 8 keypress and when I press FN2 it registers as g. Any idea what's going on here? Everything else seems to be firing right.
Title: Re: TMK keyboard firmware
Post by: a-c on Sat, 15 August 2015, 14:52:01
Thank you so much for catching that a-c! The keyboard works now! But I am having an issue with the FN keypresses not registering correctly. When I press the FN1 key it registers as an 8 keypress and when I press FN2 it registers as g. Any idea what's going on here? Everything else seems to be firing right.

You don't have your FN actions defined. Starts at 0 so FN1 and FN2 don't have a defined action.
Code: [Select]
const uint16_t PROGMEM fn_actions[] = {
  [0] = ACTION_LAYER_MOMENTARY(1),
};

Code: [Select]
const uint16_t PROGMEM fn_actions[] = {
  [1] = ACTION_LAYER_MOMENTARY(1),
  [2] = ACTION_LAYER_MOMENTARY(2),
};
Title: Re: TMK keyboard firmware
Post by: ambergrismonger on Sat, 15 August 2015, 16:08:24
Thank you! One last thing and I think my keyboard will be perfect! Is there a way to bind multiple key presses to one key? For example say I want a key to execute ctrl+C?
Title: Re: TMK keyboard firmware
Post by: a-c on Sat, 15 August 2015, 17:56:48
Thank you! One last thing and I think my keyboard will be perfect! Is there a way to bind multiple key presses to one key? For example say I want a key to execute ctrl+C?

https://github.com/tmk/tmk_keyboard/blob/master/doc/keymap.md

In section 2.1.2
Code: [Select]
const uint16_t PROGMEM fn_actions[] = {
  [1] = ACTION_LAYER_MOMENTARY(1),
  [2] = ACTION_LAYER_MOMENTARY(2),
  [3] = ACTION_MODS_KEY(MOD_LCTL, C),
};

Assign Fn3 to a key and it will execute.
Title: Re: TMK keyboard firmware
Post by: U47 on Sun, 16 August 2015, 00:55:34
As someone with a strong programming background but no experience with ARM, where should I start reading if I want to help with mbed support?

I would say jump in the pool (https://github.com/tmk/tmk_keyboard/tree/master/keyboard/infinity), but mbed is a mess right now (https://github.com/tmk/tmk_keyboard/issues/212) (it won't compile on a Mac at the moment).

I'm kinda in the same boat. Feel I could help out, but I just don't have the patience to spend nights getting a dev environment working.
Title: Re: TMK keyboard firmware
Post by: AKmalamute on Sun, 16 August 2015, 02:22:36
Can you post your keymap.c/keymap.h file?

Yeah;  now that I'm at a computer, and in particular my computer has been upgraded & reassembled, here you go:
http://pastebin.com/cewgDXka  That's the keymap file, where I'm surely making some silly mistake,
http://pastebin.com/84FjhZxB  And the keymap.h file I haven't needed to do anything with.

Quote from: nomaded
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.

Of the ergodox, I haven't gotten around to writing up something for TMK directly; I'm still using MD's web page.
Here (https://keyboard-configurator.massdrop.com/ext/ergodox/?referer=A3SE32&hash=16b7c21c11b602251d2930577c9ff6f7) is what I'm typing on now, but since I find the keys on the bottom row are all but inaccessible, I'm part way through making this other thing (https://keyboard-configurator.massdrop.com/ext/ergodox/?referer=A3SE32&hash=53d75ba848e72ecca623d55c44346f80) but have yet to try it.
Title: Re: TMK keyboard firmware
Post by: KHAANNN on Sun, 16 August 2015, 06:33:50
Hi everyone

I'm looking for the most-solid 60% PCB to use with tmk_keyboard, leds not needed, a flat front-surface should be nice (for 5mm plates)

I was going to get a Nerd60, but I read that the bootloader is not compatible with dfu-util on default, I was considering a winkeyless.kr PCB, but I'm not sure where compatibility is at

Long story short, I would appreciate some buying advice (currently using the infinity PCB, it's ARM, not solid for several reasons, both electronical and physical, another massdrop fiasco, that's why I'm looking for something solid, a proven AVR PCB without any production issues would be great)
Title: Re: TMK keyboard firmware
Post by: njbair on Sun, 16 August 2015, 07:16:54
Hi everyone

I'm looking for the most-solid 60% PCB to use with tmk_keyboard, leds not needed, a flat front-surface should be nice (for 5mm plates)

I was going to get a Nerd60, but I read that the bootloader is not compatible with dfu-util on default, I was considering a winkeyless.kr PCB, but I'm not sure where compatibility is at

Long story short, I would appreciate some buying advice (currently using the infinity PCB, it's ARM, not solid for several reasons, both electronical and physical, another massdrop fiasco, that's why I'm looking for something solid, a proven AVR PCB without any production issues would be great)

You and me both, man. There's always the option to program a very basic 60% single-layer layout, then use hasu's USB to USB converter (https://geekhack.org/index.php?topic=69169.0). I just bought one from hasu last week (just arrived in U.S. customs on Friday), and I think I'm going to configure all my Fn keys and layering via the converter.

If hasu doesn't have any converters in stock, you can build your own with an Arduino and a USB host shield.
Title: Re: TMK keyboard firmware
Post by: KHAANNN on Sun, 16 August 2015, 07:44:05
Hi everyone

I'm looking for the most-solid 60% PCB to use with tmk_keyboard, leds not needed, a flat front-surface should be nice (for 5mm plates)

I was going to get a Nerd60, but I read that the bootloader is not compatible with dfu-util on default, I was considering a winkeyless.kr PCB, but I'm not sure where compatibility is at

Long story short, I would appreciate some buying advice (currently using the infinity PCB, it's ARM, not solid for several reasons, both electronical and physical, another massdrop fiasco, that's why I'm looking for something solid, a proven AVR PCB without any production issues would be great)

You and me both, man. There's always the option to program a very basic 60% single-layer layout, then use hasu's USB to USB converter (https://geekhack.org/index.php?topic=69169.0). I just bought one from hasu last week (just arrived in U.S. customs on Friday), and I think I'm going to configure all my Fn keys and layering via the converter.

If hasu doesn't have any converters in stock, you can build your own with an Arduino and a USB host shield.

This is a genius device, I remember looking for it some months ago, it didn't exist back then, it could have prevented me from seeking custom keyboards and layouts :)

However, currently I'm trying to build this: http://www.keyboard-layout-editor.com/#/gists/56cebe0eff4d8931c305 - so one way or another I'm going to get a 60% PCB, might as well get one that natively supports tmk_keyboard out of the box

Asked the winkeyless.kr guys recently, they seem to have new 60% PCB's, but since they use the ps2toavr framework, I'm unsure whether their pcb is practically compatible with tmk_keyboard

(Edit: I will buy that USBtoUSB converter anyway, just in case, If It's in stock, it would be nice to have around :)
(Edit 2: winkeyless.kr pcb's are not compatible as I'm told)
(Edit 3: would appreciate Nerd bootloader advice too, it seems simpler to just get a nerd and solve the bootloader challenge)
Title: Re: TMK keyboard firmware
Post by: KHAANNN on Sun, 16 August 2015, 09:47:15
Hi everyone

I'm looking for the most-solid 60% PCB to use with tmk_keyboard, leds not needed, a flat front-surface should be nice (for 5mm plates)

I was going to get a Nerd60, but I read that the bootloader is not compatible with dfu-util on default, I was considering a winkeyless.kr PCB, but I'm not sure where compatibility is at

Long story short, I would appreciate some buying advice (currently using the infinity PCB, it's ARM, not solid for several reasons, both electronical and physical, another massdrop fiasco, that's why I'm looking for something solid, a proven AVR PCB without any production issues would be great)

You and me both, man. There's always the option to program a very basic 60% single-layer layout, then use hasu's USB to USB converter (https://geekhack.org/index.php?topic=69169.0). I just bought one from hasu last week (just arrived in U.S. customs on Friday), and I think I'm going to configure all my Fn keys and layering via the converter.

If hasu doesn't have any converters in stock, you can build your own with an Arduino and a USB host shield.

I changed my mind, this is MUCH MUCH better than what I was looking for :)

1) There was a hole inside me from my arduino times, as I didn't build anything really useful
2) I was looking for a way to get feedback from the keyboard, maybe from a rgb led, or a speaker

(1)+(2) is possible with this arduino+shield idea, so this is what I will be doing

Thank you for pointing me in the right direction :)

Is it still
https://www.sparkfun.com/products/11286
+
https://www.circuitsathome.com/products-page/arduino-shields/usb-host-shield-2-0-for-arduino-assembled/

for the best possible combination, or is there a better one?
Title: Re: TMK keyboard firmware
Post by: U47 on Sun, 16 August 2015, 12:48:36
Is it still
https://www.sparkfun.com/products/11286
+
https://www.circuitsathome.com/products-page/arduino-shields/usb-host-shield-2-0-for-arduino-assembled/

for the best possible combination, or is there a better one?

I think a Teensy is a better (and cheaper) way to go. Arduinos are a ripoff.
Title: Re: TMK keyboard firmware
Post by: a-c on Sun, 16 August 2015, 13:27:19
Is it still
https://www.sparkfun.com/products/11286
+
https://www.circuitsathome.com/products-page/arduino-shields/usb-host-shield-2-0-for-arduino-assembled/

for the best possible combination, or is there a better one?

I think a Teensy is a better (and cheaper) way to go. Arduinos are a ripoff.

https://www.pjrc.com/teensy/td_libs_USBHostShield.html
Title: Re: TMK keyboard firmware
Post by: njbair on Sun, 16 August 2015, 14:02:13
Hi everyone

I'm looking for the most-solid 60% PCB to use with tmk_keyboard, leds not needed, a flat front-surface should be nice (for 5mm plates)

I was going to get a Nerd60, but I read that the bootloader is not compatible with dfu-util on default, I was considering a winkeyless.kr PCB, but I'm not sure where compatibility is at

Long story short, I would appreciate some buying advice (currently using the infinity PCB, it's ARM, not solid for several reasons, both electronical and physical, another massdrop fiasco, that's why I'm looking for something solid, a proven AVR PCB without any production issues would be great)

You and me both, man. There's always the option to program a very basic 60% single-layer layout, then use hasu's USB to USB converter (https://geekhack.org/index.php?topic=69169.0). I just bought one from hasu last week (just arrived in U.S. customs on Friday), and I think I'm going to configure all my Fn keys and layering via the converter.

If hasu doesn't have any converters in stock, you can build your own with an Arduino and a USB host shield.

I changed my mind, this is MUCH MUCH better than what I was looking for :)

1) There was a hole inside me from my arduino times, as I didn't build anything really useful
2) I was looking for a way to get feedback from the keyboard, maybe from a rgb led, or a speaker

(1)+(2) is possible with this arduino+shield idea, so this is what I will be doing

Thank you for pointing me in the right direction :)

Is it still
https://www.sparkfun.com/products/11286
+
https://www.circuitsathome.com/products-page/arduino-shields/usb-host-shield-2-0-for-arduino-assembled/

for the best possible combination, or is there a better one?

If you dig through the USB-USB converter thread you'll see some folks have used Arduino clones, as well as a few different USB host shields, but clone boards don't have the best reputation, and you of all people, having bought several Infinities, can appreciate the value of knowing the components you're buying are made to spec. So if you're not buying one of hasu's ready-made converters (I think he's out of stock right now), then I would definitely recommend the official board and shield.

EDIT: I might make a full-size Arduino/shield version as well--use it on my desk and keep hasu's bite-sized one in my bag. I like the idea of using LEDs as state indicators for layers and such.
Title: Re: TMK keyboard firmware
Post by: njbair on Sun, 16 August 2015, 14:08:50
This is a genius device, I remember looking for it some months ago, it didn't exist back then, it could have prevented me from seeking custom keyboards and layouts :)

However, currently I'm trying to build this: http://www.keyboard-layout-editor.com/#/gists/56cebe0eff4d8931c305 - so one way or another I'm going to get a 60% PCB, might as well get one that natively supports tmk_keyboard out of the box

Asked the winkeyless.kr guys recently, they seem to have new 60% PCB's, but since they use the ps2toavr framework, I'm unsure whether their pcb is practically compatible with tmk_keyboard

(Edit: I will buy that USBtoUSB converter anyway, just in case, If It's in stock, it would be nice to have around :)
(Edit 2: winkeyless.kr pcb's are not compatible as I'm told)
(Edit 3: would appreciate Nerd bootloader advice too, it seems simpler to just get a nerd and solve the bootloader challenge)

You've got so much invested in the Infinity board, maybe you can modify the PCBs and use the Enabler (http://techkeys.us/collections/accessories/products/the-enabler) for the arrow keys and non-standard layout bits.
Title: Re: TMK keyboard firmware
Post by: hasu on Sun, 16 August 2015, 20:32:18

As someone with a strong programming background but no experience with ARM, where should I start reading if I want to help with mbed support?

First you will have to learn mbed sdk cuz tmk uses it to make firmware available on many platforms as possible.

I started with reading docs on mbed.org and sdk source. Also I often had to check mcu reference manual to understand peripheral functions.

In tmk repository you can locate files supports mbed under core/common/mbed and core/protocol/mbed. Those files includes many empty functions as placeholder and should be implemented to support missing features.

Title: Re: TMK keyboard firmware
Post by: hasu on Sun, 16 August 2015, 20:42:02
As someone with a strong programming background but no experience with ARM, where should I start reading if I want to help with mbed support?

I would say jump in the pool (https://github.com/tmk/tmk_keyboard/tree/master/keyboard/infinity), but mbed is a mess right now (https://github.com/tmk/tmk_keyboard/issues/212) (it won't compile on a Mac at the moment).

I'm kinda in the same boat. Feel I could help out, but I just don't have the patience to spend nights getting a dev environment working.
I think GCC 4.9 is needed to compile tmk with mbed for some reason.

Are you using 4.9? I don't know about how homebrew works but it seems to me like PX4 has some configurations for 4.6, 4.7, 4.8, 4.9 and 4.8 is installed by default.
https://github.com/PX4/homebrew-px4?files=1
Title: Re: TMK keyboard firmware
Post by: KHAANNN on Mon, 17 August 2015, 01:27:26
This is a genius device, I remember looking for it some months ago, it didn't exist back then, it could have prevented me from seeking custom keyboards and layouts :)

However, currently I'm trying to build this: http://www.keyboard-layout-editor.com/#/gists/56cebe0eff4d8931c305 - so one way or another I'm going to get a 60% PCB, might as well get one that natively supports tmk_keyboard out of the box

Asked the winkeyless.kr guys recently, they seem to have new 60% PCB's, but since they use the ps2toavr framework, I'm unsure whether their pcb is practically compatible with tmk_keyboard

(Edit: I will buy that USBtoUSB converter anyway, just in case, If It's in stock, it would be nice to have around :)
(Edit 2: winkeyless.kr pcb's are not compatible as I'm told)
(Edit 3: would appreciate Nerd bootloader advice too, it seems simpler to just get a nerd and solve the bootloader challenge)

You've got so much invested in the Infinity board, maybe you can modify the PCBs and use the Enabler (http://techkeys.us/collections/accessories/products/the-enabler) for the arrow keys and non-standard layout bits.

Indeed It could be useful to extend an 60% PCB to something 60%+, but I just add my non-standard switches to existing spaces on the PCB's by drilling

As someone with a strong programming background but no experience with ARM, where should I start reading if I want to help with mbed support?

I would say jump in the pool (https://github.com/tmk/tmk_keyboard/tree/master/keyboard/infinity), but mbed is a mess right now (https://github.com/tmk/tmk_keyboard/issues/212) (it won't compile on a Mac at the moment).

I'm kinda in the same boat. Feel I could help out, but I just don't have the patience to spend nights getting a dev environment working.
I think GCC 4.9 is needed to compile tmk with mbed for some reason.

Are you using 4.9? I don't know about how homebrew works but it seems to me like PX4 has some configurations for 4.6, 4.7, 4.8, 4.9 and 4.8 is installed by default.
https://github.com/PX4/homebrew-px4?files=1

I tried all OSX pre-compiled binaries, none of them work, I think someone needs to notify launchpad of this issue, since their objective is to make arm development easier (my perception), they should release a fixed binary for osx, similar to what they did for ubuntu/mbed
Title: Re: TMK keyboard firmware
Post by: U47 on Mon, 17 August 2015, 23:05:53
As someone with a strong programming background but no experience with ARM, where should I start reading if I want to help with mbed support?

I would say jump in the pool (https://github.com/tmk/tmk_keyboard/tree/master/keyboard/infinity), but mbed is a mess right now (https://github.com/tmk/tmk_keyboard/issues/212) (it won't compile on a Mac at the moment).

I'm kinda in the same boat. Feel I could help out, but I just don't have the patience to spend nights getting a dev environment working.
I think GCC 4.9 is needed to compile tmk with mbed for some reason.

Are you using 4.9? I don't know about how homebrew works but it seems to me like PX4 has some configurations for 4.6, 4.7, 4.8, 4.9 and 4.8 is installed by default.
https://github.com/PX4/homebrew-px4?files=1

I've tried both 4.8 and 4.9. No luck. When I have some free time, I'll delve further, but I don't think there's an easy solution at the moment.

Seems others have just fired up Linux VPSs and compiled from there. I'm almost at that point.
Title: Re: TMK keyboard firmware
Post by: KHAANNN on Tue, 18 August 2015, 02:36:02
I recently came across this PCB: https://mechanicalkeyboards.com/shop/index.php?l=product_detail&p=1352 (exciting)

It's very similar to the winkeyless.kr PCB's, I don't know what the difference is

I'm guessing this is also incompatible with tmk_keyboard?

the winkeyless.kr PCB's use atmega32a instead of the usual atmega32u4 - that's their source of incompatibility it seems
Title: Re: TMK keyboard firmware
Post by: flabbergast on Tue, 18 August 2015, 02:47:44
I recently came across this PCB: https://mechanicalkeyboards.com/shop/index.php?l=product_detail&p=1352 (exciting)

It's very similar to the winkeyless.kr PCB's, I don't know what the difference is

I'm guessing this is also incompatible with tmk_keyboard?

the winkeyless.kr PCB's use atmega32a instead of the usual atmega32u4 - that's their source of incompatibility it seems
SPRiT's PCBs also use atmega32a + vusb library (no native USB support in the controller, it is bit-banged). SPRiT's and winkeyless PCBs are pretty much the same, the only difference is that winkeyless has support for bottom-side RGB LEDs and strips, while SPRiT's has no bottom-side LED support.

They both run more-less the same firmware (ps2avrU - or ps2avrGB for the RGB stuff) and use the same flash configurator for layouts. This is the only firmware I know of that runs on these boards. There are some sources on github, but I don't know if those are updated by any of the korean guys, so they may be out of date.
Title: Re: TMK keyboard firmware
Post by: KHAANNN on Tue, 18 August 2015, 03:34:21
I recently came across this PCB: https://mechanicalkeyboards.com/shop/index.php?l=product_detail&p=1352 (exciting)

It's very similar to the winkeyless.kr PCB's, I don't know what the difference is

I'm guessing this is also incompatible with tmk_keyboard?

the winkeyless.kr PCB's use atmega32a instead of the usual atmega32u4 - that's their source of incompatibility it seems
SPRiT's PCBs also use atmega32a + vusb library (no native USB support in the controller, it is bit-banged). SPRiT's and winkeyless PCBs are pretty much the same, the only difference is that winkeyless has support for bottom-side RGB LEDs and strips, while SPRiT's has no bottom-side LED support.

They both run more-less the same firmware (ps2avrU - or ps2avrGB for the RGB stuff) and use the same flash configurator for layouts. This is the only firmware I know of that runs on these boards. There are some sources on github, but I don't know if those are updated by any of the korean guys, so they may be out of date.

That's extremely informative, thank you

I'm mainly considering them to sit behind the USB+USB converter method of tmk, but just wanted to ask whether there is work done to adapt them natively to tmk_keyboard
Title: Re: TMK keyboard firmware
Post by: flabbergast on Tue, 18 August 2015, 03:42:54
I'm mainly considering them to sit behind the USB+USB converter method of tmk, but just wanted to ask whether there is work done to adapt them natively to tmk_keyboard
There is some vusb support in TMK, but AFAIK hasu is not working on that anymore, and it was originally intended for a couple of small boards (ps2_usb and onekey).

(Plug: I have a spare atmega32u4 based Chinese 60% PCB: https://geekhack.org/index.php?topic=73453 )
Title: Re: TMK keyboard firmware
Post by: a-c on Tue, 18 August 2015, 13:03:17
I recently came across this PCB: https://mechanicalkeyboards.com/shop/index.php?l=product_detail&p=1352 (exciting)

It's very similar to the winkeyless.kr PCB's, I don't know what the difference is

I'm guessing this is also incompatible with tmk_keyboard?

the winkeyless.kr PCB's use atmega32a instead of the usual atmega32u4 - that's their source of incompatibility it seems
SPRiT's PCBs also use atmega32a + vusb library (no native USB support in the controller, it is bit-banged). SPRiT's and winkeyless PCBs are pretty much the same, the only difference is that winkeyless has support for bottom-side RGB LEDs and strips, while SPRiT's has no bottom-side LED support.

They both run more-less the same firmware (ps2avrU - or ps2avrGB for the RGB stuff) and use the same flash configurator for layouts. This is the only firmware I know of that runs on these boards. There are some sources on github, but I don't know if those are updated by any of the korean guys, so they may be out of date.

That's extremely informative, thank you

I'm mainly considering them to sit behind the USB+USB converter method of tmk, but just wanted to ask whether there is work done to adapt them natively to tmk_keyboard

These boards also do PS2. PS2 is easier to interface with than USB. No need for a USB Host shield.
http://playground.arduino.cc/Main/PS2Keyboard
Title: Re: TMK keyboard firmware
Post by: KHAANNN on Tue, 18 August 2015, 13:39:14
These boards also do PS2. PS2 is easier to interface with than USB. No need for a USB Host shield.
http://playground.arduino.cc/Main/PS2Keyboard

Interesting, how do they output PS2, do you utilise connections of the existing USB connection in this case, or manually wire an arduino to the keyboard?

In any case, a USB shield seems simpler (USB to USB board of hasu is obviously much much simpler, but it's out of stock as njbair mentioned, If anyone is selling one, I'm interested (very interested))

Title: Re: TMK keyboard firmware
Post by: njbair on Tue, 18 August 2015, 14:15:12
These boards also do PS2. PS2 is easier to interface with than USB. No need for a USB Host shield.
http://playground.arduino.cc/Main/PS2Keyboard

Interesting, how do they output PS2, do you utilise connections of the existing USB connection in this case, or manually wire an arduino to the keyboard?

In any case, a USB shield seems simpler (USB to USB board of hasu is obviously much much simpler, but it's out of stock as njbair mentioned, If anyone is selling one, I'm interested (very interested))

Now I'm curious, hasu also makes a PS/2 to USB converter (https://geekhack.org/index.php?topic=14618.0). I wonder if that would work with a USB keyboard and one of these:

(https://upload.wikimedia.org/wikipedia/commons/5/57/USB_to_PS2_mouse_adapter.jpg)
Title: Re: TMK keyboard firmware
Post by: a-c on Tue, 18 August 2015, 14:59:30
Pinout for those USB to PS2 adapters
USB -> PS2
1 -> +5
2 -> data
3 -> clock
4 -> gnd

Hasu has it all figure out already. You just need a Teensy2.0

https://github.com/tmk/tmk_keyboard/tree/master/converter/ps2_usb
Title: Re: TMK keyboard firmware
Post by: KHAANNN on Wed, 19 August 2015, 05:29:46
Pinout for those USB to PS2 adapters
USB -> PS2
1 -> +5
2 -> data
3 -> clock
4 -> gnd

Hasu has it all figure out already. You just need a Teensy2.0

https://github.com/tmk/tmk_keyboard/tree/master/converter/ps2_usb

So, is it possible to, get a FaceW PCB, put it in PS2 Mode

Connect it via USB to the USB-PS2 - connect the PS2 to a Teensy 2.0, and use Teensy 2.0 with tmk_keyboard to re-write the PS2/NKRO output to NKRO again?
(I'm assuming the USB to PS2 adapter is mostly aesthetical in this case, making it practical to connect the USB to Teensy)

It's extremely hoopy (Edit: or the exact opposite, as it seems)

I have a WASD V2 that supposedly works in PS2 mode, I also have a Teensy that I bought and never used, if this works, I would like to try it, would really appreciate some guidance at this point

It seems awfully simple from: https://github.com/tmk/tmk_keyboard/tree/master/converter/ps2_usb - I just don't know which PS2 pins are Clock, Data, VCC and GND and where to put the optional pull up resistor - but I have the components at hand like I mentioned, and I'm very eager to try it out

Edit: Found the PS2 pins ... :) - At this point the only question is how to apply the pull up resistor
Edit 2: Compiled the ps2 to usb converter at osx, no issues there, got the .hex, what is the AVR way to push it too Teensy 2.0 by the way? (dfu-util/dfu-programmer?)
Edit 3: Found pretty much all the information I need at this point, going to start experimenting soon (pull up resistors to Data and Clock: https://geekhack.org/index.php?topic=17458.0 )
Title: Re: TMK keyboard firmware
Post by: VinnyCordeiro on Wed, 19 August 2015, 08:07:29
Edit: Found the PS2 pins ... :) - At this point the only question is how to apply the pull up resistor
Connect a resistor between the line you want to pull-up and Vcc. Simply that. Just need to know the value, but something between 1k and 10k ohms should be enough.
Title: Re: TMK keyboard firmware
Post by: flabbergast on Wed, 19 August 2015, 08:50:54
Edit 2: Compiled the ps2 to usb converter at osx, no issues there, got the .hex, what is the AVR way to push it too Teensy 2.0 by the way? (dfu-util/dfu-programmer?)
Teensys have a special bootloader written by Paul. There's a command-line utility for uploading: https://www.pjrc.com/teensy/loader_cli.html or also a GUI: https://www.pjrc.com/teensy/loader.html
Title: Re: TMK keyboard firmware
Post by: KHAANNN on Wed, 19 August 2015, 09:05:13
Edit 2: Compiled the ps2 to usb converter at osx, no issues there, got the .hex, what is the AVR way to push it too Teensy 2.0 by the way? (dfu-util/dfu-programmer?)
Teensys have a special bootloader written by Paul. There's a command-line utility for uploading: https://www.pjrc.com/teensy/loader_cli.html or also a GUI: https://www.pjrc.com/teensy/loader.html

Thanks for the pull-up info Vinny, I'm thinking of using a 5K resistor

Off topic, the Teensy pulls 0.03A alone by the way (the infinity PCB was 0.01A, as a minor comparison)

Anyway, thanks so so much flabbergast - I managed to hex with with the cli tool you linked

At this point I only know that it pulls 0.03A, going to wire things soon
Title: Re: TMK keyboard firmware
Post by: mrflow3r on Wed, 19 August 2015, 09:46:52

As someone with a strong programming background but no experience with ARM, where should I start reading if I want to help with mbed support?

First you will have to learn mbed sdk cuz tmk uses it to make firmware available on many platforms as possible.

I started with reading docs on mbed.org and sdk source. Also I often had to check mcu reference manual to understand peripheral functions.

In tmk repository you can locate files supports mbed under core/common/mbed and core/protocol/mbed. Those files includes many empty functions as placeholder and should be implemented to support missing features.



Hasu, may I ask which mbed board you like the most? I am pretty sure you have mentioned it somewhere in the forum, but it's hard to search for it!
Title: Re: TMK keyboard firmware
Post by: flabbergast on Wed, 19 August 2015, 09:56:44
Off topic, the Teensy pulls 0.03A alone by the way (the infinity PCB was 0.01A, as a minor comparison)
30mA sounds too much, these AVR chips should normally run on about 15mA. This can be lowered by turning off some unneeded features (ADC, SPI, I2C, ...) The biggest hogs are of course USB and the 16MHz clock, which can't be turned off if you're using USB... But generally speaking I am running a couple of wireless sensors with atmegas which last about half a year on a coin cell battery (of course the mega sleeps most of the time :)
Title: Re: TMK keyboard firmware
Post by: KHAANNN on Wed, 19 August 2015, 10:16:22
Off topic, the Teensy pulls 0.03A alone by the way (the infinity PCB was 0.01A, as a minor comparison)
30mA sounds too much, these AVR chips should normally run on about 15mA. This can be lowered by turning off some unneeded features (ADC, SPI, I2C, ...) The biggest hogs are of course USB and the 16MHz clock, which can't be turned off if you're using USB... But generally speaking I am running a couple of wireless sensors with atmegas which last about half a year on a coin cell battery (of course the mega sleeps most of the time :)

I have a hunch it might be the PS2 method that's pulling too much ma, because it was initially around 0.01A before the new .hex

Going to test the other methods now: https://github.com/tmk/tmk_keyboard/tree/master/converter/ps2_usb

PS2_USE_BUSYWAIT is default, PS2_USE_INT is recommended, PS2_USE_USART seems native (+ recommended in the Makefile)

I think I'm going to go with the USART, although I have no idea how these methods practically differ, whether any of these methods is capable of errors etc.
Title: Re: TMK keyboard firmware
Post by: a-c on Wed, 19 August 2015, 11:31:17
BUSYWAIT is high CPU usage. It is constantly checking to see if there is incoming data. The interrupt method or UART will use built in hardware triggers so the chip is mostly idle when nothing is incoming.
Title: Re: TMK keyboard firmware
Post by: KHAANNN on Wed, 19 August 2015, 17:41:44
My experiments failed miserably

I couldn't make it work with the WASD V2

On idle, the Teensy pulls 20ma, when connected to the WASD V2 with the adapter njbair posted, it pulls 170-180ma

I have no idea how to continue from here

(https://www.pjrc.com/teensy/pinout2a.png)

My initial mistake was to connect the clock to VCC, as the labelling is extremely misleading, corrected that now, but nothing changed (The WASD V2 functions in USB mode - so it's not one of the things I fried)

Used the USART mode, made sure to clean and re-make, verified the connections from here: https://en.wikipedia.org/wiki/PS/2_port - used 4.7K pull-up resistors

Edit: After getting a good nights sleep, I have a hunch I made a male/female confusion, I probably need to mirror my PS/2 connections ...
Edit 2: Correctly wired, it works great :)
Edit 3: Definitely a great way to add NKRO and programmability to keyboards like WASD V2, or any PS/2 for that matter :) - 0.02/0.03A when correctly wired by the way, power usage doesn't change much with the PS/2 mode
Title: Re: TMK keyboard firmware
Post by: adevriesc on Wed, 19 August 2015, 19:51:02
How do you connect LEDs to a Teensy and associate them with the state of a Caps Lock/Num Lock key? I haven't been able to find explicit information on the process anywhere.
Title: Re: TMK keyboard firmware
Post by: a-c on Wed, 19 August 2015, 20:57:12
How do you connect LEDs to a Teensy and associate them with the state of a Caps Lock/Num Lock key? I haven't been able to find explicit information on the process anywhere.

https://github.com/tmk/tmk_keyboard/blob/master/keyboard/phantom/led.c
Look at the led.c in each of the different keyboards. They do it in different ways.
Title: Re: TMK keyboard firmware
Post by: flabbergast on Thu, 20 August 2015, 02:22:35
How do you connect LEDs to a Teensy and associate them with the state of a Caps Lock/Num Lock key? I haven't been able to find explicit information on the process anywhere.

https://github.com/tmk/tmk_keyboard/blob/master/keyboard/phantom/led.c
Look at the led.c in each of the different keyboards. They do it in different ways.
On the hardware side, you want <Teensy pin> --- <resistor> --- LED --- ground.
(you can do Vcc instead of Ground, or swap the LED and the resistor). For instance, Phantom's led.c assumes that the Caps Lock LED is connected like this with <Teensy pin> being B6. Taking that ping HIGH will light up the led, taking it LOW (or HI-Z) will switch the led off.
Title: Re: TMK keyboard firmware
Post by: nephiel on Thu, 20 August 2015, 07:50:18
You can also use the Teensy built-in LED on PD6 for testing, it's active high IIRC.
Title: Re: TMK keyboard firmware
Post by: AKmalamute on Thu, 20 August 2015, 23:25:44
Can you post your keymap.c/keymap.h file?

Yeah;  now that I'm at a computer, and in particular my computer has been upgraded & reassembled, here you go:
http://pastebin.com/cewgDXka  That's the keymap file, where I'm surely making some silly mistake,
http://pastebin.com/84FjhZxB  And the keymap.h file I haven't needed to do anything with.

 Poked my head in IRC, but nobody familiar with TMK was around. I've looked it over and compared to the presumably working hasu keymap and I can't see why the wrong 'layer' is selected as default. Anyone want to make any suggestions?

 How does the firmware know what 'layer' is default? It's by what order they're written in, right? Should I just shove a "make (0) default again" action key on the bottom layer?

 ...Can somebody remind me of how to do that?

EDIT: I may not be quite as dumb as I feel. Aquakeys test says the left gui key is being held down. Also the right control is more or less being held down (hitting my working keyboard's r-ctrl untoggles the held-down color) and another, rather odd choice, the ] key shows it gets tapped every time I plug the ALPS board in.

 So while the soldering job looks fine, I'd say there are a couple damaged keyswitches in there, and one of them is my FN0 button.

Dang.
Title: Re: TMK keyboard firmware
Post by: hasu on Fri, 21 August 2015, 01:38:42
Hmm, OK.
Then we really need a C++ wizrd with GCC toolchain savvy now :D

After some google searches I got my next random guess :)
From my understandings GCC provides 'libstdc++' as standard library while LLVM clang is developing 'libc++'. TMK can be compiled normally with GCC and libstdc++ on Linux. I guess GCC uses libc++ unintentionally for some reason on Mac and TMK/mbed code are not compatible to libc++.

Do you have libc++ somewhere on you Mac? What if it is uninstalled?
I think Homebrew or Xcode may install the library.

I don't have certain knowledge of GCC and C++, this may be completely wrong.

https://gcc.gnu.org/libstdc++/
http://libcxx.llvm.org/
https://github.com/Homebrew/homebrew/blob/master/share/doc/homebrew/C%2B%2B-Standard-Libraries.md


As someone with a strong programming background but no experience with ARM, where should I start reading if I want to help with mbed support?

I would say jump in the pool (https://github.com/tmk/tmk_keyboard/tree/master/keyboard/infinity), but mbed is a mess right now (https://github.com/tmk/tmk_keyboard/issues/212) (it won't compile on a Mac at the moment).

I'm kinda in the same boat. Feel I could help out, but I just don't have the patience to spend nights getting a dev environment working.
I think GCC 4.9 is needed to compile tmk with mbed for some reason.

Are you using 4.9? I don't know about how homebrew works but it seems to me like PX4 has some configurations for 4.6, 4.7, 4.8, 4.9 and 4.8 is installed by default.
https://github.com/PX4/homebrew-px4?files=1

I've tried both 4.8 and 4.9. No luck. When I have some free time, I'll delve further, but I don't think there's an easy solution at the moment.

Seems others have just fired up Linux VPSs and compiled from there. I'm almost at that point.




As someone with a strong programming background but no experience with ARM, where should I start reading if I want to help with mbed support?

I would say jump in the pool (https://github.com/tmk/tmk_keyboard/tree/master/keyboard/infinity), but mbed is a mess right now (https://github.com/tmk/tmk_keyboard/issues/212) (it won't compile on a Mac at the moment).

I'm kinda in the same boat. Feel I could help out, but I just don't have the patience to spend nights getting a dev environment working.
I think GCC 4.9 is needed to compile tmk with mbed for some reason.

Are you using 4.9? I don't know about how homebrew works but it seems to me like PX4 has some configurations for 4.6, 4.7, 4.8, 4.9 and 4.8 is installed by default.
https://github.com/PX4/homebrew-px4?files=1

I tried all OSX pre-compiled binaries, none of them work, I think someone needs to notify launchpad of this issue, since their objective is to make arm development easier (my perception), they should release a fixed binary for osx, similar to what they did for ubuntu/mbed

Title: Re: TMK keyboard firmware
Post by: hasu on Fri, 21 August 2015, 02:09:36

As someone with a strong programming background but no experience with ARM, where should I start reading if I want to help with mbed support?

First you will have to learn mbed sdk cuz tmk uses it to make firmware available on many platforms as possible.

I started with reading docs on mbed.org and sdk source. Also I often had to check mcu reference manual to understand peripheral functions.

In tmk repository you can locate files supports mbed under core/common/mbed and core/protocol/mbed. Those files includes many empty functions as placeholder and should be implemented to support missing features.



Hasu, may I ask which mbed board you like the most? I am pretty sure you have mentioned it somewhere in the forum, but it's hard to search for it!

I like NXP controllers and respect their effort and work on mbed.org. But I don't know about other vendor's controllers enough for comparison.

I don't like Freescale's coding work of mbed SDK but their FDRM boards are attractive due to OpenSDA. With loading OpenSDA app you can use the board as  Segger J-Link lite compatible debugger.
https://segger.com/opensda.html

Just FYI, Cortex boards I currently have:
https://developer.mbed.org/platforms/TG-LPC11U35-501/
https://developer.mbed.org/platforms/mbed-HRM1017/
FRDM-KL05Z
STM32F3discovery

To be honest I don't have much experience on Cortex. You may want to check this thread, instead.
http://deskthority.net/workshop-f7/alternative-controller-experiments-t8735.html
Title: Re: TMK keyboard firmware
Post by: njbair on Fri, 21 August 2015, 08:18:27
I'm just going to post about an issue I had while configuring a layout, in the hopes that I might save someone else some grief down the road.

Basically, I wanted to make a function layer to switch between some different keyboard layouts (QWERTY, Dvorak, etc.). I chose the Menu key because I never use it. So Menu+Q for QWERTY, Menu+D for Dvorak, Menu+G for my gaming layout, etc. To do this, I had to create a special Fn layer, and by default I used NO for all keys besides Q, D, and G. But when I flashed the firmware, the layout switching didn't work. What's more, the entire keyboard stopped working. I had to unplug it and plug it back in to get it to work. I tried using different keys for Fn, but they all had the same result.

Eventually, I realized that when I configured my switching layer, I set the Fn key to NO. So basically the keyboard was switching to the Fn layer, but never un-switching because the Fn key had been remapped.

So the moral of the story is, always use TRNS for Fn keys.
Title: Re: TMK keyboard firmware
Post by: mrflow3r on Fri, 21 August 2015, 11:55:58

As someone with a strong programming background but no experience with ARM, where should I start reading if I want to help with mbed support?

First you will have to learn mbed sdk cuz tmk uses it to make firmware available on many platforms as possible.

I started with reading docs on mbed.org and sdk source. Also I often had to check mcu reference manual to understand peripheral functions.

In tmk repository you can locate files supports mbed under core/common/mbed and core/protocol/mbed. Those files includes many empty functions as placeholder and should be implemented to support missing features.



Hasu, may I ask which mbed board you like the most? I am pretty sure you have mentioned it somewhere in the forum, but it's hard to search for it!

I like NXP controllers and respect their effort and work on mbed.org. But I don't know about other vendor's controllers enough for comparison.

I don't like Freescale's coding work of mbed SDK but their FDRM boards are attractive due to OpenSDA. With loading OpenSDA app you can use the board as  Segger J-Link lite compatible debugger.
https://segger.com/opensda.html

Just FYI, Cortex boards I currently have:
https://developer.mbed.org/platforms/TG-LPC11U35-501/
https://developer.mbed.org/platforms/mbed-HRM1017/
FRDM-KL05Z
STM32F3discovery

To be honest I don't have much experience on Cortex. You may want to check this thread, instead.
http://deskthority.net/workshop-f7/alternative-controller-experiments-t8735.html
Thanks for the answers Hasu, these great looking little boards. I guess I will just get a few NXP based Mbeds to play with. Freecsale seems to have a really good community of developers, but it looks like it's mostly ARM/embedded linux stuff.

Curious, why did you pick Mbed, say over Teensy? Thanks and I appreciate all the great work you have done and support to this community.
Title: Re: TMK keyboard firmware
Post by: nalui333 on Sat, 05 September 2015, 08:57:30
Hi folks, a little help if you could, i setup a 64 key (32keys each hand) split keyboard. I got one half of the keyboard working with easy avr firmware but could not get the other half working with the exception of one or two keys. I've checked and triple checked the connections and they all seem to be fine. So i decided to go the tmk route since i could dig into the code.

Now after compiling the firmware and loading with the teensy loader none of the keys in any of the halves output anything when pressed. My desktop is linux if that matters. I'm not using leds so i dropped them from the pinout I'm using the gh60 as a base per matt3o directions

files are at the links below
matrix.c :                    http://pastebin.com/Mz7VyrkQ
config.h :                    http://pastebin.com/yMJuJfAs
keymap_common.c : http://pastebin.com/qhmJZHM8
keymap_common.h : http://pastebin.com/tEAuA8Nz
keymap_poker.c        http://pastebin.com/bG7QPv36

Update:
letf hand schematic is as follows : http://ibin.co/2Ec5qvQgqrHp
right hand schematic is as follows : http://ibin.co/2Ec6ZsucNLTZ

I'm using a simple short cable between both halves no port expanders. I'm using a teensy 2 as the controller.
Any and all help is appreciated.
Title: Re: TMK keyboard firmware
Post by: hasu on Sat, 05 September 2015, 09:17:51
you can post schematic or pics of your keyboard wiring to get more precise help.
without knowing keyboard hardware anyone won't be able to check if source codes are really correct or not.
Title: Re: TMK keyboard firmware
Post by: a-c on Sat, 05 September 2015, 10:26:32
Hi folks, a little help if you could, i setup a 64 key (32keys each hand) split keyboard. I got one half of the keyboard working with easy avr firmware but could not get the other half working with the exception of one or two keys. I've checked and triple checked the connections and they all seem to be fine. So i decided to go the tmk route since i could dig into the code.

Now after compiling the firmware and loading with the teensy loader none of the keys in any of the halves output anything when pressed. My desktop is linux if that matters. I'm not using leds so i dropped them from the pinout I'm using the gh60 as a base per matt3o directions

files are at the links below
matrix.c :                    http://pastebin.com/Mz7VyrkQ
config.h :                    http://pastebin.com/yMJuJfAs
keymap_common.c : http://pastebin.com/qhmJZHM8
keymap_common.h : http://pastebin.com/tEAuA8Nz
keymap_poker.c        http://pastebin.com/bG7QPv36

Update:
letf hand schematic is as follows : http://ibin.co/2Ec5qvQgqrHp
right hand schematic is as follows : http://ibin.co/2Ec6ZsucNLTZ

I'm using a simple short cable between both halves no port expanders. I'm using a teensy 2 as the controller.
Any and all help is appreciated.

Because of the direction you have your diodes installed what you call rows are columns in TMK, and columns are rows.
Title: Re: TMK keyboard firmware
Post by: nalui333 on Sat, 05 September 2015, 11:43:10
Thanks will make changes and see..

quick question does that mean i have to change the keymap array sequence?

Update 09/19/2015
for future reference or for any newb that stumbles on this if you don't want to resolder you can make your keymap_common.h look something like this....

 KEYMAP( \
       K01,   K02,   K03,  \
K10,   K11,   K12,   K13,        \
K20,   K21,   K22,   K23,   K24, \
K30,   K31,   K32,   K33,   K34, \
K40,   K41,   K42,   K43,   K44, \
K50,   K51,   K52,   K53,   K54, \
K60,   K61,   K62,   K63,   K64, \
K70,   K71,   K72,   K73,   K74, \
K80,   K81,   K82,   K83,   K84, \
K90,   K91,   K92,   K93,   K94, \
KA0,   KA1,   KA2,   KA3,   KA4, \
KB0,   KB1,   KB2,   KB3,   KB4, \
KC0,   KC1,   KC2,   KC3,        \
       KD1,   KD2,   KD3    ){ \
    {  KC_NO,    KC_##K01,  KC_##K02,  KC_##K03,  KC_NO }, \
    {  KC_##K10, KC_##K11,  KC_##K12,  KC_##K13,  KC_NO }, \
    {  KC_##K20, KC_##K21,  KC_##K22,  KC_##K23,  KC_##K24 }, \
    {  KC_##K30, KC_##K31,  KC_##K32,  KC_##K33,  KC_##K34 }, \
    {  KC_##K40, KC_##K41,  KC_##K42,  KC_##K43,  KC_##K44 }, \
    {  KC_##K50, KC_##K51,  KC_##K52,  KC_##K53,  KC_##K54 }, \
    {  KC_##K60, KC_##K61,  KC_##K62,  KC_##K63,  KC_##K64 }, \
    {  KC_##K70, KC_##K71,  KC_##K72,  KC_##K73,  KC_##K74 }, \
    {  KC_##K80, KC_##K81,  KC_##K82,  KC_##K83,  KC_##K84 }, \
    {  KC_##K90, KC_##K91,  KC_##K92,  KC_##K93,  KC_##K94 }, \
    {  KC_##KA0, KC_##K31,  KC_##K32,  KC_##K33,  KC_##K34 }, \
    {  KC_##KB0, KC_##K31,  KC_##K32,  KC_##K33,  KC_##K34 }, \
    {  KC_##KC0, KC_##K31,  KC_##K32,  KC_##K33,  KC_NO }, \
    {  KC_NO,    KC_##K31,  KC_##K32,  KC_##K33,  KC_NO } \

 and change your keymap_poker.c to look something like this

    KEYMAP(   
      INS,  QUOT, RCTL, \
0,    SCLN, O,    SLSH,      \   
9,    Y,    I,    DOT,  FN1, \
8,    U,    E,    COMM, RSFT, \
7,    L,    N,    M,    RALT, \
6,    J,    H,    K,    ENT, \
EQL,  END,  TAB,  RGUI, BSPC, \
MINS, HOME, ESC,  LGUI, DELETE, \
5,    G,    D,    B,    SPC, \
4,    P,    T,    V,    LALT, \
3,    F,    S,    C,    LSFT, \
2,    W,    R,    X,    FN1, \
1,    Q,    A,    Z,  \
      CAPS, BSLS, LCTL),

......and so on....

Update:

I made the above changes and got some output as opposed to before with no output.

Though at this time, there's a lot of gibberish and the left hand still doesn't work. 

Update 9/08:

All of the left side works well now (there was a bad switch), 3 out of 5 keys in the right half print something but they print a mirror of what's in the left side, the journey continues.

Update 09/19:

seems my choice of cables and choice of connectors between my left and right halves were making it difficult for the (left) non teensy side) to not get the signal. will have to ghetto-ize the prototype for it to work.

Thanks and appreciations to all who helped.
Title: Re: TMK keyboard firmware
Post by: Eszett on Mon, 07 September 2015, 03:12:14
Is TMK firmware by default strobing cols or rows?
Title: Re: TMK keyboard firmware
Post by: hasu on Mon, 07 September 2015, 14:22:41
I'd say it depends on hardware but as for gh60 it is rows.
In TMK it is natual to strobe rows and sense cols but row and col are just names not matter.
Title: Re: TMK keyboard firmware
Post by: Eszett on Tue, 08 September 2015, 04:27:02
I'd say it depends on hardware but as for gh60 it is rows.
In TMK it is natual to strobe rows and sense cols but row and col are just names not matter.

Domo arigatou, hasu! Yes, they are names, only polarity matters. When I use a Teensy2.0 which senses/polls/reads with pull-up resistors (HIGH), then the polarity of strobes is LOW. That means the current flows like this

col(sensing with pull-up resistor) >> diode(+) >> diode(-) >> switch >> row(strobing LOW) 

is that correct?
Title: Re: TMK keyboard firmware
Post by: hasu on Tue, 08 September 2015, 04:42:50
Correct.
Title: Re: TMK keyboard firmware
Post by: skullydazed on Tue, 08 September 2015, 23:07:58
I modified onekey to work with my 1% test board tonight with the intention of having it send LGUI+Tab (mac app switch key combo.) It works great except that when I hold the switch down TMK seems to send key-down+key-up codes every half second or so rather than sending key-down when pressed and key-up when released. Here's my keymap code:

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

const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
    /* 0: qwerty
     * ,---.
     * |FN0|
     * `---`
     */
    KEYMAP(FN0),
};

const uint16_t PROGMEM fn_actions[] = {
    [0] = ACTION_MODS_KEY(MOD_LGUI, KC_TAB)
};

Is this expected behavior for that code? If so how can I have it send key down/up events rather than repeatedly pressing the key?
Title: Re: TMK keyboard firmware
Post by: hasu on Tue, 08 September 2015, 23:34:07
TMK firmware itself has no reapeating feature like most of modern USB keyboards. I think what you saw is OS auto key repeating.
So it is expected behaviour.
Title: Re: TMK keyboard firmware
Post by: skullydazed on Tue, 08 September 2015, 23:55:53
TMK firmware itself has no reapeating feature like most of modern USB keyboards. I think what you saw is OS auto key repeating.
So it is expected behaviour.

Ah, I see why that is. I see the same behavior when I hold cmd-tab on the keyboard. I should have realized this, the behavior I actually want is this:


Is such a thing possible in TMK currently?
Title: Re: TMK keyboard firmware
Post by: hasu on Wed, 09 September 2015, 00:21:36
It is possible with macro or function. But you need to be patient to learn it without documentations. You will have to read many codes to know how it works.

See my Alt+Tab macro, it is not exactly what you described but similar.
https://github.com/tmk/tmk_keyboard/blob/master/keyboard/hhkb/keymap_hasu.c#L233-L236
Title: Re: TMK keyboard firmware
Post by: skullydazed on Wed, 09 September 2015, 08:23:13
It is possible with macro or function. But you need to be patient to learn it without documentations. You will have to read many codes to know how it works.

See my Alt+Tab macro, it is not exactly what you described but similar.
https://github.com/tmk/tmk_keyboard/blob/master/keyboard/hhkb/keymap_hasu.c#L233-L236

Thanks for the pointer. I have this working but it doesn't behave the way I expect. When I have this code:

Code: [Select]
            return (record->event.pressed ?
                    MACRO(D(LGUI), T(TAB), END) :
                    MACRO(U(LGUI), END));

Pressing the key down behaves as I expect, LGUI is pressed down and a tab is typed. However, LGUI is not released when I let go of the key. If I press the key multiple times tab is sent multiple times, but LGUI is never released. I get the same behavior when I try this MACRO():

Code: [Select]
            return (record->event.pressed ?
                    MACRO(D(LGUI), T(TAB), U(LGUI), END) :
                    MACRO(U(LGUI), END));

Am I doing something wrong here? If I understand correctly the first MACRO() should be run when the key is pressed, and the second when the key is released, right? Why isn't U(LGUI) releasing the key?
Title: Re: TMK keyboard firmware
Post by: hasu on Wed, 09 September 2015, 16:23:19
I don't remember whether this behaviour is intentional or not, probably bug.
Try this patch. I'll push it into the repository later.

Code: [Select]
diff --git a/tmk_core/common/action_macro.c b/tmk_core/common/action_macro.c
index ba93fc8..ffaf125 100644
--- a/tmk_core/common/action_macro.c
+++ b/tmk_core/common/action_macro.c
@@ -42,6 +42,7 @@ void action_macro_play(const macro_t *macro_p)
                 dprintf("KEY_DOWN(%02X)\n", macro);
                 if (IS_MOD(macro)) {
                     add_weak_mods(MOD_BIT(macro));
+                    send_keyboard_report();
                 } else {
                     register_code(macro);
                 }
@@ -51,6 +52,7 @@ void action_macro_play(const macro_t *macro_p)
                 dprintf("KEY_UP(%02X)\n", macro);
                 if (IS_MOD(macro)) {
                     del_weak_mods(MOD_BIT(macro));
+                    send_keyboard_report();
                 } else {
                     unregister_code(macro);
                 }
Title: Re: TMK keyboard firmware
Post by: skullydazed on Thu, 10 September 2015, 17:16:19
I applied the patch but nothing changed, even after a "make clean && make && make dfu". I tried running hid_listen but while it finds the device after I plug it in it doesn't output any messages.
Title: Re: TMK keyboard firmware
Post by: hasu on Thu, 10 September 2015, 18:43:31
It works for me. This is output of xev on Xorg.
Your problem may be different but I can't come up with.

Code: [Select]
KeyPress event, serial 37, synthetic NO, window 0x4a00001,
    root 0x246, subw 0x0, time 4186601381, (-316,206), root:(395,738),
    state 0x10, keycode 133 (keysym 0xffeb, Super_L), same_screen YES,
    XLookupString gives 0 bytes:
    XmbLookupString gives 0 bytes:
    XFilterEvent returns: False

KeyPress event, serial 37, synthetic NO, window 0x4a00001,
    root 0x246, subw 0x0, time 4186601389, (-316,206), root:(395,738),
    state 0x50, keycode 23 (keysym 0xff09, Tab), same_screen YES,
    XLookupString gives 1 bytes: (09) " "
    XmbLookupString gives 1 bytes: (09) "       "
    XFilterEvent returns: False

KeyRelease event, serial 37, synthetic NO, window 0x4a00001,
    root 0x246, subw 0x0, time 4186601397, (-316,206), root:(395,738),
    state 0x50, keycode 23 (keysym 0xff09, Tab), same_screen YES,
    XLookupString gives 1 bytes: (09) " "
    XFilterEvent returns: False

KeyRelease event, serial 37, synthetic NO, window 0x4a00001,
    root 0x246, subw 0x0, time 4186601437, (-316,206), root:(395,738),
    state 0x50, keycode 133 (keysym 0xffeb, Super_L), same_screen YES,
    XLookupString gives 0 bytes:
    XFilterEvent returns: False
Title: Re: TMK keyboard firmware
Post by: p3lim on Fri, 11 September 2015, 07:44:08
Not sure if it's related to your issue, but I had to modify action_macro.c to disable modifiers while playing a macro.

Code: [Select]
diff --git a/common/action_macro.c b/common/action_macro.c
index ba93fc8..1fdda1a 100644
--- a/common/action_macro.c
+++ b/common/action_macro.c
@@ -35,6 +35,12 @@ void action_macro_play(const macro_t *macro_p)
     uint8_t interval = 0;
 
     if (!macro_p) return;
+
+    // store and depress any modifiers before running the macro
+    uint8_t old_mods = get_mods();
+    clear_mods();
+    send_keyboard_report();
+
     while (true) {
         switch (MACRO_READ()) {
             case KEY_DOWN:
@@ -74,6 +80,9 @@ void action_macro_play(const macro_t *macro_p)
                 break;
             case END:
             default:
+                // restore previous modifiers when the macro has finished playing
+                add_mods(old_mods);
+                send_keyboard_report();
                 return;
         }
         // interval
Title: Re: TMK keyboard firmware
Post by: skullydazed on Fri, 11 September 2015, 10:27:55
Not sure if it's related to your issue, but I had to modify action_macro.c to disable modifiers while playing a macro.

Code: [Select]
diff --git a/common/action_macro.c b/common/action_macro.c
index ba93fc8..1fdda1a 100644
--- a/common/action_macro.c
+++ b/common/action_macro.c
@@ -35,6 +35,12 @@ void action_macro_play(const macro_t *macro_p)
     uint8_t interval = 0;
 
     if (!macro_p) return;
+
+    // store and depress any modifiers before running the macro
+    uint8_t old_mods = get_mods();
+    clear_mods();
+    send_keyboard_report();
+
     while (true) {
         switch (MACRO_READ()) {
             case KEY_DOWN:
@@ -74,6 +80,9 @@ void action_macro_play(const macro_t *macro_p)
                 break;
             case END:
             default:
+                // restore previous modifiers when the macro has finished playing
+                add_mods(old_mods);
+                send_keyboard_report();
                 return;
         }
         // interval

Thank you! This works perfectly for me when I define this macro:

Code: [Select]
        case CMD_TAB:
            return (record->event.pressed ?
                    MACRO(D(LGUI), T(TAB), U(LGUI), END) :
                    MACRO(END));

It still does not work when using this macro:

Code: [Select]
        case CMD_TAB:
            return (record->event.pressed ?
                    MACRO(D(LGUI), T(TAB), END) :
                    MACRO(U(LGUI), END));

I dug into the code a bit and it seems like weak_real_mods isn't getting cleared properly somewhere, my added logging shows that pretty clearly:

Code: [Select]
action_macro_play: KEY_DOWN(E3)
action_macro_play: real_mods: 00)
action_macro_play: weak_real_mods: 00)
action_macro_play: KEY_DOWN(2B)
action_macro_play: real_mods: 00)
action_macro_play: weak_real_mods: 08)
action_macro_play: KEY_UP(2B)
action_macro_play: real_mods: 00)
action_macro_play: weak_real_mods: 08)
action_macro_play: KEY_UP(E3)
action_macro_play: real_mods: 00)
action_macro_play: weak_real_mods: 08)
action_macro_play: END
action_macro_play: Unknown macro: 00
action_macro_play: END
action_macro_play: Unknown macro: 00

Those are all the lines hid_listen prints when I press the key a single time.

Another curiosity is that it seems like the first macro doesn't end until the second macro has run and ended? Could that be coming into play at all?
Title: Re: TMK keyboard firmware
Post by: nephiel on Fri, 11 September 2015, 13:00:33
I'm trying to set up Shift Parenthesis using dual role keys.

I set up Left Shift as a FN key and use ACTION_MODS_TAP_KEY to send LShift when held and '(' when tapped.
But '(' is typed as Shift + 9, so I have to use ACTION_MODS_KEY to add a Shift modifier to the 9 key.
That leaves me with:
Code: [Select]
[4] = ACTION_MODS_TAP_KEY(MOD_LSFT, ACTION_MODS_KEY(MOD_LSFT, KC_9)),     // Tap for '(', hold for LShift
This works as Shift when holding, and tap works, but produces '9' instead of '('.

So, ACTION_MODS_KEY isn't working here, and I can't figure out why. Any clues?
Title: Re: TMK keyboard firmware
Post by: U47 on Fri, 11 September 2015, 14:11:55
Similarly, I'm looking to make a dual-role key out of the standard Caps Lock position which would also take a modifier.

Tap: BKSP
Shift-tap: DEL
Hold: L_CTRL

I'm not sure you can combine Actions the way you're attempting. Maybe Hasu can shed some light for us?


I'm trying to set up Shift Parenthesis using dual role keys.

I set up Left Shift as a FN key and use ACTION_MODS_TAP_KEY to send LShift when held and '(' when tapped.
But '(' is typed as Shift + 9, so I have to use ACTION_MODS_KEY to add a Shift modifier to the 9 key.
That leaves me with:
Code: [Select]
[4] = ACTION_MODS_TAP_KEY(MOD_LSFT, ACTION_MODS_KEY(MOD_LSFT, KC_9)),     // Tap for '(', hold for LShift
This works as Shift when holding, and tap works, but produces '9' instead of '('.

So, ACTION_MODS_KEY isn't working here, and I can't figure out why. Any clues?
Title: Re: TMK keyboard firmware
Post by: njbair on Fri, 11 September 2015, 14:21:57
Hey, not sure if I should post this somewhere else, but I just had to burn the alps64 firmware using FLIP in Windows, and I ran into a snag.

All the TMK docs mention setting the Device Selection dialog to ATmega32U4, but the alps64 board actually has the ATmega32U2 chip. I couldn't figure out what I was doing wrong until I got out my loupe and looked at the markings on the chip itself. Once I changed the device to ATmega32U2, the burn went perfectly.

Hopefully this helps someone else in the future!
Title: Re: TMK keyboard firmware
Post by: hasu on Fri, 11 September 2015, 14:58:47
You can't define ACTION like that. ACTION cannot be placed in another ACTION.

You can define complex behaviour with action_function(). See this.
https://github.com/tmk/tmk_keyboard/blob/master/keyboard/hhkb/keymap_hasu.c#L254-L280


I'm trying to set up Shift Parenthesis using dual role keys.

I set up Left Shift as a FN key and use ACTION_MODS_TAP_KEY to send LShift when held and '(' when tapped.
But '(' is typed as Shift + 9, so I have to use ACTION_MODS_KEY to add a Shift modifier to the 9 key.
That leaves me with:
Code: [Select]
[4] = ACTION_MODS_TAP_KEY(MOD_LSFT, ACTION_MODS_KEY(MOD_LSFT, KC_9)),     // Tap for '(', hold for LShift
This works as Shift when holding, and tap works, but produces '9' instead of '('.

So, ACTION_MODS_KEY isn't working here, and I can't figure out why. Any clues?
Title: Re: TMK keyboard firmware
Post by: hasu on Fri, 11 September 2015, 15:31:40
Ah, I'll fix doc later :D
If you don't mind using command line I'd recommend 'make flip' or 'make dfu' so that you don't need to care chip name.

Hey, not sure if I should post this somewhere else, but I just had to burn the alps64 firmware using FLIP in Windows, and I ran into a snag.

All the TMK docs mention setting the Device Selection dialog to ATmega32U4, but the alps64 board actually has the ATmega32U2 chip. I couldn't figure out what I was doing wrong until I got out my loupe and looked at the markings on the chip itself. Once I changed the device to ATmega32U2, the burn went perfectly.

Hopefully this helps someone else in the future!

Title: Re: TMK keyboard firmware
Post by: njbair on Fri, 11 September 2015, 15:33:12
Ah, I'll fix doc later :D
If you don't mind using command line I'd recommend 'make flip' or 'make dfu' so that you don't need to care chip name.

Hey, not sure if I should post this somewhere else, but I just had to burn the alps64 firmware using FLIP in Windows, and I ran into a snag.

All the TMK docs mention setting the Device Selection dialog to ATmega32U4, but the alps64 board actually has the ATmega32U2 chip. I couldn't figure out what I was doing wrong until I got out my loupe and looked at the markings on the chip itself. Once I changed the device to ATmega32U2, the burn went perfectly.

Hopefully this helps someone else in the future!

I haven't personally had much luck getting a build environment working in Windows. So I use a Debian VM to build the firmware, then SCP it to my desktop temp folder and flash it from there using FLIP GUI.
Title: Re: TMK keyboard firmware
Post by: nephiel on Fri, 11 September 2015, 16:30:08
I'm trying to set up Shift Parenthesis using dual role keys.

I set up Left Shift as a FN key and use ACTION_MODS_TAP_KEY to send LShift when held and '(' when tapped.
But '(' is typed as Shift + 9, so I have to use ACTION_MODS_KEY to add a Shift modifier to the 9 key.
That leaves me with:
Code: [Select]
[4] = ACTION_MODS_TAP_KEY(MOD_LSFT, ACTION_MODS_KEY(MOD_LSFT, KC_9)),     // Tap for '(', hold for LShift
This works as Shift when holding, and tap works, but produces '9' instead of '('.

So, ACTION_MODS_KEY isn't working here, and I can't figure out why. Any clues?
You can't define ACTION like that. ACTION cannot be placed in another ACTION.

You can define complex behaviour with action_function(). See this.
https://github.com/tmk/tmk_keyboard/blob/master/keyboard/hhkb/keymap_hasu.c#L254-L280
Looking at action_code.h, these ACTIONs are #defines, and most of them are nested. I see it doesn't work, but I don't really understand why...

Anyway, thanks! I got Shift parentheses to work using action_function, and also Control brackets [] and Alt curly brackets {}.
The code is up on my fork in Github: https://github.com/Nephiel/tmk_keyboard/commit/0903bc12f8fcc4050f3e61dee23fcccb94f917a9
Note my board layout is Spanish and parentheses are Shift+8/9 instead of Shift+9/0.

Similarly, I'm looking to make a dual-role key out of the standard Caps Lock position which would also take a modifier.

Tap: BKSP
Shift-tap: DEL
Hold: L_CTRL
This is a bit different. You can do tap=BKSP and hold=LCTRL with ACTION_MODS_TAP_KEY(MOD_LCTL, KC_BKSP). But for shift-tap=DEL you would need another layer, and if you want to use Shift to activate that layer, you'll need to apply a shift mod to all the other keys in that layer so Shift still works normally for them. I'm not sure how to do that.

Another option is to write a custom action_function() like Hasu said.
Title: Re: TMK keyboard firmware
Post by: skullydazed on Fri, 11 September 2015, 19:53:59
I don't remember whether this behaviour is intentional or not, probably bug.
Try this patch. I'll push it into the repository later.

Code: [Select]
diff --git a/tmk_core/common/action_macro.c b/tmk_core/common/action_macro.c
index ba93fc8..ffaf125 100644
--- a/tmk_core/common/action_macro.c
+++ b/tmk_core/common/action_macro.c
@@ -42,6 +42,7 @@ void action_macro_play(const macro_t *macro_p)
                 dprintf("KEY_DOWN(%02X)\n", macro);
                 if (IS_MOD(macro)) {
                     add_weak_mods(MOD_BIT(macro));
+                    send_keyboard_report();
                 } else {
                     register_code(macro);
                 }
@@ -51,6 +52,7 @@ void action_macro_play(const macro_t *macro_p)
                 dprintf("KEY_UP(%02X)\n", macro);
                 if (IS_MOD(macro)) {
                     del_weak_mods(MOD_BIT(macro));
+                    send_keyboard_report();
                 } else {
                     unregister_code(macro);
                 }

I took a look with fresh eyes and it turns out I was missing the second send_keyboard_report() in your patch. I added that and my MACRO() is working exactly as expected, thanks! As a bonus I got to dive into that code and learn a bit about how it all works.
Title: Re: TMK keyboard firmware
Post by: U47 on Fri, 11 September 2015, 20:47:47
Quote from: hasu

[quote author=U47 link=topic=41989.msg1862625#msg1862625 date=1441998715
Similarly, I'm looking to make a dual-role key out of the standard Caps Lock position which would also take a modifier.

Tap: BKSP
Shift-tap: DEL
Hold: L_CTRL
This is a bit different. You can do tap=BKSP and hold=LCTRL with ACTION_MODS_TAP_KEY(MOD_LCTL, KC_BKSP). But for shift-tap=DEL you would need another layer, and if you want to use Shift to activate that layer, you'll need to apply a shift mod to all the other keys in that layer so Shift still works normally for them. I'm not sure how to do that.

Another option is to write a custom action_function() like Hasu said.

Yeah, I think using Shift is the gotcha. I'm just used to this combination since this is how I've had Karabiner set to work. I don't think a custom action would be too onerous, or I can add it to SpaceFN instead.
Title: Re: TMK keyboard firmware
Post by: hasu on Fri, 11 September 2015, 21:36:08
Great. I'll push this fix to my repository.

I don't remember whether this behaviour is intentional or not, probably bug.
Try this patch. I'll push it into the repository later.

Code: [Select]
diff --git a/tmk_core/common/action_macro.c b/tmk_core/common/action_macro.c
index ba93fc8..ffaf125 100644
--- a/tmk_core/common/action_macro.c
+++ b/tmk_core/common/action_macro.c
@@ -42,6 +42,7 @@ void action_macro_play(const macro_t *macro_p)
                 dprintf("KEY_DOWN(%02X)\n", macro);
                 if (IS_MOD(macro)) {
                     add_weak_mods(MOD_BIT(macro));
+                    send_keyboard_report();
                 } else {
                     register_code(macro);
                 }
@@ -51,6 +52,7 @@ void action_macro_play(const macro_t *macro_p)
                 dprintf("KEY_UP(%02X)\n", macro);
                 if (IS_MOD(macro)) {
                     del_weak_mods(MOD_BIT(macro));
+                    send_keyboard_report();
                 } else {
                     unregister_code(macro);
                 }

I took a look with fresh eyes and it turns out I was missing the second send_keyboard_report() in your patch. I added that and my MACRO() is working exactly as expected, thanks! As a bonus I got to dive into that code and learn a bit about how it all works.

Title: Re: TMK keyboard firmware
Post by: nephiel on Sat, 12 September 2015, 04:24:03
Quote from: hasu

[quote author=U47 link=topic=41989.msg1862625#msg1862625 date=1441998715
Similarly, I'm looking to make a dual-role key out of the standard Caps Lock position which would also take a modifier.

Tap: BKSP
Shift-tap: DEL
Hold: L_CTRL
This is a bit different. You can do tap=BKSP and hold=LCTRL with ACTION_MODS_TAP_KEY(MOD_LCTL, KC_BKSP). But for shift-tap=DEL you would need another layer, and if you want to use Shift to activate that layer, you'll need to apply a shift mod to all the other keys in that layer so Shift still works normally for them. I'm not sure how to do that.

Another option is to write a custom action_function() like Hasu said.

Yeah, I think using Shift is the gotcha. I'm just used to this combination since this is how I've had Karabiner set to work. I don't think a custom action would be too onerous, or I can add it to SpaceFN instead.
Wouldn't this work? https://github.com/tmk/tmk_keyboard/blob/master/doc/keymap.md#35-momentary-switching-with-modifiers
Have a momentary layer with DEL on CapsLock and set Shift on the default layer as a FN key to switch to it while setting MOD_LSHIFT.
Title: Re: TMK keyboard firmware
Post by: TheGlow on Tue, 15 September 2015, 09:54:03
I hate to be that guy, but what do I need to get started on using TMK and compiling my own hex?
I have a FrostyFlake V2 and it seems Easy AVR Usb keyboard hexes are causing odd behavior.
As I type, 2-3 characters later it will repeat a char I already typed, like "sample" > samsple. Sometimes 1 word can 2 doubles in it.
I tried debouncing up to 50-75 and sometimes till get it, but then I cant spam spacebar and backspace.
Bphipanie's stock is good so Im wondering if TMK would be good.

Again, where should I start? I doubt theres a converted from Easy AVR .dat to use in TMK, is there?
Title: Re: TMK keyboard firmware
Post by: flabbergast on Tue, 15 September 2015, 10:42:33
AFAIK there is no "converter".

However bphiphany has forked TMK and added his controllers, so I'd start with his sources: https://github.com/BathroomEpiphanies/tmk_keyboard

For general instructions how to go about compiling TMK, matt3o's guide (http://deskthority.net/workshop-f7/how-to-build-your-very-own-keyboard-firmware-t7177.html) is generally a good start.
Title: Re: TMK keyboard firmware
Post by: NiceAndCreamy on Tue, 15 September 2015, 17:09:49
First time doing this custom keyboard stuff and I seem to be having an issue. I believe i have my hex file all setup and programmed to the teensy but whenever its plugged in I see another keyboard in device manager for a second and then it automatically disconnects. I can get it to say "installing keyboard" if I change the product id in config.h but the keyboard continues to disconnect.
Title: Re: TMK keyboard firmware
Post by: hasu on Sat, 19 September 2015, 21:23:29
Fixed control of LEDs for NeXT keyboard converter(Non ADB) after a long since the last time.
https://github.com/tmk/tmk_keyboard/commit/9b99f8f8649c25b5efa92c9fd49b7f4c0ce60a76

Try it if you are  interested.
https://github.com/tmk/tmk_keyboard/tree/master/converter/next_usb

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


The codes were contributed from bcg (bgould@github) long since, Thanks!
Title: Re: TMK keyboard firmware
Post by: torusJKL on Tue, 29 September 2015, 02:18:16
Hi everyone

I finally finished my ErgoDox and very much like the tmk firmware and all the features it provides.

I'm trying to do a layer for special characters.
Like shown in this neo layer 3 pdf (http://neo-layout.org/grafik/tastatur3d/tastatur_neo_Ebene3.pdf).

The layer is activated using
Code: [Select]
[4] = ACTION_LAYER_MOMENTARY(4),
The keys would be arranged the following way
Code: [Select]
   /* Keymap 4: Special chars Layer
     *
     * all special characters on one layer
     *
     * ,--------------------------------------------------.           ,--------------------------------------------------.
     * |  Esc   |   1  |   2  |   3  |   4  |   5  |      |           |      |   6  |   7  |   8  |   9  |   0  |        |
     * |--------+------+------+------+------+-------------|           |------+------+------+------+------+------+--------|
     * |  Tab   |      |   _  |   [  |   ]  |   ^  | BKSP |           |      |   !  |   <  |   >  |   =  |   &  |        |
     * |--------+------+------+------+------+------|      |           |      |------+------+------+------+------+--------|
     * |  Del   |   \  |   /  |   {  |   }  |   *  |------|           |------|   ?  |   (  |   )  |   -  |   :  |   @    |
     * |--------+------+------+------+------+------|      |           |      |------+------+------+------+------+--------|
     * |        |   #  |   $  |   |  |   ~  |      | RET  |           |  L4  |   +  |   %  |   "  |   '  |   ;  |        |
     * `--------+------+------+------+------+-------------'           `-------------+------+------+------+------+--------'
     *   | Prnt |  F1  |  F2  |  F3  |  F4  |                                       |  F9  |  F10 |  F11 | F12  |      |
     *   `----------------------------------'                                       `----------------------------------'
     *                                        ,-------------.       ,-------------.
     *                                        |  F5  |  F6  |       |  F7  |  F8  |
     *                                 ,------|------|------|       |------+------+------.
     *                                 |      |      | LAlt |       | RCtrl|      |      |
     *                                 | LSft |  L4  |------|       |------| RAlt | Space|
     *                                 |      |      | LGui |       | RGui |      |      |
     *                                 `--------------------'       `--------------------'
     */


I'm using functions to press SHIFT and a second button like KC_LBRC in order to get {.
Code: [Select]
[26] = ACTION_MODS_KEY(MOD_LSFT, KC_LBRC),
In the end my keymap uses too many of functions
Code: [Select]
    KEYMAP(
        // left hand
        ESC,    1,   2,   3,   4,   5,TRNS,
        TAB, TRNS,FN34,LBRC,RBRC,FN16,BSPC,
        TRNS,BSLS,SLSH,FN26,FN27,FN18,
        TRNS,FN13,FN14,FN28,FN29,TRNS,ENT,
        PSCR,  F1,  F2,  F3,  F4,
                                        F5,  F6,
                                           LALT,
                                 LSFT, FN4,LGUI,
        // right hand
             TRNS,   6,   7,   8,   9,   0,TRNS,
             TRNS,FN11,FN24,FN23, EQL,FN17,TRNS,
                  FN25,FN19,FN10,MINS,FN32,FN12,
              FN4,FN33,FN15,FN35,QUOT,SCLN,TRNS,
                         F9, F10, F11, F12,TRNS,
           F7, F8,
        RCTRL,
        RGUI,RALT,SPC
    ),

With all the other functions I already use I passed the allowed 32 functions (currently 34) and thus I can't compile the firmware anymore.


Is there a better way to get characters that are on the shift key?
Maybe 1 macro for the whole layout that checks which key was pressed and with this one using the same function on all the shift keys?

Thanks!
Title: Re: TMK keyboard firmware
Post by: nomaded on Tue, 29 September 2015, 11:52:21
I have an example keymap.h file at https://geekhack.org/index.php?topic=48106.msg1826237#msg1826237 (https://geekhack.org/index.php?topic=48106.msg1826237#msg1826237). That config doesn't use more than 32 functions, but it should show you how do use more than 32 functions. It's based on cub-uanic current release on github.
Title: Re: TMK keyboard firmware
Post by: torusJKL on Wed, 30 September 2015, 00:05:53
I have an example keymap.h file at https://geekhack.org/index.php?topic=48106.msg1826237#msg1826237 (https://geekhack.org/index.php?topic=48106.msg1826237#msg1826237). That config doesn't use more than 32 functions, but it should show you how do use more than 32 functions. It's based on cub-uanic current release on github.

Thanks!
I will try to do the 32 Fn keys per layer.
What do you mean with the following sentence?
Code: [Select]
* This overrides the keymap_fn_to_action() function found at the end of
 * keymap.c with an #if defined.

Could you post that line for keymap.c?


I have another question regarding your CUSTOM_KEY solution.
Code: [Select]
    keyevent_t event = record->event;

    if (id == CUSTOM_KEY) {
        uint8_t layer = biton32(layer_state);
        uint8_t col = event.key.col;
        uint8_t row = event.key.row;
        uint8_t handled = 0;
Is it possible to record nkeys from the key event?

For example if I wanted to use shift + a to get @ instead of A.
(I could use shift to change the layer but than OS key combinations with shift would not work anymore)
Title: Re: TMK keyboard firmware
Post by: U47 on Wed, 30 September 2015, 00:44:48
Anyone out there who has a board given any thought to cobbling together SGI protocol support? I have a couple of SGI Bigfoot boards, one of which has SGI's proprietary interface and protocol. Could be an interesting project...
Title: Re: TMK keyboard firmware
Post by: nomaded on Fri, 02 October 2015, 01:57:27
What do you mean with the following sentence?
Code: [Select]
* This overrides the keymap_fn_to_action() function found at the end of
 * keymap.c with an #if defined.

Could you post that line for keymap.c?

Since this is based on cub-uanic's ErgoDox port of the TMK firmware, I'll reference his code from github. If you look at https://github.com/cub-uanic/tmk_keyboard/blob/cub_layout/keyboard/ergodox/keymap.c#L221 (https://github.com/cub-uanic/tmk_keyboard/blob/cub_layout/keyboard/ergodox/keymap.c#L221), that is the start of cub-uanic's #if defined statement for his own layout that supports more than 32 FN actions. The #else that follows defines the default keymap_fn_to_action() function that has the 32 FN action limitation.

If you look at https://github.com/cub-uanic/tmk_keyboard/blob/cub_layout/keyboard/ergodox/keymap_cub.h#L558 (https://github.com/cub-uanic/tmk_keyboard/blob/cub_layout/keyboard/ergodox/keymap_cub.h#L558), this is the beginning of how he defines a separate set of FN actions for each layer. Here's his Layer 0 FN actions (https://github.com/cub-uanic/tmk_keyboard/blob/cub_layout/keyboard/ergodox/keymap_cub.h#L381), his Layer 4 FN actions (https://github.com/cub-uanic/tmk_keyboard/blob/cub_layout/keyboard/ergodox/keymap_cub.h#L428), his Layer 7 FN actions (https://github.com/cub-uanic/tmk_keyboard/blob/cub_layout/keyboard/ergodox/keymap_cub.h#L436), and his Layer 9 FN actions (https://github.com/cub-uanic/tmk_keyboard/blob/cub_layout/keyboard/ergodox/keymap_cub.h#L443).

In the other thread with my referenced code, I kept my modified version of cub-uanic's code in the keymap.h file, but commented out because that particular layout didn't need more than 32 FN actions. I don't actually run that layout; it was more of an example how to toggle capslock by hitting both shift keys at the same time.

Quote
I have another question regarding your CUSTOM_KEY solution.
Code: [Select]
    keyevent_t event = record->event;

    if (id == CUSTOM_KEY) {
        uint8_t layer = biton32(layer_state);
        uint8_t col = event.key.col;
        uint8_t row = event.key.row;
        uint8_t handled = 0;
Is it possible to record nkeys from the key event?

For example if I wanted to use shift + a to get @ instead of A.
(I could use shift to change the layer but than OS key combinations with shift would not work anymore)

A key event is always just one key that you've either pressed or released. So if you wanted to do something based on having more than one key pressed, you could adapt what I wrote for "2 shifts -> capslock". You just need to figure out when the 2 keys are pressed, and then "add_key(KEYCODE);\nsend_keyboard_report();" for the key press, and "del_key(KEYCODE);\nsend_keyboard_report();" for the key release. This is cub-uanic's custom action (https://github.com/cub-uanic/tmk_keyboard/blob/cub_layout/keyboard/ergodox/keymap_cub.h#L476), which is a bit more straight forward.
Title: Re: TMK keyboard firmware
Post by: TheGlow on Fri, 02 October 2015, 11:40:23
I just tried compiling for the Frosty Flake v2 without any changes and I'm getting an error.
I don't have any coding background and just trying to get a hang of it as I have that odd error when using an Easy AVR USB Hex.
I just wanted to rule out hardware issue vs easy avr and figured a blank stock TMK should be a decent test and I can't seem to get this to go.

http://pastebin.com/xpiUHgtM
Here is the output.

To make sure I'm reading correctly, "warning"s would be the error stopping it? As it does seem to advance for a bit after the matrix.c shows some warnings.
Lufa.c is where it looks like it has a heart attack.

Edit: I noticed I was using the tmk_keyboard-master.zip bpiphany had posted, size was 29,096KB vs the one hosted here 29,043KB.
I tried this, same error just looks the warnings are 1 digit higher. *shrug*
http://pastebin.com/kn2vETe7
Title: Re: TMK keyboard firmware
Post by: flabbergast on Fri, 02 October 2015, 12:47:41
Hi - I just tried it (well - the current master branch from github) here (on OS X though), and it does compile. The warnings are there, mostly the same as yours - you can safely ignore them. The error is weird (the one reported on line 575), and to me it indicates that something's wrong with your avr-gcc installation. (I may be wrong though.) That constant, clock_div_1 is supposed to be defined in avr-libc; and also if you have a look at tmk_core/protocol/lufa/LUFA-git/LUFA/DoxygenPages/MigrationInformation.txt, it has a note in there about this.

If you're using WinAVR, that's really old. I would recommend either upgrading to a more recent avr-gcc, or (even better) do it in a virtual machine/linux.

More recent avr-gcc for windows: start with cygwin or msys, and then http://andybrown.me.uk/2015/03/08/avr-gcc-492/
Title: Re: TMK keyboard firmware
Post by: TheGlow on Fri, 02 October 2015, 13:33:03
Yea, using WinAVR which I learned is old the hard way.
It wiped my environment variables path.
Tried to ping something and got not recognized error and panicked for a second.

Also it didnt actually export a .hex file otherwise I would have flashed for science.

Ill try cygwin/msys, both downloading now,  and see whats up.
Thanx.

Edit: Cygwin was taking forever and nearing 5gb. msys was only 150mb.
I put in avr-gcc and was able to compile it. Should I be concerned it took about 3-4 minutes as opposed to WinAVR being seconds? Although it fails.
Easy AVR also does it in seconds.

Also I thought # would comment out a line. I tried editing the manufacturer line in config.h ,
"#define PRODUCT         CM Storm QFR-Deez Nuts"
Device manager shows, manu = Standard Keyboard
Description,
#define DESCRIPTION     t.m.k. keyboard firmware for CM Storm QFR,  show as HID Keyboard Device.

If I remove the #, then I get an error.
Title: Re: TMK keyboard firmware
Post by: nomaded on Sat, 03 October 2015, 02:50:06
Also I thought # would comment out a line. I tried editing the manufacturer line in config.h ,
"#define PRODUCT         CM Storm QFR-Deez Nuts"
Device manager shows, manu = Standard Keyboard
Description,
#define DESCRIPTION     t.m.k. keyboard firmware for CM Storm QFR,  show as HID Keyboard Device.

If I remove the #, then I get an error.

In C/C++, lines that start with # are not comments. Comments are bracketed with /* ... */, or start with // (for C++).

In this case, #define is defining a constant that can be referenced and used in other parts of the code.
Title: Re: TMK keyboard firmware
Post by: flabbergast on Sat, 03 October 2015, 02:53:48
Sizes: full cygwin is a beast, you don't need all that stuff; there should be a way to select a "base" installation, plus "development tools". But msys should be fine as well.

Times: it should definitely not take 3-4 minutes to compile, but something like 10 seconds on modern computers (and most of *that* time might be locating, reading and writing files ;)

Commenting: '#' in C does not mean a comment, but a special type of "command" (which is actually not a C command, it is processed by the C preprocessor). Commenting in C (plus plus) is done by 'double slash':
Code: [Select]
// this is a comment
or more traditionally by
Code: [Select]
/* this is a comment */

EDIT: yea, got owned again.
Title: Re: TMK keyboard firmware
Post by: RavenII on Sat, 03 October 2015, 19:12:07
I'm using http://www.enjoyclick.org/tkg/# to make a keymap for my KC60...it is my understanding that with TMK you can have the ESC key double as ~ when you hit shift....but the TMG tool doesn't supply that in his help. What would be the edit that I'd need to make to the keymap.c file afterwards?
Title: Re: TMK keyboard firmware
Post by: hasu on Sat, 03 October 2015, 19:27:53
You may get help from him here. I don't know how his TKG works actually.
https://github.com/kairyu/tkg

BTW, ESC/~ is possible but not easy with TMK, you will have to write C code. I think you can find the code somewhere but I can't remember.
Title: Re: TMK keyboard firmware
Post by: VinnyCordeiro on Sat, 03 October 2015, 19:43:21
I'm using http://www.enjoyclick.org/tkg/# to make a keymap for my KC60...it is my understanding that with TMK you can have the ESC key double as ~ when you hit shift....but the TMG tool doesn't supply that in his help. What would be the edit that I'd need to make to the keymap.c file afterwards?

It is easier to do that with layers, instead of shift. That's what almost everyone do.
Title: Re: TMK keyboard firmware
Post by: njbair on Sat, 03 October 2015, 19:45:24
You may get help from him here. I don't know how his TKG works actually.
https://github.com/kairyu/tkg

BTW, ESC/~ is possible but not easy with TMK, you will have to write C code. I think you can find the code somewhere but I can't remember.

It's worth pointing out that Fn+Esc would be very easy to map to `/~, but since Shift is already a modifier it makes it hard to use it as a function/macro trigger.
Title: Re: TMK keyboard firmware
Post by: RavenII on Sat, 03 October 2015, 23:18:52
One more thing, the Magic key combos...are they meant to print anything out in a text editor? I'm trying them, but don't see any output or anything....
Title: Re: TMK keyboard firmware
Post by: hasu on Sat, 03 October 2015, 23:25:34
Not with text editor. Check README and a FAQ entry.

https://github.com/tmk/tmk_keyboard/blob/master/README.md#debugging
https://github.com/tmk/tmk_keyboard/wiki/FAQ#debug-console
Title: Re: TMK keyboard firmware
Post by: RavenII on Sat, 03 October 2015, 23:26:41
Not with text editor. Check README and a FAQ entry.

https://github.com/tmk/tmk_keyboard/blob/master/README.md#debugging
https://github.com/tmk/tmk_keyboard/wiki/FAQ#debug-console

Gotcha, I thought this was for the bootmagic only, I didn't realize it applied to both, thanks hasu!
Title: Re: TMK keyboard firmware
Post by: p3lim on Sun, 04 October 2015, 07:28:30
You may get help from him here. I don't know how his TKG works actually.
https://github.com/kairyu/tkg

BTW, ESC/~ is possible but not easy with TMK, you will have to write C code. I think you can find the code somewhere but I can't remember.

You may get help from him here. I don't know how his TKG works actually.
https://github.com/kairyu/tkg

BTW, ESC/~ is possible but not easy with TMK, you will have to write C code. I think you can find the code somewhere but I can't remember.

It's worth pointing out that Fn+Esc would be very easy to map to `/~, but since Shift is already a modifier it makes it hard to use it as a function/macro trigger.

Here's how I implemented my Escape+~/` key
https://github.com/p3lim/keyboard_firmware/commit/fd799c12b69a5ab5addd1d4c03380a1b8ef8e9dc
Title: Re: TMK keyboard firmware
Post by: torusJKL on Sun, 04 October 2015, 12:18:22
Is there a better way to get characters that are on the shift key?

I found the solution jack introduced with extended keymaps very nicely done.
https://github.com/jackhumbert/tmk_keyboard/commit/708f95a472327e25355b28899fbd13d89f6925f5 (https://github.com/jackhumbert/tmk_keyboard/commit/708f95a472327e25355b28899fbd13d89f6925f5)
https://github.com/jackhumbert/tmk_keyboard/commit/5c45ba947c760cbb28e67d6eabb887fb56cdb170 (https://github.com/jackhumbert/tmk_keyboard/commit/5c45ba947c760cbb28e67d6eabb887fb56cdb170)

As a end-user it make the usage of the shift key as easy as using S(KC_Q) and there is no need to use any of the 32 available actions.

Unfortunately I didn't manage to make it work with cub-uanic's ErgoDox port of the TMK firmware. :-(
Title: Re: TMK keyboard firmware
Post by: torusJKL on Sun, 04 October 2015, 13:36:22
Since this is based on cub-uanic's ErgoDox port of the TMK firmware, I'll reference his code from github. If you look at https://github.com/cub-uanic/tmk_keyboard/blob/cub_layout/keyboard/ergodox/keymap.c#L221 (https://github.com/cub-uanic/tmk_keyboard/blob/cub_layout/keyboard/ergodox/keymap.c#L221), that is the start of cub-uanic's #if defined statement for his own layout that supports more than 32 FN actions. The #else that follows defines the default keymap_fn_to_action() function that has the 32 FN action limitation.

Thanks! That was the missing piece.
I got it to work with my layout.
Title: Re: TMK keyboard firmware
Post by: MrRooks on Mon, 05 October 2015, 12:12:22
Hello, so this may be a waste of time but I figured I would ask. Maybe someone can point me in the right direction.

A user on here built the matrix files to support the Octagon 75% board on TMK. That's great but there is still one problem. Even though there are binds to turn each RGB LED on/off individually there is only full on or full off. While it would be nice to be able to fully control that he mentioned that the RGB LEDs aren't hooked up to PWM ports on the controller leaving software PWM or changing the voltage as options. Seeing as I don't care about cycling colors or anything can someone point me to the files I might need to tinker with in order to mess with the voltage(at my own risk of course)?

Any help is appreciated. Thanks!
Title: Re: TMK keyboard firmware
Post by: flabbergast on Mon, 05 October 2015, 12:32:21
There's no way to change the voltage to anything other than VCC (i.e. 5V) and ground (0V) on these AVRs (changing the output voltage would a digital-to-analog-converter (DAC)). The only way to regulate brightness is "software PWM". An example of that is actually in TMK itself, for "suspend LED breathing". Have a look at tmk_core/common/sleep_led.c.
Title: Re: TMK keyboard firmware
Post by: MrRooks on Mon, 05 October 2015, 12:48:48
There's no way to change the voltage to anything other than VCC (i.e. 5V) and ground (0V) on these AVRs (changing the output voltage would a digital-to-analog-converter (DAC)). The only way to regulate brightness is "software PWM". An example of that is actually in TMK itself, for "suspend LED breathing". Have a look at tmk_core/common/sleep_led.c.

Thank you!
Title: Re: TMK keyboard firmware
Post by: TheGlow on Mon, 05 October 2015, 13:28:33
Sizes: full cygwin is a beast, you don't need all that stuff; there should be a way to select a "base" installation, plus "development tools". But msys should be fine as well.

Times: it should definitely not take 3-4 minutes to compile, but something like 10 seconds on modern computers (and most of *that* time might be locating, reading and writing files ;)

Commenting: '#' in C does not mean a comment, but a special type of "command" (which is actually not a C command, it is processed by the C preprocessor). Commenting in C (plus plus) is done by 'double slash':
Code: [Select]
// this is a comment
or more traditionally by
Code: [Select]
/* this is a comment */

EDIT: yea, got owned again.
Many thanks. I know enough to shamble my way through some things.
I'll try to compile again after a reboot perhaps. I don't have much running but I would expect an i7 with 16gb memory meet the recommended specs.
Just odd the others were faster and this msys clearly not same speed.
Rebooted, about 1 min, 3 seconds now. A bit better.

I've been on the bare build all day and its seeming pretty good. Just a few extra spaces on occasion but i think that just might be user error.

Edit: heres why I thought that. In the linked how to, he clearly states # is to comment out.
http://deskthority.net/workshop-f7/how-to-build-your-very-own-keyboard-firmware-t7177.html
Title: Re: TMK keyboard firmware
Post by: hasu on Tue, 06 October 2015, 01:56:14
BTW, ESC/~ is possible but not easy with TMK, you will have to write C code. I think you can find the code somewhere but I can't remember.

I read FC660 and Poker manual and found the ESC/~ can be defined with ACTION_LAYER_MODS.

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


/* Leopold FC660
 * https://elitekeyboards.com/products.php?sub=leopold,compact&pid=fc660c
 * Shift + Esc = ~
 * Fn    + Esc = `
 *
 * Votex Poker II
 * https://adprice.fedorapeople.org/poker2_manual.pdf
 * Fn         + Esc = `
 * Fn + Shift + Esc = ~
 */
const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
    /* 0: qwerty */
    [0] = KEYMAP( \
        ESC, 1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   MINS,EQL, NUHS,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,  \
        FN0, NUBS,Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, SLSH,RSFT,ESC, \
        LCTL,LGUI,LALT,          SPC,                     RALT,FN1, RGUI,RCTL),
    [1] = KEYMAP( \
        GRV, 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,TRNS,TRNS,TRNS, \
        TRNS,TRNS,TRNS,          TRNS,                    TRNS,TRNS,TRNS,TRNS),
    [2] = KEYMAP( \
        GRV, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12, 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),
};

const uint16_t PROGMEM fn_actions[] = {
    // https://github.com/tmk/tmk_keyboard/blob/master/doc/keymap.md#35-momentary-switching-with-modifiers
    [0] = ACTION_LAYER_MODS(1, MOD_LSFT),
    [1] = ACTION_LAYER_MOMENTARY(2),
};


https://github.com/tmk/tmk_keyboard/wiki/FAQ-Keymap#esc-and--on-a-key
Title: Re: TMK keyboard firmware
Post by: hasu on Tue, 06 October 2015, 02:09:21
Is there a better way to get characters that are on the shift key?

I found the solution jack introduced with extended keymaps very nicely done.
https://github.com/jackhumbert/tmk_keyboard/commit/708f95a472327e25355b28899fbd13d89f6925f5 (https://github.com/jackhumbert/tmk_keyboard/commit/708f95a472327e25355b28899fbd13d89f6925f5)
https://github.com/jackhumbert/tmk_keyboard/commit/5c45ba947c760cbb28e67d6eabb887fb56cdb170 (https://github.com/jackhumbert/tmk_keyboard/commit/5c45ba947c760cbb28e67d6eabb887fb56cdb170)

As a end-user it make the usage of the shift key as easy as using S(KC_Q) and there is no need to use any of the 32 available actions.

Unfortunately I didn't manage to make it work with cub-uanic's ErgoDox port of the TMK firmware. :-(

I wrote some code for keymapping with 16bit codes, with this remove 32 FN limitation and you can define user defined action like S(Q) above.

https://github.com/tmk/tmk_keyboard/pull/251

This is a mapping example where s() modifies a key with Shift.
https://github.com/tmk/tmk_keyboard/blob/actionmap/keyboard/alps64/actionmap_hasu.c#L144
Code: [Select]
    /* 40% */
    [5] = ACTIONMAP_AEK( \
        TRNS,1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   TRNS,TRNS,TRNS, \
        TRNS,s(1),s(2),s(3),s(4),s(5),s(6),s(7),s(8),s(9),s(0),TRNS,TRNS,TRNS, \
        TRNS,1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   TRNS,TRNS, \
        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \
        TRNS,TRNS,TRNS,          TRNS,                         TRNS,TRNS,TRNS),

s() is defined in common/actionmap.h but you can define your actions in your own keymap file.
https://github.com/tmk/tmk_keyboard/blob/actionmap/tmk_core/common/actionmap.h#L32-L35
Code: [Select]
/* Modified key */
#define AC_c(kc)                ACTION_MODS_KEY(MOD_LCTL, KC_##kc)
#define AC_s(kc)                ACTION_MODS_KEY(MOD_LSFT, KC_##kc)
#define AC_a(kc)                ACTION_MODS_KEY(MOD_LALT, KC_##kc)
#define AC_g(kc)                ACTION_MODS_KEY(MOD_LSFT, KC_##kc)
Title: Re: TMK keyboard firmware
Post by: RavenII on Tue, 06 October 2015, 12:35:37
Where I would find how to make shift when held, up arrow when tapped?
Title: Re: TMK keyboard firmware
Post by: hasu on Tue, 06 October 2015, 12:40:29
See this.

https://github.com/tmk/tmk_keyboard/blob/master/doc/keymap.md#213-modifier-with-tap-keydual-role

EDIT: Added FAQ entry: Arrow on Right Modifier keys with Dual-Role
https://github.com/tmk/tmk_keyboard/wiki/FAQ-Keymap#arrow-on-right-modifier-keys-with-dual-role

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


/* Arrow keys on right modifier keys with TMK dual role feature
 *
 *  https://github.com/tmk/tmk_keyboard/blob/master/doc/keymap.md#213-modifier-with-tap-keydual-role
 *  https://en.wikipedia.org/wiki/Modifier_key#Dual-role_keys
 */
const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
    /* 0: qwerty */
    [0] = KEYMAP( \
        ESC, 1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   MINS,EQL, NUHS,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,NUBS,Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, SLSH,FN0, ESC, \
        FN4, LGUI,LALT,          SPC,                     APP, FN2, FN1, FN3),
    [1] = KEYMAP( \
        GRV, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12, 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,FN5, TRNS, \
        TRNS,TRNS,TRNS,          TRNS,                    TRNS,FN7, FN6, FN8),
};

const uint16_t PROGMEM fn_actions[] = {
    [0] = ACTION_MODS_TAP_KEY(MOD_RSFT, KC_UP),
    [1] = ACTION_MODS_TAP_KEY(MOD_RGUI, KC_DOWN),
    [2] = ACTION_MODS_TAP_KEY(MOD_RALT, KC_LEFT),
    [3] = ACTION_MODS_TAP_KEY(MOD_RCTL, KC_RIGHT),
    [4] = ACTION_LAYER_MOMENTARY(1),
    [5] = ACTION_MODS_TAP_KEY(MOD_RSFT, KC_PGUP),
    [6] = ACTION_MODS_TAP_KEY(MOD_RGUI, KC_PGDN),
    [7] = ACTION_MODS_TAP_KEY(MOD_RALT, KC_HOME),
    [8] = ACTION_MODS_TAP_KEY(MOD_RCTL, KC_END),
};
Title: Re: TMK keyboard firmware
Post by: RavenII on Tue, 06 October 2015, 13:57:39
See this.

https://github.com/tmk/tmk_keyboard/blob/master/doc/keymap.md#213-modifier-with-tap-keydual-role

Dude....I....I love you. I love all you guys that do all this stuff with the firmware....amazing. Amazing work. You and Metalliqaz...
Title: Re: TMK keyboard firmware
Post by: TheGlow on Tue, 06 October 2015, 14:54:50
Thank you gentlemen! I have compiled it successfully and appears to be doing what I at least wanted it to originally.
I just had some questions. So far to enter bootmode is lshift+rshift+pause. Where would I change that as I didnt see that anywhere.
Config.h had "#define IS_COMMAND() ( \
    keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \"
But no mention of pause.

Some questions from the makefile.lufa,
How does the command menu work?  I dont have it commented out but not sure where I'd bind this to activate. I assume similar to Metalliqaz' where I run in a notepad and follow allong.
Also Mouse keys(+4700), what does the 4700 signify? If there a way to speed up how long the cursor picks up speed and max speed?

How do I work with LEDs? The quickfire-r has the one F9/WinLock LED stuck on. Was wondering how to disable outright and/or have it come on with a specific layer only.

Lastly, how difficult is it to make a macro for something like filling out forms? like type location, tabx5, enter a name, tabx8, etc.
Title: Re: TMK keyboard firmware
Post by: hasu on Tue, 06 October 2015, 15:31:42
As for the command see tmk_core/common/command.c. Or you can use KC_BTLD or KC_BOOTLOADER in keymap.
To start bootloader there are two methods: magic command(Pause) and the BOOTLOADER in keymap.
EDIT: ah, three. third mothod is boot magic command(B).

Use hid_listen to see output from commands and debug prints.

It is just my memo, but it means that the option increases around 4700 bytes in firmware, iirc.

Tune tmk_core/common/mousekey.c to change parameter.

Write code yourself to control your LED.
Title: Re: TMK keyboard firmware
Post by: TheGlow on Thu, 08 October 2015, 07:59:07
Thank you sir.
Forgive me again as I don't know anything about programming really but the command.c looks like it has that area about Mousekey console.
This isn't configured similar to metalliqaz' where it will print to a text file and you interact with it on the fly?
I see i could use both shifts for magic and pause will give bootloader and 0,1,2,3 changed my default layer but others like caps for Lock_enable, v=version  didnt do anything I could see.

Title: Re: TMK keyboard firmware
Post by: hasu on Thu, 08 October 2015, 09:03:09
Ah, I didn't remember that. You can change mouse key parameter using it hopefully.

As I said, use 'hid_listen' tool to see output from magic command. Not text editor.
The Lock command is disabled by default.

Title: Re: TMK keyboard firmware
Post by: RavenII on Thu, 08 October 2015, 11:45:44
If I'm trying to add more levels to the backlight...would it be sufficient enough to replace

Code: [Select]
void tick(void)
{
    if(current_level == 1)
    {
        duty_cycle = 85;
    }
    else if(current_level == 2)
    {
        pos++;
        duty_cycle = pgm_read_byte(&breathing_table[0][pos]);
        if(pos >= 0xff){
            pos = 0;
        }
    }
    else if(current_level == 3)
    {
        duty_cycle = 255;
    }
}

with

Code: [Select]
void tick(void)
{
    if(current_level == 1)
    {
        pos++;
        duty_cycle = pgm_read_byte(&breathing_table[0][pos]);
        if(pos >= 0xff){
            pos = 0;
        }
    }
    else if(current_level == 2)
    {
        duty_cycle = 64;
    }
    else if(current_level == 3)
    {
        duty_cycle = 127;
    }
    else if(current_level == 4)
    {
        duty_cycle = 192;
    }
    else if(current_level == 5)
    {
        duty_cycle = 255;
    }

}

In backlight.c?

Oh, and how would I make it so that the caps lock LED ac....wait, I think I know...let me try first.
Title: Re: TMK keyboard firmware
Post by: TheGlow on Thu, 08 October 2015, 13:26:36
Ah, I didn't remember that. You can change mouse key parameter using it hopefully.

As I said, use 'hid_listen' tool to see output from magic command. Not text editor.
The Lock command is disabled by default.
Just wanted to confirm, is hid_listen restricted to teensys? I had it running and went to town on lshift+rshift and many keys and didnt have anything show up.
Title: Re: TMK keyboard firmware
Post by: skullydazed on Thu, 08 October 2015, 18:27:48
Just wanted to confirm, is hid_listen restricted to teensys? I had it running and went to town on lshift+rshift and many keys and didnt have anything show up.

No, I have been using it on my custom PCB's just fine.
Title: Re: TMK keyboard firmware
Post by: tominabox1 on Thu, 08 October 2015, 18:36:06
Hello all, Hasu, thanks for the awesome firmware!

I am seeing an issue that I can't figure out. When playing a game I am holding WASD a lot obviously but occasionally I will have a stuck key press - the key is obviously not stuck but the game will walk me into dangerous territory occasionally.  Is this a debouncing issue or perhaps these 20 year old switches need to be replaced?  Please advise!

Thanks.
Title: Re: TMK keyboard firmware
Post by: deductivemonkee on Thu, 08 October 2015, 19:01:47
What should I set for rows and cols for alps64 pcb?
Title: Re: TMK keyboard firmware
Post by: a-c on Thu, 08 October 2015, 19:17:07
What should I set for rows and cols for alps64 pcb?

https://github.com/tmk/tmk_keyboard

The alps64 folder is complete. Just modify the keymap and compile.
Title: Re: TMK keyboard firmware
Post by: deductivemonkee on Thu, 08 October 2015, 19:56:45
What should I set for rows and cols for alps64 pcb?

https://github.com/tmk/tmk_keyboard

The alps64 folder is complete. Just modify the keymap and compile.

Thanks, kinda blipped over that... •_•
Title: Re: TMK keyboard firmware
Post by: hasu on Fri, 09 October 2015, 01:08:21
Hello all, Hasu, thanks for the awesome firmware!

I am seeing an issue that I can't figure out. When playing a game I am holding WASD a lot obviously but occasionally I will have a stuck key press - the key is obviously not stuck but the game will walk me into dangerous territory occasionally.  Is this a debouncing issue or perhaps these 20 year old switches need to be replaced?  Please advise!

Thanks.

The key stucking smells like your keymap has any problem, I don't think it comes from your hardware or firmware core part.
Post your keymap file.
Title: Re: TMK keyboard firmware
Post by: tominabox1 on Fri, 09 October 2015, 06:38:22
Hello all, Hasu, thanks for the awesome firmware!

I am seeing an issue that I can't figure out. When playing a game I am holding WASD a lot obviously but occasionally I will have a stuck key press - the key is obviously not stuck but the game will walk me into dangerous territory occasionally.  Is this a debouncing issue or perhaps these 20 year old switches need to be replaced?  Please advise!

Thanks.

The key stucking smells like your keymap has any problem, I don't think it comes from your hardware or firmware core part.
Post your keymap file.


Here you go. All the files I have touched:

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

const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
    /* 0: colemak */
    KEYMAP(ESC,  1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   MINS,EQL, CAPS,      \
           TAB,  Q,   W,   F,   P,   G,   J,   L,   U,   Y,   SCLN, LBRC,RBRC,BSLS,      \
           BSPC, A,   R,   S,   T,   D,   H,   N,   E,   I,   O,QUOT,ENT,            \
                      Z,   X,   C,   V,   B,   K,   M,   COMM,DOT, SLSH,RSFT,          \
           LCTL, LSFT,LALT,LGUI,           FN0,                     RGUI,FN4,FN1),

    /* 1: colemak */
    KEYMAP(GRV, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, MINS,EQL, CAPS,      \
           TAB,  Q,   W,   E,   FN3,   T,   Y, PGUP,  UP,PGDN,    P,LBRC,RBRC,BSPC,      \
           DEL, FN2,   S,   D,   F,   G,   H, LEFT,DOWN,RGHT, SCLN,QUOT,      ENT,            \
                      Z,   X,   C,   V,   B,   K,   M,   COMM,DOT, SLSH,RSFT,          \
           LCTL, LSFT,LALT,LGUI,           FN0,                     RGUI,FN4,FN1),
 /* 1: Gaming */
    KEYMAP(ESC,  1,   2,   3,   4,   5,   6,   7,   8,   9,   0, MINS,EQL, CAPS,      \
           TAB,  Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P, LBRC,RBRC,BSLS,      \
           BSPC, A,   S,   D,   F,  G,   H,   J,   K,   L,   SCLN,QUOT,ENT,            \
                      Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, SLSH,RSFT,          \
           LCTL, LSFT,LALT,LGUI,           SPC,                     RGUI,RALT,FN1),

};

enum macro_id {
    AIDS,
    PRISM,
};


const uint16_t PROGMEM fn_actions[] = {
    ACTION_LAYER_TAP_KEY(1, KC_SPC),            // FN0
    ACTION_LAYER_MOMENTARY(2),                  // FN1
    ACTION_MACRO(AIDS),    // Types aids
    ACTION_MACRO(PRISM),    // Types “/prism “
    ACTION_LAYER_MOMENTARY(1),    // Same as FN0 but does not sent tab on tap
};


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 AIDS:
            return (event.pressed ?
                   MACRO(T(A), T(I), T(D), T(S), END ) :
                    MACRO( END ) );
      case PRISM:
            return (event.pressed ?
                   MACRO(T(SLSH), T(P), T(R), T(I), T(S), T(M), T(SPC), END ) :
                    MACRO( END ) );
     
    }
    return MACRO_NONE;
};

tapping.h
Code: [Select]
/*
Copyright 2013 Jun Wako <wakojun@gmail.com>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ACTION_TAPPING_H
#define ACTION_TAPPING_H



/* period of tapping(ms) */
#ifndef TAPPING_TERM
#define TAPPING_TERM    325
#endif

/* tap count needed for toggling a feature */
#ifndef TAPPING_TOGGLE
#define TAPPING_TOGGLE  5
#endif

#define WAITING_BUFFER_SIZE 8


#ifndef NO_ACTION_TAPPING
void action_tapping_process(keyrecord_t record);
#endif

#endif

matrix.c
Code: [Select]
/*
Copyright 2012 Jun Wako <wakojun@gmail.com>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

/*
 * scan matrix
 */
#include <stdint.h>
#include <stdbool.h>
#include <avr/io.h>
#include <util/delay.h>
#include "print.h"
#include "debug.h"
#include "util.h"
#include "matrix.h"


#ifndef DEBOUNCE
#   define DEBOUNCE 5
#endif
static uint8_t debouncing = DEBOUNCE;

/* matrix state(1:on, 0:off) */
static matrix_row_t matrix[MATRIX_ROWS];
static matrix_row_t matrix_debouncing[MATRIX_ROWS];

static matrix_row_t read_cols(void);
static void init_cols(void);
static void unselect_rows(void);
static void select_row(uint8_t row);


inline
uint8_t matrix_rows(void)
{
    return MATRIX_ROWS;
}

inline
uint8_t matrix_cols(void)
{
    return MATRIX_COLS;
}

void matrix_init(void)
{
    // initialize row and col
    unselect_rows();
    init_cols();

    // initialize matrix state: all keys off
    for (uint8_t i=0; i < MATRIX_ROWS; i++) {
        matrix[i] = 0;
        matrix_debouncing[i] = 0;
    }
}

uint8_t matrix_scan(void)
{
    for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
        select_row(i);
        _delay_us(30);  // without this wait read unstable value.
        matrix_row_t cols = read_cols();
        if (matrix_debouncing[i] != cols) {
            matrix_debouncing[i] = cols;
            if (debouncing) {
                debug("bounce!: "); debug_hex(debouncing); debug("\n");
            }
            debouncing = DEBOUNCE;
        }
        unselect_rows();
    }

    if (debouncing) {
        if (--debouncing) {
            _delay_ms(1);
        } else {
            for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
                matrix[i] = matrix_debouncing[i];
            }
        }
    }

    return 1;
}

bool matrix_is_modified(void)
{
    if (debouncing) return false;
    return true;
}

inline
bool matrix_is_on(uint8_t row, uint8_t col)
{
    return (matrix[row] & ((matrix_row_t)1<<col));
}

inline
matrix_row_t matrix_get_row(uint8_t row)
{
    return matrix[row];
}

void matrix_print(void)
{
    print("\nr/c 0123456789ABCDEF\n");
    for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
        phex(row); print(": ");
        pbin_reverse16(matrix_get_row(row));
        print("\n");
    }
}

uint8_t matrix_key_count(void)
{
    uint8_t count = 0;
    for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
        count += bitpop16(matrix[i]);
    }
    return count;
}

/* Column pin configuration
 * col: 0   1   2   3   4   5   6   7   8   9   10  11  12  13
 * pin: B6  F7  F6  F5  F4  F1  F0  B0  B1  B2  B3  B7  D0  D1  (Rev.A)
 */
static void  init_cols(void)
{
    // Input with pull-up(DDR:0, PORT:1)
    DDRB  &= ~(1<<6 | 1<<0 | 1<<1 | 1<<2 | 1<<3 | 1<<7);
    PORTB |=  (1<<6 | 1<<0 | 1<<1 | 1<<2 | 1<<3 | 1<<7);
    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<<0 | 1<<1);
    PORTD |=  (1<<0 | 1<<1);
   
}

static matrix_row_t read_cols(void)
{
    return (PINB&(1<<6) ? 0 : (1<<0)) |
           (PINF&(1<<7) ? 0 : (1<<1)) |
           (PINF&(1<<6) ? 0 : (1<<2)) |
           (PINF&(1<<5) ? 0 : (1<<3)) |
           (PINF&(1<<4) ? 0 : (1<<4)) |
           (PINF&(1<<1) ? 0 : (1<<5)) |
           (PINF&(1<<0) ? 0 : (1<<6)) |
           (PINB&(1<<0) ? 0 : (1<<7)) |
           (PINB&(1<<1) ? 0 : (1<<8)) |
           (PINB&(1<<2) ? 0 : (1<<9)) |
           (PINB&(1<<3) ? 0 : (1<<10)) |
           (PINB&(1<<7) ? 0 : (1<<11)) |
           (PIND&(1<<0) ? 0 : (1<<12)) |
           (PIND&(1<<1) ? 0 : (1<<13));
}

/* Row pin configuration
 * row: 0   1   2   3   4
 * pin: D2  D3  C6  C7  D5
 */
static void unselect_rows(void)
{
    // Hi-Z(DDR:0, PORT:0) to unselect
    DDRD  &= ~0b00101100;
    PORTD &= ~0b00101100;
    DDRC  &= ~0b11000000;
    PORTC &= ~0b11000000;
}

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<<3);
            PORTD &= ~(1<<3);
            break;
        case 2:
            DDRC  |= (1<<6);
            PORTC &= ~(1<<6);
            break;
        case 3:
            DDRC  |= (1<<7);
            PORTC &= ~(1<<7);
            break;
        case 4:
            DDRD  |= (1<<5);
            PORTD &= ~(1<<5);
            break;
    }
}

config.h
Code: [Select]
/*
Copyright 2012 Jun Wako <wakojun@gmail.com>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#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         GH60
#define DESCRIPTION     t.m.k. keyboard firmware for GH60

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

/* 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)) \
)



/*
 * Feature disable options
 *  These options are also useful to firmware size reduction.
 */

/* disable debug print */
//#define NO_DEBUG

/* disable print */
//#define NO_PRINT

/* disable action features */
//#define NO_ACTION_LAYER
//#define NO_ACTION_TAPPING
//#define NO_ACTION_ONESHOT
//#define NO_ACTION_MACRO
//#define NO_ACTION_FUNCTION

#endif
Title: Re: TMK keyboard firmware
Post by: RavenII on Fri, 09 October 2015, 10:41:15
Well my experiment failed...but I figured I could just use the 3 levels at 85, 170, 255 instead and ditch the pulsating, I'm fine with that....my question now is...

With the caps lock PB2 and the rest of my LEDs being on PB6, how would I disable the caps lock LED functionality and make PB2 work with PB6?...?

I know thought I could comment out the led.c file in the Makefile, but what do I do with PORTB |= (1<<6); and PORTB &= ~(1<<6); in the backlight.c file?

Could I just do something like PORTB |= (1<<6);(1<<2) ?? Didn't work...
Title: Re: TMK keyboard firmware
Post by: RavenII on Fri, 09 October 2015, 10:41:55
Double post...
Title: Re: TMK keyboard firmware
Post by: a-c on Fri, 09 October 2015, 12:16:38
Well my experiment failed...but I figured I could just use the 3 levels at 85, 170, 255 instead and ditch the pulsating, I'm fine with that....my question now is...

With the caps lock PB2 and the rest of my LEDs being on PB6, how would I disable the caps lock LED functionality and make PB2 work with PB6?...?

I know thought I could comment out the led.c file in the Makefile, but what do I do with PORTB |= (1<<6); and PORTB &= ~(1<<6); in the backlight.c file?

Could I just do something like PORTB |= (1<<6);(1<<2) ?? Didn't work...

B6 is a PWM pin. B2 is not. So you will not be able to do the same brightness control. B2 is on or off only, you could try simulating PWM by turning it on and off rapidly, but that eats CPU cycles.

B2 is also wired differently. B6 is driving a transistor to source current to the LEDs. B2 is the opposite sinking current. http://www.petervis.com/Raspberry_PI/Driving_LEDs_with_CMOS_and_TTL_Outputs/Current_Sinking_and_Sourcing_in_Digital_Circuits.html

This makes it difficult to 'disconnect' the caps lock LED from B2 and connect it to B6. The trace you need to cut is on the top side of the PCB (under the plate).
(http://i.imgur.com/eaIPh7j.png)
Title: Re: TMK keyboard firmware
Post by: RavenII on Fri, 09 October 2015, 13:06:47
B6 is a PWM pin. B2 is not. So you will not be able to do the same brightness control. B2 is on or off only, you could try simulating PWM by turning it on and off rapidly, but that eats CPU cycles.

B2 is also wired differently. B6 is driving a transistor to source current to the LEDs. B2 is the opposite sinking current. http://www.petervis.com/Raspberry_PI/Driving_LEDs_with_CMOS_and_TTL_Outputs/Current_Sinking_and_Sourcing_in_Digital_Circuits.html

This makes it difficult to 'disconnect' the caps lock LED from B2 and connect it to B6. The trace you need to cut is on the top side of the PCB (under the plate).
Show Image
(http://i.imgur.com/eaIPh7j.png)


Interesting, that was a great explanation. Thanks for the response. I suppose I could repurpose the caps lock as some sort of indicator...layer/function...etc. Maybe I'll tackle that one of these days. For now, I'll move on to my next idea...and that is to install a capacitor in the circuit to minimize the flickering that PWM causes due to the on/off switching......

Thanks again a-c
Title: Re: TMK keyboard firmware
Post by: hasu on Sat, 10 October 2015, 00:18:08
Hello all, Hasu, thanks for the awesome firmware!

I am seeing an issue that I can't figure out. When playing a game I am holding WASD a lot obviously but occasionally I will have a stuck key press - the key is obviously not stuck but the game will walk me into dangerous territory occasionally.  Is this a debouncing issue or perhaps these 20 year old switches need to be replaced?  Please advise!

Thanks.

The key stucking smells like your keymap has any problem, I don't think it comes from your hardware or firmware core part.
Post your keymap file.


Here you go. All the files I have touched:

How do you change to layer 2(gaming)? you have a mechanical lock switch on FN1? or use command Lshift+Rshift+2?

Your gaming layer is almost ok and you won't have key stucking as long as you don't touch FN1 accidentally. If you touch FN1 and space at same time space can be stuck. But other keys won't be stuck.

What's your keyboard and OS? And how do you walk in the game?

You have #define MATRIX_HAS_GHOST in config.h, your keyobard doesn't have diodes on matrix? It enalbs TMK ghost blocking code for a lame keyboard without diodes. The ghost blocking code is not used much, may have bug.

Are you using USB NKRO? If so disable it and test it again.
Title: Re: TMK keyboard firmware
Post by: tominabox1 on Sat, 10 October 2015, 08:03:17
Hello all, Hasu, thanks for the awesome firmware!

I am seeing an issue that I can't figure out. When playing a game I am holding WASD a lot obviously but occasionally I will have a stuck key press - the key is obviously not stuck but the game will walk me into dangerous territory occasionally.  Is this a debouncing issue or perhaps these 20 year old switches need to be replaced?  Please advise!

Thanks.

The key stucking smells like your keymap has any problem, I don't think it comes from your hardware or firmware core part.
Post your keymap file.


Here you go. All the files I have touched:

How do you change to layer 2(gaming)? you have a mechanical lock switch on FN1? or use command Lshift+Rshift+2?

Your gaming layer is almost ok and you won't have key stucking as long as you don't touch FN1 accidentally. If you touch FN1 and space at same time space can be stuck. But other keys won't be stuck.

What's your keyboard and OS? And how do you walk in the game?

You have #define MATRIX_HAS_GHOST in config.h, your keyobard doesn't have diodes on matrix? It enalbs TMK ghost blocking code for a lame keyboard without diodes. The ghost blocking code is not used much, may have bug.

Are you using USB NKRO? If so disable it and test it again.

Layer 2 is switched with a locking alps switch.

I'm on OS X and the keyboard is a handwired 60% using alps switches.

I have a full diode array so I should switch this. Just needs commented out right?

I was not using NKRO so I will try it with.

I had initially built the board up without diodes so thats why there's some oddity with the ghosting thing. The board has diodes now. I will report if it seems to help.
Title: Re: TMK keyboard firmware
Post by: tominabox1 on Sat, 10 October 2015, 09:57:52
Well I made the changes suggested and the problem still cropped up. It seems like it's only with the D key so I end up strafing. I replaced the switch and that didn't help.

I will try swapping between NKRO and non- and see if that helps.
Title: Re: TMK keyboard firmware
Post by: nephiel on Mon, 12 October 2015, 07:00:55
Sizes: full cygwin is a beast, you don't need all that stuff; there should be a way to select a "base" installation, plus "development tools". But msys should be fine as well.

Times: it should definitely not take 3-4 minutes to compile, but something like 10 seconds on modern computers (and most of *that* time might be locating, reading and writing files ;)

Commenting: '#' in C does not mean a comment, but a special type of "command" (which is actually not a C command, it is processed by the C preprocessor). Commenting in C (plus plus) is done by 'double slash':
Code: [Select]
// this is a comment
or more traditionally by
Code: [Select]
/* this is a comment */

EDIT: yea, got owned again.
Many thanks. I know enough to shamble my way through some things.
I'll try to compile again after a reboot perhaps. I don't have much running but I would expect an i7 with 16gb memory meet the recommended specs.
Just odd the others were faster and this msys clearly not same speed.
Rebooted, about 1 min, 3 seconds now. A bit better.

I've been on the bare build all day and its seeming pretty good. Just a few extra spaces on occasion but i think that just might be user error.

Edit: heres why I thought that. In the linked how to, he clearly states # is to comment out.
http://deskthority.net/workshop-f7/how-to-build-your-very-own-keyboard-firmware-t7177.html

Just to clarify: that specific file in the linked how to is a Makefile, not a C source file. Makefiles do use # to comment out a line. https://www.gnu.org/software/make/manual/make.html#Makefile-Contents
Title: Re: TMK keyboard firmware
Post by: TheGlow on Mon, 12 October 2015, 13:11:29
Just to clarify: that specific file in the linked how to is a Makefile, not a C source file. Makefiles do use # to comment out a line. https://www.gnu.org/software/make/manual/make.html#Makefile-Contents
Thanks for that. I noticed it after but good hear confirmation on it.
Title: Re: TMK keyboard firmware
Post by: tominabox1 on Mon, 12 October 2015, 15:10:53
Little update on my key sticking problem.  I made some changes but I still seem to get some occasional sticking. At least now if I tap the sticking key a few times it goes away.  It does not seem to be limited to a single key either.  Right now with NKRO turned OFF and the debouncing at 7, the sticking is rare.  I am using 30 year old switches so there may be something to the debouncing being the problem, but its only when I have been holding the key for a long period of time (>1 second) when the issue seems to pop up.

I'm not quite sure where else to look. Disassembling the switches and lubricating is an option if it may help. I wish I had my scope so I could check the debouncing but everything is in storage right now.
Title: Re: TMK keyboard firmware
Post by: hasu on Mon, 12 October 2015, 16:12:56
hmm, did you try other os than OSX? On Windows or Linux, can you see the sticking keys?
"Holding key long" reminds me OSX key repeating problem which was fixed in ad hoc way.

What is version of your OSX? 10.11? They might have made change there in the latest update, perhapse.
Title: Re: TMK keyboard firmware
Post by: tominabox1 on Mon, 12 October 2015, 16:14:30
hmm, did you try other os than OSX? On Windows or Linux, can you see the sticking keys?
"Holding key long" reminds me OSX key repeating problem which was fixed in ad hoc way.

What is version of your OSX? 10.11? They might have made change there in the latest update, perhapse.
I have not tried another system. I am on 10.11.

I have not had this problem with other keyboards though
Title: Re: TMK keyboard firmware
Post by: hasu on Mon, 12 October 2015, 16:23:16
Yep, the repeating problem is specifice to tmk. Try windows or linux, to see if you see your problem on those.
EDIT: the other keyboards also use TMK firmware?

And use hid_listen on OSX to see matrix state and key report. You can enable debug output with magic commands; X and K. By default these are assigned to LShift+RShift+x and LShift+RShift+k. You will see output like the following.

Code: [Select]
r/c 0123456789ABCDEF
00: 0000000000000000
01: 0000000000000000
02: 0000000000000000
03: 0010000000000000
04: 0000010000000000
05: 0000000000000000
06: 0000000000000000
07: 0000000000000000
keyboard_report: 01 00 08 00 00 00 00 00

r/c 0123456789ABCDEF
00: 0000000000000000
01: 0000000000000000
02: 0000000000000000
03: 0010000000000000
04: 0000000000000000
05: 0000000000000000
06: 0000000000000000
07: 0000000000000000
keyboard_report: 01 00 00 00 00 00 00 00

r/c 0123456789ABCDEF
00: 0000000000000000
01: 0000000000000000
02: 0000000000000000
03: 0000000000000000
04: 0000000000000000
05: 0000000000000000
06: 0000000000000000
07: 0000000000000000
keyboard_report: 00 00 00 00 00 00 00 00

r/c 0123456789ABCDEF
00: 0000000000000000
01: 0000000000000000
02: 0001000000000000
03: 0000000000000000
04: 0000000000000000
05: 0000000000000000
06: 0000000000000000
07: 0000000000000000

r/c 0123456789ABCDEF
00: 0000000000000000
01: 0000000000000000
02: 0000000000000000
03: 0000000000000000
04: 0000000000000000
05: 0000000000000000
06: 0000000000000000
07: 0000000000000000
keyboard_report: 00 00 28 00 00 00 00 00
keyboard_report: 00 00 00 00 00 00 00 00


Title: Re: TMK keyboard firmware
Post by: tominabox1 on Mon, 12 October 2015, 17:26:13
OK I have HID listen running but I'm not sure what to be looking for.

Edit: no the other keyboards to not use TMK.  I am seeing a lot of "bounce!" messages in the hid_listen but I'm not sure that is bad.
Title: Re: TMK keyboard firmware
Post by: TheGlow on Tue, 13 October 2015, 09:07:02
Is there much different between the keymap.h and .c?
For the frosty flake theres a keymap.c which is very basic but then keymap_ansi.h which is where I applied my configs and so far its working fine.
In trying to get the macros to work I see the example in keymap_hasu.c
I tried to copy/paste into my ansi.h. It compiled without errors but doesnt look like it did anything.

At least for the LED I realized the F9 winlock was actually indicating the numlock status. I removed those lines and it doesn't light up now. I think thats good enough for me for now.

Just an inquiry for macros before I put too much effort in and find out it doesnt do what I'd like.
I can modify wait times between inputs and what not? I have some online forms that sometimes you need to wait 1 or so seconds from a previous entry before it processes and populates choices for the next field. so simple stuff like a text string, tab x7, text, wait, tab, text, etc.
Title: Re: TMK keyboard firmware
Post by: mrbishop on Wed, 14 October 2015, 07:37:42
well i'm in over my head i think. i have the keyboard wired and mounted but for the life of me i can't get any keystrokes to be returned when i use my modified code. when i use the phantom un changed code i get keystrokes but not the right ones and not for all keys. i blame my lack of understanding of the firmware. have pity on me.

what i've done and or included:
made the hex file
included wiring map with pinout
entire keyboard folder with all current files.

if i can just get alittle help getting started on the firmware keymap or what ever is stopping me from getting keystrokes i can likely figure the rest out. please help.  :-[
Title: Re: TMK keyboard firmware
Post by: a-c on Wed, 14 October 2015, 11:22:02
well i'm in over my head i think. i have the keyboard wired and mounted but for the life of me i can't get any keystrokes to be returned when i use my modified code. when i use the phantom un changed code i get keystrokes but not the right ones and not for all keys. i blame my lack of understanding of the firmware. have pity on me.

what i've done and or included:
made the hex file
included wiring map with pinout
entire keyboard folder with all current files.

if i can just get alittle help getting started on the firmware keymap or what ever is stopping me from getting keystrokes i can likely figure the rest out. please help.  :-[

Which direction did you install your diodes?
Title: Re: TMK keyboard firmware
Post by: mrbishop on Wed, 14 October 2015, 11:49:26
well i'm in over my head i think. i have the keyboard wired and mounted but for the life of me i can't get any keystrokes to be returned when i use my modified code. when i use the phantom un changed code i get keystrokes but not the right ones and not for all keys. i blame my lack of understanding of the firmware. have pity on me.

what i've done and or included:
made the hex file
included wiring map with pinout
entire keyboard folder with all current files.

if i can just get alittle help getting started on the firmware keymap or what ever is stopping me from getting keystrokes i can likely figure the rest out. please help.  :-[

Which direction did you install your diodes?
Black bar down towards the run. They keyboard does return incorrect keystrokes when using the default phantom firmware. So something is done right at least
Title: Re: TMK keyboard firmware
Post by: a-c on Wed, 14 October 2015, 12:41:10
well i'm in over my head i think. i have the keyboard wired and mounted but for the life of me i can't get any keystrokes to be returned when i use my modified code. when i use the phantom un changed code i get keystrokes but not the right ones and not for all keys. i blame my lack of understanding of the firmware. have pity on me.

what i've done and or included:
made the hex file
included wiring map with pinout
entire keyboard folder with all current files.

if i can just get alittle help getting started on the firmware keymap or what ever is stopping me from getting keystrokes i can likely figure the rest out. please help.  :-[

Which direction did you install your diodes?
Black bar down towards the run. They keyboard does return incorrect keystrokes when using the default phantom firmware. So something is done right at least

You have more than 16 columns. See the section under Misc in the FAQ. https://github.com/tmk/tmk_keyboard/wiki/FAQ

You could also just put the two keys 1 and t on the first or last column since they have unused rows. Then you would only have 16 columns and save a pin for something else.

Though you should still get output from the other columns. Post a picture of your wiring.
Title: Re: TMK keyboard firmware
Post by: mrbishop on Wed, 14 October 2015, 16:42:51
well i'm in over my head i think. i have the keyboard wired and mounted but for the life of me i can't get any keystrokes to be returned when i use my modified code. when i use the phantom un changed code i get keystrokes but not the right ones and not for all keys. i blame my lack of understanding of the firmware. have pity on me.

what i've done and or included:
made the hex file
included wiring map with pinout
entire keyboard folder with all current files.

if i can just get alittle help getting started on the firmware keymap or what ever is stopping me from getting keystrokes i can likely figure the rest out. please help.  :-[

Which direction did you install your diodes?
Black bar down towards the run. They keyboard does return incorrect keystrokes when using the default phantom firmware. So something is done right at least

You have more than 16 columns. See the section under Misc in the FAQ. https://github.com/tmk/tmk_keyboard/wiki/FAQ

You could also just put the two keys 1 and t on the first or last column since they have unused rows. Then you would only have 16 columns and save a pin for something else.

Though you should still get output from the other columns. Post a picture of your wiring.

i added 1UL<< replacing all the 1<< in the column definition section. still nothing.

the keyboard has a standard ANSI layout more or less. all the data files will be attached in a ZIP
Title: Re: TMK keyboard firmware
Post by: VinnyCordeiro on Wed, 14 October 2015, 18:24:24
Atmel Studio 7 was recently released. Does anyone use this IDE to compile TMK? The manual says that it supports:

Quote
ARM GCC Toolchain 4.9.3 with upstream versions:
  • gcc 4.9 (revision 221220)
  • Binutils 2.24
  • gdb 7.8.0.20150304-cvs

Theoretically speaking, it is possible. While I wait for an answer I'll try it myself.
Title: Re: TMK keyboard firmware
Post by: a-c on Wed, 14 October 2015, 20:32:17
i added 1UL<< replacing all the 1<< in the column definition section. still nothing.

the keyboard has a standard ANSI layout more or less. all the data files will be attached in a ZIP

An actual photograph of your wiring.
Title: Re: TMK keyboard firmware
Post by: mrbishop on Wed, 14 October 2015, 21:43:31
You laugh I cry (http://images.tapatalk-cdn.com/15/10/14/bf481f6965da2a4ee9381f9d4cad0045.jpg)(http://images.tapatalk-cdn.com/15/10/14/3d860374a570ee070912a0eb57aaec6d.jpg)
Title: Re: TMK keyboard firmware
Post by: a-c on Wed, 14 October 2015, 22:39:34
You laugh I cry

The Phantom PCB is wired opposite of what most TMK handwire jobs are done. If all your diodes were installed backwards it would work. You could start with a different keyboard like the GH60 which is wired the way you did, or just switch all the rows to cols and cols to rows in your current matrix. You will have to adjust your keymap to make sense.
Title: Re: TMK keyboard firmware
Post by: mrbishop on Wed, 14 October 2015, 22:43:27
You laugh I cry

The Phantom PCB is wired opposite of what most TMK handwire jobs are done. If all your diodes were installed backwards it would work. You could start with a different keyboard like the GH60 which is wired the way you did, or just switch all the rows to cols and cols to rows in your current matrix. You will have to adjust your keymap to make sense.
Hmmm. I'll give the GH60 a shot and see if I have any luck. All the layouts are new to me as this is my first project. I'll update tomorrow if I can.
Title: Re: TMK keyboard firmware
Post by: mrbishop on Thu, 15 October 2015, 07:03:09
Haha that kinda worked. Its super off but it’s a start. Most of the keys are returning keystrokes now however they are pretty backwards. But it’s a start.

For refference
2= home
5=’=’
6=-
7=0
8=9
9=8
0=7
-=6
==5
G=;
F=‘
J=k
K=J
L=H
;=G
‘=f
U=
Enter=d
Backspace=4
N=m
M=n
T=
Y=[
Title: Re: TMK keyboard firmware
Post by: tominabox1 on Thu, 15 October 2015, 07:37:04
Hasu, I think I figured out my problem with the key sticking - I was changing the wrong debouncing value in the config.h.

I also have the code working to have an LED come on when an alternate layer is activated, as well as a single toggleable backlight LED.  Once I figure out how to fork the code on git, I will post a link.
Title: Re: TMK keyboard firmware
Post by: justinyhuang on Fri, 16 October 2015, 11:27:42
i am not sure if this has been discussed before:
is there a way to toggle the LED/backlights when a new layer has been switched to, or a key has been pressed?
i see in the code that there are macros to manipulate the LED status, but wonder how to use the macros to achieve the requirement above...
any pointers would be appeciated.

thanks,
Title: Re: TMK keyboard firmware
Post by: tominabox1 on Fri, 16 October 2015, 11:51:29
i am not sure if this has been discussed before:
is there a way to toggle the LED/backlights when a new layer has been switched to, or a key has been pressed?
i see in the code that there are macros to manipulate the LED status, but wonder how to use the macros to achieve the requirement above...
any pointers would be appeciated.

thanks,

I have code that will light up an LED when a layer that is not the default layer is selected.  I will try to figure out how to upload my code to git tonight. I have been meaning to.
Title: Re: TMK keyboard firmware
Post by: justinyhuang on Fri, 16 October 2015, 11:58:17
I have code that will light up an LED when a layer that is not the default layer is selected.  I will try to figure out how to upload my code to git tonight. I have been meaning to.

thank you tominabox1! that would be very helpful.
Title: Re: TMK keyboard firmware
Post by: nephiel on Fri, 16 October 2015, 16:24:40
i am not sure if this has been discussed before:
is there a way to toggle the LED/backlights when a new layer has been switched to, or a key has been pressed?
i see in the code that there are macros to manipulate the LED status, but wonder how to use the macros to achieve the requirement above...
any pointers would be appeciated.

thanks,


I have a LED set up to turn on while the Fn layer is active.
In addition my CapsLock key LED turns into NumLock LED while the Numpad layer is active.
Code here (https://github.com/Nephiel/tmk_keyboard/commit/12debc691f1de77131a9b735101075372ee43010) and here (https://github.com/Nephiel/tmk_keyboard/blob/master/keyboard/nph60/led.c).

There probably is a more elegant way to do it, but this one worked for me.
Title: Re: TMK keyboard firmware
Post by: tominabox1 on Fri, 16 October 2015, 20:29:03
I finally figured out how to get my changes up but its a bit confusing because I didn't do the commit right but you can see where some of the changes are

https://github.com/tominabox1/tmk_keyboard/commit/5e1625db3ad92c23bb17b3fde1e3a226370a9df0
Title: Re: TMK keyboard firmware
Post by: KHAANNN on Sat, 17 October 2015, 13:49:00
Would it be possible to:

1) Switch a layer-activator-key to be right-shift until it's switched back
2) Report NumLock while this mode is activated with the usb-usb converter

Pretty much like how KBParadise V60's let arrow-mode and modifier-mode to be switched, when the arrow mode is on, the side-led lights up, so it's easy to differentiate modes (2) is for this reason

I normally don't use the right shift, yet I rarely need it, and the layer change shortcomings of tmk doesn't let me put the R-Shift on a layer (it seemed impossible to do it with consistency, when you release the layer key before the assigned shift, the shift gets stuck etc.)
Title: Re: TMK keyboard firmware
Post by: building_an_ergo on Sun, 18 October 2015, 05:45:11
Hello,

I am trying to figure out tmkkeyboard for the first time.

I figured out how to edit to keymap.c to make it what I want, and how to compile it in windows (which was a pain). 

My question is how to make a key macro however.  What I want is for one key to act as if I had pressed Shift+Alt.  This is the windows shortcut to change languages, and is pretty much the last thing I need to make my perfect layout.

Does anyone know how to do this?  The documentation isn't exactly clear (at least not to me).

If it makes any difference, I am using the cub-unic ergodox fork.
Title: Re: TMK keyboard firmware
Post by: tominabox1 on Sun, 18 October 2015, 07:05:00
Hello,

I am trying to figure out tmkkeyboard for the first time.

I figured out how to edit to keymap.c to make it what I want, and how to compile it in windows (which was a pain). 

My question is how to make a key macro however.  What I want is for one key to act as if I had pressed Shift+Alt.  This is the windows shortcut to change languages, and is pretty much the last thing I need to make my perfect layout.

Does anyone know how to do this?  The documentation isn't exactly clear (at least not to me).

If it makes any difference, I am using the cub-unic ergodox fork.

if you made a macro key it would still have to be a 2 key operation unless you put it on your default layer I guess... if it were me I would just leave it.
Title: Re: TMK keyboard firmware
Post by: building_an_ergo on Sun, 18 October 2015, 07:40:30
if you made a macro key it would still have to be a 2 key operation unless you put it on your default layer I guess... if it were me I would just leave it.

Which is exactly what I would like to do.  I have one free space on my current default layer it would be perfect for.
Title: Re: TMK keyboard firmware
Post by: tominabox1 on Sun, 18 October 2015, 08:43:40
if you made a macro key it would still have to be a 2 key operation unless you put it on your default layer I guess... if it were me I would just leave it.

Which is exactly what I would like to do.  I have one free space on my current default layer it would be perfect for.

Should be something like this:
Code: [Select]
/*
 * Macro definition
 */
const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
{
    switch (id) {
        case SHIFT_ALT:
            return (record->event.pressed ?
                    MACRO( D(LALT), D(LSHFT), END ) :
                    MACRO( U(LALT), U(LSHFT), END ));
    }
    return MACRO_NONE;
}

Then in your fn definitions you would put:

Code: [Select]
[8] = ACTION_MACRO(SHIFT_ALT),
Where the number in brackets is your Fn number (FN8) here - then that goes in your keymap.
Title: Re: TMK keyboard firmware
Post by: building_an_ergo on Sun, 18 October 2015, 10:09:20
I think I have done fn actions before.  It would be something like this in the keymap.c?
Code: [Select]
/*
 * Fn action definition
 */
static const uint16_t PROGMEM fn_actions[] = {
    ACTION_FUNCTION(TEENSY_KEY),                    // FN0 - Teensy key
    ACTION_LAYER_MOMENTARY(1),                      // FN1 - switch to Layer1
    ACTION_LAYER_SET(2, ON_PRESS),                  // FN2 - set Layer2
    ACTION_LAYER_TOGGLE(3),                         // FN3 - toggle Layer3 aka Numpad layer
    ACTION_LAYER_SET(0, ON_PRESS),                  // FN4 - set Layer0
    ACTION_LAYER_TOGGLE(1),                         // FN5 - toggle Layer1 aka F Keys
    ACTION_MACRO(SHIFT_ALT),     // FN6 - Language Change
};

Would the macro definition also be in the keymap?
Title: Re: TMK keyboard firmware
Post by: flabbergast on Sun, 18 October 2015, 10:23:15
Correct. All of this is happening in keymap.c file. To assign the macro to a key, just use 'FN6' for that key in the definition of your keymap. Similar example is also referenced in the official TMK keymap FAQ (https://github.com/tmk/tmk_keyboard/wiki/FAQ-Keymap) file, namely this one (http://deskthority.net/workshop-f7/tmk-keyboard-firmware-collection-t4478-120.html#p195620).
Title: Re: TMK keyboard firmware
Post by: building_an_ergo on Sun, 18 October 2015, 10:42:53
So after looking at the example, I assumed the macro definition should look like this:

Code: [Select]
/*
 * Macro definition
 */
enum macro_id {
    SHIFT_ALT,
};
const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
{
    switch (id) {
        case SHIFT_ALT:
            return (record->event.pressed ?
                    MACRO( D(LALT), D(LSFT), END ) :
                    MACRO( U(LALT), U(LSFT), END ));
    }
    return MACRO_NONE;
}

It compiled, but doesn't seem to output anything at all.  :confused:
Title: Re: TMK keyboard firmware
Post by: tominabox1 on Sun, 18 October 2015, 10:44:52
So after looking at the example, I assumed the macro definition should look like this:

Code: [Select]
/*
 * Macro definition
 */
enum macro_id {
    SHIFT_ALT,
};
const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
{
    switch (id) {
        case SHIFT_ALT:
            return (record->event.pressed ?
                    MACRO( D(LALT), D(LSFT), END ) :
                    MACRO( U(LALT), U(LSFT), END ));
    }
    return MACRO_NONE;
}

It compiled, but doesn't seem to output anything at all.  :confused:

Can you post your whole keymap file
Title: Re: TMK keyboard firmware
Post by: building_an_ergo on Sun, 18 October 2015, 11:03:27
Can you post your whole keymap file

Sure, here it is:

Code: [Select]
/*
Copyright 2013 Oleg Kostyuk <cub.uanic@gmail.com>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdint.h>
#include <stdbool.h>
#include <avr/pgmspace.h>
#include <util/delay.h>
#include "keycode.h"
#include "action.h"
#include "action_util.h"
#include "action_code.h"
#include "action_macro.h"
#include "action_layer.h"
#include "bootloader.h"
#include "report.h"
#include "host.h"
#include "print.h"
#include "debug.h"
#include "keymap.h"
#include "ergodox.h"


/* ErgoDox keymap definition macro */
#define KEYMAP(                                                 \
                                                                \
    /* left hand, spatial positions */                          \
    k00,k01,k02,k03,k04,k05,k06,                                \
    k10,k11,k12,k13,k14,k15,k16,                                \
    k20,k21,k22,k23,k24,k25,                                    \
    k30,k31,k32,k33,k34,k35,k36,                                \
    k40,k41,k42,k43,k44,                                        \
                            k55,k56,                            \
                                k54,                            \
                        k53,k52,k51,                            \
                                                                \
    /* right hand, spatial positions */                         \
        k07,k08,k09,k0A,k0B,k0C,k0D,                            \
        k17,k18,k19,k1A,k1B,k1C,k1D,                            \
            k28,k29,k2A,k2B,k2C,k2D,                            \
        k37,k38,k39,k3A,k3B,k3C,k3D,                            \
                k49,k4A,k4B,k4C,k4D,                            \
    k57,k58,                                                    \
    k59,                                                        \
    k5C,k5B,k5A )                                               \
                                                                \
   /* matrix positions */                                       \
   {                                                            \
    { KC_##k00,KC_##k10,KC_##k20,KC_##k30,KC_##k40,KC_NO   },   \
    { KC_##k01,KC_##k11,KC_##k21,KC_##k31,KC_##k41,KC_##k51},   \
    { KC_##k02,KC_##k12,KC_##k22,KC_##k32,KC_##k42,KC_##k52},   \
    { KC_##k03,KC_##k13,KC_##k23,KC_##k33,KC_##k43,KC_##k53},   \
    { KC_##k04,KC_##k14,KC_##k24,KC_##k34,KC_##k44,KC_##k54},   \
    { KC_##k05,KC_##k15,KC_##k25,KC_##k35,KC_NO,   KC_##k55},   \
    { KC_##k06,KC_##k16,KC_NO,   KC_##k36,KC_NO,   KC_##k56},   \
                                                                \
    { KC_##k07,KC_##k17,KC_NO,   KC_##k37,KC_NO,   KC_##k57},   \
    { KC_##k08,KC_##k18,KC_##k28,KC_##k38,KC_NO,   KC_##k58},   \
    { KC_##k09,KC_##k19,KC_##k29,KC_##k39,KC_##k49,KC_##k59},   \
    { KC_##k0A,KC_##k1A,KC_##k2A,KC_##k3A,KC_##k4A,KC_##k5A},   \
    { KC_##k0B,KC_##k1B,KC_##k2B,KC_##k3B,KC_##k4B,KC_##k5B},   \
    { KC_##k0C,KC_##k1C,KC_##k2C,KC_##k3C,KC_##k4C,KC_##k5C},   \
    { KC_##k0D,KC_##k1D,KC_##k2D,KC_##k3D,KC_##k4D,KC_NO   }    \
   }

#if defined(KEYMAP_DVORAK)
#include "keymap_dvorak.h"
#elif defined(KEYMAP_COLEMAK)
#include "keymap_colemak.h"
#elif defined(KEYMAP_WORKMAN)
#include "keymap_workman.h"
#elif defined(KEYMAP_MICRO)
#include "keymap_micro.h"
#elif defined(KEYMAP_CUB)
#include "keymap_cub.h"
#else

static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
KEYMAP(  // layout: layer 0: default
        // left hand
        ESC, 1,   2,   3,   4,   5,   GRV,
        TAB, Q,   W,   E,   R,   T,   MINUS,
        CAPS,A,   S,   D,   F,   G,
        LSFT,Z,   X,   C,   V,   B,   EQL,
        LCTL, LEFT,UP,  DOWN,RGHT,
                                      LALT, HOME,
                                           END,
                                 SPC,DELETE, LGUI,
        // right hand
             QUOT,6,   7,   8,   9,   0,   BSPC,
             RBRC, Y,   U,   I,   O,   P,   BSLS,
                  H,   J,   K,   L,   SCLN,ENT,
             LBRC, N,   M,   COMM,DOT, SLSH,RSFT,
                       PSCR, F12, FN6, KANA,RCTL,
        PGUP,RALT,
        PGDN,
        RGUI, ENT, FN1
    ),

    KEYMAP(  // layer 1 : function and symbol keys
        // left hand
        TRNS,F1,  F2,  F3,  F4,  F5,  F11,
        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,FN4,
        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,
        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,
        TRNS,TRNS,TRNS,TRNS,TRNS,
                                      TRNS,TRNS,
                                           TRNS,
                                 TRNS,TRNS,TRNS,
        // right hand
             F12, F6,  F7,  F8,  F9,  F10, TRNS,
             FN4,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
    ),

    KEYMAP(  // layer 2 : keyboard functions
        // left hand
        FN0, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,
        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,FN4,
        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,
        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,
        TRNS,TRNS,TRNS,TRNS,TRNS,
                                      TRNS,TRNS,
                                           TRNS,
                                 TRNS,TRNS,TRNS,
        // right hand
             TRNS, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,
             FN4,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
    ),

    KEYMAP(  // layer 3: numpad
        // left hand
        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,
        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,FN4,
        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,
        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,
        TRNS,TRNS,TRNS,TRNS,TRNS,
                                      TRNS,TRNS,
                                           TRNS,
                                 TRNS,TRNS,TRNS,
        // right hand
             TRNS,NLCK,PSLS,PAST,PAST,PMNS,BSPC,
             FN4,NO,  P7,  P8,  P9,  PMNS,BSPC,
                  NO,  P4,  P5,  P6,  PPLS,PENT,
             TRNS,NO,  P1,  P2,  P3,  PPLS,PENT,
                       P0,  PDOT,SLSH,PENT,PENT,
        TRNS,TRNS,
        TRNS,
        TRNS,TRNS,TRNS
    ),

};

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

/*
 * Macro definition
 */
enum macro_id {
    SHIFT_ALT,
};
const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
{
    switch (id) {
        case SHIFT_ALT:
            return (record->event.pressed ?
                    MACRO( D(LALT), D(LSFT), END ) :
                    MACRO( U(LALT), U(LSFT), END ));
    }
    return MACRO_NONE;
}

/*
 * Fn action definition
 */
static const uint16_t PROGMEM fn_actions[] = {
    ACTION_FUNCTION(TEENSY_KEY),                    // FN0 - Teensy key
    ACTION_LAYER_MOMENTARY(1),                      // FN1 - switch to Layer1
    ACTION_LAYER_SET(2, ON_PRESS),                  // FN2 - set Layer2
    ACTION_LAYER_TOGGLE(3),                         // FN3 - toggle Layer3 aka Numpad layer
    ACTION_LAYER_SET(0, ON_PRESS),                  // FN4 - set Layer0
    ACTION_LAYER_TOGGLE(1),                         // FN5 - toggle Layer1 aka F Keys
    ACTION_MACRO(SHIFT_ALT),     // FN6 - Language Change (Shift+Alt)
};

void action_function(keyrecord_t *event, uint8_t id, uint8_t opt)
{
    if (id == TEENSY_KEY) {
        clear_keyboard();
        print("\n\nJump to bootloader... ");
        _delay_ms(250);
        bootloader_jump(); // should not return
        print("not supported.\n");
    }
}

#endif


#define KEYMAPS_SIZE    (sizeof(keymaps) / sizeof(keymaps[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, keypos_t key)
{
    if (layer < KEYMAPS_SIZE) {
        return pgm_read_byte(&keymaps[(layer)][(key.row)][(key.col)]);
    } else {
        // fall back to layer 0
        return pgm_read_byte(&keymaps[0][(key.row)][(key.col)]);
    }
}

#if defined(KEYMAP_CUB)

// function keymap_fn_to_action will be defined in keymap_cub.h

#else
/* 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;
}
#endif

Title: Re: TMK keyboard firmware
Post by: lkong on Thu, 22 October 2015, 20:43:23
Any one has experience to get the serialmouse working?
I can't seem to find the pin assignment for that.
Title: Re: TMK keyboard firmware
Post by: Ryu on Fri, 23 October 2015, 01:22:31
I'm using http://www.enjoyclick.org/tkg/# to make a keymap for my KC60...it is my understanding that with TMK you can have the ESC key double as ~ when you hit shift....but the TMG tool doesn't supply that in his help. What would be the edit that I'd need to make to the keymap.c file afterwards?

You may get help from him here. I don't know how his TKG works actually.
https://github.com/kairyu/tkg

BTW, ESC/~ is possible but not easy with TMK, you will have to write C code. I think you can find the code somewhere but I can't remember.

I call the feature 'Tricky Esc' and you can find my code here: https://github.com/kairyu/tmk_keyboard_custom/blob/master/keyboard/gh60/keymap_poker2.c#L89-L115
It's really simple code benefit from the great action_function.
As you see it's a 'Built-in' function rather than keymap, so it can only work with the firmware which has it built-in (e.g. the firmwares shipped with tkg-toolkit).
Title: Re: TMK keyboard firmware
Post by: p3lim on Fri, 23 October 2015, 07:56:51
I'm using http://www.enjoyclick.org/tkg/# to make a keymap for my KC60...it is my understanding that with TMK you can have the ESC key double as ~ when you hit shift....but the TMG tool doesn't supply that in his help. What would be the edit that I'd need to make to the keymap.c file afterwards?

You may get help from him here. I don't know how his TKG works actually.
https://github.com/kairyu/tkg

BTW, ESC/~ is possible but not easy with TMK, you will have to write C code. I think you can find the code somewhere but I can't remember.

I call the feature 'Tricky Esc' and you can find my code here: https://github.com/kairyu/tmk_keyboard_custom/blob/master/keyboard/gh60/keymap_poker2.c#L89-L115
It's really simple code benefit from the great action_function.
As you see it's a 'Built-in' function rather than keymap, so it can only work with the firmware which has it built-in (e.g. the firmwares shipped with tkg-toolkit).

https://geekhack.org/index.php?topic=41989.msg1885398#msg1885398
Title: Re: TMK keyboard firmware
Post by: RavenII on Mon, 26 October 2015, 15:06:19
I just finished modifying my KC60, basically I reeplaced the plate, changeed the switches, springs, added sip sockts, etc. Now that it's all assembled, it seems as if though the 3edx column is having issues, I'm not crtain as to what th issue may be. Notice that as I type, I either miss E or double type it. How can I trouble shoot if it's in the firmwaree or hardware? I've made the mistakes in bold for your viewing pleasure. I mostly happeens ...with the E but sometimes with D, X, or 3. I've alreaddy trieed....to add deebounce, no luck.
Title: Re: TMK keyboard firmware
Post by: a-c on Mon, 26 October 2015, 17:18:10
I just finished modifying my KC60, basically I reeplaced the plate, changeed the switches, springs, added sip sockts, etc. Now that it's all assembled, it seems as if though the 3edx column is having issues, I'm not crtain as to what th issue may be. Notice that as I type, I either miss E or double type it. How can I trouble shoot if it's in the firmwaree or hardware? I've made the mistakes in bold for your viewing pleasure. I mostly happeens ...with the E but sometimes with D, X, or 3. I've alreaddy trieed....to add deebounce, no luck.

I had some weirdness with my KC60. They didn't do a very clean job of soldering on the Atmega32U4. If you look at it with a magnifying glass you will see lots of solder residue. I fixed mine by taking a sharp plastic scribe and sliding it between the pins. Don't press hard, you don't want to bend anything, just clear anything between the pins.

This http://hackedgadgets.com/2008/01/14/surface-mount-soldering-tutorial/ (http://hackedgadgets.com/2008/01/14/surface-mount-soldering-tutorial/) picture show a very clean soldering job.
Title: Re: TMK keyboard firmware
Post by: RavenII on Mon, 26 October 2015, 18:14:08
I just finished modifying my KC60, basically I reeplaced the plate, changeed the switches, springs, added sip sockts, etc. Now that it's all assembled, it seems as if though the 3edx column is having issues, I'm not crtain as to what th issue may be. Notice that as I type, I either miss E or double type it. How can I trouble shoot if it's in the firmwaree or hardware? I've made the mistakes in bold for your viewing pleasure. I mostly happeens ...with the E but sometimes with D, X, or 3. I've alreaddy trieed....to add deebounce, no luck.

I had some weirdness with my KC60. They didn't do a very clean job of soldering on the Atmega32U4. If you look at it with a magnifying glass you will see lots of solder residue. I fixed mine by taking a sharp plastic scribe and sliding it between the pins. Don't press hard, you don't want to bend anything, just clear anything between the pins.

This http://hackedgadgets.com/2008/01/14/surface-mount-soldering-tutorial/ (http://hackedgadgets.com/2008/01/14/surface-mount-soldering-tutorial/) picture show a very clean soldering job.

You know...I wanted to contact you directly but didn't want to bother you...I was thinking it was the ground jumpers causing an issue (since I re did them) but I thought, "man, they're just grounds"...THEN I remembered that my mom tried removing the Atmega (and told me that it was epoxied to the board?)...so I'm starting to think that it's got something to do with that. I'll double check it.

In the event that anyone was wondering why my mom was trying to desolder the chip...I had desoldered the whole board to change the plate/switches and had given it to her to clean all the flux off of the board (she's all sorts of certified in soldering/BGA/etc.)...a while back I had told her that I wanted her to swap the 32u4 from my NerD60 (so I can preserve the bootloader) and she thought it was this board...luckily it was glued on...
Title: Re: TMK keyboard firmware
Post by: Ryu on Mon, 26 October 2015, 20:26:00
I'm using http://www.enjoyclick.org/tkg/# to make a keymap for my KC60...it is my understanding that with TMK you can have the ESC key double as ~ when you hit shift....but the TMG tool doesn't supply that in his help. What would be the edit that I'd need to make to the keymap.c file afterwards?

You may get help from him here. I don't know how his TKG works actually.
https://github.com/kairyu/tkg

BTW, ESC/~ is possible but not easy with TMK, you will have to write C code. I think you can find the code somewhere but I can't remember.

I call the feature 'Tricky Esc' and you can find my code here: https://github.com/kairyu/tmk_keyboard_custom/blob/master/keyboard/gh60/keymap_poker2.c#L89-L115
It's really simple code benefit from the great action_function.
As you see it's a 'Built-in' function rather than keymap, so it can only work with the firmware which has it built-in (e.g. the firmwares shipped with tkg-toolkit).

https://geekhack.org/index.php?topic=41989.msg1885398#msg1885398

I think your code might have a risk of sticking ~ key if user do "Shift Down"->"Esc Down"->"Shift Up"->"Esc Up" in sequence.
Title: Re: TMK keyboard firmware
Post by: Melvang on Mon, 26 October 2015, 22:05:40
I am pretty sure I know the answer, but does TMK support the Teensy 2.0++ for larger matrices than the 2.0 can handle?
Title: Re: TMK keyboard firmware
Post by: a-c on Mon, 26 October 2015, 22:34:45
I am pretty sure I know the answer, but does TMK support the Teensy 2.0++ for larger matrices than the 2.0 can handle?

Yes, you set it in the makefile.

https://github.com/tmk/tmk_keyboard/blob/master/doc/build.md
Title: Re: TMK keyboard firmware
Post by: flabbergast on Tue, 27 October 2015, 04:31:11
I had some weirdness with my KC60. They didn't do a very clean job of soldering on the Atmega32U4. If you look at it with a magnifying glass you will see lots of solder residue. I fixed mine by taking a sharp plastic scribe and sliding it between the pins. Don't press hard, you don't want to bend anything, just clear anything between the pins.
That would be actually flux residue, not solder (as in tin) residue. I think the Chinese "manufacturers" quite often actually solder by hand, and do not clean up afterwards. It is harmless (certainly electrically it is actually beneficial, as extra isolation, and protects the actual solder from air exposure), unless they use some weird flux which is corrosive long term.
Title: Re: TMK keyboard firmware
Post by: deductivemonkee on Tue, 27 October 2015, 19:43:02
Did I do something really dumb? I keep getting the error code: 0xc0000142 while making my alps64 code in prep for my pcb and stuff from blue's gb.

heres my code: (all i did was modify this file in alps64 folder)
keymap_plain.c

Code: [Select]

#include "keymap_common.h"

const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
    /* 0: qwerty */
    [0] = KEYMAP_MATT( \
        ESC, 1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   MINS,EQL, NUHS, 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,ESC, \
        LCTL,LGUI,LALT,          SPC,                     APP, RALT,FN1,RCTL),

/* 1: FN 1 */
    [1] = KEYMAP_MATT ( \
    (GRV, F1,   F2,   F3,   F4,   F5,   F6,   F7,   F8,   F9,   F10,  F11,  F12,  VOLD, VOLU, \
        TRNS, TRNS, UP, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, PGUP, TRNS,   TRNS, DEL,  \
        TRNS, LEFT, DOWN, RGHT, TRNS, TRNS, MYCM, TRNS, TRNS, PGDN, TRNS, TRNS, TRNS,  \
        TRNS, TRNS, TRNS, CALC, TRNS, TRNS, TRNS, TRNS, HOME, END,  TRNS, TRNS, TRNS, \
        LGUI, TRNS,             TRNS,                   PSCR, RCTL),
};
const uint16_t PROGMEM fn_actions[] = {
  [0] = ACTION_LAYER_MOMENTARY(1),
};


Title: Re: TMK keyboard firmware
Post by: hasu on Tue, 27 October 2015, 20:29:07
What is the error message like actually? Is that all. Omitting error message is not useful.
You can use service like github gist or pastbin to post text wall of error output.
And did you try compile firmware with default keymap before editing your own map?

Ah, if you are on Windows and using WinAVR you will have this problem.
http://deskthority.net/workshop-f7/tmk-keyboard-firmware-collection-t4478-180.html#p260436
Title: Re: TMK keyboard firmware
Post by: deductivemonkee on Tue, 27 October 2015, 20:56:09
What is the error message like actually? Is that all. Omitting error message is not useful.
You can use service like github gist or pastbin to post text wall of error output.
And did you try compile firmware with default keymap before editing your own map?

Ah, if you are on Windows and using WinAVR you will have this problem.
http://deskthority.net/workshop-f7/tmk-keyboard-firmware-collection-t4478-180.html#p260436

I just used the cmd in win 10, this is what I did.
CD ~~~~ (on tablet don't know file location)
make -f Make file
And is comes up with a box saying that error code, nothing else.
I did not edit any other files.
Title: Re: TMK keyboard firmware
Post by: deductivemonkee on Tue, 27 October 2015, 21:08:51
I will paste the code the cmd spits out tomorrow, not going on pc now... Almost time to sleep.
Title: Re: TMK keyboard firmware
Post by: hasu on Tue, 27 October 2015, 21:25:42
People have had some problems of building firmware on Windows. People on Windows tend to use WinAVR and this is definitely a cause.

Problems are:
1) WinAVR may not work on newer Windows like Win8 and Win10.
2) Alps64 PCB has ATmega32u2 as controller but WinAVR doesn't support it.

You have to update some files of WinAVR to compile it on those OS's.
http://deskthority.net/workshop-f7/tmk-keyboard-firmware-collection-t4478-180.html#p260436

WinAVR is very handy all-in-one package but too old. I reccomend to move to newer toolchain like Atmel's GCC and Cygwin(MinGW) for other command line tools.
https://github.com/tmk/tmk_keyboard/blob/master/doc/build.md



BTW as for Alps64,
More
I'll setup keymap editor for Alps64 PCB later, so if you are frustrated much at these things you can just wait for the editor. With the editor you can make your keymap easily with mouse, it will be useful enough unless you want complex keymap. Not that you sitll have to compile firmware yourself to use full features of TMK.
This is editor for HHKB, for example.
http://www.tmk-kbd.com/tmk_keyboard/editor/hhkb/index.html
Title: Re: TMK keyboard firmware
Post by: U47 on Wed, 28 October 2015, 17:34:13
Quote from: hasu

[quote author=U47 link=topic=41989.msg1862625#msg1862625 date=1441998715
Similarly, I'm looking to make a dual-role key out of the standard Caps Lock position which would also take a modifier.

Tap: BKSP
Shift-tap: DEL
Hold: L_CTRL
This is a bit different. You can do tap=BKSP and hold=LCTRL with ACTION_MODS_TAP_KEY(MOD_LCTL, KC_BKSP). But for shift-tap=DEL you would need another layer, and if you want to use Shift to activate that layer, you'll need to apply a shift mod to all the other keys in that layer so Shift still works normally for them. I'm not sure how to do that.

Another option is to write a custom action_function() like Hasu said.

Yeah, I think using Shift is the gotcha. I'm just used to this combination since this is how I've had Karabiner set to work. I don't think a custom action would be too onerous, or I can add it to SpaceFN instead.
Wouldn't this work? https://github.com/tmk/tmk_keyboard/blob/master/doc/keymap.md#35-momentary-switching-with-modifiers
Have a momentary layer with DEL on CapsLock and set Shift on the default layer as a FN key to switch to it while setting MOD_LSHIFT.

You're absolutely right. Thanks for wrapping your head around that.

Here's my keymap (https://github.com/U47/tmk_keyboard/blob/add617e1e58baaa9dbd1d2177996df6d26b1ee8b/keyboard/hhkb/keymap_u47.c), in case anyone's curious.

Features:

It's essentially a HHKB to anyone who doesn't know (or care) about the other layer enhancements. I've grown addicted to SpaceFN now, so that's tossed in there, too.

Feedback welcome!
Title: Re: TMK keyboard firmware
Post by: Ryu on Thu, 29 October 2015, 21:59:11
I just finished modifying my KC60, basically I reeplaced the plate, changeed the switches, springs, added sip sockts, etc. Now that it's all assembled, it seems as if though the 3edx column is having issues, I'm not crtain as to what th issue may be. Notice that as I type, I either miss E or double type it. How can I trouble shoot if it's in the firmwaree or hardware? I've made the mistakes in bold for your viewing pleasure. I mostly happeens ...with the E but sometimes with D, X, or 3. I've alreaddy trieed....to add deebounce, no luck.

I had some weirdness with my KC60. They didn't do a very clean job of soldering on the Atmega32U4. If you look at it with a magnifying glass you will see lots of solder residue. I fixed mine by taking a sharp plastic scribe and sliding it between the pins. Don't press hard, you don't want to bend anything, just clear anything between the pins.

This http://hackedgadgets.com/2008/01/14/surface-mount-soldering-tutorial/ (http://hackedgadgets.com/2008/01/14/surface-mount-soldering-tutorial/) picture show a very clean soldering job.

You know...I wanted to contact you directly but didn't want to bother you...I was thinking it was the ground jumpers causing an issue (since I re did them) but I thought, "man, they're just grounds"...THEN I remembered that my mom tried removing the Atmega (and told me that it was epoxied to the board?)...so I'm starting to think that it's got something to do with that. I'll double check it.

In the event that anyone was wondering why my mom was trying to desolder the chip...I had desoldered the whole board to change the plate/switches and had given it to her to clean all the flux off of the board (she's all sorts of certified in soldering/BGA/etc.)...a while back I had told her that I wanted her to swap the 32u4 from my NerD60 (so I can preserve the bootloader) and she thought it was this board...luckily it was glued on...

I have to say your mon is amazing! And I hope you have already fixed your KC60.
BTW I'm waiting for your NerD60 ;)
Title: Re: TMK keyboard firmware
Post by: deductivemonkee on Sat, 31 October 2015, 15:47:01
What is the error message like actually? Is that all. Omitting error message is not useful.
You can use service like github gist or pastbin to post text wall of error output.
And did you try compile firmware with default keymap before editing your own map?

Ah, if you are on Windows and using WinAVR you will have this problem.
http://deskthority.net/workshop-f7/tmk-keyboard-firmware-collection-t4478-180.html#p260436

I just used the cmd in win 10, this is what I did.
CD ~~~~ (on tablet don't know file location)
make -f Make file
And is comes up with a box saying that error code, nothing else.
I did not edit any other files.

here is what the cmd spits out.

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

C:\Users\Matt>cd C:\Users\Matt\Desktop\tmk_keyboard\keyboard\alps64

C:\Users\Matt\Desktop\tmk_keyboard\keyboard\alps64>make -f Makefile Flip
      0 [main] sh 11216 sync_with_child: child 3960(0x1D0) died before initialization with status code 0xC0000142
    149 [main] sh 11216 sync_with_child: *** child state waiting for longjmp
/usr/bin/sh: fork: Resource temporarily unavailable
      0 [main] sh 3620 sync_with_child: child 6360(0x1C0) died before initialization with status code 0xC0000142
    184 [main] sh 3620 sync_with_child: *** child state waiting for longjmp
/usr/bin/sh: fork: Resource temporarily unavailable
      0 [main] sh 5324 sync_with_child: child 10544(0x1B0) died before initialization with status code 0xC0000142
    137 [main] sh 5324 sync_with_child: *** child state waiting for longjmp
/usr/bin/sh: fork: Resource temporarily unavailable
      0 [main] sh 9488 sync_with_child: child 6736(0x1B8) died before initialization with status code 0xC0000142
    162 [main] sh 9488 sync_with_child: *** child state waiting for longjmp
/usr/bin/sh: fork: Resource temporarily unavailable
      0 [main] sh 4108 sync_with_child: child 6516(0x1A8) died before initialization with status code 0xC0000142
    137 [main] sh 4108 sync_with_child: *** child state waiting for longjmp
/usr/bin/sh: fork: Resource temporarily unavailable

mkdir -p obj_alps64
Compiling C: keymap_plain.c
avr-gcc -c -mmcu=atmega32u2 -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= -Os -funsigned-char -funsigned-bitfields -ffunction-sections -fdata-sections -fno-inline-small-functions -fpack-struct -fshort-enums -fno-strict-aliasing -Wall -Wstrict-prototypes -Wa,-adhlns=obj_alps64/keymap_plain.lst -I. -IC -I/Users/Matt/Desktop/tmk_keyboard/tmk_core -IC -I/Users/Matt/Desktop/tmk_keyboard/tmk_core/protocol/lufa -IC -I/Users/Matt/Desktop/tmk_keyboard/tmk_core/protocol/lufa/LUFA-git -IC -I/Users/Matt/Desktop/tmk_keyboard/tmk_core/common -std=gnu99 -include config.h -MMD -MP -MF .dep/obj_alps64_keymap_plain.o.d  keymap_plain.c -o obj_alps64/keymap_plain.o
make: *** [obj_alps64/keymap_plain.o] Error -1073741502

C:\Users\Matt\Desktop\tmk_keyboard\keyboard\alps64>
Title: Re: TMK keyboard firmware
Post by: deductivemonkee on Sat, 31 October 2015, 17:35:55
Ignore my last posts, I got it to work!
Now the wait for parts...  :)
Title: Re: TMK keyboard firmware
Post by: hasu on Sat, 31 October 2015, 18:12:57
Great!
Post what your problem was and how you resolved it. That may help other people with similar difficulty.
Title: Re: TMK keyboard firmware
Post by: deductivemonkee on Sat, 31 October 2015, 18:29:29
Great!
Post what your problem was and how you resolved it. That may help other people with similar difficulty.
I used dfu-programmer, cygwin terminal, and notepad++.
The cygwin terminal tells you where the errors are, what line, and what column.
Part of my problem was that I tried to use winavr... Yeah...
My other problem was just typing corrections in keymap_plain.c

Building the .hex on windows was a little intimidating, here's how I did it.

To build on windows: [I used windows 10] For alps64 pcb.
1. Open cygwin terminal
2. Type: cd [tmk_keyboard location] [for me it was: C:/Users/Matt/Desktop/tmk_keyboard/keyboard/alps64
2.1...? If you go to the alps64 location through windows explorer, copy the path. But when you paste it into cygwin terminal, all of the \ must be changed to / or it will not read it.
3. Type: make -f Makefile clean
4. Then: make -f Makefile
5. Wait. It took about 3 mins for me, with a very basic layout.

If it says "no  such command: make" or something like that, just restart your computer, that fixed it for me.

I hope this helps.
Yes, I know hasu already has a build tutorial, but I had to to do a lot of trial and error, so I'm posting this.

Now to add more fn layers and stuff!
Title: Re: TMK keyboard firmware
Post by: deductivemonkee on Sun, 01 November 2015, 11:10:12
How would I go about making say fn+m switch from Dvorak to qwerty and vice versa?
Title: Re: TMK keyboard firmware
Post by: hasu on Sun, 01 November 2015, 11:37:09
Part of my problem was that I tried to use winavr... Yeah...

What toochain are you using then? Atmel AVR toolchain or updated winavr?


Quote
How would I go about making say fn+m switch from Dvorak to qwerty and vice versa?
You can use either layer action of these probably.
https://github.com/tmk/tmk_keyboard/blob/master/doc/keymap.md#221-default-layer
https://github.com/tmk/tmk_keyboard/blob/master/doc/keymap.md#223-toggle-switch
Title: Re: TMK keyboard firmware
Post by: deductivemonkee on Sun, 01 November 2015, 11:45:08
Part of my problem was that I tried to use winavr... Yeah...

What toochain are you using then? Atmel AVR toolchain or updated winavr?


Quote
How would I go about making say fn+m switch from Dvorak to qwerty and vice versa?
You can use either layer action of these probably.
https://github.com/tmk/tmk_keyboard/blob/master/doc/keymap.md#221-default-layer
https://github.com/tmk/tmk_keyboard/blob/master/doc/keymap.md#223-toggle-switch

Oh yeah, I am using atmel avr toolchain.
Title: Re: TMK keyboard firmware
Post by: FuriousGeorge on Thu, 05 November 2015, 17:36:40
Just got my Infinity from the most recent drop and tried programming it with TMK. The main branch didn't compile, but someone on Massdrop had suggested the one below. It compiled just fine, but I'm having some issues. If I test it with the keymap_plain that's included it should have the grave character on the top right key on the board, but instead it's tab. The physical tab key gives a Q and every other character is shifted over one from where it is expected to be. Does that mean I need to change something in the matrix file? I'm not really sure what I'm doing. That I got my KC60 programmed is a minor miracle. :)


https://github.com/tmk/tmk_keyboard/tree/flabbergast-tmk_chibios/keyboard/infinity_chibios
Title: Re: TMK keyboard firmware
Post by: hasu on Thu, 05 November 2015, 20:30:23
See this.

https://github.com/tmk/tmk_keyboard/issues/266#issuecomment-153916983
Title: Re: TMK keyboard firmware
Post by: FuriousGeorge on Thu, 05 November 2015, 21:32:20
See this.

https://github.com/tmk/tmk_keyboard/issues/266#issuecomment-153916983
Awesome hasu, thanks so much.
Title: Re: TMK keyboard firmware
Post by: goflo on Mon, 09 November 2015, 14:42:45
I just finished the electronics on my first own keyboard build and started using the tmk firmware.
Now I got just one problem....my complete keymap is mirrored.

The rows are right, the top row is on top of the board, bottom row on the bottom.
But the columns are mirrored.
The "a" for example should be on the left side... but now it's the most right key.

Is there a quick way to change this or do I need to rewrite my whole keymap?

 
Title: Re: TMK keyboard firmware
Post by: a-c on Mon, 09 November 2015, 15:47:34
I just finished the electronics on my first own keyboard build and started using the tmk firmware.
Now I got just one problem....my complete keymap is mirrored.

The rows are right, the top row is on top of the board, bottom row on the bottom.
But the columns are mirrored.
The "a" for example should be on the left side... but now it's the most right key.

Is there a quick way to change this or do I need to rewrite my whole keymap?

Flip the order of the column pin definition in your matrix.
Title: Re: TMK keyboard firmware
Post by: goflo on Mon, 09 November 2015, 16:10:37
Yes....got it.
Thank you a-c  :thumb:

Title: Re: TMK keyboard firmware
Post by: RavenII on Thu, 12 November 2015, 17:57:41
I just finished modifying my KC60, basically I reeplaced the plate, changeed the switches, springs, added sip sockts, etc. Now that it's all assembled, it seems as if though the 3edx column is having issues, I'm not crtain as to what th issue may be. Notice that as I type, I either miss E or double type it. How can I trouble shoot if it's in the firmwaree or hardware? I've made the mistakes in bold for your viewing pleasure. I mostly happeens ...with the E but sometimes with D, X, or 3. I've alreaddy trieed....to add deebounce, no luck.

I had some weirdness with my KC60. They didn't do a very clean job of soldering on the Atmega32U4. If you look at it with a magnifying glass you will see lots of solder residue. I fixed mine by taking a sharp plastic scribe and sliding it between the pins. Don't press hard, you don't want to bend anything, just clear anything between the pins.

This http://hackedgadgets.com/2008/01/14/surface-mount-soldering-tutorial/ (http://hackedgadgets.com/2008/01/14/surface-mount-soldering-tutorial/) picture show a very clean soldering job.

You know...I wanted to contact you directly but didn't want to bother you...I was thinking it was the ground jumpers causing an issue (since I re did them) but I thought, "man, they're just grounds"...THEN I remembered that my mom tried removing the Atmega (and told me that it was epoxied to the board?)...so I'm starting to think that it's got something to do with that. I'll double check it.

In the event that anyone was wondering why my mom was trying to desolder the chip...I had desoldered the whole board to change the plate/switches and had given it to her to clean all the flux off of the board (she's all sorts of certified in soldering/BGA/etc.)...a while back I had told her that I wanted her to swap the 32u4 from my NerD60 (so I can preserve the bootloader) and she thought it was this board...luckily it was glued on...

I have to say your mon is amazing! And I hope you have already fixed your KC60.
BTW I'm waiting for your NerD60 ;)

Ryu!...I'm actually trying your tool right now, but it seems as if maybe the matrix in TMK is not correct for the NerD60, I swapped the chip last night actually and I'm trying to mess with TMK on it, but it seems the whole qwerty row as well as "xvn,/" aren't working...I'm trying to figure that out now and I'll let you know.

Also, I don't remember where, but I found a place that had the way to make esc/~ possible. I'll email you about it and maybe you can add it to your TKG. Thanks again man.
Title: Re: TMK keyboard firmware
Post by: amospalla on Tue, 17 November 2015, 18:02:29
I received your prebuilt usb to usb converter and I am playing with it right now  ;D

Can I use ISO or JIS layouts with it? I noticed there is no reference to JIS or ISO in on converter/usb_usb/keymap_common.h, but for example it is on converter/ps2_usb/keymap_common.h.
Title: Re: TMK keyboard firmware
Post by: hasu on Tue, 17 November 2015, 23:25:47
Added ISO and JIS keymap to USB-USB converter. You can use KEYMAP_ISO or KEYMAP_JIS for those layouts now. Or just use KEYMAP_ALL, which can support most of layouts probably.
https://github.com/tmk/tmk_keyboard/blob/706b2776464200a5723ac41d58ad7918d72460bb/converter/usb_usb/keymap_common.h#L92-L132

Title: Re: TMK keyboard firmware
Post by: amospalla on Wed, 18 November 2015, 05:46:38
Added ISO and JIS keymap to USB-USB converter. You can use KEYMAP_ISO or KEYMAP_JIS for those layouts now. Or just use KEYMAP_ALL, which can support most of layouts probably.
https://github.com/tmk/tmk_keyboard/blob/706b2776464200a5723ac41d58ad7918d72460bb/converter/usb_usb/keymap_common.h#L92-L132

:D wow thanks, I'm testing it tomorrow late!
Title: Re: TMK keyboard firmware
Post by: profet on Wed, 18 November 2015, 11:07:56
Would TMK firmware run on a Bluefruit Micro LE controller?

https://www.adafruit.com/products/2661

Has any work been done on this hardware?
Title: Re: TMK keyboard firmware
Post by: VinnyCordeiro on Wed, 18 November 2015, 13:30:55
Would TMK firmware run on a Bluefruit Micro LE controller?

https://www.adafruit.com/products/2661

Has any work been done on this hardware?
It uses an ATmega32U4, so theoretically it is possible. But AFAIK you'll have to write the code to handle the Bluetooth dongle, though. And keep in mind that it is running at 3.3V, you'll have to use an LDO or a voltage regulator to step down the voltage from the USB port.
Title: Re: TMK keyboard firmware
Post by: flabbergast on Wed, 18 November 2015, 15:27:55
There's a regulator on board; I believe that the atmega32u4 runs on 3.3v already. For the bluetooth bit, adafruit supplies a "hid keyboard firmware" for the bluetooth chip, which is connected to the atmega32u4 by serial (or spi, not sure), so it would be sufficient to replace the "send keyboard packet" function in TMK to "send the data over serial" (and get rid of all the USB stuff, since that part is now hidden in the adafruit's bluetooth firmware).
Title: Re: TMK keyboard firmware
Post by: kinglukas38 on Wed, 18 November 2015, 19:05:37
does anyone know what diodes the infinity keyboard uses? got a second-hand board and its missing a single diode
Title: Re: TMK keyboard firmware
Post by: p3lim on Thu, 19 November 2015, 06:56:04
does anyone know what diodes the infinity keyboard uses? got a second-hand board and its missing a single diode

Most likely 1N4148.
Title: Re: TMK keyboard firmware
Post by: amospalla on Fri, 20 November 2015, 13:41:58
Hasu, what you've done is wonderful  :D

JIS layout works perfectly. On keymap_jis.c:27 there is HENK,SPC,MHEN, but it should be MHEN,SPC,HENK.

Just a comment, is it posible to define a layout which includes all posible keys on all layouts so you could switch between keyboards without the need to reflash?
Title: Re: TMK keyboard firmware
Post by: hasu on Sat, 21 November 2015, 01:11:43
Fixed JIS keymap, thanks.


With KEYMAP_ALL() you can define universal keymapping for all major keyboard layouts, it is what I intended at least.
Title: Re: TMK keyboard firmware
Post by: henz on Mon, 23 November 2015, 09:22:53
i have tested #264 on kmac 2 and kmac Happy
Title: Re: TMK keyboard firmware
Post by: Zorberema on Wed, 25 November 2015, 06:06:46
Hey!

I've tried to make my software work for several days, and it gets better and better... But now I'm stuck! The error(s) I get are:
More
Code: [Select]
keymap_poker.c:5: error: 'KEYMAP' undeclared here <not in a function>
keymap_poker.c:5: error: expected '}' at e d of input
make: *** [obj_lufa/keymap_poker.o] Error 1


Here's my keymap_poker.c
More
Code: [Select]
#include "keymap_common.h"

const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
    /* 0: qwerty */
    KEYMAP(Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,  \
              A,   S,   D,   F,   G,   H,   J,   K,   L,    \
                Z,   X,   C,   V,   B,   N,   M, RSFT,      \
                          FN0,   SPC,    FN1

    /* 1: FN 1 */
    KEYMAP(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

    /* 2: FN 2 */
    KEYMAP(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[] = {
[0] = ACTION_LAYER_MOMENTARY(1)
[1] = ACTION_LAYER_MOMENTARY(2)
};


Any help is appreciated! :)

Zorb
Title: Re: TMK keyboard firmware
Post by: VinnyCordeiro on Wed, 25 November 2015, 06:27:07
Hey!

I've tried to make my software work for several days, and it gets better and better... But now I'm stuck! The error(s) I get are:
More
Code: [Select]
keymap_poker.c:5: error: 'KEYMAP' undeclared here <not in a function>
keymap_poker.c:5: error: expected '}' at e d of input
make: *** [obj_lufa/keymap_poker.o] Error 1


Here's my keymap_poker.c
More
Code: [Select]
#include "keymap_common.h"

const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
    /* 0: qwerty */
    KEYMAP(Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,  \
              A,   S,   D,   F,   G,   H,   J,   K,   L,    \
                Z,   X,   C,   V,   B,   N,   M, RSFT,      \
                          FN0,   SPC,    FN1

    /* 1: FN 1 */
    KEYMAP(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

    /* 2: FN 2 */
    KEYMAP(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[] = {
[0] = ACTION_LAYER_MOMENTARY(1)
[1] = ACTION_LAYER_MOMENTARY(2)
};


Any help is appreciated! :)

Zorb
You forgot to close the parenthesis after each keymap. You also forgot the commas at the layers definitions, but that error wasn't caught because of the previous error.

The code should look like this:

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

const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
    /* 0: qwerty */
    KEYMAP(Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,  \
              A,   S,   D,   F,   G,   H,   J,   K,   L,    \
                Z,   X,   C,   V,   B,   N,   M, RSFT,      \
                          FN0,   SPC,    FN1),

    /* 1: FN 1 */
    KEYMAP(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),

    /* 2: FN 2 */
    KEYMAP(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[] = {
[0] = ACTION_LAYER_MOMENTARY(1),
[1] = ACTION_LAYER_MOMENTARY(2),
};

And please, reorganize your code. The legibility is very poor.
Title: Re: TMK keyboard firmware
Post by: Zorberema on Wed, 25 November 2015, 13:51:10
Hey!

I've tried to make my software work for several days, and it gets better and better... But now I'm stuck! The error(s) I get are:
More
Code: [Select]
keymap_poker.c:5: error: 'KEYMAP' undeclared here <not in a function>
keymap_poker.c:5: error: expected '}' at e d of input
make: *** [obj_lufa/keymap_poker.o] Error 1


Here's my keymap_poker.c
More
Code: [Select]
#include "keymap_common.h"

const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
    /* 0: qwerty */
    KEYMAP(Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,  \
              A,   S,   D,   F,   G,   H,   J,   K,   L,    \
                Z,   X,   C,   V,   B,   N,   M, RSFT,      \
                          FN0,   SPC,    FN1

    /* 1: FN 1 */
    KEYMAP(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

    /* 2: FN 2 */
    KEYMAP(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[] = {
[0] = ACTION_LAYER_MOMENTARY(1)
[1] = ACTION_LAYER_MOMENTARY(2)
};


Any help is appreciated! :)

Zorb
You forgot to close the parenthesis after each keymap. You also forgot the commas at the layers definitions, but that error wasn't caught because of the previous error.

The code should look like this:

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

const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
    /* 0: qwerty */
    KEYMAP(Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,  \
              A,   S,   D,   F,   G,   H,   J,   K,   L,    \
                Z,   X,   C,   V,   B,   N,   M, RSFT,      \
                          FN0,   SPC,    FN1),

    /* 1: FN 1 */
    KEYMAP(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),

    /* 2: FN 2 */
    KEYMAP(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[] = {
[0] = ACTION_LAYER_MOMENTARY(1),
[1] = ACTION_LAYER_MOMENTARY(2),
};

And please, reorganize your code. The legibility is very poor.

I know that's what it says in the tutorial, but when I try that I get a thousand error messages saying something like "
Title: Re: TMK keyboard firmware
Post by: goflo on Thu, 26 November 2015, 13:04:38
After every error in my layout is fixed, this new beauty is running on tmk firmware   ;D
Thank you hasu  :thumb:
Title: Re: TMK keyboard firmware
Post by: hasu on Thu, 26 November 2015, 18:12:02
Looks realy pretty, wooden frame in particular! Thanks for posting.
Title: Re: TMK keyboard firmware
Post by: profet on Sat, 28 November 2015, 15:02:31
So I went and purchased an adafruit bluefruit micro le and compiled tmk phantom firmware for atmega32u4. I then used avrdude to upload the hex to the controller and it was written successfully.

I assumed (and maybe this was a foolish assumption) that it would "just work" in usb mode... not that any of the matrix pins would be correct... but that it would show up as a non functional HID device at least.

Instead windows reports that its an "Unknown USB Device (Device Descriptor Request Failed)."

Am I doing anything obviously wrong? Was I completely wrong in assuming that since this is also an atmega32u4 that it would "just work" as a usb HID device?

My plan was to get it working over usb then move on to getting the bluetooth working.
Title: Re: TMK keyboard firmware
Post by: hasu on Sat, 28 November 2015, 15:22:57
Post a link to the product you are using and its circuit in particular. This will help you to get more advice from people here.

Title: Re: TMK keyboard firmware
Post by: profet on Sat, 28 November 2015, 15:32:18
Post a link to the product you are using and its circuit in particular. This will help you to get more advice from people here.

This is the product page: https://www.adafruit.com/products/2661
Title: Re: TMK keyboard firmware
Post by: a-c on Sat, 28 November 2015, 16:00:13
Sounds like one of these. http://www.adafruit.com/products/2661

Probably need to set the CPU frequency to 8Mhz in your makefile.
Title: Re: TMK keyboard firmware
Post by: profet on Sat, 28 November 2015, 16:28:02
Sounds like one of these. http://www.adafruit.com/products/2661

Probably need to set the CPU frequency to 8Mhz in your makefile.


hrm... just tried setting: 

F_CPU = 8000000

but same problem.

Title: Re: TMK keyboard firmware
Post by: profet on Sat, 28 November 2015, 16:34:22
hrm... tried LUFA instead of pjrc with changed clock speed... that seems promising... will report back after dinner


thanks for the heads up.
Title: Re: TMK keyboard firmware
Post by: hasu on Sat, 28 November 2015, 18:56:57
Hmm, TMK's PJRC protocol module does not support 8MHz and it expects 16MHz.

Changed PLLCSR setting like the below and it seems to work now. But I don't think you have a reason to stick to PJRC instead of LUFA.

Code: [Select]
diff --git a/tmk_core/protocol/pjrc/usb.h b/tmk_core/protocol/pjrc/usb.h
index a195b67..881a1ef 100644
--- a/tmk_core/protocol/pjrc/usb.h
+++ b/tmk_core/protocol/pjrc/usb.h
@@ -71,7 +71,7 @@ void usb_remote_wakeup(void);
 #define USB_FREEZE() (USBCON = ((1<<USBE)|(1<<FRZCLK)))
 #elif defined(__AVR_ATmega32U4__)
 #define HW_CONFIG() (UHWCON = 0x01)
-#define PLL_CONFIG() (PLLCSR = 0x12)
+#define PLL_CONFIG() (PLLCSR = 0x02)
 #define USB_CONFIG() (USBCON = ((1<<USBE)|(1<<OTGPADE)))
 #define USB_FREEZE() (USBCON = ((1<<USBE)|(1<<FRZCLK)))
 #elif defined(__AVR_AT90USB646__)
Title: Re: TMK keyboard firmware
Post by: mrbishop on Sat, 28 November 2015, 19:15:19
so ive built a keyboard using the GH60 TMK firmware. all the default settings everything works except for 2 keys on row 3 seem to be shifted. not sure whats going on any help would be great.
the Z key is offset and the B key is as well. all the other keys in that row/column work.

here is the keymap

     * ,-----------------------------------------------------------.
     * |`| 1| 2| 3| 4| 5| 6=| 7| 8| 9|0|-|6=|BKSP|
     * |-----------------------------------------------------------|
     * |TAB|q| w|e|r|t|y]|u|i|o|p|[]|[]|y]\|
     * |-----------------------------------------------------------|
     * |caps|a|s|d|f|g|h|j|k|l|;|'|enter|
     * |-----------------------------------------------------------|
     * |shift|  |z|x|c|   |b|n|m|,|.|shift|
     * |-----------------------------------------------------------|
     * |ctrl|super|alt|         space            |alt|super|menu|???|
     * `-----------------------------------------------------------'
original thread with pictures and gh60 compile folder
https://geekhack.org/index.php?topic=77450.0
Title: Re: TMK keyboard firmware
Post by: hasu on Sat, 28 November 2015, 23:47:42
I think your 'z' key is offset physically comparing to GH60.
GH60 has 'z' on col2 of row3(let's say index starts from 0) but your 'z' on col1. Note that GH60 has ISO\ on that place(row3, col1).

Fix your hardware if you want to make your board compatible to GH60. Or change keymap code in keymap_common.h.
Title: Re: TMK keyboard firmware
Post by: nephiel on Sun, 29 November 2015, 04:05:02
Hasu is right - the GH60 board has an extra ISO key on the matrix between the left Shift and Z, and your wiring is missing that key. Rewiring that row from Z to B, but skipping that key, should fix the problem.
Title: Re: TMK keyboard firmware
Post by: mrbishop on Sun, 29 November 2015, 07:46:14
@hasu i guess i dont understand as the keymap_common.h has an ansi section. which is what i used to wire my board. i guess i dont fully understand how all the firmware files interact or are configured to make it work. i'd love alittle more direction. here or in PM. sorry for being a noob i appreciate all the help i can get!  thanks again.
Title: Re: TMK keyboard firmware
Post by: mrbishop on Sun, 29 November 2015, 07:55:50
(http://images.tapatalk-cdn.com/15/11/29/a58330214ff2909e7d277877cf701b65.jpg)
Title: Re: TMK keyboard firmware
Post by: mrbishop on Sun, 29 November 2015, 08:23:29
wel i got Z working in theproper placeby removing one of the key definitions in common.h (K31) but i can't seem to get the same result with the B key. -_-
Title: Re: TMK keyboard firmware
Post by: suicidal_orange on Sun, 29 November 2015, 08:33:04
@hasu i guess i dont understand as the keymap_common.h has an ansi section. which is what i used to wire my board. i guess i dont fully understand how all the firmware files interact or are configured to make it work. i'd love alittle more direction. here or in PM. sorry for being a noob i appreciate all the help i can get!  thanks again.

Your Z is on column 1 (yellow = 0 red = 1) but your keymap has a gap putting it in column 2.  I know next to nothing about TMK but your Z row in the keymap is wired up like this

|shift|z|x|c|v|b|n|m|,|.|/| |shift|

not this

shift| |z|x|c|   |b|n|m|,|.|shift|

Maybe there's a good reason you have no "v" or "/" in your map (and other strangeness) but give it a try?
Title: Re: TMK keyboard firmware
Post by: mrbishop on Sun, 29 November 2015, 08:39:50
@suicidal_orange. the map i posted wasto demonstratethe issue i am having. i like the Z and V key :D   what i'm trying to accomplish is an ANSI 60% Poker layers usingthe GH60 wireing. which has worked with the exception of the Z,V,6,Y,=



so i boned something up somewhere but i'm lost as to where :(



Title: Re: TMK keyboard firmware
Post by: mrbishop on Sun, 29 November 2015, 08:43:07
looks like the close square bracket does this as well "y]" sigh so close yet so far.
Title: Re: TMK keyboard firmware
Post by: suicidal_orange on Sun, 29 November 2015, 09:14:12
Ok... I guess common.h is keymap_common.h in the GH60 folder?  If so I think you need to change the ANSI sections to

    K30, K31, K32, K33, K34, K35, K36, K37, K38, K39, K3A,delete K3B           K3D, \
and
    K30, K31, K32, K33, K34, K35, K36, K37, K38, K39, K3A, NO, NO,  K3D, \


I'm not sure why you're trying to pretend this is a GH60, why not build it from scratch so you know how it works?
Title: Re: TMK keyboard firmware
Post by: mrbishop on Sun, 29 November 2015, 09:24:22
Well it's my first attempt so I thought it best to emulate something first for better understanding and to try to figure out how to fix issues like this with my code.
Title: Re: TMK keyboard firmware
Post by: profet on Sun, 29 November 2015, 09:30:05
Well thanks to everyone here I was able to get the Bluefruit micro working with TMK over USB...

Now the hard part... Bluetooth.

Could someone attempt to explain to me the architecture of the "protocol" modules? I see there is already a bluefruit protocol module but I'm thinking that if I want to use hardware SPI then I may need to start from scratch.

So protocols... can multiple be active at once?

Is there an event I can hook into somewhere/somehow that will allow me to capture keys and process them over SPI to the bluetooth module?
Title: Re: TMK keyboard firmware
Post by: mrbishop on Sun, 29 November 2015, 09:49:55
Ok... I guess common.h is keymap_common.h in the GH60 folder?  If so I think you need to change the ANSI sections to

    K30, K31, K32, K33, K34, K35, K36, K37, K38, K39, K3A,delete K3B           K3D, \
and
    K30, K31, K32, K33, K34, K35, K36, K37, K38, K39, K3A, NO, NO,  K3D, \


I'm not sure why you're trying to pretend this is a GH60, why not build it from scratch so you know how it works?
the suggestion doesn't seem to be working unless i'm just doing it completely wrong. and this doesn't address the other keys.

saddly i dont understand enough about how the firmware code works. i'll see if i can figure it out using the documents at the head of this post.
Title: Re: TMK keyboard firmware
Post by: mrbishop on Sun, 29 November 2015, 13:12:24
all is working now. thanks again for all the help Suicidal_orange. most was hardware issues. solder breaks etc microscopic amount was software. hopefully i'm now better equipped for my next project and future projects to come, 40% and full 114Key monster as well as led back lit versions and pcb creation.  :thumb: :thumb: :thumb:
Title: Re: TMK keyboard firmware
Post by: hasu on Sun, 29 November 2015, 21:00:40
Could someone attempt to explain to me the architecture of the "protocol" modules? I see there is already a bluefruit protocol module but I'm thinking that if I want to use hardware SPI then I may need to start from scratch.

So protocols... can multiple be active at once?

Is there an event I can hook into somewhere/somehow that will allow me to capture keys and process them over SPI to the bluetooth module?

Host-side "protocol" is a module(driver) to communicate with host computer, the protocol module is comprised of some functions whitch send key and mouse envent to host. 'host_diriver_t' is a struct includes pointers to those functions, which is what you have to implement.

LUFA protocol driver is defined in here:
https://github.com/tmk/tmk_keyboard/blob/master/tmk_core/protocol/lufa/lufa.c#L63-L75

And RN-42 protocol diver is located in:
https://github.com/tmk/tmk_keyboard/blob/master/keyboard/hhkb/rn42/rn42.c#L11-L24


You can change protocols in turn,  for example, my HHKB Bluetooth controller exchanges LUFA USB protocol and RN-42 BT protocol by BT module status or key combination.

https://github.com/tmk/tmk_keyboard/blob/master/keyboard/hhkb/rn42/rn42_task.c#L73-L81
https://github.com/tmk/tmk_keyboard/blob/master/keyboard/hhkb/rn42/rn42_task.c#L368-L378
Title: Re: TMK keyboard firmware
Post by: mrbishop on Mon, 30 November 2015, 12:43:07
keyboard stops responding after my computer goes to sleep. all the settings in device manager say wake on power save. is this a know bug or is there a fix for it?
other information. computer in question is a microsoft surface pro 3
works great until sleep. then i have to unplug and plug back in for it to start working again.

Title: Re: TMK keyboard firmware
Post by: ratch on Tue, 01 December 2015, 01:49:52
Does anyone know how you would switch the number keys so that by default they send the shifted versions and when holding down the shift key, they send the unshifted versions? I tried using an action function, but I don't think trying to track the state of your shift key in the action function is the way to go about it.
Title: Re: TMK keyboard firmware
Post by: profet on Thu, 03 December 2015, 10:09:39
Haven't done any C coding since college... moving from C# back to C has proven... interesting.

Still trying to figure out how to gethe the bluefruit micro working in Bluetooth mode. It would really open the door to a whole host of bluetooth keyboards.

TMK seems to function perfectly in USB mode on this controller.

I also purchased one of these:  http://www.adafruit.com/product/2829

Basically the same thing as the bluefruit micro but the battery port is built in.
Title: Re: TMK keyboard firmware
Post by: Charger on Thu, 03 December 2015, 16:02:52
oh random question hasu, I seem to recall seeing you post about rotary encoders before and I was wondering if anything for them ever made it into the tmk firmware?
Title: Re: TMK keyboard firmware
Post by: hasu on Thu, 03 December 2015, 18:49:55
profet, nice. keep us updated!
And intresting product, Adafruit has really nice tutorials and resouce of information.

Charger, no. I still have some encoders around and idea of etch-a-stketch mouse somewhere in mind. But I don't know when I can code for it.
Title: Re: TMK keyboard firmware
Post by: hasu on Thu, 03 December 2015, 23:26:35
Does anyone know how you would switch the number keys so that by default they send the shifted versions and when holding down the shift key, they send the unshifted versions? I tried using an action function, but I don't think trying to track the state of your shift key in the action function is the way to go about it.

you can use get_mods() in action.h to know current modifier state and static variable to "track the state"?
Title: Re: TMK keyboard firmware
Post by: hasu on Fri, 04 December 2015, 00:36:23
I tried my HHKB(TMK/LUFA) on lenovo X201s running Widows 10 and confirmed it works even after a few sleep and resume cycles.

keyboard stops responding after my computer goes to sleep. all the settings in device manager say wake on power save. is this a know bug or is there a fix for it?
other information. computer in question is a microsoft surface pro 3
works great until sleep. then i have to unplug and plug back in for it to start working again.



Title: Re: TMK keyboard firmware
Post by: GuilleAcoustic on Fri, 04 December 2015, 02:25:08
It reminds me that I never thanked you for your firmware. It is used everyday inside my M0110, so .... Arigatou gozaima****a !
Title: Re: TMK keyboard firmware
Post by: mrbishop on Fri, 04 December 2015, 07:25:07
Hmmm not sure then I'll look again at my firmware. It's on windows 8.1 pro. It's joined to a domain so it's not on 10 yet
Title: Re: TMK keyboard firmware
Post by: Charger on Fri, 04 December 2015, 09:36:36
Charger, no. I still have some encoders around and idea of etch-a-stketch mouse somewhere in mind. But I don't know when I can code for it.
I was thinking more about using one for a volume control but an etch a sketch mouse sounds interesting as well
Title: Re: TMK keyboard firmware
Post by: ratch on Sat, 05 December 2015, 11:28:29
Does anyone know how you would switch the number keys so that by default they send the shifted versions and when holding down the shift key, they send the unshifted versions? I tried using an action function, but I don't think trying to track the state of your shift key in the action function is the way to go about it.

you can use get_mods() in action.h to know current modifier state and static variable to "track the state"?

I tried this:
Code: [Select]
     
              if (record->event.pressed) {
shift_mod = get_mods()&(MOD_BIT(KC_LSHIFT)|MOD_BIT(KC_RSHIFT));
initial_mods_state = get_mods();
        if (shift_mod) {
    del_mods(shift_mod);
    add_key(KC_1);
    send_keyboard_report();
} else {
    add_mods(MOD_BIT(KC_LSHIFT));
                    add_key(KC_1);
    send_keyboard_report();
}
    } else {
del_key(KC_1);
clear_mods();
add_mods(initial_mods_state); // don't know what happened to the state of the physical shift switch between press and release
send_keyboard_report();
    }

If I release shift before releasing 1, then I get stuck with the shift modifier. I also tried moving all of it into event.pressed, but if I push and hold 1, it outputs something like "!11111".
Title: Re: TMK keyboard firmware
Post by: hasu on Sat, 05 December 2015, 22:50:19
This kind of thing is not straight and coding is likely to be heuristic and adhoc. It is difficult to find a smart and straight answer.

get_mods() returns logical state of modifiers, not physical key. If you want to track state of physical Shift key you will have to write action function for Shift.
Title: Re: TMK keyboard firmware
Post by: ratch on Sun, 06 December 2015, 01:30:02
This kind of thing is not straight and coding is likely to be heuristic and adhoc. It is difficult to find a smart and straight answer.

get_mods() returns logical state of modifiers, not physical key. If you want to track state of physical Shift key you will have to write action function for Shift.

Thanks for your responses, Hasu.

Do you have an example of what that might look like? Since I'm updating the logical state of the modifiers, it doesn't seem like get_mods() will help me figure out what the modifier state should be after releasing 1. Rather than try to check the physical keys, is there a way for me to essentially re-sync the modifiers so they're back to what they should be?

I think I understand. So I would need an action function that updates both the logical modifier state and the state of the key which I'm trying to track. I'll give is a try and see what happens.
Title: Re: TMK keyboard firmware
Post by: hasu on Sun, 06 December 2015, 02:10:41
Ah, OK. I just saw your post was edited now :D

anyway, what I meant is like below.

Code: [Select]
static uint8_t physical_mods = 0;     
                                 
void action_function(keyrecord_t *record, uint8_t id, uint8_t opt)
{                                 
    switch (id) {                 
        case REVESED_SHIFT_1:     
            ... your code presented above ...     
            break;               
        case MY_LSHIFT:           
            if (record->event.pressed) {
                physical_mods |= MOD_BIT(KC_LSHIFT);
                register_code(KC_LSHIFT);
            } else {             
                physical_mods &= ~MOD_BIT(KC_LSHIFT);
                unregister_code(KC_LSHIFT);
            }                     
            break;               
    }                             
}
Title: Re: TMK keyboard firmware
Post by: ratch on Mon, 07 December 2015, 00:21:06
Ah, OK. I just saw your post was edited now :D

anyway, what I meant is like below.

Code: [Select]
static uint8_t physical_mods = 0;     
                                 
void action_function(keyrecord_t *record, uint8_t id, uint8_t opt)
{                                 
    switch (id) {                 
        case REVESED_SHIFT_1:     
            ... your code presented above ...     
            break;               
        case MY_LSHIFT:           
            if (record->event.pressed) {
                physical_mods |= MOD_BIT(KC_LSHIFT);
                register_code(KC_LSHIFT);
            } else {             
                physical_mods &= ~MOD_BIT(KC_LSHIFT);
                unregister_code(KC_LSHIFT);
            }                     
            break;               
    }                             
}

Seems to work exactly how I expected. The only downside to this method is that the shift modifier is active when holding down any of the numbers. Pressing other keys before releasing a number will have a shift modifier active, but I suppose it's not a big concern. Thanks, Hasu!
Title: Re: TMK keyboard firmware
Post by: hasu on Mon, 07 December 2015, 01:10:48
ratch, great.
Can you post your code and share it? It would be useful for someone else. Thanks,
Title: Re: TMK keyboard firmware
Post by: ratch on Tue, 08 December 2015, 02:51:45
ratch, great.
Can you post your code and share it? It would be useful for someone else. Thanks,

Sure thing.

https://github.com/matthewjf/tmk_firmware/blob/master/keyboard/gh60/keymap_poker.c
Title: Re: TMK keyboard firmware
Post by: ratch on Tue, 08 December 2015, 03:09:07
One more question. I made a small change to layer_state_set so that it also updates the keyboard LEDs. When I tap or toggle a layer, it will update the LEDs no problem. When I press & hold, there's a slight delay between when I press the key and the LEDs update. If I tap that same key, there's no delay. Do you have any idea why this might be happening? All my other key presses recognize the correct layer (no delay).
Title: Re: TMK keyboard firmware
Post by: nephiel on Tue, 08 December 2015, 05:30:35
One more question. I made a small change to layer_state_set so that it also updates the keyboard LEDs. When I tap or toggle a layer, it will update the LEDs no problem. When I press & hold, there's a slight delay between when I press the key and the LEDs update. If I tap that same key, there's no delay. Do you have any idea why this might be happening? All my other key presses recognize the correct layer (no delay).
A tap is sent as soon as you release a key that's been held for less than TAPPING_TERM milliseconds, so it's immediate. But that means it takes TAPPING_TERM milliseconds of holding down a key for it to react as a press & hold - that might be the 'delay' you see.

You can define TAPPING_TERM to a lower value in config.h. I think by default it's set to 500 or something like that, so that's 0.5 seconds, I'd try 200.

In any case, there must always be some delay, otherwise there'd be no way for the board to tell apart a tap from a press & hold.
Title: Re: TMK keyboard firmware
Post by: ratch on Tue, 08 December 2015, 20:43:18
One more question. I made a small change to layer_state_set so that it also updates the keyboard LEDs. When I tap or toggle a layer, it will update the LEDs no problem. When I press & hold, there's a slight delay between when I press the key and the LEDs update. If I tap that same key, there's no delay. Do you have any idea why this might be happening? All my other key presses recognize the correct layer (no delay).
A tap is sent as soon as you release a key that's been held for less than TAPPING_TERM milliseconds, so it's immediate. But that means it takes TAPPING_TERM milliseconds of holding down a key for it to react as a press & hold - that might be the 'delay' you see.

You can define TAPPING_TERM to a lower value in config.h. I think by default it's set to 500 or something like that, so that's 0.5 seconds, I'd try 200.

In any case, there must always be some delay, otherwise there'd be no way for the board to tell apart a tap from a press & hold.

Interesting. I've never really noticed a delay on my key presses when holding a layer key but it's definitely possible that it appears there as well. I could probably test this by jacking up the tapping_term but it's really not a big deal. I just wanted to make sure there wasn't a better place for me to be updating the LEDs. From the sound of it, the behavior is expected. Thanks, nephiel!
Title: Re: TMK keyboard firmware
Post by: nephiel on Wed, 09 December 2015, 15:41:43
Note the delay only counts when holding a single key - there is no delay when tapping a second key while holding the first one, because as soon as the second one is tapped, it overrides the hold on the first. So you'd never really notice it unless you use LEDs to show layer state (I do, too).
Title: Re: TMK keyboard firmware
Post by: BlueNalgene on Thu, 10 December 2015, 09:51:03
Hardware issue question:

I put together an Alps64 to test, and row 4 is misbehaving.  Any time I press a key in row 4, all of the the keys in the column are 'pressed'.  e.g. when I press 43, it sends the signals for 13, 23, 33, 43, 53, 63, 73.  The notable exception is switch K41, which has no switch installed, yet when I short the connection (closing the circuit) it only sends 41.  All of the diodes appear to be in the correct orientation.  I can't find the issue.  I would think if there was a problem like loose solder, the keystrokes would be sending constantly.
Title: Re: TMK keyboard firmware
Post by: VinnyCordeiro on Thu, 10 December 2015, 09:58:16
Hardware issue question:

I put together an Alps64 to test, and row 4 is misbehaving.  Any time I press a key in row 4, all of the the keys in the column are 'pressed'.  e.g. when I press 43, it sends the signals for 13, 23, 33, 43, 53, 63, 73.  The notable exception is switch K41, which has no switch installed, yet when I short the connection (closing the circuit) it only sends 41.  All of the diodes appear to be in the correct orientation.  I can't find the issue.  I would think if there was a problem like loose solder, the keystrokes would be sending constantly.
Did you hand-soldered the microcontroller on the PCB? This same behavior happened on a prototype keyboard I made and I found that it was caused by a short circuit on microcontroller pins. I solved the problem using solder wick on them.
Title: Re: TMK keyboard firmware
Post by: BlueNalgene on Thu, 10 December 2015, 10:13:42
Hardware issue question:

I put together an Alps64 to test, and row 4 is misbehaving.  Any time I press a key in row 4, all of the the keys in the column are 'pressed'.  e.g. when I press 43, it sends the signals for 13, 23, 33, 43, 53, 63, 73.  The notable exception is switch K41, which has no switch installed, yet when I short the connection (closing the circuit) it only sends 41.  All of the diodes appear to be in the correct orientation.  I can't find the issue.  I would think if there was a problem like loose solder, the keystrokes would be sending constantly.
Did you hand-soldered the microcontroller on the PCB? This same behavior happened on a prototype keyboard I made and I found that it was caused by a short circuit on microcontroller pins. I solved the problem using solder wick on them.

No, this is a hasu creation which he oven soldered.  When I discovered the error, I checked solder joints.  There was a bad spot on the microcontroller.  I used wick on it, and it did not help.  Although, I might have made it a mess.
Title: Re: TMK keyboard firmware
Post by: hasu on Thu, 10 December 2015, 10:31:24
Hmm, assuming diodes are in correct direction short circuit on adjacent pins of MCU is most likely cause. Can you drag solder on pins again with flux?
Title: Re: TMK keyboard firmware
Post by: BlueNalgene on Thu, 10 December 2015, 10:33:24
Hmm, assuming diodes are in correct direction short circuit on adjacent pins of MCU is most likely cause. Can you drag solder on pins again with flux?

I brought it to my lab since I have better tools here.  If I get a free moment I will play with it and report back. 

I'm leaving the country today, and I was hoping to take this with me.  Can you imagine a whole week without a keyboard?
Title: Re: TMK keyboard firmware
Post by: BlueNalgene on Thu, 10 December 2015, 12:12:47
Wicking did not fix the problem. 

The 'bad spot' I noticed before was some solder connecting two pins on the controller.  Checking the KiCAD files for 23 and 24, these should be connected.  Therefore it isn't an issue.
Title: Re: TMK keyboard firmware
Post by: BlueNalgene on Thu, 10 December 2015, 17:01:01
I must have not said the magic words.  I checked the diodes with a multimeter, and checked that they weren't shorting across the diodes.  Then I unsoldered the switches in the 4 row.  When I soldered them back in, everything was fixed.  Magic.
Title: Re: TMK keyboard firmware
Post by: deductivemonkee on Thu, 10 December 2015, 17:05:44
I must have not said the magic words.  I checked the diodes with a multimeter, and checked that they weren't shorting across the diodes.  Then I unsoldered the switches in the 4 row.  When I soldered them back in, everything was fixed.  Magic.

Phew! You had me worried for a second
Title: Re: TMK keyboard firmware
Post by: hasu on Thu, 10 December 2015, 17:25:13
Great. Glad to hear that.

I had shallow sleep last night and this still scares me terribly, because annoying hardware/soldering problem like this can be happened to many Alps GB paticipants and most of them probably are not patient and don't have decent tools unlike you. Now I worry about diffculty in discrimination between their problem or my failure on board production.

Anyway, my worry is off topic here.
Title: Re: TMK keyboard firmware
Post by: BlueNalgene on Thu, 10 December 2015, 23:30:03
Great. Glad to hear that.

I had shallow sleep last night and this still scares me terribly, because annoying hardware/soldering problem like this can be happened to many Alps GB paticipants and most of them probably are not patient and don't have decent tools unlike you. Now I worry about diffculty in discrimination between their problem or my failure on board production.

Anyway, my worry is off topic here.

It is a valid concern.  Hardware problems are a lot more difficult to diagnose over a few thousand miles.  One of the purposes of me building this out early, is that I can notice things that other users might have questions about as they build them (Oh no, Idon't have a switch in K41 because of my Infinity layout, could that be why I have issues? Etc.)
Title: Re: TMK keyboard firmware
Post by: TalkingTree on Sun, 13 December 2015, 13:05:07
I need help.
I'm using a Filco TKL with a Pegasus Hoof 2015 revision.
My goal is to add extra key between Equal/Plus and Backspace.
The key is labeled J14 on the PCB, as you can see here (http://img.photobucket.com/albums/v288/WhiteFireDragon/keyboard/Filcosingle-sided.jpg) (right under the USB connector).


Now, I used keymap.c and matrix.c from vpont's fork of the TMK firmware (https://github.com/vpont/tmk_keyboard/tree/master/keyboard/pegasus_hoof), as he already included the 2015 revision, and made the following changes:


In keymap.c I added the KB5 entry in the matrix as it's the entry for the J14 key. Like this:
Code: [Select]
//KB5 is J14 and belongs to JIS
#define KEYMAP( \
    KJ6, KI4, KH4, KH2, KH6, KA7, KE6, KD2, KD4, KB4, KB7, KB6, KB0,      KC7, KC5, KA5, \
    KJ4, KJ7, KI7, KH7, KG7, KG4, KF4, KF7, KE7, KD7, KR7, KR4, KE4, KB5, KB2, KL4, KO4, KQ4, \
KJ2, KJ5, KI5, KH5, KG5, KG2, KF2, KF5, KE5, KD5, KR5, KR2, KE2, KB3, KK4, KO7, KQ7, \
KI2, KJ3, KI3, KH3, KG3, KG6, KF6, KF3, KE3, KD3, KR3, KR6, KB1,                     \
KN2, KI6, KJ1, KI1, KH1, KG1, KG0, KF0, KF1, KE1, KD1, KR0, KN3,           KO6,      \
    KA4, KP2, KC6,           KK6,                     KC3, KM3, KD0, KA1, KO0, KK0, KL0  \
) { \
/*             0         1         2         3         4         5         6         7     */ \
/* A */   { KC_NO,    KC_##KA1, KC_NO,    KC_NO   , KC_##KA4, KC_##KA5, KC_NO   , KC_##KA7 }, \
/* B */   { KC_##KB0, KC_##KB1, KC_##KB2, KC_##KB3, KC_##KB4, KC_##KB5, KC_##KB6, KC_##KB7 }, \
/* C */   { KC_NO,    KC_NO,    KC_NO,    KC_##KC3, KC_NO   , KC_##KC5, KC_##KC6, KC_##KC7 }, \
/* D */   { KC_##KD0, KC_##KD1, KC_##KD2, KC_##KD3, KC_##KD4, KC_##KD5, KC_NO   , KC_##KD7 }, \
/* E */   { KC_NO,    KC_##KE1, KC_##KE2, KC_##KE3, KC_##KE4, KC_##KE5, KC_##KE6, KC_##KE7 }, \
/* F */   { KC_##KF0, KC_##KF1, KC_##KF2, KC_##KF3, KC_##KF4, KC_##KF5, KC_##KF6, KC_##KF7 }, \
/* G */   { KC_##KG0, KC_##KG1, KC_##KG2, KC_##KG3, KC_##KG4, KC_##KG5, KC_##KG6, KC_##KG7 }, \
/* H */   { KC_NO,    KC_##KH1, KC_##KH2, KC_##KH3, KC_##KH4, KC_##KH5, KC_##KH6, KC_##KH7 }, \
/* I */   { KC_NO,    KC_##KI1, KC_##KI2, KC_##KI3, KC_##KI4, KC_##KI5, KC_##KI6, KC_##KI7 }, \
/* J */   { KC_NO,    KC_##KJ1, KC_##KJ2, KC_##KJ3, KC_##KJ4, KC_##KJ5, KC_##KJ6, KC_##KJ7 }, \
/* K */   { KC_##KK0, KC_NO,    KC_NO,    KC_NO   , KC_##KK4, KC_NO   , KC_##KK6, KC_NO    }, \
/* L */   { KC_##KL0, KC_NO,    KC_NO   , KC_NO   , KC_##KL4, KC_NO   , KC_NO   , KC_NO    }, \
/* M */   { KC_NO,    KC_NO,    KC_NO   , KC_##KM3, KC_NO   , KC_NO   , KC_NO   , KC_NO    }, \
/* N */   { KC_NO   , KC_NO,    KC_##KN2, KC_##KN3, KC_NO   , KC_NO   , KC_NO   , KC_NO    }, \
/* O */   { KC_##KO0, KC_NO,    KC_NO   , KC_NO   , KC_##KO4, KC_NO   , KC_##KO6, KC_##KO7 }, \
/* P */   { KC_NO   , KC_NO,    KC_##KP2, KC_NO   , KC_NO   , KC_NO   , KC_NO   , KC_NO    }, \
/* Q */   { KC_NO   , KC_NO,    KC_NO,    KC_NO   , KC_##KQ4, KC_NO   , KC_NO   , KC_##KQ7 }, \
/* R */   { KC_##KR0, KC_NO,    KC_##KR2, KC_##KR3, KC_##KR4, KC_##KR5, KC_##KR6, KC_##KR7 }  \
}


In led.c I replaced USB_LED_CAPS_LOCK with USB_LED_NUM_LOCK (Just stating for the sake of it but I doubt it causes any issue).


And this would be my keymap.h
Code: [Select]
static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
// Default layer


  KEYMAP(\
      ESC,   F1,   F2,   F3,   F4,   F5,   F6,   F7,   F8,   F9,  F10,  F11,  F12,       PSCR, SLCK,  BRK, \
      GRV,    1,    2,    3,    4,    5,    6,    7,    8,    9,    0, MINS,  EQL, BSLS, NUBS,  INS, HOME, PGUP, \
      TAB,    Q,    W,    E,    R,    T,    Y,    U,    I,    O,    P, LBRC, RBRC, BSPC,  DEL,  END, PGDN, \
    LCTRL,    A,    S,    D,    F,    G,    H,    J,    K,    L, SCLN, QUOT,        ENT,                   \ 
     LSFT, NUBS,    Z,    X,    C,    V,    B,    N,    M, COMM,  DOT, SLSH,       RSFT,         UP,       \
     FN0, LGUI, LALT,              SPC,                         RALT, RGUI,  APP, RCTL, LEFT, DOWN, RGHT),


// Layer 1
  KEYMAP(\
      PWR,   F1,   F2,   F3,   F4,   F5,   F6,   F7,   F8,   F9,  F10,  F11,  F12,       PSCR, LNUM,  BOOTLOADER, \
      GRV,    1,    2,    3,    4,    5,    6,   P7,   P8,   P9,    PSLS, MINS,  EQL, BSLS, NUBS,  INS, HOME, PGUP, \
      TAB,    HOME, UP,   END,  R,    T,    Y,   P4,   P5,   P6,    PAST, LBRC, RBRC, DEL,  DEL,  END, PGDN, \
    LCTRL,    LEFT, DOWN, RIGHT,F,    G,    H,   P1,   P2,   P3,  PMNS, QUOT,        ENT,                   \ 
     LSFT, NUBS,    Z,    X,    CALC,    V,    B,    N,   P0, P0,  PDOT, PPLS,       RSFT,         VOLU,       \
     FN0,   LGUI, LALT,             PENT,                         RALT, RGUI,  CAPS, RCTL, MPRV, VOLD, MNXT),


};


static const uint16_t PROGMEM fn_actions[] = {
[0] = ACTION_LAYER_MOMENTARY(1), // activate layer 1 when FN1 pressed
};
Everything compiles just fine, but when I load the hex to my board, it goes wild. It only registers one keystroke every now and then and it returns the wrong key, often numbers.
It's basically unusable.


My knowledge of C is very limited so I can't figure out what's going on [/size]on my own[/size][size=78%].[/size]
Is anyone sparing a moment to take a look at this?


Thanks.

Title: Re: TMK keyboard firmware
Post by: Zorberema on Mon, 14 December 2015, 04:01:05
Hey!

I've tried to make it further into the coding, but whenever I try to compile I get loads of warnings together with one error, which says:
Code: [Select]
keymap_poker.c:21: error: expected '}' before ';' token
This is my keymap_poker.c file:
Code: [Select]
#include "keymap_common.h"

const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  /* 0: qwerty */
  KEYMAP(Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P, 
            A,   S,   D,   F,   G,   H,   J,   K,   L,   
              Z,   X,   C,   V,   B,   N,   M, RSFT,     
                        FN0,   SPC,    FN1),

  /* 1: FN 1 */
  KEYMAP(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),

  /* 2: FN 2 */
  KEYMAP(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[] = {
[0] = ACTION_LAYER_MOMENTARY(1)
[1] = ACTION_LAYER_MOMENTARY(2)
};

Thankfull for any help I can get!  :)
Title: Re: TMK keyboard firmware
Post by: TalkingTree on Mon, 14 December 2015, 05:11:52
Try this.
Backslashes are mandatory to tell the compiler the code continues to the next line (you might want to align them properly) and you missed a comma between your fn_actions.


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

const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  /* 0: qwerty */
  KEYMAP(Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,  \
            A,   S,   D,   F,   G,   H,   J,   K,   L,              \
              Z,   X,   C,   V,   B,   N,   M, RSFT,             \
                        FN0,   SPC,    FN1),                          \

  /* 1: FN 1 */
  KEYMAP(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),                                                             \

  /* 2: FN 2 */
  KEYMAP(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[] = {
[0] = ACTION_LAYER_MOMENTARY(1),
[1] = ACTION_LAYER_MOMENTARY(2)
};
Title: Re: TMK keyboard firmware
Post by: Zorberema on Mon, 14 December 2015, 05:36:38
Thanks for the notice; tried adding both things, but still no difference whatsoever... :(
Title: Re: TMK keyboard firmware
Post by: mrbishop on Mon, 14 December 2015, 07:49:14
i took a look over my firmware and my device manager settings and i didnt see anything out of the ordinary.
my keyboard is still not waking my surface (either of them Pro2 or 3) from sleep. when it sleeps the keyboard stops responding until i unplug and plug it back in.

any thoughts?
Title: Re: TMK keyboard firmware
Post by: hasu on Mon, 14 December 2015, 14:06:09
i took a look over my firmware and my device manager settings and i didnt see anything out of the ordinary.
my keyboard is still not waking my surface (either of them Pro2 or 3) from sleep. when it sleeps the keyboard stops responding until i unplug and plug it back in.

any thoughts?
Console feature has problems in some situations. Try disabling it if you have the build option in your makefile.
Title: Re: TMK keyboard firmware
Post by: mrbishop on Mon, 14 December 2015, 14:06:57
i took a look over my firmware and my device manager settings and i didnt see anything out of the ordinary.
my keyboard is still not waking my surface (either of them Pro2 or 3) from sleep. when it sleeps the keyboard stops responding until i unplug and plug it back in.

any thoughts?
Console feature has problems in some situations. Try disabling it if you have the build option in your makefile.
Cool I'll give that a try tonight. Thanks
Title: Re: TMK keyboard firmware
Post by: hasu on Mon, 14 December 2015, 14:53:03
I need help.
I'm using a Filco TKL with a Pegasus Hoof 2015 revision.
My goal is to add extra key between Equal/Plus and Backspace.
The key is labeled J14 on the PCB, as you can see here (http://img.photobucket.com/albums/v288/WhiteFireDragon/keyboard/Filcosingle-sided.jpg) (right under the USB connector).


Now, I used keymap.c and matrix.c from vpont's fork of the TMK firmware (https://github.com/vpont/tmk_keyboard/tree/master/keyboard/pegasus_hoof), as he already included the 2015 revision, and made the following changes:


In keymap.c I added the KB5 entry in the matrix as it's the entry for the J14 key. Like this:
Code: [Select]
//KB5 is J14 and belongs to JIS
#define KEYMAP( \
    KJ6, KI4, KH4, KH2, KH6, KA7, KE6, KD2, KD4, KB4, KB7, KB6, KB0,      KC7, KC5, KA5, \
    KJ4, KJ7, KI7, KH7, KG7, KG4, KF4, KF7, KE7, KD7, KR7, KR4, KE4, KB5, KB2, KL4, KO4, KQ4, \
KJ2, KJ5, KI5, KH5, KG5, KG2, KF2, KF5, KE5, KD5, KR5, KR2, KE2, KB3, KK4, KO7, KQ7, \
KI2, KJ3, KI3, KH3, KG3, KG6, KF6, KF3, KE3, KD3, KR3, KR6, KB1,                     \
KN2, KI6, KJ1, KI1, KH1, KG1, KG0, KF0, KF1, KE1, KD1, KR0, KN3,           KO6,      \
    KA4, KP2, KC6,           KK6,                     KC3, KM3, KD0, KA1, KO0, KK0, KL0  \
) { \
/*             0         1         2         3         4         5         6         7     */ \
/* A */   { KC_NO,    KC_##KA1, KC_NO,    KC_NO   , KC_##KA4, KC_##KA5, KC_NO   , KC_##KA7 }, \
/* B */   { KC_##KB0, KC_##KB1, KC_##KB2, KC_##KB3, KC_##KB4, KC_##KB5, KC_##KB6, KC_##KB7 }, \
/* C */   { KC_NO,    KC_NO,    KC_NO,    KC_##KC3, KC_NO   , KC_##KC5, KC_##KC6, KC_##KC7 }, \
/* D */   { KC_##KD0, KC_##KD1, KC_##KD2, KC_##KD3, KC_##KD4, KC_##KD5, KC_NO   , KC_##KD7 }, \
/* E */   { KC_NO,    KC_##KE1, KC_##KE2, KC_##KE3, KC_##KE4, KC_##KE5, KC_##KE6, KC_##KE7 }, \
/* F */   { KC_##KF0, KC_##KF1, KC_##KF2, KC_##KF3, KC_##KF4, KC_##KF5, KC_##KF6, KC_##KF7 }, \
/* G */   { KC_##KG0, KC_##KG1, KC_##KG2, KC_##KG3, KC_##KG4, KC_##KG5, KC_##KG6, KC_##KG7 }, \
/* H */   { KC_NO,    KC_##KH1, KC_##KH2, KC_##KH3, KC_##KH4, KC_##KH5, KC_##KH6, KC_##KH7 }, \
/* I */   { KC_NO,    KC_##KI1, KC_##KI2, KC_##KI3, KC_##KI4, KC_##KI5, KC_##KI6, KC_##KI7 }, \
/* J */   { KC_NO,    KC_##KJ1, KC_##KJ2, KC_##KJ3, KC_##KJ4, KC_##KJ5, KC_##KJ6, KC_##KJ7 }, \
/* K */   { KC_##KK0, KC_NO,    KC_NO,    KC_NO   , KC_##KK4, KC_NO   , KC_##KK6, KC_NO    }, \
/* L */   { KC_##KL0, KC_NO,    KC_NO   , KC_NO   , KC_##KL4, KC_NO   , KC_NO   , KC_NO    }, \
/* M */   { KC_NO,    KC_NO,    KC_NO   , KC_##KM3, KC_NO   , KC_NO   , KC_NO   , KC_NO    }, \
/* N */   { KC_NO   , KC_NO,    KC_##KN2, KC_##KN3, KC_NO   , KC_NO   , KC_NO   , KC_NO    }, \
/* O */   { KC_##KO0, KC_NO,    KC_NO   , KC_NO   , KC_##KO4, KC_NO   , KC_##KO6, KC_##KO7 }, \
/* P */   { KC_NO   , KC_NO,    KC_##KP2, KC_NO   , KC_NO   , KC_NO   , KC_NO   , KC_NO    }, \
/* Q */   { KC_NO   , KC_NO,    KC_NO,    KC_NO   , KC_##KQ4, KC_NO   , KC_NO   , KC_##KQ7 }, \
/* R */   { KC_##KR0, KC_NO,    KC_##KR2, KC_##KR3, KC_##KR4, KC_##KR5, KC_##KR6, KC_##KR7 }  \
}


In led.c I replaced USB_LED_CAPS_LOCK with USB_LED_NUM_LOCK (Just stating for the sake of it but I doubt it causes any issue).


And this would be my keymap.h
Code: [Select]
static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
// Default layer


  KEYMAP(\
      ESC,   F1,   F2,   F3,   F4,   F5,   F6,   F7,   F8,   F9,  F10,  F11,  F12,       PSCR, SLCK,  BRK, \
      GRV,    1,    2,    3,    4,    5,    6,    7,    8,    9,    0, MINS,  EQL, BSLS, NUBS,  INS, HOME, PGUP, \
      TAB,    Q,    W,    E,    R,    T,    Y,    U,    I,    O,    P, LBRC, RBRC, BSPC,  DEL,  END, PGDN, \
    LCTRL,    A,    S,    D,    F,    G,    H,    J,    K,    L, SCLN, QUOT,        ENT,                   \ 
     LSFT, NUBS,    Z,    X,    C,    V,    B,    N,    M, COMM,  DOT, SLSH,       RSFT,         UP,       \
     FN0, LGUI, LALT,              SPC,                         RALT, RGUI,  APP, RCTL, LEFT, DOWN, RGHT),


// Layer 1
  KEYMAP(\
      PWR,   F1,   F2,   F3,   F4,   F5,   F6,   F7,   F8,   F9,  F10,  F11,  F12,       PSCR, LNUM,  BOOTLOADER, \
      GRV,    1,    2,    3,    4,    5,    6,   P7,   P8,   P9,    PSLS, MINS,  EQL, BSLS, NUBS,  INS, HOME, PGUP, \
      TAB,    HOME, UP,   END,  R,    T,    Y,   P4,   P5,   P6,    PAST, LBRC, RBRC, DEL,  DEL,  END, PGDN, \
    LCTRL,    LEFT, DOWN, RIGHT,F,    G,    H,   P1,   P2,   P3,  PMNS, QUOT,        ENT,                   \ 
     LSFT, NUBS,    Z,    X,    CALC,    V,    B,    N,   P0, P0,  PDOT, PPLS,       RSFT,         VOLU,       \
     FN0,   LGUI, LALT,             PENT,                         RALT, RGUI,  CAPS, RCTL, MPRV, VOLD, MNXT),


};


static const uint16_t PROGMEM fn_actions[] = {
[0] = ACTION_LAYER_MOMENTARY(1),// activate layer 1 when FN1 pressed
};
Everything compiles just fine, but when I load the hex to my board, it goes wild. It only registers one keystroke every now and then and it returns the wrong key, often numbers.
It's basically unusable.


My knowledge of C is very limited so I can't figure out what's going on [/size]on my own[/size][size=78%].[/size]
Is anyone sparing a moment to take a look at this?


Thanks.
Firstly, Did it work before you modified?
It seems to me your code is ok.

Are you sure your board revision?
Are you sure that firmware for 2015 revision ?
Are you sure the key matrix position?
Title: Re: TMK keyboard firmware
Post by: VinnyCordeiro on Mon, 14 December 2015, 15:15:18
I'm programming an spare of my custom designed PCB and preparing it for ABNT2. The PCB works with ANSI layout flawless and beautifully, so I just need to solve 2 questions.

Keep in mind that, as suggested by the USB HID standard, I'll have to program the keyboard firmware using US ANSI codes and let the operating system convert it back to PT-BR.

I've used two programs to test an ABNT2 keyboard I have here at home (rubber dome, unfortunately): Aqua'S KeyTest and Switch Hitter. Layout for UK ISO, US ANSI & BR ABNT2 in the image below for reference:

[attach=1]

Questions:

The cyan button (BIOS code 0x73 and Windows code 0xC1) is to be set as INT1, as I read on the USB HID standard, if I'm not mistaken.
Title: Re: TMK keyboard firmware
Post by: TalkingTree on Mon, 14 December 2015, 15:23:28
Are you sure the key matrix position?
You're right, I got the layout from here (http://deskthority.net/wiki/Controller_matrix_traces#Filco_Majestouch_TKL), but bpiphany's code (https://github.com/BathroomEpiphanies/tmk_keyboard/blob/master/keyboard/be_pegasus_hoof_20150108/keymap.c) looks much different, I'll try with his.
Thanks for your time.
Title: Re: TMK keyboard firmware
Post by: hasu on Mon, 14 December 2015, 17:06:14
Hey!

I've tried to make it further into the coding, but whenever I try to compile I get loads of warnings together with one error, which says:
Code: [Select]
keymap_poker.c:21: error: expected '}' before ';' token
This is my keymap_poker.c file:
Code: [Select]
#include "keymap_common.h"

const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  /* 0: qwerty */
  KEYMAP(Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P, 
            A,   S,   D,   F,   G,   H,   J,   K,   L,   
              Z,   X,   C,   V,   B,   N,   M, RSFT,     
                        FN0,   SPC,    FN1),

  /* 1: FN 1 */
  KEYMAP(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),

  /* 2: FN 2 */
  KEYMAP(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[] = {
[0] = ACTION_LAYER_MOMENTARY(1)
[1] = ACTION_LAYER_MOMENTARY(2)
};

Thankfull for any help I can get!  :)

Probably your KEYMAP macro definition causes the error.
Title: Re: TMK keyboard firmware
Post by: mrbishop on Mon, 14 December 2015, 19:17:22
i took a look over my firmware and my device manager settings and i didnt see anything out of the ordinary.
my keyboard is still not waking my surface (either of them Pro2 or 3) from sleep. when it sleeps the keyboard stops responding until i unplug and plug it back in.

any thoughts?
Console feature has problems in some situations. Try disabling it if you have the build option in your makefile.

i disabled all the things i didnt think were necessary. seems to be working for the moment. i'll be doing ongoing testing. thanks for the tip Hasu
Title: Re: TMK keyboard firmware
Post by: hasu on Mon, 14 December 2015, 19:34:39
i took a look over my firmware and my device manager settings and i didnt see anything out of the ordinary.
my keyboard is still not waking my surface (either of them Pro2 or 3) from sleep. when it sleeps the keyboard stops responding until i unplug and plug it back in.

any thoughts?
Console feature has problems in some situations. Try disabling it if you have the build option in your makefile.

i disabled all the things i didnt think were necessary. seems to be working for the moment. i'll be doing ongoing testing. thanks for the tip Hasu

Great. If you can take time to narrow down which is exactly the cause of your problem, it would be appreciated.
Do you think the console is the cause or else?
Title: Re: TMK keyboard firmware
Post by: hasu on Mon, 14 December 2015, 21:21:48
I'm programming an spare of my custom designed PCB and preparing it for ABNT2. The PCB works with ANSI layout flawless and beautifully, so I just need to solve 2 questions.

Keep in mind that, as suggested by the USB HID standard, I'll have to program the keyboard firmware using US ANSI codes and let the operating system convert it back to PT-BR.

I've used two programs to test an ABNT2 keyboard I have here at home (rubber dome, unfortunately): Aqua'S KeyTest and Switch Hitter. Layout for UK ISO, US ANSI & BR ABNT2 in the image below for reference:

(Attachment Link)

Questions:
  • The red key is BACKSLASH on US ANSI, the programs confirmed that. But on the ABNT2 keyboard it is located where in the UK ISO it should be NONUS_HASH. Is there any problem on using BACKSLASH over NONUS_HASH?
  • Is the yellow key (BIOS code 0x56 and Windows code 0xE2) supposed to be NONUS_BSLASH? At this location both UK ANSI & BR ABNT2 are the same.

The cyan button (BIOS code 0x73 and Windows code 0xC1) is to be set as INT1, as I read on the USB HID standard, if I'm not mistaken.

Firstly, you cannot see real code sent from your keyboard with Aqua's tool and SwitchHitter.(I never tried SwitchHitter, I may be wrong about it, perhaps.) What you are seeing is virtual Windows scancode trasnlated by the OS. I think you'll have to use USB packet capture tool like wireshark to see real USB code.

I don't have any USB ISO/JIS/Brazilian keyboards and don't know what they send in real. But I'm also interested to know, it would be nice if you or someone can see them with capture tool.

You can know how Windows translates real USB codes into Windows scancodes with MIcrosoft document, see below. Windows scanocds is PS/2 scan code set 1 in fact.

Fun keyboard trivia: Windows still uses XT scancode(PS/2 set1) interanlly and Mac still uses ADB.

1. I don't know. Try it and report!
2. I think so.

I recommend to conform to HID spec first, if you have any problem let us know. It would be an interesting topic.



Today I learnt:
I had to search these things on the web to write this. Writing down these here may be useful for someone sometime.

ABNT2: Portuguese–Brazilian keyboard layout https://msdn.microsoft.com/en-us/library/cc195107.aspx
PT-BR: Portuguese Brazil locale
Aqua's Keytest: key test tool https://geekhack.org/index.php?topic=6643.0
Switch Hitter: Keyboard Diagnostic Software https://elitekeyboards.com/switchhitter.php

BIOS code: Windows scancodes  http://download.microsoft.com/download/1/6/1/161ba512-40e2-4cc9-843a-923143f3456c/translate.pdf
Windows code: virtual keycodes for GUI? https://msdn.microsoft.com/library/windows/desktop/dd375731(v=vs.85).aspx

And you can refer it about USB HID codes, around pp.54.
HID usage table: http://www.usb.org/developers/hidpage/Hut1_12v2.pdf
Title: Re: TMK keyboard firmware
Post by: mrbishop on Mon, 14 December 2015, 21:25:22
i took a look over my firmware and my device manager settings and i didnt see anything out of the ordinary.
my keyboard is still not waking my surface (either of them Pro2 or 3) from sleep. when it sleeps the keyboard stops responding until i unplug and plug it back in.

any thoughts?
Console feature has problems in some situations. Try disabling it if you have the build option in your makefile.

i disabled all the things i didnt think were necessary. seems to be working for the moment. i'll be doing ongoing testing. thanks for the tip Hasu

Great. If you can take time to narrow down which is exactly the cause of your problem, it would be appreciated.
Do you think the console is the cause or else?
Console was not it. I'll have to test them one at a time which will take awhile. But I'll report back here in a day or so
Title: Re: TMK keyboard firmware
Post by: Zorberema on Tue, 15 December 2015, 01:51:05
Probably your KEYMAP macro definition causes the error.

Thanks! I had forgotten to place some brackets, which caused the error! That solved that error at least... Now there's 4 more..!
Title: Re: TMK keyboard firmware
Post by: mrbishop on Tue, 15 December 2015, 08:23:09
i took a look over my firmware and my device manager settings and i didnt see anything out of the ordinary.
my keyboard is still not waking my surface (either of them Pro2 or 3) from sleep. when it sleeps the keyboard stops responding until i unplug and plug it back in.

any thoughts?
Console feature has problems in some situations. Try disabling it if you have the build option in your makefile.

i disabled all the things i didnt think were necessary. seems to be working for the moment. i'll be doing ongoing testing. thanks for the tip Hasu

Great. If you can take time to narrow down which is exactly the cause of your problem, it would be appreciated.
Do you think the console is the cause or else?

After testing it appears the combo of Sleep LED Enable and Command Enable were the combined issue. after commenting both out all is well with the world.
Title: Re: TMK keyboard firmware
Post by: VinnyCordeiro on Tue, 15 December 2015, 09:49:25
ABNT2: Portuguese–Brazilian keyboard layout https://msdn.microsoft.com/en-us/library/cc195107.aspx
The link hasu has posted is an US ANSI keyboard physical key layout with the logical PT-BR ABNT2 keys. The physical layout, as I usually says, is a modified version of ISO, including the JIS layout split right Shift for an extra 1u key. Wikipedia shows it: https://en.wikipedia.org/wiki/QWERTY#Brazil
Title: Re: TMK keyboard firmware
Post by: Zorberema on Wed, 16 December 2015, 15:29:16
Sorry for posting so frequently appart, but there seems to be more and more errors popping up every time I solve one...

I was able to sort the last error out with your help, but now there's 4 new that I have no clue on how to solve.. Here's what the current ones says:

Code: [Select]
keymap_poker.c:3: error: static declaration of 'keymaps' follows non-static declaration
keymap_common.h:33: error: previous declaration of 'keymaps' was here
keymap_poker.c:22: error: static declaration of 'fn_actions' follows non-static declaration
keymap_common.h:34: error: previous declaration of 'fn_actions' was here
make: *** [obj_gh60_lufa/keymap_poker.o] Error 1

I figure that they're connected between the 2 files, but since my coding knowledge is... limited... I have no clue on how to go about fixing this!

Here's my keymap_common.h file:
Code: [Select]
#ifndef KEYMAP_COMMON_H
#define KEYMAP_COMMON_H

#include <stdint.h>
#include <stdbool.h>
#include <avr/pgmspace.h>
#include "keycode.h"
#include "action.h"
#include "action_macro.h"
#include "report.h"
#include "host.h"
#include "print.h"
#include "debug.h"
#include "keymap.h"


extern const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS];
extern const uint16_t fn_actions[];


/* 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, \
    K11, K12, K13, K14, K15, K16, K17, K18, K19, \
    K21, K22, K23, K24, K25, K26, K27, K28, \
    K33, K35, K36 \
) { \
    { KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07, KC_##K08, KC_##K09}, \
    { KC_NO, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17, KC_##K18, KC_##K19}, \
    { KC_NO, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_##K27, KC_##K28, KC_NO}, \
    { KC_NO, KC_NO, KC_NO, KC_##K33, KC_NO, KC_##K35, KC_##K36, KC_NO, KC_NO, KC_NO}, \
}

/* 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

And my keymap_poker.c file:
Code: [Select]
#include "keymap_common.h"

const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  /* 0: qwerty */
  KEYMAP(Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,  \
            A,   S,   D,   F,   G,   H,   J,   K,   L,    \
              Z,   X,   C,   V,   B,   N,   M, RSFT,      \
                        FN0,   SPC,    FN1),

  /* 1: FN 1 */
  KEYMAP(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),

  /* 2: FN 2 */
  KEYMAP(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[] = {
[0] = ACTION_LAYER_MOMENTARY(1),
[1] = ACTION_LAYER_MOMENTARY(2)
};

As said; thankful for all the help I can get! Thank you so much for helping out! :)
Title: Re: TMK keyboard firmware
Post by: TalkingTree on Wed, 16 December 2015, 15:38:57
It compiled just fine here.
Maybe you're missing come gcc headers? Have you tried to update your system?
Title: Re: TMK keyboard firmware
Post by: Zorberema on Wed, 16 December 2015, 15:42:01
It compiled just fine here.
Maybe you're missing come gcc headers? Have you tried to update your system?

Sorry for my incompetence, but what is gcc headers? How would I go about updating the system? Also, how were you able to compile it without having the other files correct; I assume this hex file would not be useable on the keyboard as of now? Thanks for helping out; I'm new to this whole programming thing, haha! :)
Title: Re: TMK keyboard firmware
Post by: abjr on Wed, 16 December 2015, 15:45:06
It compiled just fine here.
Maybe you're missing come gcc headers? Have you tried to update your system?

It compiled fine here too. I would be careful about giving him that .hex file unless you know what his matrix.c looked like  ;)

@Zorberema, try a "make clean" and them compile again.
Title: Re: TMK keyboard firmware
Post by: Zorberema on Wed, 16 December 2015, 15:49:40
It compiled just fine here.
Maybe you're missing come gcc headers? Have you tried to update your system?

It compiled fine here too. I would be careful about giving him that .hex file unless you know what his matrix.c looked like  ;)

@Zorberema, try a "make clean" and them compile again.

 :thumb: Will try! Just gonna switch computer; updating in 5! :D
Title: Re: TMK keyboard firmware
Post by: TalkingTree on Wed, 16 December 2015, 15:51:19
but what is gcc headers? How would I go about updating the system?
I realise I was too vague, sorry for that.
I meant the C compiler. You should update it to the latest version available.

how were you able to compile it without having the other files correct;
I used GH60 files in TMK firmware and replaced the code you provided.

I assume this hex file would not be useable on the keyboard as of now?
Your FN layers are blank, so it will boot but won't be of much use.
Also, and most importantly, if your matrix.c is different it won't work at all.

Make sure you run "make -f Makefile clean" before "make -f Makefile".
Zip the whole folder and upload it here, I'll take a look.
Title: Re: TMK keyboard firmware
Post by: Zorberema on Wed, 16 December 2015, 15:57:31
but what is gcc headers? How would I go about updating the system?
I realise I was too vague, sorry for that.
I meant the C compiler. You should update it to the latest version available.

how were you able to compile it without having the other files correct;
I used GH60 files in TMK firmware and replaced the code you provided.

I assume this hex file would not be useable on the keyboard as of now?
Your FN layers are blank, so it will boot but won't be of much use.
Also, and most importantly, if your matrix.c is different it won't work at all.

Make sure you run "make -f Makefile clean" before "make -f Makefile".
Zip the whole folder and upload it here, I'll take a look.

Tried to clean, didn't work still... :/ The FN layers are blank on purpose, just to test things out! And yes, the matrix file is very different :P Here's the file anyways!
Title: Re: TMK keyboard firmware
Post by: TalkingTree on Wed, 16 December 2015, 16:08:15
Remove the word static before const from keymap_poker.c (occurs twice), clean and recompile.
Title: Re: TMK keyboard firmware
Post by: Zorberema on Wed, 16 December 2015, 16:16:24
Remove the word static before const from keymap_poker.c (occurs twice), clean and recompile.

Had to open several text editors and close down sublime text 2 times before I could see static written... It seemed to work now, but it made like 1000 different files; is that normal? I got a hex file in here, will try that out!
Title: Re: TMK keyboard firmware
Post by: TalkingTree on Wed, 16 December 2015, 16:20:30
it made like 1000 different files; is that normal?
1000 different files? No.
2 folders and 6 files (eep, elf, hex, lss, map and sym)? Yes.
And yes, .hex is what you need.
Please note that make clean will delete those files, so backup your last working .hex before editing and cleaning.
Enjoy your firmware.
Title: Re: TMK keyboard firmware
Post by: Zorberema on Wed, 16 December 2015, 16:28:41
it made like 1000 different files; is that normal?
1000 different files? No.
2 folders and 6 files (eep, elf, hex, lss, map and sym)? Yes.
And yes, .hex is what you need.
Please note that make clean will delete those files, so backup your last working .hex before editing and cleaning.
Enjoy your firmware.

That sounds correct! Sooooo, I got the firmware into the keyboard... And it is pretty messed up! Half the buttons work... But backwards(The right-most button is q, followed by w etc.). Where could this fault be? Anyways, thank you so-so-so much for the help; at least I know that it... kind of works now, haha! :D
Title: Re: TMK keyboard firmware
Post by: TalkingTree on Wed, 16 December 2015, 16:31:14
Half the buttons work... But backwards(The right-most button is q, followed by w etc.). Where could this fault be?
Most likely your matrix. Sounds like you defined it backwards and missed some entries. It could also be a hardwiring issue, or both things.
Title: Re: TMK keyboard firmware
Post by: Zorberema on Wed, 16 December 2015, 16:33:27
Half the buttons work... But backwards(The right-most button is q, followed by w etc.). Where could this fault be?
Most likely your matrix. Sounds like you defined it backwards and missed some entries. It could also be a hardwiring issue, or both things.
The second row don't work at all, haha! I guess that row is handwiring, and the backwards stuff is matrix... Maybe both! Anyways, I'm heading to bed now, I'll look further into this tomorrow! Thanks once again for the help, I really appreciate it!
Title: Re: TMK keyboard firmware
Post by: abjr on Wed, 16 December 2015, 16:35:46
Remove the word static before const from keymap_poker.c (occurs twice), clean and recompile.

Had to open several text editors and close down sublime text 2 times before I could see static written... It seemed to work now, but it made like 1000 different files; is that normal? I got a hex file in here, will try that out!

Weird. The code you pasted above didn't have static in keymap_poker.c, but the .zip file did. Were you editing one set of files and compiling another? :)
Title: Re: TMK keyboard firmware
Post by: TalkingTree on Wed, 16 December 2015, 16:36:11
Thanks once again for the help, I really appreciate it!
Don't mention. And keep me posted, I'm intrigued.
Title: Re: TMK keyboard firmware
Post by: Zorberema on Wed, 16 December 2015, 16:40:55
Remove the word static before const from keymap_poker.c (occurs twice), clean and recompile.

Had to open several text editors and close down sublime text 2 times before I could see static written... It seemed to work now, but it made like 1000 different files; is that normal? I got a hex file in here, will try that out!

Weird. The code you pasted above didn't have static in keymap_poker.c, but the .zip file did. Were you editing one set of files and compiling another? :)

That's the weird part; I couldn't see it myself, until he said it and I checked the zip. I am a 100% sure it was never there before as I've compared to matt3o's a lot. It popped up after saving and restarting my editor and going into notepad...
Title: Re: TMK keyboard firmware
Post by: hasu on Wed, 16 December 2015, 21:40:21
i took a look over my firmware and my device manager settings and i didnt see anything out of the ordinary.
my keyboard is still not waking my surface (either of them Pro2 or 3) from sleep. when it sleeps the keyboard stops responding until i unplug and plug it back in.

any thoughts?
Console feature has problems in some situations. Try disabling it if you have the build option in your makefile.

i disabled all the things i didnt think were necessary. seems to be working for the moment. i'll be doing ongoing testing. thanks for the tip Hasu

Great. If you can take time to narrow down which is exactly the cause of your problem, it would be appreciated.
Do you think the console is the cause or else?

After testing it appears the combo of Sleep LED Enable and Command Enable were the combined issue. after commenting both out all is well with the world.

Thanks for the report back. I added it to FAQ on github wiki.
Title: Re: TMK keyboard firmware
Post by: mrbishop on Wed, 16 December 2015, 22:00:30
i took a look over my firmware and my device manager settings and i didnt see anything out of the ordinary.
my keyboard is still not waking my surface (either of them Pro2 or 3) from sleep. when it sleeps the keyboard stops responding until i unplug and plug it back in.

any thoughts?
Console feature has problems in some situations. Try disabling it if you have the build option in your makefile.

i disabled all the things i didnt think were necessary. seems to be working for the moment. i'll be doing ongoing testing. thanks for the tip Hasu

Great. If you can take time to narrow down which is exactly the cause of your problem, it would be appreciated.
Do you think the console is the cause or else?

After testing it appears the combo of Sleep LED Enable and Command Enable were the combined issue. after commenting both out all is well with the world.

Thanks for the report back. I added it to FAQ on github wiki.
Np thanks for all your help
Title: Re: TMK keyboard firmware
Post by: Koren on Fri, 18 December 2015, 12:36:03
I'm pretty sure the question has been answered, but I don't find it, and Google don't help me :/

I wonder how exactly momentary switches of layers are handled... Can someone confirms me that it basically toggle the layer on press AND on release, and the release need that the key has the same meaning at release time? I've yet to take the time to read the relevant part of the code...

I guess it's the case, because if a key in layer 0 is KC_FN1 that momentarily activate layer 1, I'm stuck in layer 1 if the same key in layer 1 is translated to something else than KC_TRNS or KC_FN1.


Not a big deal in this case, but it can become tricky. Let's suppose I have a keyboard with two keys, and four layers :

Layer 0 : KC_F1     KC_F2
Layer 1 : KC_TRNS KC_F3
Layer 2 : KC_F3    KC_TRNS
Layer 3 : KC_TRNS KC_TRNS

where KC_Fi are momentary layer switch to layer i

When I try this, I can access layer 1 and 2 easily, and when I press both keys, I access layer 3.

Problems arise when I release the keys : if I release them in the opposite order I pressed them, no issue, I go back to layer 1 ; but if I release them in the same order (press K1, press K2, release K1, release K2), I end up stuck in layer 3 and (I think) layer 2 active underneath: pressing K1 make me reach layer 2, and K2 has no effect.

I'd say it works this way:
[layer 0] : KC_F1     KC_F2
press left key
[layers 0+1] : KC_F1     KC_F3
press right key
[layers 0+1+3] : KC_F1     KC_F3
release left key
[layers 0+3] : KC_F1     KC_F2
release right key
[layers 0+2+3] : KC_F3     KC_F2

So I'm not back on layer 0 only after releasing all keys in this order. Is my analysis correct?

Is there a trick to make this work beside duplicating the layer 3?
Title: Re: TMK keyboard firmware
Post by: hasu on Sun, 20 December 2015, 06:19:19
So I'm not back on layer 0 only after releasing all keys in this order. Is my analysis correct?

Is there a trick to make this work beside duplicating the layer 3?

I think you are correct, you can handle 5 layers with two keys at maximum. Yes, duplicating is one of solutions.

But this doesn't work for you? I may be wrong.

Quote

Layer 0 : L1   L2
Layer 1 : L1   L3
Layer 2 : L3   L2
Layer 3 : TRNS TRNS
Using KC_F* here is confusing, I used L* instead.


You can rewrite it more detail like the below. In TMK an action is comprised of press action and release action, in fact.  For example, ACTION_LAYER_MOMENTARY(1) acts as  +L1 on press and -L1 on release.
Quote

        KeyL                KeyR
Layer   press   release     press   release 
----------------------------------------------
0       +L1     x           +L2     x
1       x       -L1         +L3     -L3
2       +L3     -L3         x       -L2
3       TRNS    TRNS        TRNS    TRNS

where
x   : 'don't care',
+Ln : turn on Layer n
-Ln : turn off Layer n
=Ln : set Layer n only(other layers are disabled)


Or you can also use ACTION_LAYER_SET() probably.
Quote

        KeyL                KeyR
Layer   press   release     press   release 
----------------------------------------------
0       =L1     x           =L2     x
1       x       =L0         =L3     x
2       =L3     x           x       =L0
3       x       =L2         x       =L1


BTW, to handle 5 layers with two keys you will be able to define like this.
Quote

        KeyL                KeyR
Layer   press   release     press   release 
----------------------------------------------
0       +L1     x           +L2     x
1       x       -L1         +L3     x
2       +L4     x           x       -L2
3       x       -L1         x       -L3
4       x       -L4         x       -L2
Title: Re: TMK keyboard firmware
Post by: Koren on Mon, 21 December 2015, 13:59:56
First, many thanks for the detailed answer... and also for all your work on firmwares!
But this doesn't work for you? I may be wrong.
If I'm not mistaken, I've tried it, it works, but only if I release the keys in the correct order, which is not perfect... That being said, I should go on testing this (but I'm away from my avr-gcc compilation chain now)

For the moment, I settled for a different solution : use the user scan function to update the variable layer so that the bit for the layer 12 is the result of binary AND applied to both bits corresponding to layers 4 and 8. I thus don't use any layer switch to switch to layer 12 anymore, I just activate 4 and 8 which triggers 12. it's a bit crude, but it works.

Yes, it's not 1, 2 and 3 anymore, but 4, 8 and 12. That's because it's not the dirtiest thing I've done ^_^... If a layer 4*k (where k<4) is enabled, I activate the layer 4*k+1 if shift is pressed (and I've found nothing better than importing the matrix table to check this), 4*k+2 if the layer 31 (completely transparent) is active, and 4*k+3 if both are True.

The shift trick is because I don't want e.g. shift-comma to act as less for example (on QWERTY, it's not exactly my case), but still sending shift as soon as I press the key (so I can't really use a classic layer for shifted keys) and the second one because I want to be able to change a couple of keys depending on the task I'm doing.

What's great with programmable keyboards is that you can do nearly whatever you want, given some time... nearly, because I'm already at 99% full :/ I still want to fork your code, but I doubt I'll be able to do what I want (*) on a normal Ergodox (I need an Axios ^_^)

I've read half of the firmware last saturday (I left the hardware part for the moment). A lot of interesting stuff... It took me some time to figure how you exactly handled the tap feature, though. it shows that you spent a lot of time tweaking special cases!

Again, many many thanks for all your work, and the help you keeps providing.


(* what I want is, among other things, a double conversion, key to symbols, then symbols to keycodes so that I don't need to be able to change the layout in the computer... the problem is that I use a mix of french AZERTY and belgian AZERTY (closer to QWERTY) on my own computers, to ease access to coding symbols, but computer at work use plain french AZERTY and I can't change it. And I don't want to flash the keyboard each time I jump from one computer to another.

Quote
BTW, to handle 5 layers with two keys you will be able to define like this.
Interesting...
Title: Re: TMK keyboard firmware
Post by: McPwned on Sun, 27 December 2015, 18:17:10
I'm having a bit of trouble using mouse keys in macros.  For example, when I just put WH_U in my keymap, it works fine.  However, when I have a macro like the following, nothing happens:

        case WHEEL_UP:
            return (record->event.pressed ?
                    MACRO( T(WH_U), END ) :
                    MACRO_NONE );

Are they any suggestions as to what I may be doing incorrectly?  I have got other macros to work fine.
Title: Re: TMK keyboard firmware
Post by: Koren on Mon, 28 December 2015, 11:00:53
I'm having a bit of trouble using mouse keys in macros.
I may be wrong (Hasu will correct me if I am), but I suspect you simply can't use mouse events in macro (at least in the firmware version I have).

I think keypresses call action_exec which calls process_action which can deal with mouse events, but macros directly use register_code which can't. I'd say macros can only send keyboard scancodes (up to KC_EXSEL / 0xA4). Media keys and power management keys probably don't work either in macros based on a quick survey of source code.

(again, at least on the version I have, but that would explain your problem)


From a more practical point of view, I confirm you I can't use mouse keys in macros either, so if you do something wrong, I've done it too ^_^
Title: Re: TMK keyboard firmware
Post by: McPwned on Mon, 28 December 2015, 14:34:27
I may be wrong (Hasu will correct me if I am), but I suspect you simply can't use mouse events in macro (at least in the firmware version I have).

I think keypresses call action_exec which calls process_action which can deal with mouse events, but macros directly use register_code which can't. I'd say macros can only send keyboard scancodes (up to KC_EXSEL / 0xA4). Media keys and power management keys probably don't work either in macros based on a quick survey of source code.

(again, at least on the version I have, but that would explain your problem)


From a more practical point of view, I confirm you I can't use mouse keys in macros either, so if you do something wrong, I've done it too ^_^
I appreciate the information and your confirmation.  Thank you.
Title: Re: TMK keyboard firmware
Post by: hasu on Mon, 28 December 2015, 15:00:24
As Koren said, you cannot send mousekey with register_code(), but it seems like media key and system key can be sent.
https://github.com/tmk/tmk_keyboard/blob/master/tmk_core/common/action.c#L419-L424

I think you can fix around here to send mouse keys.(or register_code() should be fixed?)
https://github.com/tmk/tmk_keyboard/blob/33714e55827d1cf52df1d3ff143f03fa34ad1f06/tmk_core/common/action_macro.c#L40-L59

And I originaly designed that macro can send keycodes only of 0x04-0x73 to save memory space. So I didn't think about sending mouse and media key events in macro much.
https://github.com/tmk/tmk_keyboard/blob/33714e55827d1cf52df1d3ff143f03fa34ad1f06/tmk_core/common/action_macro.h#L38-L55

This was filed and will be fixed some later(TM).
https://github.com/tmk/tmk_keyboard/issues/289
Title: Re: TMK keyboard firmware
Post by: McPwned on Mon, 28 December 2015, 17:41:47
As Koren said, you cannot send mousekey with register_code(), but it seems like media key and system key can be sent.
https://github.com/tmk/tmk_keyboard/blob/master/tmk_core/common/action.c#L419-L424

I think you can fix around here to send mouse keys.(or register_code() should be fixed?)
https://github.com/tmk/tmk_keyboard/blob/33714e55827d1cf52df1d3ff143f03fa34ad1f06/tmk_core/common/action_macro.c#L40-L59

And I originaly designed that macro can send keycodes only of 0x04-0x73 to save memory space. So I didn't think about sending mouse and media key events in macro much.
https://github.com/tmk/tmk_keyboard/blob/33714e55827d1cf52df1d3ff143f03fa34ad1f06/tmk_core/common/action_macro.h#L38-L55

This was filed and will be fixed some later(TM).
https://github.com/tmk/tmk_keyboard/issues/289

Between both of your posts, I was able to fix it, I think.  My testing is far from extensive, but wheel up/down and left click work in a couple different macros for me.

In register_code() I added the following to the end:

    else if IS_MOUSEKEY(code) {
        mousekey_on(code);
        mousekey_send();
    }

And similarly I added the following to unregister_code():

    else if IS_MOUSEKEY(code) {
        mousekey_off(code);
        mousekey_send();
    }

Thanks.
Title: Re: TMK keyboard firmware
Post by: Koren on Mon, 28 December 2015, 18:33:49
As Koren said, you cannot send mousekey with register_code(), but it seems like media key and system key can be sent.
I stand corrected. I'm indeed missing those lines in my version, but I'm using a fork, and I'm not really sure when the sources parted.

or register_code() should be fixed?
You can indeed do some tricks in the user macro function since it won't clash with other keyboard functions, but a solution in the firmware core is probably more satisfying...

That being said, if there's mouse support in register_code(), it'll be a bit akward that process_action() is not using it... The same goes for media/power keys, though.


Out of curiosity, can you confirm that there's no way in mouse drivers to move to an absolute position, and that you can only do relative motions? Have you ever looked into "tablets" (Wacom-like) devices and would it be possible for the keyboard to also act as a tablet, to overcome this limitation?

I need something like this (I'm working on a electronic whiteboard), I thought about creating my own ATMega code for it, but if I can "patch" this firmware, it'll probably easier.
Title: Re: TMK keyboard firmware
Post by: suicidal_orange on Sat, 09 January 2016, 14:50:50
Can anyone explain how to make the LEDs work on a GH60 PCB?  If I've read right Caps, Esc, WASD and Poker Arrows should be wired up while the rest need an expansion module, but the only one mentioned in led.c is Caps and that doesn't work.  There's nothing about LEDs in the help files either, unless I'm missing something - feel free to link it :)
Title: Re: TMK keyboard firmware
Post by: flabbergast on Sun, 10 January 2016, 08:57:33
Can anyone explain how to make the LEDs work on a GH60 PCB?  If I've read right Caps, Esc, WASD and Poker Arrows should be wired up while the rest need an expansion module, but the only one mentioned in led.c is Caps and that doesn't work.  There's nothing about LEDs in the help files either, unless I'm missing something - feel free to link it :)
So, poker arrows LEDs are routed to PF4; WASD to PF7; Caps to PB2; Esc to PF6. All of them are active LOW. You'll need to solder in resistors for these (indicated on the PCB). It's up to you how will you use those (you can e.g. use the esc led for a layer indicator, etc...)
Title: Re: TMK keyboard firmware
Post by: suicidal_orange on Sun, 10 January 2016, 11:12:17
Can anyone explain how to make the LEDs work on a GH60 PCB?  If I've read right Caps, Esc, WASD and Poker Arrows should be wired up while the rest need an expansion module, but the only one mentioned in led.c is Caps and that doesn't work.  There's nothing about LEDs in the help files either, unless I'm missing something - feel free to link it :)
So, poker arrows LEDs are routed to PF4; WASD to PF7; Caps to PB2; Esc to PF6. All of them are active LOW. You'll need to solder in resistors for these (indicated on the PCB). It's up to you how will you use those (you can e.g. use the esc led for a layer indicator, etc...)

Thanks, that's a great start.  Pretty sure Caps should have been working (I was touching an LED and resistor combo to the right pads) but now I can check the config and test the rest of them to see what's wrong :thumb:
Title: Re: TMK keyboard firmware
Post by: flabbergast on Sun, 10 January 2016, 11:50:07
Glad I could help. BTW I haven't actually put the LEDs into my GH60, I just traced the connections on the PCB with a multimeter.
Title: Re: TMK keyboard firmware
Post by: suicidal_orange on Sun, 10 January 2016, 13:06:50
Haha, why didn't I think of that!  Seems the config was correct for Caps to work but definitely no light...

I'm going to wait until I have the correct value resistors to solder in before testing further, perhaps I'm just not making good enough contact (though I get light from the GPIO + and - pads, so pretty sure I am)



Title: Re: TMK keyboard firmware
Post by: flabbergast on Sun, 10 January 2016, 14:53:46
Forgot to say: these LEDs are powered through the MCU, so the resistors should be enough so that they don't draw too much power (I think the rules are 20mA per pin, 100mA all things together).
Title: Re: TMK keyboard firmware
Post by: mastermachetier on Sun, 10 January 2016, 19:33:54
Hey first of all thank you for the awesome firmware its beautiful. I am pretty new to the world of hardware and also coding. I have a apple standard keyboard M0116 that i converted from adb using the tmk firmware. It is working beautifully, the next step i would like to do is convert it to bluetooth. I saw the bluetooth protocol in the repo this is just if you are using serial. I have a bluefruit ez-link that supports serial , but i also have a bluefruit le spi that supports bluetooth hid. https://learn.adafruit.com/introducing-the-adafruit-bluefruit-spi-breakout/hidkeyboard  . So after all that my questions are

1. Is there an advantage to using the bluetooth hid instead of serial ? If so how hard would it be to implement and where would I begin.
2. How do I add the bluefruit protocol in the firmware to the makefile for the adb converter .

Thanks !
Title: Re: TMK keyboard firmware
Post by: mastermachetier on Mon, 11 January 2016, 17:40:16
"posted by mistake" :(
Title: Re: TMK keyboard firmware
Post by: zeroni13 on Sat, 16 January 2016, 07:55:42
Hi,

I'm trying to build TMK for my Ghost Squid controller, but it won't build correctly
It works with other keyboards in the other folders.

Here is the output from my terminal: http://hastebin.com/omuhusiday.tex

Could anyone please help me figure out what's wrong?

I'm have not changed anything in the folder and the guide tell me to simply

"Move to this directory then just run make like:

$ make -f Makefile.lufa"

Should not be that hard, maybe I'm just really stupid today..
Title: Re: TMK keyboard firmware
Post by: hasu on Sat, 16 January 2016, 08:03:35
maybe you need to update your toolchain.
Title: Re: TMK keyboard firmware
Post by: a-c on Sat, 16 January 2016, 09:41:29
Same error with winavr

Compiles fine in Linux.
Title: Re: TMK keyboard firmware
Post by: flabbergast on Sat, 16 January 2016, 10:49:51
Please do not use winavr, it is way too old by now. Errors/problems like this pop up here or on DT every couple of months. The way to update the toolchain is either this (http://deskthority.net/workshop-f7/you-may-want-to-update-winavr-t7538.html), or just get cygwin/msys separately and install the toolchain from e.g. here (http://andybrown.me.uk/2015/03/08/avr-gcc-492/).
Title: Re: TMK keyboard firmware
Post by: suicidal_orange on Sun, 17 January 2016, 05:43:23
I'm being stupid again, can someone please point out where?

This works perfectly (Fn0 as will be outputs a K as a placeholder)
Code: [Select]
#include "keymap_common.h"

/*
 * Custom Layout
 */
const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
    /* 0: Default layer
     * ,------------------------------------------------------------.
     * |Esc|  1|  2|  3|  4|  5|  6|  7|  8|  9|  0|  -|  =|  `| Del|
     * |------------------------------------------------------------|
     * |Tab  |  Q|  W|  E|  R|  T|  Y|  U|  I|  O|  P|  [|  ]|Return|
     * |------------------------------------------------------------|
     * |Ctrl  |  A|  S|  D|  F|  G|  H|  J|  K|  L|  ;|  '|   #|Bksp|
     * |------------------------------------------------------------|
     * |Shft| \|  Z|  X|  C|  V|  B|  N|  M|  ,|  .|  /|Shft|    Fn0|
     * |------------------------------------------------------------|
     * |Ctrl|Gui |Alt |      Space             | Alt| Gui| APP| Ctrl|
     * `------------------------------------------------------------'
     */
    KEYMAP_HHKB(
        ESC, 1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   MINS,EQL, GRV, DEL,\
        TAB, Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,   LBRC,RBRC,ENT,     \
        LCTL,A,   S,   D,   F,   G,   H,   J,   K,   L,   SCLN,QUOT,NUHS,BSPC,    \
        LSFT,NUBS,Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, SLSH,RSFT,   K,   \
        LCTL,  LGUI,LALT,          SPC,                   RALT,APP,RGUI,RCTL),

};

const uint16_t PROGMEM fn_actions[] = {};

but adding a layer makes FN0 output a G?

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

/*
 * Custom Layout
 */
const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
    /* 0: Default layer
     * ,------------------------------------------------------------.
     * |Esc|  1|  2|  3|  4|  5|  6|  7|  8|  9|  0|  -|  =|  `| Del|
     * |------------------------------------------------------------|
     * |Tab  |  Q|  W|  E|  R|  T|  Y|  U|  I|  O|  P|  [|  ]|Return|
     * |------------------------------------------------------------|
     * |Ctrl  |  A|  S|  D|  F|  G|  H|  J|  K|  L|  ;|  '|   #|Bksp|
     * |------------------------------------------------------------|
     * |Shft| \|  Z|  X|  C|  V|  B|  N|  M|  ,|  .|  /|Shft|    Fn0|
     * |------------------------------------------------------------|
     * |Ctrl|Gui |Alt |      Space             | Alt| Gui| APP| Ctrl|
     * `------------------------------------------------------------'
     */
    KEYMAP_HHKB(
        ESC, 1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   MINS,EQL, GRV, DEL,\
        TAB, Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,   LBRC,RBRC,ENT,     \
        LCTL,A,   S,   D,   F,   G,   H,   J,   K,   L,   SCLN,QUOT,NUHS,BSPC,    \
        LSFT,NUBS,Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, SLSH,RSFT,FN0,   \
        LCTL,  LGUI,LALT,          SPC,                   RALT,APP,RGUI,RCTL),

    /* 1: FN layer
     * ,------------------------------------------------------------.
     * |LED| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del |
     * |------------------------------------------------------------|
     * |Tab  |  Q|  W|  E|  R|  T|  Y|  U|  I|  O|  P|  [|  ]|Return|
     * |------------------------------------------------------------|
     * |Ctrl  |  A|  S|  D|  F|  G|  H|  J|  K|  L|  ;|  '|   #|Bksp|
     * |------------------------------------------------------------|
     * |Shft| \|  Z|  X|  C|  V|  B|  N|  M|  ,|  .|  / | Up |    Fn|
     * |------------------------------------------------------------|
     * |Ctrl|Gui |Alt |      Space             | Alt|Left|Down|Right|
     * `------------------------------------------------------------'
     */
    KEYMAP_HHKB(
        TRNS, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12, INS, DEL,\
        TAB, Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,   LBRC,RBRC,ENT,     \
        LCTL,A,   S,   D,   F,   G,   H,   J,   K,   L,   SCLN,QUOT,NUHS,BSPC,    \
        LSFT,NUBS,Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, SLSH,UP,TRNS,   \
        LCTL,  LGUI,LALT,          SPC,                   RALT,LEFT,DOWN,RGHT),
};
const uint16_t PROGMEM fn_actions[] = {};

I've changed just about every file in the gh60 folder to create this "all keys" variant starting from HHKB as it had the split backspace but thought once it worked for one layer it would work for all.  Guess not!
Title: Re: TMK keyboard firmware
Post by: a-c on Sun, 17 January 2016, 07:28:14
Do you have FN0 defined as an action?
Title: Re: TMK keyboard firmware
Post by: Koren on Sun, 17 January 2016, 08:15:11
Do you have FN0 defined as an action?

I think that's the problem... There's apparently no action defined for FN0,
Code: [Select]
const uint16_t PROGMEM fn_actions[] = {};(although it could be done in a different fashion)

Not sure what FN0 should do, but since I don't see a layer switch, I guess it's the goal. So something like
Code: [Select]
const uint16_t PROGMEM fn_actions[] = {
    [0] = ACTION_LAYER_TAP_TOGGLE(1)
};
would probably be welcome...
Title: Re: TMK keyboard firmware
Post by: suicidal_orange on Sun, 17 January 2016, 09:53:31
Do you have FN0 defined as an action?

I think that's the problem... There's apparently no action defined for FN0,
Code: [Select]
const uint16_t PROGMEM fn_actions[] = {};(although it could be done in a different fashion)

Not sure what FN0 should do, but since I don't see a layer switch, I guess it's the goal. So something like
Code: [Select]
const uint16_t PROGMEM fn_actions[] = {
    [0] = ACTION_LAYER_TAP_TOGGLE(1)
};
would probably be welcome...

Told you I was being stupid :))  That of course fixed it - thanks!
Title: Re: TMK keyboard firmware
Post by: Koren on Sun, 17 January 2016, 12:36:25
Told you I was being stupid :))  That of course fixed it - thanks!
Definitively not stupid (you need to be quite skilled to compile and upload the firmware, already), just unaware of how things work in the firmware (yet). Happy that things are running now... Feel free to ask if there's anything else!
Title: Re: TMK keyboard firmware
Post by: deductivemonkee on Mon, 18 January 2016, 11:53:59
The oneshot shift on the alps64 tmk editor seems to act as a normal shift.
Title: Re: TMK keyboard firmware
Post by: MrCyprus on Mon, 18 January 2016, 14:44:58
Is there any word on support for the teensy 3.2?  I accidentally ordered one and am now trying to decide if I should try to make it work or just save myself some trouble and get a 2.
Title: Re: TMK keyboard firmware
Post by: flabbergast on Mon, 18 January 2016, 15:01:36
Is there any word on support for the teensy 3.2?  I accidentally ordered one and am now trying to decide if I should try to make it work or just save myself some trouble and get a 2.
There is (http://deskthority.net/workshop-f7/tmk-support-for-arm-teensies-t11799.html), but not for the rookies. Things work (e.g. the infinity keyboard, or the whitefox (WF uses the same chip as Teensy 3.2)), but still rather beta, expect to run into bugs and/or compilation problems.
Title: Re: TMK keyboard firmware
Post by: henz on Mon, 18 January 2016, 15:17:32
Is there any word on support for the teensy 3.2?  I accidentally ordered one and am now trying to decide if I should try to make it work or just save myself some trouble and get a 2.

i wrote some code in teensyduino if your interested, its using the keyboard library which is included in arduino:

https://github.com/ageaenes/teensykb (https://github.com/ageaenes/teensykb)

I guess you need some basic coding skills to make it work with whatever board you want to use it with, mine is for a handwired apple m0116.

I did the same blunder as you did, although it was at the time 3.1 i bought :)

Title: Re: TMK keyboard firmware
Post by: MrCyprus on Mon, 18 January 2016, 15:18:11
Is there any word on support for the teensy 3.2?  I accidentally ordered one and am now trying to decide if I should try to make it work or just save myself some trouble and get a 2.
There is (http://deskthority.net/workshop-f7/tmk-support-for-arm-teensies-t11799.html), but not for the rookies. Things work (e.g. the infinity keyboard, or the whitefox (WF uses the same chip as Teensy 3.2)), but still rather beta, expect to run into bugs and/or compilation problems.

Thanks!  I will take a look at this and make a decision from there.
Title: Re: TMK keyboard firmware
Post by: hasu on Mon, 18 January 2016, 21:51:03
The oneshot shift on the alps64 tmk editor seems to act as a normal shift.

I confirmed it works.
I think 'oneshot modifier' doesn't work like what you expect. It works as normal modifier in most cases except for when you tap(press and release quickly) it.

This description is confusing? TMK requires documenation improvement as always :D your contribution is welcomed.
https://github.com/tmk/tmk_keyboard/blob/master/tmk_core/doc/keymap.md#43-oneshot-modifier
Title: Re: TMK keyboard firmware
Post by: Kaibz on Thu, 21 January 2016, 08:31:47
I have been using this firmware for more than a year and it is awesome and once again thanks to Hasu for his amazing work!!!! I actually think that because of this firmware i have one of the best gamer keyboard you can find not only because of nkro but also the 1000hz polling rate which makes it very reactive.

I have one question that may seem stupid but honestly i am still a beginner and i just want to learn....I know that this firmware is very advanced, complex and written in C and i'll never be able to understand it as much as i would like. But if i wanted to make a firmware for a 84 keys keyboard by modifying one of the examples of the arduino IDE like this one, like Henz did :

Code: [Select]
#include <Keypad.h>

const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns
//define the cymbols on the buttons of the keypads
char hexaKeys[ROWS][COLS] = {
  {'0','1','2','3'},
  {'4','5','6','7'},
  {'8','9','A','B'},
  {'C','D','E','F'}
};
byte rowPins[ROWS] = {3, 2, 1, 0}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {7, 6, 5, 4}; //connect to the column pinouts of the keypad

//initialize an instance of class NewKeypad
Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);

void setup(){
  Serial.begin(9600);
}
 
void loop(){
  char customKey = customKeypad.getKey();
 
  if (customKey){
    Serial.println(customKey);
  }
}


My question is, the difference between the 2 firmwares would it be that the code would run slower and that i wouldn't get 1000hz polling rate as i do with TKM? Or that i wouldn't have the ability to implement NKRO? Or would it be just less reliable....?
On the other hand it would make things easier for me to implement a LCD for example, as i would have acces to libraries right?

Thank you.

Title: Re: TMK keyboard firmware
Post by: hasu on Thu, 21 January 2016, 18:34:13
I think there is no reason why Arduino prevents you from making keyboard that you described. Arduino is powerful option, in particular due to its community and enormous libraries. You cannot go wrong with Arduino.

I don't know "1000hz polling" definition in gaming community but I don't think TMK is so fast by default. You will be able to improve it easily, though.
Title: Re: TMK keyboard firmware
Post by: Kaibz on Fri, 22 January 2016, 07:40:12
Thank you Hasu i will try with the Arduino as a learning experience.

If i may, when you say i should be able to improve the polling rate easily in TMK....May i know which file i should look into to do that?

Cheers.
Title: Re: TMK keyboard firmware
Post by: Koren on Fri, 22 January 2016, 14:26:51
If i may, when you say i should be able to improve the polling rate easily in TMK....May i know which file i should look into to do that?
I'm pretty sure that the firmware run "as fast as it can". But it performs a lot of things that you may not need. You can increase the pollrate either by optimizing the source code, or, more easily, by (carefully) removing features.

That being said, many switches need debounce, and I'm not sure the firmware will be the biggest hurdle to reach a 1000Hz polling rate.
Title: Re: TMK keyboard firmware
Post by: deductivemonkee on Sat, 23 January 2016, 13:38:12
Im trying to compile my .hex, but keep getting the error
Code: [Select]
In file included from keymap_plain.c:1:0:
keymap_common.h:23:21: fatal error: keycode.h: No such file or directory
 #include "keycode.h"
Title: Re: TMK keyboard firmware
Post by: Koren on Sat, 23 January 2016, 13:46:39
Im trying to compile my .hex, but keep getting the error
Code: [Select]
In file included from keymap_plain.c:1:0:
keymap_common.h:23:21: fatal error: keycode.h: No such file or directory
 #include "keycode.h"
Do you have a keycode.h file in the /common directory of the firmware source?

If so, it's a path issue, but it should be OK. How do you compile it? Make? Could you paste the last compilation command that failed? (probably a line beginning by avr-gcc a couple lines above the error)
Title: Re: TMK keyboard firmware
Post by: deductivemonkee on Sat, 23 January 2016, 13:49:48
Im trying to compile my .hex, but keep getting the error
Code: [Select]
In file included from keymap_plain.c:1:0:
keymap_common.h:23:21: fatal error: keycode.h: No such file or directory
 #include "keycode.h"
Do you have a keycode.h file in the /common directory of the firmware source?

If so, it's a path issue, but it should be OK. How do you compile it? Make? Could you paste the last compilation command that failed? (probably a line beginning by avr-gcc a couple lines above the error)

keycode.h is in the tmk_core/common file.
I compile it with cygwin terminal
Code: [Select]
mkdir -p obj_alps64
Compiling C: keymap_plain.c
avr-gcc -c -mmcu=atmega32u2 -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= -Os -funsigned-char -funsigned-bitfields -ffunction-sections -fdata-sections -fno-inline-small-functions -fpack-struct -fshort-enums -fno-strict-aliasing -Wall -Wstrict-prototypes -Wa,-adhlns=obj_alps64/keymap_plain.lst -I. -ID -I\KeyboardStuff\TMK\tmk_keyboard-master\tmk_core -ID -I\KeyboardStuff\TMK\tmk_keyboard-master\tmk_core/protocol/lufa -ID -I\KeyboardStuff\TMK\tmk_keyboard-master\tmk_core/protocol/lufa/LUFA-git -ID -I\KeyboardStuff\TMK\tmk_keyboard-master\tmk_core/common -std=gnu99 -include config.h -MMD -MP -MF .dep/obj_alps64_keymap_plain.o.d  keymap_plain.c -o obj_alps64/keymap_plain.o
In file included from keymap_plain.c:1:0:
keymap_common.h:23:21: fatal error: keycode.h: No such file or directory
 #include "keycode.h"
Title: Re: TMK keyboard firmware
Post by: Koren on Sat, 23 January 2016, 14:25:19
keycode.h is in the tmk_core/common file.
Seems OK. You can check that it's readable and the directory has execute and read permissions, but I doubt that's the issue.

It seems that path includes are there, but

-I\KeyboardStuff\TMK\tmk_keyboard-master\tmk_core/common

is a bit strange. When I compile it under cygwin, I only have slashes (/) in paths, not backslashes. And beginning with a / would be strange, too... is KeyboardStuff a directory in your root cygwin directory?

How did you generate your makefile? The problem probably lies there...
Title: Re: TMK keyboard firmware
Post by: deductivemonkee on Sat, 23 January 2016, 14:28:43
keycode.h is in the tmk_core/common file.
Seems OK. You can check that it's readable and the directory has execute and read permissions, but I doubt that's the issue.

It seems that path includes are there, but

-I\KeyboardStuff\TMK\tmk_keyboard-master\tmk_core/common

is a bit strange. When I compile it under cygwin, I only have slashes (/) in paths, not backslashes. And beginning with a / would be strange, too... is KeyboardStuff a directory in your root cygwin directory?

How did you generate your makefile? The problem probably lies there...

i fixed the slashes, my makefile was the one in the alps64 dir, thats what board its for. KeyboardStuff is in my D: drive
Title: Re: TMK keyboard firmware
Post by: Koren on Sat, 23 January 2016, 14:49:29
i fixed the slashes
And? Any change?

my makefile was the one in the alps64 dir, thats what board its for.
Often, projects don't come with a makefile... because the makefile will be slightly different depending on which compiler/tools you use. But I don't see a configure file, and I don't remember how I generated my own Makefile. :/

KeyboardStuff is in my D: drive
I'd suggest you to use relative paths if you modify your makefile by hand, or /cygdrive/d/... I don't remember Cygwin being able to refer to disks by their name, but I may be wrong.
Title: Re: TMK keyboard firmware
Post by: deductivemonkee on Sat, 23 January 2016, 14:58:40
i fixed the slashes
And? Any change?

my makefile was the one in the alps64 dir, thats what board its for.
Often, projects don't come with a makefile... because the makefile will be slightly different depending on which compiler/tools you use. But I don't see a configure file, and I don't remember how I generated my own Makefile. :/

KeyboardStuff is in my D: drive
I'd suggest you to use relative paths if you modify your makefile by hand, or /cygdrive/d/... I don't remember Cygwin being able to refer to disks by their name, but I may be wrong.

It recognizes keycode.h now.
Now it's just errors like 64 arguments needed, only 61 given.
Will post later.
Title: Re: TMK keyboard firmware
Post by: Koren on Sat, 23 January 2016, 15:07:19
It recognizes keycode.h now.
Now it's just errors like 64 arguments needed, only 61 given.
Will post when done lunch.
Most probably missing commas in your keyboard layout definition (check the end of lines, especially)
Title: Re: TMK keyboard firmware
Post by: Kaibz on Sun, 24 January 2016, 07:29:50

I'm pretty sure that the firmware run "as fast as it can". But it performs a lot of things that you may not need. You can increase the pollrate either by optimizing the source code, or, more easily, by (carefully) removing features.

That being said, many switches need debounce, and I'm not sure the firmware will be the biggest hurdle to reach a 1000Hz polling rate.

Thank you Sir.

Does that mean that using hardware debouncing, instead of software, would/could make the polling rate "faster"?
Also is the actual microcontroler speed tied in some ways to the polling rate?
Sorry if these questions sound stupid but i just want to be sure.
Title: Re: TMK keyboard firmware
Post by: Koren on Sun, 24 January 2016, 07:59:56
Does that mean that using hardware debouncing, instead of software, would/could make the polling rate "faster"?
What I mean is that, if you want to have 1000Hz polling, you need to be able to distinguish

4.900 Key Down
5.000 Key Up
5.001 Key Down
5.002 Key Up

from

4.900 Key Down
5.000 Key Up
5.001 Bounce down
5.002 Bounce up

Hasu did some tests on, e.g. Cherry Blacks, and got this (granted, that was apparently the worst case):
(http://i.imgur.com/qhVMghZ.png)

Official MX documentation suggest a 5ms debounce, so you shouldn't be able to reach 1000Hz with cherries (at least, in theory... 5ms may be quite a lot, and you may prefer having 1000Hz and a couple of ghost presses)


I'm curious, though: how do you intend to do "hardware debounce"? Most debouncing solutions, electronics or software, induce a latency. I doubt you'll want adding to much latency when you aim for a really high polling rate if you're into gaming... A high polling rate keyboard should probably use very specific switches with reliable, non-bouncing hardware. I have no idea if Alps are great for this or not.


About debouncing and rate, you should look into the matrix.c file in your alp64 directory... The debouncing stuff is usually on a per-board basis, since not all keyboards need the same timings. By default, the debouncing is set to about 5ms, apparently, which will prevent you from going close to 1000Hz (assuming you *could* go close to 1000Hz).

Also is the actual microcontroler speed tied in some ways to the polling rate?
In some cases, yes...

The software will read the state of the keys, do something depending on the changes of thoses states, send a report to the computer, and start again. The longest it take to do the polling and the computations, the lower the rate of the reports. And slower microcontroller will take longer to do the polling and the computations afterwards.

But at the same time, with high-speed microcontrollers, the physical parts will become the ones limiting the polling rate.

Sorry if these questions sound stupid but i just want to be sure.
They're not stupid, I just hope I'm not wrong myself, and I'm not even sure whether I haven't missed a sleeping function somewhere in the TMK firmware (besides anything in matrix.c). There's interesting tweaks that can be done to the debouncing part if you want, too.
Title: Re: TMK keyboard firmware
Post by: flabbergast on Sun, 24 January 2016, 12:14:29
I think AVRs at 16MHz run fast enough so that the main delays occur at debouncing (5ms default, configurable), and waiting for PC to initiate an USB transaction (so that the information about the pressed keys, aka "report" gets transmitted to the computer) - this is 1ms worst case I think.

I personally think that marketing departments of keyboard-making companies go for the "1000Hz - hype" just because this is the limit set by the USB HID protocol (a report can be transmitted every 1ms but not more often).

By the way, what does "1000Hz polling rate" actually mean? if there are no keypresses I'd wager that TMK (and every other custom firmware) polls even more often than 1000 times per second. But once a keypress occurs, it takes 5ms to debounce. If Cherry datasheet specifies 5ms debounce time, a hardware debounce solution would have to be built around this number anyway, so you wouldn't get any advantage over the software solution - a keypress would simply register with the firmware 5ms after the key was really pressed.

Marketing is pretty good these days... I still have to see one instance where an improvement of a few ms for registering keypresses makes any difference whatsoever.
Title: Re: TMK keyboard firmware
Post by: Koren on Sun, 24 January 2016, 14:52:49
I think AVRs at 16MHz run fast enough so that the main delays occur at debouncing (5ms default, configurable), and waiting for PC to initiate an USB transaction (so that the information about the pressed keys, aka "report" gets transmitted to the computer)
I think so, indeed. Although if you try to do complex things with the keypresses, I think you could be limited by the AVR speed. I've yet to do tests to backup this claim, though, it's just coming from some experiences with AVR microcontrollers used for other things than keyboards. It's never fast enough ^_^

By the way, what does "1000Hz polling rate" actually mean?
If you talk about what it SHOULD mean, I'd say it's "no more than 1ms lag induced by the device". I doubt that it's always the actual behavior of products displaying it, though... Marketing, as you say...

if there are no keypresses I'd wager that TMK (and every other custom firmware) polls even more often than 1000 times per second.
Probably, but not by much. First, you need to wait a couple dozen microseconds after selecting the row to be able to read the columns. So there's probably a third of millisecond waiting, and after that quite a lot of things to do to transform the bits into keypressed. If it's over 1000Hz, it's not by much.

But once a keypress occurs, it takes 5ms to debounce. If Cherry datasheet specifies 5ms debounce time, a hardware debounce solution would have to be built around this number anyway, so you wouldn't get any advantage over the software solution - a keypress would simply register with the firmware 5ms after the key was really pressed.
That's my understanding, indeed. So I think that any claim over 200Hz will be misleading.
Title: Re: TMK keyboard firmware
Post by: flabbergast on Sun, 24 January 2016, 17:34:25
Probably, but not by much. First, you need to wait a couple dozen microseconds after selecting the row to be able to read the columns. So there's probably a third of millisecond waiting, and after that quite a lot of things to do to transform the bits into keypressed. If it's over 1000Hz, it's not by much.
I've run a quick grep over TMK sources: the settling wait is 30 microseconds max (I think this is a safe baseline for hasu), but a lot of keyboards have 1-3 microseconds.
Title: Re: TMK keyboard firmware
Post by: ctm on Sun, 24 January 2016, 17:45:33
Is there any chance that we can get TMK on Ellipse's Model F keyboards?
Title: Re: TMK keyboard firmware
Post by: Kaibz on Sun, 24 January 2016, 19:23:57
@Koren

Thanks again for your answers. I have a lot of things to learn in the debouncing department, i spent most of my day reading about it.
About hardware debouncing, i talked about it because this person is doing it on her project:

http://dawnmist.dreamwidth.org/2553.html (http://dawnmist.dreamwidth.org/2553.html)

But she didn't tell me exactly how she implemented it, but she was still very helpful.


@flabbergast

You said "I still have to see one instance where an improvement of a few ms for registering keypresses makes any difference whatsoever" and honestly i'm pretty sure you are right, however generally gaming company do not advertize about keyboard polling rate, it's just that one day, i read this article:

http://tech.firstpost.com/news-analysis/gaming-keyboards-demystified-40081.html (http://tech.firstpost.com/news-analysis/gaming-keyboards-demystified-40081.html)

This guy actually explains "technically" why a 1000hz polling rate makes a difference, and to be honest i would very much like to know what you think about what he says and if you think he has a point or not ?

Title: Re: TMK keyboard firmware
Post by: flabbergast on Mon, 25 January 2016, 03:50:42
@flabbergast

You said "I still have to see one instance where an improvement of a few ms for registering keypresses makes any difference whatsoever" and honestly i'm pretty sure you are right, however generally gaming company do not advertize about keyboard polling rate, it's just that one day, i read this article:

http://tech.firstpost.com/news-analysis/gaming-keyboards-demystified-40081.html (http://tech.firstpost.com/news-analysis/gaming-keyboards-demystified-40081.html)

This guy actually explains "technically" why a 1000hz polling rate makes a difference, and to be honest i would very much like to know what you think about what he says and if you think he has a point or not ?
This article explains things pretty well (although it is visibly biased towards mechs, just to mention one instance - the actuation distance on rubber domes is not necessarily that big as he writes - it is about 2mm on apple keyboards).

With that author's definition of 1000Hz polling rate, TMK performs well (as I wrote above). But the example with Super Meat Boy he gives is nonsense in my opinion. 2000 pixels per second? That's just shy of twice the width of my screen. Per second. For platformers like this you train to react "before" stuff actually happens. Now the average human reaction time is 250ms (from googling), so whether you "train to react" 251ms before an event or 255ms before an event doesn't make much of a difference. Any game where you play "against the computer" is tuned so that a normal person with a common keyboard can play it; then it's a matter of training.

I think there can be a point made for FPS - but again, I have yet to see a case where 1ms vs 5ms will make a difference.
Title: Re: TMK keyboard firmware
Post by: Kaibz on Mon, 25 January 2016, 06:26:43
Very nice flabbergast thanks for your observations !

Just to make sure i understand correctly, when mouse manufacturers talk about 1000hz polling rate mouse, is it the same "marketing talk" as keyboard for you ?

On a different subject, i do use NKRO on my TMK powered keyboard, is there a trick to make it enabled by default instead of having to enter the keys combination to enable it every time it's turned on?
Title: Re: TMK keyboard firmware
Post by: Koren on Mon, 25 January 2016, 08:39:45
About hardware debouncing, i talked about it because this person is doing it on her project:
I'd like to know what she's doing...

You said "I still have to see one instance where an improvement of a few ms for registering keypresses makes any difference whatsoever" and honestly i'm pretty sure you are right, however generally gaming company do not advertize about keyboard polling rate, it's just that one day, i read this article:
When I read "I've seen differences", I'd like to see a (double) blind test. There's plently of people saying they hear a big difference when you put marbles, travel clocks in the room. Placebo can be pretty huge.

And compared to what? A keyboard with a 5ms lag or one with a 15ms one? In the second case, it can be noticable (and sometimes bothering).

I agree with Flabbergast, I'm not convinced. I'd be curious to know whether SMB actually read the keyboard at 1000Hz itself, btw (or do I read 500Hz between the lines? Not sure, and I can't find developpers words on this).

I'm really really sensitive about input lag, especially on monitors (can't stand more than 20ms because I begin to notice the delay on very specific games like video golf), but yes, human brain can train itself to correct a couple ms lag pretty easily in a platforming game, even a fast one.

Also, there's usually more than 1ms difference of input lag between the upper part and the lower part of the screen, if 1ms was really a problem, you'd see other problems arise.


He has a point, though, in the fact that even if you need a debounce of 5ms, you could still have a 1ms lag for isolated keypressed (assuming the firmware optimize it this way, which is not the default behavior).
Title: Re: TMK keyboard firmware
Post by: flabbergast on Mon, 25 January 2016, 13:19:47
Just to make sure i understand correctly, when mouse manufacturers talk about 1000hz polling rate mouse, is it the same "marketing talk" as keyboard for you ?

On a different subject, i do use NKRO on my TMK powered keyboard, is there a trick to make it enabled by default instead of having to enter the keys combination to enable it every time it's turned on?
Sorry, I didn't want to start another flamewar (although it is very civil, so perhaps a "candlewar" ;)
With mice there's one crucial difference - when you move the mouse, you're sampling a continuous curve, and so you want to sample it as densely as possible. With keypresses, it's "discrete" on/off, the question is only about the delay between actuation and PC registering it. Although also with mice I don't know when does the sampling become smooth enough so that a human can't tell the difference.

We're moving away from technical points, so I'd like to just concede some points: while there's no hard evidence that high polling rates improve (say) gaming performance or make any other practical difference, they are technically better. Other things being equal, I would go for a keyboard with a higher polling rate.
{I think the subjective feeling of having a better/more personally comfortable keyboard makes a big difference in gaming (or in general - people who feel better just perform better).}

With NKRO enable/boot magic key: the setting is automatically saved in EEPROM. So when you press the magic NKRO_enable key  during power-up, you are actually toggling the NKRO setting; and this is remembered by the MCU even if you re-plug the keyboard.
Title: Re: TMK keyboard firmware
Post by: Prelim on Mon, 25 January 2016, 14:21:59
With NKRO enable/boot magic key: the setting is automatically saved in EEPROM. So when you press the magic NKRO_enable key  during power-up, you are actually toggling the NKRO setting; and this is remembered by the MCU even if you re-plug the keyboard.

Hi!

I've tried to press LShift+RShift+N and then plug again the keyboard cable, but I'm getting always 6NKRO only. If I press again the magic combination for NKRO, it turn nkro on but it doesn't save :( Am I doing something wrong?
Title: Re: TMK keyboard firmware
Post by: a-c on Mon, 25 January 2016, 15:58:40
Bootmagic key is different. It is usually the spacebar.

spacebar + n and plug in USB
Title: Re: TMK keyboard firmware
Post by: Prelim on Mon, 25 January 2016, 16:21:45
thanks for the help, but that's not working also.

The NKRO is saved when computer reboots, but once I unplug and plug keyboard again it reverts to 6KRO :/
Title: Re: TMK keyboard firmware
Post by: flabbergast on Mon, 25 January 2016, 17:18:45
thanks for the help, but that's not working also.

The NKRO is saved when computer reboots, but once I unplug and plug keyboard again it reverts to 6KRO :/
Hm. My post was based on reading hasu's code, but now I found it also on the wiki: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
The behaviour you describe is weird. What MCU are you on? Did you compile TMK yourself? I suppose BOOTMAGIC_ENABLE and NKRO_ENABLE are both 'yes' because otherwise you wouldn't be able to switch NKRO with 'spacebar+N' during power-up.
Title: Re: TMK keyboard firmware
Post by: Prelim on Mon, 25 January 2016, 17:39:54
I'm using a GH60 rev.C and didn't compile myself, I'm using TMK Keymap Generator and flashing over TKG toolkit: www.enjoyclick.org/tkg/
Title: Re: TMK keyboard firmware
Post by: Hzza on Tue, 26 January 2016, 07:51:51
Oh, I set magic key to be left shift+right shift+right control (I kept triggering it when it was set to both shifts), try holding all three and then pressing N.

I've never needed NKRO so I don't have it on by default, if you want I can do you a version with it enabled on boot.
Title: Re: TMK keyboard firmware
Post by: flabbergast on Tue, 26 January 2016, 09:21:40
I can't really tell why the bootmagic won't work properly. There's a very small chance that Kai Ryu has made some change to TMK that prevents this, but it is not very likely. If Hzza would kindly provide a firmware that works for him, it would be great for testing... (I don't have a GH60 to test.)
Title: Re: TMK keyboard firmware
Post by: e_l_tang on Sat, 30 January 2016, 02:24:30
Has anyone gotten TMK to work on an ARM processor yet?
Title: Re: TMK keyboard firmware
Post by: p3lim on Sat, 30 January 2016, 07:24:28
Has anyone gotten TMK to work on an ARM processor yet?

TMK has support for Cortex-M, the infinity keyboard uses a Cortex-M4 MCU: https://github.com/tmk/tmk_keyboard/tree/master/keyboard/infinity
Title: Re: TMK keyboard firmware
Post by: pwnz on Thu, 04 February 2016, 07:49:53
Hi,

I'm having some trouble mapping my keys. I wired a custom 60%-keyboard that's absolutely standard German ISO. I mapped all the ISO keys to their US-ANSI counterpart and simply switched the Windows input language. This works perfectly fine except for the freakin' "double bracket" key that has no counterpart in US-ANSI. I just get two keys that give me backslashes since that's what they do if I switch my OS input language with any other keyboard.

It's the key right to the left shift btw. What do I put in the array there?

Thanks for your help. 

Code: [Select]
const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
    /* 0: default */
    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, \
        FN0, A,   S,   D,   F,   G,   H,   J,   K,   L,   SCLN,QUOT,BSLS,      \
        LSFT,BSLS,Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, SLSH,RSFT,      \
        LCTL,LGUI,LALT,          SPC,                     RALT, RGUI,FN1, RCTL),
    /* 1: fn */
    KEYMAP(
        GRV, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12, TRNS, \
        TRNS,HOME,UP,  END, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \
        TRNS,LEFT,DOWN,RGHT,DEL, 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[] = {
    /* Poker Layout */
    [0] = ACTION_LAYER_MOMENTARY(1),  // to Fn overlay
    [1] = ACTION_LAYER_TOGGLE(1),     // toggle Fn overlay
};
Title: Re: TMK keyboard firmware
Post by: nephiel on Thu, 04 February 2016, 07:59:46
Try NUBS, it's what I have on my ISO there.

Edit: and NUHS for the other slash. Like this:

Code: [Select]
...
    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, \
        FN0, A,   S,   D,   F,   G,   H,   J,   K,   L,   SCLN,QUOT,NUHS,      \
        LSFT,NUBS,Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, SLSH,RSFT,      \
        LCTL,LGUI,LALT,          SPC,                     RALT, RGUI,FN1, RCTL),
...
Title: Re: TMK keyboard firmware
Post by: Liocer on Thu, 04 February 2016, 19:01:10
I've built flashed and worked with Jacks fork of TMK on my Planck without too much issue. but...

I've just got hold of a Sparkfun Pro Micro that I wanted to use as a HHKB controller, now I get most of what's going on but the Sparkfun doesn't have a connected PB0 as it's used to signal the yellow LED on the board.

I'm struggling to work out the PIN addressing in hhkb_avr.h https://github.com/tmk/tmk_keyboard/blob/master/keyboard/hhkb/hhkb_avr.h maybe I can change the ports but I just don't get it. I had a look at Smasher's writeup here: https://geekhack.org/index.php?topic=57008.0 but the code for the ATMEGA32U4 is quite different to his changes.

I really want to understand how this works so I could make further changes if needed, if anyone has a link to something I could read that would be awesome :).

If I can just remap PB0 to say PF7 I should be okay.
Title: Re: TMK keyboard firmware
Post by: hasu on Fri, 05 February 2016, 00:55:34
You can read this to know how it works, but I'm not sure this is sufficient to understand.
https://github.com/tmk/tmk_keyboard/blob/master/keyboard/hhkb/doc/HHKB.txt

And see theese charts.
https://github.com/tmk/tmk_keyboard/blob/master/keyboard/hhkb/doc/HHKB_img/HHKB_chart1.jpg
https://github.com/tmk/tmk_keyboard/blob/master/keyboard/hhkb/doc/HHKB_img/HHKB_chart2.jpg

EDIT: hmm, I'm not sure I could understand your question correctly :D You can post 'HHKB alt controller specific' quesion here: https://geekhack.org/index.php?topic=12047.0

To use PF4-7 can be problematic in some cases, I don't recommend it. If you want to use it check datasheet to disable JTAG, iirc JTD register is related.
Title: Re: TMK keyboard firmware
Post by: Liocer on Fri, 05 February 2016, 07:53:13
You can read this to know how it works, but I'm not sure this is sufficient to understand.
https://github.com/tmk/tmk_keyboard/blob/master/keyboard/hhkb/doc/HHKB.txt

And see theese charts.
https://github.com/tmk/tmk_keyboard/blob/master/keyboard/hhkb/doc/HHKB_img/HHKB_chart1.jpg
https://github.com/tmk/tmk_keyboard/blob/master/keyboard/hhkb/doc/HHKB_img/HHKB_chart2.jpg

EDIT: hmm, I'm not sure I could understand your question correctly :D You can post 'HHKB alt controller specific' quesion here: https://geekhack.org/index.php?topic=12047.0

To use PF4-7 can be problematic in some cases, I don't recommend it. If you want to use it check datasheet to disable JTAG, iirc JTD register is related.

Thanks Hasu, I'm gradually working this out, it doesn't matter to me which pins I use as replacements I guess I could avoid the JTAG pins entirely without too much issue.
Title: Re: TMK keyboard firmware
Post by: ctm on Fri, 05 February 2016, 07:56:07
Any chance of porting TMK to xwhatsit controller?
Title: Re: TMK keyboard firmware
Post by: Liocer on Fri, 05 February 2016, 17:33:25
Okay so I've made some progress but I'm not 100% there yet..

So I've not worked with a Atmega32u4 before so this is all new to me, I don't really have any C experience either so I'm just trying to get this right :).

I went through your old matrix.c code and added some comments for myself.

Code: [Select]
#define KEY_INIT()              do {    \
    DDRB  = 0xFF;                       \ # Set all pins on PORTB to be inputs - setting PD0 LOW on the Pro Mega turns on the LED
    PORTB = 0x00;                       \ # set all PORTB pins to 0 LOW
    DDRD  &= ~0x80;                     \ # set PD1 to be output (0)
    PORTD |= 0x80;                      \ # Set PD1 high (1)
    /* keyswitch board power on */      \
    DDRD  |=  (1<<4);                   \ # Set PD4 to Input (1)
    PORTD |=  (1<<4);                   \ # Pull PD4 HIGH (1)
    KEY_UNABLE();                       \
    KEY_PREV_OFF();                     \
} while (0)

I notice when you're scanning you do so here:

Code: [Select]
static inline void KEY_SELECT(uint8_t ROW, uint8_t COL)
{
    PORTB = (PORTB & 0xC0) | (((COL) & 0x07)<<3) | ((ROW) & 0x07); // notation here is confusing me C0 scans first 2? PB0 and PB1? and then into a 07 (First 3) for both COLS and ROWS
#ifdef HHKB_JP
    if ((ROW) & 0x08) PORTC = (PORTC & ~(1<<6|1<<7)) | (1<<6);
    else              PORTC = (PORTC & ~(1<<6|1<<7)) | (1<<7);
#endif
}

There's no way I can hook up all 7 pins to one port on this board without soldering directly to the Atmega which I'm not doing :P so I will have to adopt at least one additional scan like your additional JP scan above, or have I misunderstood..

This probably not very clear, basically I'm asking you to explain KEY_SELECT above or at least let me know what I've gotten wrong :).

Pins I have available are, is there any other pins I should avoid?

PD0 PD1 PD2 PD3 PD4 PD7
PB1 PB2 PB3 PB4 PB5 PB6
PE6
PC6
PF4 PF5 PF6 PF7 (reserved for JTAG)
Title: Re: TMK keyboard firmware
Post by: hasu on Fri, 05 February 2016, 19:34:51
Any chance of porting TMK to xwhatsit controller?

Me? no, I don't have the controller. Donate it to TMK :D
You just need to place scan logic in matrix.c from xwhatsit's code and write keymap for your keyboard, me think.
Title: Re: TMK keyboard firmware
Post by: a-c on Fri, 05 February 2016, 19:37:47
The TX/RX LEDS are B0 and D5. You can remove the LED and resistor to have a convenient tiny pad to solder to.

Just aware that the bootloader flashes these when loading firmware, otherwise they work fine for digital io.

You can see how they are wired in the schematic. http://cdn.sparkfun.com/datasheets/Dev/Arduino/Boards/Pro_Micro_v13b.pdf
Title: Re: TMK keyboard firmware
Post by: hasu on Fri, 05 February 2016, 20:15:17
Okay so I've made some progress but I'm not 100% there yet..

So I've not worked with a Atmega32u4 before so this is all new to me, I don't really have any C experience either so I'm just trying to get this right :).

I went through your old matrix.c code and added some comments for myself.

I think you have to check how to operate AVR IO ports with tutorial or datasheet again. When DDR bits are set to 1 corresponding ports are configured as output, while input when DDR is 0.

Code: [Select]
DDR PORT Pin state           
-----------------------------
1   0    Output Low         
1   1    Output Hi           
0   0    Input               
0   1    Input with pull-up

I can't explain AVR basics any more here, because it is off topic for subscribers of this thread.


Quote
There's no way I can hook up all 7 pins to one port on this board without soldering directly to the Atmega which I'm not doing :P so I will have to adopt at least one additional scan like your additional JP scan above, or have I misunderstood..
It is no problem, you can use simple C bit operation. I'm not sure what you mean by 'additional scan' but if you use HHKB pro/pro2 you don't need to read(scan) keys on additional rows.

Quote
This probably not very clear, basically I'm asking you to explain KEY_SELECT above or at least let me know what I've gotten wrong :).
KEY_SELECT selects a key on switch matrix to read its state(pressed/released) with given row and col arguments. In my configuration, you can select a row with PB0-2 and col with PB3-5, those pins control HC4051 and LS145.
https://github.com/tmk/tmk_keyboard/blob/master/keyboard/hhkb/doc/HHKB.txt#L41-L47

FYI, PB6,7 are retained without change here.
https://github.com/tmk/tmk_keyboard/blob/master/keyboard/hhkb/hhkb_avr.h#L82

EDIT: hmm, it is common idiom on C. You can take time to learn C more it will be very fruitive investment in the end.
Quote
    PORTB = (PORTB & 0xC0) | (((COL) & 0x07)<<3) | ((ROW) & 0x07); // notation here is confusing me C0 scans first 2? PB0 and PB1? and then into a 07 (First 3) for both COLS and ROWS

'(PORTB & 0xC0)` is used to keep bit7 and 6 from change during this operation. Again, C basics is off topic here though.
Title: Re: TMK keyboard firmware
Post by: Liocer on Sat, 06 February 2016, 01:31:30
Once again thank you hasu I will stop poisoning your thread now
Title: Re: TMK keyboard firmware
Post by: e_l_tang on Sun, 07 February 2016, 04:11:32
Hi everyone, I am fairly new to the world of mechanical keyboards and also to that of programming. I have a few miscellaneous questions:

Any help is appreciated!
Title: Re: TMK keyboard firmware
Post by: Koren on Sun, 07 February 2016, 18:16:44
From memory (can't check the source now), so take this with a huge grain of salt before someone can confirm this...


I would think that in order to set the Magic key combination to be both Shift keys pressed together, it would have to be defined as "(keyboard_report->mods == (MOD_BIT(KC_LSHIFT) & MOD_BIT(KC_RSHIFT)))". However, it is defined differently as "(keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)))". Why doesn't pressing either Shift key activate Magic?
Pretty sure mods is a set of bits corresponding to the state of modifiers, and MOD_BIT(KC...) corresponds to the single bit associated with the modifier.

E.g. :

left_shift is 0b00000001
right_shift is 0b00000010

To get both, you need a report that say 0b00000011

Which is 0b00000001 | 0b00000010

0b00000001 & 0b00000010 would be 0, so NO modifier...

  • What is the conditional statement that represents that no modifiers are being held? To clarify, I'm looking for something like "(keyboard_report->mods == (MOD_BIT(FALSE)))"
Probably simply == 0, for the same reason as above.



Not sure what you want to do exactly with your last question... Could you elaborate a bit?
Title: Re: TMK keyboard firmware
Post by: e_l_tang on Sun, 07 February 2016, 18:47:34
Thank you for enlightening me. My first two questions just seem dumb now.

The macro in my third question was supposed to register a semicolon when tapped and a colon when double tapped, but it registered a semicolon no matter what.
Title: Re: TMK keyboard firmware
Post by: Koren on Sun, 07 February 2016, 19:14:51
The macro in my third question was supposed to register a semicolon when tapped and a colon when double tapped, but it registered a semicolon no matter what.
I see...

How exactly do you intend to recognize a single tap?

Because you need somethink like:

Key Down
(small time)
Key Up
(enough time to be sure there won't be a second tap)

The last part can be tricky, since you can't act either on a keydown or on a keyup... And you don't want to wait to the next key down either. I don't remember an event like a timer occuring some time after a key release (although I'm sure it could be done without too much hassle... you'd have to flush it before a different keypress, though).


I'd suggest you an alternative, though, that may suits you depending on what you're after, and could be easier to implement:
- on keydown, register a colon
- on keydown after a tap on the same key, register a backspace then a semicolon

This way, the key will work normally as a colon, but tap + press or double tap will replace the colon with a semicolon.

You won't be able to use it in a game that expect a semicolon, but if you want to use it to type text or code, I think it's a valid solution that avoids creating a timer event and dealing with the related issues...
Title: Re: TMK keyboard firmware
Post by: e_l_tang on Sun, 07 February 2016, 20:24:57
This seems a little too complex for me to wrap my head around, so I'll drop this idea for now and revisit it later. Thanks for all your help.
Title: Re: TMK keyboard firmware
Post by: pwnz on Mon, 08 February 2016, 01:41:08
Thanks man, this worked!

Try NUBS, it's what I have on my ISO there.

Edit: and NUHS for the other slash. Like this:

Code: [Select]
...
    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, \
        FN0, A,   S,   D,   F,   G,   H,   J,   K,   L,   SCLN,QUOT,NUHS,      \
        LSFT,NUBS,Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, SLSH,RSFT,      \
        LCTL,LGUI,LALT,          SPC,                     RALT, RGUI,FN1, RCTL),
...
Title: Re: TMK keyboard firmware
Post by: Liocer on Mon, 08 February 2016, 03:05:14
The TX/RX LEDS are B0 and D5. You can remove the LED and resistor to have a convenient tiny pad to solder to.

Just aware that the bootloader flashes these when loading firmware, otherwise they work fine for digital io.

You can see how they are wired in the schematic. http://cdn.sparkfun.com/datasheets/Dev/Arduino/Boards/Pro_Micro_v13b.pdf

Thanks A-c, I got it working this weekend, desoldered the resistor from PB0 so I didn't have to change the scanning code, my soldering is better then my ;). I moved PB7 and PD4 to PD0 and PD1 respectively and all seemed to work fine. Typing on my modded hhkb now :D.
Title: Re: TMK keyboard firmware
Post by: dricher on Wed, 10 February 2016, 21:47:26
Hey guys,

I have tried to figure it out on my own but I just can't! I have recently build myself a right handed gamepad for work. Everything works even backlights!

My problem is that backlights are WAY to strong. I could probably light the moon with it! I just can't seem to figure out how to ajust the brightness. I have tried to use the backlight_increase or backlight_decrease event backlight_step but nothing works.

My LEDs are connected to PB5, PB6 and PD7 (they are all PWM ports).

Thanks!
Title: Re: TMK keyboard firmware
Post by: skullydazed on Wed, 10 February 2016, 22:39:48
Hey guys,

I have tried to figure it out on my own but I just can't! I have recently build myself a right handed gamepad for work. Everything works even backlights!

My problem is that backlights are WAY to strong. I could probably light the moon with it! I just can't seem to figure out how to ajust the brightness. I have tried to use the backlight_increase or backlight_decrease event backlight_step but nothing works.

My LEDs are connected to PB5, PB6 and PD7 (they are all PWM ports).

Thanks!

Have you setup your init_backlight_pin() and backlight_set() functions? If not take a look at what I put together for my backlit keypad here:

https://github.com/skullydazed/tmk_keyboard/blob/master/keyboard/cluepad/backlight.c

You can poke around the other files in that directory to see how I got it all integrated.
Title: Re: TMK keyboard firmware
Post by: e_l_tang on Wed, 10 February 2016, 23:38:20
I have another question. What is the condition that checks whether or not a single bit of the modifier report is true? For example, how would I detect if left Shift being pressed while ignoring the states of all the other modifiers?

Edit: Alternatively, is there a way that I can link two keys together so that they act as one key?

Edit 2: I solved this problem with variables.

Edit 3: Still, does anyone know the answer to my first question? I would rather not use separate variables.
Title: Re: TMK keyboard firmware
Post by: obones on Thu, 11 February 2016, 10:18:34
In my setup, I have a function key that toggles NumLock and goes to a given layer.
I have assigned it FN1 and given these definitions:

Code: [Select]
   
[1] = ACTION_MACRO(NUM_LOCK),     // macro to press NumLock key then FN2
[2] = ACTION_LAYER_TOGGLE(2),     // to Numlock overlay

I have also written the following code:

Code: [Select]
const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
{
    switch (id) {
        case NUM_LOCK:
            return (record->event.pressed ?
                    MACRO( I(50), D(NUMLOCK), U(NUMLOCK), D(FN2), END ) :
                    MACRO( U(FN2), END ));
    }
    return MACRO_NONE;
}

However, I'm facing two issues:

1. When plugging the keyboard, there might be an initial state for NumLock from another plugged keyboard. How do I react to this?
2. While toggling the numlock status works, Switching to layer 2 does not seem to work with the macro. Is there another way to do it?

Regards
Title: Re: TMK keyboard firmware
Post by: e_l_tang on Thu, 11 February 2016, 12:32:18
I am very new to programming myself, so pardon me if some of this code doesn't work.

To solve your first issue, try throwing this in your keymap file. I'm assuming that you want you keyboard to turn Num Lock off when you plug it in.
Code: [Select]
void * matrix_init_user(void) {
  if (host_keyboard_leds() & (1<<USB_LED_NUM_LOCK)) {
    register_code(KC_NLCK);
    unregister code(KC_NLCK);
  }
};

To solve your second issue, you need a macro each of the two layers you are switching between.
Code: [Select]
case NUM_LOCK_ON:
  if (record->event.pressed) {
    layer_on(2);
    register_code(KC_NLCK);
    unregister_code(KC_NLCK);
  }
break;
case NUM_LOCK_OFF:
  if (record->event.pressed) {
    register_code(KC_NLCK);
    unregister_code(KC_NLCK);
    layer_off(2);
  }
break;
Title: Re: TMK keyboard firmware
Post by: obones on Fri, 12 February 2016, 10:13:29
To solve your first issue, try throwing this in your keymap file. I'm assuming that you want you keyboard to turn Num Lock off when you plug it in.
Code: [Select]
void * matrix_init_user(void) {
  if (host_keyboard_leds() & (1<<USB_LED_NUM_LOCK)) {
    register_code(KC_NLCK);
    unregister code(KC_NLCK);
  }
};

I could not find any trace of matrix_init_user in TMK's source code, but I already had a matrix_init function in my matrix.c file.
However, the code above would not work because host_keyboard_leds is always returning 0 in that context as matrix_init is called by keyboard_init before the driver variable is set.
This is why I created the following pull request: https://github.com/tmk/tmk_keyboard/pull/307
It adds keyboard_startup/matrix_startup that are called when the driver variable is set.
But thanks for the pointers, it got me started.


To solve your second issue, you need a macro each of the two layers you are switching between.
Code: [Select]
case NUM_LOCK_ON:
  if (record->event.pressed) {
    layer_on(2);
    register_code(KC_NLCK);
    unregister_code(KC_NLCK);
  }
break;
case NUM_LOCK_OFF:
  if (record->event.pressed) {
    register_code(KC_NLCK);
    unregister_code(KC_NLCK);
    layer_off(2);
  }
break;

Ah yes, of course. I wasn't sure I could press keys from within a function but that's possible and will be much more reliable.
So in the end, I don't have any macro left, just two more branches in my function handling code.

Thanks for your help.
Title: Re: TMK keyboard firmware
Post by: e_l_tang on Fri, 12 February 2016, 12:22:43
I got matrix_init_user from QMK, a branch of TMK. You can try to find it in QMK's repository at https://github.com/jackhumbert/qmk_firmware/.

What other user-defined functions do you have? I simply put all my custom stuff in action_get_macro.
Title: Re: TMK keyboard firmware
Post by: e_l_tang on Fri, 12 February 2016, 15:44:38
So I am assuming that there is no way to check if a single bit in a modifier report is true?
Title: Re: TMK keyboard firmware
Post by: dricher on Fri, 12 February 2016, 18:38:32
Hey guys,

I have tried to figure it out on my own but I just can't! I have recently build myself a right handed gamepad for work. Everything works even backlights!

My problem is that backlights are WAY to strong. I could probably light the moon with it! I just can't seem to figure out how to ajust the brightness. I have tried to use the backlight_increase or backlight_decrease event backlight_step but nothing works.

My LEDs are connected to PB5, PB6 and PD7 (they are all PWM ports).

Thanks!

Have you setup your init_backlight_pin() and backlight_set() functions? If not take a look at what I put together for my backlit keypad here:

https://github.com/skullydazed/tmk_keyboard/blob/master/keyboard/cluepad/backlight.c

You can poke around the other files in that directory to see how I got it all integrated.

Thanks a lot! that helped but when I add everything for PB5, PB6 and PD7, only PD7 works. If I remove everything regarding PD7, only PB6 works..... This is driving me nuts! here is my backlight.c

Code: [Select]
#include <avr/io.h>
#include "backlight.h"
#include "led.h"
#include "print.h"

int pwm_level;

void backlight_init_ports() {
    DDRD |= (1<<7);
    DDRB |= (1<<6) | (1<<5);
   
    // Initialize the timer
    TC4H = 0x03;
    //OCR4C = 0xFF;
    OCR4B = 0xFF;
    OCR4D = 0xFF;
    TCCR4A = 0b00100001;
    TCCR4B = 0b00000001;
    TCCR4C = 0b00001001;
    TCCR4D = 0b00000001;
    //TCCR4E = 0b00000100;
}

void backlight_set(uint8_t level)
{
    // Set as output.
    //DDRB |= (1<<6) | (1<<5);
    //DDRD |= (1<<7);
   
    // Determine the PWM level
    switch (level)
    {
        case 0:
            // 25%
            pwm_level = 0x40;
            break;
        case 1:
            // 66%
            pwm_level = 0x7F;
            break;
        case 2:
            // 66%
            pwm_level = 0xBF;
            break;
        case 3:
            // 100%
            pwm_level = 0xFF;
            break;
        case 4:
            // 0%
            pwm_level = 0x00;
            break;
        default:
            xprintf("Unknown level: %d\n", level);
    }
   
    // Write the PWM level to the timer
    TC4H = pwm_level >> 8;
    OCR4A = 0xFF & pwm_level;
    OCR4D = 0xFF & pwm_level;
    OCR4B = 0xFF & pwm_level;
    //OCR4C = 0xFF & pwm_level;

   
   
    //(level & BACKLIGHT_REAR) ? backlight_enable_rear() : backlight_disable_rear();

}
Title: Re: TMK keyboard firmware
Post by: hasu on Fri, 12 February 2016, 19:39:42
So I am assuming that there is no way to check if a single bit in a modifier report is true?
keyboard_report.mod has state of eight modifiers in 8bits, you can use it for your purpose.

its format looks look like this.
https://github.com/tmk/tmk_keyboard/blob/master/tmk_core/common/report.h#L118

you can check if left shift is depressed like this.

if (mods & (1<<1) ) { yes, depressed }
Title: Re: TMK keyboard firmware
Post by: e_l_tang on Fri, 12 February 2016, 22:00:17
Thank you, hasu. Unfortunately, my new keymap file cannot compile; I am getting an error message saying that "mods" is undefined. Can you point me to the correct header file I need to include?
Title: Re: TMK keyboard firmware
Post by: hasu on Fri, 12 February 2016, 22:41:42
use keyboard_report.mods, which defined in action_util.h.
Title: Re: TMK keyboard firmware
Post by: e_l_tang on Fri, 12 February 2016, 22:53:13
I already have that header file included in my keymap. Do you have any idea why things are not working?
Title: Re: TMK keyboard firmware
Post by: hasu on Fri, 12 February 2016, 22:56:45
perhaps qmk problem ?
are you sure using tmk?
Title: Re: TMK keyboard firmware
Post by: e_l_tang on Fri, 12 February 2016, 23:00:41
I am indeed using QMK, but shouldn't these low-level things be the same?

Here is the header file in question.
Code: [Select]
/*
Copyright 2013 Jun Wako <wakojun@gmail.com>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ACTION_UTIL_H
#define ACTION_UTIL_H

#include <stdint.h>
#include "report.h"

#ifdef __cplusplus
extern "C" {
#endif

extern report_keyboard_t *keyboard_report;

void send_keyboard_report(void);

/* key */
void add_key(uint8_t key);
void del_key(uint8_t key);
void clear_keys(void);

/* modifier */
uint8_t get_mods(void);
void add_mods(uint8_t mods);
void del_mods(uint8_t mods);
void set_mods(uint8_t mods);
void clear_mods(void);

/* weak modifier */
uint8_t get_weak_mods(void);
void add_weak_mods(uint8_t mods);
void del_weak_mods(uint8_t mods);
void set_weak_mods(uint8_t mods);
void clear_weak_mods(void);

/* oneshot modifier */
void set_oneshot_mods(uint8_t mods);
void clear_oneshot_mods(void);
void oneshot_toggle(void);
void oneshot_enable(void);
void oneshot_disable(void);

/* inspect */
uint8_t has_anykey(void);
uint8_t has_anymod(void);
uint8_t get_first_key(void);

#ifdef __cplusplus
}
#endif

#endif
Title: Re: TMK keyboard firmware
Post by: hasu on Fri, 12 February 2016, 23:11:52
ah, . vs -> ?
Title: Re: TMK keyboard firmware
Post by: e_l_tang on Fri, 12 February 2016, 23:17:50
What exactly should I be editing?

Edit: I misunderstood some of your previous comments. I edited my keymap file and everything is working perfectly now. Thank you so much for all your help.
Title: Re: TMK keyboard firmware
Post by: mveinot on Tue, 16 February 2016, 13:07:25
Greetings everyone. I'm a long time user of boards such as the Arduino, and recently ESP8266-based hardware. So hacking on this type of thing is not new to me. I'm a software developer and I use an IBM Model-M regularly on a 2012 Mac Mini (OS X 10.11).

I stumbled upon this project and had a spare Teensy 2.0 lying around from a previous project and thought it looked interesting and might offer some enhanced capabilities. I managed to wire up the teensy, compile and upload the code with no major issues and for the most part it's working perfectly.

My issue (which is an issue I've had with every PS/2->USB converter I've tried so far) is that if I perform a soft reboot of the Mac, upon starting again, keyboard input is ignored until I unplug the USB adapter and plug it back in. Is anyone here familiar with this issue. I'm not opposed to making changes to the code and testing it. Can anyone offer any insight on where I could look to attempt to resolve this issue? Or is there a more fundamental hardware issue at fault here?
Title: Re: TMK keyboard firmware
Post by: njbair on Tue, 16 February 2016, 16:04:01
What's the officially recommended way to use tmk_core?

For instance, I have a bunch of devices running TMK: a Pegasus Hoof, multiple alps64 boards, a Planck (QMK but still), two Infinity boards, and a pair of USB-to-USB converters. I like to maintain my own TMK fork with all my custom layouts. Currently these are scattered across multiple forks, which is not ideal. I want to consolidate my personal stuff into a single subdirectory, and include TMK Core and the QMK fork as Git submodules in a separate top-level directory, like so:

Code: [Select]

.
|-- devices
|   |-- alps64
|   |-- infinity
|   |-- pegasus_hoof
|   |-- planck
|   `-- usb_usb_converter
`-- submodules
    |-- qmk
    `-- tmk_core


Alternatively, I could add another layer of organization to the devices folder:

Code: [Select]

.
|-- devices
|   |-- controller
|   |   `-- pegasus_hoof
|   |-- converter
|   |   `-- usb_usb
|   `-- keyboard
|       |-- alps64
|       |-- infinity
|       `-- planck
`-- submodules
    |-- qmk
    `-- tmk_core


hasu, I'm particularly curious to hear your thoughts on this idea, and whether or not you think there's a better way to do this. Others are also free to offer their input, of course. Thanks.
Title: Re: TMK keyboard firmware
Post by: hasu on Tue, 16 February 2016, 18:17:05
Greetings everyone. I'm a long time user of boards such as the Arduino, and recently ESP8266-based hardware. So hacking on this type of thing is not new to me. I'm a software developer and I use an IBM Model-M regularly on a 2012 Mac Mini (OS X 10.11).

I stumbled upon this project and had a spare Teensy 2.0 lying around from a previous project and thought it looked interesting and might offer some enhanced capabilities. I managed to wire up the teensy, compile and upload the code with no major issues and for the most part it's working perfectly.

My issue (which is an issue I've had with every PS/2->USB converter I've tried so far) is that if I perform a soft reboot of the Mac, upon starting again, keyboard input is ignored until I unplug the USB adapter and plug it back in. Is anyone here familiar with this issue. I'm not opposed to making changes to the code and testing it. Can anyone offer any insight on where I could look to attempt to resolve this issue? Or is there a more fundamental hardware issue at fault here?

Capture packets using tool like wireshark both on fault device and working device and compare the logs?
Title: Re: TMK keyboard firmware
Post by: hasu on Tue, 16 February 2016, 19:32:40
What's the officially recommended way to use tmk_core?

For instance, I have a bunch of devices running TMK: a Pegasus Hoof, multiple alps64 boards, a Planck (QMK but still), two Infinity boards, and a pair of USB-to-USB converters. I like to maintain my own TMK fork with all my custom layouts. Currently these are scattered across multiple forks, which is not ideal. I want to consolidate my personal stuff into a single subdirectory, and include TMK Core and the QMK fork as Git submodules in a separate top-level directory, like so:

Code: [Select]

.
|-- devices
|   |-- alps64
|   |-- infinity
|   |-- pegasus_hoof
|   |-- planck
|   `-- usb_usb_converter
`-- submodules
    |-- qmk
    `-- tmk_core


Alternatively, I could add another layer of organization to the devices folder:

Code: [Select]

.
|-- devices
|   |-- controller
|   |   `-- pegasus_hoof
|   |-- converter
|   |   `-- usb_usb
|   `-- keyboard
|       |-- alps64
|       |-- infinity
|       `-- planck
`-- submodules
    |-- qmk
    `-- tmk_core


hasu, I'm particularly curious to hear your thoughts on this idea, and whether or not you think there's a better way to do this. Others are also free to offer their input, of course. Thanks.

No official recommendation for project file organization :D It completely depends on project owner's preference. Both file trees looks decent to me,

You can manage all projects(keyboard/converter/controller) in a git repo or can have a repo per project. Also you can clone, submodule or subtree tmk_core depending on your preference.
Title: Re: TMK keyboard firmware
Post by: e_l_tang on Sat, 20 February 2016, 22:25:20
Is there a way to program the keyboard to return to layer 0 and turn off Caps Lock after, say, one minute of inactivity?
Title: Re: TMK keyboard firmware
Post by: Koren on Sun, 21 February 2016, 01:51:57
Is there a way to program the keyboard to return to layer 0 and turn off Caps Lock after, say, one minute of inactivity?
Yes (provided you're not to strict on the exact value of "one minute")

Here is how I would do it:
- open keyboard.c
- look for keyboard_task
- create a static integer variable, initialized at zero
- increment the variable somewhere, e.g. before the matrix_scan() call
- reset it to zero in the if (matrix_change) { ...
- at the end of the function, for example (after MATRIX_LOOP_END), check whether the variable reached a given value (e.g. 50000) and if so, do what you want after inactivity.

I'd strongly suggest the test at the end of the function just call a user function, something like void* inactivity_user(void), that you define for example in your keymap files rather than directly in the keyboard.c that should only contains user-independant code.

The value (50000) should also be defined by the user. You may be forced to use trial and error to know the value that will correspond to one minute, though (it's 60 times the scan rate when nothing happens)
Title: Re: TMK keyboard firmware
Post by: e_l_tang on Sun, 21 February 2016, 12:54:30
Is there any way I could do this in my keymap file? I don't want my changes to be overwritten when I pull an update.

I think QMK might allow me to do this because the default ErgoDox keymap, which can be found at https://github.com/jackhumbert/qmk_firmware/blob/master/keyboard/ergodox_ez/keymaps/default/keymap.c, has a loop at the end to control the LEDs. I think I might be able to make a similar loop that does what I want.
Title: Re: TMK keyboard firmware
Post by: flabbergast on Sun, 21 February 2016, 14:07:46
Normally you'd "fork" TMK (i.e. create another git branch) and maintain it. You can periodically 'merge' the master branch if you want to pull in the new code. Things won't get overwritten; git is pretty good at auto-merging but if the conflicts are too severe you'll need to decide manually by editing the files.
Title: Re: TMK keyboard firmware
Post by: e_l_tang on Sun, 21 February 2016, 14:50:36
I have a cloned the QMK repository into a folder instead of forking it. Will pulling updates to the folder be any different?

Either way, I would still prefer to only change my keymap file. Do you have any ideas?
Title: Re: TMK keyboard firmware
Post by: flabbergast on Sun, 21 February 2016, 15:02:54
Sorry, I don't think this can be done with the "normal" TMK by just editing the 'keyboard' files, at least not without some relatively ugly hacks. I mean that there are functions there which are called very often in matrix.c (e.g. matrix_scan) within which you can do a similar hook to what Koren described (basically a counter in that function, and you can also test there whether anything's been pressed).

Ad forking: cloning is fine; you now have your own repository which pulls the remote master branch into your local master branch. You can locally create your own branch ('git checkout -b myownsuperbranch') where you can commit, etc... and when you want to pull upstream changes, do 'git checkout master; git pull; git checkout myownsuperbranch; git merge master').
Just google 'git branching', there are a bunch of tutorials out there at various levels :)
Title: Re: TMK keyboard firmware
Post by: e_l_tang on Sun, 21 February 2016, 15:07:55
I am not using TMK, but rather a fork of it called QMK. The name of the loop in the default keymap of the ErgoDox suggests that it's synchronized with the matrix scanning. Are you sure I can't appropriate that loop for my own purposes?

Thanks, I didn't know that.
Title: Re: TMK keyboard firmware
Post by: flabbergast on Sun, 21 February 2016, 15:42:21
Yep, just had a look at QMK. It does have periodically called functions - you can use matrix_scan_user on ergodox_ez.
Title: Re: TMK keyboard firmware
Post by: e_l_tang on Sun, 21 February 2016, 16:02:47
I actually tried to use matrix_scan_user first, but I failed. The instructions that Koren gave me gave me a good idea of what I was doing wrong, but they seem to rely a lot on the other stuff in keyboard.c. How would I use matrix_scan_user instead?

Edit: Apparently there is no way for it to detect keypresses because nothing is being fed to it.
Title: Re: TMK keyboard firmware
Post by: e_l_tang on Sun, 21 February 2016, 21:43:22
I fiddled around with things and I think I am getting close. You can see my current keymap, which does not work fully, at https://gist.github.com/Eric-L-T/9c3f8093eacca1b905cb. I intended the last function to reset empty_scans to zero whenever any key is pressed, but it seems that I am misunderstanding record->event.pressed. Can someone help?
Title: Re: TMK keyboard firmware
Post by: naasfu on Mon, 22 February 2016, 03:01:29
I spent some time wondering why some of my layers would not take effect while I had another layer activated.  Then I found this issue item (https://github.com/tmk/tmk_keyboard/issues/59) that explained my incorrect assumption about TMK layers.  I thought layers would pile up as a stack as you activated them, but there is only the fixed ordering of layers that we defined in the first place.  I moved the layers that I wanted to activate to the end of the layer definitions array, and that fixed it. :)

hasu, could you please a note to the documentation that specifically says that the layers do not stack based on the order in which you activate them?  You do have the explanation of the stack and how layers are turned on/off, but I guess people (like me, oops) may assume that layers might get stacked according to their activation order, so maybe specifically call out that is not the case.

Anyways, very cool stuff. :)
Title: Re: TMK keyboard firmware
Post by: Koren on Mon, 22 February 2016, 03:49:06
I fiddled around with things and I think I am getting close. You can see my current keymap, which does not work fully, at https://gist.github.com/Eric-L-T/9c3f8093eacca1b905cb. I intended the last function to reset empty_scans to zero whenever any key is pressed, but it seems that I am misunderstanding record->event.pressed. Can someone help?
I think you may understand how record->event.pressed but be wrong about the function itself...

It's called only if you press a FN* key (not the function keys on a keyboard, the TMK action keys in the TMK keymap)

But yes, it's doable using only the keymap file, although probably a bit uglier:

1) create a variable
matrix_row_t matrix_previous[MATRIX_ROWS]

2) at the start of the matrix user function :
for each i in 0..MATRIX_ROWS-1
- check whether matrix_previous != matrix
- if so, reset your counter to 0, and copy matrix to matrix_previous

(if you want the counter to only reset on keypresses and not releases, you can replace != by < for the reset, but still copy if !=)
Title: Re: TMK keyboard firmware
Post by: e_l_tang on Mon, 22 February 2016, 12:38:24
Sorry, I'm not understanding what you want me to put in matrix_scan_user. Also, I don't need action_function anymore, correct?

I also updated my code to rely on the timer, which will give more predictable results than the matrix will. Does that change anything?

Edit: This may be a dumb question, but I'm curious to know its answer. Will my timer variable overflow? If so, what will happen?
Title: Re: TMK keyboard firmware
Post by: Koren on Mon, 22 February 2016, 16:14:47
Sorry, I'm not understanding what you want me to put in matrix_scan_user.
Something like this:
Code: [Select]
for(int i=0; i<MATRIX_ROWS; ++i) {
    if (matrix[i] != prev_matrix[i]) {
        prev_matrix[i] = matrix[i]
        empty_scans = 0;
    }
Or the equivalent timer reset.

Also, I don't need action_function anymore, correct?
Not for this, at least.

I also updated my code to rely on the timer, which will give more predictable results than the matrix will. Does that change anything?
Probably not (although I don't really see why it would be more predictable... easier threshold value? During inactivity, the scan rate is probably really stable, and you won't probably mind a couple milliseconds in such a timer), but I'm not sure exactly how the timers work in this case. Any link?

Edit: This may be a dumb question, but I'm curious to know its answer. Will my timer variable overflow? If so, what will happen?
It's never a dumb question to think about overflows.

If you use uint32, you'll probably need something like a year without a keypress to overflow, so you're safe. With 16 bits, it's far more tricky. An additional reason to look how timers work.

If you managed the counter yourself, you can stop incrementing if you're over the threshold.

But in the worst case, you'll trigger the "return to layer 1" each time you do a complete cycle. Depending on how you program this return, it shouldn't be a problem.
Title: Re: TMK keyboard firmware
Post by: e_l_tang on Mon, 22 February 2016, 18:30:33
I integrated your code. However, the resulting keymap, which I have put in my gist, does not compile. Here is what I get:
Code: [Select]
-------- begin --------
avr-gcc (GCC) 4.9.3
Copyright (C) 2015 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.


Size before:
   text    data     bss     dec     hex filename
  19410      82     159   19651    4cc3 planck.elf


mkdir -p obj_planck/keymaps
Compiling C: keymaps/eric_mac.c
avr-gcc -c -mmcu=atmega32u4 -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 -DBACKLIGHT_ENABLE -DVERSION=af6163f -Os -funsigned-char -funsigned-bitfields -ffunction-sections -fdata-sections -fno-inline-small-functions -fpack-struct -fshort-enums -fno-strict-aliasing -Wall -Wstrict-prototypes -Wa,-adhlns=obj_planck/keymaps/eric_mac.lst -I. -I../.. -I../../tmk_core -I../../quantum -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_planck_keymaps_eric_mac.o.d  keymaps/eric_mac.c -o obj_planck/keymaps/eric_mac.o
keymaps/eric_mac.c: In function 'matrix_scan_user':
keymaps/eric_mac.c:181:7: error: 'matrix' undeclared (first use in this function)
   if (matrix[i] != prev_matrix[i]) {
       ^
keymaps/eric_mac.c:181:7: note: each undeclared identifier is reported only once for each function it appears in
keymaps/eric_mac.c:181:20: error: 'prev_matrix' undeclared (first use in this function)
   if (matrix[i] != prev_matrix[i]) {
                    ^
make: *** [obj_planck/keymaps/eric_mac.o] Error 1
Title: Re: TMK keyboard firmware
Post by: hasu on Mon, 22 February 2016, 19:59:42
I spent some time wondering why some of my layers would not take effect while I had another layer activated.  Then I found this issue item (https://github.com/tmk/tmk_keyboard/issues/59) that explained my incorrect assumption about TMK layers.  I thought layers would pile up as a stack as you activated them, but there is only the fixed ordering of layers that we defined in the first place.  I moved the layers that I wanted to activate to the end of the layer definitions array, and that fixed it. :)

hasu, could you please a note to the documentation that specifically says that the layers do not stack based on the order in which you activate them?  You do have the explanation of the stack and how layers are turned on/off, but I guess people (like me, oops) may assume that layers might get stacked according to their activation order, so maybe specifically call out that is not the case.

Anyways, very cool stuff. :)


Filed under "TODO" tag.
https://github.com/tmk/tmk_keyboard/issues/310

Oh my, already too many TODOs! :D
https://github.com/tmk/tmk_keyboard/labels/TODO
Title: Re: TMK keyboard firmware
Post by: hasu on Mon, 22 February 2016, 20:11:46
BTW, recent big thing is flabbergast's Chibios backend merger.
Now we can use Cortex-M with the 'chibios' in addition to existent 'mbed' stack. Chibios support many kind of STM32 and Kinetis.
https://github.com/tmk/tmk_keyboard/blob/master/README.md#20160210

Thank you, flabbergast!
Title: Re: TMK keyboard firmware
Post by: e_l_tang on Tue, 23 February 2016, 00:56:12
I figured out some of the problems and was able to compile my keymap. However, my keyboard still resets regardless of whether I am actively using it. I have no idea how to fix this. Anyone who wants to help can see my keymap at https://gist.github.com/Eric-L-T/9c3f8093eacca1b905cb.
Title: Re: TMK keyboard firmware
Post by: naasfu on Tue, 23 February 2016, 01:59:39
I spent some time wondering why some of my layers would not take effect while I had another layer activated.  Then I found this issue item (https://github.com/tmk/tmk_keyboard/issues/59) that explained my incorrect assumption about TMK layers.  I thought layers would pile up as a stack as you activated them, but there is only the fixed ordering of layers that we defined in the first place.  I moved the layers that I wanted to activate to the end of the layer definitions array, and that fixed it. :)

hasu, could you please a note to the documentation that specifically says that the layers do not stack based on the order in which you activate them?  You do have the explanation of the stack and how layers are turned on/off, but I guess people (like me, oops) may assume that layers might get stacked according to their activation order, so maybe specifically call out that is not the case.

Anyways, very cool stuff. :)


Filed under "TODO" tag.
https://github.com/tmk/tmk_keyboard/issues/310

Oh my, already too many TODOs! :D
https://github.com/tmk/tmk_keyboard/labels/TODO

thanks, hasu. :)

and haha, TODOs always love to pile up.
Title: Re: TMK keyboard firmware
Post by: e_l_tang on Tue, 23 February 2016, 03:21:25
hasu, you might want to take a look at the documentation of QMK Firmware and see if any of it is of any use to you. Although it is lacking in some repects, most of what's there is high-quality. Also, do you have any idea what might be wrong with my keymap?
Title: Re: TMK keyboard firmware
Post by: Koren on Tue, 23 February 2016, 12:54:24
I integrated your code. However, the resulting keymap, which I have put in my gist, does not compile.
Sorry about that...

You probably need a
Code: [Select]
#include "matrix.h"in the preamble of the file and a
Code: [Select]
matrix_row_t prev_matrix[MATRIX_ROWS]somewhere in the file, too.

It seems that you figured the second part, but after a quick look at the code, I'm not sure the first part is correct. Please add the include and replace "matrix_state" by "matrix" and try again...

However, my keyboard still resets regardless of whether I am actively using it. I have no idea how to fix this.
What do you mean by "reset"? Return to layer 1 even if you're typing?

It may be because of the problem above (the include). If not, I'd be curious to know more about the timer functions, I'd like to know how they work to help you, but I can't find anything?
Title: Re: TMK keyboard firmware
Post by: e_l_tang on Tue, 23 February 2016, 13:24:01
Now I get this error message:
Code: [Select]
-------- begin --------
avr-gcc (GCC) 4.9.3
Copyright (C) 2015 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.


Size before:
   text    data     bss     dec     hex filename
  19390      82     167   19639    4cb7 planck.elf


mkdir -p obj_planck/keymaps
Compiling C: keymaps/eric_mac.c
avr-gcc -c -mmcu=atmega32u4 -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 -DBACKLIGHT_ENABLE -DVERSION=af6163f -Os -funsigned-char -funsigned-bitfields -ffunction-sections -fdata-sections -fno-inline-small-functions -fpack-struct -fshort-enums -fno-strict-aliasing -Wall -Wstrict-prototypes -Wa,-adhlns=obj_planck/keymaps/eric_mac.lst -I. -I../.. -I../../tmk_core -I../../quantum -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_planck_keymaps_eric_mac.o.d  keymaps/eric_mac.c -o obj_planck/keymaps/eric_mac.o
keymaps/eric_mac.c: In function 'matrix_scan_user':
keymaps/eric_mac.c:176:7: error: 'matrix' undeclared (first use in this function)
   if (matrix[i] != prev_matrix[i]) {
       ^
keymaps/eric_mac.c:176:7: note: each undeclared identifier is reported only once for each function it appears in
make: *** [obj_planck/keymaps/eric_mac.o] Error 1

Yes, that's what I mean. I don't think there is much documentation on the timer feature; I'm not too sure how it works either. Anyway, its code can be found in the files named "timer.*."
Title: Re: TMK keyboard firmware
Post by: hasu on Tue, 23 February 2016, 14:39:52
you have to listen to compiler error messages word by word at first. in most cases GCC is correct and exact in general, believe it from the bottom of your heart :) if you can't understand it then Google is your friend.

your problem is that you don't declare matrix in this 'compilarion unit' or keymaps/eric_mac.c. In C compiler see just one file at a time basically so matrix[] defined in other file is not visible to GCC. To solve this you can use '#include' directive which makes specified file to be visible from current compilation unit.

this explanation is based on my iffy C knowledge you better learn how #include works from good C books or resources on line.

I hope this helps.


Quote
keymaps/eric_mac.c: In function 'matrix_scan_user':
keymaps/eric_mac.c:176:7: error: 'matrix' undeclared (first use in this function)
   if (matrix != prev_matrix) {
       ^
Title: Re: TMK keyboard firmware
Post by: redbanshee on Tue, 23 February 2016, 14:44:47
Hasu, I have a question for you... what exactly is so different about Quantum (QMK) compared to your repo? Sorry if this has already been covered (its a long thread!) just wondering what the main difference is?
Title: Re: TMK keyboard firmware
Post by: e_l_tang on Tue, 23 February 2016, 14:53:41
I already had "include "matrix.h"" at the top of my file when I got that error message.
Title: Re: TMK keyboard firmware
Post by: e_l_tang on Tue, 23 February 2016, 14:55:05
QMK is a fork of TMK maintained by Jack Humbert of Ortholinear Keyboards. It just contains some added features.
Title: Re: TMK keyboard firmware
Post by: redbanshee on Tue, 23 February 2016, 14:58:05
QMK is a fork of TMK maintained by Jack Humbert of Ortholinear Keyboards. It just contains some added features.

Thanks eric, I am aware that its a fork of tmk, I was just wondering how it differs exactly. "It just contains some added features." just wondering what those features are...
Title: Re: TMK keyboard firmware
Post by: e_l_tang on Tue, 23 February 2016, 15:04:42
A few things that I can think of right now are shortcuts for defining keymaps, built-in support for WS2812 RGB LED strips, and a few extra functions that can be used in keymap files.
Title: Re: TMK keyboard firmware
Post by: Darkshado on Tue, 23 February 2016, 16:10:57
Pro tip: Github now lets you compare across forks directly from their website.

Or: add the other repo as a remote and use git difftool + your favorite compare tool. I've used Meld in Linux and WinMerge in Windows, both FOSS; as well as Beyond Compare, $. There's command line options for the difftool command to compare between different remotes as well as compare a directory instead of a file.
Title: Re: TMK keyboard firmware
Post by: regack on Tue, 23 February 2016, 17:59:20
A few things that I can think of right now are shortcuts for defining keymaps, built-in support for WS2812 RGB LED strips, and a few extra functions that can be used in keymap files.

It's easier for someone less familiar with coding to change between column driven or row driven polling, and easier to set up your row/column pins.  It is probably not very important to most people, but QMK doesn't support the ATMEGA32U2, but TMK does.
Title: Re: TMK keyboard firmware
Post by: Koren on Tue, 23 February 2016, 18:23:30
I already had "include "matrix.h"" at the top of my file when I got that error message.
Yes, but I was actually wrong with that. It's actually not enough. I'm discussing this from memory, and I had not spent enough time checking everything was correct.

Hasu is right, the answer is in the error message: he can't find the table called "matrix"

That's because the declaration of the "matrix" table is *not* in matrix.h (I think I have included it to get access to the matrix_row_t definition).

It's defined somewhere in a .c file written for your board. You can find the correct file using grep (or any full-text research function). It's usually in a file called "matrix.c" in a directory called like your board/keyboard.

Unfortunately, it's defined as
Code: [Select]
static matrix_row_t matrix[MATRIX_ROWS];
You'll have to remove the static keyword in this file...

I know you wanted to modify only the keymap file, but I must say I run out of ideas :/ Just removing the "static" keyword shouldn't be a huge modification, though.

After that, you have to add a
Code: [Select]
extern matrix_row_t matrix[MATRIX_ROWS];in your keymap file.

And that should compile (and hopefully work).
Title: Re: TMK keyboard firmware
Post by: Koren on Tue, 23 February 2016, 18:27:41
It is probably not very important to most people, but QMK doesn't support the ATMEGA32U2, but TMK does.
I'd be curious to know why the support has been dropped? Is it because the fork is older than Atmega32U2 support in TMK and they never bothered to merge the branches? Or is there some incompatibility?
Title: Re: TMK keyboard firmware
Post by: e_l_tang on Tue, 23 February 2016, 18:48:22
Now I'm getting a lot of error messages saying that I have multiple definitions for a ton of things. Thanks for trying, though.

hasu, do you know of any simpler way to detect when any key is pressed?
Title: Re: TMK keyboard firmware
Post by: njbair on Tue, 23 February 2016, 19:12:03
BTW, recent big thing is flabbergast's Chibios backend merger.
Now we can use Cortex-M with the 'chibios' in addition to existent 'mbed' stack. Chibios support many kind of STM32 and Kinetis.
https://github.com/tmk/tmk_keyboard/blob/master/README.md#20160210

Thank you, flabbergast!

This sounds cool. Will this new stack affect the Infinity?

I am primarily curious about media keys support and boot magic for the Infinity.
Title: Re: TMK keyboard firmware
Post by: flabbergast on Wed, 24 February 2016, 02:36:07
This sounds cool. Will this new stack affect the Infinity?

I am primarily curious about media keys support and boot magic for the Infinity.
You'll have the option to either use mbed backend as before, or the chibios one. The chibios one should support both of these (if it does not, please report!).
Title: Re: TMK keyboard firmware
Post by: Koren on Wed, 24 February 2016, 04:34:10
Now I'm getting a lot of error messages saying that I have multiple definitions for a ton of things. Thanks for trying, though.
A ton? That's strange... I know it works, I use it myself. It's just that it's difficult to debug via a forum.

I think it would be quicker if I was trying to compile it myself. What board from QMK firmware do you use?
Title: Re: TMK keyboard firmware
Post by: e_l_tang on Wed, 24 February 2016, 04:36:45
I'm using a Planck. By the way, are you familiar with strong modifiers and weak modifiers? If so, could you briefly explain them to me? I can't seem to find any documentation on them.
Title: Re: TMK keyboard firmware
Post by: regack on Wed, 24 February 2016, 06:22:39
It is probably not very important to most people, but QMK doesn't support the ATMEGA32U2, but TMK does.
I'd be curious to know why the support has been dropped? Is it because the fork is older than Atmega32U2 support in TMK and they never bothered to merge the branches? Or is there some incompatibility?

I think I shouldn't have said 'doesn't support' so much as 'support has been skipped'.  It's not that you can't make it work (I have (https://geekhack.org/index.php?topic=79929.0)) but QMK assumes that you have all of the registers (B, C, D, E, F) without taking into account that the ATmega32u2 only has B, C & D.  QMK also assumes access to Timer3 and other output compare registers, which aren't there on the U2.  I intend to make my branch more generic to support the U4 and U2, but I haven't gotten to it yet.
Title: Re: TMK keyboard firmware
Post by: njbair on Wed, 24 February 2016, 08:59:21
This sounds cool. Will this new stack affect the Infinity?

I am primarily curious about media keys support and boot magic for the Infinity.
You'll have the option to either use mbed backend as before, or the chibios one. The chibios one should support both of these (if it does not, please report!).

This is great news!

hasu, any word on when we can expect these updates to show up in the core branch?
Title: Re: TMK keyboard firmware
Post by: e_l_tang on Wed, 24 February 2016, 12:07:19
It would seem from the documentation at https://github.com/tmk/tmk_keyboard#20160210 that ChibiOS is already part of TMK.
Title: Re: TMK keyboard firmware
Post by: njbair on Wed, 24 February 2016, 12:42:10
It would seem from the documentation at https://github.com/tmk/tmk_keyboard#20160210 that Chibios is already part of TMK.

Yep, I was asking about the core branch (https://github.com/tmk/tmk_keyboard/tree/core).
Title: Re: TMK keyboard firmware
Post by: hasu on Wed, 24 February 2016, 13:19:06
It would seem from the documentation at https://github.com/tmk/tmk_keyboard#20160210 that Chibios is already part of TMK.

Yep, I was asking about the core branch (https://github.com/tmk/tmk_keyboard/tree/core).

I didn't update core branch any more, instead I'll maintain tmk_core repository for same purpose. The repository integreated chibios. You will be able to git-subtree or submodule it to start your own project.
https://github.com/tmk/tmk_core

core branch didn't seem to be useful or tmk_core repository makes more sense to me. Probably I'll remove core branch some later.
Title: Re: TMK keyboard firmware
Post by: e_l_tang on Wed, 24 February 2016, 13:43:18
hasu, I am tailoring TMK/QMK to my needs and I am wondering if the behaviors I am implementing would be of any use to others.

Would you consider adding any of the following to TMK?
Title: Re: TMK keyboard firmware
Post by: njbair on Wed, 24 February 2016, 16:01:03
It would seem from the documentation at https://github.com/tmk/tmk_keyboard#20160210 that Chibios is already part of TMK.

Yep, I was asking about the core branch (https://github.com/tmk/tmk_keyboard/tree/core).

I didn't update core branch any more, instead I'll maintain tmk_core repository for same purpose. The repository integreated chibios. You will be able to git-subtree or submodule it to start your own project.
https://github.com/tmk/tmk_core

core branch didn't seem to be useful or tmk_core repository makes more sense to me. Probably I'll remove core branch some later.

OK thanks. I'll just switch my personal repo to pull in the master branch, then adjust the TMK_DIR in the Makefiles accordingly. Thanks for clearing that up.

So I'm trying to compile this infinity_chibios firmware. I downloaded ChibiOS from Sourceforge, and symlinked it to tmk_core/tools/chibios/chibios, but I still get the following error when I try to compile the Infinity firmware:

Code: [Select]
../../module/tmk/tmk_core/tool/chibios/chibios.mk:88: ../../module/tmk/tmk_core/tool/chibios/chibios/os/common/ports/ARMCMx/compilers/GCC/mk/startup_k20x5.mk: No such file or directory
make: *** No rule to make target '../../module/tmk/tmk_core/tool/chibios/chibios/os/common/ports/ARMCMx/compilers/GCC/mk/startup_k20x5.mk'.  Stop.

When I list the contents of the directory in question, I do not see startup_k20x5.mk, but I do see these:

Code: [Select]
startup_k20x.mk
startup_kl2x.mk
startup_stm32f0xx.mk
startup_stm32f1xx.mk
startup_stm32f3xx.mk
startup_stm32f4xx.mk
startup_stm32l0xx.mk
startup_stm32l1xx.mk

What am I missing?
Title: Re: TMK keyboard firmware
Post by: flabbergast on Wed, 24 February 2016, 16:07:23
@njbair: The thing is that at the moment you'll need to get my branch of chibios (https://github.com/flabbergast/chibios/tree/kinetis), which has a more up-to-date kinetis support.

{Merging this to something more official in chibios is in the works, but it may take a bit. Meanwhile I'm more-less keeping up with the chibios mainline.}
Title: Re: TMK keyboard firmware
Post by: njbair on Wed, 24 February 2016, 17:24:37
@njbair: The thing is that at the moment you'll need to get my branch of chibios (https://github.com/flabbergast/chibios/tree/kinetis), which has a more up-to-date kinetis support.

{Merging this to something more official in chibios is in the works, but it may take a bit. Meanwhile I'm more-less keeping up with the chibios mainline.}
That's good to know. However, the readme links to the official ChibiOS site. Did I miss something in the Readme about using your branch?
Title: Re: TMK keyboard firmware
Post by: flabbergast on Wed, 24 February 2016, 17:44:45
@njbair: The thing is that at the moment you'll need to get my branch of chibios (https://github.com/flabbergast/chibios/tree/kinetis), which has a more up-to-date kinetis support.

{Merging this to something more official in chibios is in the works, but it may take a bit. Meanwhile I'm more-less keeping up with the chibios mainline.}
That's good to know. However, the readme links to the official ChibiOS site. Did I miss something in the Readme about using your branch?
It does, but now I realise it may not be quite clear, sorry (the MCUs in Teensy 3.x and Infinity and Whitefox are all Freescale Kinetis line).
Quote
To use, unpack or symlink ChibiOS {currently 3.0.2} to tmk_core/tool/chibios/chibios. For Kinetis support, you'll need a fork which implements the USB driver, e.g. this one.
Title: Re: TMK keyboard firmware
Post by: e_l_tang on Wed, 24 February 2016, 19:17:42
Everyone, a redditor solved my problem. Thanks for trying, though. See my gist for my new keymap.
Title: Re: TMK keyboard firmware
Post by: njbair on Thu, 25 February 2016, 09:08:51


@njbair: The thing is that at the moment you'll need to get my branch of chibios (https://github.com/flabbergast/chibios/tree/kinetis), which has a more up-to-date kinetis support.

{Merging this to something more official in chibios is in the works, but it may take a bit. Meanwhile I'm more-less keeping up with the chibios mainline.}
That's good to know. However, the readme links to the official ChibiOS site. Did I miss something in the Readme about using your branch?
It does, but now I realise it may not be quite clear, sorry (the MCUs in Teensy 3.x and Infinity and Whitefox are all Freescale Kinetis line).
Quote
To use, unpack or symlink ChibiOS {currently 3.0.2} to tmk_core/tool/chibios/chibios. For Kinetis support, you'll need a fork which implements the USB driver, e.g. this one.

Just following up. I got this working this morning. I cloned your ChibiOS repo this morning and copied over my existing Infinity keymap into the ChibiOS folder. I had to comment out the INFINITY_PROTOTYPE flag in the Makefile, but other than that it worked perfectly out of the box.

I'm super psyched to finally have media keys support on my Infinity boards! I'll have to test out boot magic sometime soon and make sure that's working. Flabbergast, you've given the Infinity a new lease on life! Thanks to you and hasu for all your hard work. Hopefully I can find a way to contribute, despite my unfamiliarity with embedded programming.
Title: Re: TMK keyboard firmware
Post by: battletux on Fri, 26 February 2016, 06:34:16
Does anyone know how I can get the back lights for Fn, wasd and escape working for the GH60? I've soldered in the resistors to the required points on the PCB and added in the LEDs for the relevant switches, however I can not figure out how to get anything but the caps lock light to work.


Thanks.
Title: Re: TMK keyboard firmware
Post by: hasu on Fri, 26 February 2016, 10:17:22
you will need to check schematic of PCB to know how to control and write code.

my GH 60 firmware doesn't support any LEDs except for caps lock, if you didn't know.
Title: Re: TMK keyboard firmware
Post by: axtran on Mon, 29 February 2016, 22:17:46
Does anyone know how I can get the back lights for Fn, wasd and escape working for the GH60? I've soldered in the resistors to the required points on the PCB and added in the LEDs for the relevant switches, however I can not figure out how to get anything but the caps lock light to work.


Thanks.

I think you're mistaking the GH60 TMK config with what sounds like your board, being a Satan GH60. Unfortunately, the Satan GH60 has nothing to do with the original GH60 other than improperly stealing it's name.

You'll have better luck finding QMK guides of people who've already done backlight configuration, than making your own TMK config.
Title: Re: TMK keyboard firmware
Post by: a-c on Mon, 29 February 2016, 23:49:41
He may have a Rev B board. As described here: http://blog.komar.be/gh60-evolution/
Title: Re: TMK keyboard firmware
Post by: axtran on Tue, 01 March 2016, 06:25:58
True, I'm making an assumption... I do know the gh60 config in TMK has nothing but lock indicators, and hasu is also working on more advanced LED API changes.
Title: Re: TMK keyboard firmware
Post by: njbair on Tue, 01 March 2016, 11:17:43
I'm trying to figure out how to use the Child Lock magic command. The readme file says it's lshift+rshift+caps, but that doesn't work for me. I have not changed the default magic key combination, and lshift+rshift does work for most other magic commands, but Child Lock never works. Am I missing something?
Title: Re: TMK keyboard firmware
Post by: flabbergast on Tue, 01 March 2016, 11:28:17
@njbair: Did you #define KEYBOARD_LOCK_ENABLE somewhere (e.g. in the Makefile)?
Title: Re: TMK keyboard firmware
Post by: flog on Tue, 01 March 2016, 15:30:10
Using cubanics tmk firmware on my ergodox. Works great but Im having issues when connecting it to a kvm switch at work. The firmware doesnt seem to boot(leds do not flash when connected) I dont know how much difference there are between cubanics and the original tmk. The kvm has both usb and ps/2 on it. Tried connecting the ergodox to usb and ps/2 via a usb-to-ps/2 adapter. Any ideas how to get it to work?
Title: Re: TMK keyboard firmware
Post by: njbair on Tue, 01 March 2016, 20:40:08
@njbair: Did you #define KEYBOARD_LOCK_ENABLE somewhere (e.g. in the Makefile)?

That was it. I didn't have that option in my Makefile. It's there now, recompiled and locking like a charm. Thanks!

Now I just wish there was a way to default to locked on boot. I could always make a layer full of NO's, and set the boot magic default layer to that, but it would be nice if it was an option to use the built-in lock functionality. Either way, this should do well enough to keep my 4-year-old from doing any damage when I step away.
Title: Re: TMK keyboard firmware
Post by: shaymdev on Tue, 01 March 2016, 22:26:53
Haven't done any C coding since college... moving from C# back to C has proven... interesting.

Still trying to figure out how to gethe the bluefruit micro working in Bluetooth mode. It would really open the door to a whole host of bluetooth keyboards.

TMK seems to function perfectly in USB mode on this controller.

I also purchased one of these:  http://www.adafruit.com/product/2829

Basically the same thing as the bluefruit micro but the battery port is built in.
profet or anyone else: Any news on getting tmk working with the bluefruit feather 32u4?

I'm very interested in building a new version of my custom build using bluetooth low energy and that controller looks like the best option right now. I'd love it if I can use my existing tmk fork because of all the awesome stuff hasu has baked in that I don't want to live without (and I know I probably don't even use the half of what it's capable of)

Once I can verify the firmware works with it I'm very interested to see how battery life is since I tend to want to force myself to work in a pretty tight space I'd probably want to find the smallest battery that I can get away with. Will tmk's sleep functionality come in handy here?

I also saw today the adafruit bluefruit feather m0 which I'm wondering if the new chibios stuff from flabbergast means that controller would work just as well as the 32u4 version?
Title: Re: TMK keyboard firmware
Post by: flabbergast on Wed, 02 March 2016, 04:20:25
I think TMK supports bluefruit (the one with atmega32u4); at least there is some code in TMK towards that (I don't have one so I can't test).
For the new bluefruit M0 - that one has an ATSAMD chip, and these are not supported by chibios (yet).

The thing about ARM MCUs is that there are several major manufacturers (Freescale+NXP, ST, ATMEL), and the code is *not* compatible between them (sure, the basic core is the same, but all the other hardware features (e.g. GPIO) are implemented differently). Chibios has support for STM32s and Kinetises, but not much yet for LPC and ATSAM.
Title: Re: TMK keyboard firmware
Post by: knowsnokb on Wed, 02 March 2016, 19:19:10
Does the TMK firmware have have double function functionality/hold-key tap-key functionality?

For example,can I do the following with TMK firmware on my keyboard?

Press and hold left ALT= ALT
Press and hold right ALT = ALT
Press and release left ALT = [
Press and release right ALT = ]
Press and hold left SHIFT = SHIFT
Press and release left SHIFT = {
Press and hold Q = fn1
Press and release Q = Q

Can I also assign shift keys to like !@#$":? etc... to any key I want without me requiring to press shift?
Ex..
Assigning ? to backspace
Assigning : to spacebar

Thanks.
Title: Re: TMK keyboard firmware
Post by: e_l_tang on Wed, 02 March 2016, 19:24:33
All of these functionalities are possible. They're documented at https://github.com/tmk/tmk_core/blob/master/doc/keymap.md.
Title: Re: TMK keyboard firmware
Post by: e_l_tang on Wed, 02 March 2016, 19:25:35
Does there exist a detailed explanation of how TMK works? I've been reading through the source code trying to understand it, but there are some parts that I just can't figure out.
Title: Re: TMK keyboard firmware
Post by: typewriter on Wed, 02 March 2016, 19:45:32
Does there exist a detailed explanation of how TMK works? I've been reading through the source code trying to understand it, but there are some parts that I just can't figure out.

I would also like to understand the code.
Are all the source code for the all libraries used by TMK available in your repository? (aside of course from standard C/C++/language libraries)?
Do all .h files (if TMK uses c/c++) have .c/.cpp files available at the TMK repository? (aside of course form standard C/C++ language libraries)?
I mean, does it use external libraries whose source codes are not available from the TMK repository?

Title: Re: TMK keyboard firmware
Post by: njbair on Wed, 02 March 2016, 20:51:16
Does there exist a detailed explanation of how TMK works? I've been reading through the source code trying to understand it, but there are some parts that I just can't figure out.

I would also like to understand the code.
Are all the source code for the all libraries used by TMK available in your repository? (aside of course from standard C/C++/language libraries)?
Do all .h files (if TMK uses c/c++) have .c/.cpp files available at the TMK repository? (aside of course form standard C/C++ language libraries)?
I mean, does it use external libraries whose source codes are not available from the TMK repository?
Everything you need to compile TMK is included in hasu's repo, with the exception of ChibiOS which must be pulled in manually if you need to use it (you would know if you did).

A lot of third-party libs are included in the repo.
Title: Re: TMK keyboard firmware
Post by: Koren on Thu, 03 March 2016, 04:36:32
I would also like to understand the code.
It's not really hard to understand, just take a pen and paper to remember what is in which file. ^_^

I don't think there's documentation on it (in fact, there's several fonctionalities that doesn't seem to have user documentation, if I'm not mistaken). Maybe we should create a Wiki to share our informations on it...

Are all the source code for the all libraries used by TMK available in your repository? (aside of course from standard C/C++/language libraries)?
As njbair said, it's self-contained for most boards, but the C/C++ chain is non-standard if you're doing your first embedded project. You may need avr-gcc or an equivalent for your board.
Title: Re: TMK keyboard firmware
Post by: e_l_tang on Thu, 03 March 2016, 16:30:38
I know what code in each file (the filenames make that pretty clear), but what I don't know what it does. I would greatly appreciate it if you wrote an explanation.
Title: Re: TMK keyboard firmware
Post by: a-c on Sat, 05 March 2016, 20:07:51
you will need to check schematic of PCB to know how to control and write code.

my GH 60 firmware doesn't support any LEDs except for caps lock, if you didn't know.

I traced the circuit on the GH60 Rev.C from Techkeys.

The WASD LEDs are connected to F7
The Poker Arrow LEDs are connected to F4
ESC is connected to F6

They are connected directly to the pin so appropriate resistors should be chosen to keep power draw for the 4 LEDs under 20mA total.
Title: Re: TMK keyboard firmware
Post by: gcardinal on Mon, 07 March 2016, 03:54:06
I have Tandberg TDV-5000 and it has a few uniq keys which I wasn't able to find in https://github.com/tmk/tmk_core/blob/master/doc/keycode.txt
[attach=1]

I used HID Listen from https://www.pjrc.com/teensy/hid_listen.html and a few keys (top right row, orange keys in the picture)

// felt
r80 r4B +0F d0F
r80 rF0 r4B -0F u0F

// avsn
r80 r2A +19 d19
r80 rF0 r2A -19 u19

// setn
r80 r32 +05 d05
r80 rF0 r32 -05 u05

// ord
r80 r3A +10 d10
r80 rF0 r3A -10 u10

but I wasn't able to see how I can go from those codes to generate new array in keymap_common.h

Any help is greatly appreciated !

Edit: For use with tmk_keyboard > converter > ps2_usb

Edit 2: I now see that codes I got was wrong - since they came from arduino running "Soarer's Converter" - but I would still very much appreciate info on how to go from hid monitor output to keymapping
Title: Re: TMK keyboard firmware
Post by: hasu on Mon, 07 March 2016, 09:45:03
It seems like those keys spit scan code "80 xx" for press and "80 F0 xx" for release. Prefix code "80" is not known in general, probably specific to your keyboard. TMK PS/2 converter doesn't support it and I think Soarer's also not, they will just ignore "80".

To support those scan codes you have to fix ps2_usb/matrix.c to handle "80" prefix.
Title: Re: TMK keyboard firmware
Post by: axtran on Mon, 07 March 2016, 10:15:38

you will need to check schematic of PCB to know how to control and write code.

my GH 60 firmware doesn't support any LEDs except for caps lock, if you didn't know.

I traced the circuit on the GH60 Rev.C from Techkeys.

The WASD LEDs are connected to F7
The Poker Arrow LEDs are connected to F4
ESC is connected to F6

They are connected directly to the pin so appropriate resistors should be chosen to keep power draw for the 4 LEDs under 20mA total.

Any chance that you also have Fn or Caps LEDs too?
Title: Re: TMK keyboard firmware
Post by: a-c on Mon, 07 March 2016, 10:54:45
Caps is B2


Didn't notice a separate circuit for the FN, but it has to be either F5 or B0, those are the only pins left.
Title: Re: TMK keyboard firmware
Post by: axtran on Mon, 07 March 2016, 12:58:23

Caps is B2


Didn't notice a separate circuit for the FN, but it has to be either F5 or B0, those are the only pins left.

Thanks. I got my hands on a Green Rev. C from TechKeys and it is awesome.
Title: Re: TMK keyboard firmware
Post by: BlueNalgene on Mon, 07 March 2016, 14:37:59
I'm playing with dfu-programmer on debian, and I cannot successfully erase the old firmware on my board (which I programmed in Windows with FLIP)

Code: [Select]
# dfu-programmer atmega32u2 erase --suppress-validation --debug 300
Produces:

Code: [Select]
     target: atmega32u2
    chip_id: 0x2ff0
  vendor_id: 0x03eb
    command: erase
      quiet: false
      debug: 300
device_type: AVR
------ command specific below ------
   validate: false

then it proceeds to bring up the --help file.  This does not appear to erase the firmware on the device.  Running

Code: [Select]
# dfu-programmer atmega32u2 erase --suppress-validation --debug 300 && dfu-programmer atmega32u2 flash /home/wes/Downloads/alps64_firmware.hex --debug 300 && dfu-programmer atmega32u2 reset --debug 300
confirms this by giving a similar response as the erase only command, then spits out:

Code: [Select]
dfu.c:387: dfu_device_init( 1003, 12272, 0x7fff154fede0, true, false )
dfu.c:389: dfu_device_init(000003eb, 00002ff0)
libusb: debug [libusb_get_device_list]
libusb: debug [discovered_devs_append] need to increase capacity
libusb: debug [libusb_get_device_descriptor]
dfu.c:404:  0: 0x058f, 0x6364
libusb: debug [libusb_get_device_descriptor]
dfu.c:404:  1: 0x1d6b, 0x0002
libusb: debug [libusb_get_device_descriptor]
dfu.c:404:  2: 0x1267, 0x0103
libusb: debug [libusb_get_device_descriptor]
dfu.c:404:  3: 0x1d6b, 0x0001
libusb: debug [libusb_get_device_descriptor]
dfu.c:404:  4: 0x1d6b, 0x0001
libusb: debug [libusb_get_device_descriptor]
dfu.c:404:  5: 0x1d6b, 0x0002
libusb: debug [libusb_get_device_descriptor]
dfu.c:404:  6: 0x1d6b, 0x0001
libusb: debug [libusb_get_device_descriptor]
dfu.c:404:  7: 0x1d6b, 0x0002
libusb: debug [libusb_get_device_descriptor]
dfu.c:404:  8: 0x1d6b, 0x0001
libusb: debug [libusb_get_device_descriptor]
dfu.c:404:  9: 0x1d6b, 0x0003
libusb: debug [libusb_get_device_descriptor]
dfu.c:404: 10: 0x093a, 0x2521
libusb: debug [libusb_get_device_descriptor]
dfu.c:404: 11: 0x2109, 0x3431
libusb: debug [libusb_get_device_descriptor]
dfu.c:404: 12: 0x1d6b, 0x0002
dfu-programmer: no device present.
libusb: debug [libusb_exit]
libusb: debug [libusb_exit] destroying default context

The 4th line of that last output suggests that the old firmware did not erase.  Am I missing some sort of protection I need to disable when programming on Linux?
Title: Re: TMK keyboard firmware
Post by: e_l_tang on Mon, 07 March 2016, 15:10:42
Did you try using sudo?
Title: Re: TMK keyboard firmware
Post by: BlueNalgene on Mon, 07 March 2016, 15:16:07
Did you try using sudo?

I'm in Debian, so I use "su".  I was root when I ran the commands.
Title: Re: TMK keyboard firmware
Post by: axtran on Mon, 07 March 2016, 15:29:10

I'm playing with dfu-programmer on debian, and I cannot successfully erase the old firmware on my board (which I programmed in Windows with FLIP)

Code: [Select]
# dfu-programmer atmega32u2 erase --suppress-validation --debug 300
Produces:

Code: [Select]
     target: atmega32u2
    chip_id: 0x2ff0
  vendor_id: 0x03eb
    command: erase
      quiet: false
      debug: 300
device_type: AVR
------ command specific below ------
   validate: false

then it proceeds to bring up the --help file.  This does not appear to erase the firmware on the device.  Running

Code: [Select]
# dfu-programmer atmega32u2 erase --suppress-validation --debug 300 && dfu-programmer atmega32u2 flash /home/wes/Downloads/alps64_firmware.hex --debug 300 && dfu-programmer atmega32u2 reset --debug 300
confirms this by giving a similar response as the erase only command, then spits out:

Code: [Select]
dfu.c:387: dfu_device_init( 1003, 12272, 0x7fff154fede0, true, false )
dfu.c:389: dfu_device_init(000003eb, 00002ff0)
libusb: debug [libusb_get_device_list]
libusb: debug [discovered_devs_append] need to increase capacity
libusb: debug [libusb_get_device_descriptor]
dfu.c:404:  0: 0x058f, 0x6364
libusb: debug [libusb_get_device_descriptor]
dfu.c:404:  1: 0x1d6b, 0x0002
libusb: debug [libusb_get_device_descriptor]
dfu.c:404:  2: 0x1267, 0x0103
libusb: debug [libusb_get_device_descriptor]
dfu.c:404:  3: 0x1d6b, 0x0001
libusb: debug [libusb_get_device_descriptor]
dfu.c:404:  4: 0x1d6b, 0x0001
libusb: debug [libusb_get_device_descriptor]
dfu.c:404:  5: 0x1d6b, 0x0002
libusb: debug [libusb_get_device_descriptor]
dfu.c:404:  6: 0x1d6b, 0x0001
libusb: debug [libusb_get_device_descriptor]
dfu.c:404:  7: 0x1d6b, 0x0002
libusb: debug [libusb_get_device_descriptor]
dfu.c:404:  8: 0x1d6b, 0x0001
libusb: debug [libusb_get_device_descriptor]
dfu.c:404:  9: 0x1d6b, 0x0003
libusb: debug [libusb_get_device_descriptor]
dfu.c:404: 10: 0x093a, 0x2521
libusb: debug [libusb_get_device_descriptor]
dfu.c:404: 11: 0x2109, 0x3431
libusb: debug [libusb_get_device_descriptor]
dfu.c:404: 12: 0x1d6b, 0x0002
dfu-programmer: no device present.
libusb: debug [libusb_exit]
libusb: debug [libusb_exit] destroying default context

The 4th line of that last output suggests that the old firmware did not erase.  Am I missing some sort of protection I need to disable when programming on Linux?

I thought the chip was the atmega32u4?
Title: Re: TMK keyboard firmware
Post by: BlueNalgene on Mon, 07 March 2016, 15:41:28
I thought the chip was the atmega32u4?

The Alps64 uses ATMega32u2.  Source (https://geekhack.org/index.php?topic=69740.0;topicseen)
Title: Re: TMK keyboard firmware
Post by: flabbergast on Mon, 07 March 2016, 16:03:09
There should be nothing special about doing this in linux. It looks like the dfu-programmer can't talk to the atmega at all. Maybe it's a permissions problem (try as root/sudo?).
Title: Re: TMK keyboard firmware
Post by: e_l_tang on Mon, 07 March 2016, 16:13:50
Are you sure you activated your chip's boot loader?
Title: Re: TMK keyboard firmware
Post by: hasu on Mon, 07 March 2016, 17:53:04
BlueNalgene,
Seems like dfu-programmer doesn't find bootloader device(03eb:2ff0) somehow. To activate bootlaoder
push the button on bottom and run `lsusb` command to check if the device is recognized. You should get a line for the device in output of the command like this.
Code: [Select]
Bus 001 Device 038: ID 03eb:2ff0 Atmel Corp.

If not something wrong may be in OS configuration or hardware.
Title: Re: TMK keyboard firmware
Post by: BlueNalgene on Mon, 07 March 2016, 18:38:37
BlueNalgene,
Seems like dfu-programmer doesn't find bootloader device(03eb:2ff0) somehow. To activate bootlaoder
push the button on bottom and run `lsusb` command to check if the device is recognized. You should get a line for the device in output of the command like this.
Code: [Select]
Bus 001 Device 038: ID 03eb:2ff0 Atmel Corp.

If not something wrong may be in OS configuration or hardware.

lsusb yields

Code: [Select]
Bus 006 Device 005: ID 03eb:2ff0 Atmel Corp.
Looking at the code, it seems that the
Code: [Select]
--force parameter is only necessary for programming a 'blank' chip.  I removed that flag and the erase command works again. 

SOLVED

Can anyone else confirm this observation?  It might be worth updating the FAQ/Instructions
Title: Re: TMK keyboard firmware
Post by: axtran on Mon, 07 March 2016, 18:48:48

BlueNalgene,
Seems like dfu-programmer doesn't find bootloader device(03eb:2ff0) somehow. To activate bootlaoder
push the button on bottom and run `lsusb` command to check if the device is recognized. You should get a line for the device in output of the command like this.
Code: [Select]
Bus 001 Device 038: ID 03eb:2ff0 Atmel Corp.

If not something wrong may be in OS configuration or hardware.

lsusb yields

Code: [Select]
Bus 006 Device 005: ID 03eb:2ff0 Atmel Corp.
Looking at the code, it seems that the
Code: [Select]
--force parameter is only necessary for programming a 'blank' chip.  I removed that flag and the erase command works again. 

SOLVED

Can anyone else confirm this observation?  It might be worth updating the FAQ/Instructions

I had to use --force on a blank GH60 Rev. C for an into all programming (erased first) and then subsequent programming attempts (dfu-programmer on OS X) worked without any issues.
Title: Re: TMK keyboard firmware
Post by: hasu on Mon, 07 March 2016, 20:12:06
Looking at the code, it seems that the
Code: [Select]
--force parameter is only necessary for programming a 'blank' chip.  I removed that flag and the erase command works again. 

SOLVED

Can anyone else confirm this observation?  It might be worth updating the FAQ/Instructions

First note that '--force' option of erase command is only implemented in 0.7.x, I think older dfu-programmer has no this option. So this depends on version of the tool.


Quote from man page. In case of 0.7.x it is safe that you always have '--force' option for erase, you will get an error when chip are already blank unless you have this option.
Quote
       erase [--force]
              Erases  all the flash memory.  For AT90 and ATmega type devices a chip erase must
              be performed before other commands become available.  Erase first checks  if  the
              memory is blank unless --force flag is set.
Title: Re: TMK keyboard firmware
Post by: njbair on Tue, 08 March 2016, 20:31:56
So I had an idea today. I use TMK's layer switching all the time. But I think it would be really cool if layouts could be broken out into "zones." I'll give an example below.

So I ordered a Monarch from the group buy last fall. If you're not familiar with the Monarch, it's basically a 60% with a number pad on the left. Like this:

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

It would be cool to be able to switch the layout of the 60% section, without changing the layout of the numpad section. Then I could configure that bank of numpad keys for different tasks, such as gaming, CAD, or number entry, meanwhile switching alpha layouts between QWERTY and Dvorak without the two affecting one another.

I know this is something that TMK can't do, but I'm wondering if it would be possible to do add support for this. I'm not asking if it's likely, because I know it's an obscure use case, but is it technically possible to do this?

I envision the keymap file could define the zones as arrays of keys that belong to each group, like so:

Code: [Select]
zones = {
    /* numpad zone */
    [0] = [0, 1, 2, 3,
           18,19,20,21,
           36,37,38,39,
           54,55,56,57,
           70,71],
    /* everything else */
    [1] = [4, 5, 6, 7, 8, 9, 10,11,12,13,14,15,16,17,
           22,23,24,25,26,27,28,29,30,31,32,33,34,35,
           40,41,42,43,44,45,46,47,48,49,50,51,52,53,
           58,59,60,61,62,63,64,65,66,67,68,69,
           72,73,74,75,76,77,78]
}

Then you would need to define the keymaps for those zones, which you could do pretty much the same way as it's done now.

But then the important final step would be to take the two zone arrays and concatenate them into the currently-active keymap. This seems like it should work; you just have to keep track of which layer is active in each zone.

The only thing I'm not sure about, is whether there is enough memory to do all of this extra work.

Any thoughts?
Title: Re: TMK keyboard firmware
Post by: hasu on Tue, 08 March 2016, 21:38:49
If Monarch has an AVR as controller you will be able to read keymap directly from flash and don't need much memory. Or if it has Cortex-M you don't have to worry about memory space any more.
http://www.nongnu.org/avr-libc/user-manual/group__avr__pgmspace.html

You can implement your own keymap framework by replacing existent `action_for_key()` in tmk_core/common/keymap.c.
Title: Re: TMK keyboard firmware
Post by: gcardinal on Wed, 09 March 2016, 08:58:21
It seems like those keys spit scan code "80 xx" for press and "80 F0 xx" for release. Prefix code "80" is not known in general, probably specific to your keyboard. TMK PS/2 converter doesn't support it and I think Soarer's also not, they will just ignore "80".

To support those scan codes you have to fix ps2_usb/matrix.c to handle "80" prefix.

Thank you for the answer - I don't know C but I did gave it a try:
https://github.com/bergstar/tmk_keyboard/commit/f170fd174a4a2d523d8c8cc62337cf05a869a7dc

Will this be sufficient?
Title: Re: TMK keyboard firmware
Post by: BlueNalgene on Wed, 09 March 2016, 11:00:20
So I had an idea today. I use TMK's layer switching all the time. But I think it would be really cool if layouts could be broken out into "zones." I'll give an example below.

So I ordered a Monarch from the group buy last fall. If you're not familiar with the Monarch, it's basically a 60% with a number pad on the left. Like this:

Show Image
(http://i.imgur.com/XoHzCTl.png)


It would be cool to be able to switch the layout of the 60% section, without changing the layout of the numpad section. Then I could configure that bank of numpad keys for different tasks, such as gaming, CAD, or number entry, meanwhile switching alpha layouts between QWERTY and Dvorak without the two affecting one another.

I know this is something that TMK can't do, but I'm wondering if it would be possible to do add support for this. I'm not asking if it's likely, because I know it's an obscure use case, but is it technically possible to do this?

I envision the keymap file could define the zones as arrays of keys that belong to each group, like so:

Code: [Select]
zones = {
    /* numpad zone */
    [0] = [0, 1, 2, 3,
           18,19,20,21,
           36,37,38,39,
           54,55,56,57,
           70,71],
    /* everything else */
    [1] = [4, 5, 6, 7, 8, 9, 10,11,12,13,14,15,16,17,
           22,23,24,25,26,27,28,29,30,31,32,33,34,35,
           40,41,42,43,44,45,46,47,48,49,50,51,52,53,
           58,59,60,61,62,63,64,65,66,67,68,69,
           72,73,74,75,76,77,78]
}

Then you would need to define the keymaps for those zones, which you could do pretty much the same way as it's done now.

But then the important final step would be to take the two zone arrays and concatenate them into the currently-active keymap. This seems like it should work; you just have to keep track of which layer is active in each zone.

The only thing I'm not sure about, is whether there is enough memory to do all of this extra work.

Any thoughts?

Isn't that possible now?  You can use the toggle layer buttons to change the alpha section of the board, but leave the TK as transparent"  If you are talking about mixing and matching, you could just use a lot of layers. e.g. Layer 0 (default), Layer 1 (Dvorak Alpha), Layer 2 (upsidedown TK) , Layer 3 (Dvorak + upsidedown TK)
Title: Re: TMK keyboard firmware
Post by: axtran on Wed, 09 March 2016, 11:02:31

So I had an idea today. I use TMK's layer switching all the time. But I think it would be really cool if layouts could be broken out into "zones." I'll give an example below.

So I ordered a Monarch from the group buy last fall. If you're not familiar with the Monarch, it's basically a 60% with a number pad on the left. Like this:

Show Image
(http://i.imgur.com/XoHzCTl.png)


It would be cool to be able to switch the layout of the 60% section, without changing the layout of the numpad section. Then I could configure that bank of numpad keys for different tasks, such as gaming, CAD, or number entry, meanwhile switching alpha layouts between QWERTY and Dvorak without the two affecting one another.

I know this is something that TMK can't do, but I'm wondering if it would be possible to do add support for this. I'm not asking if it's likely, because I know it's an obscure use case, but is it technically possible to do this?

I envision the keymap file could define the zones as arrays of keys that belong to each group, like so:

Code: [Select]
zones = {
    /* numpad zone */
    [0] = [0, 1, 2, 3,
           18,19,20,21,
           36,37,38,39,
           54,55,56,57,
           70,71],
    /* everything else */
    [1] = [4, 5, 6, 7, 8, 9, 10,11,12,13,14,15,16,17,
           22,23,24,25,26,27,28,29,30,31,32,33,34,35,
           40,41,42,43,44,45,46,47,48,49,50,51,52,53,
           58,59,60,61,62,63,64,65,66,67,68,69,
           72,73,74,75,76,77,78]
}

Then you would need to define the keymaps for those zones, which you could do pretty much the same way as it's done now.

But then the important final step would be to take the two zone arrays and concatenate them into the currently-active keymap. This seems like it should work; you just have to keep track of which layer is active in each zone.

The only thing I'm not sure about, is whether there is enough memory to do all of this extra work.

Any thoughts?

Isn't that possible now?  You can use the toggle layer buttons to change the alpha section of the board, but leave the TK as transparent"  If you are talking about mixing and matching, you could just use a lot of layers. e.g. Layer 0 (default), Layer 1 (Dvorak Alpha), Layer 2 (upsidedown TK) , Layer 3 (Dvorak + upsidedown TK)

Yeah--you could just copy the keymap_poker.c approach (in the GH60 config). Overlay the keys you want and not others-- the array can also be viewed (reorganized) in different ways if you'd like to make it look like an unlock block.
Title: Re: TMK keyboard firmware
Post by: axtran on Wed, 09 March 2016, 11:02:50
Ugh "numlock block"
Title: Re: TMK keyboard firmware
Post by: njbair on Wed, 09 March 2016, 11:12:09
So I had an idea today. I use TMK's layer switching all the time. But I think it would be really cool if layouts could be broken out into "zones." I'll give an example below.

So I ordered a Monarch from the group buy last fall. If you're not familiar with the Monarch, it's basically a 60% with a number pad on the left. Like this:

Show Image
(http://i.imgur.com/XoHzCTl.png)


It would be cool to be able to switch the layout of the 60% section, without changing the layout of the numpad section. Then I could configure that bank of numpad keys for different tasks, such as gaming, CAD, or number entry, meanwhile switching alpha layouts between QWERTY and Dvorak without the two affecting one another.

I know this is something that TMK can't do, but I'm wondering if it would be possible to do add support for this. I'm not asking if it's likely, because I know it's an obscure use case, but is it technically possible to do this?

I envision the keymap file could define the zones as arrays of keys that belong to each group, like so:

Code: [Select]
zones = {
    /* numpad zone */
    [0] = [0, 1, 2, 3,
           18,19,20,21,
           36,37,38,39,
           54,55,56,57,
           70,71],
    /* everything else */
    [1] = [4, 5, 6, 7, 8, 9, 10,11,12,13,14,15,16,17,
           22,23,24,25,26,27,28,29,30,31,32,33,34,35,
           40,41,42,43,44,45,46,47,48,49,50,51,52,53,
           58,59,60,61,62,63,64,65,66,67,68,69,
           72,73,74,75,76,77,78]
}

Then you would need to define the keymaps for those zones, which you could do pretty much the same way as it's done now.

But then the important final step would be to take the two zone arrays and concatenate them into the currently-active keymap. This seems like it should work; you just have to keep track of which layer is active in each zone.

The only thing I'm not sure about, is whether there is enough memory to do all of this extra work.

Any thoughts?

Isn't that possible now?  You can use the toggle layer buttons to change the alpha section of the board, but leave the TK as transparent"  If you are talking about mixing and matching, you could just use a lot of layers. e.g. Layer 0 (default), Layer 1 (Dvorak Alpha), Layer 2 (upsidedown TK) , Layer 3 (Dvorak + upsidedown TK)

This won't work as you start adding more layers, because of the way layer stacking works.

Say you set up your layers like this (pseudo-code):

Code: [Select]
[0] = qwerty w/ numpad,
[1] = dvorak w/ numpad,
[3] = numpad gaming overlay (transparent alpha cluster),
[4] = numpad CAD overlay (transparent alpha cluster)

According to the docs (https://github.com/tmk/tmk_keyboard/blob/master/tmk_core/doc/keymap.md#02-layer-precedence-and-transparency), the firmware starts on your current layer, then keeps searching down the layer stack until it finds the first layer with something other than KC_TRANS, which in this case would be the Dvorak layer. Which means it's impossible to use the numpad overlay layers with QWERTY.

Unless, of course, you just make a layer for every conceivable combination, but that becomes unmanageable very quickly. There is also a 32-layer limit, which seems like a lot until you realize that 3 numpad layers and 3 alpha layers yields a total of 33 = 27 layers.

That's why it would be necessary to be able to combine them programmatically at runtime.
Title: Re: TMK keyboard firmware
Post by: BlueNalgene on Wed, 09 March 2016, 12:24:01
More
So I had an idea today. I use TMK's layer switching all the time. But I think it would be really cool if layouts could be broken out into "zones." I'll give an example below.

So I ordered a Monarch from the group buy last fall. If you're not familiar with the Monarch, it's basically a 60% with a number pad on the left. Like this:

Show Image
(http://i.imgur.com/XoHzCTl.png)


It would be cool to be able to switch the layout of the 60% section, without changing the layout of the numpad section. Then I could configure that bank of numpad keys for different tasks, such as gaming, CAD, or number entry, meanwhile switching alpha layouts between QWERTY and Dvorak without the two affecting one another.

I know this is something that TMK can't do, but I'm wondering if it would be possible to do add support for this. I'm not asking if it's likely, because I know it's an obscure use case, but is it technically possible to do this?

I envision the keymap file could define the zones as arrays of keys that belong to each group, like so:

Code: [Select]
zones = {
    /* numpad zone */
    [0] = [0, 1, 2, 3,
           18,19,20,21,
           36,37,38,39,
           54,55,56,57,
           70,71],
    /* everything else */
    [1] = [4, 5, 6, 7, 8, 9, 10,11,12,13,14,15,16,17,
           22,23,24,25,26,27,28,29,30,31,32,33,34,35,
           40,41,42,43,44,45,46,47,48,49,50,51,52,53,
           58,59,60,61,62,63,64,65,66,67,68,69,
           72,73,74,75,76,77,78]
}

Then you would need to define the keymaps for those zones, which you could do pretty much the same way as it's done now.

But then the important final step would be to take the two zone arrays and concatenate them into the currently-active keymap. This seems like it should work; you just have to keep track of which layer is active in each zone.

The only thing I'm not sure about, is whether there is enough memory to do all of this extra work.

Any thoughts?

Isn't that possible now?  You can use the toggle layer buttons to change the alpha section of the board, but leave the TK as transparent"  If you are talking about mixing and matching, you could just use a lot of layers. e.g. Layer 0 (default), Layer 1 (Dvorak Alpha), Layer 2 (upsidedown TK) , Layer 3 (Dvorak + upsidedown TK)

This won't work as you start adding more layers, because of the way layer stacking works.

Say you set up your layers like this (pseudo-code):

Code: [Select]
[0] = qwerty w/ numpad,
[1] = dvorak w/ numpad,
[3] = numpad gaming overlay (transparent alpha cluster),
[4] = numpad CAD overlay (transparent alpha cluster)

According to the docs (https://github.com/tmk/tmk_keyboard/blob/master/tmk_core/doc/keymap.md#02-layer-precedence-and-transparency), the firmware starts on your current layer, then keeps searching down the layer stack until it finds the first layer with something other than KC_TRANS, which in this case would be the Dvorak layer. Which means it's impossible to use the numpad overlay layers with QWERTY.

Unless, of course, you just make a layer for every conceivable combination, but that becomes unmanageable very quickly. There is also a 32-layer limit, which seems like a lot until you realize that 3 numpad layers and 3 alpha layers yields a total of 33 = 27 layers.

That's why it would be necessary to be able to combine them programmatically at runtime.

I see what you are saying.  I was recommending doing a layer for each combination (which might be less than you expect), but that may not be appropriate for what you want.  If you were to program a new layer class, you could have a separate switch toggle between QWERTY and DVORAK and just have a bunch of normal layer toggles for the numpad and anything else.  My pseudocode thinking is:

Code: [Select]
//layouttoggle
if switch.state = 1
    assign [q]->[']
    [w]->[,]
    etc.
else return default layout

//normal layers
[3] = numpad gaming overlay (transparent alpha cluster),
[4] = numpad CAD overlay (transparent alpha cluster)

By taking whatever matrix location is [q] and telling the firmware to now treat that as ['] you could possibly do this without creating a class that separates the board into fragments.  This is a more rudimentary approach to solving the problem, but it might be easier to implement. 
Title: Re: TMK keyboard firmware
Post by: njbair on Wed, 09 March 2016, 12:42:34
More
So I had an idea today. I use TMK's layer switching all the time. But I think it would be really cool if layouts could be broken out into "zones." I'll give an example below.

So I ordered a Monarch from the group buy last fall. If you're not familiar with the Monarch, it's basically a 60% with a number pad on the left. Like this:

Show Image
(http://i.imgur.com/XoHzCTl.png)


It would be cool to be able to switch the layout of the 60% section, without changing the layout of the numpad section. Then I could configure that bank of numpad keys for different tasks, such as gaming, CAD, or number entry, meanwhile switching alpha layouts between QWERTY and Dvorak without the two affecting one another.

I know this is something that TMK can't do, but I'm wondering if it would be possible to do add support for this. I'm not asking if it's likely, because I know it's an obscure use case, but is it technically possible to do this?

I envision the keymap file could define the zones as arrays of keys that belong to each group, like so:

Code: [Select]
zones = {
    /* numpad zone */
    [0] = [0, 1, 2, 3,
           18,19,20,21,
           36,37,38,39,
           54,55,56,57,
           70,71],
    /* everything else */
    [1] = [4, 5, 6, 7, 8, 9, 10,11,12,13,14,15,16,17,
           22,23,24,25,26,27,28,29,30,31,32,33,34,35,
           40,41,42,43,44,45,46,47,48,49,50,51,52,53,
           58,59,60,61,62,63,64,65,66,67,68,69,
           72,73,74,75,76,77,78]
}

Then you would need to define the keymaps for those zones, which you could do pretty much the same way as it's done now.

But then the important final step would be to take the two zone arrays and concatenate them into the currently-active keymap. This seems like it should work; you just have to keep track of which layer is active in each zone.

The only thing I'm not sure about, is whether there is enough memory to do all of this extra work.

Any thoughts?

Isn't that possible now?  You can use the toggle layer buttons to change the alpha section of the board, but leave the TK as transparent"  If you are talking about mixing and matching, you could just use a lot of layers. e.g. Layer 0 (default), Layer 1 (Dvorak Alpha), Layer 2 (upsidedown TK) , Layer 3 (Dvorak + upsidedown TK)

This won't work as you start adding more layers, because of the way layer stacking works.

Say you set up your layers like this (pseudo-code):

Code: [Select]
[0] = qwerty w/ numpad,
[1] = dvorak w/ numpad,
[3] = numpad gaming overlay (transparent alpha cluster),
[4] = numpad CAD overlay (transparent alpha cluster)

According to the docs (https://github.com/tmk/tmk_keyboard/blob/master/tmk_core/doc/keymap.md#02-layer-precedence-and-transparency), the firmware starts on your current layer, then keeps searching down the layer stack until it finds the first layer with something other than KC_TRANS, which in this case would be the Dvorak layer. Which means it's impossible to use the numpad overlay layers with QWERTY.

Unless, of course, you just make a layer for every conceivable combination, but that becomes unmanageable very quickly. There is also a 32-layer limit, which seems like a lot until you realize that 3 numpad layers and 3 alpha layers yields a total of 33 = 27 layers.

That's why it would be necessary to be able to combine them programmatically at runtime.

I see what you are saying.  I was recommending doing a layer for each combination (which might be less than you expect), but that may not be appropriate for what you want.  If you were to program a new layer class, you could have a separate switch toggle between QWERTY and DVORAK and just have a bunch of normal layer toggles for the numpad and anything else.  My pseudocode thinking is:

Code: [Select]
//layouttoggle
if switch.state = 1
    assign [q]->[']
    [w]->[,]
    etc.
else return default layout

//normal layers
[3] = numpad gaming overlay (transparent alpha cluster),
[4] = numpad CAD overlay (transparent alpha cluster)

By taking whatever matrix location is [q] and telling the firmware to now treat that as ['] you could possibly do this without creating a class that separates the board into fragments.  This is a more rudimentary approach to solving the problem, but it might be easier to implement.

Your approach could work, and I've actually thought about that before, implementing a function in TMK that can create alternate layouts (Dvorak, Colemak, Workman, etc.) simply by juxtaposing their indexed positions. It would be extensible for other layouts just by creating new mappings, like so:

Code: [Select]
# QWERTY to Dvorak
q2d = [
  [A, A],
  [S, O],
  [D, E],
  [F, U],
  ...

This would be easier to maintain when changing layouts, because you really only have to create the QWERTY mapping and then just run the subsequent alternate layouts through the conversion process. You might even be able to do this with the macro preprocessor, although I'm admittedly inexperienced with C code.

For my Monarch idea, though, I am trying to think beyond this particular use case and to hopefully create an extensible system for multiple layout zones.
Title: Re: TMK keyboard firmware
Post by: e_l_tang on Wed, 09 March 2016, 19:14:47
njbair, I believe that BlueNalgene's original answer to your question is correct. If I'm not mistaken, if the keyboard spots a "TRNS" code on a layer, it will look down to the highest active layer with a keycode in that position that is not "TRNS".
Title: Re: TMK keyboard firmware
Post by: hasu on Wed, 09 March 2016, 22:33:40
It seems like those keys spit scan code "80 xx" for press and "80 F0 xx" for release. Prefix code "80" is not known in general, probably specific to your keyboard. TMK PS/2 converter doesn't support it and I think Soarer's also not, they will just ignore "80".

To support those scan codes you have to fix ps2_usb/matrix.c to handle "80" prefix.

Thank you for the answer - I don't know C but I did gave it a try:
https://github.com/bergstar/tmk_keyboard/commit/f170fd174a4a2d523d8c8cc62337cf05a869a7dc

Will this be sufficient?

It is not perfect but it may work.
You can handle 80-prefix codes as psuedo E0-prefix ones, though some of 80-prefix codes may crash with E0-prefix ones. But I think you can tolerable that, for example, ord(80 3A) key interferes 'WWW HOME' key(E0 3A) and etc.

See this for E0-prefix codes in Code Set 2(PS/2 scan codes).
http://www.computer-engineering.org/ps2keyboard/scancodes2.html


You can map the ord '80 3A' key with name 'KBA'(BA=80|3A) in keymap. You will need to change keymap macro for the other 80-prefix keys.
https://github.com/bergstar/tmk_keyboard/blob/f170fd174a4a2d523d8c8cc62337cf05a869a7dc/converter/ps2_usb/keymap_common.h#L36-L87
Title: Re: TMK keyboard firmware
Post by: Koren on Thu, 10 March 2016, 07:52:10
This won't work as you start adding more layers, because of the way layer stacking works.

Say you set up your layers like this (pseudo-code):

Code: [Select]
[0] = qwerty w/ numpad,
[1] = dvorak w/ numpad,
[3] = numpad gaming overlay (transparent alpha cluster),
[4] = numpad CAD overlay (transparent alpha cluster)

According to the docs (https://github.com/tmk/tmk_keyboard/blob/master/tmk_core/doc/keymap.md#02-layer-precedence-and-transparency), the firmware starts on your current layer, then keeps searching down the layer stack until it finds the first layer with something other than KC_TRANS, which in this case would be the Dvorak layer. Which means it's impossible to use the numpad overlay layers with QWERTY.
I may have misunderstood what you're after, but I think there's a slight error in the way layers works.

It starts with the higher active layer and go through lower *active* layers till it find a non-TRNS key.

If you have 0 and 3 as active, you'll get gaming keypad with qwerty alpha...

Unless, of course, you just make a layer for every conceivable combination, but that becomes unmanageable very quickly. There is also a 32-layer limit, which seems like a lot until you realize that 3 numpad layers and 3 alpha layers yields a total of 33 = 27 layers.
It's definitively not a lot, I'm using 31, and that's with a lot of tricks to avoid multiplying layers. And I still can't do what I want. But that's because I want strange things ^_^

I'm running out of macros, too, but since I'm also at 99% memory usage...

That's why it would be necessary to be able to combine them programmatically at runtime.
Working on it for at least a different reasons (I want the keyboard layout and layout output both switchable... so that I can, for example, tell my keyboard that the computer wants QWERTY, or AZERTY, and translate its layout into the one the computer wants)
Title: Re: TMK keyboard firmware
Post by: njbair on Thu, 10 March 2016, 08:46:33
This won't work as you start adding more layers, because of the way layer stacking works.

Say you set up your layers like this (pseudo-code):

Code: [Select]
[0] = qwerty w/ numpad,
[1] = dvorak w/ numpad,
[3] = numpad gaming overlay (transparent alpha cluster),
[4] = numpad CAD overlay (transparent alpha cluster)

According to the docs (https://github.com/tmk/tmk_keyboard/blob/master/tmk_core/doc/keymap.md#02-layer-precedence-and-transparency), the firmware starts on your current layer, then keeps searching down the layer stack until it finds the first layer with something other than KC_TRANS, which in this case would be the Dvorak layer. Which means it's impossible to use the numpad overlay layers with QWERTY.
I may have misunderstood what you're after, but I think there's a slight error in the way layers works.

It starts with the higher active layer and go through lower *active* layers till it find a non-TRNS key.

If you have 0 and 3 as active, you'll get gaming keypad with qwerty alpha...

Unless, of course, you just make a layer for every conceivable combination, but that becomes unmanageable very quickly. There is also a 32-layer limit, which seems like a lot until you realize that 3 numpad layers and 3 alpha layers yields a total of 33 = 27 layers.
It's definitively not a lot, I'm using 31, and that's with a lot of tricks to avoid multiplying layers. And I still can't do what I want. But that's because I want strange things ^_^

I'm running out of macros, too, but since I'm also at 99% memory usage...

That's why it would be necessary to be able to combine them programmatically at runtime.
Working on it for at least a different reasons (I want the keyboard layout and layout output both switchable... so that I can, for example, tell my keyboard that the computer wants QWERTY, or AZERTY, and translate its layout into the one the computer wants)
Are you sure this is the case? AFAIK there is only one active layer at a time. And if not, how do you select multiple layers for activation?

So if I'm understanding you correctly, you want to take a computer that's set up for AZERTY at the software level, and send it the necessary hardware codes while the keyboard is configured for QWERTY? That is definitely an obscure use case, but one I'm familiar with. I'm fact, I can instantly recognize "bhxacp" when I try to type "njbair" means I've got a double-Dvorak condition, just like I recognize "lcnago" means I'm in QWERTY when I should be in Dvorak.
Title: Re: TMK keyboard firmware
Post by: e_l_tang on Thu, 10 March 2016, 12:09:11
njbair, the state of every layer is independently stored as a bit. You are correct that there can be only one working layer, which is the highest layer that's active at a given time. You can use the functions below to activate and deactivate layers independently. 
Code: [Select]
layer_on(/*layer*/);
layer_off(/*layer*/);
Title: Re: TMK keyboard firmware
Post by: Koren on Thu, 10 March 2016, 18:05:53
Are you sure this is the case? AFAIK there is only one active layer at a time. And if not, how do you select multiple layers for activation?
Totally sure, I'm using it (a lot). Unless it's a fork difference, but I doubt it.

Each layer can be on or off independantly, and there's 32 layers because the state of each layer is store as a bit in a 32 bits word.

You can set / unset layers under the current active one without any issue with the normal way, btw.

So if I'm understanding you correctly, you want to take a computer that's set up for AZERTY at the software level, and send it the necessary hardware codes while the keyboard is configured for QWERTY?
Not exactly...


Imagine that I want a Dvorak on my keyboard, where the first character of the home row is A.

When I press the key, I want a A, obviously.

Now, if the computer driver believe the keyboard is a qwerty one, I need to send "2nd key, home row". If the computer believe the keyboard is an azerty one, I need to send "2nd key, upper row".

I want to be able to change this on the fly, having the same layout on the keyboard even if the layout defined in the computer change.


Another way to look at it, if you look at the TMK source code, you don't put a "Q" on your layout, but "KEY_Q", which is a macro that send "the key where there is a Q on a QWERTY keyboard". If you have another layout defined in the computer, you have to import a different definition file.

TMK translate

key  ---(layout)-->  scancode

I want

key  ---(layout)-->  character   ---(translation table)-->  scancode

where the translation table is also switchable on-the-fly.


Could be done by defining the 32 layers for each possible layout the computer may want (AZERTY, QWERTY, etc.), but I'm far from having enough memory for this...

All this come from the fact that keyboard still use scancodes to communicate with the computer instead of unicode points, which is just awfully crude...
Title: Re: TMK keyboard firmware
Post by: e_l_tang on Thu, 10 March 2016, 19:02:23
Does anyone know how I can make my keyboard momentarily cut off its data connection to my computer?
Title: Re: TMK keyboard firmware
Post by: vvp on Fri, 11 March 2016, 04:24:25
If the firmware does not support firmware reboot (in my fw it is Prg-B) then design your hardware so that you can hardware reset the keyboard.
Title: Re: TMK keyboard firmware
Post by: njbair on Fri, 11 March 2016, 09:32:00
I have a question about something I read in the docs:

Quote
Keymap layer '0' is usually default_layer and which is the only valid layer and other layers is initially off after boot up firmware, though, you can configured them in config.h.

So it says you can initialize other layers to be on by default in config.h, but I don't see any examples of this, or any documentation on which flags to set.

So how do I initialize Layer 31 to be on by default?
Title: Re: TMK keyboard firmware
Post by: nephiel on Fri, 11 March 2016, 13:38:14
Are you sure this is the case? AFAIK there is only one active layer at a time. And if not, how do you select multiple layers for activation?
Totally sure, I'm using it (a lot). Unless it's a fork difference, but I doubt it.

Each layer can be on or off independantly, and there's 32 layers because the state of each layer is store as a bit in a 32 bits word.

You can set / unset layers under the current active one without any issue with the normal way, btw.

So if I'm understanding you correctly, you want to take a computer that's set up for AZERTY at the software level, and send it the necessary hardware codes while the keyboard is configured for QWERTY?
Not exactly...


Imagine that I want a Dvorak on my keyboard, where the first character of the home row is A.

When I press the key, I want a A, obviously.

Now, if the computer driver believe the keyboard is a qwerty one, I need to send "2nd key, home row". If the computer believe the keyboard is an azerty one, I need to send "2nd key, upper row".

I want to be able to change this on the fly, having the same layout on the keyboard even if the layout defined in the computer change.


Another way to look at it, if you look at the TMK source code, you don't put a "Q" on your layout, but "KEY_Q", which is a macro that send "the key where there is a Q on a QWERTY keyboard". If you have another layout defined in the computer, you have to import a different definition file.

TMK translate

key  ---(layout)-->  scancode

I want

key  ---(layout)-->  character   ---(translation table)-->  scancode

where the translation table is also switchable on-the-fly.


Could be done by defining the 32 layers for each possible layout the computer may want (AZERTY, QWERTY, etc.), but I'm far from having enough memory for this...

All this come from the fact that keyboard still use scancodes to communicate with the computer instead of unicode points, which is just awfully crude...
I attempted to do this, because my board layout is Spanish but sometimes I use it on machines that expect an English layout. I tried to make a layer that I could toggle in that case, but ditched the idea because Spanish has 4 symbols per key (no mods, Shift, AltGr and Shift+AltGr) and not all of them are in the same key on English, so I'd have to check for 2 mods on each key before deciding what key to map to.
Title: Re: TMK keyboard firmware
Post by: Koren on Fri, 11 March 2016, 14:52:39
I attempted to do this, because my board layout is Spanish but sometimes I use it on machines that expect an English layout. I tried to make a layer that I could toggle in that case, but ditched the idea because Spanish has 4 symbols per key (no mods, Shift, AltGr and Shift+AltGr) and not all of them are in the same key on English, so I'd have to check for 2 mods on each key before deciding what key to map to.
Yes, it's difficult to do perfectly with 32 layers... That's the reason I want a double translation (also, it would be easier to define)

My current dox layout has 7 symbols per key (not counting arrows, Fn, media, mouse, japanese and shortcuts layers), and indeed it's a nightmare to map because symbols are not on the same keys/modifiers. Even worse, I still want shift to work like a normal shift key (plently of programs use shift) but shift should also work as a layer switcher for *some* layers (which isn't an issue) but sometimes (often) on the "shifted" layer I have symbols that require a non-shifted scancode, so I have to create a macro that un-shift just the time to send the scancode.

It fully works with computer set on my azerty variant, and I have a fallback on plain azerty and on plain qwerty, but it's really basic. But the worst part is that it's insanely time consuming to setup :/
Title: Re: TMK keyboard firmware
Post by: e_l_tang on Fri, 11 March 2016, 15:16:12
Koren, I am going to send a pull request to the QMK repository in a few weeks that will make creating keymaps like yours a lot easier. Do you want me to notify you when I do?
Title: Re: TMK keyboard firmware
Post by: Koren on Sat, 12 March 2016, 06:08:49
Koren, I am going to send a pull request to the QMK repository in a few weeks that will make creating keymaps like yours a lot easier. Do you want me to notify you when I do?
I'm checking from time to time the repo, because I'm interested in how people tackle the problems even if I intend to develop my own solution (probably this summer). If you have tome to send me a notification, that would be nice, indeed, but if you forget, that's not a big deal, I'll see it anyway.
Title: Re: TMK keyboard firmware
Post by: njbair on Sat, 12 March 2016, 10:05:11
According to the docs, keymap_call_function is called every time a key event is triggered. Is it possible to use this to detect which key is pressed and override the output with a different key code? This way you could translate QWERTY to Dvorak, for example, without having to hard-code the keymaps.

Or maybe there's a different function which would be better suited for this purpose?
Title: Re: TMK keyboard firmware
Post by: axtran on Sat, 12 March 2016, 22:49:55
Just finished adding LEDs to my GH60 Rev. C -- now playing off of the Caps Lock configuration in led.c (GH60 config folder) everything works as intended. I tried adding a layer config notification LED and it bombs out and sends the keyboard into just typing junk all over the place... anyone else experience this issue on GH60 Rev. C?
Title: Re: TMK keyboard firmware
Post by: e_l_tang on Sat, 12 March 2016, 22:50:45
njbair, why don't you just have separate layers for QWERTY and Dvorak?
Title: Re: TMK keyboard firmware
Post by: njbair on Sat, 12 March 2016, 23:50:58
njbair, why don't you just have separate layers for QWERTY and Dvorak?

Right now I do. But I have a bunch of keyboards running TMK and it gets tedious to recreate several different keymap definitions for each one (QWERTY, Dvorak, Colemak). Since QWERTY S is always Dvorak O and Colemak R, regardless of the board layout, I don't see why this step can't be automated. This could even be built into the magic commands and free up the function keys for other things. Just an idea.
Title: Re: TMK keyboard firmware
Post by: njbair on Fri, 25 March 2016, 21:26:33
I just discovered the existence of the Teensy-LC (https://www.pjrc.com/store/teensylc.html), made by PJRC who also make the original Teensy 2.0. Here are the specs:

Would the ChibiOS build work with the Cortex M0+? The really cool part is that the whole board is only $12.
Title: Re: TMK keyboard firmware
Post by: flabbergast on Sat, 26 March 2016, 01:37:52
Would the ChibiOS build work with the Cortex M0+? The really cool part is that the whole board is only $12.
Yes. (The "Cortex Mn" does not actually mean that much in this context, it's about whether ChibiOS supports the particular chip that's on the LC (MKL27Z64), and with my patches in does.)
Title: Re: TMK keyboard firmware
Post by: njbair on Sat, 26 March 2016, 07:24:03
Would the ChibiOS build work with the Cortex M0+? The really cool part is that the whole board is only $12.
Yes. (The "Cortex Mn" does not actually mean that much in this context, it's about whether ChibiOS supports the particular chip that's on the LC (MKL27Z64), and with my patches in does.)
You know, only after asking this did I think to check the code just now, and there it is right in your Makefile. What about RAM? 8K doesn't sound like much but I know keymaps and such are stored in flash using PROGMEM.

Speaking of which, I thought things like PROGMEM and uint8_t were specific to avr-gcc. But an ARM firmware doesn't use avr-gcc, does it?
Title: Re: TMK keyboard firmware
Post by: flabbergast on Sat, 26 March 2016, 08:45:52
RAM: Just for comparison, atmega32u4 has 2.5kB RAM, atmega32u2 (on alps64) has 1kB RAM. 8kB is not too much, but certainly enough. ChibiOS kernel takes about 1-1.5kB in normal configuration (i.e. no debug options enabled {EDIT: by this I mean internal ChibiOS debug, not the TMK DEBUG.}, but also not trying to go absolutely minimal). The TMK onekey example on LC (everything enabled) uses about 3kB of LC's RAM.

PROGMEM: This is AVR specific. On ARMs, it's enough to declare a variable 'const' and it goes automatically into the flash space and doesn't occupy RAM. (That's one of the advantages of having a single address space.)

uint8_t: I think this is a generic gcc thing (I'm 100% sure it's at least a generic embedded GCC thing).
Title: Re: TMK keyboard firmware
Post by: rsac on Sat, 26 March 2016, 17:54:54
uint8_t: I think this is a generic gcc thing (I'm 100% sure it's at least a generic embedded GCC thing).
It is a C99 (and C++11) thing: https://en.wikipedia.org/wiki/C_data_types#Fixed-width_integer_types
Title: Re: TMK keyboard firmware
Post by: rsac on Sat, 26 March 2016, 18:23:40
I just discovered the existence of the Teensy-LC (https://www.pjrc.com/store/teensylc.html), made by PJRC who also make the original Teensy 2.0.

Would the ChibiOS build work with the Cortex M0+? The really cool part is that the whole board is only $12.
There is also the Mapple Mini (http://letsmakerobots.com/node/43457) that you can find clones (made by baite, for example) for less than $5 shipped, from China. The only downside is that it is much longer than a Teensy. For you it might not be better, but for people from outside USA it means not dealing with the high USA international shipping and export restrictions on teensy LC.

Oh, it also don't have an EEPROM. @flabbergast: the teensy LC also has only a few bytes of (emulated) EEPROM. Is this a problem? How easy it is to use an external EEPROM chip with TMK? I'm also curious on how much bigger or smaller (in flash size) is TMK when compiled for ARM Cortex M vs AVR 8bit.
Title: Re: TMK keyboard firmware
Post by: flabbergast on Sun, 27 March 2016, 01:41:59
Oh, it also don't have an EEPROM. @flabbergast: the teensy LC also has only a few bytes of (emulated) EEPROM. Is this a problem? How easy it is to use an external EEPROM chip with TMK? I'm also curious on how much bigger or smaller (in flash size) is TMK when compiled for ARM Cortex M vs AVR 8bit.
Depends on your programming experience. You just need to replace 'eeprom_read_byte' and 'eeprom_write_byte' functions.
The standard TMK only uses 7 bytes of EEPROM. (I intend to do EEPROM emulation a-la LC also for EEPROM-less STM32s. There is  an example code from ST that does this, so it is definitely doable.)

Firmware size - it depends a lot more on the particular features that you enable/disable then on the architecture. Of course if you use ChibiOS backend, then the binary is somewhat (2-6kB) bigger than bare metal. The fact that ARMs are 32bit tends to increase the memory consumption slightly (alignment requirements), but again, the actual chip hardware has much more influence on this as well (e.g. the size and number of USB buffers, etc).
Title: Re: TMK keyboard firmware
Post by: rsac on Mon, 28 March 2016, 18:33:18
Quote
Depends on your programming experience. You just need to replace 'eeprom_read_byte' and 'eeprom_write_byte' functions.
Ok, it seems that the hardest part would be interfacing with the external EEPROM. I have no experience with those hardware things. I will probably avoid that part though. I'm going to experiment with a micro-sd reader anyway. I want to log key press statistics, including digraphs, trigraphs, etc, and latter try to implement programmable macros. Given that, I can make those functions write to a Fat32 file. If you isn't faster. You will implement this (http://www.st.com/st-web-ui/static/active/en/resource/technical/document/application_note/DM00036065.pdf)?

As for the firmware size between architectures, of course the comparison should be with between equivalent tmk features (say, all of them).
Title: Re: TMK keyboard firmware
Post by: flabbergast on Mon, 28 March 2016, 18:52:08
Having done both, I find interfacing with EEPROMs way easier that interfacing with (micro)SD cards. For EEPROMs it's basically enough to read its datasheet and use SPI or I2C; with microSD it's SPI but the point is that the protocol is quite a bit more complicated. Also this gives you raw blocks (like doing 'dd' in linux). You'll then need to do a FAT read/write layer.
However there are libraries for everything, so it's not very hard, it's just that you'll need to plug several of them together.

About the EEPROM emulation - yes, I mean to implement that (I mean the application note you linked) but start with STM32F0, because I have no F4s :) That will be good enough for the cca 10 bytes of EEPROM that TMK uses; however I would not recommend logging into flash with this, because of the limited number of flash erase operations (I think it's generally around 10000 guaranteed). You can maybe get away with this if you use a MCU with a very large flash (like 512kB or such) and use a lot of flash for wear levelling (almost all of it), and be smart about writing to it.

Firmware size: As a rule of thumb, I would expect the firmwares using the ChibiOS backend to be more-less 5kB bigger than the bare metal AVR ones (so e.g. 20kB vs 25kB). But in the memory consumption there is a "bigger" difference, maybe 3kB more (but this time it's 1kB vs 4kB).
Title: Re: TMK keyboard firmware
Post by: e_l_tang on Tue, 29 March 2016, 18:34:54
What exactly does ChibiOS do? Does it act as a "translator" between TMK and ARM chips?
Title: Re: TMK keyboard firmware
Post by: flabbergast on Tue, 29 March 2016, 19:52:02
I started writing some notes about this. Not really finished in any way, but they hopefully contain an answer to this question:
text file (https://gist.githubusercontent.com/anonymous/c3a8006d90970da3454e6483f47b9d2d/raw/e411b9bd4464cd15ab3715f1fa3ba5038525744b/TMK.txt)
Title: Re: TMK keyboard firmware
Post by: Moistgun on Tue, 29 March 2016, 20:36:41
Hi, Im trying to create a hex file to program my hand wire project.
Im following Matt30's guide but I cant get the thing to compile

would someone be willing to try to compile this for me?
its just the GH60 folder.
I think thats all that is needed right?

https://www.dropbox.com/s/zps95d2kr3f9lif/gh60.zip?dl=0


the error im getting can be seen on this thread.
https://geekhack.org/index.php?topic=80853.msg2119862#msg2119862
Title: Re: TMK keyboard firmware
Post by: flabbergast on Tue, 29 March 2016, 20:50:46
It's this: https://github.com/tmk/tmk_keyboard/issues/99
{It comes up every few weeks. Try to get rid of as much of winavr from your computer as you can; or else you can get weird errors from basic tools (make, grep) even when you'll be using a completely different toolchain.}
Title: Re: TMK keyboard firmware
Post by: Moistgun on Tue, 29 March 2016, 21:31:33
I tried it in linux to compile but I ended up with something else that I don't understand

In file included from keymap_poker.c:1:0:
keymap_common.h:46:1: error: parameter name missing
 ) { \
 ^

also at the bottom
make: *** [obj_gh60_lufa/keymap_poker.o] Error 1



in my keymap_common.h it shows

K40, K41,      K43,                K47,                K4B, K4C, K4D, \
) { \
Title: Re: TMK keyboard firmware
Post by: e_l_tang on Tue, 29 March 2016, 21:45:16
Your first KEYMAP macro needs a closing parenthesis like that of your second one.
Title: Re: TMK keyboard firmware
Post by: Moistgun on Tue, 29 March 2016, 21:47:41
Your first KEYMAP macro needs a closing parenthesis like that of your second one.

My first set starts with (  and ends with )
how am i doing it wrong?
Title: Re: TMK keyboard firmware
Post by: Moistgun on Tue, 29 March 2016, 21:59:02
My error code said it needed a parenthesis, but the true error was a trailing comma after the last key in the keymap
K40, K41,      K43,                K47,                K4B, K4C, K4D, \
) { \
Title: Re: TMK keyboard firmware
Post by: e_l_tang on Wed, 30 March 2016, 00:03:54
You're correct about that extra comma in keymap_common.h, but I don't see a closing parenthesis for the first KEYMAP macro in keymap_poker.c.
Title: Re: TMK keyboard firmware
Post by: Moistgun on Wed, 30 March 2016, 08:44:34
Oh, I see, I was only looking through the common file for errors  :-X

Thanks Eric-t Ill give it a shot tonight.
Title: Re: TMK keyboard firmware
Post by: njbair on Wed, 30 March 2016, 23:50:17
So I'm trying something a little more complicated here with a function action. So far it's working in concept, but my board goes haywire after using the feature a few times.

Basically, I'm trying to emulate the behavior of the Mac keyboard layout Dvorak - QWERTY Command, where the board uses Dvorak layout, but when you hold down the Command button, it switches the alphas to QWERTY layout, so you can still use the familiar one-handed Ctrl+C, Ctrl+V, etc., that we are all so used to. I've got it mostly working with the following code:

Code: [Select]
uint32_t default_layer_state;
uint32_t qwerty_fallback_previous_state;

void action_function(keyrecord_t *record, uint8_t id, uint8_t opt __attribute__ ((unused))) {
    switch (id) {
        case F_CTRL_QWERTY_FALLBACK:
            if (record->event.pressed) {
                qwerty_fallback_previous_state = default_layer_state;
                default_layer_set(1UL<<L_QWERTY);
                add_weak_mods(MOD_LCTL);
            } else {
                default_layer_set(1UL<<qwerty_fallback_previous_state);
                del_weak_mods(MOD_LCTL);
            }
            break;
    }
};

But after using the Ctrl key 3 times in a row, it messes up the keymap and all the keys get mixed up.

Interestingly, if I use Ctrl twice, then manually switch the default layer, I can use Ctrl again. But the moment I use it 3 times in a row without manual intervention in between, the keymap goes haywire.

Any ideas? It sounds like a memory issue but I don't know enough about C to say for sure.
Title: Re: TMK keyboard firmware
Post by: e_l_tang on Thu, 31 March 2016, 00:17:00
Why are you playing with default_layer_state? Why don't you just use ACTION_LAYER_MODS?
Title: Re: TMK keyboard firmware
Post by: rsac on Thu, 31 March 2016, 00:23:29
Having done both, I find interfacing with EEPROMs way easier that interfacing with (micro)SD cards. For EEPROMs it's basically enough to read its datasheet and use SPI or I2C; with microSD it's SPI but the point is that the protocol is quite a bit more complicated. Also this gives you raw blocks (like doing 'dd' in linux). You'll then need to do a FAT read/write layer.
However there are libraries for everything, so it's not very hard, it's just that you'll need to plug several of them together.

About the EEPROM emulation - yes, I mean to implement that (I mean the application note you linked) but start with STM32F0, because I have no F4s :) That will be good enough for the cca 10 bytes of EEPROM that TMK uses; however I would not recommend logging into flash with this, because of the limited number of flash erase operations (I think it's generally around 10000 guaranteed). You can maybe get away with this if you use a MCU with a very large flash (like 512kB or such) and use a lot of flash for wear levelling (almost all of it), and be smart about writing to it.

Firmware size: As a rule of thumb, I would expect the firmwares using the ChibiOS backend to be more-less 5kB bigger than the bare metal AVR ones (so e.g. 20kB vs 25kB). But in the memory consumption there is a "bigger" difference, maybe 3kB more (but this time it's 1kB vs 4kB).
I mean that messing with microSDs is something I wanted to do anyway, so doing the EEPROM that way is no extra work. What I'm kinda hoping is that someone has already done a nice library to abstract everything about it, like sdfatlib or SD library in arduino. I havent looked deeply yet, but here (https://github.com/ChibiOS/ChibiOS/tree/master/demos/STM32/RT-STM32F407-OLIMEX_E407-LWIP-FATFS-USB) seems to be a fat32 demo for chibios. Don't seem as friendly as Arduino's SD lib but probably workable.

As for wear levelling, I will partially trust the microSD one, but I also plan to write the updates in batches that can be summed up latter. I have plenty of space, and plenty of time when I try to read it back. As for security, I don't think it will be a problem, but I can encrypt it with my public key. Or an one time pad, if the former is too dificult/impractical.

And for the firmware size, you are saying that code compiled for ARM Cortex M will be about the exact same size than for AVR8? The only difference is the ChibiOS overhead? Besides higher memory consumption.
Title: Re: TMK keyboard firmware
Post by: flabbergast on Thu, 31 March 2016, 02:00:46
@rsac: Yes, in my experience code compiled for ARM has more-less the same size as the same code compiled for AVR. The resulting binary size depends much much more on the optimisation level enabled in GCC and also on the particular GCC release.
However this comparison is pretty much moot, because it would require completely hardware-independent code. The hardware-specific portions of the code (HAL) will make the resulting firmware size differ quite a bit even within ARM MCUs themselves (for instance the size of the USB buffers, if not dynamically allocated).
Title: Re: TMK keyboard firmware
Post by: njbair on Thu, 31 March 2016, 20:31:45
Why are you playing with default_layer_state? Why don't you just use ACTION_LAYER_MODS?

Because the QWERTY layer is at the bottom of the stack. You can't switch to a lower layer.
Title: Re: TMK keyboard firmware
Post by: e_l_tang on Thu, 31 March 2016, 20:56:24
Why not put that layer at the top of the stack?
Title: Re: TMK keyboard firmware
Post by: njbair on Thu, 31 March 2016, 21:49:26
Why not put that layer at the top of the stack?

Well, reasons. Firstly, Boot Magic reads its commands based on the layout at layer 0, which I want to be QWERTY so that I can make EEPROM changes without having to mentally translate keymaps (the keycaps are still in QWERTY layout, despite my preference for Dvorak). Secondly, that doesn't really solve the problem, just hacks around it. And I don't want to define two identical QWERTY layers because DRY.

Anyway, I managed to find my bug. When you set the default layer to, say, layer 2, you have to bit-shift that 2. I was storing the previous default_layer_state in a placeholder variable, but when I was reassigning it I was absentmindedly doing 1UL<<qwerty_fallback_previous_state, which was bit-shifting an already bit-shifted value, effectively causing the default layer to double in value each time. Mine went from 1 to 2 to 4 to 16, and since I don't have sixteen layers defined, it was pulling keycodes from somewhere outside the correct memory range. Thus, haywire layout.

So now I've got the best of both worlds for Ctrl shortcuts. If I use the HHKB Ctrl (Caps Lock position), I can use the current layout. This is how I normally type, and for the most part I'm used to cut/copy/paste/etc. on Dvorak. But for left-handed use while mousing, I can use the Ctrl in the standard bottom-left positon, which re-maps the alphas to QWERTY until I release it. It's a pretty cool setup!

Oh, and Right Ctrl is remapped to Caps Lock, so I can still use the Keyboard Lock magic command (lshift+rshift+caps). I have kids and they like to bang on keyboards. Hardware-lock is invaluable to me.
Title: Re: TMK keyboard firmware
Post by: Kalp1 on Mon, 04 April 2016, 12:02:28
Hello coders, It's been 2 days that I'm struggling with my AMJ40's firmware.

I've found a fonctional one on Github, but I want to edit the keymap. So I opened keymap_default with Mfile and changed the keymap.
Build the firmware, load it on AMJ40, but I'm back with the older keymap.

Do I need to change something else in Makefile, config.h or keymap_common.h ??

I tried removing driver, changing VID and PID, nothing worked.

Newbie there. Excuse me if this basic question have been already asked, but I've read build/keymap's core/faq and found nothing about this.

Edited keymap:
Code: [Select]
  /* Keymap 0: Default Layer
     * ,-------------------------------------------------.
     * |Esc | Q|  W|  E|  R|  T|  Y|  U|  I|  O|  P| Bs  |
     * |-------------------------------------------------|
     * |Tab  |  A|  S|  D|  F|  G|  H|  J|  K|  L|  Ent |
     * |-------------------------------------------------|
     * |Shift   |  Z|  X|  C|  V|  B|  N|  M|  /| SFT|FN0|
     * |-------------------------------------------------|
     * |Ctrl|Win |Alt |       Space            | ' |Ctrl|
     * `-------------------------------------------------'
     */
    KEYMAP(
        ESC, Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P, BSPC,\
        TAB,A,   S,   D,   F,   G,   H,   J,   K,   L,       ENT,\
        LSFT,     Z,   X,   C,   V,   B,   N,   M, SLSH,RSFT,  FN0,\
        LCTL,LGUI,LALT,          SPC,                  QUOT,RCTL),

Original:
Code: [Select]
   /* Keymap 0: Default Layer
     * ,-------------------------------------------------.
     * |Esc | Q|  W|  E|  R|  T|  Y|  U|  I|  O|  P| Bs  |
     * |-------------------------------------------------|
     * |Caps  |  A|  S|  D|  F|  G|  H|  J|  K|  L|  Ent |
     * |-------------------------------------------------|
     * |Shift   |  Z|  X|  C|  V|  B|  N|  M|  /| SFT|FN0|
     * |-------------------------------------------------|
     * |Ctrl|Win |Alt |       Space            | Alt |Ctrl|
     * `-------------------------------------------------'
     */
    KEYMAP(
        ESC, Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P, BSPC,\
        CAPS,A,   S,   D,   F,   G,   H,   J,   K,   L,       ENT,\
        LSFT,     Z,   X,   C,   V,   B,   N,   M, SLSH,RSFT,  FN0,\
        LCTL,LGUI,LALT,          SPC,                  RALT,RCTL),
Title: Re: TMK keyboard firmware
Post by: flabbergast on Mon, 04 April 2016, 12:07:28
Depends on which firmware are you actually using. Some of the forks (e.g. Kai Ryu's) actually store the keymap in EEPROM, so even if you flash a new firmware, it may still be using the keymap it finds in EEPROM. You can try using bootmagic to erase the EEPROM settings (usually holding Space+Backspace during power-up). See https://github.com/tmk/tmk_keyboard#general .
Title: Re: TMK keyboard firmware
Post by: Kalp1 on Mon, 04 April 2016, 12:52:03
Depends on which firmware are you actually using. Some of the forks (e.g. Kai Ryu's) actually store the keymap in EEPROM, so even if you flash a new firmware, it may still be using the keymap it finds in EEPROM. You can try using bootmagic to erase the EEPROM settings (usually holding Space+Backspace during power-up). See https://github.com/tmk/tmk_keyboard#general .

Thank you for your fast response, I will try it.

Edit: It worked ! But lost backlight in the process :confused:
I'll try to build another firmware or maybe try to "dump" Eeprom

I' ve also seen bugs with  key from the last alpha row that send input from bottom row, like C doing C+SPACE, B doing B+ALT ...
Title: Re: TMK keyboard firmware
Post by: Kalp1 on Tue, 05 April 2016, 13:14:12
So it' s seems that this firmware https://github.com/AMJKeyboard/AMJ40 (https://github.com/AMJKeyboard/AMJ40) doesn' t support backlight.

So I used the HEX file, that the sellor from taobao send to me, and everything worked fine again.
But I still can' t edit the layout, since I only have the hex file.

Do you think it is possible to reverse build HEX file ?

Title: Re: TMK keyboard firmware
Post by: kasakka on Wed, 06 April 2016, 08:50:26
I'm looking to make a custom 60% but I really like the "R.Alt + Spacebar = Arrow keys" toggle on my Pok3r. Is something like that possible with the TMK firmware as it's not really toggling a layer but just remapping a few buttons?

I'm going custom because Pok3r can't do numpad keys and alt keycodes and I'd like to play around with the layout a bit.
Title: Re: TMK keyboard firmware
Post by: hasu on Wed, 06 April 2016, 18:58:21
I'm looking to make a custom 60% but I really like the "R.Alt + Spacebar = Arrow keys" toggle on my Pok3r. Is something like that possible with the TMK firmware as it's not really toggling a layer but just remapping a few buttons?

I'm going custom because Pok3r can't do numpad keys and alt keycodes and I'd like to play around with the layout a bit.

I don't know how Pok3r works actually, but this keymap can emulate Poer X including arrow keys toggle.
https://github.com/tmk/tmk_keyboard/blob/master/keyboard/gh60/keymap_poker.c

As you can see it is a bit tricky or not easy.
Title: Re: TMK keyboard firmware
Post by: e_l_tang on Thu, 07 April 2016, 03:03:25
@kasakka That functionality can be very easily enabled with a macro.
Title: Re: TMK keyboard firmware
Post by: kasakka on Thu, 07 April 2016, 15:20:59
I'm looking to make a custom 60% but I really like the "R.Alt + Spacebar = Arrow keys" toggle on my Pok3r. Is something like that possible with the TMK firmware as it's not really toggling a layer but just remapping a few buttons?

I'm going custom because Pok3r can't do numpad keys and alt keycodes and I'd like to play around with the layout a bit.

I don't know how Pok3r works actually, but this keymap can emulate Poer X including arrow keys toggle.
https://github.com/tmk/tmk_keyboard/blob/master/keyboard/gh60/keymap_poker.c

As you can see it is a bit tricky or not easy.

Cool, thanks for the reply. I think what I'll end up doing is setting that section permanently as arrow keys and using a Fn button next to shift to make them do something else when needed (probably just PgUp,PgDn,Home and End).
Title: Re: TMK keyboard firmware
Post by: ProCarpet on Wed, 13 April 2016, 04:35:02
Hello there i've been working again on my keyboard recently and have made some progression. I've used matt3o's
More
https://deskthority.net/workshop-f7/how-to-build-your-very-own-keyboard-firmware-t7177.html (https://deskthority.net/workshop-f7/how-to-build-your-very-own-keyboard-firmware-t7177.html)
guid to build my firmware and to correct it(at least i thougth i had done this). But when i plug in my teensy i behaves strangely it posts a few random keys and then nothing, just to go haywaer from time to time. Once i had it pluged in on a devboard where i had waired all the cols to gnd but one and connected this to rowx with a switch and it returned w as it should whenever i pressed the button.
I've been unable to sort out the problem on why it goes haywire from time to time neither have i been able to reliably reproduce said behaiviour.
I hope someone here can help me, because im at lose.

I've pluged in the teens2.0 on such a device:
More
(http://www.distrelec.ch/Web/WebShopImages/landscape_large/_t/if/3m-csi-923253.jpg)

Here is a picture of my matrix(i know its not fully connected yet and the ressistors are unnecesary):
More
(http://i.imgur.com/WrpADJ8.png)
                                                                                       
And the code i've written:https://www.dropbox.com/s/j0iyzltbnnsyalj/gh60.rar?dl=0 (https://www.dropbox.com/s/j0iyzltbnnsyalj/gh60.rar?dl=0)

Edit: I tried running aqua key while teensy is pluged in it starts by spmaing F3,3,4,E,D and moves then to F5 and oters.  (note it didnt press the Win key that was me)
I left it pluged in for a good 10secs or so.
More
(http://i.imgur.com/v2QDcSB.png)

Edit2:In the config.h where 5 and 13 defined for the rows and cols fixed that but didn't fix my problem :/


I hope someone can help me with this  ;D
Title: Re: TMK keyboard firmware
Post by: Columnaire on Wed, 13 April 2016, 10:24:01
Hi I have a new question. I have an Ergodox EZ and I have one of the three LEDs indicate the Caps Lock function. That works fine. I would like the same light to turn on when I press the Shift key (and turn off when I release it). How do I determine whether Shift is being held down?
Title: Re: TMK keyboard firmware
Post by: e_l_tang on Wed, 13 April 2016, 11:57:26
@Columnaire You have to put #include "action_util.h" at the top of your keymap file. That will allow you to test the condition (keyboard_report->mods & (MOD_BIT(KC_LSFT) | MOD_BIT(KC_RSFT))).
Title: Re: TMK keyboard firmware
Post by: e_l_tang on Wed, 13 April 2016, 13:31:53
@ProCarpet It doesn't look like you have a column connected to E6. Also, your unselect_rows function does not look right.
Title: Re: TMK keyboard firmware
Post by: ProCarpet on Wed, 13 April 2016, 14:05:28
@ProCarpet It doesn't look like you have a column connected to E6. Also, your unselect_rows function does not look right.
Thans for your reply :D
ive removed col E6 and have switched the zeros for ones ind the unselect_rows
It now spits out diferent charakters but still doesnt work :(
updated version https://www.dropbox.com/s/7c58rq789xw0s3f/gh60_2.rar?dl=0 (https://www.dropbox.com/s/7c58rq789xw0s3f/gh60_2.rar?dl=0)
Title: Re: TMK keyboard firmware
Post by: a-c on Wed, 13 April 2016, 14:39:39
LSB is on the right. Your bits are backwards.

Code: [Select]
/* Row pin configuration
 * row: 0   1   2   3   4   5 
 * pin: B0  B1  B2  B3  D0  B7
 */
static void unselect_rows(void)
{
    // Hi-Z(DDR:0, PORT:0) to unselect
    DDRD  &= ~0b10000000;
    PORTD &= ~0b10000000;
    DDRB  &= ~0b11110001;
    PORTB &= ~0b11110001;
}
Title: Re: TMK keyboard firmware
Post by: ProCarpet on Thu, 14 April 2016, 04:39:05
Thanks alot a-c, it now does no longer spam random stuff. It also has a normal output. Just the programm doesnt corespond with the pins yet somehow ill look in to that now.
Edit: i'm an idiot and should have known better everything works just fine i tested the Y switch and in aqua key Y lighted up on row 3 but i have it on row 1 because i modified the us layout duhh.  ;D
Title: Re: TMK keyboard firmware
Post by: Columnaire on Thu, 14 April 2016, 08:30:33
(keyboard_report->mods & (MOD_BIT(KC_LSFT) | MOD_BIT(KC_RSFT))).

Thank you, Eric-T, that was exactly what I needed!
Title: Re: TMK keyboard firmware
Post by: kekman on Thu, 21 April 2016, 20:38:14
Hi, are there any resources for programming leds? by default my board has 2 backlighting options, breathing and full backlit with 3 levels of brightness. however, it's factory flashed so I'm not sure how they did it, and I'm looking at setting up some custom effects
Title: Re: TMK keyboard firmware
Post by: e_l_tang on Thu, 21 April 2016, 23:08:47
@kekman What keyboard do you have?
Title: Re: TMK keyboard firmware
Post by: kekman on Thu, 21 April 2016, 23:18:47
A GH60
Title: Re: TMK keyboard firmware
Post by: e_l_tang on Thu, 21 April 2016, 23:28:15
@kekman You're in luck. Your keyboard is one of the few keyboards directly supported by TMK. Its folder is at https://github.com/tmk/tmk_keyboard/tree/master/keyboard/gh60. What light effects do you want to program?
Title: Re: TMK keyboard firmware
Post by: kekman on Thu, 21 April 2016, 23:32:27
some of the effects on ducky shine keyboards, such as lighting keypresses, and pulse out from keypress. i have experience with programming kb with tmk before, but never tried programming leds.
Title: Re: TMK keyboard firmware
Post by: e_l_tang on Thu, 21 April 2016, 23:54:53
You're going to need individually addressable LEDs for those effects. Are you sure you have them? If your keyboard's LEDs are all at the same brightness level at a given time, you probably don't.
Title: Re: TMK keyboard firmware
Post by: kekman on Fri, 22 April 2016, 00:03:25
I doubt it. Are there any resources regarding the matter though? I want to test what I'm able to do with it and see what happens from there.
Title: Re: TMK keyboard firmware
Post by: goflo on Mon, 25 April 2016, 12:39:49
Got another problem again  ;D
I'm just rewiring a Maltron 3D keyboard with a Teensy2++

Got 7 rows and 19 columns, so I had to use the 1UL<<16 for responses of my last 3 columns.
Now I got the following problem....if I press a key from column 16 I get multiple key presses.
Mostly the next 2 keys to the right, one key gives me the next 3 keys to the right.

All other columns and rows work fine, it's just that one column that goes wild.
I'm pretty sure my soldering is quite ok, but I got the ping it through with my multimeter.

Any ideas if that could be some wrong configuration?
Title: Re: TMK keyboard firmware
Post by: e_l_tang on Mon, 25 April 2016, 13:38:55
@goflo Could you post your pin configuration and your code, please?
Title: Re: TMK keyboard firmware
Post by: a-c on Mon, 25 April 2016, 13:42:01
Got 7 rows and 19 columns, so I had to use the 1UL<<16 for responses of my last 3 columns.
Now I got the following problem....if I press a key from column 16 I get multiple key presses.
Mostly the next 2 keys to the right, one key gives me the next 3 keys to the right.

Code: [Select]
1UL<<16
1UL<<17
1UL<<18
1UL<<19
Title: Re: TMK keyboard firmware
Post by: goflo on Mon, 25 April 2016, 13:49:17
@Eric-T
No prob....just didn't want to post it all at once, maybe someone would have a clue just by the description of the problem.

matrix.c Part
Code: [Select]
/* Column pin configuration (left to right from behind)
 * col: 0   1   2   3   4   5   6   7   8   9   10  11  12  13  14  15  16  17  18
 * pin: F7  F6  F5  F4  F3  D0  F2  F1  F0  E6  E7  B0  B1  B7  B2  B3  B4  B5  B6 
 */
static void  init_cols(void)
{
    // Input with pull-up(DDR:0, PORT:1)
    DDRF  &= ~(1<<0 | 1<<1 | 1<<2 | 1<<3 | 1<<4 | 1<<5 | 1<<6 | 1<<7);
    PORTF |=  (1<<0 | 1<<1 | 1<<2 | 1<<3 | 1<<4 | 1<<5 | 1<<6 | 1<<7);
    DDRB  &= ~(1<<0 | 1<<1 | 1<<2 | 1<<3 | 1<<4 | 1<<5 | 1<<6 | 1<<7);
    PORTB |=  (1<<0 | 1<<1 | 1<<2 | 1<<3 | 1<<4 | 1<<5 | 1<<6 | 1<<7);
    DDRE  &= ~(1<<6 | 1<<7 );
    PORTE |=  (1<<6 | 1<<7 );
    DDRD  &= ~(1<<0);
    PORTD |=  (1<<0);
}


static matrix_row_t read_cols(void)
{
    return (PINB&(1<<6) ? 0 : (1<<0)) |
           (PINB&(1<<5) ? 0 : (1<<1)) |
           (PINB&(1<<4) ? 0 : (1<<2)) |
           (PINB&(1<<3) ? 0 : (1<<3)) |
           (PINB&(1<<2) ? 0 : (1<<4)) |
   (PINB&(1<<7) ? 0 : (1<<5)) |
           (PINB&(1<<1) ? 0 : (1<<6)) |
           (PINB&(1<<0) ? 0 : (1<<7)) |
           (PINE&(1<<7) ? 0 : (1<<8)) |
           (PINE&(1<<6) ? 0 : (1<<9)) |     
           (PINF&(1<<0) ? 0 : (1<<10)) |
           (PINF&(1<<1) ? 0 : (1<<11)) |
           (PINF&(1<<2) ? 0 : (1<<12)) |
           (PIND&(1<<0) ? 0 : (1<<13)) |
   (PINF&(1<<3) ? 0 : (1<<14)) |
           (PINF&(1<<4) ? 0 : (1<<15)) |
   (PINF&(1<<5) ? 0 : (1UL<<16)) |
   (PINF&(1<<6) ? 0 : (1UL<<17)) |
   (PINF&(1<<7) ? 0 : (1UL<<18));
}

/* Row pin configuration (up to down)
 * row: 0   1   2   3   4   5   6
 * pin: C7  C6  C5  C4  C3  C2  C1
 */
static void unselect_rows(void)
{
    // Hi-Z(DDR:0, PORT:0) to unselect
    DDRC  &= ~(1<<7 | 1<<6 | 1<<5 | 1<<4 | 1<<3 | 1<<2 |1<<1 );
    PORTC |=  (1<<7 | 1<<6 | 1<<5 | 1<<4 | 1<<3 | 1<<2 |1<<1 );
}

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


keymap_common.h
Code: [Select]
#ifndef KEYMAP_COMMON_H
#define KEYMAP_COMMON_H

#include <stdint.h>
#include <stdbool.h>
#include <avr/pgmspace.h>
#include "keycode.h"
#include "action.h"
#include "action_macro.h"
#include "report.h"
#include "host.h"
#include "print.h"
#include "debug.h"
#include "keymap.h"


extern const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS];
extern const uint16_t fn_actions[];


/* Maltron 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, K0C, K0D, K0E, K0F, K0G, K0H, K0I, \
    K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, K1E, K1F, K1G, K1H, K1I, \
    K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, K2D, K2E, K2F, K2G, K2H, K2I, \
    K30, K31, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3C, K3D, K3E, K3F, K3G, K3H, K3I, \
    K40, K41, K42, K43, K44, K45, K46, K47, K48,      K4A, K4B, K4C, K4D, K4E, K4F, K4G, K4H, K4I, \
         K51, K52, K53, K54,      K56, K57, K58,      K5A, K5B, K5C,      K5E, K5F, K5G, K5H,  \
                                    K68,      K6A \
) { \
    { 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_##K0E, KC_##K0F, KC_##K0G, KC_##K0H, KC_##K0I }, \
    { 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_##K1F, KC_##K1G, KC_##K1H, KC_##K1I }, \
    { 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_##K2E, KC_##K2F, KC_##K2G, KC_##K2H, KC_##K2I }, \
    { 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_##K3E, KC_##K3F, KC_##K3G, KC_##K3H, KC_##K3I }, \
    { KC_##K40, KC_##K41, KC_##K42, KC_##K43, KC_##K44, KC_##K45, KC_##K46, KC_##K47, KC_##K48, KC_NO   , KC_##K4A, KC_##K4B, KC_##K4C, KC_##K4D, KC_##K4E, KC_##K4F, KC_##K4G, KC_##K4H, KC_##K4I }, \
    { KC_NO   , KC_##K51, KC_##K52, KC_##K53, KC_##K54, KC_NO   , KC_##K56, KC_##K57, KC_##K58, KC_NO   , KC_##K5A, KC_##K5B, KC_##K5C, KC_NO   , KC_##K5E, KC_##K5F, KC_##K5G, KC_##K5H, KC_NO    },  \
    { KC_NO   , KC_NO   , KC_NO   , KC_NO   , KC_NO   , KC_NO   , KC_NO   , KC_NO   , KC_##K68, KC_NO   , KC_##K6A, KC_NO   , KC_NO   , KC_NO   , KC_NO   , KC_NO   , KC_NO   , KC_NO   , KC_NO    }  \
}


#endif


keymap_maltron.c
Code: [Select]
#include "keymap_common.h"
// Maltron DE
const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
    /* 0: qwerty */
    KEYMAP(
          F1,   F2,   F3,  F4,  F5,  F6,   ESC, NUMLOCK, KP_7,   KP_8,     KP_9,    KP_SLASH, PAUS,  F7,   F8,   F9,  F10,  F11,  F12,  \
           1,    2,    3,   4,   5,   6,  CAPS,     EQL, KP_4,   KP_5,     KP_6, KP_ASTERISK, VOLU,   7,    8,    9,    0, MINS,  EQL,  \
         TAB,    Q,    W,   E,   R,   T,  PSCR,    SLCK, KP_1,   KP_2,     KP_3,    KP_MINUS, VOLD,   Y,    U,    I,    O,    P, LBRC,  \
        LCTL,    A,    S,   D,   F,   G,  PAUS,     INS, KP_0, KP_DOT, KP_ENTER,     KP_PLUS, MUTE,   H,    J,    K,    L, SCLN, RSFT,  \
        LSFT,    Z,    X,   C,   V,   B,   DEL,    HOME,  END,             PGUP,        PGDN,  DEL,   N,    M, COMM,  DOT, SLSH, RSFT,  \
              RALT, LEFT,RGHT, FN0,       BSPC,     DEL, LALT,             RALT,         ENT,  SPC,       FN0,   UP, DOWN, NUBS, \
         LCTL,             RCTL ),
     Function layer left out.
};

Title: Re: TMK keyboard firmware
Post by: e_l_tang on Mon, 25 April 2016, 15:10:40
You counted your columns backwards! The columns are counted left to right from the front.
Title: Re: TMK keyboard firmware
Post by: goflo on Mon, 25 April 2016, 15:35:51
That shouldn't be the problem as all other columns and rows are functional and printing the right characters that they are meant to print.
I just turned that around in the allocation further down.

It is just one column that doesn't like me  :))
Btw: The layout isn't ready for use yet, just if you are wondering ;) Some keys are just mapped with senseless stuff  ;D
Title: Re: TMK keyboard firmware
Post by: e_l_tang on Mon, 25 April 2016, 16:12:56
How are you testing your keyboard? I'd be surprised if each of its keys wasn't doing what the same key on the other side of it is supposed to do.
Title: Re: TMK keyboard firmware
Post by: a-c on Mon, 25 April 2016, 16:30:26
Use 1UL for all of the columns. You are mixing different types.
Title: Re: TMK keyboard firmware
Post by: e_l_tang on Mon, 25 April 2016, 18:24:30
@a-c I don't think that's the problem.

@goflo Did you change the definitions of MATRIX_ROWS and MATRIX_COLS in your config.h file? If you didn't, matrix_row_t, which is the return type of the function that's giving you trouble, might not be wide enough.
Title: Re: TMK keyboard firmware
Post by: goflo on Tue, 26 April 2016, 11:38:21
a-c was right. After using 1UL at all columns, not just the ones above 15, everything works fine  :thumb:
I just used it for 16 upwards and that seemed to be the problem.

Thanks alot.
My third tmk keyboard is officially up and running  :cool:
Title: Re: TMK keyboard firmware
Post by: e_l_tang on Tue, 26 April 2016, 12:02:49
Interesting.
Title: Re: TMK keyboard firmware
Post by: vivalarevolución on Wed, 27 April 2016, 20:29:00
Potentially dumb/repetitive question here.  Is it possible to upload the keymap from a keyboard to see what layout is on there?  I accidentally deleted my keymap file, and I had some fancy layers on there that I don't remember.
Title: Re: TMK keyboard firmware
Post by: e_l_tang on Wed, 27 April 2016, 21:18:32
@vivalarevolución Are you using git in your tmk_keyboard folder? If so, you might be be able to recover your keymap file.
Title: Re: TMK keyboard firmware
Post by: vivalarevolución on Thu, 28 April 2016, 19:44:49
@vivalarevolución Are you using git in your tmk_keyboard folder? If so, you might be be able to recover your keymap file.

I don't know.  I'm not sure how to figure that out.
Title: Re: TMK keyboard firmware
Post by: hasu on Fri, 29 April 2016, 00:43:02
Potentially dumb/repetitive question here.  Is it possible to upload the keymap from a keyboard to see what layout is on there?  I accidentally deleted my keymap file, and I had some fancy layers on there that I don't remember.

TMK doens't have a feature like that.
Title: Re: TMK keyboard firmware
Post by: goflo on Fri, 29 April 2016, 10:04:31
I'm fiddling around with the LEDs on my maltron. I got the usual Caps, Num and Scrollock working, but got 2 LEDs left unused.
I just found the definitons for the three LED above. Is it possible to use a LED if a function toggle is pressed?
Like FN0 is a LED and FN1 another one?
Title: Re: TMK keyboard firmware
Post by: hasu on Fri, 29 April 2016, 10:11:31
I'm fiddling around with the LEDs on my maltron. I got the usual Caps, Num and Scrollock working, but got 2 LEDs left unused.
I just found the definitons for the three LED above. Is it possible to use a LED if a function toggle is pressed?
Like FN0 is a LED and FN1 another one?

Post shcematic or pics, and your code.
Title: Re: TMK keyboard firmware
Post by: goflo on Fri, 29 April 2016, 10:21:43
Hmm, there's no special schematic.
I wired all LEDs to a port on the teensy with a resistor in between.
Is it possble to define something like USB_LED_FN0 and USB_LED_FN1 for use in the spots labeled "XXX" and "YYY"?

My current led.c looks like this:

Code: [Select]
void led_set(uint8_t usb_led)
{
    if (usb_led & (1<<USB_LED_CAPS_LOCK)) {
        // Output high
        DDRD |= (1<<1);
        PORTD |= (1<<1);
      } else {
        // output low
        DDRD &= ~(1<<1);
        PORTD &= ~(1<<1);
     }
     
    if (usb_led & (1<<USB_LED_SCROLL_LOCK))
    {
        // Output high.
        DDRD |= (1<<2);
        PORTD |= (1<<2);
    }
    else
    {
        // Output low.
        DDRD &= ~(1<<2);
        PORTD &= ~(1<<2);
    }

    if (usb_led & (1<<USB_LED_NUM_LOCK))
    {
        // Output high.
        DDRD |= (1<<3);
        PORTD |= (1<<3);
    }
    else
    {
        // Output low.
        DDRD &= ~(1<<3);
        PORTD &= ~(1<<3);
    }

    if (usb_led & (1<<USB_LED_YYY))
    {
        // Output high.
        DDRD |= (1<<4);
        PORTD |= (1<<4);
    }
    else
    {
        // Output low.
        DDRD &= ~(1<<4);
        PORTD &= ~(1<<4);
    }

    if (usb_led & (1<<USB_LED_XXX))
    {
        // Output high.
        DDRD |= (1<<5);
        PORTD |= (1<<5);
    }
    else
    {
        // Output low.
        DDRD &= ~(1<<5);
        PORTD &= ~(1<<5);
    }
}
Title: Re: TMK keyboard firmware
Post by: hasu on Fri, 29 April 2016, 11:05:52
led_set() is used for standard indicators(capslock, numlock and etc.). You have to define custom action in keymap file to control the LEDs.
Someone wrote similar action somewhere, FAQ on github may have related entry, but not sure.
Title: Re: TMK keyboard firmware
Post by: a-c on Fri, 29 April 2016, 11:44:31
https://deskthority.net/workshop-f7/activatin-a-toggle-led-using-hasu-s-tmk-code-t11569.html
Title: Re: TMK keyboard firmware
Post by: hasu on Fri, 29 April 2016, 13:02:30
No, it deosn't work like that.
Instead, I think you can use 'hook_layer_change()' to run arbitrary code when layer is changed.
https://github.com/tmk/tmk_keyboard/issues/304


Hmm, there's no special schematic.
I wired all LEDs to a port on the teensy with a resistor in between.
Is it possble to define something like USB_LED_FN0 and USB_LED_FN1 for use in the spots labeled "XXX" and "YYY"?

My current led.c looks like this:

Code: [Select]
void led_set(uint8_t usb_led)
{
    if (usb_led & (1<<USB_LED_CAPS_LOCK)) {
        // Output high
        DDRD |= (1<<1);
        PORTD |= (1<<1);
      } else {
        // output low
        DDRD &= ~(1<<1);
        PORTD &= ~(1<<1);
     }
     
    if (usb_led & (1<<USB_LED_SCROLL_LOCK))
    {
        // Output high.
        DDRD |= (1<<2);
        PORTD |= (1<<2);
    }
    else
    {
        // Output low.
        DDRD &= ~(1<<2);
        PORTD &= ~(1<<2);
    }

    if (usb_led & (1<<USB_LED_NUM_LOCK))
    {
        // Output high.
        DDRD |= (1<<3);
        PORTD |= (1<<3);
    }
    else
    {
        // Output low.
        DDRD &= ~(1<<3);
        PORTD &= ~(1<<3);
    }

    if (usb_led & (1<<USB_LED_YYY))
    {
        // Output high.
        DDRD |= (1<<4);
        PORTD |= (1<<4);
    }
    else
    {
        // Output low.
        DDRD &= ~(1<<4);
        PORTD &= ~(1<<4);
    }

    if (usb_led & (1<<USB_LED_XXX))
    {
        // Output high.
        DDRD |= (1<<5);
        PORTD |= (1<<5);
    }
    else
    {
        // Output low.
        DDRD &= ~(1<<5);
        PORTD &= ~(1<<5);
    }
}
Title: Re: TMK keyboard firmware
Post by: goflo on Fri, 29 April 2016, 13:54:37
The post by a-c worked. Thanks again  :thumb:
Now I almost got the functionality of my ergodox.

At moment I'm figuring out how to define a "key" that gives me things like "ALT+8".
I got this to work with to ergodox firmware from benblazak, but not yet with the tmk firmware.

Right now the maltron is a bit strange to me...the 3D molds feel quite good, but at the moment I like my ergodoxes more.  :eek:
Title: Re: TMK keyboard firmware
Post by: goflo on Sat, 30 April 2016, 10:38:37
Got it.  :))
Now I got a maltron clone of my ergodox. Now the layout is no longer an excuse. :-X
Title: Re: TMK keyboard firmware
Post by: chupanibre on Wed, 04 May 2016, 11:59:33
hi!

i'm trying to get an old keyboard off an electric typewriter to work with hasu's firmware (thanks for making that, btw!).
that should in theory be possible, right?

i followed matt3o's very informative thread over at deskthority to get everything configured, compiled it and loaded it onto the teensy.
my .hex kinda works, but the keypresses it sends are all wrong. i'm only getting a few of the keys i configured, and always 4 or 5 at once (for a single keypress).

here are my config files, it would be awesome if somebody with eagle eyes could spot my mistake(s)..

matrix.c
More
/*
Copyright 2012 Jun Wako <wakojun@gmail.com>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

/*
 * scan matrix
 */
#include <stdint.h>
#include <stdbool.h>
#include <avr/io.h>
#include <util/delay.h>
#include "print.h"
#include "debug.h"
#include "util.h"
#include "matrix.h"


#ifndef DEBOUNCE
#   define DEBOUNCE   5
#endif
static uint8_t debouncing = DEBOUNCE;

/* matrix state(1:on, 0:off) */
static matrix_row_t matrix[MATRIX_ROWS];
static matrix_row_t matrix_debouncing[MATRIX_ROWS];

static matrix_row_t read_cols(void);
static void init_cols(void);
static void unselect_rows(void);
static void select_row(uint8_t row);


inline
uint8_t matrix_rows(void)
{
    return MATRIX_ROWS;
}

inline
uint8_t matrix_cols(void)
{
    return MATRIX_COLS;
}

void matrix_init(void)
{
    // 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;
    }
}

uint8_t matrix_scan(void)
{
    for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
        select_row(i);
        _delay_us(30);  // without this wait read unstable value.
        matrix_row_t cols = read_cols();
        if (matrix_debouncing != cols) {
            matrix_debouncing = cols;
            if (debouncing) {
                debug("bounce!: "); debug_hex(debouncing); debug("\n");
            }
            debouncing = DEBOUNCE;
        }
        unselect_rows();
    }

    if (debouncing) {
        if (--debouncing) {
            _delay_ms(1);
        } else {
            for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
                matrix = matrix_debouncing;
            }
        }
    }

    return 1;
}

bool matrix_is_modified(void)
{
    if (debouncing) return false;
    return true;
}

inline
bool matrix_is_on(uint8_t row, uint8_t col)
{
    return (matrix[row] & ((matrix_row_t)1<<col));
}

inline
matrix_row_t matrix_get_row(uint8_t row)
{
    return matrix[row];
}

void matrix_print(void)
{
    print("\nr/c 0123456789ABCDEF\n");
    for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
        phex(row); print(": ");
        pbin_reverse16(matrix_get_row(row));
        print("\n");
    }
}

uint8_t matrix_key_count(void)
{
    uint8_t count = 0;
    for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
        count += bitpop16(matrix);
    }
    return count;
}

/* 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);
    PORTF |=  (1<<7 | 1<<6 | 1<<5 | 1<<4);
    DDRD  &= ~(1<<7);
    PORTD |=  (1<<7);
    DDRB  &= ~(1<<6 | 1<< 5 | 1<<4);
    PORTB |=  (1<<6 | 1<< 5 | 1<<4);
}

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

/* 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  &= ~0b00010001;
    PORTB &= ~0b00010001;
    DDRD  &= ~0b11110000;
    PORTD &= ~0b11110000;
    DDRC  &= ~0b00000011;
    PORTC &= ~0b00000011;
}

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

keymap.common
More
/*
Copyright 2012,2013 Jun Wako <wakojun@gmail.com>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef KEYMAP_COMMON_H
#define KEYMAP_COMMON_H

#include <stdint.h>
#include <stdbool.h>
#include <avr/pgmspace.h>
#include "keycode.h"
#include "action.h"
#include "action_macro.h"
#include "report.h"
#include "host.h"
#include "print.h"
#include "debug.h"
#include "keymap.h"


extern const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS];
extern const uint16_t fn_actions[];


/* GH60 keymap definition macro
 * K2C, K31 and  K3C are extra keys for ISO
 */
#define KEYMAP( \
    K00, K01, K02, K03, K04, K05, K06, K07, \
   K10, K11, K12, K13, K14, K15, K16, K17, \
   K20, K21, K22, K23, K24, K25, K26, K27, \
   K30, K31, K32, K33, K34, K35, K36, K37, \
   K40, K41, K42, K43, K44, K45, K46, K47, \
   K50, K51, K52, K53, K54, K55,           \
   K60, K61, K62, K63, K64, K65, K66, K67, \
   K70, K71, K72, K73, K74, K75, K76, K77  \
) { \
    { KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07 }, \
   { KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17 }, \
   { KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_##K27 }, \
   { KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_##K35, KC_##K36, KC_##K37 }, \
   { KC_##K40, KC_##K41, KC_##K42, KC_##K43, KC_##K44, KC_##K45, KC_##K46, KC_##K47 }, \
   { KC_##K50, KC_##K51, KC_##K52, KC_##K53, KC_##K54, KC_##K55, KC_NO,    KC_NO    }, \
   { KC_##K60, KC_##K61, KC_##K62, KC_##K63, KC_##K64, KC_##K65, KC_##K66, KC_##K67 }, \
   { KC_##K70, KC_##K71, KC_##K72, KC_##K73, KC_##K74, KC_##K75, KC_##K76, KC_##K77 }  \
}

#endif

keymap_poker.c
More
#include "keymap_common.h"

const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
    KEYMAP(
        0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, \
        0, 0, Q, W, E, R, T, Z, U, I, O, P, U, 0, 0,    \
        0, 0, A, S, D, F, G, H, J, K, L, O, A, 0, 0,    \
        0, 0, LSFT, Y, X, C, V, B, N, M, 0, 0, 0,       \
        LCTL, SPC, RCTL),
};

const uint16_t PROGMEM fn_actions[] = {};


Title: Re: TMK keyboard firmware
Post by: a-c on Wed, 04 May 2016, 12:14:37
Your bits are backwards. LSB is on the right.

Code: [Select]
    // Hi-Z(DDR:0, PORT:0) to unselect
    DDRB  &= ~0b00010001;
    PORTB &= ~0b00010001;
    DDRD  &= ~0b11110000;
    PORTD &= ~0b11110000;
    DDRC  &= ~0b00000011;
    PORTC &= ~0b00000011;
Title: Re: TMK keyboard firmware
Post by: chupanibre on Wed, 04 May 2016, 12:53:37
Your bits are backwards. LSB is on the right.

arrgh! thanks!
i fixed my bits, recompiled, but i still get the exact same keys in aqua's key test.. huh?
i guess there are some more errors in my files, maybe it's best to start over..

edit. i started over with a fresh copy from the tmk repo, and i'm back at the same output as before.
i probably do something very stupid somewhere, but i can't figure out what.
i measured the outputs with a voltmeter, and wrote down the matrix.
e.g. when i press key 1, the resistance between the leftmost wires drops, and so on.
i've attached a picture:


edit.2 i found my mistake!! i had a 15x4 matrix defined in my keymap_common.h but i needed a 8x8.. it's working, wooohoo!! and now for some serious tweaking, i need all the fn layers, leds and special keys!
Title: Re: TMK keyboard firmware
Post by: BorisYeltsin on Fri, 06 May 2016, 19:31:49
Hello,

I am currently building a custom keyboard and am having some problems with the firmware.  I am using a Teensy lc with a matrix with 16 outputs and 6 inputs.  I meant for it to be the opposite of that, but I guess I messed up the direction of the diodes even though I checked before soldering.  I have gotten all of the keys to work, however when I try to type at more than ~2 keys per second, the keyboard pauses then starts outputting a whole bunch of a single character.  For example, if I alternate between g and h quickly, it will type a g and an h then pause then type multiple g's or h's in a row almost as if I was holding the key down.  This works with any 2 keys.  I'm using the teensy_lc_onekey example in the keyboards directory but I have added a keymap_common.h and .c and have changed matrix.c and keymap_plain.c

any help would be appreciated and if you need any more info just ask.

keymap_common.c:
http://pastebin.com/JxQeyqfe

keymap_common.h:
http://pastebin.com/3hYe6qrM

matrix.c
http://pastebin.com/AxUZxCrf

keymap_plain.c
http://pastebin.com/XYve6ni7

keyboard pictures:
http://imgur.com/a/rNCds
Title: Re: TMK keyboard firmware
Post by: e_l_tang on Sat, 07 May 2016, 14:49:36
@BorisYeltsin Did you follow the instructions to build TMK for ARM chips at https://github.com/tmk/tmk_keyboard/tree/master/tmk_core/protocol/chibios (https://github.com/tmk/tmk_keyboard/tree/master/tmk_core/protocol/chibios)?
Title: Re: TMK keyboard firmware
Post by: BorisYeltsin on Sat, 07 May 2016, 16:41:30
I was able to figure get my matrix to be the right dimensions by making keys active high instead of active low.  I had a small problem with the capslock led being on the same pin as a column but that is fixed as well.  basically when the caps lock was turned on, all of the keys in the column would be pressed.  Now I am getting the same symptom with the scroll lock led but I have made sure that they are on different pins (scroll lock led on 17, column on 12).  I am also getting some strange behavior by the pause break key in which the key doesnt work but it is pressed seemingly randomly.  I'm fairly sure this is a software issue since I have checked the rows and columns for shorts multiple times.  If you can think of anything that might help I would love to hear it.

led.c
http://pastebin.com/iyNdhwXr

matrix.c
http://pastebin.com/3AcQDGvJ

keymap_common.h
http://pastebin.com/Veg4BT4k

keymap_plain.c
http://pastebin.com/yM5PLm8Q

Also, I followed the directions in instructions.md in the teensy_lc_onekey folder, which seem to be more or less the same as those in the link you posted

Edit: also found out that pressing asd or sdf at the same time toggles caps lock, which is weird and I cant really explain it. I have tried a bunch of other key configurations and nothing else does this.  I have also found that most of my problems seem to be centered around the pause/break key, all the other keys are fine but it gets held down randomly.  none of the other keys on its column or row are affected.  I could just disable this key but I would like to have it in order to get to the bootloader without having to press the button on the teensy
Title: Re: TMK keyboard firmware
Post by: flabbergast on Sun, 08 May 2016, 14:19:54
Not sure what the problem could be. Just a couple of comments: your mileage may vary with PIN13 - the Teensy has a LED on it. If you want to have the pause/break key just for getting into the bootloader (and you don't normally use it), you can ditch it completely and define a 'BTLD' keycode for some combination. That will get you into the bootloader just as well.

EDIT: Just tested PIN13 - and *almost always* when set as input with the internal pullup, it does read high. So you can probably use it. However if you have another spare pin, I'd rewire that row/column there. BTW having a LED on that pin is fine (you'll simply have 2 LEDs on at the same time).
Title: Re: TMK keyboard firmware
Post by: BorisYeltsin on Wed, 11 May 2016, 21:59:39
I moved the column connected to pin 13 and used a different USB cable and all of the problems went away! thanks for the help
Title: Re: TMK keyboard firmware
Post by: RavenII on Thu, 12 May 2016, 08:00:03
How can I make a key do the following...

When held it's LALT, but when tapped twice (and held on the second tap), it becomes Fn1?

ACTION_LAYER_TAP_KEY(KC_LALT, 2) doesn't work, I thought if I swapped the Layer number with the modifier it would...but no go.
Title: Re: TMK keyboard firmware
Post by: hasu on Thu, 12 May 2016, 15:04:11
How can I make a key do the following...

When held it's LALT, but when tapped twice (and held on the second tap), it becomes Fn1?

ACTION_LAYER_TAP_KEY(KC_LALT, 2) doesn't work, I thought if I swapped the Layer number with the modifier it would...but no go.

you cannot do this with existent keymap action, you have to write function code in your keymap file. You can use tap_count to know how many it taps.
http://www.tmk-kbd.com/tmk_keyboard/editor/alps64/index.html
Title: Re: TMK keyboard firmware
Post by: ProCarpet on Fri, 13 May 2016, 09:15:20
Yet again i have to request your help. Ive soldered in my diodes the wrong way. Now ive read that it is possible to reverse them in software but how? Can anybody tell me?
Title: Re: TMK keyboard firmware
Post by: a-c on Fri, 13 May 2016, 11:52:03
Yet again i have to request your help. Ive soldered in my diodes the wrong way. Now ive read that it is possible to reverse them in software but how? Can anybody tell me?

Look at the matrix.c from the phantom keyboard for an example of wiring with the diodes in the opposite direction to the GH60. https://github.com/tmk/tmk_keyboard/blob/master/keyboard/phantom/matrix.c
Title: Re: TMK keyboard firmware
Post by: ProCarpet on Fri, 13 May 2016, 12:45:22
Yet again i have to request your help. Ive soldered in my diodes the wrong way. Now ive read that it is possible to reverse them in software but how? Can anybody tell me?

Look at the matrix.c from the phantom keyboard for an example of wiring with the diodes in the opposite direction to the GH60. https://github.com/tmk/tmk_keyboard/blob/master/keyboard/phantom/matrix.c
So i would need to switch all rows for cols and do the same in the matrix? If so id rather desolder the switches and turn the diode
Title: Re: TMK keyboard firmware
Post by: hasu on Fri, 13 May 2016, 17:56:10
Yet again i have to request your help. Ive soldered in my diodes the wrong way. Now ive read that it is possible to reverse them in software but how? Can anybody tell me?

Look at the matrix.c from the phantom keyboard for an example of wiring with the diodes in the opposite direction to the GH60. https://github.com/tmk/tmk_keyboard/blob/master/keyboard/phantom/matrix.c
So i would need to switch all rows for cols and do the same in the matrix? If so id rather desolder the switches and turn the diode


Resolder them, it seems to be easy to you.
Title: Re: TMK keyboard firmware
Post by: wolfv on Sat, 14 May 2016, 00:46:11
I want to try hasu's firmware on a key matrix that is active-high, pull down resistors on the columns, and uses Teensy 2.0.
Is there a TMK firmware with a similar setup that I could modify?
Where in the TMK code is the active-high or active-low configured?

Thank you.
Title: Re: TMK keyboard firmware
Post by: hasu on Sat, 14 May 2016, 01:03:08
I want to try hasu's firmware on a key matrix that is active-high, pull down resistors on the columns, and uses Teensy 2.0.
Is there a TMK firmware with a similar setup that I could modify?
Where in the TMK code is the active-high or active-low configured?

Thank you.

No such configuration option, you basically have to write code for the matrix with TMK. I can't remember if there is project using active-high matrix in TMK repository.
Title: Re: TMK keyboard firmware
Post by: ProCarpet on Sat, 14 May 2016, 02:04:58
Yet again i have to request your help. Ive soldered in my diodes the wrong way. Now ive read that it is possible to reverse them in software but how? Can anybody tell me?

Look at the matrix.c from the phantom keyboard for an example of wiring with the diodes in the opposite direction to the GH60. https://github.com/tmk/tmk_keyboard/blob/master/keyboard/phantom/matrix.c
ok ill do that thanks you both for the help :D
So i would need to switch all rows for cols and do the same in the matrix? If so id rather desolder the switches and turn the diode


Resolder them, it seems to be easy to you.
Title: Re: TMK keyboard firmware
Post by: wolfv on Sat, 14 May 2016, 02:10:57
I want to try hasu's firmware on a key matrix that is active-high, pull down resistors on the columns, and uses Teensy 2.0.
Is there a TMK firmware with a similar setup that I could modify?
Where in the TMK code is the active-high or active-low configured?

Thank you.

No such configuration option, you basically have to write code for the matrix with TMK. I can't remember if there is project using active-high matrix in TMK repository.
Thanks for the quick response hasu.
Is there an example TMK firmware with a Teensy LC and active-low key matrix, that I could modify?

Title: Re: TMK keyboard firmware
Post by: mike52787 on Sat, 14 May 2016, 22:30:12
Having some trouble compiling my firmware. I tried it on windows and on a linux vm and got different errors each time. Here is my code. check my work!
matrix.c
Code: [Select]
/*
/*
Copyright 2012 Jun Wako <wakojun@gmail.com>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

/*
 * scan matrix
 */
#include <stdint.h>
#include <stdbool.h>
#include <avr/io.h>
#include <util/delay.h>
#include "print.h"
#include "debug.h"
#include "util.h"
#include "matrix.h"


#ifndef DEBOUNCE
#   define DEBOUNCE 5
#endif
static uint8_t debouncing = DEBOUNCE;

/* matrix state(1:on, 0:off) */
static matrix_row_t matrix[MATRIX_ROWS];
static matrix_row_t matrix_debouncing[MATRIX_ROWS];

static matrix_row_t read_cols(void);
static void init_cols(void);
static void unselect_rows(void);
static void select_row(uint8_t row);


inline
uint8_t matrix_rows(void)
{
    return MATRIX_ROWS;
}

inline
uint8_t matrix_cols(void)
{
    return MATRIX_COLS;
}

void matrix_init(void)
{
    // initialize row and col
    unselect_rows();
    init_cols();

    // initialize matrix state: all keys off
    for (uint8_t i=0; i < MATRIX_ROWS; i++) {
        matrix[i] = 0;
        matrix_debouncing[i] = 0;
    }
}

uint8_t matrix_scan(void)
{
    for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
        select_row(i);
        _delay_us(30);  // without this wait read unstable value.
        matrix_row_t cols = read_cols();
        if (matrix_debouncing[i] != cols) {
            matrix_debouncing[i] = cols;
            if (debouncing) {
                debug("bounce!: "); debug_hex(debouncing); debug("\n");
            }
            debouncing = DEBOUNCE;
        }
        unselect_rows();
    }

    if (debouncing) {
        if (--debouncing) {
            _delay_ms(1);
        } else {
            for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
                matrix[i] = matrix_debouncing[i];
            }
        }
    }

    return 1;
}

bool matrix_is_modified(void)
{
    if (debouncing) return false;
    return true;
}

inline
bool matrix_is_on(uint8_t row, uint8_t col)
{
    return (matrix[row] & ((matrix_row_t)1<<col));
}

inline
matrix_row_t matrix_get_row(uint8_t row)
{
    return matrix[row];
}

void matrix_print(void)
{
    print("\nr/c 0123456789ABCDEF\n");
    for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
        phex(row); print(": ");
        pbin_reverse16(matrix_get_row(row));
        print("\n");
    }
}

uint8_t matrix_key_count(void)
{
    uint8_t count = 0;
    for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
        count += bitpop16(matrix[i]);
    }
    return count;
}

/* Column pin configuration
 * col: 0   1   2   3   4   5   6   7   8   9   10  11  12  13  14  15  16
 * pin: B6  B5  B4  D7  D6  D4  D5  C7  C6  D3  D2  D1  D0  B7  B3  B2  B1                                                 
 */
static void  init_cols(void)
{
    // Input with pull-up(DDR:0, PORT:1)
    DDRD  &= ~(1<<7 | 1<<6 | 1<<4 | 1<<5 | 1<<3 | 1<<2 | 1<<1 | 1<<0);
    PORTD |=  (1<<7 | 1<<6 | 1<<4 | 1<<5 | 1<<3 | 1<<2 | 1<<1 | 1<<0);
    DDRC  &= ~(1<<7 | 1<<6);
    PORTC |=  (1<<7 | 1<<6);
    DDRB  &= ~(1<<7 | 1<<6 | 1<< 5 | 1<<4 | 1<<3 | 1<<1 | 1<<2);
    PORTB |=  (1<<7 | 1<<6 | 1<< 5 | 1<<4 | 1<<3 | 1<<1 | 1<<2);
}

static matrix_row_t read_cols(void)
{
    return (PINB&(1<<6) ? 0 : (1<<0)) |
           (PINB&(1<<5) ? 0 : (1<<1)) |
           (PINB&(1<<4) ? 0 : (1<<2)) |
           (PIND&(1<<7) ? 0 : (1<<3)) |
           (PIND&(1<<6) ? 0 : (1<<4)) |
           (PIND&(1<<4) ? 0 : (1<<5)) |
           (PIND&(1<<5) ? 0 : (1<<6)) |
           (PINC&(1<<7) ? 0 : (1<<7)) |
           (PINC&(1<<6) ? 0 : (1<<8)) |
           (PIND&(1<<3) ? 0 : (1<<9)) |
           (PIND&(1<<2) ? 0 : (1<<10)) |
   (PIND&(1<<1) ? 0 : (1<<11)) |
   (PIND&(1<<0) ? 0 : (1<<12)) |
   (PINB&(1<<7) ? 0 : (1<<13)) |
   (PINB&(1<<3) ? 0 : (1<<14)) |
   (PINB&(1<<2) ? 0 : (1<<15)) |
           (PINB&(1<<1) ? 0 : (1<<16));
}

/* Row pin configuration
 * row: 0   1   2   3   4  5
 * pin: F0  F1  F4  F5  F6 F7
 */
static void unselect_rows(void)
{
    // Hi-Z(DDR:0, PORT:0) to unselect
    DDRF  &= ~0b11001111;
    PORTF &= ~0b11001111;
}

static void select_row(uint8_t row)
{
    // Output low(DDR:1, PORT:0) to select
    switch (row) {
        case 0:
            DDRF  |= (1<<0);
            PORTF &= ~(1<<0);
            break;
        case 1:
            DDRF  |= (1<<1);
            PORTF &= ~(1<<1);
            break;
        case 2:
            DDRF  |= (1<<4);
            PORTF &= ~(1<<4);
            break;
        case 3:
            DDRF  |= (1<<5);
            PORTF &= ~(1<<5);
            break;
    case 4:
            DDRF  |= (1<<6);
            PORTF &= ~(1<<6);
            break;
        case 5:
            DDRF  |= (1<<7);
            PORTF &= ~(1<<7);
            break;
    }
}
keymap_poker.c
Code: [Select]
#include "keymap_common.h"

const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
/* 0: qwerty */
KEYMAP(\
    ESC, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11,  F12,        PSCR,SLCK,PAUS,                         \
    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,                       \
    LSFT, Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, SLSH,     RSFT,        UP,            \
    LCTL,FN0,LALT,               SPC,                RALT,RGUI,RCTL,         LEFT,DOWN,RGHT,    ),
};

const uint16_t PROGMEM fn_actions[] = {

};
here is the board.
(http://i.imgur.com/Ovu5IdK.png)
Here is the error i get when compiling.
(http://i.imgur.com/qatK1Fb.png)
please help!
Title: Re: TMK keyboard firmware
Post by: hasu on Sat, 14 May 2016, 23:43:45
mike52787, did you see if default source codes can be compiled in your environment yet? I like to know if your enviroment is correct before inspecting your codes.
Title: Re: TMK keyboard firmware
Post by: xevz on Sun, 15 May 2016, 06:02:38
So, I'm trying to implement translation from Swedish QWERTY (https://upload.wikimedia.org/wikipedia/commons/thumb/e/e0/KB_Sweden.svg/900px-KB_Sweden.svg.png) to Svorak A5 (http://aoeu.info/s/dvorak/images/svorak-A5.png) using TMK on my Ergodox.
Almost everything works, except for the combinations that require Right Alt (AltGr) + keys on the left hand side of the keyboard in Swedish QWERTY, which means that neither $ nor @ works.

Tried both LUFA and PJRC libraries.

Any pointers on how to debug this further?

Output from xev when sending @:
Code: [Select]
MappingNotify event, serial 33, synthetic NO, window 0x0,
    request MappingKeyboard, first_keycode 8, count 248

KeyPress event, serial 33, synthetic NO, window 0x3200001,
    root 0xd9, subw 0x0, time 616870409, (-492,511), root:(195,531),
    state 0x0, keycode 108 (keysym 0xfe03, ISO_Level3_Shift), same_screen YES,
    XKeysymToKeycode returns keycode: 92
    XLookupString gives 0 bytes:
    XmbLookupString gives 0 bytes:
    XFilterEvent returns: False

FocusOut event, serial 34, synthetic NO, window 0x3200001,
    mode NotifyGrab, detail NotifyAncestor

FocusIn event, serial 34, synthetic NO, window 0x3200001,
    mode NotifyUngrab, detail NotifyAncestor

KeymapNotify event, serial 34, synthetic NO, window 0x0,
    keys:  1   0   0   0   0   0   0   0   0   0   0   0   0   16  0   0   
           0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   

KeyRelease event, serial 34, synthetic NO, window 0x3200001,
    root 0xd9, subw 0x0, time 616870497, (-492,511), root:(195,531),
    state 0x80, keycode 108 (keysym 0xfe03, ISO_Level3_Shift), same_screen YES,
    XKeysymToKeycode returns keycode: 92
    XLookupString gives 0 bytes:
    XFilterEvent returns: False

hid_listen:
Code: [Select]
---- action_exec: start -----
EVENT: 0705d(39579)
ACTION: ACT_LAYER_TAP[1:F1] layer_state: 00000000(0) default_layer_state: 00000000(0)
layer_state: 00000000(0) to 00000002(1)
keyboard_report: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
processed: 0705d(39579):0


---- action_exec: start -----
EVENT: 0303d(40171)
ACTION: ACT_RMODS[4:1F] layer_state: 00000002(1) default_layer_state: 00000000(0)
keyboard_report: 40 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
keyboard_report: 40 00 1F 00 00 00 00 00 00 00 00 00 00 00 00 00
processed: 0303d(40171):0


---- action_exec: start -----
EVENT: 0303u(40261)
ACTION: ACT_RMODS[4:1F] layer_state: 00000002(1) default_layer_state: 00000000(0)
keyboard_report: 40 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
keyboard_report: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
processed: 0303u(40261):0


---- action_exec: start -----
EVENT: 0705u(41107)
ACTION: ACT_LAYER_TAP[1:F1] layer_state: 00000002(1) default_layer_state: 00000000(0)
layer_state: 00000002(1) to 00000000(0)
keyboard_report: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
processed: 0705u(41107):0

keymap:
Code: [Select]
static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
    KEYMAP(  // Layer0: default, leftled:none
        // left hand
        NO,   1,   2,      3,   4,   5,   NO,
        TAB,  LBRC,QUOT,SCLN,   P,   Y,   NO,
        ESC,  A,      O,   E,   U,   I,
        LSFT, DOT,    Q,   J,   K,   X,   NO,
        NO,          NO,  NO,  NO,  NO,
                                       LCTL,  LALT,
                                                NO,
                                     BSPC, DEL, NO,
        // right hand
             NO,  6,   7,   8,    9,   0,   NO,
             NO,  F,   G,   C,    R,   L,   NO,
                  D,   H,   T,    N,   S,   NO,
             NO,  B,   M,   W,    V,   Z,   RSFT,
                       NO, NO, COMM,   NO,  NO,
        FN1,  RCTL,
        NO,
        NO, ENT, SPC
    ),

    KEYMAP(  // Layer1: AltGr
        // left hand
        NO,   NO,    NO,      NO,   NO,   NO,   NO,
        NO,  FN2,   FN3,     FN4,  FN5,  FN6,   NO,
        NO,  FN12, FN13,    FN14, FN15, FN16,
        NO,  FN22, FN23,    FN24, FN25, FN26,   NO,
        NO,          NO,  NO,  NO,  NO,
                                       NO,  NO,
                                                NO,
                                     NO, NO, NO,
        // right hand
             NO,    NO,    NO,   NO,   NO,   NO,   NO,
             NO,   FN7,   FN8,  FN9, FN10, FN11,   NO,
                  FN17,  FN18, FN19, FN20, FN21,   NO,
             NO,  FN27,    NO,   NO,   NO,   NO,   NO,
                    NO,    NO,   NO,   NO,   NO,
        FN1,  NO,
        NO,
        NO, NO, NO
    ),
};

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

enum macro_id {
    NODEAD_TILDE,
    NODEAD_CARET,
};

/*
 * Fn action definition
 */
static const uint16_t PROGMEM fn_actions[] = {
    [0]  = ACTION_FUNCTION(TEENSY_KEY),                       // FN0  - Teensy key

    // AltGr toogle
    [1]  = ACTION_LAYER_MOMENTARY(1),                         // FN1 = Temporarily switch to layer 1

    // AltGr, top row
    [2]  = ACTION_MODS_KEY(MOD_RALT, KC_7),                   // FN2  = {
    [3]  = ACTION_MODS_KEY(MOD_RALT, KC_0),                   // FN3  = }
    [4]  = ACTION_MODS_KEY(MOD_RALT, KC_8),                   // FN4  = [
    [5]  = ACTION_MODS_KEY(MOD_RALT, KC_9),                   // FN5  = ]
    [6]  = ACTION_MODS_KEY(MOD_RALT, KC_4),                   // FN6  = $ XXX: NOT WORKING
    [7]  = ACTION_MODS_KEY(MOD_RSFT, KC_2),                   // FN7  = "
    [8]  = ACTION_MODS_KEY(MOD_RSFT, KC_MINUS),               // FN8  = ?
    [9]  = ACTION_MODS_KEY(MOD_RSFT, KC_6),                   // FN9  = &
    [10] = ACTION_KEY(KC_NONUS_BSLASH),                       // FN10 = <, not necessary, just easier to keep track
    [11] = ACTION_MODS_KEY(MOD_RSFT, KC_NONUS_BSLASH),        // FN11 = >

    // Middle row
    [12] = ACTION_MODS_KEY(MOD_RSFT, KC_COMMA),               // FN12 = ;
    [13] = ACTION_MODS_KEY(MOD_RSFT, KC_7),                   // FN13 = /
    [14] = ACTION_MODS_KEY(MOD_RSFT, KC_8),                   // FN14 = (
    [15] = ACTION_MODS_KEY(MOD_RSFT, KC_9),                   // FN15 = )
    [16] = ACTION_MODS_KEY(MOD_RALT, KC_NONUS_BSLASH),        // FN16 = |
    [17] = ACTION_MODS_KEY(MOD_RSFT, KC_3),                   // FN17 = #
    [18] = ACTION_MACRO(NODEAD_CARET),                        // FN18 = ^
    [19] = ACTION_MODS_KEY(MOD_RSFT, KC_3),                   // FN19 = #
    [20] = ACTION_MODS_KEY(MOD_RSFT, KC_2),                   // FN20 = "
    [21] = ACTION_MACRO(NODEAD_TILDE),                        // FN21 = ~

    // Last row
    [22] = ACTION_MODS_KEY(MOD_RSFT, KC_DOT),                 // FN22 = :
    [23] = ACTION_MODS_KEY(MOD_RSFT, KC_0),                   // FN23 = =
    [24] = ACTION_MODS_KEY(MOD_RALT, KC_2),                   // FN24 = @ XXX: NOT WORKING
    [25] = ACTION_MODS_KEY(MOD_RSFT, KC_1),                   // FN25 = !
    [26] = ACTION_MODS_KEY(MOD_RALT, KC_MINUS),               // FN26 = backslash
    [27] = ACTION_MODS_KEY(MOD_RSFT, KC_5),                   // FN27 = %
};

const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) {
    if (record->event.pressed) {
        switch (id) {
            case NODEAD_TILDE:
                return MACRO(D(RALT), T(RBRACKET), U(RALT), T(SPACE), END);
                break;
            case NODEAD_CARET:
                return MACRO(D(RSHIFT), T(RBRACKET), U(RSHIFT), T(SPACE), END);
                break;
        }
    }
    return MACRO_NONE;
}


void action_function(keyrecord_t *event, uint8_t id, uint8_t opt)
{
    print("action_function called\n");
    print("id  = "); phex(id); print("\n");
    print("opt = "); phex(opt); print("\n");
    if (id == TEENSY_KEY) {
        clear_keyboard();
        print("\n\nJump to bootloader... ");
        _delay_ms(250);
        bootloader_jump(); // should not return
        print("not supported.\n");
    }
}

EDIT: Just noticed that they don't work with the swedish layout using the laptop keyboard either, so it seems to be a X.org related problem.
Title: Re: TMK keyboard firmware
Post by: mike52787 on Sun, 15 May 2016, 13:15:48
mike52787, did you see if default source codes can be compiled in your environment yet? I like to know if your enviroment is correct before inspecting your codes.
I tried compiling the alps64 files and no success. What could be wrong? I am running a fresh install of mint 17.3.
Title: Re: TMK keyboard firmware
Post by: hasu on Sun, 15 May 2016, 16:45:30
I don't know about mint but seems like toolchain is not correctly setup. Maybe avr libc?
You can Google to know how to install packages required for avr toolchain.

Sent from my Nexus 5X using Tapatalk

Title: Re: TMK keyboard firmware
Post by: TD22057 on Sun, 15 May 2016, 19:38:49
Hey hasu,
I'd like to try and support the following features.  Any ideas on if they've been done before or how hard they would be to implement?

1) key to turn oneshot mods on and off for all mods (or a list of mods).  I want to be able to try out oneshot mods for shift, alt, ctrl but I may want to turn them off if I decide I don't like them so I'd like to have a key that globally enables and disables them (using an fn_actions function).

2) oneshot mod when a mod is tapped and normal mod when held - like ACTION_MODS_TAP_KEY( LSFT, LSFT ).  So tap left shift and get a normal oneshot behavior, hold it to get regular shift behavior (oneshot might already work this way - I haven't tried it yet).

3) oneshot layer switch.  Tap FN key which switches to layer 2 and after any key press switches back to layer 1.  Similar to 2) - if FN is held down, layer 2 is active until FN is released - i.e. if FN is held down and another key is pressed, that key from layer 2 is used and the layer switches back to 1 when FN is released but if FN is tapped, then the next key is from layer 2.

I noticed that action_util.h contains these function prototypes but they aren't defined or used anywhere.  I'm guessing these declarations should be removed.
Code: [Select]
void oneshot_toggle(void);
void oneshot_enable(void);
void oneshot_disable(void);
Title: Re: TMK keyboard firmware
Post by: TD22057 on Sun, 15 May 2016, 22:48:25
One more question (for now) - if I'm running out of function slots (32 limit), is there any reason to not move to a uint16_t matrix storing action_t objects for each key and override the action_for_key() function in keymap.c?  It seems like there is plenty of flash available and that would basically allow me to customize each key with an action object.  I'd need to do something different for the KEYMAP macro but that shouldn't be too hard.
Title: Re: TMK keyboard firmware
Post by: alienman82 on Tue, 17 May 2016, 12:28:45
removed.
Title: Re: TMK keyboard firmware
Post by: TD22057 on Tue, 17 May 2016, 12:43:23
One more question (for now) - if I'm running out of function slots (32 limit), is there any reason to not move to a uint16_t matrix storing action_t objects for each key and override the action_for_key() function in keymap.c?  It seems like there is plenty of flash available and that would basically allow me to customize each key with an action object.  I'd need to do something different for the KEYMAP macro but that shouldn't be too hard.

Answering my own question:  See alps64/Makefile which defines ACTIONMAP_ENABLE which triggers swapping keymap.c with actionmap.c to handle this.   This requires that the keyboard define a uint16_t matrix of actions to use instead of the keymap which is what I'm trying to do.   The alps64 directory has examples for doing this already.
Title: Re: TMK keyboard firmware
Post by: hasu on Tue, 17 May 2016, 16:16:27
One more question (for now) - if I'm running out of function slots (32 limit), is there any reason to not move to a uint16_t matrix storing action_t objects for each key and override the action_for_key() function in keymap.c?  It seems like there is plenty of flash available and that would basically allow me to customize each key with an action object.  I'd need to do something different for the KEYMAP macro but that shouldn't be too hard.

Answering my own question:  See alps64/Makefile which defines ACTIONMAP_ENABLE which triggers swapping keymap.c with actionmap.c to handle this.   This requires that the keyboard define a uint16_t matrix of actions to use instead of the keymap which is what I'm trying to do.   The alps64 directory has examples for doing this already.

Right, no reason to hesitate actionmap except for twice usage of flash memory and conventinalism.
Title: Re: TMK keyboard firmware
Post by: hasu on Tue, 17 May 2016, 16:21:38
Hasu, I am using the alps64 hex generator website:

http://www.tmk-kbd.com/tmk_keyboard/editor/alps64/index.html

I cannot get left or right alt keys to work on any layers or keys.  I have tested the all the switches for various other commands, and they seem to work fine.  I even mapped L7 to a key and alt to that same key, but that didn't work. Need my alt + tab T_T

X-post

You cannot do that at this time at least, I have a plan to improve this limitation but not soon.
Title: Re: TMK keyboard firmware
Post by: alienman82 on Tue, 17 May 2016, 16:22:19
removed.
Title: Re: TMK keyboard firmware
Post by: hasu on Tue, 17 May 2016, 16:25:33
Hasu, I am using the alps64 hex generator website:

http://www.tmk-kbd.com/tmk_keyboard/editor/alps64/index.html

I cannot get left or right alt keys to work on any layers or keys.  I have tested the all the switches for various other commands, and they seem to work fine.  I even mapped L7 to a key and alt to that same key, but that didn't work. Need my alt + tab T_T

X-post

You cannot do that at this time at least, I have a plan to improve this limitation but not soon.


Can building firmware without the tool fix this??

Not sure exactly your problem. Can you post editor URL for your keymap?
Title: Re: TMK keyboard firmware
Post by: alienman82 on Tue, 17 May 2016, 16:35:57
removed.
Title: Re: TMK keyboard firmware
Post by: TD22057 on Tue, 17 May 2016, 17:07:22
Right, no reason to hesitate actionmap except for twice usage of flash memory and conventinalism.

Thanks!  Any thoughts on my questions about features in post 1445 (https://geekhack.org/index.php?topic=41989.msg2171654#msg2171654)?
Title: Re: TMK keyboard firmware
Post by: firerock on Wed, 18 May 2016, 11:00:09
Hello friends,

I'm currently bringing new life to the old Soviet Izot Magnetic Reed Switch terminal keyboard. For some reasons, I've decided to create the new Teensy-based PCB for this monster.

So, I've got a bunch of very old-fashioned key legend combinations. And following symbol pairs are sharing the same keys: 2 and ", 6 and &, 7 and ', 8 and (, 9 and ), ; and +, : and *. Also, there are @ and ^ at non-shifted positions. How to implement this layout using TMK?

As far as I've got, I could use Fn keys for that purpose. But what I don't understand is how to assign the different meanings for these keys at the normal and shifted positions? Is it possible after all?

Thank you in advance for the answers!

And here is the layout itself, the troublesome keys have red outlines:

[attach=1]
Title: Re: TMK keyboard firmware
Post by: hasu on Wed, 18 May 2016, 11:40:06
Hey hasu,
I'd like to try and support the following features.  Any ideas on if they've been done before or how hard they would be to implement?

1) key to turn oneshot mods on and off for all mods (or a list of mods).  I want to be able to try out oneshot mods for shift, alt, ctrl but I may want to turn them off if I decide I don't like them so I'd like to have a key that globally enables and disables them (using an fn_actions function).

2) oneshot mod when a mod is tapped and normal mod when held - like ACTION_MODS_TAP_KEY( LSFT, LSFT ).  So tap left shift and get a normal oneshot behavior, hold it to get regular shift behavior (oneshot might already work this way - I haven't tried it yet).

3) oneshot layer switch.  Tap FN key which switches to layer 2 and after any key press switches back to layer 1.  Similar to 2) - if FN is held down, layer 2 is active until FN is released - i.e. if FN is held down and another key is pressed, that key from layer 2 is used and the layer switches back to 1 when FN is released but if FN is tapped, then the next key is from layer 2.

I noticed that action_util.h contains these function prototypes but they aren't defined or used anywhere.  I'm guessing these declarations should be removed.
Code: [Select]
void oneshot_toggle(void);
void oneshot_enable(void);
void oneshot_disable(void);



1) Not sure what you want, can you rephrase it with examples?
2) Maybe it is what ACTION_MODS_ONESHOT does. Why don't you try it first?
3) It looks reasonable and useful. Implement it! Not so hard, I think.

As for action_util.h it looks true. Send pull request to https://github.com/tmk/tmk_core if possible.
Title: Re: TMK keyboard firmware
Post by: chupanibre on Fri, 20 May 2016, 04:58:35
hi, and thanks for making this firmware, it's working great!

i have a question about "ghosting", my keyboard sadly doesn't have diodes for every key.
that means, for example, if i hold "asd" and press "e", my keyboard also sends "qw" although these keys aren't pressed.
is there anything i can do to prevent these false keypresses with software?
i've seen the "MATRIX_HAS_GHOST" parameter, but found no further explanation in the readme files.

it's not a big deal, but if there's an easy fix for this i'd be happy to know!
Title: Re: TMK keyboard firmware
Post by: hasu on Fri, 20 May 2016, 06:46:15
It should be what you need. Try it and contribute missing document for this.

Sent from my Nexus 5X using Tapatalk

Title: Re: TMK keyboard firmware
Post by: alienman82 on Fri, 20 May 2016, 18:12:09
removed.
Title: Re: TMK keyboard firmware
Post by: BlueNalgene on Fri, 20 May 2016, 18:24:32
Hello friends,

I'm currently bringing new life to the old Soviet Izot Magnetic Reed Switch terminal keyboard. For some reasons, I've decided to create the new Teensy-based PCB for this monster.

So, I've got a bunch of very old-fashioned key legend combinations. And following symbol pairs are sharing the same keys: 2 and ", 6 and &, 7 and ', 8 and (, 9 and ), ; and +, : and *. Also, there are @ and ^ at non-shifted positions. How to implement this layout using TMK?

As far as I've got, I could use Fn keys for that purpose. But what I don't understand is how to assign the different meanings for these keys at the normal and shifted positions? Is it possible after all?

Thank you in advance for the answers!

And here is the layout itself, the troublesome keys have red outlines:

(Attachment Link)

This sounds like a neat project.  Unfortunately, you cannot change how shift treats keys with TMK afaik.  To do something like that, you would need to write some extra code from scratch telling the firmware to treat the 'shift' key as something like 'shift2'.  You then define in a header the shift2 is actually meant to do all of these crazy things one by one. 

With TMK, you could do something similar quite simply.  What you are looking for are function layers.  You could tell the keyboard to treat the 'shift' key as 'fn1' where fn1 brings up a new layer with the things you want.  You might be able have that second layer give caps versions of the non-special letters by, for example, telling the keyboard when layer fn1 is activated and the "x" key is pressed to send "shift+x".  I'm not sure how you would implement that in the code though.
Title: Re: TMK keyboard firmware
Post by: hasu on Fri, 20 May 2016, 18:48:41
Hasu, I am using the alps64 hex generator website:

http://www.tmk-kbd.com/tmk_keyboard/editor/alps64/index.html

I cannot get left or right alt keys to work on any layers or keys.  I have tested the all the switches for various other commands, and they seem to work fine.  I even mapped L7 to a key and alt to that same key, but that didn't work. Need my alt + tab T_T

X-post

You cannot do that at this time at least, I have a plan to improve this limitation but not soon.


Can building firmware without the tool fix this??

Not sure exactly your problem. Can you post editor URL for your keymap?

http://bit.ly/1W11EAl

My issue is not a macro.  I cannot get 'alt' to work for any keys on the keyboard
I don't see any ALT on your keymap.

Describe what you want to do and your problem in detail using example, use case or scenario.

Sent from my Nexus 5X using Tapatalk

Title: Re: TMK keyboard firmware
Post by: alienman82 on Fri, 20 May 2016, 18:51:07
removed.
Title: Re: TMK keyboard firmware
Post by: hasu on Fri, 20 May 2016, 19:02:49
Ha, your keymap works completely to me, lol.
Downloaded your keymap and flashed it on my Alps64 and it works! :D

Then, your problem is reltated to your hardware, OS setting or ...
Title: Re: TMK keyboard firmware
Post by: alienman82 on Fri, 20 May 2016, 19:29:38
removed.
Title: Re: TMK keyboard firmware
Post by: chupanibre on Sat, 21 May 2016, 05:43:38
Try it
ok, i simply put the line #define MATRIX_HAS_GHOST in the config.h file and recompiled. turns out that was all i needed to do :) i wasn't sure if it would work because the (commented) line is not present in the ps2/usb converter code. it doesn't completely solve the problem (only diodes will, i guess), but the situation is slightly improved. most of the "ghosts" are gone. there are still some cases of wrong keypresses, but no more "ghost rows". for example "asd" + "e" now gives me "sdq" (before "asdqwe"). of course, my other keyboard with full nkro gets limited by this as well if i don't recompile the firmware without the parameter..
and contribute missing document for this.
umm.. does the above qualify..?
Title: Re: TMK keyboard firmware
Post by: hasu on Sat, 21 May 2016, 07:04:56
Oh, wait. are you using converter? You should have said about this first!
Ghost block code doesn't work on converter at all. I'm suprised at the fact your keyboard has no ghost block code, I didn't even know such keyboard exists. It sucks. I'm curious about what your keyboard is in fact.
Title: Re: TMK keyboard firmware
Post by: skullydazed on Sat, 21 May 2016, 08:22:54
Hello friends,

I'm currently bringing new life to the old Soviet Izot Magnetic Reed Switch terminal keyboard. For some reasons, I've decided to create the new Teensy-based PCB for this monster.

So, I've got a bunch of very old-fashioned key legend combinations. And following symbol pairs are sharing the same keys: 2 and ", 6 and &, 7 and ', 8 and (, 9 and ), ; and +, : and *. Also, there are @ and ^ at non-shifted positions. How to implement this layout using TMK?

As far as I've got, I could use Fn keys for that purpose. But what I don't understand is how to assign the different meanings for these keys at the normal and shifted positions? Is it possible after all?

Thank you in advance for the answers!

And here is the layout itself, the troublesome keys have red outlines:

(Attachment Link)

That's a national layout, and you probably don't want to program the keys to send the US equivalents of those characters.

Quick 10,000 ft view- when you press a key on your keyboard it doesn't send a character. Instead it sends a scan code, which is just a number corresponding to that particular button. Your OS will read that scancode and then convert it to a character. So when you press the number 2 on any keyboard it always sends the same scancode, even if you have a french azerty keyboard that will type é instead.

In your case, you probably want to configure your number row to send the same numbers as any other keyboard. Then you'll need to configure your OS to use a keyboard input language that corresponds to the keyboard you're using.

If you want to design your keyboard so it sends the corresponding characters even while your computer is configured for standard QWERTY input, you will need to define a lot of macros, and replace your shift key with an Fn instead. I do not recommend this approach as you will spend a lot of time putting it together and troubleshooting it to get the behavior right.
Title: Re: TMK keyboard firmware
Post by: chupanibre on Sat, 21 May 2016, 12:57:50
Oh, wait. are you using converter? You should have said about this first!
Ghost block code doesn't work on converter at all.
well, it does, at least a little. like i said, it improves the ghosting a bit, "worst case" key combinations now only produce one false keypress instead of a row. and in some situations, it successfully blocks the wrong key and delivers the rest. works, but not perfectly.
Quote
I'm curious about what your keyboard is in fact.
here's the current (desolate) state of affairs: http://imgur.com/cqUPx1t
i don't have the enclosure, the only lettering on the pcb is "OTC". looks like it's a cousin of the otc ok-keyboard 100m, it has a similar mounting plate but mine has complicated white alps.
it was meant as a testing bed for layouts and keycaps, but i do like the current configuration a lot. all the letter keys had their clicky/tactile plate removed, the rest is unmodified (but cleaned and lubed). and the ghosting thing hasn't been a noticeable issue so far..

also,
Quote
It sucks.
hey!! :'(:'(:'(
Title: Re: TMK keyboard firmware
Post by: firerock on Sat, 21 May 2016, 18:51:37
BlueNalgene, skullydazed, thank you for the valuable info!
OK then, I'll make the standard layout and when everything will work fine, I'll create the custom Windows layout for those peculiar combos.
So, now I have to wait until the PCB will be shipped as well as other parts I've ordered.
And when I'll be done, I'll definitely post my build report!
Title: Re: TMK keyboard firmware
Post by: TD22057 on Sun, 22 May 2016, 20:46:08
FYI - in case anyone cares... I've implemented oneshot mods functions to toggle oneshots mods on and off globally.  The branch is here (https://github.com/TD22057/tmk_keyboard/tree/oneshot_toggle) and the pull request is here (https://github.com/tmk/tmk_keyboard/pull/350).  This allows me to declare all my mods as oneshots and then toggle that behavior on and off with a key on one of my function layers.

Quote
This branch implements the following functions to control oneshot behavior and adds an action macro ACTION_MODS_ONESHOT_TOGGLE() to call the toggle function.

    oneshot_toggle()
    oneshot_enable()
    oneshot_disable()

If oneshot is disabled, then any key marked as oneshot behaves normally. When oneshot is enabled (the default), keys marked as oneshot work that way. It does not turn any modifier into a oneshot modifier - only mods marked that way in the action map will work as oneshots. This just allows that behavior to be turned off if desired.

This makes it easy to experiment in a keymap with oneshot modifiers. They can be declared as oneshot mods and another key can be designated to turn the oneshot behavior on and off. So the deciding to use oneshots or not is a software switch controlled from the keyboard instead of requiring a change to the firmware.
Title: Re: TMK keyboard firmware
Post by: shaymdev on Fri, 27 May 2016, 23:53:19
I'm working with the Adafruit Feather 32u4 Bluefruit LE. pinout (https://cdn-learn.adafruit.com/assets/assets/000/030/931/original/2889_pinout_v1_0.pdf?1457306379) and product (https://www.adafruit.com/products/2829) link

 My end goal is to use TMK with the bluetooth from the board. It's been almost a year since I did this for my first custom build (using a teensy 2)and now I'm having trouble with this microcontroller. As a starting point I'm trying to get TMK working with the "onekey" keyboard but I can't even get that working. I'm using the onekey from tmk as of a day ago (with one change to use pin f0 and f1).

I'm using avrdude to program the board with the hex file. When I push the bootloader button on the board and run lsusb I see the board

Code: [Select]
Bus 003 Device 046: ID 239a:000c
but once the device is programmed I don't get anything in lsusb for it and I can't get hid_listen to find the device (just continues waiting for a device).
I'm on Ubuntu 14.04. I've created the /etc/udev/rules.d/52-tmk-keyboard.rules with the following:
Code: [Select]
SUBSYSTEMS=="usb", ATTRS{idVendor}=="feed", MODE:="0666".

My other keyboard that's got tmk on a teensy is showing up in lsusb and can be read by hid_listen.

When use the same programming commands and push a hex I built from the adafruit tutorials with the arduino ide I can successfully program the board (it'll show in lsusb with the same 239a:000c entry as above and connect it via bluetooth to my phone). This leads me to believe it's maybe an issue with the udev type stuff. Oh, and when I plug it into a windows machine I get "usb device not recognized" errors.

Any suggestions would be greatly appreciated.
Title: Re: TMK keyboard firmware
Post by: hasu on Sat, 28 May 2016, 00:00:08
what Mhz Xtal does that product has? did you check its frequency?
Many projects in TMK is assuming it is 16MHz.
Title: Re: TMK keyboard firmware
Post by: shaymdev on Sat, 28 May 2016, 00:06:51
After days of trying and reading I decide to post the question then find a solution 2 minutes later... :-[

Sounds like one of these. http://www.adafruit.com/products/2661

Probably need to set the CPU frequency to 8Mhz in your makefile.


hrm... just tried setting: 

F_CPU = 8000000


This worked for me! Oh it was an exciting moment.

Now I'm going to explore the bluetooth side of things. I'll probably start by using the bluetooth hid tutorial from adafruit (https://github.com/adafruit/Adafruit_BluefruitLE_nRF51/tree/master/examples/hidkeyboard) and see what kind of integration I can get with tmk. From what I can tell this type of stuff hasn't been done yet (my searches have indicated some people starting to look into but not getting very far). If I'm reinventing the wheel please let me know!

edit: woah, and I was ninja post'd by hasu. Thanks, for your lightning speed!
Title: Re: TMK keyboard firmware
Post by: TD22057 on Sat, 28 May 2016, 16:34:52
Has anyone tried out the chibios version on a Teensy 3.2?  I've been struggling all afternoon to solder D+ and D- to the mini usb connector on my Teensy 2.0 (I don't have enough space in my case for the giant connector that's in the mini usb cables) and have basically given up.  The 3.2 has the USB connectors as pads on the bottom which would solve this in a trivial fashion if I can use it.
Title: Re: TMK keyboard firmware
Post by: a-c on Sat, 28 May 2016, 17:27:56
Has anyone tried out the chibios version on a Teensy 3.2?  I've been struggling all afternoon to solder D+ and D- to the mini usb connector on my Teensy 2.0 (I don't have enough space in my case for the giant connector that's in the mini usb cables) and have basically given up.  The 3.2 has the USB connectors as pads on the bottom which would solve this in a trivial fashion if I can use it.


Would something like what they do on the ergodox work? https://keyboard-configurator.massdrop.com/ext/ergodox/assembly.php Scroll down to step 7.
Title: Re: TMK keyboard firmware
Post by: TD22057 on Sat, 28 May 2016, 18:04:56
Would something like what they do on the ergodox work? https://keyboard-configurator.massdrop.com/ext/ergodox/assembly.php Scroll down to step 7.

That's what I've been trying.  I cut up different USB cables and they were both a little larger than the one shown there which is bigger than my case can deal with.  I need a solution that doesn't have the large metal connector.  I managed to pull out the plastic tray the pins sit in inside that connector but the solder points are very small and I can't get a reliable connection to it.  My soldering skills just aren't as good as I thought they were...
Title: Re: TMK keyboard firmware
Post by: Eszett on Mon, 30 May 2016, 18:20:47
I'd like to have rows as "output high", and cols as "input low", how do i have to alter these two passages of the code?
Code: [Select]
static matrix_row_t read_cols(void)
{
    return (PINB&(1<<3) ? 0 : (1UL<<0)) |
           (PINB&(1<<2) ? 0 : (1UL<<1)) |
           (PINB&(1<<1) ? 0 : (1UL<<2)) |
           (PINB&(1<<0) ? 0 : (1UL<<3)) |
           (PINC&(1<<7) ? 0 : (1UL<<4)) |
           (PINF&(1<<0) ? 0 : (1UL<<5)) |
           (PINF&(1<<1) ? 0 : (1UL<<6)) |
           (PINF&(1<<4) ? 0 : (1UL<<7)) |
           (PINF&(1<<5) ? 0 : (1UL<<) |
           (PINF&(1<<6) ? 0 : (1UL<<9)) |
           (PINF&(1<<7) ? 0 : (1UL<<10)) |
           (PINC&(1<<6) ? 0 : (1UL<<11)) |
           (PINB&(1<<6) ? 0 : (1UL<<12)) |
           (PINB&(1<<5) ? 0 : (1UL<<13)) |
           (PINB&(1<<4) ? 0 : (1UL<<14)) |
           (PIND&(1<<7) ? 0 : (1UL<<15)) |
           (PIND&(1<<6) ? 0 : (1UL<<16)) ;
}
and
Code: [Select]
static void unselect_rows(void)
{
    DDRD  &= ~0b00101111;
    PORTD &= ~0b00101111;
}
Title: Re: TMK keyboard firmware
Post by: rondg on Mon, 30 May 2016, 22:01:42
Hi there!

I am planning to make a keyboard and use TMK for the firmware. The layout will be similar to lightsaver. If I plan to add in-switch/underglow leds,  later on the build, how do I go about the keyboard matrix? I believe that the layout is 19x6, with approx 100 keys. Will it be simpler to use Teensy++ 2.0? Or should I just use Teensy 2.0 and make a 10x10 matrix? Is there a better approach?
Title: Re: TMK keyboard firmware
Post by: alexjd99 on Tue, 31 May 2016, 22:03:39
So I've been trying to figure out how to use this for a while to program my gh60, and I've looked all over for tutorials, and I still can't figure out how to use this at all. I have all the files downloaded and everything sorted out, but I can't figure out how to make my own layout for the life of me.

Does anyone have any recommendation on a tutorial/guide on how to use this? I'm pretty confused with everything after trying for a few days and making no progress at all (I'm also using windows so preferably a windows guide)
Title: Re: TMK keyboard firmware
Post by: RavenII on Wed, 01 June 2016, 09:36:21
So I've been trying to figure out how to use this for a while to program my gh60, and I've looked all over for tutorials, and I still can't figure out how to use this at all. I have all the files downloaded and everything sorted out, but I can't figure out how to make my own layout for the life of me.

Does anyone have any recommendation on a tutorial/guide on how to use this? I'm pretty confused with everything after trying for a few days and making no progress at all (I'm also using windows so preferably a windows guide)

Well, for starters, what does "Everything sorted out" mean? You've got all your prereqs installed? Compiler, etc? What OS are you on? What have you tried?
Title: Re: TMK keyboard firmware
Post by: netdudeuk on Wed, 01 June 2016, 13:19:58
Hi

I'm using the IBM Model M version of the TMK code to try and hook up an old USB keyboard with a PS2 adapter to my PC via an Arduino Micro and an Adafruit EZ-Key.

I can pair ok and send key presses from the pre-programmed input pins.

The keyboard looks to be reset by the Micro and I see this in the debugging output -

started logging
[ Initializing PS2 matrix ]
setting global host driver
wFF [ack]
RESET_RESPONSE: rAA [ok]
KBD_ID:

Adafruit Bluefruit HID v1.2 5/12/2014

Attempt to connect to 9,dd,500e7e
Connected
NL:Y CL:N SL:N


When I press the main ENTER key, I get loads of output like this -


r5A rF0
CODESET_QUERY: wF0 [ack] w00 [codeset] FA [ack]
CODESET_RESPONSE: r02 02 [ok]
CODESET_REQUEST: wF0 [ack] w03 [ok]
CODESET_QUERY: wF0 [ack] w00 [codeset] FA [ack]
CODESET_RESPONSE: r02 02 [ok]
CODESET_REQUEST: wF0 [ack] w03 [ok]
CODESET_QUERY: wF0 [ack] w00 [codeset] FA [ack]
CODESET_RESPONSE: r02 02 [ok]
CODESET_REQUEST: wF0 [ack] w03 [ok]
CODESET_QUERY: wF0 [ack] w00 [codeset] FA [ack]
CODESET_RESPONSE: r02 02 [ok]
CODESET_REQUEST: wF0 [ack] w03 [ok]
CODESET_QUERY: wF0 [ack] w00 [codeset] FA [ack]
CODESET_RESPONSE: r02 02 [ok]
CODESET_REQUEST: wF0 [ack] w03 [ok]

and so on ...


I don't get a key press on the PC but the 5A F0 is encouraging as they do seem to relate to this ENTER key.

Any idea what the rest of the debug output implies and why I don't see the key press ?

Thanks

Title: Re: TMK keyboard firmware
Post by: hasu on Sat, 04 June 2016, 10:19:15
UPDATE:
papodaca's XT to USB converter was merged now.
https://github.com/tmk/tmk_keyboard/pull/355

https://github.com/tmk/tmk_keyboard/tree/master/converter/xt_usb
Title: Re: TMK keyboard firmware
Post by: Hypersphere on Fri, 10 June 2016, 07:21:53
I have a 60% keyboard with the Hasu Alps64 PCB, and I wish to use the excellent TMK editor to create a HHKB-like layout. However, I have been unsure what to do with two things:

1. How to designate keys that are on the editor map but not on my keyboard (such as the split Backspace and split left and right Shift keys).

2. How to designate a Fn key. For example, I would like to remap the RCtrl as Fn.

I have been told by a very knowledgeable source that for (1) I can either do nothing or use the "NO" designation. Likewise, for (2), I have been told to use L1 for Fn for layer 1, L2 for Fn for layer 2, etc. This certainly makes logical sense, but I wanted to check because the documentation can seem confusing for new users.

UPDATE: After some false starts trying to flash the chip with FLIP for Windows, I was about to move over to my Linux box, but I got things working. My first hex file was not quite correct, but I re-did it, and SUCCESS! I now have a custom brown Alps 60% board with a HHKB layout, complete with media controls.

For reasons unknown the Esc key is unresponsive, which I think is a hardware problem with the board, but I made a new Esc key by mapping Fn+E --> Esc.

Full programmability is definitely the way to go with keyboards. I hope that keyboard companies will start incorporating fully programmable chips using either TMK or their own systems for programming.

In any event, Thanks, Hasu! You have created a marvelous tool and made it relatively easy to use.

Title: Re: TMK keyboard firmware
Post by: climbalima on Fri, 10 June 2016, 17:41:28
Would adding laptop trackpad support work in the same way as trackpoint support?
Title: Re: TMK keyboard firmware
Post by: nephiel on Fri, 10 June 2016, 20:00:11
Would adding laptop trackpad support work in the same way as trackpoint support?
A touchpad? If it uses PS/2, then it should probably just work as a mouse, but some features such as multitouch or edge scrolling may not work.
Title: Re: TMK keyboard firmware
Post by: climbalima on Sat, 11 June 2016, 00:19:07
Would adding laptop trackpad support work in the same way as trackpoint support?
A touchpad? If it uses PS/2, then it should probably just work as a mouse, but some features such as multitouch or edge scrolling may not work.

Yeah. the only issue is that I cannot find the reset pin
Title: Re: TMK keyboard firmware
Post by: Kaibz on Sat, 11 June 2016, 05:53:34
I've been using tmk firmware with a teensy 2.0++ for more than a year now, however there is still something i don't understand.

About 1 time out of five, when i launch my computer (windows 7), with the keyboard connected, i get this screen:

(http://www.techjaws.com/wp-content/uploads/2010/03/win7-error-recovery.png)

Of course each time i have to choose "starts windows normally" and unplug the keyboard until windows is loaded, but is there a way to prevent this screen to show up ?

I know it's link to the keyboard as it does not happen if it is unplugged. I even tried changing the teensy, disabling NKRO....I just don't know what to do, please help !
Title: Re: TMK keyboard firmware
Post by: deductivemonkee on Tue, 14 June 2016, 19:12:51
I keep getting the error while compiling:
Code: [Select]
C:\Users\Matt\Desktop\tmk\keyboard\alps64>make flip
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
ECHO is off.
mkdir -p obj_alps64
Compiling C: keymap_plain.c
avr-gcc -c -mmcu=atmega32u2 -gdwarf-2 -DF_CPU=16000000UL -DINTERRUPT_CONTROL_ENDPOINT -DNO_LIMITED_CONTROLLER_CONNECT -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= -Os -funsigned-char -funsigned-bitfields -ffunction-sections -fdata-sections -fno-inline-small-functions -fpack-struct -fshort-enums -fno-strict-aliasing -Wall -Wstrict-prototypes -Wa,-adhlns=obj_alps64/keymap_plain.lst -IC -I/Users/Matt/Desktop/tmk/keyboard/alps64 -IC -I/Users/Matt/Desktop/tmk/tmk_core -IC -I/Users/Matt/Desktop/tmk/tmk_core/protocol/lufa -IC -I/Users/Matt/Desktop/tmk/tmk_core/protocol/lufa/LUFA-git -IC -I/Users/Matt/Desktop/tmk/tmk_core/common -std=gnu99 -include config.h -MMD -MP -MF .dep/obj_alps64_keymap_plain.o.d  keymap_plain.c -o obj_alps64/keymap_plain.o
keymap_plain.c:41:1: fatal error: opening dependency file .dep/obj_alps64_keymap_plain.o.d: No such file or directory
 };
 ^
compilation terminated.
C:/Users/Matt/Desktop/tmk/tmk_core/rules.mk:550: recipe for target 'obj_alps64/keymap_plain.o' failed
make: *** [obj_alps64/keymap_plain.o] Error 1

Any ideas?
Title: Re: TMK keyboard firmware
Post by: hasu on Tue, 14 June 2016, 19:32:58
I keep getting the error while compiling:
Code: [Select]
C:\Users\Matt\Desktop\tmk\keyboard\alps64>make flip
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
ECHO is off.
mkdir -p obj_alps64
Compiling C: keymap_plain.c
avr-gcc -c -mmcu=atmega32u2 -gdwarf-2 -DF_CPU=16000000UL -DINTERRUPT_CONTROL_ENDPOINT -DNO_LIMITED_CONTROLLER_CONNECT -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= -Os -funsigned-char -funsigned-bitfields -ffunction-sections -fdata-sections -fno-inline-small-functions -fpack-struct -fshort-enums -fno-strict-aliasing -Wall -Wstrict-prototypes -Wa,-adhlns=obj_alps64/keymap_plain.lst -IC -I/Users/Matt/Desktop/tmk/keyboard/alps64 -IC -I/Users/Matt/Desktop/tmk/tmk_core -IC -I/Users/Matt/Desktop/tmk/tmk_core/protocol/lufa -IC -I/Users/Matt/Desktop/tmk/tmk_core/protocol/lufa/LUFA-git -IC -I/Users/Matt/Desktop/tmk/tmk_core/common -std=gnu99 -include config.h -MMD -MP -MF .dep/obj_alps64_keymap_plain.o.d  keymap_plain.c -o obj_alps64/keymap_plain.o
keymap_plain.c:41:1: fatal error: opening dependency file .dep/obj_alps64_keymap_plain.o.d: No such file or directory
 };
 ^
compilation terminated.
C:/Users/Matt/Desktop/tmk/tmk_core/rules.mk:550: recipe for target 'obj_alps64/keymap_plain.o' failed
make: *** [obj_alps64/keymap_plain.o] Error 1

Any ideas?

If you are using old WinAVR use other new tool. it doesn't support ATMega32u2 of Alps64 PCB.
If you are editting  keymap_plain.c something is wrong there. Check your change again.
Title: Re: TMK keyboard firmware
Post by: mrbishop on Tue, 14 June 2016, 19:56:05
having some issues. everything works GREAT except for column 6 which is "5,r,f,c"
when i plug the keyboard in it immediately outputs "
5rfccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc" until i hit keys to interrupt it
all this was on pin D6
moved to pin C6
same long string output but without firmware update it wont output any key presses but that doesn't surprise me since i haven't flashed it since the pin move.
this feels like a programming issue or two things trying to use that D6 pin

last time i tried to compile i get an error on keymap_plain.c so something is wrong there.

if anyone could help with the errors and weird column issues that would be really awesome. attached is my build folder.

thanks in advance
Title: Re: TMK keyboard firmware
Post by: a-c on Tue, 14 June 2016, 21:44:19
led.c is conflicting with your matrix B2

having some issues. everything works GREAT except for column 6 which is "5,r,f,c"
when i plug the keyboard in it immediately outputs "
5rfccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc" until i hit keys to interrupt it
all this was on pin D6
moved to pin C6
same long string output but without firmware update it wont output any key presses but that doesn't surprise me since i haven't flashed it since the pin move.
this feels like a programming issue or two things trying to use that D6 pin

last time i tried to compile i get an error on keymap_plain.c so something is wrong there.

if anyone could help with the errors and weird column issues that would be really awesome. attached is my build folder.

thanks in advance
Title: Re: TMK keyboard firmware
Post by: deductivemonkee on Tue, 14 June 2016, 22:03:00
I keep getting the error while compiling:
Code: [Select]
C:\Users\Matt\Desktop\tmk\keyboard\alps64>make flip
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
ECHO is off.
mkdir -p obj_alps64
Compiling C: keymap_plain.c
avr-gcc -c -mmcu=atmega32u2 -gdwarf-2 -DF_CPU=16000000UL -DINTERRUPT_CONTROL_ENDPOINT -DNO_LIMITED_CONTROLLER_CONNECT -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= -Os -funsigned-char -funsigned-bitfields -ffunction-sections -fdata-sections -fno-inline-small-functions -fpack-struct -fshort-enums -fno-strict-aliasing -Wall -Wstrict-prototypes -Wa,-adhlns=obj_alps64/keymap_plain.lst -IC -I/Users/Matt/Desktop/tmk/keyboard/alps64 -IC -I/Users/Matt/Desktop/tmk/tmk_core -IC -I/Users/Matt/Desktop/tmk/tmk_core/protocol/lufa -IC -I/Users/Matt/Desktop/tmk/tmk_core/protocol/lufa/LUFA-git -IC -I/Users/Matt/Desktop/tmk/tmk_core/common -std=gnu99 -include config.h -MMD -MP -MF .dep/obj_alps64_keymap_plain.o.d  keymap_plain.c -o obj_alps64/keymap_plain.o
keymap_plain.c:41:1: fatal error: opening dependency file .dep/obj_alps64_keymap_plain.o.d: No such file or directory
 };
 ^
compilation terminated.
C:/Users/Matt/Desktop/tmk/tmk_core/rules.mk:550: recipe for target 'obj_alps64/keymap_plain.o' failed
make: *** [obj_alps64/keymap_plain.o] Error 1

Any ideas?

If you are using old WinAVR use other new tool. it doesn't support ATMega32u2 of Alps64 PCB.
If you are editting  keymap_plain.c something is wrong there. Check your change again.

I was using cygwin and flip. I will check my code and report back :thumb:
Title: Re: TMK keyboard firmware
Post by: mrbishop on Tue, 14 June 2016, 22:04:18
led.c is conflicting with your matrix B2

having some issues. everything works GREAT except for column 6 which is "5,r,f,c"
when i plug the keyboard in it immediately outputs "
5rfccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc" until i hit keys to interrupt it
all this was on pin D6
moved to pin C6
same long string output but without firmware update it wont output any key presses but that doesn't surprise me since i haven't flashed it since the pin move.
this feels like a programming issue or two things trying to use that D6 pin

last time i tried to compile i get an error on keymap_plain.c so something is wrong there.

if anyone could help with the errors and weird column issues that would be really awesome. attached is my build folder.

thanks in advance

i noticed that, and yes it needs to be corrected but would that effect the D6 pin or the other pins in this column's keys? that particular row's keys work fine. but i agree it needs to be fixed.
Title: Re: TMK keyboard firmware
Post by: mrbishop on Tue, 14 June 2016, 22:36:35
led.c is conflicting with your matrix B2

having some issues. everything works GREAT except for column 6 which is "5,r,f,c"
when i plug the keyboard in it immediately outputs "
5rfccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc" until i hit keys to interrupt it
all this was on pin D6
moved to pin C6
same long string output but without firmware update it wont output any key presses but that doesn't surprise me since i haven't flashed it since the pin move.
this feels like a programming issue or two things trying to use that D6 pin

last time i tried to compile i get an error on keymap_plain.c so something is wrong there.

if anyone could help with the errors and weird column issues that would be really awesome. attached is my build folder.

thanks in advance

i noticed that, and yes it needs to be corrected but would that effect the D6 pin or the other pins in this column's keys? that particular row's keys work fine. but i agree it needs to be fixed.

flashed the firmware with the C6 pin move and the LED B2 pin changed and all seems well now really strange

thanks for all who are looking into this anyway :)
Title: Re: TMK keyboard firmware
Post by: a-c on Tue, 14 June 2016, 22:38:52
If this is a Teensy++ there is a LED attached to D6 probably pulled to ground through a resistor.

led.c is conflicting with your matrix B2

having some issues. everything works GREAT except for column 6 which is "5,r,f,c"
when i plug the keyboard in it immediately outputs "
5rfccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc" until i hit keys to interrupt it
all this was on pin D6
moved to pin C6
same long string output but without firmware update it wont output any key presses but that doesn't surprise me since i haven't flashed it since the pin move.
this feels like a programming issue or two things trying to use that D6 pin

last time i tried to compile i get an error on keymap_plain.c so something is wrong there.

if anyone could help with the errors and weird column issues that would be really awesome. attached is my build folder.

thanks in advance

i noticed that, and yes it needs to be corrected but would that effect the D6 pin or the other pins in this column's keys? that particular row's keys work fine. but i agree it needs to be fixed.
Title: Re: TMK keyboard firmware
Post by: mrbishop on Tue, 14 June 2016, 22:42:59
it is very much a teensy ++

this is a full key keyboard https://geekhack.org/index.php?topic=82671.0 (https://geekhack.org/index.php?topic=82671.0)

typing on it now.
thanks again for taking a look and the knowledge about the D6 pin

If this is a Teensy++ there is a LED attached to D6 probably pulled to ground through a resistor.

led.c is conflicting with your matrix B2

having some issues. everything works GREAT except for column 6 which is "5,r,f,c"
when i plug the keyboard in it immediately outputs "
5rfccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc" until i hit keys to interrupt it
all this was on pin D6
moved to pin C6
same long string output but without firmware update it wont output any key presses but that doesn't surprise me since i haven't flashed it since the pin move.
this feels like a programming issue or two things trying to use that D6 pin

last time i tried to compile i get an error on keymap_plain.c so something is wrong there.

if anyone could help with the errors and weird column issues that would be really awesome. attached is my build folder.

thanks in advance

i noticed that, and yes it needs to be corrected but would that effect the D6 pin or the other pins in this column's keys? that particular row's keys work fine. but i agree it needs to be fixed.
Title: Re: TMK keyboard firmware
Post by: a-c on Tue, 14 June 2016, 23:00:41
Don't forget to change the bootloader size in the Makefile.

it is very much a teensy ++

this is a full key keyboard https://geekhack.org/index.php?topic=82671.0 (https://geekhack.org/index.php?topic=82671.0)

typing on it now.
thanks again for taking a look and the knowledge about the D6 pin
Title: Re: TMK keyboard firmware
Post by: mrbishop on Tue, 14 June 2016, 23:03:04
Don't forget to change the bootloader size in the Makefile.

it is very much a teensy ++

this is a full key keyboard https://geekhack.org/index.php?topic=82671.0 (https://geekhack.org/index.php?topic=82671.0)

typing on it now.
thanks again for taking a look and the knowledge about the D6 pin

it was changed to the 90USB1268 or were you talking about something else?

update just checked its set to 4096 but eveything is working currently. what are the issues that could become if this is not changed to  Teensy++ halfKay 1024
Title: Re: TMK keyboard firmware
Post by: a-c on Wed, 15 June 2016, 12:14:36
Using the Bootmagic or Magic key combo to jump to bootloader will probably not work. Convenient if you don't want to leave a hole in your case to access the reset button.

Don't forget to change the bootloader size in the Makefile.

it is very much a teensy ++

this is a full key keyboard https://geekhack.org/index.php?topic=82671.0 (https://geekhack.org/index.php?topic=82671.0)

typing on it now.
thanks again for taking a look and the knowledge about the D6 pin

it was changed to the 90USB1268 or were you talking about something else?

update just checked its set to 4096 but eveything is working currently. what are the issues that could become if this is not changed to  Teensy++ halfKay 1024
Title: Re: TMK keyboard firmware
Post by: mrbishop on Wed, 15 June 2016, 12:24:07
Using the Bootmagic or Magic key combo to jump to bootloader will probably not work. Convenient if you don't want to leave a hole in your case to access the reset button.

Don't forget to change the bootloader size in the Makefile.

it is very much a teensy ++

this is a full key keyboard https://geekhack.org/index.php?topic=82671.0 (https://geekhack.org/index.php?topic=82671.0)

typing on it now.
thanks again for taking a look and the knowledge about the D6 pin

it was changed to the 90USB1268 or were you talking about something else?

update just checked its set to 4096 but eveything is working currently. what are the issues that could become if this is not changed to  Teensy++ halfKay 1024

i already made a hole for it in the design. good to know tho :) :thumb:
Title: Re: TMK keyboard firmware
Post by: Hypersphere on Wed, 15 June 2016, 12:35:25
I wanted to add a cautionary note about winavr. I learned the hard way to take care when installing this. When I installed winavr, without thinking, I accepted its offer to modify my path. It overwrote my path, leaving only the path to itself. Luckily, I was able to restore my path by using regedit -- this process becomes much more difficult if you have rebooted your machine more than once after the install. It appears that winavr was last updated in 2010.

My own preference is to use linux to do things like compiling code, using either a dedicated linux machine or a linux VM. However, for things like flashing a chip, I have found that Atmel FLIP in Windows works nicely.
Title: Re: TMK keyboard firmware
Post by: deductivemonkee on Wed, 15 June 2016, 18:13:23
I keep getting the error while compiling:
Code: [Select]
C:\Users\Matt\Desktop\tmk\keyboard\alps64>make flip
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
ECHO is off.
mkdir -p obj_alps64
Compiling C: keymap_plain.c
avr-gcc -c -mmcu=atmega32u2 -gdwarf-2 -DF_CPU=16000000UL -DINTERRUPT_CONTROL_ENDPOINT -DNO_LIMITED_CONTROLLER_CONNECT -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= -Os -funsigned-char -funsigned-bitfields -ffunction-sections -fdata-sections -fno-inline-small-functions -fpack-struct -fshort-enums -fno-strict-aliasing -Wall -Wstrict-prototypes -Wa,-adhlns=obj_alps64/keymap_plain.lst -IC -I/Users/Matt/Desktop/tmk/keyboard/alps64 -IC -I/Users/Matt/Desktop/tmk/tmk_core -IC -I/Users/Matt/Desktop/tmk/tmk_core/protocol/lufa -IC -I/Users/Matt/Desktop/tmk/tmk_core/protocol/lufa/LUFA-git -IC -I/Users/Matt/Desktop/tmk/tmk_core/common -std=gnu99 -include config.h -MMD -MP -MF .dep/obj_alps64_keymap_plain.o.d  keymap_plain.c -o obj_alps64/keymap_plain.o
keymap_plain.c:41:1: fatal error: opening dependency file .dep/obj_alps64_keymap_plain.o.d: No such file or directory
 };
 ^
compilation terminated.
C:/Users/Matt/Desktop/tmk/tmk_core/rules.mk:550: recipe for target 'obj_alps64/keymap_plain.o' failed
make: *** [obj_alps64/keymap_plain.o] Error 1

Any ideas?

If you are using old WinAVR use other new tool. it doesn't support ATMega32u2 of Alps64 PCB.
If you are editting  keymap_plain.c something is wrong there. Check your change again.

I was using cygwin and flip. I will check my code and report back :thumb:

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

const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {

    [0] = KEYMAP( \
        ESC, 1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   MINS,EQL, NO, 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,NO,Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, SLSH,RSFT,NO, \
        LCTL,FN0,LALT,          SPC,                     APP, RALT,FN1,RCTRL),
    [1] = KEYMAP( \
        GRV, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12, NO, DEL, \
        TRNS,TRNS,UP,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS, TRNS,TRNS, \
        TRNS,LEFT,DOWN,RIGHT,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \
        TRNS,NO,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS,TRNS,TRNS,NO, \
        TRNS,TRNS,TRNS,          TRNS,                    TRNS,TRNS,TRNS,TRNS),
    [2] = KEYMAP( \
        GRV, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12, NO, DEL, \
        TRNS,TRNS,TRNS,TRNS,INS,HOME,PGUP,TRNS,UP,TRNS,TRNS, TRNS, TRNS,TRNS, \
        TRNS,TRNS,TRNS,TRNS,DEL,END,PGDN,LEFT,DOWN,RIGHT,TRNS,TRNS,TRNS, \
        TRNS,NO,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,MUTE, VOLD,VOLU,TRNS,NO, \
        TRNS,TRNS,TRNS,          MPLY,                    TRNS,TRNS,TRNS,TRNS),
};

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


Am I not seeing something? It all looks correct to me...

EDIT: I tried to compile with hasu's keymap, same error. There is an error in the Makefile I am assuming.
Title: Re: TMK keyboard firmware
Post by: hasu on Wed, 15 June 2016, 18:38:39
Deductivemonkee,
hmm, your keymap code seems to be ok.
What is you gcc actually? Can you post output of 'avr-gcc -v'?
I'm still gussing you are using old gcc which doesn't support the controller from WINAVR.
Title: Re: TMK keyboard firmware
Post by: deductivemonkee on Wed, 15 June 2016, 18:56:19
Deductivemonkee,
hmm, your keymap code seems to be ok.
What is you gcc actually? Can you post output of 'avr-gcc -v'?
I'm still gussing you are using old gcc which doesn't support the controller from WINAVR.

That's the only text that my terminal spat out, I was using MHV, I will try atmel studio instead.
Title: Re: TMK keyboard firmware
Post by: deductivemonkee on Wed, 15 June 2016, 19:17:26
I am using atmel avr toolchain now, and it spits out the same code. I think that there is an error in the Makefile. Also, what is keymap_editor and Makefile.keymap_editor?
Title: Re: TMK keyboard firmware
Post by: hasu on Wed, 15 June 2016, 20:03:51
hmm, I copied your keymap code into file name keymap_test.c and I could compilied  it with 'make KEYMAP=test' without any problem. I'm using avr-gcc4.9.2 and avr-libc1.8.0 on ubuntu and Atmel AVR toolchan 3.5.0 on windows10.

Running 'make clean' then 'make' is not helpful?

They are used to build firmware for keymap editor. You don't have to use them usually.
Title: Re: TMK keyboard firmware
Post by: deductivemonkee on Wed, 15 June 2016, 20:09:34
I am using atmel studio and I get this error with anything. I even tried to compile the base gh60 code.
This is the error when i run'make'
Code: [Select]
C:\Users\Matt\Desktop\tmk\keyboard\alps64>make
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
ECHO is off.
-------- begin --------
avr-gcc (AVR_8_bit_GNU_Toolchain_3.5.2_1680) 4.9.2
Copyright (C) 2014 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.
C:/Users/Matt/Desktop/tmk/tmk_core/rules.mk:395: recipe for target 'sizebefore' failed
make: *** [sizebefore] Error 255

C:\Users\Matt\Desktop\tmk\keyboard\alps64>
Title: Re: TMK keyboard firmware
Post by: hasu on Wed, 15 June 2016, 20:28:08
why are you using cmd.exe? I don't know if windows command prompt works for firmware build.

If you have Cygwin installed why don't you use bash? I think you have to just set path to Atmel  avr toolchain and run make.

EDIT: check this again.
https://github.com/tmk/tmk_keyboard/blob/master/tmk_core/doc/build.md#build-firmware-and-program-controller
Title: Re: TMK keyboard firmware
Post by: deductivemonkee on Wed, 15 June 2016, 20:34:30
why are you using cmd.exe? I don't know if windows command prompt works for firmware build.

If you have Cygwin installed why don't you use bash? I think you have to just set path to Atmel  avr toolchain and run make.

EDIT: check this again.
https://github.com/tmk/tmk_keyboard/blob/master/tmk_core/doc/build.md#build-firmware-and-program-controller

I was using atmel studio terminal, cygwin would't recognize make.
Title: Re: TMK keyboard firmware
Post by: hasu on Wed, 15 June 2016, 20:46:10
why are you using cmd.exe? I don't know if windows command prompt works for firmware build.

If you have Cygwin installed why don't you use bash? I think you have to just set path to Atmel  avr toolchain and run make.

EDIT: check this again.
https://github.com/tmk/tmk_keyboard/blob/master/tmk_core/doc/build.md#build-firmware-and-program-controller

I was using atmel studio terminal, cygwin would't recognize make.

ah, ok. I'll have to write the document more detail in step by step form when I got time.
Title: Re: TMK keyboard firmware
Post by: Morituri on Wed, 15 June 2016, 20:46:45
First of all I want to thank Hasu and everybody who has helped for this fantastic keyboard controller software.  I've got a keyboard build in mind to make a keyboard that is very different in functionality than most, so I really need to completely read this and completely understand it - and then start modding....   :D

First thing; is there any reason why buffering is not the best way to solve the 6KRO BIOS vs. NKRO keyboard problem?  If the user mashes fifteen keys in the time it takes to send one packet, why doesn't the keyboard buffer the unsent ones and send the next six of them 250 µseconds later in another packet and the last three 250 µseconds later in the packet after that?  I ask because first, it seems weird and complicated for the thing to claim to be two different keyboards.  Second, I'm going to have to implement buffering anyway to extend it to do user-defined long macro playbacks.  User-defined macros can be longer than 128 characters, so they'll potentially exceed single packets in the HID protocol anyway.

Second, I'm going to want to implement something like an asian input mode in the controller.  That means the keyboard does not emits its output until the keys are released.   Gamers hate it but typists doing complicated unicode documents love it, because it allows combining modifiers and combining accents without screwing about with an altgr key.
Title: Re: TMK keyboard firmware
Post by: hasu on Wed, 15 June 2016, 21:18:13
First thing; is there any reason why buffering is not the best way to solve the 6KRO BIOS vs. NKRO keyboard problem?  If the user mashes fifteen keys in the time it takes to send one packet, why doesn't the keyboard buffer the unsent ones and send the next six of them 250 µseconds later in another packet and the last three 250 µseconds later in the packet after that?  I ask because first, it seems weird and complicated for the thing to claim to be two different keyboards.  Second, I'm going to have to implement buffering anyway to extend it to do user-defined long macro playbacks.  User-defined macros can be longer than 128 characters, so they'll potentially exceed single packets in the HID protocol anyway.

Hi,
I'm not sure what "6KRO vs NKRO problem" and "keyboard buffer" you refered exactly are.
But I think most of keyboards have kind of buffer and send just one key event(press/release) per packet(HID keyboard report). If you send two events with a report host cannot recognize which key is first event and which is second.
Title: Re: TMK keyboard firmware
Post by: Morituri on Wed, 15 June 2016, 22:24:50
Actually I've never seen a system get confused about what order the keystrokes are in; it reads the packet from lowest (serial first) to highest (serial last) address and applies the strokes in order.  ALL strokes in the packet though will use the same combination of modifier bits.

6KRO vs NKRO is about the BIOS requiring a board with a "Bootable" mode for interacting with/configuring the BIOS, where it uses only small HID packets (which have room for no more than 6 keystrokes per packet, plus eight modifier-key bits).  It is supposed to emit a signal to the keyboard that boot is over, so the keyboard can start using extended HID codes and bigger packets if it wants to - but many BIOSes don't. 

If the bootable keyboard ever emits a larger packet, or a packet with an extended HID code, before the OS loads while doing BIOS configuration, the results are very unpredictable.  Mostly they ignore the whole packet, but some of them hang and have to be powered off because you can't get out of the BIOS setup, and a few of them (mostly Gateway) can hang with corrupted BIOS information.  That can make them crash so hard you have to flash the BIOS to get them to boot up ever again. 

Once the operating system loads, it is fully prepared to accept larger HID packets.  But the computer BIOS has to have sent the message for the keyboard to ever know that. So the keyboard controller, the BIOS, and the Operating System all have to agree on this or else whenever someone hits more than six keys too fast, the whole packet gets lost.  As a result most keyboard controllers never enable bigger packets, and implement 6-key rollover regardless of what the keyboard can sense.  If the user presses more than six keys at once some keystrokes get dropped on the floor, and the NKRO that gamers want for ridiculously time-sensitive play is reduced to 6KRO.

This is a nonissue with typing, but gamers sometimes actually do press more than six keys that fast, or trigger macros that try to. 
Title: Re: TMK keyboard firmware
Post by: Morituri on Wed, 15 June 2016, 22:45:55
I reread the USB specification. 

Now I understand the issue better. 

The Keyboard is constantly reporting the entire list of currently depressed keys - but the BIOS (in boot mode) is not guaranteed to be able to understand reports of more than six simultaneously pressed keys.

And therefore when someone has seven different keys all pressed at once, a USB keyboard if still in boot mode may report only six of them.  Once initialized the keyboard will get a Get_Protocol message that should allow it to switch from Boot Protocol to Report Protocol.  The Report protocol may use longer reports than the Boot Protocol, but most keyboards implement only the Boot Protocol and use it as the Report Protocol as well. 

The result is that they implement 6KRO, as that will fit into the Boot Protocol, and report a "Ghosting" state if a seventh key is simultaneously pressed. This causes Gamers to scream "augh!  I want my N-Key Rollover!"  and go find a PS/2 keyboard, which reports events rather than states and therefore handles NKRO just fine.  The alternatives are to actually have a Report Protocol that's different from the Boot Protocol, or to pretend to be more than one keyboard. 

Also, you are absolutely right that according to the spec the computer has no requirement to infer any sequence of operations within a packet.  If two events (key-up or key-down) have changed the state between moments when the state is  reported, the computer has the right to assume that these events happened in either order.  As far as I know there's nothing that ever handles it in any order other than lowest-to-highest, but ... you are correct to report states that differ by only a single event if it is important to the user to preserve sequence.
Title: Re: TMK keyboard firmware
Post by: Kaibz on Thu, 16 June 2016, 05:58:23
Does anyone have any idea why i get to the windows recovery screen when i let my TMK keyboard plugged when booting up? Or any hint of where the issue might come from or if anyone has had the same issue before?

The keyboard + TMK firmware works great otherwise, it's just that 1 time out of 5, when plugged in while windows is booting up, it brings me to the windows recovery screen.



Title: Re: TMK keyboard firmware
Post by: tokyo on Thu, 16 June 2016, 16:18:18
layer_state variable not seem to reflect currently active momentary layers, I am using 20160525 downloaded codes not latest
        [1] = ACTION_LAYER_TAP_KEY(2, KC_SPC)   //momentary layer
        [11] = ACTION_LAYER_TOGGLE(2),   //toggle layer, which works fine
  below is my code, see LSFT_DQT

Code: [Select]

#include "keymap_common.h"
#include "action_util.h"
#include "action_layer.h"


const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = {
       
       
    KEYMAP_ALL(
              F13, F14, F15, F16, F17, F18, F19, F20, F21, F22, F23, F24,

              ESC,      F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12,           PSCR,SLCK,PAUS,    VOLD,VOLU,MUTE,PWR,     HELP,
    GRV, 1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   MINS,EQL, JYEN,BSPC,     INS, HOME,PGUP,    NLCK,PSLS,PAST,PMNS,    STOP,AGIN,
    FN6, Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,   LBRC,RBRC,     BSLS,     DEL, END, PGDN,    P7,  P8,  P9,  PPLS,    MENU,UNDO,
    FN5,A,   S,   D,   F,   G,   H,   J,   K,   L,   SCLN,QUOT,     NUHS,ENT,                         P4,  P5,  P6,  PCMM,    SLCT,COPY,
    FN7,NUBS,Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, SLSH,     RO,  FN8,          UP,           P1,  P2,  P3,  PEQL,    EXEC,PSTE,
    LCTL,LGUI,LALT,FN2,HANJ,     FN1,      HAEN,FN0, FN3,RALT,RGUI,APP, RCTL,     LEFT,DOWN,RGHT,    P0,       PDOT,PENT,    FIND, CUT
    ),

   
   
    [1] = \
    KEYMAP_ALL(
              F13, F14, F15, F16, F17, F18, F19, F20, F21, F22, F23, F24,
    ESC,      F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12,           PSCR,SLCK,PAUS,    VOLD,VOLU,MUTE,PWR,     HELP,
    GRV, 1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   MINS,EQL, FN0,BSPC,     INS, HOME,PGUP,    NLCK,PSLS,PAST,PMNS,    STOP,AGIN,
    TRNS, TRNS,   FN15,   E,   FN19,   T,   Y,   U,   I,   O,   P,   LBRC,RBRC,     BSLS,     DEL, END, PGDN,    P7,  P8,  P9,  PPLS,    MENU,UNDO,
    CAPS,FN18,   FN17,   D,   F,   G,   H,   J,   K,   L,   SCLN,QUOT,     NUHS,ENT,                         P4,  P5,  P6,  PCMM,    SLCT,COPY,
    TRNS,TRNS,FN10,   TRNS,   FN16,   V,   B,   N,   M,   COMM,DOT, SLSH,     RO,  FN8,          UP,           P1,  P2,  P3,  PEQL,    EXEC,PSTE,
    TRNS,TRNS,TRNS,MHEN,TRNS,     FN11,      TRNS,TRNS, FN3,RALT,RGUI,APP, RCTL,     LEFT,DOWN,RGHT,    P0,       PDOT,PENT,    FIND, CUT
            ),

   

   
   
   
   
   
   
   
   

   
   
   
    [2] = \
    KEYMAP(
    TRNS, TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS, TRNS, TRNS,           PSCR,SLCK,BRK,
    TRNS, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12, TRNS,      INS, HOME,PGUP,    NLCK,PSLS,PAST,PMNS,
    TRNS, ESC,FN15,PGUP,  FN4,F12, JYEN,PGUP,TRNS,HOME, TRNS,  TRNS,  TRNS,  TRNS,     DEL, END, PGDN,    P7,  P8,  P9,
    TRNS,TRNS,  LEFT,PGDN,RGHT,TRNS,  LEFT,DOWN,UP,  RGHT,KP_PLUS,  TRNS,       TRNS,                         P4,  P5,  P6,  PPLS,
    FN7,FN10,  DEL,  EQL,  TRNS,  BSPC,  END,FN9,FN13,FN14, TRNS,          TRNS,          UP,           P1,  P2,  P3,
    FN20,TRNS,TRNS,          TRNS,                     TRNS,TRNS,TRNS, TRNS,     LEFT,DOWN,RGHT,    P0,       PDOT,PENT
            ),
   
   

    [3] =                                       \
    KEYMAP(
    TRNS, TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS, TRNS, TRNS,           PSCR,SLCK,BRK,
    TRNS, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12, TRNS,      INS, HOME,PGUP,    NLCK,PSLS,PAST,PMNS,
    TRNS, TRNS,TRNS,TRNS,  TRNS,TRNS, TRNS,TRNS,F4,TRNS, TRNS,  TRNS,  TRNS,  TRNS,     DEL, END, PGDN,    P7,  P8,  P9,
    TRNS,TRNS,  FN12,DOWN,TAB,TRNS,  FN12,DOWN,UP,  TAB,TRNS,  TRNS,       TRNS,                         P4,  P5,  P6,  PPLS,
    TRNS,TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,TRNS,TRNS,TRNS, TRNS,          TRNS,          UP,           P1,  P2,  P3,
    TRNS,TRNS,TRNS,          TRNS,                     TRNS,TRNS,TRNS, TRNS,     FN12,DOWN,TAB,    P0,       PDOT,PENT
            ),
   
   
    [4] = \
    KEYMAP(
    TRNS, TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS, TRNS, TRNS,           PSCR,SLCK,BRK,
    TRNS, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12, TRNS,      INS, HOME,PGUP,    NLCK,PSLS,PAST,PMNS,
    TRNS, TRNS,TRNS,TRNS,  TRNS,TRNS, TRNS,TRNS,TRNS,TRNS, TRNS,  TRNS,  TRNS,  TRNS,     DEL, END, PGDN,    P7,  P8,  P9,
    TRNS,TRNS,  LEFT,DOWN,RGHT,TRNS,  LEFT,DOWN,UP,  RIGHT,TRNS,  TRNS,       TRNS,                         P4,  P5,  P6,  PPLS,
    TRNS,TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,TRNS,TRNS,TRNS, TRNS,          TRNS,          UP,           P1,  P2,  P3,
    TRNS,TRNS,TRNS,          TRNS,                     TRNS,TRNS,TRNS, TRNS,     LEFT,DOWN,RGHT,    P0,       PDOT,PENT
            ),
   
   
    [5] = \
    KEYMAP(
    TRNS, TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS, TRNS, TRNS,           PSCR,SLCK,BRK,
    TRNS, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12, TRNS,      INS, HOME,PGUP,    NLCK,PSLS,PAST,PMNS,
    NO, FN9,  NO,  NO,  TRNS,  NO,  WH_L,WH_D,MS_U,WH_U,WH_R,WBAK,WFWD,NO,      DEL, END, PGDN,    P7,  P8,  P9,
    LCTL,ACL0,ACL1,ACL2,ACL2,NO,  MS_L,MS_D,MS_U,MS_R,TRNS,NO,       ENT,                         P4,  P5,  P6,  PPLS,
    LSFT,FN10,  NO,  NO,  NO,  BTN3,BTN2,FN10,BTN4,BTN5,NO,            RSFT,          UP,           P1,  P2,  P3,
    LCTL,LGUI,LALT,          BTN1,                    RALT,TRNS,TRNS,RCTL,     LEFT,DOWN,RGHT,    P0,       PDOT,PENT
            ),
   






    [6] =                                       \
    KEYMAP(
    TRNS, TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS, TRNS, TRNS,           PSCR,SLCK,BRK,
    TRNS, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12, TRNS,      INS, HOME,PGUP,    NLCK,PSLS,PAST,PMNS,
    TRNS, ESC,TRNS,PGUP,  FN4,F12, JYEN,PGUP,TRNS,HOME, TRNS,  TRNS,  TRNS,  TRNS,     DEL, END, PGDN,    P7,  P8,  P9,
    TRNS,TRNS,  LEFT,PGDN,RGHT,TRNS,  LEFT,DOWN,UP,  RGHT,KP_PLUS,  TRNS,       TRNS,                         P4,  P5,  P6,  PPLS,
    TRNS,FN10,  DEL,  EQL,  TRNS,  BSPC,  END,FN9,FN13,FN14, TRNS,          TRNS,          UP,           P1,  P2,  P3,
    TRNS,TRNS,TRNS,          TRNS,                     TRNS,TRNS,TRNS, TRNS,     LEFT,DOWN,RGHT,    P0,       PDOT,PENT
            )
};



enum function_id {
        LALT_TAB,
        LSFT_DQT,
        TGGL_MOD,


};


const uint16_t fn_actions[] PROGMEM = {

        [0] = ACTION_MODS_TAP_KEY(MOD_RSFT, KC_ENT),
       
        [1] = ACTION_LAYER_TAP_KEY(2, KC_SPC)   ,
        [2] = ACTION_MODS_TAP_KEY(MOD_LALT, KC_RO),
        [3] = ACTION_LAYER_TAP_KEY(1, KC_BSPC)   ,

        [4] = ACTION_LAYER_TOGGLE(6),
       
        [5] = ACTION_MODS_TAP_KEY(MOD_LCTL, KC_RBRC),
        [6] = ACTION_FUNCTION_TAP(LALT_TAB),
        [7] = ACTION_FUNCTION_TAP(LSFT_DQT),
       
       
        [8] = ACTION_MODS_TAP_TOGGLE(MOD_RSFT),

        [9] = ACTION_LAYER_TOGGLE(5),

        [10] = ACTION_LAYER_SET_CLEAR(0),
        [11] = ACTION_LAYER_TOGGLE(2),
        [12] = ACTION_MODS_KEY(MOD_RSFT, KC_TAB),
        [13] = ACTION_MODS_KEY(MOD_RSFT | MOD_RCTL, KC_TAB),
        [14] = ACTION_MODS_KEY(MOD_RCTL, KC_TAB),
       


        [15] = ACTION_FUNCTION_OPT(TGGL_MOD, MOD_LGUI),
        [16] = ACTION_FUNCTION_OPT(TGGL_MOD, MOD_LCTL),
        [17] = ACTION_FUNCTION_OPT(TGGL_MOD, MOD_LSFT),
        [18] = ACTION_FUNCTION_OPT(TGGL_MOD, MOD_LALT),
        [19] = ACTION_LAYER_TAP_KEY(5, KC_R),

        [20] = ACTION_MODS_KEY(MOD_LALT, KC_PSCR)
};




void action_function(keyrecord_t *record, uint8_t id, uint8_t opt)
{
       
       
       
       

    switch (id) {
        case LALT_TAB:
            if (record->event.pressed) {
                if (record->tap.count > 0 && !record->tap.interrupted) {
                        if (record->tap.interrupted) {

                                layer_on(3);
                        register_mods(MOD_BIT(KC_LALT));

                        register_code(KC_TAB);
                        unregister_code(KC_TAB);
                    }
                } else {
                    layer_on(3);
                    register_mods(MOD_BIT(KC_LALT));

                    register_code(KC_TAB);
                        unregister_code(KC_TAB);
                }
            } else {
                if (record->tap.count > 0 && !(record->tap.interrupted)) {
                       
                       
                    register_code(KC_TAB);
                    unregister_code(KC_TAB);
                   
                   
                    record->tap.count = 0;
                } else {
                    unregister_mods(MOD_BIT(KC_LALT));
                    layer_off(3);
                }
            }
            break;
    case TGGL_MOD:


            if (record->event.pressed) {
                    if (opt & get_mods()) {
                            unregister_mods(opt);
                    } else {
                            register_mods(opt);
                    }
            }
            break;

    case LSFT_DQT:
            if (record->event.pressed) {
                if (record->tap.count > 0 && !record->tap.interrupted) {
                        if (record->tap.interrupted) {

                                register_mods(MOD_BIT(KC_LSHIFT));
                    }
                } else {
                        register_mods(MOD_BIT(KC_LSHIFT));
                }
            } else {
                if (record->tap.count > 0 && !(record->tap.interrupted)) {


                        add_weak_mods(MOD_BIT(KC_LSHIFT));



                        if(2 & layer_state)
                        {
                        register_code(KC_2);
                        unregister_code(KC_2);
                    }
                    else
                    {
                        register_code(KC_7);
                        unregister_code(KC_7);
                    }
                    del_weak_mods(MOD_BIT(KC_LSHIFT));

                    record->tap.count = 0;
                } else {
                    unregister_mods(MOD_BIT(KC_LSHIFT));
                }
            }
            break;           
           
           
           
           
           
           
           
           
           
           
           
           
           
           
           
           
           
           
           
           
           
           
           
           
           
           
           
           
           
           
    }
}
Title: Re: TMK keyboard firmware
Post by: greenwhite on Sat, 18 June 2016, 16:40:26
I'm having an issue trying to get my keyboard up and running.  I'm designing a custom one-handed keyboard.  Here is the layout:  http://www.keyboard-layout-editor.com/#/gists/26d2adaa022322bf6e7a71a1d37396e4 (http://www.keyboard-layout-editor.com/#/gists/26d2adaa022322bf6e7a71a1d37396e4)

[attach=1]

I started with the gh60 code as base.  I changed to row count to 6 and column count to 12 in the config.h file.

I changed the following in matrix.c:

Code: [Select]
/* Column pin configuration
 * col: 0   1   2   3   4   5   6   7   8   9   10  11
 * pin: F1  F0  B6  F4  F5  F6  F7  B5  B4  C5  D5  D2
  */
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<<5 | 1<<2);
    PORTD |=  (1<<5 | 1<<2);
    DDRC  &= ~(1<<5);
    PORTC |=  (1<<5);
    DDRB  &= ~(1<<6 | 1<< 5 | 1<<4);
    PORTB |=  (1<<6 | 1<< 5 | 1<<4);
}

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

/* Row pin configuration
 * row: 0   1   2   3   4   5
 * pin: D1  D0  B7  B3  B1  B0
 */
static void unselect_rows(void)
{
    // Hi-Z(DDR:0, PORT:0) to unselect
    DDRD  &= ~0b00000011;
    PORTD &= ~0b00000011;
DDRB  &= ~0b10001011;
    PORTB &= ~0b10001011;
}

static void select_row(uint8_t row)
{
    // Output low(DDR:1, PORT:0) to select
    switch (row) {
        case 0:
            DDRD  |= (1<<1);
            PORTD &= ~(1<<1);
            break;
        case 1:
            DDRD  |= (1<<0);
            PORTD &= ~(1<<0);
            break;
        case 2:
            DDRB  |= (1<<7);
            PORTB &= ~(1<<7);
            break;
        case 3:
            DDRB  |= (1<<3);
            PORTB &= ~(1<<3);
            break;
        case 4:
            DDRB  |= (1<<1);
            PORTB &= ~(1<<1);
            break;
case 5:
            DDRB  |= (1<<0);
            PORTB &= ~(1<<0);
            break;
    }
}

I changed keymap_common.c:
Code: [Select]
#ifndef KEYMAP_COMMON_H
#define KEYMAP_COMMON_H

#include <stdint.h>
#include <stdbool.h>
#include <avr/pgmspace.h>
#include "keycode.h"
#include "action.h"
#include "action_macro.h"
#include "report.h"
#include "host.h"
#include "print.h"
#include "debug.h"
#include "keymap.h"


extern const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS];
extern const uint16_t fn_actions[];


/* */
#define KEYMAP( \
    K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, \
    K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, \
    K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, \
    K30, K31,      K33, K34, K35, K36, K37, K38,      K3A,      \
    K40, K41, K42, K43, K44, K45, K46, K47, K48, K49, K4A, K4B, \
K50,           K53, K54, K55, K56, K57, K58, K59, K5A, K5B \
) { \
    { 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_##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_NO,    KC_##K33, KC_##K34, KC_##K35, KC_##K36, KC_##K37, KC_##K38, KC_NO,    KC_##K3A, KC_NO, \
    { KC_##K40, KC_##K41, KC_##K42, KC_##K43, KC_##K44, KC_##K45, KC_##K46, KC_##K47, KC_##K48, KC_##K49, KC_##K4A, KC_##K4B, \
{ KC_##K50, KC_NO,    KC_NO,    KC_##K53, KC_##K54, KC_##K55, KC_##K56, KC_##K57, KC_##K58, KC_##K59, KC_##K5A, KC_##K5B, \
}


#endif

And keymap_poker.c:
Code: [Select]
#include "keymap_common.h"

const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
    /* 0: qwerty */
    KEYMAP(
         F1,   F2,   F3,   F4,   F5,   F6,   F7,   F8,   F9,  F10,  F11,  F12, \
        ESC, PSCR, PAUS,    G,    F,    B,    V,    K,    J,  INS, HOME, PGUP, \
       CAPS, SLCK, BSPC,    D,    T,    H,    R,    N,    W,  DEL,  END, PGDN, \
       LGUI,  TAB,          A,    E,    I,    O,    U,    Y,         UP,       \
       LALT,  ENT,  SPC,    L,    S,    C,    M,    P,    Y, LEFT, DOWN, RGHT, \
   LCTL,     ,     , COMM,  DOT,    X,    Q,    Z, RSFT, RGUI, RALT, RCTL ),
   

};
const uint16_t PROGMEM fn_actions[] = {
    /* Poker Layout */
 /*   [0] = ACTION_LAYER_MOMENTARY(6),  // to Fn overlay
    [1] = ACTION_LAYER_TOGGLE(4),     // toggle arrow overlay
    [2] = ACTION_LAYER_TOGGLE(5),     // toggle Esc overlay
    [3] = ACTION_MODS_KEY(MOD_RCTL|MOD_RSFT, KC_ESC), // Task(RControl,RShift+Esc)
    [4] = ACTION_LAYER_MOMENTARY(7),  // to Layout selector
    [5] = ACTION_DEFAULT_LAYER_SET(0),  // set qwerty layout
    [6] = ACTION_DEFAULT_LAYER_SET(1),  // set colemak layout
    [7] = ACTION_DEFAULT_LAYER_SET(2),  // set dvorak layout
    [8] = ACTION_DEFAULT_LAYER_SET(3),  // set workman layout
*/
};

I know commenting out the function won't access my function layers, but I was just trying to get my base layer of letters to work before trying to figure out the function layer (which I"m sure I will have more questions about.)

When I try typing on the keyboard, I get strange  results.  Only a small subset of keys work and they keys that do work result in the wrong character.  For example when I push what should be F4, I get P.  Pushing F5 gives O.  F10 is T, F11 is tab, and insert is 5. 

I'm not sure if anyone can help, but I thought I would ask.
Title: Re: TMK keyboard firmware
Post by: a-c on Sat, 18 June 2016, 16:57:24
I'm having an issue trying to get my keyboard up and running.  I'm designing a custom one-handed

Missing pipe:
Code: [Select]
    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);

Also B7 is used in led.c comment it out or it will conflict with your rows.
Title: Re: TMK keyboard firmware
Post by: greenwhite on Sat, 18 June 2016, 17:42:21
Thanks.  I fixed that, but now I get a bunch of warnings and an error when compiling.  I get the following warnings:
-keymap_poker.c:5: warning: braces around scalar initializer
-keymap_poker.c:5: warning: (near initialization for 'keymaps[0][0][12]')
-keymap_poker.c:5: warning: excess elements in scaler initializer

The bottom two are repeated a bunch of times, and then once for line 14 and three times for line 27.

An error pops up after the line 14 errors:
-keymap_poker.c:14: error: expected'}' before';' token.


Edit:  I got it to work. I was missing the '}' in the keycap_common.  I compiled.  Still having the same issues that I started with, but most keys are now working properly, so thats a start. 
Title: Re: TMK keyboard firmware
Post by: Hypersphere on Sat, 18 June 2016, 18:44:36
Thanks, hasu, for creating the firmware and for your keyboard and converter projects. I have an Alps64 keyboard that I have successfully programmed with a HHKB layout. I have also been using the USB-USB converter, and it works beautifully with the online configurator GUI for generating hex files. I have then used Atmel FLIP for Windows to flash the hex files to the USB-USB converter for a HHKB layout.

Thus far, I have tested the following keyboards and found them to work with the USB-USB converter:

+ CM Novatouch
+ CM QFS TKL
+ IBM Model M SSK (with Orihalcon SDL to USB cable)
+ KBP V60MTS-C
+ KBP V60MTS-Q
+ Pok3r
+ Topre Realforce 87UB45
+ Topre Realforce 87UB55
+ WASD Keyboards V2 TKL

In addition, the USB-USB converter works when connected to a powered USB hub that is in turn connected to a KVM switch (Iogear DVI 4-port). I connect keyboards to the USB-USB converter through a non-powered switchable USB hub (Sabrent).

I remap CapsLock as L_Ctrl and (on TKL boards) Scroll Lock on the navigation island as Num Lock. For CapsLock, I use Fn+Tab. The lock indicator LEDs work with the USB-USB converter.

Finally, the USB-USB converter works with Synergy software (virtual KM switch), using a Windows 10 server and Linux clients (Linux Mint 17.3 64-bit Xfce).

Here is my setup:

C1, C2, C3 --- KVM + Synergy --- pUSBhub --- USB-USB-Converter --- npsUSBhub --- K1, K2, K3

C1, etc. = computer 1, etc.
pUSBhub = powered USB hub
KVM = Iogear DVI 4-port switch
Synergy = software KM
npsUSBhub = non-powered switched USB hub
K1, etc. = Keyboard 1, etc.

The setup has 1 Windows and 2 Linux computers mutually sharing 3 monitors and a keyboard and mouse. The mouse is connected to the powered USB hub. Keyboards that are not using the USB-USB converter can also be connected to the powered USB hub. Keyboards that are using the USB-USB converter are connected to it via the unpowered switched USB hub.

The USB-USB converter is connected to the USB hubs using highly flexible short USB cables to provide strain relief:(https://www.amazon.com/gp/product/B00MXCTDTC/ref=oh_aui_detailpage_o05_s00?ie=UTF8&psc=1)

The USB-USB converter has proved to be a highly versatile and extremely useful tool!



Title: Re: TMK keyboard firmware
Post by: gelmoak on Sat, 25 June 2016, 17:26:19
Hi I made a thread about a problem I have with the TMK firmware and I was told to post here. The link to the thread is: https://geekhack.org/index.php?topic=83033.0. Would greatly appreciate any help as I would like to get the keyboard working.
Title: Re: TMK keyboard firmware
Post by: mrbishop on Sun, 26 June 2016, 16:08:14
can anyone help me with adding a NeoPixel 8 Led strip to my keyboard and having it controlled by TMK? or resources?
Title: Re: TMK keyboard firmware
Post by: sithlord on Wed, 29 June 2016, 00:37:45
Hi Haku,

Thanks for building TMK and sharing your work with everyone.

I've used it to customize my Planck and MiniVan boards which use TMK.

I have run into a problem with getting macros working in TMK for the MiniVan board.

I'm not sure I am doing it right. I can get the layout flashed correctly, but when I try to add a macro, it fails.

Do you or someone else have some examples of using a macro so I can test this?

Thank you for your help.

Edit:

Never mind, I figured it out.
Title: Re: TMK keyboard firmware
Post by: Criterus on Wed, 29 June 2016, 16:36:08
I'm trying to get a set of modified drivers to compile and I've got something going on I can't quite figure out. I keep getting the following errors when I try to compile.

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


Here is my matrix.c  kepmap_comm.h and keymap.c 

My matrix is 16x4

Code: [Select]
/*
Copyright 2012 Jun Wako <wakojun@gmail.com>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

/*
 * scan matrix
 */
#include <stdint.h>
#include <stdbool.h>
#include <avr/io.h>
#include <util/delay.h>
#include "print.h"
#include "debug.h"
#include "util.h"
#include "matrix.h"


#ifndef DEBOUNCE
#   define DEBOUNCE 5
#endif
static uint8_t debouncing = DEBOUNCE;

/* matrix state(1:on, 0:off) */
static matrix_row_t matrix[MATRIX_ROWS];
static matrix_row_t matrix_debouncing[MATRIX_ROWS];

static matrix_row_t read_cols(void);
static void init_cols(void);
static void unselect_rows(void);
static void select_row(uint8_t row);


inline
uint8_t matrix_rows(void)
{
    return MATRIX_ROWS;
}

inline
uint8_t matrix_cols(void)
{
    return MATRIX_COLS;
}

void matrix_init(void)
{
    // initialize row and col
    unselect_rows();
    init_cols();

    // initialize matrix state: all keys off
    for (uint8_t i=0; i < MATRIX_ROWS; i++) {
        matrix[i] = 0;
        matrix_debouncing[i] = 0;
    }
}

uint8_t matrix_scan(void)
{
    for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
        select_row(i);
        _delay_us(30);  // without this wait read unstable value.
        matrix_row_t cols = read_cols();
        if (matrix_debouncing[i] != cols) {
            matrix_debouncing[i] = cols;
            if (debouncing) {
                debug("bounce!: "); debug_hex(debouncing); debug("\n");
            }
            debouncing = DEBOUNCE;
        }
        unselect_rows();
    }

    if (debouncing) {
        if (--debouncing) {
            _delay_ms(1);
        } else {
            for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
                matrix[i] = matrix_debouncing[i];
            }
        }
    }

    return 1;
}

bool matrix_is_modified(void)
{
    if (debouncing) return false;
    return true;
}

inline
bool matrix_is_on(uint8_t row, uint8_t col)
{
    return (matrix[row] & ((matrix_row_t)1<<col));
}

inline
matrix_row_t matrix_get_row(uint8_t row)
{
    return matrix[row];
}

void matrix_print(void)
{
    print("\nr/c 0123456789ABCDEF\n");
    for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
        phex(row); print(": ");
        pbin_reverse16(matrix_get_row(row));
        print("\n");
    }
}

uint8_t matrix_key_count(void)
{
    uint8_t count = 0;
    for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
        count += bitpop16(matrix[i]);
    }
    return count;
}

/* Column pin configuration
 * col: 0   1   2   3   4   5   6   7   8   9   10  11  12  13  14  15 
 * pin: B0  B1  B2  B3  B7  D1  D2  D3  C6  C7  D6  D7  B4  B5  B6  F7  (Rev.A)
 * pin: //  //  //  //  //  //  //  //  //  //  // //   //  //  //  //                                 
 */
static void  init_cols(void)
{
    // Input with pull-up(DDR:0, PORT:1)
    DDRF  &= ~(1<<7);
    PORTF |=  (1<<7);
   
//DDRE  &= ~(1<<6);
    //PORTE |=  (1<<6);
   
DDRD  &= ~(1<<7 |1<<6|1<<3 |1<<2 | 1<<1);
    PORTD |=  (1<<7 |1<<6|1<<3 |1<<2 | 1<<1);
   
DDRC  &= ~(1<<7 | 1<<6);
    PORTC |=  (1<<7 | 1<<6);
   
DDRB  &= ~(1<<7 | 1<<6 | 1<<5 | 1<< 4 | 1<<3 | 1<<2 | 1<<1 | 1<<0);
    PORTB |=  (1<<7 | 1<<6 | 1<<5 | 1<< 4 | 1<<3 | 1<<2 | 1<<1 | 1<<0);
}

static matrix_row_t read_cols(void)
{
    return (PINB&(1<<0) ? 0 : (1<<0)) |
           (PINB&(1<<1) ? 0 : (1<<1)) |
   (PINB&(1<<2) ? 0 : (1<<2)) |
   (PINB&(1<<3) ? 0 : (1<<3)) |
   (PINB&(1<<7) ? 0 : (1<<4)) |
   (PIND&(1<<1) ? 0 : (1<<5)) |
   (PIND&(1<<2) ? 0 : (1<<6)) |
   (PIND&(1<<3) ? 0 : (1<<7)) |
   (PINC&(1<<6) ? 0 : (1<<8)) |
   (PINC&(1<<7) ? 0 : (1<<9)) |
   (PIND&(1<<6) ? 0 : (1<<10))|
   (PIND&(1<<7) ? 0 : (1<<11))|
   (PINB&(1<<4) ? 0 : (1<<12))|
   (PINB&(1<<5) ? 0 : (1<<13))|
   (PINB&(1<<6) ? 0 : (1<<14))|
   (PINF&(1<<7) ? 0 : (1<<15))|
   
   
           
           
          ;
}

/* Row pin configuration
 * row: 0   1   2   3 
 * pin: F6  F5  F4  F1 
 */
static void unselect_rows(void)
{
    // Hi-Z(DDR:0, PORT:0) to unselect
    DDRF  &= ~0b01110010;
    PORTF &= ~0b01110010;
}

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

Code: [Select]
/*
Copyright 2012,2013 Jun Wako <wakojun@gmail.com>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef KEYMAP_COMMON_H
#define KEYMAP_COMMON_H

#include <stdint.h>
#include <stdbool.h>
#include <avr/pgmspace.h>
#include "keycode.h"
#include "action.h"
#include "action_macro.h"
#include "report.h"
#include "host.h"
#include "print.h"
#include "debug.h"
#include "keymap.h"


extern const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS];
extern const uint16_t fn_actions[];


/* 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, K0C, K0D, K0E, K0F, \
    K10, K11, K12, K13, K14, K15, K16, K17, K18, K19,      K1B, K1C, K1D, K1E, K1F, \
    K20,      K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, K2D, K2E, K2F, \
    K30, K31,                     K36,           K39, k3A, K3B,      K3D, K3E       \
) {\
    { 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_##K0E, KC_##K0F, }, \
    { KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17, KC_##K18, KC_##K19, KC_NO,    KC_##K1B, KC_##K1C, KC_##K1D  KC_##K1E, KC_##K1F, }, \
    { KC_##K20, KC_NO,    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_##K2E, KC_##K2F, }, \
    { KC_##K30, KC_##K31, KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_##K36, KC_NO,    KC_NO,    KC_##K39, KC_##K3A, KC_##K3B, KC_NO,    KC_##K3D  KC_##K3E, KC_NO     }, \ }

#endif


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

const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {

KEYMAP( ESC,  Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,   BSPC, 7, 8, 9, MINS, \
TAB,  A,   S,   D,   F,   G,   H,   J,   K,   L,        ENT,  4, 5, 6, PLUS, \
LSFT, Z,   X,   C,   V,   B,   N,   M,      QUOT, LBRC, DOT,  1, 2, 3, ENT,  \
LCTL, LALT,              SPC,               FN0, RBRC, COMM,  0, DOT),
};

const uint16_t PROGMEM fn_actions[] = {};


Is there anything obvious I am missing.
Title: Re: TMK keyboard firmware
Post by: hasu on Thu, 30 June 2016, 00:21:35
Criterus,
you missed commas in KEYMAP macro definition around ##K1D, ##K2D and ##K3D
and missed to captialize of k3A.
Title: Re: TMK keyboard firmware
Post by: Chaosghoul on Sun, 03 July 2016, 02:37:04
Hey everyone,

Thank you for sharing your code Hasu.
I am a absolute beginner to Arduino/Teensy programming. I have already wired a 106-key (german layout with numpad) and wanted to alter your code and upload it. I have imported everything into the Arduino (I'm on windows) and altered the keymap and config files to my needs.
When I click on upload or check though, I get a TON of compiling errors in all kinds of files (most noticable in the avr files) which I am not able to solve on my own :(

Could you help me please?

I have attached my keymap files to this.
My layout is 6 rows and 21 columns. I have soldered my 6 rows bottom to top to pins 24-29 and my columns to pins 1-21.

Kind regards,
Jakob
Title: Re: TMK keyboard firmware
Post by: hasu on Sun, 03 July 2016, 02:59:50
Hi,
Tmk is not compatible with arduino. Read README, docs and issues on Github.com first. I think it takes a week at least to understand how to use this if you are not familiar with these things. Take time.

If you are still interested in using tmk with arduino see this issue and try bgould's repo. https://github.com/tmk/tmk_keyboard/issues/364

Sent from my Nexus 5X using Tapatalk

Title: Re: TMK keyboard firmware
Post by: Chaosghoul on Sun, 03 July 2016, 03:10:41
Hi Hasu,

Thank you for replying.
If Arduino is not the software to use here, I don't have a problem with switching to something else. I've tried to find out what programming environment you used, but the readme doesn't state this :(

Phew, an additional week to do this would be quite hard to set aside for this project. With work and everything else, I barely got the wiring done over the course of three weeks :(
Would there be someone interested in doing the code for me for a donation? In a way so I can just copy-paste the whole thing, upload and be done with it?

Kind regards,
Jakob
Title: Re: TMK keyboard firmware
Post by: Chaosghoul on Mon, 04 July 2016, 01:17:29
Heyho, me again.

So after some googling, I found out that there is a bigger readme than the one that is included in the github files, so sorry for stating that there is not a lot in your readme.

I have altered the code with winavr now and after fiddling around for a while I got it to compile and make a .hex file (jay!).

I now wanted to upload the code using the teensy uploader, only to find out that the code is for teensy 2.0 (I have a teensy 3.2 wired up).
I found out that the whitefox used a teensy 3.2 as well and tried to copy some of the code from that makefile and put it into mine (which gave me a lot of errors). I also tried using the whitefox code and altering it to my needs (which gave me a lt of compiling errors I am not able to decipher :( ).

Could you help me make this code work for teensy 3.2? I have attached the complete code of what I was able to compile and tun into a .hex. I also think my matrix.c is still wrong, but I unfortunately wasn't able to get behind the coding and alter it to my needs. Could you guide me to where to read up on that?

Thanks in advance,
Jakob
Title: Re: TMK keyboard firmware
Post by: rrrsss on Mon, 04 July 2016, 11:19:41
can anyone help me with adding a NeoPixel 8 Led strip to my keyboard and having it controlled by TMK? or resources?

it's a ws2812 protocol rgb light right?

https://github.com/rafael-azevedo/tmk_splitkeyboard

on the erglowdox and c44 it has implementation for it. the rgb pin is configured on the config.h file.
i haven't tried it myself, but the results are very pretty:
http://imgur.com/gallery/3vRUa
http://imgur.com/gallery/M445Z
Title: Re: TMK keyboard firmware
Post by: mrbishop on Mon, 04 July 2016, 11:21:45
can anyone help me with adding a NeoPixel 8 Led strip to my keyboard and having it controlled by TMK? or resources?

it's a ws2812 protocol rgb light right?

https://github.com/rafael-azevedo/tmk_splitkeyboard

on the erglowdox and c44 it has implementation for it. the rgb pin is configured on the config.h file.
i haven't tried it myself, but the results are very pretty:
http://imgur.com/gallery/3vRUa
http://imgur.com/gallery/M445Z

awesome thanks.
i happen to have a neopixel lying around and my keyboard case bottom is clear so i figured why not.
Title: Re: TMK keyboard firmware
Post by: MOZ on Tue, 05 July 2016, 01:58:24
If you want to use the Neopixel, might I suggest QMK. It has support for RGB (WS2812/B) built in, just set the pin, and keys to change colors and done.
Title: Re: TMK keyboard firmware
Post by: tokyo on Sat, 09 July 2016, 18:03:03
Still stuck with this problem, help please :-*
layer_state variable not seem to reflect currently active momentary layers, I am using 20160525 downloaded codes not latest
        [1] = ACTION_LAYER_TAP_KEY(2, KC_SPC)   //momentary layer
        [11] = ACTION_LAYER_TOGGLE(2),   //toggle layer, which works fine
  below is my code, see LSFT_DQT

Code: [Select]

#include "keymap_common.h"
#include "action_util.h"
#include "action_layer.h"


const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = {
       
       
    KEYMAP_ALL(
              F13, F14, F15, F16, F17, F18, F19, F20, F21, F22, F23, F24,

              ESC,      F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12,           PSCR,SLCK,PAUS,    VOLD,VOLU,MUTE,PWR,     HELP,
    GRV, 1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   MINS,EQL, JYEN,BSPC,     INS, HOME,PGUP,    NLCK,PSLS,PAST,PMNS,    STOP,AGIN,
    FN6, Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,   LBRC,RBRC,     BSLS,     DEL, END, PGDN,    P7,  P8,  P9,  PPLS,    MENU,UNDO,
    FN5,A,   S,   D,   F,   G,   H,   J,   K,   L,   SCLN,QUOT,     NUHS,ENT,                         P4,  P5,  P6,  PCMM,    SLCT,COPY,
    FN7,NUBS,Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, SLSH,     RO,  FN8,          UP,           P1,  P2,  P3,  PEQL,    EXEC,PSTE,
    LCTL,LGUI,LALT,FN2,HANJ,     FN1,      HAEN,FN0, FN3,RALT,RGUI,APP, RCTL,     LEFT,DOWN,RGHT,    P0,       PDOT,PENT,    FIND, CUT
    ),

   
   
    [1] = \
    KEYMAP_ALL(
              F13, F14, F15, F16, F17, F18, F19, F20, F21, F22, F23, F24,
    ESC,      F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12,           PSCR,SLCK,PAUS,    VOLD,VOLU,MUTE,PWR,     HELP,
    GRV, 1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   MINS,EQL, FN0,BSPC,     INS, HOME,PGUP,    NLCK,PSLS,PAST,PMNS,    STOP,AGIN,
    TRNS, TRNS,   FN15,   E,   FN19,   T,   Y,   U,   I,   O,   P,   LBRC,RBRC,     BSLS,     DEL, END, PGDN,    P7,  P8,  P9,  PPLS,    MENU,UNDO,
    CAPS,FN18,   FN17,   D,   F,   G,   H,   J,   K,   L,   SCLN,QUOT,     NUHS,ENT,                         P4,  P5,  P6,  PCMM,    SLCT,COPY,
    TRNS,TRNS,FN10,   TRNS,   FN16,   V,   B,   N,   M,   COMM,DOT, SLSH,     RO,  FN8,          UP,           P1,  P2,  P3,  PEQL,    EXEC,PSTE,
    TRNS,TRNS,TRNS,MHEN,TRNS,     FN11,      TRNS,TRNS, FN3,RALT,RGUI,APP, RCTL,     LEFT,DOWN,RGHT,    P0,       PDOT,PENT,    FIND, CUT
            ),

   

   
   
   
   
   
   
   
   

   
   
   
    [2] = \
    KEYMAP(
    TRNS, TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS, TRNS, TRNS,           PSCR,SLCK,BRK,
    TRNS, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12, TRNS,      INS, HOME,PGUP,    NLCK,PSLS,PAST,PMNS,
    TRNS, ESC,FN15,PGUP,  FN4,F12, JYEN,PGUP,TRNS,HOME, TRNS,  TRNS,  TRNS,  TRNS,     DEL, END, PGDN,    P7,  P8,  P9,
    TRNS,TRNS,  LEFT,PGDN,RGHT,TRNS,  LEFT,DOWN,UP,  RGHT,KP_PLUS,  TRNS,       TRNS,                         P4,  P5,  P6,  PPLS,
    FN7,FN10,  DEL,  EQL,  TRNS,  BSPC,  END,FN9,FN13,FN14, TRNS,          TRNS,          UP,           P1,  P2,  P3,
    FN20,TRNS,TRNS,          TRNS,                     TRNS,TRNS,TRNS, TRNS,     LEFT,DOWN,RGHT,    P0,       PDOT,PENT
            ),
   
   

    [3] =                                       \
    KEYMAP(
    TRNS, TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS, TRNS, TRNS,           PSCR,SLCK,BRK,
    TRNS, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12, TRNS,      INS, HOME,PGUP,    NLCK,PSLS,PAST,PMNS,
    TRNS, TRNS,TRNS,TRNS,  TRNS,TRNS, TRNS,TRNS,F4,TRNS, TRNS,  TRNS,  TRNS,  TRNS,     DEL, END, PGDN,    P7,  P8,  P9,
    TRNS,TRNS,  FN12,DOWN,TAB,TRNS,  FN12,DOWN,UP,  TAB,TRNS,  TRNS,       TRNS,                         P4,  P5,  P6,  PPLS,
    TRNS,TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,TRNS,TRNS,TRNS, TRNS,          TRNS,          UP,           P1,  P2,  P3,
    TRNS,TRNS,TRNS,          TRNS,                     TRNS,TRNS,TRNS, TRNS,     FN12,DOWN,TAB,    P0,       PDOT,PENT
            ),
   
   
    [4] = \
    KEYMAP(
    TRNS, TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS, TRNS, TRNS,           PSCR,SLCK,BRK,
    TRNS, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12, TRNS,      INS, HOME,PGUP,    NLCK,PSLS,PAST,PMNS,
    TRNS, TRNS,TRNS,TRNS,  TRNS,TRNS, TRNS,TRNS,TRNS,TRNS, TRNS,  TRNS,  TRNS,  TRNS,     DEL, END, PGDN,    P7,  P8,  P9,
    TRNS,TRNS,  LEFT,DOWN,RGHT,TRNS,  LEFT,DOWN,UP,  RIGHT,TRNS,  TRNS,       TRNS,                         P4,  P5,  P6,  PPLS,
    TRNS,TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,TRNS,TRNS,TRNS, TRNS,          TRNS,          UP,           P1,  P2,  P3,
    TRNS,TRNS,TRNS,          TRNS,                     TRNS,TRNS,TRNS, TRNS,     LEFT,DOWN,RGHT,    P0,       PDOT,PENT
            ),
   
   
    [5] = \
    KEYMAP(
    TRNS, TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS, TRNS, TRNS,           PSCR,SLCK,BRK,
    TRNS, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12, TRNS,      INS, HOME,PGUP,    NLCK,PSLS,PAST,PMNS,
    NO, FN9,  NO,  NO,  TRNS,  NO,  WH_L,WH_D,MS_U,WH_U,WH_R,WBAK,WFWD,NO,      DEL, END, PGDN,    P7,  P8,  P9,
    LCTL,ACL0,ACL1,ACL2,ACL2,NO,  MS_L,MS_D,MS_U,MS_R,TRNS,NO,       ENT,                         P4,  P5,  P6,  PPLS,
    LSFT,FN10,  NO,  NO,  NO,  BTN3,BTN2,FN10,BTN4,BTN5,NO,            RSFT,          UP,           P1,  P2,  P3,
    LCTL,LGUI,LALT,          BTN1,                    RALT,TRNS,TRNS,RCTL,     LEFT,DOWN,RGHT,    P0,       PDOT,PENT
            ),
   






    [6] =                                       \
    KEYMAP(
    TRNS, TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS, TRNS, TRNS,           PSCR,SLCK,BRK,
    TRNS, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12, TRNS,      INS, HOME,PGUP,    NLCK,PSLS,PAST,PMNS,
    TRNS, ESC,TRNS,PGUP,  FN4,F12, JYEN,PGUP,TRNS,HOME, TRNS,  TRNS,  TRNS,  TRNS,     DEL, END, PGDN,    P7,  P8,  P9,
    TRNS,TRNS,  LEFT,PGDN,RGHT,TRNS,  LEFT,DOWN,UP,  RGHT,KP_PLUS,  TRNS,       TRNS,                         P4,  P5,  P6,  PPLS,
    TRNS,FN10,  DEL,  EQL,  TRNS,  BSPC,  END,FN9,FN13,FN14, TRNS,          TRNS,          UP,           P1,  P2,  P3,
    TRNS,TRNS,TRNS,          TRNS,                     TRNS,TRNS,TRNS, TRNS,     LEFT,DOWN,RGHT,    P0,       PDOT,PENT
            )
};



enum function_id {
        LALT_TAB,
        LSFT_DQT,
        TGGL_MOD,


};


const uint16_t fn_actions[] PROGMEM = {

        [0] = ACTION_MODS_TAP_KEY(MOD_RSFT, KC_ENT),
       
        [1] = ACTION_LAYER_TAP_KEY(2, KC_SPC)   ,
        [2] = ACTION_MODS_TAP_KEY(MOD_LALT, KC_RO),
        [3] = ACTION_LAYER_TAP_KEY(1, KC_BSPC)   ,

        [4] = ACTION_LAYER_TOGGLE(6),
       
        [5] = ACTION_MODS_TAP_KEY(MOD_LCTL, KC_RBRC),
        [6] = ACTION_FUNCTION_TAP(LALT_TAB),
        [7] = ACTION_FUNCTION_TAP(LSFT_DQT),
       
       
        [8] = ACTION_MODS_TAP_TOGGLE(MOD_RSFT),

        [9] = ACTION_LAYER_TOGGLE(5),

        [10] = ACTION_LAYER_SET_CLEAR(0),
        [11] = ACTION_LAYER_TOGGLE(2),
        [12] = ACTION_MODS_KEY(MOD_RSFT, KC_TAB),
        [13] = ACTION_MODS_KEY(MOD_RSFT | MOD_RCTL, KC_TAB),
        [14] = ACTION_MODS_KEY(MOD_RCTL, KC_TAB),
       


        [15] = ACTION_FUNCTION_OPT(TGGL_MOD, MOD_LGUI),
        [16] = ACTION_FUNCTION_OPT(TGGL_MOD, MOD_LCTL),
        [17] = ACTION_FUNCTION_OPT(TGGL_MOD, MOD_LSFT),
        [18] = ACTION_FUNCTION_OPT(TGGL_MOD, MOD_LALT),
        [19] = ACTION_LAYER_TAP_KEY(5, KC_R),

        [20] = ACTION_MODS_KEY(MOD_LALT, KC_PSCR)
};




void action_function(keyrecord_t *record, uint8_t id, uint8_t opt)
{
       
       
       
       

    switch (id) {
        case LALT_TAB:
            if (record->event.pressed) {
                if (record->tap.count > 0 && !record->tap.interrupted) {
                        if (record->tap.interrupted) {

                                layer_on(3);
                        register_mods(MOD_BIT(KC_LALT));

                        register_code(KC_TAB);
                        unregister_code(KC_TAB);
                    }
                } else {
                    layer_on(3);
                    register_mods(MOD_BIT(KC_LALT));

                    register_code(KC_TAB);
                        unregister_code(KC_TAB);
                }
            } else {
                if (record->tap.count > 0 && !(record->tap.interrupted)) {
                       
                       
                    register_code(KC_TAB);
                    unregister_code(KC_TAB);
                   
                   
                    record->tap.count = 0;
                } else {
                    unregister_mods(MOD_BIT(KC_LALT));
                    layer_off(3);
                }
            }
            break;
    case TGGL_MOD:


            if (record->event.pressed) {
                    if (opt & get_mods()) {
                            unregister_mods(opt);
                    } else {
                            register_mods(opt);
                    }
            }
            break;

    case LSFT_DQT:
            if (record->event.pressed) {
                if (record->tap.count > 0 && !record->tap.interrupted) {
                        if (record->tap.interrupted) {

                                register_mods(MOD_BIT(KC_LSHIFT));
                    }
                } else {
                        register_mods(MOD_BIT(KC_LSHIFT));
                }
            } else {
                if (record->tap.count > 0 && !(record->tap.interrupted)) {


                        add_weak_mods(MOD_BIT(KC_LSHIFT));



                        if(2 & layer_state)
                        {
                        register_code(KC_2);
                        unregister_code(KC_2);
                    }
                    else
                    {
                        register_code(KC_7);
                        unregister_code(KC_7);
                    }
                    del_weak_mods(MOD_BIT(KC_LSHIFT));

                    record->tap.count = 0;
                } else {
                    unregister_mods(MOD_BIT(KC_LSHIFT));
                }
            }
            break;           
           
           
           
           
           
           
           
           
           
           
           
           
           
           
           
           
           
           
           
           
           
           
           
           
           
           
           
           
           
           
    }
}
Title: Re: TMK keyboard firmware
Post by: hasu on Sat, 09 July 2016, 18:16:20
Describe detail of what you expect and what you really get.
Title: Re: TMK keyboard firmware
Post by: Chaosghoul on Wed, 13 July 2016, 00:18:10
Heyho,

me again.
With help of a friend I figured most of the stuff out and everything works so far, except one thing: numpad comma. I have a physical numpad on my keyboard, all the keys work, just the comma doesn't for some reason.
I have tried a keyboard tester and I can see that the physical key works and also if I program the keypad comma to be something else (e.g. DOT) it works, but neither PCMM, nor KP_COMMA work for me :(

Any ideas on this?
Title: Re: TMK keyboard firmware
Post by: hasu on Wed, 13 July 2016, 01:05:58
Heyho,

me again.
With help of a friend I figured most of the stuff out and everything works so far, except one thing: numpad comma. I have a physical numpad on my keyboard, all the keys work, just the comma doesn't for some reason.
I have tried a keyboard tester and I can see that the physical key works and also if I program the keypad comma to be something else (e.g. DOT) it works, but neither PCMM, nor KP_COMMA work for me :(

Any ideas on this?

I think most of system/layouts don't support the keycode. Accroding to spec it seems to exist for Brazillian keyboard layout.
Try changing your layout to Brazillian and report whether it works or not. I'm curious.

HID Usage Tables Version 1.12 p.59
Quote
Keypad Comma is the appropriate usage for the Brazilian keypad period (.) key. This represents the closest possible
match, and system software should do the correct mapping based on the current locale setting.
Title: Re: TMK keyboard firmware
Post by: kitten_paw on Thu, 14 July 2016, 04:16:34
Hi,

I am trying to create a couple of layers for the tmk firmware with an ISO 105 key keyboard. I am using the German keymap on my system, where I have to use RALT+8 to get the [ character, RALT+0 to get } and so on. This is extremely annoying for programming, of course, which is why I've been using the US keymap when programming and switching back and forth.

Now my idea is that I'd like to have a "programming layer" that basically mimics the US layout when active. For example when I press the ü key I want to get ü on the default layer and [ on the programming layer, without having to change the system keymap. I know I can achieve this for a single key by making ü a FN key with ACTION_MODS_KEY, but this means a) that I have to waste a function key and b) that I can't use shift+ü to get { (at least I don't know how).

So basically my question is, how can I set up the KEYMAP that my programming layer sends the correct keycodes on the German keymap to mimic the US keymap?

I created my intended layer layout here: http://www.keyboard-layout-editor.com/#/gists/3f4485a4bef29532c9d25c522d221037
The black labels are the default layer, the red key toggles the programming layer, and the red labels are the characters that I want to get when the programming layer is active (upper labels are Shift+key), without having to change the keymap in the OS. I hope this makes a little more sense now.

Disclaimer: I posted more or less the same thing on deskthority.

[edit: Implemented a solution]
So, for now I have implemented it using FN keys and MACROs, thanks to the tmk github wiki. I think it's an ugly solution, but it works. So here's my keymap that, when using a German OS keymap, has German layout on the default layer and a US layout on two seperate programming layers. Maybe somebody finds this useful.

Code: [Select]

const uint8_t PROGMEM keymaps[][MATRIX_COLS][MATRIX_ROWS] = {
    /* Layer 0: Standard ANSI layer */
    KEYMAP(\
         ESC, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11,  F12,        PSCR,SLCK,PAUS,                         \
         GRV, 1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   MINS, EQL,BSPC,   INS, HOME,PGUP,    NLCK,PSLS,PAST,PMNS, \
         TAB, Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,   LBRC,RBRC,BSLS,   DEL, END, PGDN,    P7,  P8,  P9,  PPLS, \
         RALT,A,   S,   D,   F,   G,   H,   J,   K,   L,   SCLN,QUOT,      ENT,                      P4,  P5,  P6,        \
         LSFT,NUBS,Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, SLSH,     RSFT,        UP,           P1,  P2,  P3,  PENT, \
         LCTL,LGUI,LALT,               SPC,                FN0, FN1,  FN2,RCTL,   LEFT,DOWN,RGHT,    P0,  PDOT),          \
    /* Layer 1: programming layer 1*/
    KEYMAP(\
          ESC,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,SLSH,FN11,TRNS,   TRNS,TRNS,TRNS,    TRNS,TRNS,TRNS,TRNS, \
         TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,FN12,FN13,FN16,   TRNS,TRNS,TRNS,    TRNS,TRNS,TRNS,TRNS, \
         TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,FN14,FN15,     TRNS,                      TRNS,TRNS,TRNS,      \
         FN26,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,FN17,     TRNS,        TRNS,         TRNS,TRNS,TRNS,TRNS, \
         TRNS,TRNS,TRNS,               TRNS,               TRNS,TRNS,TRNS,TRNS,   TRNS,TRNS,TRNS,    TRNS,TRNS),
    /* Layer 2: programming layer 2*/
    KEYMAP(\
          ESC,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,FN18,RBRC,TRNS,   TRNS,TRNS,TRNS,    TRNS,TRNS,TRNS,TRNS, \
         TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,FN19,FN20,FN23,   TRNS,TRNS,TRNS,    TRNS,TRNS,TRNS,TRNS, \
         TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,FN21,FN22,     TRNS,                      TRNS,TRNS,TRNS,      \
         TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,NUBS,FN24,FN25,     TRNS,        TRNS,         TRNS,TRNS,TRNS,TRNS, \
         TRNS,TRNS,TRNS,               TRNS,               TRNS,TRNS,TRNS,TRNS,   TRNS,TRNS,TRNS,    TRNS,TRNS),
    /* Layer 3: media layer */
    KEYMAP(\
          FN3,  NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,        MPRV,MPLY,MNXT,                         \
           NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,     NO,  NO,VOLU,      NO,  NO,  NO,  NO, \
           NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,     NO,MUTE,VOLD,      NO,  NO,  NO,  NO, \
           NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,       NO,                        NO,  NO,  NO,      \
           NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,       NO,          NO,           NO,  NO,  NO,  NO, \
           NO,  NO,  NO,                 NO,                 NO,  NO,  NO,  NO,     NO,  NO,  NO,      NO,  NO),
    /* Layer 4: Mouse layer */
    KEYMAP(\
          FN3,  NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,          NO,  NO,  NO,                         \
           NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,     NO,  NO,  NO,      NO,  NO,  NO,  NO, \
           NO,  NO,  NO,MS_U,  NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,     NO,  NO,  NO,      NO,  NO,  NO,  NO, \
           NO,  NO,MS_L,MS_D,MS_R,  NO,WH_L,WH_D,WH_U,WH_R,  NO,  NO,       NO,                        NO,  NO,  NO,      \
           NO,  NO,  NO,  NO,  NO,  NO,  NO,BTN2,BTN3,  NO,  NO,  NO,       NO,          NO,           NO,  NO,  NO,  NO, \
           NO,  NO,  NO,               BTN1,                 NO,  NO,  NO,  NO,     NO,  NO,  NO,      NO,  NO)

};
enum macro_id {
    UNDERSCORE,
    EQUAL,
    RBRACE_L,
    CBRACE_L,
    RBRACE_R,
    CBRACE_R,
    SEMICOLON,
    COLON,
    APOSTROPHE,
    QUOTE,
    BACKSLASH,
    PIPE,
    GREATERTHAN,
    SLASH,
    QUESTION
};

static const uint16_t PROGMEM fn_actions[] = {
    [0] = ACTION_LAYER_TOGGLE(4),
    [1] = ACTION_LAYER_TOGGLE(1),
    [2] = ACTION_LAYER_MOMENTARY(3),
    [3] = ACTION_LAYER_SET_CLEAR(0),
    [11] = ACTION_MACRO(EQUAL),
    [12] = ACTION_MACRO(RBRACE_L),
    [13] = ACTION_MACRO(RBRACE_R),
    [14] = ACTION_MACRO(SEMICOLON),
    [15] = ACTION_MACRO(APOSTROPHE),
    [16] = ACTION_MACRO(BACKSLASH),
    [17] = ACTION_MACRO(SLASH),
    [18] = ACTION_MACRO(UNDERSCORE),
    [19] = ACTION_MACRO(CBRACE_L),
    [20] = ACTION_MACRO(CBRACE_R),
    [21] = ACTION_MACRO(COLON),
    [22] = ACTION_MACRO(QUOTE),
    [23] = ACTION_MACRO(PIPE),
    [24] = ACTION_MACRO(GREATERTHAN),
    [25] = ACTION_MACRO(QUESTION),
    [26] = ACTION_LAYER_MOMENTARY(2)
};

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 EQUAL:
            return (event.pressed ?
                    MACRO( D(LSHIFT), T(0), U(LSHIFT), END ) :
                    MACRO( END ) );
        case RBRACE_L:
            return (event.pressed ?
                    MACRO( D(RALT), T(8), U(RALT), END ) :
                    MACRO( END ) );
        case RBRACE_R:
            return (event.pressed ?
                    MACRO( D(RALT), T(9), U(RALT), END ) :
                    MACRO( END ) );
        case SEMICOLON:
            return (event.pressed ?
                    MACRO( D(LSHIFT), T(COMM), U(LSHIFT), END ):
                    MACRO( END ) );
        case APOSTROPHE:
            return (event.pressed ?
                    MACRO( D(LSHIFT), T(BSLS), U(LSHIFT), END ):
                    MACRO( END ) );
        case BACKSLASH:
            return (event.pressed ?
                    MACRO( D(RALT), T(MINS), U(RALT), END ):
                    MACRO( END ) );
        case SLASH:
            return (event.pressed ?
                    MACRO( D(LSHIFT), T(7), U(LSHIFT), END ) :
                    MACRO( END ) );
        case UNDERSCORE:
            return (event.pressed ?
                    MACRO( D(LSHIFT), T(SLSH), U(LSHIFT), END ) :
                    MACRO( END ) );
        case CBRACE_L:
            return (event.pressed ?
                    MACRO( D(RALT), T(7), U(RALT), END ) :
                    MACRO( END ) );
        case CBRACE_R:
            return (event.pressed ?
                    MACRO( D(RALT), T(0), U(RALT), END ) :
                    MACRO( END ) );
        case COLON:
            return (event.pressed ?
                    MACRO( D(LSHIFT), T(DOT), U(LSHIFT), END ) :
                    MACRO( END ) );
        case QUOTE:
            return (event.pressed ?
                    MACRO( D(LSHIFT), T(2), U(LSHIFT), END ) :
                    MACRO( END ) );
        case PIPE:
            return (event.pressed ?
                    MACRO( D(RALT), T(NUBS), U(RALT), END ) :
                    MACRO( END ) );
        case GREATERTHAN:
            return (event.pressed ?
                    MACRO( D(LSHIFT), T(NUBS), U(LSHIFT), END ) :
                    MACRO( END ) );
        case QUESTION:
            return (event.pressed ?
                    MACRO( D(LSHIFT), T(MINS), U(LSHIFT), END ) :
                    MACRO( END ) );
    }
    return MACRO_NONE;
}
Title: Re: TMK keyboard firmware
Post by: xauser on Thu, 14 July 2016, 15:53:54
@kitten_paw

Nice apporach for developers that insist on german keymap. I would suggest another mind set and switch over to us international keymap. You have to learn the new positions for the german umlauts (4 keys) but get everything you
want in one keymap without any tmk or os magic. 
Title: Re: TMK keyboard firmware
Post by: kitten_paw on Fri, 15 July 2016, 06:00:20
@xauser

First of all thank you very much for pointing this out to me, I didn't know this variant even existed. I have already activated it on my laptop, where I use a US layout.
Still, I have to write a lot more prose than I have to write code, so I actually think I will keep the German layout as my main layout on my PC. The idea of having these layers was one of my main motivators behind getting a keyboard with replaceable and programmable controller, so don't go and spoil it for me ;)
Title: Re: TMK keyboard firmware
Post by: MrMen on Sun, 17 July 2016, 16:56:04
Hi guys.
I'd like to use TMK with my HHKB and bepo French layout. To do so, I have to use many (too much) macros.

I recently saw actiomap and I'd like to give it a try. I investigate the alps64 example but I can't figure out how to modify the Makefile.rn42

Does anyone has a hint for me ?

Thank you.
Title: Re: TMK keyboard firmware
Post by: nikchi on Sun, 17 July 2016, 17:40:20
I'm using https://deskthority.net/w/images/1/11/Voice_of_Reason_Components.PNG (https://deskthority.net/w/images/1/11/Voice_of_Reason_Components.PNG)

It runs a ATMEGA32U2 and bpiphany has a working fork of TMK for his controllers. It also compiles and runs fine on the main TMK fork. I want to use the protocol/bluefruit stuff. How would I make this work? The controller has the TX and RX pins broken out.

I've added in this code to my config.h. What else should I do to make this work before I try this entire thing?

Code: [Select]
#ifdef __AVR_ATmega32U2__
    #define SERIAL_UART_BAUD       9600
    #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)
#else
#   error "USART configuration is needed."
#endif
Title: Re: TMK keyboard firmware
Post by: hasu on Sun, 17 July 2016, 17:57:13
I'm using https://deskthority.net/w/images/1/11/Voice_of_Reason_Components.PNG (https://deskthority.net/w/images/1/11/Voice_of_Reason_Components.PNG)

It runs a ATMEGA32U2 and bpiphany has a working fork of TMK for his controllers. It also compiles and runs fine on the main TMK fork. I want to use the protocol/bluefruit stuff. How would I make this work? The controller has the TX and RX pins broken out.

I've added in this code to my config.h. What else should I do to make this work before I try this entire thing?

Code: [Select]
#ifdef __AVR_ATmega32U2__
    #define SERIAL_UART_BAUD       9600
    #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)
#else
#   error "USART configuration is needed."
#endif

See converter/x68k_usb/config.h, it appears to have USART configuration for 32U2 and I remember it works.
And of course you have to read datasheet, first.
Title: Re: TMK keyboard firmware
Post by: nikchi on Sun, 17 July 2016, 19:51:02
Thanks for the reply!

The issue now is how to get the serial working. Ideally I want to send both through usb and through serial
Title: Re: TMK keyboard firmware
Post by: hasu on Mon, 18 July 2016, 19:35:36
Thanks for the reply!

The issue now is how to get the serial working. Ideally I want to send both through usb and through serial

You can refer hhkb/rn42 codes which switches between two protocols USB(lufa) and Bluetooth(rn42) dynamically.
https://github.com/tmk/tmk_keyboard/blob/master/keyboard/hhkb/rn42/main.c#L75-L79
Title: Re: TMK keyboard firmware
Post by: RichardRahl on Thu, 04 August 2016, 08:44:39
Dear Geekhack community,

I am trying to make a firmware for my laptop keyboard because I put a raspberry pi inside my old laptop and I want to use my original keyboard with it.

This keyboard got a 26 wire flat ribbon cable. I made a pcb to be able to connect it with a teensy lc I purchased recently. I am done with the wiring and started with the programing. I learned to program with C but it was a long time ago and I forgot a lot. I used this site and program as a starting point http://www.40percent.club/2016/07/teensy-lc-fastest-van.html (http://www.40percent.club/2016/07/teensy-lc-fastest-van.html).
I modified the original program, taking out the led components adding my keyboard matrix and surprisingly I could compile the program with tones of warnings. I believe I attached the modified program to this post.

Again, surprisingly some of the buttons actually work, but most of them are not. I was trying to figure out the problem for some time now and have some idea but that's not enough.

I figured out the keyboard matrix by connecting it to a raspberry Pi writing a little program and connecting one pin to ground ... I went throw all the pins and came up with the matrix. 17 columns and 8 rows and 1 wire was use for some other thing I am not sure what. I connected all 17 cols to teensy lc 0-16 pins and the 8 rows to 17-24. I attach the keyboard matrix as well with 3 pictures.

I would appreciate any help you can give me with the program.

thank you,

RR
Title: Re: TMK keyboard firmware
Post by: a-c on Thu, 04 August 2016, 13:26:09
You need this delay. Uncomment this line in the matrix.c

wait_us(30);  // without this wait read unstable value.

Pin 13 also has a LED attached to it which may cause problems. If you are out of pins you can try removing the LED.
Title: Re: TMK keyboard firmware
Post by: RichardRahl on Thu, 04 August 2016, 14:05:08
Thank you for your answer.

wait_us(30); makes no difference as it is right now. I tried to compile the program with a hundred different way altering the program, including that one. :(

I will leave out pin 13 and see what happens but I thing someting fundamental is wrong with my program just dont know what... :(

Thanks!!
Title: Re: TMK keyboard firmware
Post by: a-c on Thu, 04 August 2016, 14:14:36
Thank you for your answer.

wait_us(30); makes no difference as it is right now. I tried to compile the program with a hundred different way altering the program, including that one. :(

I will leave out pin 13 and see what happens but I thing someting fundamental is wrong with my program just dont know what... :(

Thanks!!

Since it is a Teensy you can try programming a simple Arduino sketch that works like your Pi one and see if the switches are making connections like you expect.
Title: Re: TMK keyboard firmware
Post by: RichardRahl on Fri, 05 August 2016, 13:19:03
Hi guys! I have found the problem. :) I didn't modify the config.h .

I changed the number of rows and cols and woala... :) It is still not 100% but a lot better than before. I think now pin 13 is messing with me, I am not sure tho.
I thought I missed something basic. :)

I looked into it. When I push a button in pin19 the keyboard will type two letters on pin18 and pin19 at the same time. - Interesting - But when I push a button on pin18 it will only type the right letter. :)

I am still thrilled that I found the problem I had before.
Title: Re: TMK keyboard firmware
Post by: a-c on Fri, 05 August 2016, 13:30:40
I looked into it. When I push a button in pin19 the keyboard will type two letters on pin18 and pin19 at the same time. - Interesting - But when I push a button on pin18 it will only type the right letter. :)

Missing the break after row 1
Code: [Select]
        case 1:
            palSetPadMode(TEENSY_PIN18_IOPORT, TEENSY_PIN18, PAL_MODE_OUTPUT_PUSHPULL);
            palClearPad(TEENSY_PIN18_IOPORT, TEENSY_PIN18);
        case 2:
            palSetPadMode(TEENSY_PIN19_IOPORT, TEENSY_PIN19, PAL_MODE_OUTPUT_PUSHPULL);
            palClearPad(TEENSY_PIN19_IOPORT, TEENSY_PIN19);
            break;
Title: Re: TMK keyboard firmware
Post by: RichardRahl on Fri, 05 August 2016, 13:44:55
Thank you! :)   :thumb:

Now I have to make the other layers.
Title: Re: TMK keyboard firmware
Post by: RichardRahl on Mon, 08 August 2016, 05:40:12
Hello fellow geekhackers,

I still have a problem with my keyboard. The shift keys don't seem to work for me. I can't type capital letters with shift + letter, capslock works just fine. I tried to search for this problem with little or no success and I read the docs at tmk_core searching for capital letters but I didn't find anything helpful or if I found I didn't realize it would help me.. :(
Not to mention all the special characters I need shift for ( %, !, =, etc depending on your layout). - I hope it is a legit English sentence.
About these special characters, I haven't had time to worry about those. First, I wanted to solve the problem with the capital letters.

ctrl +c, ctrl +v, tab, capslock, numlock buttons are working for sure.

I attach some of 'my' codes, keep in mind that I tried a lot of different versions, modifications - this is just the latest one.

I would appreciate if you could point me to the right direction.
Best regrades,

RR

mod: Might seem to be wiring problem. I moved the pin9 cable with my fingers and now it works... :confused:  somewhere the connection not good, maybe a broken cable.
Title: Re: TMK keyboard firmware
Post by: Mystic-X on Tue, 09 August 2016, 11:29:58
Hey!

I need some advice from the experts.

bought one of those cheap "pro micro" boards with the atmega32u4 from ebay.

Now trying to get the TMK firmware (onekey sample) to run on this thing.
I'm using ubuntu 14.04LTS.

what I did:

modify the Makefile to
Code: [Select]
OPT_DEFS += -DBOOTLOADER_SIZE=512found this on another forum! but also tried with the default 4096 (changes nothing for me)

than I run: (from the folder where the onekey sample files are located)
make -f Makefile

Code: [Select]
-------- begin --------
avr-gcc (GCC) 4.8.2
Copyright (C) 2013 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.

Linking: onekey_lufa.elf
avr-gcc -mmcu=atmega32u4 -gdwarf-2 -DF_CPU=16000000UL -DINTERRUPT_CONTROL_ENDPOINT -DBOOTLOADER_SIZE=512 -DCONSOLE_ENABLE -DVERSION=unknown -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 -Os -funsigned-char -funsigned-bitfields -ffunction-sections -fdata-sections -fno-inline-small-functions -fpack-struct -fshort-enums -fno-strict-aliasing -Wall -Wstrict-prototypes -Wa,-adhlns=onekey_lufa.elf -I. -I../../tmk_core -I../../tmk_core/common -I../../tmk_core/protocol -I../../tmk_core/protocol/lufa -I../../tmk_core/protocol/lufa/LUFA-git -std=gnu99 -include config.h -MMD -MP -MF .dep/onekey_lufa.elf.d  obj_onekey_lufa/keymap.o obj_onekey_lufa/matrix.o obj_onekey_lufa/led.o obj_onekey_lufa/common/host.o obj_onekey_lufa/common/keyboard.o obj_onekey_lufa/common/action.o obj_onekey_lufa/common/action_tapping.o obj_onekey_lufa/common/action_macro.o obj_onekey_lufa/common/action_layer.o obj_onekey_lufa/common/action_util.o obj_onekey_lufa/common/print.o obj_onekey_lufa/common/debug.o obj_onekey_lufa/common/util.o obj_onekey_lufa/common/hook.o obj_onekey_lufa/common/avr/suspend.o obj_onekey_lufa/common/avr/xprintf.o obj_onekey_lufa/common/avr/timer.o obj_onekey_lufa/common/avr/bootloader.o obj_onekey_lufa/common/keymap.o obj_onekey_lufa/protocol/lufa/lufa.o obj_onekey_lufa/protocol/lufa/descriptor.o obj_onekey_lufa/protocol/lufa/LUFA-git/LUFA/Drivers/USB/Class/Common/HIDParser.o obj_onekey_lufa/protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/AVR8/Device_AVR8.o obj_onekey_lufa/protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/AVR8/EndpointStream_AVR8.o obj_onekey_lufa/protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/AVR8/Endpoint_AVR8.o obj_onekey_lufa/protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/AVR8/Host_AVR8.o obj_onekey_lufa/protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/AVR8/PipeStream_AVR8.o obj_onekey_lufa/protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/AVR8/Pipe_AVR8.o obj_onekey_lufa/protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/AVR8/USBController_AVR8.o obj_onekey_lufa/protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/AVR8/USBInterrupt_AVR8.o obj_onekey_lufa/protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/ConfigDescriptors.o obj_onekey_lufa/protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/DeviceStandardReq.o obj_onekey_lufa/protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/Events.o obj_onekey_lufa/protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/HostStandardReq.o obj_onekey_lufa/protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/USBTask.o --output onekey_lufa.elf -Wl,-Map=onekey_lufa.map,--cref -Wl,--gc-sections     -lm

Creating load file for Flash: onekey_lufa.hex
avr-objcopy -O ihex -R .eeprom -R .fuse -R .lock -R .signature onekey_lufa.elf onekey_lufa.hex

Creating load file for EEPROM: onekey_lufa.eep
avr-objcopy -j .eeprom --set-section-flags=.eeprom="alloc,load" \
--change-section-lma .eeprom=0 --no-change-warnings -O ihex onekey_lufa.elf onekey_lufa.eep || exit 0

Creating Extended Listing: onekey_lufa.lss
avr-objdump -h -S -z onekey_lufa.elf > onekey_lufa.lss

Creating Symbol Table: onekey_lufa.sym
avr-nm -n onekey_lufa.elf > onekey_lufa.sym

Size after:
   text    data     bss     dec     hex filename
  11816      14     123   11953    2eb1 onekey_lufa.elf

-------- end --------
looks like its working for me??!?!

than I plug in the pro micro board and short the reset pin to GND twice and than: ls /dev/tty*
-> schows me /dev/ttyACM3 as new devide

than I run:
avrdude -p atmega32u4 -P /dev/ttyACM3 -c avr109 -U flash:w:onekey_lufa.hex

Code: [Select]
Connecting to programmer: .
Found programmer: Id = "CATERIN"; type = S
    Software Version = 1.0; No Hardware Version given.
Programmer supports auto addr increment.
Programmer supports buffered memory access with buffersize=128 bytes.

Programmer supports the following devices:
    Device code: 0x44

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e9587
avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed
         To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: reading input file "onekey_lufa.hex"
avrdude: input file onekey_lufa.hex auto detected as Intel Hex
avrdude: writing flash (11830 bytes):

Writing | ################################################## | 100% 1.02s

avrdude: 11830 bytes of flash written
avrdude: verifying flash memory against onekey_lufa.hex:
avrdude: load data flash data from input file onekey_lufa.hex:
avrdude: input file onekey_lufa.hex auto detected as Intel Hex
avrdude: input file onekey_lufa.hex contains 11830 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 0.19s

avrdude: verifying ...
avrdude: 11830 bytes of flash verified

avrdude: safemode: Fuses OK (H:CB, E:D8, L:FF)

avrdude done.  Thank you.

than I unplugged the pro micro from the USB and plugged it in again

than: dmesg |tail shows:
Code: [Select]
[158341.894298] hid-generic 0003:FEED:1111.000A: hiddev0,hidraw1: USB HID v1.11 Device [geekhack Onekey] on usb-0000:00:1d.0-2/input1
[158344.428219] usb 5-2: USB disconnect, device number 13
[158346.612080] usb 5-2: new full-speed USB device number 14 using uhci_hcd
[158346.793139] usb 5-2: New USB device found, idVendor=feed, idProduct=1111
[158346.793145] usb 5-2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[158346.793149] usb 5-2: Product: Onekey
[158346.793152] usb 5-2: Manufacturer: geekhack
[158346.798787] input: geekhack Onekey as /devices/pci0000:00/0000:00:1d.0/usb5/5-2/5-2:1.0/input/input16
[158346.798920] hid-generic 0003:FEED:1111.000B: input,hidraw0: USB HID v1.11 Keyboard [geekhack Onekey] on usb-0000:00:1d.0-2/input0
[158346.802278] hid-generic 0003:FEED:1111.000C: hiddev0,hidraw1: USB HID v1.11 Device [geekhack Onekey] on usb-0000:00:1d.0-2/input1

looks ok for me
BUT
If I connect PB0 and PB1 nothing happens!
Yes I have really connected the correct pins... I had a look ath the schematics of this thing and PB0=D14, PB1=D15

Any idea whats wrong with that?
I have tried 2 of this pro micro boards, they behave the same way.

I really hope someone has an advice for me.
Title: Re: TMK keyboard firmware
Post by: a-c on Tue, 09 August 2016, 11:47:56

If I connect PB0 and PB1 nothing happens!
Yes I have really connected the correct pins... I had a look ath the schematics of this thing and PB0=D14, PB1=D15


B0 is connected to the LED.

Pick a different pin. http://i.imgur.com/wMNx2u6.png
Title: Re: TMK keyboard firmware
Post by: Dwarlorf on Fri, 19 August 2016, 22:25:33
This is my first try at TMK so theres probably a lot going wrong. I'll just spill it all out.

Matrix Wiring: http://www.servimg.com/view/11209166/175

Teensy wiring: http://www.servimg.com/view/11209166/174

I used this guide made by Matteo: https://deskthority.net/workshop-f7/how-to-build-your-very-own-keyboard-firmware-t7177.html#p141386

I'm getting this message when compiling hexfile:
More
$ make -f Makefile
/usr/bin/sh: dfu-programmer: command not found
/usr/bin/sh: dfu-programmer: command not found

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


mkdir -p obj_gh60_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 -fdata-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../../tmk_core -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_gh60_lufa_keymap_poker.o.d  keymap_poker.c -o obj_gh60_lufa/keymap_poker.o
In file included from keymap_poker.c:1:
keymap_common.h:43:8: error: parameter name missing
keymap_poker.c:5: warning: implicit declaration of function 'KEYMAP'
keymap_poker.c:5: warning: missing braces around initializer
keymap_poker.c:5: warning: (near initialization for 'keymaps[0]')
keymap_poker.c:5: error: initializer element is not constant
keymap_poker.c:5: error: (near initialization for 'keymaps[0][0][0]')
make: *** [obj_gh60_lufa/keymap_poker.o] Error 1


This is what I've done:
makefile
More
#----------------------------------------------------------------------------
-----------------------------------------------------

# Target file name (without extension).
TARGET = gh60_lufa

# Directory common source filess exist
TMK_DIR = ../../tmk_core

# Directory keyboard dependent files exist
TARGET_DIR = .

# project specific files
SRC =   keymap_common.c \
   matrix.c \
   led.c

ifdef KEYMAP
    SRC := keymap_$(KEYMAP).c $(SRC)
else
    SRC := keymap_poker.c $(SRC)
endif

CONFIG_H = config.h


# MCU name
MCU = at90usb1287
#MCU = atmega32u4

# Processor frequency.
#     This will define a symbol, F_CPU, in all source code files equal to the
#     processor frequency in Hz. You can then use this symbol in your source code to
#     calculate timings. Do NOT tack on a 'UL' at the end, this will be done
#     automatically to create a 32-bit value in your source code.
#
#     This will be an integer division of F_USB below, as it is sourced by
#     F_USB after it has run through any CPU prescalers. Note that this value
#     does not *change* the processor frequency - it should merely be updated to
#     reflect the processor speed set externally so that the code can use accurate
#     software delays.
F_CPU = 16000000


#
# LUFA specific
#
# Target architecture (see library "Board Types" documentation).
ARCH = AVR8

# Input clock frequency.
#     This will define a symbol, F_USB, in all source code files equal to the
#     input clock frequency (before any prescaling is performed) in Hz. This value may
#     differ from F_CPU if prescaling is used on the latter, and is required as the
#     raw input clock is fed directly to the PLL sections of the AVR for high speed
#     clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
#     at the end, this will be done automatically to create a 32-bit value in your
#     source code.
#
#     If no clock division is performed on the input clock inside the AVR (via the
#     CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
F_USB = $(F_CPU)

# Interrupt driven control endpoint task(+60)
OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT


# Boot Section Size in *bytes*
#   Teensy halfKay   512
#   Teensy++ halfKay 1024
#   Atmel DFU loader 4096
#   LUFA bootloader  4096
#   USBaspLoader     2048
OPT_DEFS += -DBOOTLOADER_SIZE=4096


# 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


# Optimize size but this may cause error "relocation truncated to fit"
#EXTRALDFLAGS = -Wl,--relax

# Search Path
VPATH += $(TARGET_DIR)
VPATH += $(TMK_DIR)

include $(TMK_DIR)/protocol/lufa.mk
include $(TMK_DIR)/common.mk
include $(TMK_DIR)/rules.mk

Config.h
More
#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         GH34
#define DESCRIPTION     t.m.k. keyboard firmware for GH60

/* key matrix size */
#define MATRIX_ROWS 6
#define MATRIX_COLS 7

/* 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)) \
)



/*
 * Feature disable options
 *  These options are also useful to firmware size reduction.
 */

/* disable debug print */
//#define NO_DEBUG

/* disable print */
//#define NO_PRINT

/* disable action features */
//#define NO_ACTION_LAYER
//#define NO_ACTION_TAPPING
//#define NO_ACTION_ONESHOT
//#define NO_ACTION_MACRO
//#define NO_ACTION_FUNCTION

#endif



Matrix.c
More
/*
 * scan matrix
 */
#include <stdint.h>
#include <stdbool.h>
#include <avr/io.h>
#include <util/delay.h>
#include "print.h"
#include "debug.h"
#include "util.h"
#include "matrix.h"


#ifndef DEBOUNCE
#   define DEBOUNCE   5
#endif
static uint8_t debouncing = DEBOUNCE;

/* matrix state(1:on, 0:off) */
static matrix_row_t matrix[MATRIX_ROWS];
static matrix_row_t matrix_debouncing[MATRIX_ROWS];

static matrix_row_t read_cols(void);
static void init_cols(void);
static void unselect_rows(void);
static void select_row(uint8_t row);


inline
uint8_t matrix_rows(void)
{
    return MATRIX_ROWS;
}

inline
uint8_t matrix_cols(void)
{
    return MATRIX_COLS;
}

void matrix_init(void)
{
    // 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;
    }
}

uint8_t matrix_scan(void)
{
    for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
        select_row(i);
        _delay_us(30);  // without this wait read unstable value.
        matrix_row_t cols = read_cols();
        if (matrix_debouncing != cols) {
            matrix_debouncing = cols;
            if (debouncing) {
                debug("bounce!: "); debug_hex(debouncing); debug("\n");
            }
            debouncing = DEBOUNCE;
        }
        unselect_rows();
    }

    if (debouncing) {
        if (--debouncing) {
            _delay_ms(1);
        } else {
            for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
                matrix = matrix_debouncing;
            }
        }
    }

    return 1;
}

bool matrix_is_modified(void)
{
    if (debouncing) return false;
    return true;
}

inline
bool matrix_is_on(uint8_t row, uint8_t col)
{
    return (matrix[row] & ((matrix_row_t)1<<col));
}

inline
matrix_row_t matrix_get_row(uint8_t row)
{
    return matrix[row];
}

void matrix_print(void)
{
    print("\nr/c 0123456789ABCDEF\n");
    for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
        phex(row); print(": ");
        pbin_reverse16(matrix_get_row(row));
        print("\n");
    }
}

uint8_t matrix_key_count(void)
{
    uint8_t count = 0;
    for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
        count += bitpop16(matrix);
    }
    return count;
}

/* Column pin configuration
 * col: 0   1   2   3   4   5  6
 * pin: F0  F1  F4  F5  F6 F7 B6
  */
static void  init_cols(void)
{
    // Input with pull-up(DDR:0, PORT:1)
    DDRF  &= ~(1<<0 | 1<<1| 1<<4| 1<<5| 1<<7);
    PORTF |=  (1<<0 | 1<<1| 1<<4| 1<<5| 1<<7);
    DDRB  &= ~(1<<6);
    PORTB |=  (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)) |
}

/* Row pin configuration
 * row: 0   1   2   3   4  5
 * pin: B0  B1  B2  B3  B7 D0
 */
static void unselect_rows(void)
{
    // Hi-Z(DDR:0, PORT:0) to unselect
    DDRB  &= ~0b10001111;
    PORTB &= ~0b10001111;
    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<<7;
            PORTB &= ~(1<<7);
            break;
        case 5:
            DDRD  |= (1<<0);
            PORTD &= ~(1<<0);
            break;
    }
}



keymap_common.h
More
#ifndef KEYMAP_COMMON_H
#define KEYMAP_COMMON_H

#include <stdint.h>
#include <stdbool.h>
#include <avr/pgmspace.h>
#include "keycode.h"
#include "action.h"
#include "action_macro.h"
#include "report.h"
#include "host.h"
#include "print.h"
#include "debug.h"
#include "keymap.h"


extern const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS];


/* GH34 keymap definition macro
 * K2C, K31 and  K3C are extra keys for ISO
 */
#define KEYMAP( \
    K00, K01, K02, K03, K04, K05, K06, \
    K10, K11, K12, K13, K14, K15, K16, \
    K20, K21, K22, K23, K24, K25, K26, \
       ,    ,    , K33, K34, K35,    , \
       , K41,    , K43, K44, K45, K46, \
    K50, K51, K52,    , K54, K55,    , \
)
#endif

Keymap_poker.c (I made this very simple to get a better understanding of it all.)
More
#include "keymap_common.h"

const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
    /* 0: qwerty */
    KEYMAP(1, 1,   1,   1,   1,   1,   1,  \
           1, 1,  1,  1,   1,  1,   1,  \
           1, 1,   1,   1,   1,   1,   1,   \
           1, 1,  1, \
           1, 1, 1, 1, 1, \
           1, 1, 1, 1, 1),
};

I understand it's quite a lot but any help is appreciated. Please be reminded this is my first try.
Title: Re: TMK keyboard firmware
Post by: Moistgun on Sat, 20 August 2016, 00:52:00
This is my first try at TMK so theres probably a lot going wrong. I'll just spill it all out.

Matrix Wiring: http://www.servimg.com/view/11209166/175

Teensy wiring: http://www.servimg.com/view/11209166/174

I used this guide made by Matteo: https://deskthority.net/workshop-f7/how-to-build-your-very-own-keyboard-firmware-t7177.html#p141386

I'm getting this message when compiling hexfile:
More
$ make -f Makefile
/usr/bin/sh: dfu-programmer: command not found
/usr/bin/sh: dfu-programmer: command not found

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


mkdir -p obj_gh60_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 -fdata-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../../tmk_core -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_gh60_lufa_keymap_poker.o.d  keymap_poker.c -o obj_gh60_lufa/keymap_poker.o
In file included from keymap_poker.c:1:
keymap_common.h:43:8: error: parameter name missing
keymap_poker.c:5: warning: implicit declaration of function 'KEYMAP'
keymap_poker.c:5: warning: missing braces around initializer
keymap_poker.c:5: warning: (near initialization for 'keymaps[0]')
keymap_poker.c:5: error: initializer element is not constant
keymap_poker.c:5: error: (near initialization for 'keymaps[0][0][0]')
make: *** [obj_gh60_lufa/keymap_poker.o] Error 1


This is what I've done:
makefile
More
#----------------------------------------------------------------------------
-----------------------------------------------------

# Target file name (without extension).
TARGET = gh60_lufa

# Directory common source filess exist
TMK_DIR = ../../tmk_core

# Directory keyboard dependent files exist
TARGET_DIR = .

# project specific files
SRC =   keymap_common.c \
   matrix.c \
   led.c

ifdef KEYMAP
    SRC := keymap_$(KEYMAP).c $(SRC)
else
    SRC := keymap_poker.c $(SRC)
endif

CONFIG_H = config.h


# MCU name
MCU = at90usb1287
#MCU = atmega32u4

# Processor frequency.
#     This will define a symbol, F_CPU, in all source code files equal to the
#     processor frequency in Hz. You can then use this symbol in your source code to
#     calculate timings. Do NOT tack on a 'UL' at the end, this will be done
#     automatically to create a 32-bit value in your source code.
#
#     This will be an integer division of F_USB below, as it is sourced by
#     F_USB after it has run through any CPU prescalers. Note that this value
#     does not *change* the processor frequency - it should merely be updated to
#     reflect the processor speed set externally so that the code can use accurate
#     software delays.
F_CPU = 16000000


#
# LUFA specific
#
# Target architecture (see library "Board Types" documentation).
ARCH = AVR8

# Input clock frequency.
#     This will define a symbol, F_USB, in all source code files equal to the
#     input clock frequency (before any prescaling is performed) in Hz. This value may
#     differ from F_CPU if prescaling is used on the latter, and is required as the
#     raw input clock is fed directly to the PLL sections of the AVR for high speed
#     clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
#     at the end, this will be done automatically to create a 32-bit value in your
#     source code.
#
#     If no clock division is performed on the input clock inside the AVR (via the
#     CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
F_USB = $(F_CPU)

# Interrupt driven control endpoint task(+60)
OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT


# Boot Section Size in *bytes*
#   Teensy halfKay   512
#   Teensy++ halfKay 1024
#   Atmel DFU loader 4096
#   LUFA bootloader  4096
#   USBaspLoader     2048
OPT_DEFS += -DBOOTLOADER_SIZE=4096


# 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


# Optimize size but this may cause error "relocation truncated to fit"
#EXTRALDFLAGS = -Wl,--relax

# Search Path
VPATH += $(TARGET_DIR)
VPATH += $(TMK_DIR)

include $(TMK_DIR)/protocol/lufa.mk
include $(TMK_DIR)/common.mk
include $(TMK_DIR)/rules.mk

Config.h
More
#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         GH34
#define DESCRIPTION     t.m.k. keyboard firmware for GH60

/* key matrix size */
#define MATRIX_ROWS 6
#define MATRIX_COLS 7

/* 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)) \
)



/*
 * Feature disable options
 *  These options are also useful to firmware size reduction.
 */

/* disable debug print */
//#define NO_DEBUG

/* disable print */
//#define NO_PRINT

/* disable action features */
//#define NO_ACTION_LAYER
//#define NO_ACTION_TAPPING
//#define NO_ACTION_ONESHOT
//#define NO_ACTION_MACRO
//#define NO_ACTION_FUNCTION

#endif



Matrix.c
More
/*
 * scan matrix
 */
#include <stdint.h>
#include <stdbool.h>
#include <avr/io.h>
#include <util/delay.h>
#include "print.h"
#include "debug.h"
#include "util.h"
#include "matrix.h"


#ifndef DEBOUNCE
#   define DEBOUNCE   5
#endif
static uint8_t debouncing = DEBOUNCE;

/* matrix state(1:on, 0:off) */
static matrix_row_t matrix[MATRIX_ROWS];
static matrix_row_t matrix_debouncing[MATRIX_ROWS];

static matrix_row_t read_cols(void);
static void init_cols(void);
static void unselect_rows(void);
static void select_row(uint8_t row);


inline
uint8_t matrix_rows(void)
{
    return MATRIX_ROWS;
}

inline
uint8_t matrix_cols(void)
{
    return MATRIX_COLS;
}

void matrix_init(void)
{
    // 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;
    }
}

uint8_t matrix_scan(void)
{
    for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
        select_row(i);
        _delay_us(30);  // without this wait read unstable value.
        matrix_row_t cols = read_cols();
        if (matrix_debouncing != cols) {
            matrix_debouncing = cols;
            if (debouncing) {
                debug("bounce!: "); debug_hex(debouncing); debug("\n");
            }
            debouncing = DEBOUNCE;
        }
        unselect_rows();
    }

    if (debouncing) {
        if (--debouncing) {
            _delay_ms(1);
        } else {
            for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
                matrix = matrix_debouncing;
            }
        }
    }

    return 1;
}

bool matrix_is_modified(void)
{
    if (debouncing) return false;
    return true;
}

inline
bool matrix_is_on(uint8_t row, uint8_t col)
{
    return (matrix[row] & ((matrix_row_t)1<<col));
}

inline
matrix_row_t matrix_get_row(uint8_t row)
{
    return matrix[row];
}

void matrix_print(void)
{
    print("\nr/c 0123456789ABCDEF\n");
    for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
        phex(row); print(": ");
        pbin_reverse16(matrix_get_row(row));
        print("\n");
    }
}

uint8_t matrix_key_count(void)
{
    uint8_t count = 0;
    for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
        count += bitpop16(matrix);
    }
    return count;
}

/* Column pin configuration
 * col: 0   1   2   3   4   5  6
 * pin: F0  F1  F4  F5  F6 F7 B6
  */
static void  init_cols(void)
{
    // Input with pull-up(DDR:0, PORT:1)
    DDRF  &= ~(1<<0 | 1<<1| 1<<4| 1<<5| 1<<7);
    PORTF |=  (1<<0 | 1<<1| 1<<4| 1<<5| 1<<7);
    DDRB  &= ~(1<<6);
    PORTB |=  (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)) |
}

/* Row pin configuration
 * row: 0   1   2   3   4  5
 * pin: B0  B1  B2  B3  B7 D0
 */
static void unselect_rows(void)
{
    // Hi-Z(DDR:0, PORT:0) to unselect
    DDRB  &= ~0b10001111;
    PORTB &= ~0b10001111;
    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<<7;
            PORTB &= ~(1<<7);
            break;
        case 5:
            DDRD  |= (1<<0);
            PORTD &= ~(1<<0);
            break;
    }
}



keymap_common.h
More
#ifndef KEYMAP_COMMON_H
#define KEYMAP_COMMON_H

#include <stdint.h>
#include <stdbool.h>
#include <avr/pgmspace.h>
#include "keycode.h"
#include "action.h"
#include "action_macro.h"
#include "report.h"
#include "host.h"
#include "print.h"
#include "debug.h"
#include "keymap.h"


extern const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS];


/* GH34 keymap definition macro
 * K2C, K31 and  K3C are extra keys for ISO
 */
#define KEYMAP( \
    K00, K01, K02, K03, K04, K05, K06, \
    K10, K11, K12, K13, K14, K15, K16, \
    K20, K21, K22, K23, K24, K25, K26, \
       ,    ,    , K33, K34, K35,    , \
       , K41,    , K43, K44, K45, K46, \
    K50, K51, K52,    , K54, K55,    , \
)
#endif

Keymap_poker.c (I made this very simple to get a better understanding of it all.)
More
#include "keymap_common.h"

const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
    /* 0: qwerty */
    KEYMAP(1, 1,   1,   1,   1,   1,   1,  \
           1, 1,  1,  1,   1,  1,   1,  \
           1, 1,   1,   1,   1,   1,   1,   \
           1, 1,  1, \
           1, 1, 1, 1, 1, \
           1, 1, 1, 1, 1),
};

I understand it's quite a lot but any help is appreciated. Please be reminded this is my first try.

I recommend just uploading all these in a folder to dropbox and sharing the link.
Someone is more likely willing to look through your code if they can use their editor.
Title: Re: TMK keyboard firmware
Post by: Dwarlorf on Sat, 20 August 2016, 03:38:09
This is my first try at TMK so theres probably a lot going wrong. I'll just spill it all out.

Matrix Wiring: http://www.servimg.com/view/11209166/175

Teensy wiring: http://www.servimg.com/view/11209166/174

I used this guide made by Matteo: https://deskthority.net/workshop-f7/how-to-build-your-very-own-keyboard-firmware-t7177.html#p141386

I'm getting this message when compiling hexfile:
More
$ make -f Makefile
/usr/bin/sh: dfu-programmer: command not found
/usr/bin/sh: dfu-programmer: command not found

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


mkdir -p obj_gh60_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 -fdata-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../../tmk_core -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_gh60_lufa_keymap_poker.o.d  keymap_poker.c -o obj_gh60_lufa/keymap_poker.o
In file included from keymap_poker.c:1:
keymap_common.h:43:8: error: parameter name missing
keymap_poker.c:5: warning: implicit declaration of function 'KEYMAP'
keymap_poker.c:5: warning: missing braces around initializer
keymap_poker.c:5: warning: (near initialization for 'keymaps[0]')
keymap_poker.c:5: error: initializer element is not constant
keymap_poker.c:5: error: (near initialization for 'keymaps[0][0][0]')
make: *** [obj_gh60_lufa/keymap_poker.o] Error 1


This is what I've done:
makefile
More
#----------------------------------------------------------------------------
-----------------------------------------------------

# Target file name (without extension).
TARGET = gh60_lufa

# Directory common source filess exist
TMK_DIR = ../../tmk_core

# Directory keyboard dependent files exist
TARGET_DIR = .

# project specific files
SRC =   keymap_common.c \
   matrix.c \
   led.c

ifdef KEYMAP
    SRC := keymap_$(KEYMAP).c $(SRC)
else
    SRC := keymap_poker.c $(SRC)
endif

CONFIG_H = config.h


# MCU name
MCU = at90usb1287
#MCU = atmega32u4

# Processor frequency.
#     This will define a symbol, F_CPU, in all source code files equal to the
#     processor frequency in Hz. You can then use this symbol in your source code to
#     calculate timings. Do NOT tack on a 'UL' at the end, this will be done
#     automatically to create a 32-bit value in your source code.
#
#     This will be an integer division of F_USB below, as it is sourced by
#     F_USB after it has run through any CPU prescalers. Note that this value
#     does not *change* the processor frequency - it should merely be updated to
#     reflect the processor speed set externally so that the code can use accurate
#     software delays.
F_CPU = 16000000


#
# LUFA specific
#
# Target architecture (see library "Board Types" documentation).
ARCH = AVR8

# Input clock frequency.
#     This will define a symbol, F_USB, in all source code files equal to the
#     input clock frequency (before any prescaling is performed) in Hz. This value may
#     differ from F_CPU if prescaling is used on the latter, and is required as the
#     raw input clock is fed directly to the PLL sections of the AVR for high speed
#     clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
#     at the end, this will be done automatically to create a 32-bit value in your
#     source code.
#
#     If no clock division is performed on the input clock inside the AVR (via the
#     CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
F_USB = $(F_CPU)

# Interrupt driven control endpoint task(+60)
OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT


# Boot Section Size in *bytes*
#   Teensy halfKay   512
#   Teensy++ halfKay 1024
#   Atmel DFU loader 4096
#   LUFA bootloader  4096
#   USBaspLoader     2048
OPT_DEFS += -DBOOTLOADER_SIZE=4096


# 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


# Optimize size but this may cause error "relocation truncated to fit"
#EXTRALDFLAGS = -Wl,--relax

# Search Path
VPATH += $(TARGET_DIR)
VPATH += $(TMK_DIR)

include $(TMK_DIR)/protocol/lufa.mk
include $(TMK_DIR)/common.mk
include $(TMK_DIR)/rules.mk

Config.h
More
#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         GH34
#define DESCRIPTION     t.m.k. keyboard firmware for GH60

/* key matrix size */
#define MATRIX_ROWS 6
#define MATRIX_COLS 7

/* 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)) \
)



/*
 * Feature disable options
 *  These options are also useful to firmware size reduction.
 */

/* disable debug print */
//#define NO_DEBUG

/* disable print */
//#define NO_PRINT

/* disable action features */
//#define NO_ACTION_LAYER
//#define NO_ACTION_TAPPING
//#define NO_ACTION_ONESHOT
//#define NO_ACTION_MACRO
//#define NO_ACTION_FUNCTION

#endif



Matrix.c
More
/*
 * scan matrix
 */
#include <stdint.h>
#include <stdbool.h>
#include <avr/io.h>
#include <util/delay.h>
#include "print.h"
#include "debug.h"
#include "util.h"
#include "matrix.h"


#ifndef DEBOUNCE
#   define DEBOUNCE   5
#endif
static uint8_t debouncing = DEBOUNCE;

/* matrix state(1:on, 0:off) */
static matrix_row_t matrix[MATRIX_ROWS];
static matrix_row_t matrix_debouncing[MATRIX_ROWS];

static matrix_row_t read_cols(void);
static void init_cols(void);
static void unselect_rows(void);
static void select_row(uint8_t row);


inline
uint8_t matrix_rows(void)
{
    return MATRIX_ROWS;
}

inline
uint8_t matrix_cols(void)
{
    return MATRIX_COLS;
}

void matrix_init(void)
{
    // 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;
    }
}

uint8_t matrix_scan(void)
{
    for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
        select_row(i);
        _delay_us(30);  // without this wait read unstable value.
        matrix_row_t cols = read_cols();
        if (matrix_debouncing != cols) {
            matrix_debouncing = cols;
            if (debouncing) {
                debug("bounce!: "); debug_hex(debouncing); debug("\n");
            }
            debouncing = DEBOUNCE;
        }
        unselect_rows();
    }

    if (debouncing) {
        if (--debouncing) {
            _delay_ms(1);
        } else {
            for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
                matrix = matrix_debouncing;
            }
        }
    }

    return 1;
}

bool matrix_is_modified(void)
{
    if (debouncing) return false;
    return true;
}

inline
bool matrix_is_on(uint8_t row, uint8_t col)
{
    return (matrix[row] & ((matrix_row_t)1<<col));
}

inline
matrix_row_t matrix_get_row(uint8_t row)
{
    return matrix[row];
}

void matrix_print(void)
{
    print("\nr/c 0123456789ABCDEF\n");
    for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
        phex(row); print(": ");
        pbin_reverse16(matrix_get_row(row));
        print("\n");
    }
}

uint8_t matrix_key_count(void)
{
    uint8_t count = 0;
    for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
        count += bitpop16(matrix);
    }
    return count;
}

/* Column pin configuration
 * col: 0   1   2   3   4   5  6
 * pin: F0  F1  F4  F5  F6 F7 B6
  */
static void  init_cols(void)
{
    // Input with pull-up(DDR:0, PORT:1)
    DDRF  &= ~(1<<0 | 1<<1| 1<<4| 1<<5| 1<<7);
    PORTF |=  (1<<0 | 1<<1| 1<<4| 1<<5| 1<<7);
    DDRB  &= ~(1<<6);
    PORTB |=  (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)) |
}

/* Row pin configuration
 * row: 0   1   2   3   4  5
 * pin: B0  B1  B2  B3  B7 D0
 */
static void unselect_rows(void)
{
    // Hi-Z(DDR:0, PORT:0) to unselect
    DDRB  &= ~0b10001111;
    PORTB &= ~0b10001111;
    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<<7;
            PORTB &= ~(1<<7);
            break;
        case 5:
            DDRD  |= (1<<0);
            PORTD &= ~(1<<0);
            break;
    }
}



keymap_common.h
More
#ifndef KEYMAP_COMMON_H
#define KEYMAP_COMMON_H

#include <stdint.h>
#include <stdbool.h>
#include <avr/pgmspace.h>
#include "keycode.h"
#include "action.h"
#include "action_macro.h"
#include "report.h"
#include "host.h"
#include "print.h"
#include "debug.h"
#include "keymap.h"


extern const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS];


/* GH34 keymap definition macro
 * K2C, K31 and  K3C are extra keys for ISO
 */
#define KEYMAP( \
    K00, K01, K02, K03, K04, K05, K06, \
    K10, K11, K12, K13, K14, K15, K16, \
    K20, K21, K22, K23, K24, K25, K26, \
       ,    ,    , K33, K34, K35,    , \
       , K41,    , K43, K44, K45, K46, \
    K50, K51, K52,    , K54, K55,    , \
)
#endif

Keymap_poker.c (I made this very simple to get a better understanding of it all.)
More
#include "keymap_common.h"

const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
    /* 0: qwerty */
    KEYMAP(1, 1,   1,   1,   1,   1,   1,  \
           1, 1,  1,  1,   1,  1,   1,  \
           1, 1,   1,   1,   1,   1,   1,   \
           1, 1,  1, \
           1, 1, 1, 1, 1, \
           1, 1, 1, 1, 1),
};

I understand it's quite a lot but any help is appreciated. Please be reminded this is my first try.

I recommend just uploading all these in a folder to dropbox and sharing the link.
Someone is more likely willing to look through your code if they can use their editor.
Thank you for your help. I hope the link works. I had to install dropbox, never used it before.
https://www.dropbox.com/sh/gyt9cdhe03ukz5g/AADBFYGX0Cr1--R5BsmDOhi6a?dl=0
Title: Re: TMK keyboard firmware
Post by: Tactile on Sat, 20 August 2016, 11:27:00
I think your keymap matrix (array, is that the right word?) in keymap_common.h is incomplete. Here's a piece of mine:

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: suicidal_orange on Sat, 20 August 2016, 11:37:47
This is my first try at TMK so theres probably a lot going wrong. I'll just spill it all out.

Matrix Wiring: http://www.servimg.com/view/11209166/175

Teensy wiring: http://www.servimg.com/view/11209166/174

I used this guide made by Matteo: https://deskthority.net/workshop-f7/how-to-build-your-very-own-keyboard-firmware-t7177.html#p141386

I'm getting this message when compiling hexfile:
More
$ make -f Makefile
/usr/bin/sh: dfu-programmer: command not found
/usr/bin/sh: dfu-programmer: command not found

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


mkdir -p obj_gh60_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 -fdata-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../../tmk_core -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_gh60_lufa_keymap_poker.o.d  keymap_poker.c -o obj_gh60_lufa/keymap_poker.o
In file included from keymap_poker.c:1:
keymap_common.h:43:8: error: parameter name missing
keymap_poker.c:5: warning: implicit declaration of function 'KEYMAP'
keymap_poker.c:5: warning: missing braces around initializer
keymap_poker.c:5: warning: (near initialization for 'keymaps[0]')
keymap_poker.c:5: error: initializer element is not constant
keymap_poker.c:5: error: (near initialization for 'keymaps[0][0][0]')
make: *** [obj_gh60_lufa/keymap_poker.o] Error 1


This is what I've done:
makefile
More
#----------------------------------------------------------------------------
-----------------------------------------------------

# Target file name (without extension).
TARGET = gh60_lufa

# Directory common source filess exist
TMK_DIR = ../../tmk_core

# Directory keyboard dependent files exist
TARGET_DIR = .

# project specific files
SRC =   keymap_common.c \
   matrix.c \
   led.c

ifdef KEYMAP
    SRC := keymap_$(KEYMAP).c $(SRC)
else
    SRC := keymap_poker.c $(SRC)
endif

CONFIG_H = config.h


# MCU name
MCU = at90usb1287
#MCU = atmega32u4

# Processor frequency.
#     This will define a symbol, F_CPU, in all source code files equal to the
#     processor frequency in Hz. You can then use this symbol in your source code to
#     calculate timings. Do NOT tack on a 'UL' at the end, this will be done
#     automatically to create a 32-bit value in your source code.
#
#     This will be an integer division of F_USB below, as it is sourced by
#     F_USB after it has run through any CPU prescalers. Note that this value
#     does not *change* the processor frequency - it should merely be updated to
#     reflect the processor speed set externally so that the code can use accurate
#     software delays.
F_CPU = 16000000


#
# LUFA specific
#
# Target architecture (see library "Board Types" documentation).
ARCH = AVR8

# Input clock frequency.
#     This will define a symbol, F_USB, in all source code files equal to the
#     input clock frequency (before any prescaling is performed) in Hz. This value may
#     differ from F_CPU if prescaling is used on the latter, and is required as the
#     raw input clock is fed directly to the PLL sections of the AVR for high speed
#     clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
#     at the end, this will be done automatically to create a 32-bit value in your
#     source code.
#
#     If no clock division is performed on the input clock inside the AVR (via the
#     CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
F_USB = $(F_CPU)

# Interrupt driven control endpoint task(+60)
OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT


# Boot Section Size in *bytes*
#   Teensy halfKay   512
#   Teensy++ halfKay 1024
#   Atmel DFU loader 4096
#   LUFA bootloader  4096
#   USBaspLoader     2048
OPT_DEFS += -DBOOTLOADER_SIZE=4096


# 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


# Optimize size but this may cause error "relocation truncated to fit"
#EXTRALDFLAGS = -Wl,--relax

# Search Path
VPATH += $(TARGET_DIR)
VPATH += $(TMK_DIR)

include $(TMK_DIR)/protocol/lufa.mk
include $(TMK_DIR)/common.mk
include $(TMK_DIR)/rules.mk

Config.h
More
#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         GH34
#define DESCRIPTION     t.m.k. keyboard firmware for GH60

/* key matrix size */
#define MATRIX_ROWS 6
#define MATRIX_COLS 7

/* 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)) \
)



/*
 * Feature disable options
 *  These options are also useful to firmware size reduction.
 */

/* disable debug print */
//#define NO_DEBUG

/* disable print */
//#define NO_PRINT

/* disable action features */
//#define NO_ACTION_LAYER
//#define NO_ACTION_TAPPING
//#define NO_ACTION_ONESHOT
//#define NO_ACTION_MACRO
//#define NO_ACTION_FUNCTION

#endif



Matrix.c
More
/*
 * scan matrix
 */
#include <stdint.h>
#include <stdbool.h>
#include <avr/io.h>
#include <util/delay.h>
#include "print.h"
#include "debug.h"
#include "util.h"
#include "matrix.h"


#ifndef DEBOUNCE
#   define DEBOUNCE   5
#endif
static uint8_t debouncing = DEBOUNCE;

/* matrix state(1:on, 0:off) */
static matrix_row_t matrix[MATRIX_ROWS];
static matrix_row_t matrix_debouncing[MATRIX_ROWS];

static matrix_row_t read_cols(void);
static void init_cols(void);
static void unselect_rows(void);
static void select_row(uint8_t row);


inline
uint8_t matrix_rows(void)
{
    return MATRIX_ROWS;
}

inline
uint8_t matrix_cols(void)
{
    return MATRIX_COLS;
}

void matrix_init(void)
{
    // 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;
    }
}

uint8_t matrix_scan(void)
{
    for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
        select_row(i);
        _delay_us(30);  // without this wait read unstable value.
        matrix_row_t cols = read_cols();
        if (matrix_debouncing != cols) {
            matrix_debouncing = cols;
            if (debouncing) {
                debug("bounce!: "); debug_hex(debouncing); debug("\n");
            }
            debouncing = DEBOUNCE;
        }
        unselect_rows();
    }

    if (debouncing) {
        if (--debouncing) {
            _delay_ms(1);
        } else {
            for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
                matrix = matrix_debouncing;
            }
        }
    }

    return 1;
}

bool matrix_is_modified(void)
{
    if (debouncing) return false;
    return true;
}

inline
bool matrix_is_on(uint8_t row, uint8_t col)
{
    return (matrix[row] & ((matrix_row_t)1<<col));
}

inline
matrix_row_t matrix_get_row(uint8_t row)
{
    return matrix[row];
}

void matrix_print(void)
{
    print("\nr/c 0123456789ABCDEF\n");
    for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
        phex(row); print(": ");
        pbin_reverse16(matrix_get_row(row));
        print("\n");
    }
}

uint8_t matrix_key_count(void)
{
    uint8_t count = 0;
    for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
        count += bitpop16(matrix);
    }
    return count;
}

/* Column pin configuration
 * col: 0   1   2   3   4   5  6
 * pin: F0  F1  F4  F5  F6 F7 B6
  */
static void  init_cols(void)
{
    // Input with pull-up(DDR:0, PORT:1)
    DDRF  &= ~(1<<0 | 1<<1| 1<<4| 1<<5| 1<<7);
    PORTF |=  (1<<0 | 1<<1| 1<<4| 1<<5| 1<<7);
    DDRB  &= ~(1<<6);
    PORTB |=  (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)) |
}

/* Row pin configuration
 * row: 0   1   2   3   4  5
 * pin: B0  B1  B2  B3  B7 D0
 */
static void unselect_rows(void)
{
    // Hi-Z(DDR:0, PORT:0) to unselect
    DDRB  &= ~0b10001111;
    PORTB &= ~0b10001111;
    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<<7;
            PORTB &= ~(1<<7);
            break;
        case 5:
            DDRD  |= (1<<0);
            PORTD &= ~(1<<0);
            break;
    }
}



keymap_common.h
More
#ifndef KEYMAP_COMMON_H
#define KEYMAP_COMMON_H

#include <stdint.h>
#include <stdbool.h>
#include <avr/pgmspace.h>
#include "keycode.h"
#include "action.h"
#include "action_macro.h"
#include "report.h"
#include "host.h"
#include "print.h"
#include "debug.h"
#include "keymap.h"


extern const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS];


/* GH34 keymap definition macro
 * K2C, K31 and  K3C are extra keys for ISO
 */
#define KEYMAP( \
    K00, K01, K02, K03, K04, K05, K06, \
    K10, K11, K12, K13, K14, K15, K16, \
    K20, K21, K22, K23, K24, K25, K26, \
       ,    ,    , K33, K34, K35,    , \
       , K41,    , K43, K44, K45, K46, \
    K50, K51, K52,    , K54, K55,    , \
)
#endif

Keymap_poker.c (I made this very simple to get a better understanding of it all.)
More
#include "keymap_common.h"

const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
    /* 0: qwerty */
    KEYMAP(1, 1,   1,   1,   1,   1,   1,  \
           1, 1,  1,  1,   1,  1,   1,  \
           1, 1,   1,   1,   1,   1,   1,   \
           1, 1,  1, \
           1, 1, 1, 1, 1, \
           1, 1, 1, 1, 1),
};

I understand it's quite a lot but any help is appreciated. Please be reminded this is my first try.

Code: [Select]
keymap_common.h:43:8: error: parameter name missing
This error message tells you where the problem is - keymap_common.h, line 43, character 8 - it doesn't like you having a blank at the beginning of the line.  Comparing your file to some others there shouldn't be any blanks in that bit, and you're also missing a KC_##K00, KC_##K01, KC_##K02 bit which defines the matrix positions of the keys (probably exactly the same as the physical positions as you've handwired)

Hope that helps!
Title: Re: TMK keyboard firmware
Post by: Dwarlorf on Sat, 20 August 2016, 21:58:05
wall of text

Code: [Select]
keymap_common.h:43:8: error: parameter name missing
This error message tells you where the problem is - keymap_common.h, line 43, character 8 - it doesn't like you having a blank at the beginning of the line.  Comparing your file to some others there shouldn't be any blanks in that bit, and you're also missing a KC_##K00, KC_##K01, KC_##K02 bit which defines the matrix positions of the keys (probably exactly the same as the physical positions as you've handwired)

Hope that helps!

Yes it helped tremendously and Tactile's example also. I've been able to correct a lot of errors.

Unfortunately I'm stuck now on another error: (I've only posted part of the output but I have the rest if this is not enough to go by. But that part didn't seem relevant for the error code to me.)

Code: [Select]
obj_gh60_lufa/common/keymap.o: In function `action_for_key':
C:\tmk_keyboard-master\keyboard\gh60/../../tmk_core/common/keymap.c:40: undefined reference to `keymap_fn_to_action'
make: *** [gh60_lufa.elf] Error 1

I can't find a file named keymap.c. I also had a look at keymap.o since it was mentioned as well but it was all garbled. So I'm kinda stuck atm. I don't have a clue what to look for now. Any thoughts?
Title: Re: TMK keyboard firmware
Post by: suicidal_orange on Sun, 21 August 2016, 03:03:42
wall of text

Code: [Select]
keymap_common.h:43:8: error: parameter name missing
This error message tells you where the problem is - keymap_common.h, line 43, character 8 - it doesn't like you having a blank at the beginning of the line.  Comparing your file to some others there shouldn't be any blanks in that bit, and you're also missing a KC_##K00, KC_##K01, KC_##K02 bit which defines the matrix positions of the keys (probably exactly the same as the physical positions as you've handwired)

Hope that helps!

Yes it helped tremendously and Tactile's example also. I've been able to correct a lot of errors.

Unfortunately I'm stuck now on another error: (I've only posted part of the output but I have the rest if this is not enough to go by. But that part didn't seem relevant for the error code to me.)

Code: [Select]
obj_gh60_lufa/common/keymap.o: In function `action_for_key':
C:\tmk_keyboard-master\keyboard\gh60/../../tmk_core/common/keymap.c:40: undefined reference to `keymap_fn_to_action'
make: *** [gh60_lufa.elf] Error 1

I can't find a file named keymap.c. I also had a look at keymap.o since it was mentioned as well but it was all garbled. So I'm kinda stuck atm. I don't have a clue what to look for now. Any thoughts?

At the bottom of whichever file has actual letters etc assigned to keys you need a section to say what each Fn should do - have a look at any 60% for an example :)
Title: Re: TMK keyboard firmware
Post by: Dwarlorf on Sun, 21 August 2016, 05:27:21
Ok, disregard all these ramblings below. I used the wrong makefile. I needed to use the Makefile.pjrc for the teensy. I was able to compile a proper hexfile and load it unto the Teensy. And that worked.
More
EDIT: I just read this:
Quote
LED Blinks Green or Blue
You have a counterfeit board. PJRC has never made any Teensy with a green or blue LED. If you purchased using Ebay and Paypal, we recommend you immediately begin a dispute on Paypal's website. Do not bother contacting the seller. They have already scammed many other people with defective boards, but they simply do not care. A dispute on Paypal is the only way you will recover your money. The sooner you file the dispute, the better your odds of receiving a refund. We recommend waiting to leave negative feedback until after Paypal returns your money.

https://www.pjrc.com/teensy/troubleshoot.html

Mine has a blue led. Is it fake?

Since I'm not able to program it?

----------------------------

Ok, I've successfully been able to generate a .hex file. A milestone!  :D

But.... when I try to load the hexfile on the Teensy via the Teensy loader I get this error message:  :(


Quote
Error: "gh60_lufa_hex is not compiled for this board.

Compiled for Teensy++ 2.0 (AT90USB1286)"
This board is: Teensy 2.0 (ATMEGA32U4)"

Ypu must configure and recompile for the correct board type.
To change the board configuration using a Makefile edit the MCU variable inside the Makefile.

To change the board configuration using the Arduino IDE, use the Tools -> Boards menu.

So that's what I did. I changed the MCU to ATMEGA32U4 and recompiled the hexfile. But I still get the same error code. Below the make file. What am I missing?

More
Code: [Select]
#----------------------------------------------------------------------------
# On command line:
#
# make all = Make software.
#
# make clean = Clean out built project files.
#
# make coff = Convert ELF to AVR COFF.
#
# make extcoff = Convert ELF to AVR Extended COFF.
#
# make program = Download the hex file to the device.
#                Please customize your programmer settings(PROGRAM_CMD)
#
# make teensy = Download the hex file to the device, using teensy_loader_cli.
#               (must have teensy_loader_cli installed).
#
# make dfu = Download the hex file to the device, using dfu-programmer (must
#            have dfu-programmer installed).
#
# make flip = Download the hex file to the device, using Atmel FLIP (must
#             have Atmel FLIP installed).
#
# make dfu-ee = Download the eeprom file to the device, using dfu-programmer
#               (must have dfu-programmer installed).
#
# make flip-ee = Download the eeprom file to the device, using Atmel FLIP
#                (must have Atmel FLIP installed).
#
# make debug = Start either simulavr or avarice as specified for debugging,
#              with avr-gdb or avr-insight as the front end for debugging.
#
# make filename.s = Just compile filename.c into the assembler code only.
#
# make filename.i = Create a preprocessed source file for use in submitting
#                   bug reports to the GCC project.
#
# To rebuild project do "make clean" then "make all".
#----------------------------------------------------------------------------

# Target file name (without extension).
TARGET = gh60_lufa

# Directory common source filess exist
TMK_DIR = ../../tmk_core

# Directory keyboard dependent files exist
TARGET_DIR = .

# project specific files
SRC = keymap_common.c \
matrix.c \
led.c

ifdef KEYMAP
    SRC := keymap_$(KEYMAP).c $(SRC)
else
    SRC := keymap_poker.c $(SRC)
endif

CONFIG_H = config.h


# MCU name
#MCU = at90usb1287
MCU = atmega32u4

# Processor frequency.
#     This will define a symbol, F_CPU, in all source code files equal to the
#     processor frequency in Hz. You can then use this symbol in your source code to
#     calculate timings. Do NOT tack on a 'UL' at the end, this will be done
#     automatically to create a 32-bit value in your source code.
#
#     This will be an integer division of F_USB below, as it is sourced by
#     F_USB after it has run through any CPU prescalers. Note that this value
#     does not *change* the processor frequency - it should merely be updated to
#     reflect the processor speed set externally so that the code can use accurate
#     software delays.
F_CPU = 16000000


#
# LUFA specific
#
# Target architecture (see library "Board Types" documentation).
ARCH = AVR8

# Input clock frequency.
#     This will define a symbol, F_USB, in all source code files equal to the
#     input clock frequency (before any prescaling is performed) in Hz. This value may
#     differ from F_CPU if prescaling is used on the latter, and is required as the
#     raw input clock is fed directly to the PLL sections of the AVR for high speed
#     clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
#     at the end, this will be done automatically to create a 32-bit value in your
#     source code.
#
#     If no clock division is performed on the input clock inside the AVR (via the
#     CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
F_USB = $(F_CPU)

# Interrupt driven control endpoint task(+60)
OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT


# Boot Section Size in *bytes*
#   Teensy halfKay   512
#   Teensy++ halfKay 1024
#   Atmel DFU loader 4096
#   LUFA bootloader  4096
#   USBaspLoader     2048
OPT_DEFS += -DBOOTLOADER_SIZE=4096


# 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


# Optimize size but this may cause error "relocation truncated to fit"
#EXTRALDFLAGS = -Wl,--relax

# Search Path
VPATH += $(TARGET_DIR)
VPATH += $(TMK_DIR)

include $(TMK_DIR)/protocol/lufa.mk
include $(TMK_DIR)/common.mk
include $(TMK_DIR)/rules.mk

EDIT2: If it's not a fake teensy: I have a Teensy 2.0 NOT the Teensy++ 2.0 so maybe I need to change more values in the Make file according to hardware differences between the two boards?

Still one problem which i guess is hardware/wired related. It 'automatically presses' 1 so I'm getting 111111111111 etc.
Title: Re: TMK keyboard firmware
Post by: Dwarlorf on Sun, 21 August 2016, 09:15:00
Ok, here's the deal. I've been able to localize what matrix position is causing trouble by editing the keymap. It's col5, row1. Below is my keymap.

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

const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
    /* 0: qwerty */
    KEYMAP(6, 6,   6,   6,   9,   6,   6,  \
                    2, 2,   2,   2,   8,   2,   2,  \
                    3, 3,   3,   3,   7,   3,   3,  \
                    4, 4,   4,   4,   6,   4,   4,  \
                    5, 5,   5,   5,   5,   5,   5,  \
                    0, 1,   7,   8,   4,   1,   1),
    /* 1: ****off */
    KEYMAP(1, 1,   1,   1,   1,   1,   1,  \
                    1, 1,   1,   1,   1,   1,   1,  \
                    1, 1,   1,   1,   1,   1,   1,  \
                    1, 1,   1,   1,   1,   1,   1,  \
                    1, 1,   1,   1,   1,   1,   1,  \
                    1, 1,   1,   1,   1,   1,   1),
};

const uint16_t PROGMEM fn_actions[] = {
    /* Poker Layout */
    [0] = ACTION_LAYER_MOMENTARY(6),  // to Fn overlay
    [1] = ACTION_LAYER_TOGGLE(4),     // ****off
};

As you can see in the matrix col5, row1 outputs a 9.
As soon as I go in keyboard mode it goes 9999999999 etc. (until I disconnect the USB)

So I figured it was a hardware problem either in the matrix or with a switch so this is what I did:
1. check my soldered hardware matrix -> didn't see anything wrong
2. unsoldered the specific switch (col5, row1) and connected the usb again -> still the same problem
3. unsoldered the mirrored switch just in case I accidentally mirrored the hardware matrix and software -> still the same problem
4. unsoldered  both switches -> still the same problem
5. replaced both switches wit other ones -> still the same problem
This makes me think it's not a hardware problem in one of my matrices.

I did some more experimenting with editing the keymap_poker.c and it switches output to whatever change I make in that column. So it must be something in the programmed software.

hmm,  I compiled again and now I'm getting 987654987654 etc with the same Matrix as above. Maybe some sort of crazy function loop?

I'm at a loss (again). If someone could have a look please? would be much appreciated.
https://www.dropbox.com/sh/ssw3ltc185s1e21/AADADI6Nsg8P21V7yyIS5qDva?dl=0

EDIT: I still have doubts about the authenticity of my Teensy. I'm thinking of ordering another one.
Title: Re: TMK keyboard firmware
Post by: a-c on Sun, 21 August 2016, 19:10:21
Your 'teensy' is most likely a fake. Buy from one of these distributors if you want a genuine one. https://forum.pjrc.com/threads/23601-Official-Distributors

F6 is missing from your col init function.
Title: Re: TMK keyboard firmware
Post by: Dwarlorf on Mon, 22 August 2016, 04:30:21
Your 'teensy' is most likely a fake. Buy from one of these distributors if you want a genuine one. https://forum.pjrc.com/threads/23601-Official-Distributors

F6 is missing from your col init function.

Thanks for your help. It's actually working now. Even fake Teensys work. Now that it works I start making a decent key lay-out.

But I did order a new one (from floris.cc) and I can get my money back on the old one. So it's all good. Now that I have 2 I need to find another project.  :)
Title: Re: TMK keyboard firmware
Post by: rvense on Tue, 30 August 2016, 19:30:47
I am trying to use TMK-on-ChibiOS as the basis for a... thing that's both a USB keyboard but also has internal functionality of sorts, so you could switch between the keystrokes going to a computer and going to some internal "applications", like a calculator, or a keylogger/note keeper, or for use as an old-fashioned dumb serial console byt adding the VGA text generator I've built in an FPGA which could attach to the FMC of an STM32...

I've etched a prototype board with a 5x6 key matrix and am using an STM32F7 board that's nicely supported by ChibiOS. I already have it running as a USB keyboard, was very impressed with how easy that was to get working. This means my "keyboard" is high-speed USB and has an Ethernet port, SD card, 8 megs of SDRAM and a 5" LCD. And of course a very nice, not particularly busy, RTOS to make use of it!

The next step for me is to modify the firmware to conditionally (based on some switch set by a button) send keystrokes either over USB or to a separate ChibiOS thread that handles... whatever else it is I want it to do.
 
I've been attempting to find the best place to do this without modifying the core of TMK too much, since I'd like to be able to get updates later on and maybe also share things back if I add/fix something that would be of more general use.

Really it looks like the best place would be making a new host driver, and have some global conditional set by a TMK action or a dedicated button decide whether to call send_keyboard from usb_main.c as normal, or send a message to my application thread with the keys.

It doesn't seem ideal, though, and whilst I generally find the code very nicely structured and easy to follow, I wonder if there's any reason why the calls to the host driver are hidden in the depths of action.c - wouldn't it be nicer if keyboard_task returned something (maybe just a pointer to the report_keyboard_t or NULL if nothing's changed) that was then passed to the driver in the main loop? I'll have to admit I haven't looked at a lot of the existing firmwares, so there might be obvious reasons why it's structured like it is, like how it works on different platforms or all the other advanced stuff this firmware does that I don't know about yet.

I know my use case is a little off from what the firmware normally does, but I wonder if there are some suggestions as to what'd be the best course of action. But having played with the firmware for a few days now I really feel like I've got a head start and a good base to build from, so thanks to all who've contributed for making this firmware.
Title: Re: TMK keyboard firmware
Post by: hag.com on Wed, 31 August 2016, 00:07:01
Hello hasu and others!
I've (finnaly) managed to complete my custom keyboard to that point where it's alive and I can begin to design my keymap. However, I have som problems I hope you could help me with.

First, I don't use a normal keymap and would like to have special characters accessable on some keys directly without using shift or other layers. I have found the function(?) modified key which seems to be useful, but don't know how to implement it in the code to get it to work properly. I have tested inserting it in one of the keymaps in keymap_common.h, it compiles but only the last key is fired as the key is pressed.
For example, I want the key next to backspace to fire "!" on activation, but with this syntax it just works as a normal KC_1 key. (look for ACTION_MODS_KEY(MOD_LSFT, KC_1) )
More
Code: [Select]
#define KEYMAP( \
    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,   K42, K43,                K47,       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, ACTION_MODS_KEY(MOD_LSFT, KC_1), 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_NO,    KC_##K42, KC_##K43, KC_NO,    KC_NO,    KC_NO,    KC_##K47, KC_NO,    KC_NO,    KC_##K4A, KC_##K4B, KC_##K4C, KC_##K4D, KC_##K4E}  \
}


Next, I would like to have other characters than the usual on that keys when shift is pressed, but have shift working as it should on the letter part of the keymap. It's possible that this is easy done with layers or something like that, that I haven't reseached very much yet. I guess I alway can make shift an FN layer button and use the action_mods_key-thing with shift key on the qwerty part although it seems like bad programming for me.  :p

Here's a picture of the keyboard so you can see what layout I seek for. I'm planning to have a keypad hidden under the qwerty-part on an fn-layer accesable via lower and only have symbols and commands on the fifth row.
More
(http://i.imgur.com/yeMKAUv.jpg)

Hope you can help me or link a page where I can read more about implementing the functions described in .../tmk_core/doc/keymap.md. :)
Title: Re: TMK keyboard firmware
Post by: Tactile on Wed, 31 August 2016, 00:23:08
For example, I want the key next to backspace to fire "!" on activation, but with this syntax it just works as a normal KC_1 key.

A lot of stuff you describe might be simpler in QMK. For example:

http://qmk.fm/#fun-with-modifier-keys
Title: Re: TMK keyboard firmware
Post by: hag.com on Fri, 02 September 2016, 15:56:55
For example, I want the key next to backspace to fire "!" on activation, but with this syntax it just works as a normal KC_1 key.

A lot of stuff you describe might be simpler in QMK. For example:

http://qmk.fm/#fun-with-modifier-keys

Hm, yes, it looks quite easy to use. Thanks for the hint.
But now I have worked quite a while on getting TMK to work for my layout and would be glad if I could use it. It's even described in the documentations so it must be possible, I just can't find how to implement it.
Title: Re: TMK keyboard firmware
Post by: Tactile on Fri, 02 September 2016, 17:26:41
For example, I want the key next to backspace to fire "!" on activation, but with this syntax it just works as a normal KC_1 key.

A lot of stuff you describe might be simpler in QMK. For example:

http://qmk.fm/#fun-with-modifier-keys
Hm, yes, it looks quite easy to use. Thanks for the hint.
But now I have worked quite a while on getting TMK to work for my layout and would be glad if I could use it. It's even described in the documentations so it must be possible, I just can't find how to implement it.


This code isn't commented but here's how one guy did it...

https://github.com/matthewjf/tmk_firmware/blob/master/keyboard/gh60/keymap_poker_deprecated.c

Title: Re: TMK keyboard firmware
Post by: IBNobody on Tue, 06 September 2016, 09:44:56
I am trying to extend the number of keycodes that can be sent via the NKRO report for LUFA. It currently has a report size of 16 bytes, which can support 120 keys and 8 mods.

(Note that KEYBOARD_REPORT_BITS = 16-1.)

Code: [Select]
static inline void add_key_bit(uint8_t code)
{
    if ((code>>3) < KEYBOARD_REPORT_BITS) {
        keyboard_report->nkro.bits[code>>3] |= 1<<(code&7);
    } else {
        dprintf("add_key_bit: can't add: %02X\n", code);
    }
}

This prevents keys such as the language and international keys from being sent in NKRO mode. I did some experimentation and found I could change the size of the report from 16 to 32 bytes and get all the keys (but in reality, it only needs to be 21 bytes to hit all keycodes up to 0xA4 / KC_EXSEL).

Can someone tell me the ramifications of doing this?

Also... If I want to send more than the standard 104 keys plus F13-F24 to the host Windows PC, how should I handle it? add_key/del_key/send_keyboard_report? I want to do this to extend the number of keys that AutoHotkey can detect. It has support for virtual keys/scancodes.
Title: Re: TMK keyboard firmware
Post by: Tactile on Tue, 06 September 2016, 09:53:24
I am trying to extend the number of keycodes that can be sent via the NKRO report for LUFA. It currently has a report size of 16 bytes, which can support 120 keys and 8 mods.

...

Also... If I want to send more than the standard 104 keys plus F13-F24 to the host Windows PC, how should I handle it? add_key/del_key/send_keyboard_report? I want to do this to extend the number of keys that AutoHotkey can detect. It has support for virtual keys/scancodes.

I can't answer your questions, but have you read this?

https://github.com/tmk/tmk_keyboard/blob/master/tmk_core/doc/USB_NKRO.txt
Title: Re: TMK keyboard firmware
Post by: IBNobody on Tue, 06 September 2016, 09:58:57

I can't answer your questions, but have you read this?

https://github.com/tmk/tmk_keyboard/blob/master/tmk_core/doc/USB_NKRO.txt

Thanks. That confirms that I was on the right path, but it isn't clear if the 32 byte report had a realistic downside.

EDIT: Also, a 32 byte report will only represent 248 keys and 8 mod keys. The distinction is critical because this means that keycodes F8 to FF will not be sent.
Title: Re: TMK keyboard firmware
Post by: hasu on Tue, 06 September 2016, 12:52:45
1

I can't answer your questions, but have you read this?

https://github.com/tmk/tmk_keyboard/blob/master/tmk_core/doc/USB_NKRO.txt

Thanks. That confirms that I was on the right path, but it isn't clear if the 32 byte report had a realistic downside.

EDIT: Also, a 32 byte report will only represent 248 keys and 8 mod keys. The distinction is critical because this means that keycodes F8 to FF will not be sent.

Just efficiency of memory usage and report seding but these will be negligible probably. I prefer 32 byte size for simplicity than saving some bytes.

And with 32 byte report you will be able to use simple report descriptor to send 0x00-FF. But we have to test it.
Title: Re: TMK keyboard firmware
Post by: IBNobody on Tue, 06 September 2016, 14:55:51
Just efficiency of memory usage and report seding but these will be negligible probably. I prefer 32 byte size for simplicity than saving some bytes.

And with 32 byte report you will be able to use simple report descriptor to send 0x00-FF. But we have to test it.

Do you mean sending 0x00-0xFF instead of sending 0x80-0x87 and 0x00-0xF7?
Title: Re: TMK keyboard firmware
Post by: Meepsi on Tue, 06 September 2016, 17:55:14
Hey guys, long time lurker, first time writer.

So I've been working on a hand wired keyboard for a little while now and have finally finished the physical aspects of the work (mostly). I'm looking to get this Teensy 2.0 flashed with the settings I want but I am a complete moron when it comes to programming. I've spent the last couple nights looking into how to set up a keymap, and have even found a couple really good examples, but alas, it seems I am an idiot and cannot seem to get this right.

I am wondering if someone might be willing to hold my hand and help me get this keyboard up and running. Thanks in advance for any help to come!

Some background on the project:
I found an old Amiga 2000 Space Invader keyboard in a recycling bin at work. I of course could not allow such a travesty to befall such a specimen. It was missing a few keycaps and had a damaged cord, but was otherwise in a fairly decent condition. Failing to find any replacement keycaps for the missing keys, I did what and sensible person would do and got the Dremel (first I removed the case, PCB, and key switches; I'm not a monster). I cut away the function key row and the numpad. Now I have a tenkeyless board with an arrow cluster. Everything is wired up and ready to go (sans the caps LED; I'll come back to that once I get this baby working).

Pictures of the build so far:
(https://i.imgur.com/jgbIDG8m.jpg) (https://i.imgur.com/jgbIDG8.jpg) (http://i.imgur.com/KyvY0nNm.jpg) (http://i.imgur.com/KyvY0nN.jpg)
(http://i.imgur.com/os6KTocm.jpg) (http://i.imgur.com/os6KToc.jpg) (http://i.imgur.com/RK5xB84m.jpg) (http://i.imgur.com/RK5xB84.jpg)

So this is where I'm stuck...
This is how the board is wired:
(http://i.imgur.com/5sIywoql.jpg) (http://i.imgur.com/5sIywoq.jpg)

And this is the key map I am attempting to get working:
(http://i.imgur.com/a2gEbrfl.png) (http://i.imgur.com/a2gEbrf.png)

What should code for this look like?
Thanks guys!
Title: Re: TMK keyboard firmware
Post by: hasu on Tue, 06 September 2016, 19:43:04
Just efficiency of memory usage and report seding but these will be negligible probably. I prefer 32 byte size for simplicity than saving some bytes.

And with 32 byte report you will be able to use simple report descriptor to send 0x00-FF. But we have to test it.

Do you mean sending 0x00-0xFF instead of sending 0x80-0x87 and 0x00-0xF7?

Yes, it looks like a commit below. But it requires some more changes on existent codes to .
https://github.com/tmk/tmk_keyboard/commit/622f3424045ac4f9d7e2e75a57de25814db00768

I think just changing of NKRO_EPSIZE to 32 is enough for a while, you can't send 0xF8-FF with this but who cares.
Title: Re: TMK keyboard firmware
Post by: IBNobody on Tue, 06 September 2016, 20:50:06
Yes, it looks like a commit below. But it requires some more changes on existent codes to .
https://github.com/tmk/tmk_keyboard/commit/622f3424045ac4f9d7e2e75a57de25814db00768

I think just changing of NKRO_EPSIZE to 32 is enough for a while, you can't send 0xF8-FF with this but who cares.

That is what I thought. You are right. It would require extra work. keyboard_report->mods would need to change. That is more work to implement with no real benefit.

I will be happy with my INT1-6 and LANG1-5 keycodes and NKRO. Thank you!
Title: Re: TMK keyboard firmware
Post by: Dwarlorf on Wed, 07 September 2016, 02:51:42
I'm stuck once again. I'm in QMK but I believe this part is the same as TMK? If not than this would be my actual problem.  ;)

Anyhow, the code below enables me to (temporary) access layer 1 with FN0. But I can't for the life of me figure out how to access layer 2.  I experimented myself, looked at other peoples code and I've read all instructions and everything else I could find on the web but I guess I just don't understand. So if anyone could help me out it would be much appreciated.

Silly thing is when I pres the FN2 key

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

const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[0] = KEYMAP( /* Base */
      KC_9, KC_6, KC_3, KC_0, KC_UNDS, KC_ASTR, KC_BSPC, \
      KC_8, KC_5, KC_2, KC_SCOLON, KC_LPRN, KC_DOT, KC_DEL, \
      KC_7, KC_4, KC_1, KC_O, KC_N, KC_S, KC_ENT, \
      KC_NO, KC_NO, KC_NO, KC_T, KC_E, KC_I, KC_TRNS, \
      KC_NO, KC_RIGHT, KC_NO, KC_D, KC_A, KC_R, KC_SPACE, \
      KC_UP, KC_LEFT, KC_DOWN, KC_NO, KC_FN0, KC_FN1, KC_NO \),
   
[1] = KEYMAP(  /* 1: fn */
      KC_TRNS, KC_END, KC_PSCREEN, KC_PLUS, KC_EQUAL, KC_DLR, KC_BSPACE, \
      KC_PGUP, KC_TRNS, KC_PGDOWN, KC_EXLM, KC_LBRC, KC_BSLASH, KC_TAB, \
      KC_TRNS, KC_HOME, KC_TRNS, KC_U, KC_G, KC_P, KC_TRNS, \
      KC_TRNS, KC_TRNS, KC_TRNS, KC_H, KC_L, KC_K, KC_TRNS, \
      KC_TRNS, KC_TRNS, KC_TRNS, KC_B, KC_V, KC_M, KC_TRNS, \
      KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS \),

[2] = KEYMAP( /* 2: fn */
      KC_TRNS, KC_TRNS, KC_TRNS, KC_AT, KC_PERC, KC_HASH, KC_TRNS, \
      KC_TRNS, KC_TRNS, KC_TRNS, KC_AMPR, KC_LCBR, KC_PIPE, KC_TRNS, \
      KC_TRNS, KC_TRNS, KC_TRNS, KC_Y, KC_J, KC_LABK, KC_TRNS, \
      KC_TRNS, KC_TRNS, KC_TRNS, KC_C, KC_W, KC_F, KC_TRNS, \
      KC_TRNS, KC_TRNS, KC_TRNS, KC_Q, KC_N, KC_X, KC_TRNS, \
      KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS \),
};

const uint16_t PROGMEM fn_actions[] = {
[0] = ACTION_LAYER_MOMENTARY(1)
};

const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
{
  // MACRODOWN only works in this function
      switch(id) {
        case 0:
          if (record->event.pressed) {
            register_code(KC_RSFT);
          } else {
            unregister_code(KC_RSFT);
          }
        break;
      }
    return MACRO_NONE;
};


void matrix_init_user(void) {

}

void matrix_scan_user(void) {

}

bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  return true;
}

void led_set_user(uint8_t usb_led) {

}
Title: Re: TMK keyboard firmware
Post by: suicidal_orange on Wed, 07 September 2016, 03:06:33
I'm stuck once again. I'm in QMK but I believe this part is the same as TMK? If not than this would be my actual problem.  ;)

Anyhow, the code below enables me to (temporary) access layer 1 with FN0. But I can't for the life of me figure out how to access layer 2.  I experimented myself, looked at other peoples code and I've read all instructions and everything else I could find on the web but I guess I just don't understand. So if anyone could help me out it would be much appreciated.

Silly thing is when I pres the FN2 key

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

const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[0] = KEYMAP( /* Base */
      KC_9, KC_6, KC_3, KC_0, KC_UNDS, KC_ASTR, KC_BSPC, \
      KC_8, KC_5, KC_2, KC_SCOLON, KC_LPRN, KC_DOT, KC_DEL, \
      KC_7, KC_4, KC_1, KC_O, KC_N, KC_S, KC_ENT, \
      KC_NO, KC_NO, KC_NO, KC_T, KC_E, KC_I, KC_TRNS, \
      KC_NO, KC_RIGHT, KC_NO, KC_D, KC_A, KC_R, KC_SPACE, \
      KC_UP, KC_LEFT, KC_DOWN, KC_NO, KC_FN0, KC_FN1, KC_NO \),
   
[1] = KEYMAP(  /* 1: fn */
      KC_TRNS, KC_END, KC_PSCREEN, KC_PLUS, KC_EQUAL, KC_DLR, KC_BSPACE, \
      KC_PGUP, KC_TRNS, KC_PGDOWN, KC_EXLM, KC_LBRC, KC_BSLASH, KC_TAB, \
      KC_TRNS, KC_HOME, KC_TRNS, KC_U, KC_G, KC_P, KC_TRNS, \
      KC_TRNS, KC_TRNS, KC_TRNS, KC_H, KC_L, KC_K, KC_TRNS, \
      KC_TRNS, KC_TRNS, KC_TRNS, KC_B, KC_V, KC_M, KC_TRNS, \
      KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS \),

[2] = KEYMAP( /* 2: fn */
      KC_TRNS, KC_TRNS, KC_TRNS, KC_AT, KC_PERC, KC_HASH, KC_TRNS, \
      KC_TRNS, KC_TRNS, KC_TRNS, KC_AMPR, KC_LCBR, KC_PIPE, KC_TRNS, \
      KC_TRNS, KC_TRNS, KC_TRNS, KC_Y, KC_J, KC_LABK, KC_TRNS, \
      KC_TRNS, KC_TRNS, KC_TRNS, KC_C, KC_W, KC_F, KC_TRNS, \
      KC_TRNS, KC_TRNS, KC_TRNS, KC_Q, KC_N, KC_X, KC_TRNS, \
      KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS \),
};

const uint16_t PROGMEM fn_actions[] = {
[0] = ACTION_LAYER_MOMENTARY(1)
};

const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
{
  // MACRODOWN only works in this function
      switch(id) {
        case 0:
          if (record->event.pressed) {
            register_code(KC_RSFT);
          } else {
            unregister_code(KC_RSFT);
          }
        break;
      }
    return MACRO_NONE;
};


void matrix_init_user(void) {

}

void matrix_scan_user(void) {

}

bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  return true;
}

void led_set_user(uint8_t usb_led) {

}

Below the keymaps you have an fn_actions section, you need a line in there starting [1] and ending (2), assuming you want to use FN2 in the same way as FN :)
Title: Re: TMK keyboard firmware
Post by: Dwarlorf on Wed, 07 September 2016, 03:35:58
I'm stuck once again. I'm in QMK but I believe this part is the same as TMK? If not than this would be my actual problem.  ;)

Anyhow, the code below enables me to (temporary) access layer 1 with FN0. But I can't for the life of me figure out how to access layer 2.  I experimented myself, looked at other peoples code and I've read all instructions and everything else I could find on the web but I guess I just don't understand. So if anyone could help me out it would be much appreciated.

Silly thing is when I pres the FN2 key

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

const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[0] = KEYMAP( /* Base */
      KC_9, KC_6, KC_3, KC_0, KC_UNDS, KC_ASTR, KC_BSPC, \
      KC_8, KC_5, KC_2, KC_SCOLON, KC_LPRN, KC_DOT, KC_DEL, \
      KC_7, KC_4, KC_1, KC_O, KC_N, KC_S, KC_ENT, \
      KC_NO, KC_NO, KC_NO, KC_T, KC_E, KC_I, KC_TRNS, \
      KC_NO, KC_RIGHT, KC_NO, KC_D, KC_A, KC_R, KC_SPACE, \
      KC_UP, KC_LEFT, KC_DOWN, KC_NO, KC_FN0, KC_FN1, KC_NO \),
   
[1] = KEYMAP(  /* 1: fn */
      KC_TRNS, KC_END, KC_PSCREEN, KC_PLUS, KC_EQUAL, KC_DLR, KC_BSPACE, \
      KC_PGUP, KC_TRNS, KC_PGDOWN, KC_EXLM, KC_LBRC, KC_BSLASH, KC_TAB, \
      KC_TRNS, KC_HOME, KC_TRNS, KC_U, KC_G, KC_P, KC_TRNS, \
      KC_TRNS, KC_TRNS, KC_TRNS, KC_H, KC_L, KC_K, KC_TRNS, \
      KC_TRNS, KC_TRNS, KC_TRNS, KC_B, KC_V, KC_M, KC_TRNS, \
      KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS \),

[2] = KEYMAP( /* 2: fn */
      KC_TRNS, KC_TRNS, KC_TRNS, KC_AT, KC_PERC, KC_HASH, KC_TRNS, \
      KC_TRNS, KC_TRNS, KC_TRNS, KC_AMPR, KC_LCBR, KC_PIPE, KC_TRNS, \
      KC_TRNS, KC_TRNS, KC_TRNS, KC_Y, KC_J, KC_LABK, KC_TRNS, \
      KC_TRNS, KC_TRNS, KC_TRNS, KC_C, KC_W, KC_F, KC_TRNS, \
      KC_TRNS, KC_TRNS, KC_TRNS, KC_Q, KC_N, KC_X, KC_TRNS, \
      KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS \),
};

const uint16_t PROGMEM fn_actions[] = {
[0] = ACTION_LAYER_MOMENTARY(1)
};

const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
{
  // MACRODOWN only works in this function
      switch(id) {
        case 0:
          if (record->event.pressed) {
            register_code(KC_RSFT);
          } else {
            unregister_code(KC_RSFT);
          }
        break;
      }
    return MACRO_NONE;
};


void matrix_init_user(void) {

}

void matrix_scan_user(void) {

}

bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  return true;
}

void led_set_user(uint8_t usb_led) {

}

Below the keymaps you have an fn_actions section, you need a line in there starting [1] and ending (2), assuming you want to use FN2 in the same way as FN :)

Thanks for your reply once again. That's actually what I've been doing (tried out different values as well) but then I get this error message when compiling:

Code: [Select]
Compiling: keyboards/gh30/keymaps/default/keymap.c                                                 keyboards/gh30/keymaps/default/keymap.c:37: error: subscripted value is neither array nor pointer
 [ERRORS]
 |
 |
 |
make[1]: *** [.build/obj_gh30_default/keyboards/gh30/keymaps/default/keymap.o] Error 1
Make finished with errors
make: *** [default] Error 1

If I load the hex with teensy anyway but when I press that FN key I get an 'windows background sound' (https://youtu.be/K5ARPC-FTHo?t=2m33s).
And I just found out that when I'm in Firefox it does bookmarks shortcut (either Ctrl + B or Ctrl + I) when I press it.

EDIT:
I'm a step further. When I add , behind every line I don't get compile errors anymore but FN2 still does not work.
Title: Re: TMK keyboard firmware
Post by: Dwarlorf on Wed, 07 September 2016, 06:27:57
I'm stuck once again. I'm in QMK but I believe this part is the same as TMK? If not than this would be my actual problem.  ;)

Anyhow, the code below enables me to (temporary) access layer 1 with FN0. But I can't for the life of me figure out how to access layer 2.  I experimented myself, looked at other peoples code and I've read all instructions and everything else I could find on the web but I guess I just don't understand. So if anyone could help me out it would be much appreciated.

Silly thing is when I pres the FN2 key

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

const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[0] = KEYMAP( /* Base */
      KC_9, KC_6, KC_3, KC_0, KC_UNDS, KC_ASTR, KC_BSPC, \
      KC_8, KC_5, KC_2, KC_SCOLON, KC_LPRN, KC_DOT, KC_DEL, \
      KC_7, KC_4, KC_1, KC_O, KC_N, KC_S, KC_ENT, \
      KC_NO, KC_NO, KC_NO, KC_T, KC_E, KC_I, KC_TRNS, \
      KC_NO, KC_RIGHT, KC_NO, KC_D, KC_A, KC_R, KC_SPACE, \
      KC_UP, KC_LEFT, KC_DOWN, KC_NO, KC_FN0, KC_FN1, KC_NO \),
   
[1] = KEYMAP(  /* 1: fn */
      KC_TRNS, KC_END, KC_PSCREEN, KC_PLUS, KC_EQUAL, KC_DLR, KC_BSPACE, \
      KC_PGUP, KC_TRNS, KC_PGDOWN, KC_EXLM, KC_LBRC, KC_BSLASH, KC_TAB, \
      KC_TRNS, KC_HOME, KC_TRNS, KC_U, KC_G, KC_P, KC_TRNS, \
      KC_TRNS, KC_TRNS, KC_TRNS, KC_H, KC_L, KC_K, KC_TRNS, \
      KC_TRNS, KC_TRNS, KC_TRNS, KC_B, KC_V, KC_M, KC_TRNS, \
      KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS \),

[2] = KEYMAP( /* 2: fn */
      KC_TRNS, KC_TRNS, KC_TRNS, KC_AT, KC_PERC, KC_HASH, KC_TRNS, \
      KC_TRNS, KC_TRNS, KC_TRNS, KC_AMPR, KC_LCBR, KC_PIPE, KC_TRNS, \
      KC_TRNS, KC_TRNS, KC_TRNS, KC_Y, KC_J, KC_LABK, KC_TRNS, \
      KC_TRNS, KC_TRNS, KC_TRNS, KC_C, KC_W, KC_F, KC_TRNS, \
      KC_TRNS, KC_TRNS, KC_TRNS, KC_Q, KC_N, KC_X, KC_TRNS, \
      KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS \),
};

const uint16_t PROGMEM fn_actions[] = {
[0] = ACTION_LAYER_MOMENTARY(1)
};

const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
{
  // MACRODOWN only works in this function
      switch(id) {
        case 0:
          if (record->event.pressed) {
            register_code(KC_RSFT);
          } else {
            unregister_code(KC_RSFT);
          }
        break;
      }
    return MACRO_NONE;
};


void matrix_init_user(void) {

}

void matrix_scan_user(void) {

}

bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  return true;
}

void led_set_user(uint8_t usb_led) {

}

Below the keymaps you have an fn_actions section, you need a line in there starting [1] and ending (2), assuming you want to use FN2 in the same way as FN :)


After a lot of trial and error I  ended up with:

Code: [Select]
[1] = ACTION_LAYER_MOMENTARY(1),
[0] = ACTION_LAYER_MOMENTARY(2),

But I only got it to work by swapping the FN0 key and the FN1 key in the base keymap.

So:              " KC_UP, KC_LEFT, KC_DOWN, KC_NO, KC_FN1, KC_FN0, KC_NO"
instead of:   "KC_UP, KC_LEFT, KC_DOWN, KC_NO, KC_FN0, KC_FN1, KC_NO"  as intended

So I actually have no insight why it works like this. :-[

And now it doesnt work at all any more. only D's. I quit for the day.
its a hardware problem apparently

Title: Re: TMK keyboard firmware
Post by: IBNobody on Wed, 07 September 2016, 14:49:48
Hey guys, long time lurker, first time writer.

So I've been working on a hand wired keyboard for a little while now and have finally finished the physical aspects of the work (mostly). I'm looking to get this Teensy 2.0 flashed with the settings I want but I am a complete moron when it comes to programming. I've spent the last couple nights looking into how to set up a keymap, and have even found a couple really good examples, but alas, it seems I am an idiot and cannot seem to get this right.

I am wondering if someone might be willing to hold my hand and help me get this keyboard up and running. Thanks in advance for any help to come!

If you go ahead and fill out one of these spreadsheets (https://www.reddit.com/r/olkb/comments/50x04k/sheet_to_generate_keyboard_layout_editor_raw_data/), and let me know what pin assignments you used, I will use them to set up a QMK or TMK keyboard for you.

Title: Re: TMK keyboard firmware
Post by: suicidal_orange on Wed, 07 September 2016, 15:18:34
More
I'm stuck once again. I'm in QMK but I believe this part is the same as TMK? If not than this would be my actual problem.  ;)

Anyhow, the code below enables me to (temporary) access layer 1 with FN0. But I can't for the life of me figure out how to access layer 2.  I experimented myself, looked at other peoples code and I've read all instructions and everything else I could find on the web but I guess I just don't understand. So if anyone could help me out it would be much appreciated.

Silly thing is when I pres the FN2 key

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

const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[0] = KEYMAP( /* Base */
      KC_9, KC_6, KC_3, KC_0, KC_UNDS, KC_ASTR, KC_BSPC, \
      KC_8, KC_5, KC_2, KC_SCOLON, KC_LPRN, KC_DOT, KC_DEL, \
      KC_7, KC_4, KC_1, KC_O, KC_N, KC_S, KC_ENT, \
      KC_NO, KC_NO, KC_NO, KC_T, KC_E, KC_I, KC_TRNS, \
      KC_NO, KC_RIGHT, KC_NO, KC_D, KC_A, KC_R, KC_SPACE, \
      KC_UP, KC_LEFT, KC_DOWN, KC_NO, KC_FN0, KC_FN1, KC_NO \),
   
[1] = KEYMAP(  /* 1: fn */
      KC_TRNS, KC_END, KC_PSCREEN, KC_PLUS, KC_EQUAL, KC_DLR, KC_BSPACE, \
      KC_PGUP, KC_TRNS, KC_PGDOWN, KC_EXLM, KC_LBRC, KC_BSLASH, KC_TAB, \
      KC_TRNS, KC_HOME, KC_TRNS, KC_U, KC_G, KC_P, KC_TRNS, \
      KC_TRNS, KC_TRNS, KC_TRNS, KC_H, KC_L, KC_K, KC_TRNS, \
      KC_TRNS, KC_TRNS, KC_TRNS, KC_B, KC_V, KC_M, KC_TRNS, \
      KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS \),

[2] = KEYMAP( /* 2: fn */
      KC_TRNS, KC_TRNS, KC_TRNS, KC_AT, KC_PERC, KC_HASH, KC_TRNS, \
      KC_TRNS, KC_TRNS, KC_TRNS, KC_AMPR, KC_LCBR, KC_PIPE, KC_TRNS, \
      KC_TRNS, KC_TRNS, KC_TRNS, KC_Y, KC_J, KC_LABK, KC_TRNS, \
      KC_TRNS, KC_TRNS, KC_TRNS, KC_C, KC_W, KC_F, KC_TRNS, \
      KC_TRNS, KC_TRNS, KC_TRNS, KC_Q, KC_N, KC_X, KC_TRNS, \
      KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS \),
};

const uint16_t PROGMEM fn_actions[] = {
[0] = ACTION_LAYER_MOMENTARY(1)
};

const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
{
  // MACRODOWN only works in this function
      switch(id) {
        case 0:
          if (record->event.pressed) {
            register_code(KC_RSFT);
          } else {
            unregister_code(KC_RSFT);
          }
        break;
      }
    return MACRO_NONE;
};


void matrix_init_user(void) {

}

void matrix_scan_user(void) {

}

bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  return true;
}

void led_set_user(uint8_t usb_led) {

}

Below the keymaps you have an fn_actions section, you need a line in there starting [1] and ending (2), assuming you want to use FN2 in the same way as FN :)


After a lot of trial and error I  ended up with:

Code: [Select]
[1] = ACTION_LAYER_MOMENTARY(1),
[0] = ACTION_LAYER_MOMENTARY(2),

But I only got it to work by swapping the FN0 key and the FN1 key in the base keymap.

So:              " KC_UP, KC_LEFT, KC_DOWN, KC_NO, KC_FN1, KC_FN0, KC_NO"
instead of:   "KC_UP, KC_LEFT, KC_DOWN, KC_NO, KC_FN0, KC_FN1, KC_NO"  as intended

So I actually have no insight why it works like this. :-[

And now it doesnt work at all any more. only D's. I quit for the day.
its a hardware problem apparently


Ok, had a look on a big screen and not looking for the easy answer.

You have
Code: [Select]
[0] =
[1] =
etc before each KEYMAP( which I've never noticed in TMK and I just looked in QMK and can't see any there either.  As usual don't ask me what this means or does, I'm just playing spot the difference :))
Title: Re: TMK keyboard firmware
Post by: IBNobody on Wed, 07 September 2016, 15:27:16
Ok, had a look on a big screen and not looking for the easy answer.

You have
Code: [Select]
[0] =
[1] =
etc before each KEYMAP( which I've never noticed in TMK and I just looked in QMK and can't see any there either.  As usual don't ask me what this means or does, I'm just playing spot the difference :))

Those define the layer and should be the same in TMK and QMK.
Title: Re: TMK keyboard firmware
Post by: suicidal_orange on Wed, 07 September 2016, 15:32:34
Ok, had a look on a big screen and not looking for the easy answer.

You have
Code: [Select]
[0] =
[1] =
etc before each KEYMAP( which I've never noticed in TMK and I just looked in QMK and can't see any there either.  As usual don't ask me what this means or does, I'm just playing spot the difference :))

Those define the layer and should be the same in TMK and QMK.

I see none here (https://github.com/jackhumbert/qmk_firmware/blob/master/keyboards/gh60/keymaps/default/keymap.c) where there are two FNs and 3 layers?  Then again, all the keys don't start KC_ either so maybe it's not the same file...

I really should learn this stuff if you have time to explain what I'm missing that would be great :)
Title: Re: TMK keyboard firmware
Post by: IBNobody on Wed, 07 September 2016, 16:14:41
I see none here (https://github.com/jackhumbert/qmk_firmware/blob/master/keyboards/gh60/keymaps/default/keymap.c) where there are two FNs and 3 layers?  Then again, all the keys don't start KC_ either so maybe it's not the same file...

I really should learn this stuff if you have time to explain what I'm missing that would be great :)

They are optional and are just used for convenience or to errorproof your code.

https://github.com/jackhumbert/qmk_firmware/blob/master/keyboards/retro_refit/keymaps/default/keymap.c
Title: Re: TMK keyboard firmware
Post by: suicidal_orange on Wed, 07 September 2016, 17:12:22
I see none here (https://github.com/jackhumbert/qmk_firmware/blob/master/keyboards/gh60/keymaps/default/keymap.c) where there are two FNs and 3 layers?  Then again, all the keys don't start KC_ either so maybe it's not the same file...

I really should learn this stuff if you have time to explain what I'm missing that would be great :)

They are optional and are just used for convenience or to errorproof your code.

https://github.com/jackhumbert/qmk_firmware/blob/master/keyboards/retro_refit/keymaps/default/keymap.c

Thanks, would never have guessed that!
Title: Re: TMK keyboard firmware
Post by: Meepsi on Wed, 07 September 2016, 18:36:08
Hey guys, long time lurker, first time writer.

So I've been working on a hand wired keyboard for a little while now and have finally finished the physical aspects of the work (mostly). I'm looking to get this Teensy 2.0 flashed with the settings I want but I am a complete moron when it comes to programming. I've spent the last couple nights looking into how to set up a keymap, and have even found a couple really good examples, but alas, it seems I am an idiot and cannot seem to get this right.

I am wondering if someone might be willing to hold my hand and help me get this keyboard up and running. Thanks in advance for any help to come!

If you go ahead and fill out one of these spreadsheets (https://www.reddit.com/r/olkb/comments/50x04k/sheet_to_generate_keyboard_layout_editor_raw_data/), and let me know what pin assignments you used, I will use them to set up a QMK or TMK keyboard for you.

So apparently I have a Teensy-LC not a Teensy 2.0 I don't think this should be a problem though.
Pin reference:
(http://i.imgur.com/NEPpG9Pm.png) (http://i.imgur.com/NEPpG9P.png)

ROW 0 - PIN 0
ROW 1 - PIN 1
ROW 2 - PIN 2
ROW 3 - PIN 3
ROW 4 - PIN 4

COL 0 - PIN 5
COL 1 - PIN 6
COL 2 - PIN 7
COL 3 - PIN 8
COL 4 - PIN 9
COL 5 - PIN 10
COL 6 - PIN 11
COL 7 - PIN 12
COL 8 - PIN 13
COL 9 - PIN 14
COL 10 - PIN 15
COL 11 - PIN 16
COL 12 - PIN 17
COL 13 - PIN 18
COL 14 - PIN 19
COL 15 - PIN 20
COL 16 - PIN 21
COL 17 - PIN 22

As for the spreadsheet you linked me, my keymap didn't fit in there, so I filled what I could and hand entered the rest. I hope this is what you were looking for. If not let me know and I'll try again.
Code: [Select]
/* LAYER = PRIMARY
  .-----------------------------------------------------------------------------------------------------------------------------------------------------------------.
  | GRV    | 1      | 2      | 3      | 4      | 5      | 6      | 7      | 8      | 9      | 0      | MINS   | EQL    | BSLS   | BSPC   | DEL    |        | F5     |
  |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------|
  | TAB    |        | Q      | W      | E      | R      | T      | Y      | U      | I      | O      | P      | LBRC   | RBRC   |        |        |        |        |
  |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------|
  | LCTR   | CAPS   | A      | S      | D      | F      | G      | H      | J      | K      | L      | SCLN   | QUOT   |        | ENT    |        | UP     |        |
  |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------|
  |        | LSFT   |        | Z      | X      | C      | V      | B      | N      | M      | COMM   | DOT    | SLSH   |        | RSFT   | LEFT   | DOWN   | RGHT   |
  |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------|
  |        | LALT   | LGUI   |        |        |        |        | SPC    |        |        |        |        |        | FN0    | RALT   |        |        |        |
  '-----------------------------------------------------------------------------------------------------------------------------------------------------------------'
*/
[LAYER_PRIMARY] = {
  { GRV    , 1      , 2      , 3      , 4      , 5      , 6      , 7      , 8      , 9      , 0      , MINS   , EQL    , BSLS   , BSPC   , DEL    ,        , F5     },
  { TAB    ,        , Q      , W      , E      , R      , T      , Y      , U      , I      , O      , P      , LBRC   , RBRC   ,        ,        ,        ,        },
  { LCTR   , 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   ,        ,        ,        },
  {        , LALT   , LGUI   ,        ,        ,        ,        , SPC    ,        ,        ,        ,        ,        , FN0    , RALT   ,        ,        ,        }
},
/* LAYER = FN0
  .-----------------------------------------------------------------------------------------------------------------------------------------------------------------.
  | ESC    | F1     | F2     | F3     | F4     | F5     | F6     | F7     | F8     | F9     | F10    | F11    | F12    |        |        |        |        |        |
  |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------|
  |        |        |        |        |        |        |        |        |        |        |        |        |        |        |        |        |        |        |
  |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------|
  |        |        |        |        |        |        |        |        |        |        |        |        |        |        |        |        | PGUP   |        |
  |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------|
  |        |        |        |        |        |        |        |        |        |        |        |        |        |        |        |        | PGDN   |        |
  |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------|
  |        |        |        |        |        |        |        |        |        |        |        |        |        |        |        |        |        |        |
  '-----------------------------------------------------------------------------------------------------------------------------------------------------------------'
*/
[LAYER_FN0] = {
  { ESC    , F1     , F2     , F3     , F4     , F5     , F6     , F7     , F8     , F9     , F10    , F11    , F12    ,        ,        ,        ,        ,        },
  {        ,        ,        ,        ,        ,        ,        ,        ,        ,        ,        ,        ,        ,        ,        ,        ,        ,        },
  {        ,        ,        ,        ,        ,        ,        ,        ,        ,        ,        ,        ,        ,        ,        ,        , PGUP   ,        },
  {        ,        ,        ,        ,        ,        ,        ,        ,        ,        ,        ,        ,        ,        ,        ,        , PGDN   ,        },
  {        ,        ,        ,        ,        ,        ,        ,        ,        ,        ,        ,        ,        ,        ,        ,        ,        ,        }
},
Title: Re: TMK keyboard firmware
Post by: IBNobody on Wed, 07 September 2016, 20:05:54
So.... The good news is that half of your code is complete. The bad news is that... Having a Teensy LC makes things harder. It is because the LC has an ARM processor and the 2.0 has an AVR processor. I have not done any work using ARMs and cannot say which are supported via ChibiOS. No promises... I'll try. :)

EDIT: And... No... Sorry. There is ChibiOS support, but I didn't see a fully functional keyboard in the QMK repo for it with a full layout. I don't think I am your guy. If it were an AVR, it would be no sweat.
Title: Re: TMK keyboard firmware
Post by: Dwarlorf on Thu, 08 September 2016, 03:23:11
Ok, had a look on a big screen and not looking for the easy answer.

You have
Code: [Select]
[0] =
[1] =
etc before each KEYMAP( which I've never noticed in TMK and I just looked in QMK and can't see any there either.  As usual don't ask me what this means or does, I'm just playing spot the difference :))

Those define the layer and should be the same in TMK and QMK.

I see none here (https://github.com/jackhumbert/qmk_firmware/blob/master/keyboards/gh60/keymaps/default/keymap.c) where there are two FNs and 3 layers?  Then again, all the keys don't start KC_ either so maybe it's not the same file...

I really should learn this stuff if you have time to explain what I'm missing that would be great :)

I'm getting rid of the KC_'s since they're not necessary. Less chance of mistakes when editing. Hmm, apparently I can remove them from numbers but not from special symbols like underscore (KC_UNDS) or letters.

I see none here (https://github.com/jackhumbert/qmk_firmware/blob/master/keyboards/gh60/keymaps/default/keymap.c) where there are two FNs and 3 layers?  Then again, all the keys don't start KC_ either so maybe it's not the same file...

I really should learn this stuff if you have time to explain what I'm missing that would be great :)

They are optional and are just used for convenience or to errorproof your code.

https://github.com/jackhumbert/qmk_firmware/blob/master/keyboards/retro_refit/keymaps/default/keymap.c

I can't remember where I got the example from but in the example in the link you post they are part of the comment, not the code like in my keymap. I removed them and it still works. but theres also this line
Code: [Select]
#include "action_layer.h" which I didn't have. I added it and there's no error code when compiling.

Or have my 'problems' something to do with the fact that I use cygdrive and not mingw? For QMK MinGw and MHV-AVR_Tools were advised but I couldn't get them to install properly.
Title: Re: TMK keyboard firmware
Post by: IBNobody on Thu, 08 September 2016, 07:38:17
I'm getting rid of the KC_'s since they're not necessary. Less chance of mistakes when editing. Hmm, apparently I can remove them from numbers but not from special symbols like underscore (KC_UNDS) or letters.

If you use a KEYMAP macro, you can get rid of KC_ because the KEYMAP macro adds them in. I prefer not to use KEYMAP macros that do this because with QMK, you have more options for keycodes that do not start with KC_.


I can't remember where I got the example from but in the example in the link you post they are part of the comment, not the code like in my keymap. I removed them and it still works. but theres also this line
Code: [Select]
#include "action_layer.h" which I didn't have. I added it and there's no error code when compiling.

Or have my 'problems' something to do with the fact that I use cygdrive and not mingw? For QMK MinGw and MHV-AVR_Tools were advised but I couldn't get them to install properly.

Haha, don't use my example to debug your momentary layer issue. I do not use momentary layers on that keyboard.

When I do use momentary layers, I do it via macros. They give me better control over what is happening and let me do things like flash my backlight, play a chiptune, or do some fairly complicated layer shifting. For example...

https://github.com/jackhumbert/qmk_firmware/blob/master/keyboards/planck/keymaps/pvc/keymap.c

Code: [Select]
        case MACRO_UPPER:
            if (record->event.pressed)
            {
                layer_on(LAYER_UPPER);
                breathing_speed_set(2);
                breathing_pulse();
                update_tri_layer(LAYER_LOWER, LAYER_UPPER, LAYER_ADJUST);
            }
            else
            {
                layer_off(LAYER_UPPER);
                update_tri_layer(LAYER_LOWER, LAYER_UPPER, LAYER_ADJUST);
            }
            break;

        case MACRO_LOWER:
            if (record->event.pressed)
            {
                layer_on(LAYER_LOWER);
                breathing_speed_set(2);
                breathing_pulse();
                update_tri_layer(LAYER_LOWER, LAYER_UPPER, LAYER_ADJUST);
            }
            else
            {
                layer_off(LAYER_LOWER);
                update_tri_layer(LAYER_LOWER, LAYER_UPPER, LAYER_ADJUST);
            }
            break;

If I hold UPPER, I get the upper layer. If I hold LOWER, I get the LOWER layer. If I hold UPPER and then LOWER or LOWER and then UPPER, I get the ADJUST layer.
Title: Re: TMK keyboard firmware
Post by: Dwarlorf on Thu, 08 September 2016, 19:02:43
I'm getting rid of the KC_'s since they're not necessary. Less chance of mistakes when editing. Hmm, apparently I can remove them from numbers but not from special symbols like underscore (KC_UNDS) or letters.

If you use a KEYMAP macro, you can get rid of KC_ because the KEYMAP macro adds them in. I prefer not to use KEYMAP macros that do this because with QMK, you have more options for keycodes that do not start with KC_.


I can't remember where I got the example from but in the example in the link you post they are part of the comment, not the code like in my keymap. I removed them and it still works. but theres also this line
Code: [Select]
#include "action_layer.h" which I didn't have. I added it and there's no error code when compiling.

Or have my 'problems' something to do with the fact that I use cygdrive and not mingw? For QMK MinGw and MHV-AVR_Tools were advised but I couldn't get them to install properly.

Haha, don't use my example to debug your momentary layer issue. I do not use momentary layers on that keyboard.

When I do use momentary layers, I do it via macros. They give me better control over what is happening and let me do things like flash my backlight, play a chiptune, or do some fairly complicated layer shifting. For example...

https://github.com/jackhumbert/qmk_firmware/blob/master/keyboards/planck/keymaps/pvc/keymap.c

Code: [Select]
        case MACRO_UPPER:
            if (record->event.pressed)
            {
                layer_on(LAYER_UPPER);
                breathing_speed_set(2);
                breathing_pulse();
                update_tri_layer(LAYER_LOWER, LAYER_UPPER, LAYER_ADJUST);
            }
            else
            {
                layer_off(LAYER_UPPER);
                update_tri_layer(LAYER_LOWER, LAYER_UPPER, LAYER_ADJUST);
            }
            break;

        case MACRO_LOWER:
            if (record->event.pressed)
            {
                layer_on(LAYER_LOWER);
                breathing_speed_set(2);
                breathing_pulse();
                update_tri_layer(LAYER_LOWER, LAYER_UPPER, LAYER_ADJUST);
            }
            else
            {
                layer_off(LAYER_LOWER);
                update_tri_layer(LAYER_LOWER, LAYER_UPPER, LAYER_ADJUST);
            }
            break;

If I hold UPPER, I get the upper layer. If I hold LOWER, I get the LOWER layer. If I hold UPPER and then LOWER or LOWER and then UPPER, I get the ADJUST layer.

Hmm, that macro system is actually fairly clear and understandable. If I understand correctly I also need to use Macros for Tap Dance and Timer functionality so your example seems very useful for me. I'll delve into it some more.

Thanks for your help so far. I will probably return with more questions in the future .  :D
Title: Re: TMK keyboard firmware
Post by: IBNobody on Sun, 11 September 2016, 22:43:59
I am working on a way to send HID messages to AutoHotkey. (See this post... (https://forum.pjrc.com/threads/24049-windows-dll-for-rawhid?p=115116#post115116)) It is the same principle as hid_listen.

In TMK, where is the best place for me to add print statements to output the pressed key / scancode to the HID message output?

What if I wanted to do the reverse and send data to the keyboard? Is that even implemented yet?
Title: Re: TMK keyboard firmware
Post by: eeymiel on Mon, 12 September 2016, 00:48:54
What if I wanted to do the reverse and send data to the keyboard? Is that even implemented yet?
Would be cool if we could select the layer in software.For example I want to use a different layer in Windows vs Linux.
Title: Re: TMK keyboard firmware
Post by: Dwarlorf on Tue, 13 September 2016, 05:00:43

When I do use momentary layers, I do it via macros. They give me better control over what is happening and let me do things like flash my backlight, play a chiptune, or do some fairly complicated layer shifting. For example...

https://github.com/jackhumbert/qmk_firmware/blob/master/keyboards/planck/keymaps/pvc/keymap.c

Code: [Select]
        case MACRO_UPPER:
            if (record->event.pressed)
            {
                layer_on(LAYER_UPPER);
                breathing_speed_set(2);
                breathing_pulse();
                update_tri_layer(LAYER_LOWER, LAYER_UPPER, LAYER_ADJUST);
            }
            else
            {
                layer_off(LAYER_UPPER);
                update_tri_layer(LAYER_LOWER, LAYER_UPPER, LAYER_ADJUST);
            }
            break;

        case MACRO_LOWER:
            if (record->event.pressed)
            {
                layer_on(LAYER_LOWER);
                breathing_speed_set(2);
                breathing_pulse();
                update_tri_layer(LAYER_LOWER, LAYER_UPPER, LAYER_ADJUST);
            }
            else
            {
                layer_off(LAYER_LOWER);
                update_tri_layer(LAYER_LOWER, LAYER_UPPER, LAYER_ADJUST);
            }
            break;

If I hold UPPER, I get the upper layer. If I hold LOWER, I get the LOWER layer. If I hold UPPER and then LOWER or LOWER and then UPPER, I get the ADJUST layer.

I've actually managed to make it work for my situation. I now have the basic three layers working.

More
Code: [Select]
#include "GH30.h"

enum keyboard_layers {
  LAYER_ONE = 0,
  LAYER_TWO,
  LAYER_THREE,
};

enum keyboard_macros {
  MACRO_ONE = 0,
  MACRO_TWO,
  MACRO_THREE,
};

#define M_ONE                   M(MACRO_ONE)
#define M_TWO                  M(MACRO_TWO)
#define M_THREE              M(MACRO_THREE)
#define M_FUNCT              M(MACRO_FUNCTION)

#define _______             KC_TRNS
#define XXXXXXX             KC_NO
#define ________________    _______, _______
#define XXXXXXXXXXXXXXXX    XXXXXXX, XXXXXXX

const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
/* LAYER = LAYER_ONE
add visual lay out here
*/

[LAYER_ONE] = {
      { KC_9, KC_6, KC_3, KC_0, KC_UNDS, KC_ASTR, KC_BSPC },
      { KC_8, KC_5, KC_2, KC_SCOLON, KC_LPRN, KC_DOT, KC_ENT },
      { KC_7, KC_4, KC_1, KC_O, KC_N, KC_S, KC_SPACE },
      { XXXXXXX, XXXXXXX , XXXXXXX , KC_T, KC_E, KC_I, KC_TRNS },
      { XXXXXXX, KC_RIGHT, XXXXXXX, KC_D, KC_A, KC_R, KC_DEL},
      { KC_UP, KC_LEFT, KC_DOWN, XXXXXXX, M_TWO, M_THREE, XXXXXXX  }
},   

/* LAYER = LAYER_TWO
add visual lay out here
*/

[LAYER_TWO] = {
     { KC_TRNS, KC_END, KC_PSCREEN, KC_PLUS, KC_EQUAL, KC_DLR, KC_ESC },
     { KC_PGUP, KC_TRNS, KC_PGDOWN, KC_EXLM, KC_LBRC, KC_BSLASH, KC_RCTL },
     { _______, KC_HOME, _______, KC_U, KC_G, KC_P, _______  },
     { _______, _______, _______, KC_H, KC_L, KC_K, _______  },
     { _______, _______, _______, KC_B, KC_V, KC_M, _______  },
     { _______, _______, _______, _______, _______, _______, _______  }
},

/* LAYER = LAYER_THREE
add visual lay out here
*/

[LAYER_THREE] = {
      { _______, _______, _______, KC_AT, KC_PERC, KC_HASH, _______ },
      { _______, _______, _______, KC_AMPR, KC_LCBR, KC_PIPE, _______ },
      { _______, _______, _______, KC_Y, KC_J, KC_LABK, _______ },
      { _______, _______, _______, KC_C, KC_W, KC_F, _______ },
      { _______, _______, _______, KC_Q, KC_Z, KC_X, _______ },
      { _______, _______, _______, _______, _______, _______, _______ }
},

};

/* toevoegen:
TOGGLE FUNCTIE VOOR ENTER EN SPACE
LONGPRESS NUMMER VOOR FTOETS
LONGPRESS VOOR OPPOSITES
*/

void persistant_default_layer_set(uint16_t default_layer)
{
    eeconfig_update_default_layer(default_layer);
    default_layer_set(default_layer);
}

const uint16_t PROGMEM fn_actions[] = {

};

const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
{
 switch(id)
     {
     case MACRO_ONE:
            if (record->event.pressed)
            {
                persistant_default_layer_set(1UL<<LAYER_ONE);
            }
            break;

      case MACRO_TWO:
            if (record->event.pressed)
            {
                layer_on(LAYER_TWO);
            }
            else
            {
                layer_off(LAYER_TWO);
            }
            break;

       case MACRO_THREE:
            if (record->event.pressed)
            {
                layer_on(LAYER_THREE);
            }
            else
            {
               layer_off(LAYER_THREE);
            }
            break;
      }       
     
      return MACRO_NONE;
};


void matrix_init_user(void) {

}

void matrix_scan_user(void) {

}

bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  return true;
}

void led_set_user(uint8_t usb_led) {

}


And now I'm trying to put in the QMK timer function but I'm struggling. I want a long press of keys to result in their upper case variants.
These are the error messages:
Quote
Compiling: keyboards/gh30/keymaps/default/keymap.c 
keyboards/gh30/keymaps/default/keymap.c: In function 'action_get_macro':
keyboards/gh30/keymaps/default/keymap.c:91: error: expected expression before '=' token
keyboards/gh30/keymaps/default/keymap.c:95: error: too few arguments to function 'timer_elapsed'
keyboards/gh30/keymaps/default/keymap.c:96: error: expected expression before ',' token
keyboards/gh30/keymaps/default/keymap.c:147: error: expected declaration or statement at end of input
My problem is that I kinda understand what type of errors they are but don't know where to look/what to look for. This is what I have so far:
Code: [Select]
#include "GH30.h"

enum keyboard_layers {
  LAYER_ONE = 0,
  LAYER_TWO,
  LAYER_THREE,
};

enum keyboard_macros {
  MACRO_ONE = 0,
  MACRO_TWO,
  MACRO_THREE,
};

#define M_ONE                   M(MACRO_ONE)
#define M_TWO                  M(MACRO_TWO)
#define M_THREE              M(MACRO_THREE)
#define key_timer

#define _______             KC_TRNS
#define XXXXXXX             KC_NO
#define ________________    _______, _______
#define XXXXXXXXXXXXXXXX    XXXXXXX, XXXXXXX

const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
/* LAYER = LAYER_ONE
add visual lay out here
*/

[LAYER_ONE] = {
      { KC_9, KC_6, KC_3, KC_0, KC_UNDS, KC_ASTR, KC_BSPC },
      { KC_8, KC_5, KC_2, KC_SCOLON, KC_LPRN, KC_DOT, KC_ENT },
      { KC_7, KC_4, KC_1, KC_O, KC_N, KC_S, KC_SPACE },
      { XXXXXXX, XXXXXXX , XXXXXXX , KC_T, KC_E, KC_I, KC_TRNS },
      { XXXXXXX, KC_RIGHT, XXXXXXX, KC_D, KC_A, KC_R, KC_DEL},
      { KC_UP, KC_LEFT, KC_DOWN, XXXXXXX, M_TWO, M_THREE, XXXXXXX  }
},   

/* LAYER = LAYER_TWO
add visual lay out here
*/

[LAYER_TWO] = {
     { KC_TRNS, KC_END, KC_PSCREEN, KC_PLUS, KC_EQUAL, KC_DLR, KC_ESC },
     { KC_PGUP, KC_TRNS, KC_PGDOWN, KC_EXLM, KC_LBRC, KC_BSLASH, KC_RCTL },
     { _______, KC_HOME, _______, KC_U, KC_G, KC_P, _______  },
     { _______, _______, _______, KC_H, KC_L, KC_K, _______  },
     { _______, _______, _______, KC_B, KC_V, KC_M, _______  },
     { _______, _______, _______, _______, _______, _______, _______  }
},

/* LAYER = LAYER_THREE
add visual lay out here
*/

[LAYER_THREE] = {
      { _______, _______, _______, KC_AT, KC_PERC, KC_HASH, _______ },
      { _______, _______, _______, KC_AMPR, KC_LCBR, KC_PIPE, _______ },
      { _______, _______, _______, KC_Y, KC_J, KC_LABK, _______ },
      { _______, _______, _______, KC_C, KC_W, KC_F, _______ },
      { _______, _______, _______, KC_Q, KC_Z, KC_X, _______ },
      { _______, _______, _______, _______, _______, _______, _______ }
},

};

/* toevoegen:
TOGGLE FUNCTIE VOOR ENTER EN SPACE
LONGPRESS NUMMER VOOR FTOETS
LONGPRESS VOOR OPPOSITES
*/

void persistant_default_layer_set(uint16_t default_layer)
{
    eeconfig_update_default_layer(default_layer);
    default_layer_set(default_layer);
};

const uint16_t PROGMEM fn_actions[] = {

};

const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
{
 switch(id)
     {
      case MACRO_ONE:
            if (record->event.pressed)
            {
                persistant_default_layer_set(1UL<<LAYER_ONE);
                key_timer = timer_read();
            }
            else
{
                if (timer_elapsed(key_timer) > 150) {
                    return MACRO( D(LCTL), T(C),  ,END  );
                }
                else
{
                    return MACRO_ONE;
                }           
                break;


      case MACRO_TWO:
            if (record->event.pressed)
            {
                layer_on(LAYER_TWO);
            }
            else
            {
                layer_off(LAYER_TWO);
            }
            break;

       case MACRO_THREE:
            if (record->event.pressed)
            {
                layer_on(LAYER_THREE);
            }
            else
            {
               layer_off(LAYER_THREE);
            }
            break;
      }       
     
      return MACRO_NONE;
};


void matrix_init_user(void) {

}

void matrix_scan_user(void) {

}


bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  return true;
}

void led_set_user(uint8_t usb_led) {

}

If anyone could point me in the right direction it would be much appreciated.
Title: Re: TMK keyboard firmware
Post by: algernon on Tue, 13 September 2016, 05:32:21

Code: [Select]
const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
{
 switch(id)
     {
      case MACRO_ONE:
            if (record->event.pressed)
            {
                persistant_default_layer_set(1UL<<LAYER_ONE);
                key_timer = timer_read();
            }
            else
{
                if (timer_elapsed(key_timer) > 150) {
                    return MACRO( D(LCTL), T(C),  ,END  );
                }
                else
{
                    return MACRO_ONE;
                }           
                break;

This is where your troubles start. Your curly braces are unbalanced, by the looks of it, and that upsets parsing. Make sure that any curly braces you open, are properly closed. This does not seem to be the only case of this issue.
Title: Re: TMK keyboard firmware
Post by: Dwarlorf on Tue, 13 September 2016, 06:49:54

Code: [Select]
const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
{
 switch(id)
     {
      case MACRO_ONE:
            if (record->event.pressed)
            {
                persistant_default_layer_set(1UL<<LAYER_ONE);
                key_timer = timer_read();
            }
            else
{
                if (timer_elapsed(key_timer) > 150) {
                    return MACRO( D(LCTL), T(C),  ,END  );
                }
                else
{
                    return MACRO_ONE;
                }           
                break;

This is where your troubles start. Your curly braces are unbalanced, by the looks of it, and that upsets parsing. Make sure that any curly braces you open, are properly closed. This does not seem to be the only case of this issue.

Thanks for your help. I was indeed missing some curly wurly braces which I was able to solve.

Now I still have these errors left:
Quote
keyboards/gh30/keymaps/default/keymap.c:91: error: expected expression before '=' token
keyboards/gh30/keymaps/default/keymap.c:95: error: too few arguments to function 'timer_elapsed'

Could that also be an issue with some curly braces or is there more to it? As example I used: http://qmk.fm/#example-single-key-copypaste-hold-to-copy-tap-to-paste

Code: [Select]
const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
{
 switch(id)
     {
      case MACRO_ONE:
            if (record->event.pressed)
            {
                persistant_default_layer_set(1UL<<LAYER_ONE);
key_timer = timer_read();
            }
            else
{
                if (timer_elapsed(key_timer)> 150)
{
                    return MACRO( D(LCTL), T(C),  END );
                }
                else
{
                    return MACRO_ONE;
                }
}         
                break;
Title: Re: TMK keyboard firmware
Post by: algernon on Tue, 13 September 2016, 09:25:58
Now I still have these errors left:
Quote
keyboards/gh30/keymaps/default/keymap.c:91: error: expected expression before '=' token
keyboards/gh30/keymaps/default/keymap.c:95: error: too few arguments to function 'timer_elapsed'

Could you upload your full keymap to gist.github.com, or somewhere similar where it is easier to see line numbers? (bonus points if I can clone it too, to see it locally).
Title: Re: TMK keyboard firmware
Post by: Dwarlorf on Tue, 13 September 2016, 11:02:31
Now I still have these errors left:
Quote
keyboards/gh30/keymaps/default/keymap.c:91: error: expected expression before '=' token
keyboards/gh30/keymaps/default/keymap.c:95: error: too few arguments to function 'timer_elapsed'

Could you upload your full keymap to gist.github.com, or somewhere similar where it is easier to see line numbers? (bonus points if I can clone it too, to see it locally).

Dropbox (https://www.dropbox.com/sh/xn68ae3tqcsf6r2/AADK5lL_UeurDQ0-e5oBUt4da?dl=0)

Github (https://gist.github.com/dwarlorf/1c773ebd01642677996671428f7f797f)

If you need more please let me know. Thank you for your help once again.  :thumb:
Title: Re: TMK keyboard firmware
Post by: IBNobody on Tue, 13 September 2016, 12:09:21
So... Obvious question... Why do you need MACRO_ONE defined when your keymap isn't calling it? If you deleted lines 87-104, your code would compile.

As to the errors. You need to define key_timer with a variable definition like "uint_16 key_timer;" on line 85 rather than a #define on 18. #defines are used to tell the compiler to do some magic code processing before the code actually gets compiled. For more info, google C preprocessor.

Note that I don't know the data type that timer_read returns. It could be uint_8 or int. You'd have to look up the timer_read function.


Also, you don't need persistant_default_layer_set(1UL<<LAYER_ONE);. That is only used to set the current layer and layer at power-on. As long as you never call persistant_default_layer_set, your QWERTY layer will always be the lowest default layer.
Title: Re: TMK keyboard firmware
Post by: algernon on Tue, 13 September 2016, 16:28:42
Note that I don't know the data type that timer_read returns. It could be uint_8 or int. You'd have to look up the timer_read function.

It's uint16_t, fwiw.
Title: Re: TMK keyboard firmware
Post by: Dwarlorf on Tue, 13 September 2016, 21:53:11
So... Obvious question... Why do you need MACRO_ONE defined when your keymap isn't calling it? If you deleted lines 87-104, your code would compile.

As to the errors. You need to define key_timer with a variable definition like "uint_16 key_timer;" on line 85 rather than a #define on 18. #defines are used to tell the compiler to do some magic code processing before the code actually gets compiled. For more info, google C preprocessor.

Note that I don't know the data type that timer_read returns. It could be uint_8 or int. You'd have to look up the timer_read function.

Also, you don't need persistant_default_layer_set(1UL<<LAYER_ONE);. That is only used to set the current layer and layer at power-on. As long as you never call persistant_default_layer_set, your QWERTY layer will always be the lowest default layer.

Its not so obvious to me.  I have little to no experience with programming. This is all new to me. I've been looking on the internet but one of the big problems with all those explanations is that they're all so cryptic because they're written by programmers for programmers and not for total inexperienced people like me.

But once again thank you for your help.

Note that I don't know the data type that timer_read returns. It could be uint_8 or int. You'd have to look up the timer_read function.

It's uint16_t, fwiw.

Thanks again. Ill look into it some more later.

Title: Re: TMK keyboard firmware
Post by: IBNobody on Tue, 13 September 2016, 22:00:26
Haha, it's all good. We'll get you there.
Title: Re: TMK keyboard firmware
Post by: Dwarlorf on Tue, 13 September 2016, 22:08:17
Haha, it's all good. We'll get you there.

I have no doubt!  :thumb:
Title: Re: TMK keyboard firmware
Post by: splicepoint on Tue, 13 September 2016, 22:48:03
Hi all,

First time posting here. I'm working through my first mech build using a Phantom PCB and I'm having some trouble when trying to compile the file for flashing to my Teensy 2.0. I'm fairly inexperienced at programming other than some basics and looking for a hand, if someone doesn't mind having a look.

I know that my issue is occurring in the keymap.c file line 148 and that I'm missing an expression. I can get that much, but not so sure how to solve the issue. Any help would be greatly appreciated.

Edit: While the screenshot says otherwise (I was trying everything to get this to work) I've been using the "make -f Makefile.pjrc ansi" command via the console. The same error exists either way.

[attach=1]
[attach=2]
Title: Re: TMK keyboard firmware
Post by: Dwarlorf on Thu, 15 September 2016, 05:02:32
Haha, it's all good. We'll get you there.

Well I managed to get it right! It's actually quite simple.
Note to self: stop thinking too complex. Start with the basics.

Code: [Select]
static uint16_t key_timer;

const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
{
      switch(id) {
        case 4: {
            if (record->event.pressed) {
                key_timer = timer_read(); // if the key is being pressed, we start the timer.
            }
            else { // this means the key was just released, so we can figure out how long it was pressed for (tap or "held down").
                if (timer_elapsed(key_timer) > 150) { // 150 being 150ms, the threshhold we pick for counting something as a tap.
return MACRO( D(LSFT), T(D), U(LSFT), END);
                }
                else {
return MACRO( T(D), END);
                }
            }
            break;
        }
      }
    return MACRO_NONE;
};

And in the keymap I assigned M(4) to 'D'. (row 5, column 3)

Code: [Select]
[LAYER_ONE] = {
      { KC_9, KC_6, KC_3, KC_0, KC_UNDS, KC_ASTR, KC_BSPC },
      { KC_8, KC_5, KC_2, KC_SCOLON, KC_LPRN, KC_DOT, KC_ENT },
      { KC_7, KC_4, KC_1, KC_O, KC_N, KC_S, KC_SPACE },
      { XXXXXXX, XXXXXXX , XXXXXXX , KC_T, KC_E, KC_I, KC_TRNS },
      { XXXXXXX, KC_RIGHT, XXXXXXX, M(4), KC_A, KC_R, KC_DEL},
      { KC_UP, KC_LEFT, KC_DOWN, XXXXXXX, M_TWO, M_THREE, XXXXXXX  }

Now I'm wondering if there's a shorter way to program all this because now I need to assign a macro to every letter (and other symbols). That's a lot of code.
Title: Re: TMK keyboard firmware
Post by: algernon on Thu, 15 September 2016, 05:37:05
Now I'm wondering if there's a shorter way to program all this because now I need to assign a macro every letter (and other symbol). That's a lot of code.

You can: implement `process_record_user`, a function that gets executed for each and every key pressed or released. In that function, you can do something like this (pseudo-code follows, because I don't have the time to write the real code for you):

Code: [Select]
if (!(key >= KC_A && key <= KC_Z))
  return true; // not a key we care about, let the default handler handle it
if (pressed) {
  start_timer_for_key(keycode);
} else {
  if (long_press) {
    register_shift;
    register_key;
    unregister_key;
    unregister_shift;
  } else {
    register_key;
    unregister_key;
  }
}

The downside of this is that you lose the ability to hold a key and have it repeat, and keys will only register on keyup. You could make it support holding too, if you'd hook into `matrix_scan_user`, and iterate over the keymap, checking for expired timers. But then you'd have to keep track of held keys too, to not register them twice or change the above logic to have a case for expired keys, too.

Hope this helps.
Title: Re: TMK keyboard firmware
Post by: Dwarlorf on Thu, 15 September 2016, 05:59:39
Now I'm wondering if there's a shorter way to program all this because now I need to assign a macro every letter (and other symbol). That's a lot of code.

You can: implement `process_record_user`, a function that gets executed for each and every key pressed or released. In that function, you can do something like this (pseudo-code follows, because I don't have the time to write the real code for you):

The downside of this is that you lose the ability to hold a key and have it repeat, and keys will only register on keyup. You could make it support holding too, if you'd hook into `matrix_scan_user`, and iterate over the keymap, checking for expired timers. But then you'd have to keep track of held keys too, to not register them twice or change the above logic to have a case for expired keys, too.

Hope this helps.

I actually want to program as much as possible myself. All I need is being pointed to the right direction, and some help when I'm stuck.  And that's exactly what I'm getting from you guys. :) Thanks again.
Hold and repeat doesn't work now either so that's no problem. I don't think it's a very important feature anyway.
Title: Re: TMK keyboard firmware
Post by: splicepoint on Fri, 16 September 2016, 21:51:48
Hi all,

First time posting here. I'm working through my first mech build using a Phantom PCB and I'm having some trouble when trying to compile the file for flashing to my Teensy 2.0. I'm fairly inexperienced at programming other than some basics and looking for a hand, if someone doesn't mind having a look.

I know that my issue is occurring in the keymap.c file line 148 and that I'm missing an expression. I can get that much, but not so sure how to solve the issue. Any help would be greatly appreciated.

Edit: While the screenshot says otherwise (I was trying everything to get this to work) I've been using the "make -f Makefile.pjrc ansi" command via the console. The same error exists either way.

(Attachment Link)
(Attachment Link)

Thanks to help from IBNobody and some others around reddit, I've been able to start compiling. However, now I'm stuck with only 8 functional keys. If spam enough keys at the same time periodically I will get some others that will briefly activate. This makes me think that I could possibly have a ghosting issue? Is this a fair assumption. I thought I checked the direction of each diode but could this be the problem?

Thanks in advance.
Title: Re: TMK keyboard firmware
Post by: IBNobody on Fri, 16 September 2016, 23:31:59

Thanks to help from IBNobody and some others around reddit, I've been able to start compiling. However, now I'm stuck with only 8 functional keys. If spam enough keys at the same time periodically I will get some others that will briefly activate. This makes me think that I could possibly have a ghosting issue? Is this a fair assumption. I thought I checked the direction of each diode but could this be the problem?

Thanks in advance.

Glad to help.

In what condition did you receive the PCB. Did you have to populate the diodes? And how did you check their direction? What happens if you place a short across the switch? What happens when you place a short across the diode AND the switch? Could your diodes be reversed? Have any pics of the board?
Title: Re: TMK keyboard firmware
Post by: ctm on Sat, 17 September 2016, 15:48:18
Is there a ACTION_FN_TAP_KEY? I would like to have Shift+Esc to produce ~, but my right shift has already been used as a ACTION_MODS_TAP_KEY(MOD_RSFT, KC_UP). Is it possible to have tapping Shift produces up arrow and holding the key produces ACTION_LAYER_MODS(3, MOD_RSFT)?
Title: Re: TMK keyboard firmware
Post by: hasu on Sat, 17 September 2016, 17:25:16
Is there a ACTION_FN_TAP_KEY? I would like to have Shift+Esc to produce ~, but my right shift has already been used as a ACTION_MODS_TAP_KEY(MOD_RSFT, KC_UP). Is it possible to have tapping Shift produces up arrow and holding the key produces ACTION_LAYER_MODS(3, MOD_RSFT)?

you need to write your own action in  action_function() and define it with ACTION_FUNCTION_TAP().
Title: Re: TMK keyboard firmware
Post by: ctm on Sat, 17 September 2016, 18:26:09
Is there a ACTION_FN_TAP_KEY? I would like to have Shift+Esc to produce ~, but my right shift has already been used as a ACTION_MODS_TAP_KEY(MOD_RSFT, KC_UP). Is it possible to have tapping Shift produces up arrow and holding the key produces ACTION_LAYER_MODS(3, MOD_RSFT)?

you need to write your own action in  action_function() and define it with ACTION_FUNCTION_TAP().
Cool. Thanks!
Title: Re: TMK keyboard firmware
Post by: splicepoint on Sun, 18 September 2016, 22:15:03
In what condition did you receive the PCB. Did you have to populate the diodes? And how did you check their direction? What happens if you place a short across the switch? What happens when you place a short across the diode AND the switch? Could your diodes be reversed? Have any pics of the board?

The PCB looks great. I did have the populate the diodes, that's where I suspect the issue is. I can sometimes get keys working if I spam the whole keyboard at once. I tested the diodes using a multimeter to make sure they had a reading one direction but not the other; I installed all the diodes with the black line towards the square contact point on the PCB. Nothing is impossible and I'm wondering if I messed one up at some point, there are a few that have to be reversed based on location on the PCB.

I have not tried shorting the diode & switch (and then pressing the switch I assume?).

Here's an imgur album: http://imgur.com/gallery/jFj0p (http://imgur.com/gallery/jFj0p) of some photos. Unfortunately I did an dumb thing and put the diodes on the underside so I'll need to desolder every switch to get back to that side of the PCB. As I mentioned, this is a first time for me so I'm learning as I go. I will likely desolder each switch at some point and get back to the top of the board in order to
then test the firmware without the keys in the board so I can adjust on the fly. It'll take me a while to desolder them so it may be a while before I post an update.

Any tips on testing/reworking or any additional insight on firmware vs. hardware I'm tracking this thread. Thanks!
Title: Re: TMK keyboard firmware
Post by: a-c on Mon, 19 September 2016, 04:36:40
Is the Teensy soldered to the pins?

Here's an imgur album: http://imgur.com/gallery/jFj0p (http://imgur.com/gallery/jFj0p) of some photos. Unfortunately I did an dumb thing and put the diodes on the underside so I'll need to desolder every switch to get back to that side of the PCB. As I mentioned, this is a first time for me so I'm learning as I go. I will likely desolder each switch at some point and get back to the top of the board in order to
then test the firmware without the keys in the board so I can adjust on the fly. It'll take me a while to desolder them so it may be a while before I post an update.

Any tips on testing/reworking or any additional insight on firmware vs. hardware I'm tracking this thread. Thanks!
Title: Re: TMK keyboard firmware
Post by: splicepoint on Mon, 19 September 2016, 09:16:08
Is the Teensy soldered to the pins?

It is in indeed, I've tested the connections from each switch contact point on the PCB back to the Teensy with luck. The Teensy shouldn't be the issue.
Title: Re: TMK keyboard firmware
Post by: IBNobody on Tue, 20 September 2016, 09:11:23
The PCB looks great. I did have the populate the diodes, that's where I suspect the issue is. I can sometimes get keys working if I spam the whole keyboard at once. I tested the diodes using a multimeter to make sure they had a reading one direction but not the other; I installed all the diodes with the black line towards the square contact point on the PCB. Nothing is impossible and I'm wondering if I messed one up at some point, there are a few that have to be reversed based on location on the PCB.

I have not tried shorting the diode & switch (and then pressing the switch I assume?).

Here's an imgur album: http://imgur.com/gallery/jFj0p (http://imgur.com/gallery/jFj0p) of some photos. Unfortunately I did an dumb thing and put the diodes on the underside so I'll need to desolder every switch to get back to that side of the PCB. As I mentioned, this is a first time for me so I'm learning as I go. I will likely desolder each switch at some point and get back to the top of the board in order to
then test the firmware without the keys in the board so I can adjust on the fly. It'll take me a while to desolder them so it may be a while before I post an update.

Any tips on testing/reworking or any additional insight on firmware vs. hardware I'm tracking this thread. Thanks!

Thanks for the pictures.

The code is set up to look for a logic 0 on the rows. Normally, the rows float at 3-5V due to some internal pullup resistors. The code is also set up to drive the active column to 0. When you push a switch and the column that the switch is on is active, it pulls the row line down to 0. If you have diodes backwards, this will not happen.

Without plugging your board in... If you put the + terminal of your DMM (in Diode mode) on a row (B0-B5), put the - terminal on the column with a switch (D5  C7  C6  D4  D0  E6  F0  F1  F4  F5  F6  F7  D7  D6  D1  D2  D3), and press the switch, do you read the diode voltage drop (of around 0.63V)?

Also, have you confirmed that there are no shorts between pins? It looks like you mounted your teensy flush against the PCB. That may be a source of the problem. Whenever I do that, I always put a barrier of nonconductive tape on the bottom of the teensy.

Finally, dumb question... Where did you buy your Teensy?
Title: Re: TMK keyboard firmware
Post by: kekstee on Tue, 20 September 2016, 18:57:09
So I got a NerD60 flashed with tmk. And it almost behaves like I would expect it to.
But despite every LED working in backlight mode the caps lock indicator just refuses to do anything. As far as I understand it that should work out of the box, reporting its status through the led_set function.
Or am I missing something obvious?

I tried excluding the caps bit from backlight_init_ports, thinking it might interfere, but that didn't change anything.
https://github.com/tmk/tmk_keyboard/blob/master/orphan/nerd/backlight.c

Also, why does not setting the backlight port as output in DDRB just dim the backlight?
Title: Re: TMK keyboard firmware
Post by: hasu on Tue, 20 September 2016, 19:35:58
So I got a NerD60 flashed with tmk. And it almost behaves like I would expect it to.
But despite every LED working in backlight mode the caps lock indicator just refuses to do anything. As far as I understand it that should work out of the box, reporting its status through the led_set function.
Or am I missing something obvious?

I tried excluding the caps bit from backlight_init_ports, thinking it might interfere, but that didn't change anything.
https://github.com/tmk/tmk_keyboard/blob/master/orphan/nerd/backlight.c

Also, why does not setting the backlight port as output in DDRB just dim the backlight?


What if with orignial author's repository?
https://github.com/xauser/tmk_keyboard/tree/xauser
Title: Re: TMK keyboard firmware
Post by: kekstee on Wed, 21 September 2016, 04:38:38
I did test it again, same result. Then I finally managed to google up the answer I needed in the first place. The caps indicator LED is on the PCB next to it, not the in switch LED :D
Thanks for directing me towards the original author though, I could have asked him if it was a software problem.
Title: Re: TMK keyboard firmware
Post by: axtran on Thu, 22 September 2016, 07:01:56
I did test it again, same result. Then I finally managed to google up the answer I needed in the first place. The caps indicator LED is on the PCB next to it, not the in switch LED :D
Thanks for directing me towards the original author though, I could have asked him if it was a software problem.

Glad hasu was able to help. Yeah, the LED pins for "Indicator" are what drive the caps notification. I usually use clear housing switch and a "creatively installed" RGB LED in order to get my desired results with the Caps functionality: http://imgur.com/zz0bXnU
Title: Re: TMK keyboard firmware
Post by: lkong on Wed, 28 September 2016, 12:06:26
I recently made a hand-wired keyboard using tmk firmware.
it works perfectly on one machine but not the other.
Works on Surface Book, also inside a linux VM:
(http://i.imgur.com/UGLk6h7.gif)
Pressing f gives f back

But not the other machine
(http://i.imgur.com/BuuX8lB.gif)
Pressing f gives f and v back

Any ideas why it is happening?
Title: Re: TMK keyboard firmware
Post by: IBNobody on Wed, 28 September 2016, 13:10:47
You are firing modifier keys. That's why you see the ribbon menu in Word flash. Grab Switch Hitter. That will help diagnose misfiring keys.

https://elitekeyboards.com/switchhitter.php
Title: Re: TMK keyboard firmware
Post by: hasu on Wed, 28 September 2016, 16:37:40
 lkong,
What are OS on "Surface Book"  and "the other"?
Smell like NKRO. Are you using NKRO?
Title: Re: TMK keyboard firmware
Post by: lkong on Wed, 28 September 2016, 17:09:06
lkong,
What are OS on "Surface Book"  and "the other"?
Smell like NKRO. Are you using NKRO?
Surface Book is running Win10
The other is my office computer running Win7.
It also misbehaves on my home computer which is running Win10.

And no, NKRO is turned off.
Title: Re: TMK keyboard firmware
Post by: hasu on Wed, 28 September 2016, 17:27:04
Then it is likely your hardware or code. Use the tool as IBNobody said.

Sent from my Nexus 5X

Title: Re: TMK keyboard firmware
Post by: lkong on Wed, 28 September 2016, 22:54:08
Then it is likely your hardware or code. Use the tool as IBNobody said.

Sent from my Nexus 5X
(http://i.imgur.com/MDii7qT.gif)
Tested this on my home computer the whole row was firing.
It's connected to B2 pin on the teensy 2.0 Is that the pin I suppose to avoid?
The misfiring occurs even if I desoldered the wire connected to the particular row.
So it's definitely software/code coursing a whole row firing.
Title: Re: TMK keyboard firmware
Post by: IBNobody on Wed, 28 September 2016, 23:24:08
That's awesome. What key are you hitting in that picture?

B2 is fine to use.

Do you have your diodes backwards maybe?
Title: Re: TMK keyboard firmware
Post by: lkong on Wed, 28 September 2016, 23:41:51
That's awesome. What key are you hitting in that picture?

B2 is fine to use.

Do you have your diodes backwards maybe?
A whole row:
Alt, z, x, c, v, b, Esc, Num layer.
As shown as the third row and 6th row (they are connected by wire) on the left hand.
    /*  _________________________________________                     _________________________________________  */
    /* |      |      |      |      |      |      |                   |      |      |      |      |      |      | */
    /* | SHFT |  Q   |  W   |  E   |  R   |  T   |                   |  Y   |  U   |  I   |  O   |  P   | SHFT | */
    /* |______|______|______|______|______|______|                   |______|______|______|______|______|______| */
    /* |      |      |      |      |      |      |                   |      |      |      |      |      |      | */
    /* | CTRL |  A   |  S   |  D   |  F   |  G   |                   |  H   |  J   |  K   |  L   |  ;   |  CMD | */
    /* |______|______|______|______|______|______|                   |______|______|______|______|______|______| */
    /* |      |      |      |      |      |      |                   |      |      |      |      |      |      | */
    /* |  ALT |  Z   |  X   |  C   |  V   |  B   |                   |  N   |  M   |  ,   |  .   |  /   |  ALT | */
    /* |______|______|______|______|______|______|_                 _|______|______|______|______|______|______| */
    /*                               |      |      |               |      |      |                               */
    /*                               | BSPC | CMD  |               | CTRL | SPC  |                               */
    /*                               |      |      |               |      |      |                               */
    /*                               |______|______|_             _|______|______|                               */
    /*                                 |      |      |           |      |      |                                 */
    /*                                 | TAB  | SYM  |           | SYM  |  ENT |                                 */
    /*                                 |______|_LYR__|_         _|_LYR__|______|                                 */
    /*                                   |      |      |       |      |      |                                   */
    /*                                   |  ESC | NUM  |       | AROW | ALT  |                                   */
    /*                                   |______|_LYR__|       |__LYR_|______|                                   */
    /*                                                                                                           */
    /*                                                                                                           */
    /*                                                                                                           */
Title: Re: TMK keyboard firmware
Post by: lkong on Wed, 28 September 2016, 23:42:28
That's awesome. What key are you hitting in that picture?

B2 is fine to use.

Do you have your diodes backwards maybe?
Diodes are fine.
It's firing the whole row:
Alt, z, x, c, v, b, Esc, Num layer.
As shown as the third row and 6th row (they are connected by wire) on the left hand.
    /*  _________________________________________                     _________________________________________  */
    /* |      |      |      |      |      |      |                   |      |      |      |      |      |      | */
    /* | SHFT |  Q   |  W   |  E   |  R   |  T   |                   |  Y   |  U   |  I   |  O   |  P   | SHFT | */
    /* |______|______|______|______|______|______|                   |______|______|______|______|______|______| */
    /* |      |      |      |      |      |      |                   |      |      |      |      |      |      | */
    /* | CTRL |  A   |  S   |  D   |  F   |  G   |                   |  H   |  J   |  K   |  L   |  ;   |  CMD | */
    /* |______|______|______|______|______|______|                   |______|______|______|______|______|______| */
    /* |      |      |      |      |      |      |                   |      |      |      |      |      |      | */
    /* |  ALT |  Z   |  X   |  C   |  V   |  B   |                   |  N   |  M   |  ,   |  .   |  /   |  ALT | */
    /* |______|______|______|______|______|______|_                 _|______|______|______|______|______|______| */
    /*                               |      |      |               |      |      |                               */
    /*                               | BSPC | CMD  |               | CTRL | SPC  |                               */
    /*                               |      |      |               |      |      |                               */
    /*                               |______|______|_             _|______|______|                               */
    /*                                 |      |      |           |      |      |                                 */
    /*                                 | TAB  | SYM  |           | SYM  |  ENT |                                 */
    /*                                 |______|_LYR__|_         _|_LYR__|______|                                 */
    /*                                   |      |      |       |      |      |                                   */
    /*                                   |  ESC | NUM  |       | AROW | ALT  |                                   */
    /*                                   |______|_LYR__|       |__LYR_|______|                                   */
    /*                                                                                                           */
    /*                                                                                                           */
    /*                                                                                                           */
Title: Re: TMK keyboard firmware
Post by: Dwarlorf on Thu, 29 September 2016, 00:01:59
That's awesome. What key are you hitting in that picture?

B2 is fine to use.

Do you have your diodes backwards maybe?
A whole row:
Alt, z, x, c, v, b, Esc, Num layer.

I had a similar problem with a column and it turned out I forgot a pin in the col init function in the matrix .c file. Maybe it's a similar problem with your row? I'm guessing here since I'm by no means an expert.
Title: Re: TMK keyboard firmware
Post by: lkong on Thu, 29 September 2016, 00:41:06
That's awesome. What key are you hitting in that picture?

B2 is fine to use.

Do you have your diodes backwards maybe?
A whole row:
Alt, z, x, c, v, b, Esc, Num layer.

I had a similar problem with a column and it turned out I forgot a pin in the col init function in the matrix .c file. Maybe it's a similar problem with your row? I'm guessing here since I'm by no means an expert.
Fixed the problem is B2 is used in led.c.
So that it gets all funky to trigger the whole row.
Still have no idea why it works on Surface Book but nothing else.
Title: Re: TMK keyboard firmware
Post by: XenGi on Sun, 02 October 2016, 17:54:19
Hi,

I'm a bit confused. I made my own keyboard with a custom layout. Next step is the firmware. It would be cool to use the tmk one but I'm not sure if this is possible.

Here's my layout for keyboard layout editor (http://www.keyboard-layout-editor.com/): gist (https://gist.github.com/XenGi/6683d370900801a808e4169d29cc2929)

Here's the hardware: http://imgur.com/a/Vwe7P

Is it possible to use the tmk firmware for this? Because I can only find 40% keyboards or ergodox. I thought I could just put my layout in a config file, define some pins and done. Can anyone point me in the right directions? I can't find a step by step guide how to get started with this.

PS:
I have 9 more plates with this layout. My brother made these with a big laser cnc at work. It's 5 different types of steel. I can make pictures if your interested.
So if anyone likes the layout and wants a plate I can ship them basically anywhere in exchange for something nice or interesting. Candy is always a good choice. ;)
Title: Re: TMK keyboard firmware
Post by: ideus on Wed, 05 October 2016, 08:54:45
What the code is to get double functionality for an ESC and ~' key, combined.
Title: Re: TMK keyboard firmware
Post by: hasu on Wed, 05 October 2016, 20:33:46
What the code is to get double functionality for an ESC and ~' key, combined.

I don't know how these two keys can be combined. You have a idea?
Title: Re: TMK keyboard firmware
Post by: hasu on Wed, 05 October 2016, 20:37:29
Checked ****ing FAQ and found this. You may be interested.
https://github.com/tmk/tmk_keyboard/wiki/FAQ-Keymap#esc-and--on-a-key
Title: Re: TMK keyboard firmware
Post by: ideus on Wed, 05 October 2016, 22:59:53
Checked ****ing FAQ and found this. You may be interested.
https://github.com/tmk/tmk_keyboard/wiki/FAQ-Keymap#esc-and--on-a-key (https://github.com/tmk/tmk_keyboard/wiki/FAQ-Keymap#esc-and--on-a-key)


This is it, you are a life saver Sir Hasu. Thank you very much.
Title: Re: TMK keyboard firmware
Post by: SirFabular on Fri, 07 October 2016, 10:26:34
Hi,
I've previously with success used this firmware for two custom keyboards without any problems, but this time cant find the error even when comparing against my earlier builds. The error is keymap_poker.c:16: error: expected '}' before 'KC_NO'

This is my keymap_common.h
Code: [Select]
#define KEYMAP( \
    K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, \
    K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, \
    K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, \
    K30, K31, K32, K33, K34, K35, K36, K37, K38, K39, K3A, \
    K40, K41, K42, K43, K44, K45, K46, K47, K48, K49, K4A, \
    K50, K51, K52,                         K56,                         K5A, \
    K60, K61, K62, K63, K64, K65, K66, K67, K68, K69, K6A, \
    K70, K71,         K73, K74, K75, K76, K77, K78, K79, K7A, \
    K80, K81,         K83, K84, K85, K86, K87, K88, K89, K8A, \
    K90, K91,                 K94, K95, K96, K97, K98, K99,      \
    KA0,         KA2,         KA4, KA5, KA6, KA7, KA8, KA9, KAA, \
    KB0, KB1,         KB3, KB4, KB5, KB6,         KB8, KB9       \
) { \
    { 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_##K14, 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_##K33, 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_##K48, KC_##K49, KC_##K4A }, \
    { KC_##K50, KC_##K51, KC_##K52, KC_NO,   KC_NO,    KC_NO,    KC_##K56  KC_NO,    KC_NO,    KC_NO,    KC_##K5A }, \
{ KC_##K60, KC_##K61, KC_##K62, KC_##K63, KC_##K64, KC_##K65, KC_##K66, KC_##K67, KC_##K68, KC_##K69, KC_##K6A }, \
    { KC_##K70, KC_##K71, KC_NO,    KC_##K73, KC_##K74, KC_##K75, KC_##K76, KC_##K77, KC_##K78, KC_##K79, KC_##K7A }, \
    { KC_##K80, KC_##K81, KC_NO,    KC_##K83, KC_##K84, KC_##K85, KC_##K86, KC_##K87, KC_##K88, KC_##K89, KC_##K8A }, \
    { KC_##K90, KC_##K91, KC_NO,    KC_NO,    KC_##K94, KC_##K95, KC_##K96, KC_##K97, KC_##K98, KC_##K99, KC_NO    }, \
{ KC_##KA0, KC_NO,    KC_##KA2, KC_NO,    KC_##KA4, KC_##KA5, KC_##KA6, KC_##KA7, KC_##KA8, KC_##KA9, KC_##KAA }, \
{ KC_##KB0, KC_##KB1, KC_NO,    KC_##KB3, KC_##KB4, KC_##KB5, KC_##KB6, KC_NO,    KC_##KB8, KC_##KB9, KC_NO    }  \
}

#endif

And this is the keymap_poker.c
Code: [Select]
#include "keymap_common.h"

const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {

 KEYMAP(ESC,    F1,     F2,     F3,     F4,     F5,     F6,     F7,     F8,     F9,     F10,    \
        GRV,    1,      2,      3,      4,      5,      6,      7,      8,      9,      0,      \
        TAB,    Q,      W,      E,      R,      T,      Y,      U,      I,      O,      P,      \
        CAPS,   A,      S,      D,      F,      G,      H,      J,      K,      L,      SCLN,   \
        LSFT,   NUBS,   Z,      X,      C,      V,      B,      N,      M,      COMM,   DOT,    \
        LCTL,   LGUI,   LALT,                           SPC,                            RALT,   \
        F11,    F12,    F13,    F14,    PSCR,   SLCK,   PAUS,   CALC,   MYCM,   WHOM,   PWR,    \
        MINS,   EQL,            BSPC,   INS,    HOME,   PGUP,   NLCK,   PSLS,   PAST,   PMNS,   \
        LBRC,   RBRC,           ENT,    DELETE, END,    PGDN,   P7,     P8,     P9,     PPLS,   \
        QUOT,   BSLS,                   VOLU,   MUTE,   NO,     P4,     P5,     P6,             \
        SLSH,           RSFT,           VOLD,   UP,     NO,     P1,     P2,     P3,     PENT,   \
        RGUI,   NO,             RCTL,   LEFT,   DOWN,   RGHT,           P0,     PDOT)
};

Any help is appreciated since I'm stuck here.
Title: Re: TMK keyboard firmware
Post by: Tactile on Fri, 07 October 2016, 10:36:35
I think "PDOT)" should be "PDOT),"
Title: Re: TMK keyboard firmware
Post by: SirFabular on Fri, 07 October 2016, 10:43:25
Thanks, but that comma seems to have no impact on the error message.
Title: Re: TMK keyboard firmware
Post by: SirFabular on Fri, 07 October 2016, 13:07:30
Nevermind. I still dont have any idea what caused the error, but it works now after rewriting everything. :thumb:
Title: Re: TMK keyboard firmware
Post by: kalmlikabohm on Fri, 07 October 2016, 15:54:24
First time posting!

I have a switch tester on the way and I wanted to hand wire it, so I figured I would try the OneKey keyboard folder within the TMK project with my Teensy 2.0

However, I get the same linker error on both Ubuntu and OS X.

Does anyone have any idea what is going on? I just wanted to make sure I can compile and download a simple firmware before going forward.


Code: [Select]
obj_onekey_lufa/common/keymap.o: In function `keymap_key_to_keycode':
/Users/mhiggins/projects/tmk_keyboard/keyboard/onekey/../../tmk_core/common/keymap.c:236: undefined reference to `keymaps'
/Users/mhiggins/projects/tmk_keyboard/keyboard/onekey/../../tmk_core/common/keymap.c:236: undefined reference to `keymaps'
obj_onekey_lufa/common/keymap.o: In function `keymap_fn_to_action':
/Users/mhiggins/projects/tmk_keyboard/keyboard/onekey/../../tmk_core/common/keymap.c:246: undefined reference to `fn_actions'
/Users/mhiggins/projects/tmk_keyboard/keyboard/onekey/../../tmk_core/common/keymap.c:246: undefined reference to `fn_actions'
collect2: error: ld returned 1 exit status
make: *** [onekey_lufa.elf] Error 1



Title: Re: TMK keyboard firmware
Post by: hasu on Fri, 07 October 2016, 16:00:36
Did you edit any files? Or do you still get the error with default codes?

Sent from my Nexus 5X

Title: Re: TMK keyboard firmware
Post by: kalmlikabohm on Fri, 07 October 2016, 16:04:42
Did you edit any files? Or do you still get the error with default codes?

Sent from my Nexus 5X

I didn't edit any files, just git clone and make!

Title: Re: TMK keyboard firmware
Post by: hasu on Fri, 07 October 2016, 16:06:56
OK. I'll check recent commits later which might break existent codes.

Sent from my Nexus 5X

Title: Re: TMK keyboard firmware
Post by: kalmlikabohm on Fri, 07 October 2016, 16:08:22
OK. I'll check recent commits later which might break existent codes.

Sent from my Nexus 5X

Awesome! Thanks for the quick reply. I'm excited to get into TMK.
Title: Re: TMK keyboard firmware
Post by: hasu on Fri, 07 October 2016, 17:15:20
OK. I'll check recent commits later which might break existent codes.

Sent from my Nexus 5X

Awesome! Thanks for the quick reply. I'm excited to get into TMK.

Remove 'static' keywords from keymap.c. It will update in repository later.

https://github.com/tmk/tmk_keyboard/issues/56#issuecomment-252373646
Title: Re: TMK keyboard firmware
Post by: Eszett on Sat, 08 October 2016, 09:48:54
The keycodes KC_COPY and KC_PASTE doesn't seem to work for me, anyone got an idea what might be the issue?
Title: Re: TMK keyboard firmware
Post by: Tactile on Sat, 08 October 2016, 10:04:38
The keycodes KC_COPY and KC_PASTE doesn't seem to work for me, anyone got an idea what might be the issue?

I'm reading tmk_keyboard/tmk_core/common/keycode.h and KC_COPY is, I think, 0x7C. In this chart, Microsoft seem to say that code is for F13. It looks like Windows won't interpret those codes the way you want.

[EDIT]

I'm sitting here looking at that page in one of the tabs but when I copy/paste the address it botches. I hope you can make it work.

https://msdn.microsoft.com/en-us/library/windows/desktop/dd375731

https://msdn.microsoft.com/en-us/library/windows/desktop/dd375731%28v=vs.85%29.aspx
Title: Re: TMK keyboard firmware
Post by: Eszett on Sat, 08 October 2016, 10:21:24
Hi Tactile. Yes, I can follow your argument. Do you think it is a shortcoming in TMK?
Title: Re: TMK keyboard firmware
Post by: Tactile on Sat, 08 October 2016, 10:30:18
Hi Tactile. Yes, I can follow your argument. Do you think it is a bug in TMK?

I don't think in Windows there is a single key code for copy or paste. I think there are only CTL-C & CTL-V. The problem isn't in TMK but instead in the way Windows interprets keycodes. I think the "COPY" & "PASTE" in TMK are holdovers from UNIX keyboards & there just isn't an equivalent in Windows.
Title: Re: TMK keyboard firmware
Post by: Eszett on Sat, 08 October 2016, 10:34:38
@Tactile, yes, understood. So I have to put up a macro in TMK for "Ctrl-v" and "Ctrl-c".
Title: Re: TMK keyboard firmware
Post by: Tactile on Sat, 08 October 2016, 10:38:04
@Tactile, yes, understood. So I have to put up a macro in TMK for "Ctrl-v" and "Ctrl-c".

I think that's the only way to do it.... but I've been wrong before  :D
Title: Re: TMK keyboard firmware
Post by: hasu on Sat, 08 October 2016, 14:02:48
The keycodes KC_COPY and KC_PASTE doesn't seem to work for me, anyone got an idea what might be the issue?

I'm reading tmk_keyboard/tmk_core/common/keycode.h and KC_COPY is, I think, 0x7C. In this chart, Microsoft seem to say that code is for F13. It looks like Windows won't interpret those codes the way you want.

[EDIT]

I'm sitting here looking at that page in one of the tabs but when I copy/paste the address it botches. I hope you can make it work.

https://msdn.microsoft.com/en-us/library/windows/desktop/dd375731

https://msdn.microsoft.com/en-us/library/windows/desktop/dd375731%28v=vs.85%29.aspx

It is not codes keyboard sends to host, you can refer to these.
http://www.usb.org/developers/hidpage/Hut1_12v2.pdf
http://download.microsoft.com/download/1/6/1/161ba512-40e2-4cc9-843a-923143f3456c/scancode.doc
Title: Re: TMK keyboard firmware
Post by: hasu on Sat, 08 October 2016, 14:04:11
Hi Tactile. Yes, I can follow your argument. Do you think it is a shortcoming in TMK?

No, it is your OS's probably. Try Solaris or kindof Unix it will recognize the keys.
Title: Re: TMK keyboard firmware
Post by: Eszett on Sat, 08 October 2016, 15:23:12
Alright hasu. I solved this now without a clumsy macro. I added to the keymap (keymap.c) "LCTL(KC_V)" for pasting. I'm not sure if this is a QMK-only feature, or also works in TMK. But it's the most convenient way and executes quickly without delay. :thumb:
Title: Re: TMK keyboard firmware
Post by: hasu on Sat, 08 October 2016, 16:33:31
Alright hasu. I solved this now without a clumsy macro. I added to the keymap (keymap.c) "LCTL(KC_V)" for pasting. I'm not sure if this is a QMK-only feature, or also works in TMK. But it's the most convenient way and executes quickly without delay. :thumb:

I'm not sure if you already know that QMK has great community on github or reddit. You can ask your question there because you are using QMK.
Title: Re: TMK keyboard firmware
Post by: Eszett on Sat, 08 October 2016, 17:07:02
Ok, sorry, I wrote in the wrong thread then.
Title: Re: TMK keyboard firmware
Post by: ctm on Tue, 18 October 2016, 19:29:39
A noob question. What's the difference between "infinity" and "infinity_chibios"?

Also, when I compile infinity, it shows the following error:
../../tmk_core/common/mbed/xprintf.cpp:1:19: fatal error: cstdarg: No such file or directory
Am I missing some dependency here?

Thanks!
Title: Re: TMK keyboard firmware
Post by: hasu on Tue, 18 October 2016, 19:39:05
hmm it smells like a toolchain problem.

You can use this method to build if you are not on Linux.
https://github.com/tmk/tmk_keyboard/wiki/Build-firmware-on-VirtualBox
Title: Re: TMK keyboard firmware
Post by: ctm on Tue, 18 October 2016, 20:11:00
hmm it smells like a toolchain problem.

You can use this method to build if you are not on Linux.
https://github.com/tmk/tmk_keyboard/wiki/Build-firmware-on-VirtualBox
Thanks for the reply. I am on Linux though. Running Ubuntu 14.04 and my Alps64 compiles without a problem.

By the way, what's the difference between "infinity" and "infinity_chibios"?
Title: Re: TMK keyboard firmware
Post by: hasu on Tue, 18 October 2016, 20:19:34
Difference is mbed.org based vs chibios based.
Title: Re: TMK keyboard firmware
Post by: hasu on Tue, 18 October 2016, 20:38:01
hmm it smells like a toolchain problem.

You can use this method to build if you are not on Linux.
https://github.com/tmk/tmk_keyboard/wiki/Build-firmware-on-VirtualBox
Thanks for the reply. I am on Linux though. Running Ubuntu 14.04 and my Alps64 compiles without a problem.

See these. Probably you will have to install specific version from PPA on 14.04. Or update your ubuntu to 16.04 it seems to work without problem.
https://github.com/tmk/tmk_keyboard/issues/212#issuecomment-100422816
https://github.com/tmk/tmk_keyboard/wiki/mbed-cortex-porting

Title: Re: TMK keyboard firmware
Post by: ctm on Tue, 18 October 2016, 21:20:28
A noob question. What's the difference between "infinity" and "infinity_chibios"?

Also, when I compile infinity, it shows the following error:
../../tmk_core/common/mbed/xprintf.cpp:1:19: fatal error: cstdarg: No such file or directory
Am I missing some dependency here?

Thanks!
I find out the problem. It turns out arm-none-eabi-gcc that I got from Ubuntu PPA was 4.8. I added team-gcc-arm-embedded/ppa and installed 5.4.1 and now it works!
Title: Re: TMK keyboard firmware
Post by: ctm on Tue, 18 October 2016, 21:41:16
Hmm... now my Infinity firmware compiles, but when I flash it (sudo make program), the keyboard behaves very strangely. The debug LED keeps flashing. When pressing a key, sometimes it does nothing, sometimes it splits out a random key. Any suggestions?
Title: Re: TMK keyboard firmware
Post by: hasu on Wed, 19 October 2016, 03:05:10
As far as i know Infinity has tree diffrent versions; prototype, without led and with led.
If you have prototype define INFINITY_PROTOTYPE in config.h, INFINITY_LED for 'with led'.
Title: Re: TMK keyboard firmware
Post by: ctm on Wed, 19 October 2016, 07:28:33
As far as i know Infinity has tree diffrent versions; prototype, without led and with led.
If you have prototype define INFINITY_PROTOTYPE in config.h, INFINITY_LED for 'with led'.
Thanks a lot! That's exactly what I was missing.
Title: Re: TMK keyboard firmware
Post by: kalmlikabohm on Fri, 21 October 2016, 11:47:53
Hasu, thank you again for TMK firmware. I hope this is the right "spot" for this question. If not, please let me know and I'll post again in a diff part of the forum.

So, this is my first build, and I wanted to try a simple hand wire. "Simple".

In the pic below, I have the "Core". buttons working on the numpad. The upper right grid. All of the red wires.

However, I CANNOT figure out how to configure(or did I wire it wrong?) the "L" shaped 5 keys on the left and bottom. Green/Black

I have posted all the code I am using and none of the keys on the leftmost column or bottom most row work.

Is this wired right?
Am I using the config code properly? All of the NUMBERS and Function keys work, just not any Letters.

[attach=1]
[attach=2]



Title: Re: TMK keyboard firmware
Post by: ctm on Sat, 22 October 2016, 11:18:04
Does infinity_chibios currently support Infinity 1.1 (with LEDs)?
Title: Re: TMK keyboard firmware
Post by: hasu on Sat, 22 October 2016, 20:57:41
Does infinity_chibios currently support Infinity 1.1 (with LEDs)?

no.
Title: Re: TMK keyboard firmware
Post by: Lude on Thu, 27 October 2016, 09:07:55
Hi,

I use tmk converter on an italian IBM Terminal 122 keys keyboard with a pro micro clone.
I would to know if there's a keycode to leave default key value, something like "KC_DEFAULT"
I'm asking 'cause I haved a little problem with KC_BSLASH and KC_NONUS_BSLASH. They print "ù" instead of "\"
I've used KC_GRAVE and I fixed it!

I've problem with bootloader mode using 0x7777 stuff
I know that something happens 'cause I hear usb disconnected device under win 7, but serial port is not recognized.
I use bootloader burned from arduino ide.
Any hint?

Thank you,
Lude
Title: Re: TMK keyboard firmware
Post by: hasu on Thu, 27 October 2016, 11:02:04
Hi,

I use tmk converter on an italian IBM Terminal 122 keys keyboard with a pro micro clone.
I would to know if there's a keycode to leave default key value, something like "KC_DEFAULT"
I'm asking 'cause I haved a little problem with KC_BSLASH and KC_NONUS_BSLASH. They print "ù" instead of "\"
I've used KC_GRAVE and I fixed it!

I've problem with bootloader mode using 0x7777 stuff
I know that something happens 'cause I hear usb disconnected device under win 7, but serial port is not recognized.
I use bootloader burned from arduino ide.
Any hint?

Thank you,
Lude

what's your os and layout?

EDIT: And are you talking about key between left shift and z?
Title: Re: TMK keyboard firmware
Post by: Lude on Thu, 27 October 2016, 13:18:29
what's your os and layout?

EDIT: And are you talking about key between left shift and z?

Hi,

I've Win7 sp1 64bit and I use a standard italian layout.
I'm talking about key before 1, just below escape key in my standard keyboard.
If you refer to tmk layout I use modified default on terminal_usb:

    KEYMAP(
                     F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12,
                MYCM, WHOM, WBAK, WFWD, F17, F18, F19, F20, FN4, PAUSE, SCROLLLOCK, PSCR,

    ESC,LGUI,   GRAVE, 1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   MINS,EQL, NO,  BSPC,  INS, HOME,PGUP,  CALC,NLCK,PSLS,PAST,
    MPLY,MUTE,  TAB, Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,   LBRC,RBRC,     NO,    DEL, END, PGDN,  P7,  P8,  P9,  PMNS,
    VOLU,VOLD,  CAPS,A,   S,   D,   F,   G,   H,   J,   K,   L,   SCLN,QUOT,     BSLS,ENT,        UP,         P4,  P5,  P6,  PPLS,
    FN2,FN3,  LSFT,NONUS_BSLASH,Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, SLSH,     NO,  RSFT,  LEFT,DOWN,RGHT,  P1,  P2,  P3,  PENT,
    FN0,FN1,  LCTL,     LALT,               SPC,                          RALT,     RCTL,        DOWN,       NO,  P0,  PDOT,NO
    ),


EDIT:
maybe I'm a bit confused regarding KC_BSLASH and KC_NONUS_BSLASH.
Probabily KC_BSLASH  gives me an "ù".
KC_NONUS_BSLASH gives me a "<". As you can see I use it on keymap, just before Z key

Title: Re: TMK keyboard firmware
Post by: hasu on Thu, 27 October 2016, 13:45:15
what's your os and layout?

EDIT: And are you talking about key between left shift and z?

Hi,

I've Win7 sp1 64bit and I use a standard italian layout.
I'm talking about key before 1, just below escape key in my standard keyboard.
If you refer to tmk layout I use modified default on terminal_usb:

    KEYMAP(
                     F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12,
                MYCM, WHOM, WBAK, WFWD, F17, F18, F19, F20, FN4, PAUSE, SCROLLLOCK, PSCR,

    ESC,LGUI,   GRAVE, 1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   MINS,EQL, NO,  BSPC,  INS, HOME,PGUP,  CALC,NLCK,PSLS,PAST,
    MPLY,MUTE,  TAB, Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,   LBRC,RBRC,     NO,    DEL, END, PGDN,  P7,  P8,  P9,  PMNS,
    VOLU,VOLD,  CAPS,A,   S,   D,   F,   G,   H,   J,   K,   L,   SCLN,QUOT,     BSLS,ENT,        UP,         P4,  P5,  P6,  PPLS,
    FN2,FN3,  LSFT,NONUS_BSLASH,Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, SLSH,     NO,  RSFT,  LEFT,DOWN,RGHT,  P1,  P2,  P3,  PENT,
    FN0,FN1,  LCTL,     LALT,               SPC,                          RALT,     RCTL,        DOWN,       NO,  P0,  PDOT,NO
    ),




Ah, OK. It is just common woe of non-US layout(qwerty) users, computer is completely US centric, not Italy nor Japan unfortunately :D
USB spec uses key naming of US layout, so you have to think in that way even if your keyboard is italian. For example, in France they send keycode of 'q' to computer to get 'a' with their azerty keyboard, I guess.
Title: Tiny TMK
Post by: a-c on Wed, 02 November 2016, 14:51:24
My tiniest keyboard running TMK

[attach=1]

[attach=2]
http://www.40percent.club/2016/11/micro-tmk.html (http://www.40percent.club/2016/11/micro-tmk.html)
Title: Re: TMK keyboard firmware
Post by: hasu on Wed, 02 November 2016, 23:52:27
looks nice :thumb:
Title: Re: TMK keyboard firmware
Post by: ac2ev on Sun, 13 November 2016, 16:01:21
I'm starting to program TMK for my keyboard. I've got the matrix all mapped out and I'm now modifying the keymap and I have a "issue". The keyboard I'm using is non-standard in the fact that the typical key pairs such at '7&' ':;' aren't all the same.

1st key is normal, 2nd key is with Shift Modifier
2  "
6 &
7 '
8 (
9 )
- =
~ ^
` @
The list goes on. How do I program these? Do I program the first layer as normal the correct option and then rather then TRNS for the second layer I subsitute the actual key?

layer 0
1 2 3 4 5 6 7

layer 1
TRNS " TRNS TRNS TRNS & '

Lastly, how do I program a mechanical latching Shift Lock? My keyboard has both a latching and non-latching shift key.

It also has a latching RPT key which I'm thinking I could use for something else just not sure what.

Pictures over in this post:
https://geekhack.org/index.php?topic=85666.0


Title: Re: TMK keyboard firmware
Post by: hasu on Sun, 13 November 2016, 20:16:34
Read and find proper action for your need in this doc or code. If you can't find you will have to write code for your own action.
https://github.com/tmk/tmk_core/blob/master/doc/keymap.md
https://github.com/tmk/tmk_keyboard/blob/master/tmk_core/common/action_code.h

EDIT: Defining Shift layer in keybard firmware is generally difficult or not good idea at least, in some situation you will have subtle problem. Instead, changing keyboard layout on your computer is good and legitimate idea.

If you want to use the "Shift Lock" key as shift lock assign normal shift keycode, or  see this if locking capslock is what you want.
https://github.com/tmk/tmk_keyboard/wiki/FAQ-Keymap#mechanical-lock-switch-support
Title: Re: TMK keyboard firmware
Post by: ac2ev on Mon, 14 November 2016, 06:45:14
Those are those I was reading. Looks like I might be digging into the code or using something like SharpKeys to re-assign keys. Since I'm a touch typist I may just choose to ignore the legends and program it as a normal layout.

Thank you.
Title: Re: TMK keyboard firmware
Post by: kalmlikabohm on Fri, 18 November 2016, 12:03:31
Yet again i have to request your help. Ive soldered in my diodes the wrong way. Now ive read that it is possible to reverse them in software but how? Can anybody tell me?

Look at the matrix.c from the phantom keyboard for an example of wiring with the diodes in the opposite direction to the GH60. https://github.com/tmk/tmk_keyboard/blob/master/keyboard/phantom/matrix.c
So i would need to switch all rows for cols and do the same in the matrix? If so id rather desolder the switches and turn the diode

What happened to this file?
I _might_ have done something similar and am still debugging. Having the option to reverse the scan/diodes in code would be a HUGE help.

Title: Re: TMK keyboard firmware
Post by: a-c on Fri, 18 November 2016, 13:00:18
Yet again i have to request your help. Ive soldered in my diodes the wrong way. Now ive read that it is possible to reverse them in software but how? Can anybody tell me?

Look at the matrix.c from the phantom keyboard for an example of wiring with the diodes in the opposite direction to the GH60. https://github.com/tmk/tmk_keyboard/blob/master/keyboard/phantom/matrix.c
So i would need to switch all rows for cols and do the same in the matrix? If so id rather desolder the switches and turn the diode

What happened to this file?
I _might_ have done something similar and am still debugging. Having the option to reverse the scan/diodes in code would be a HUGE help.

Hasu did some housekeeping, they are now in the orphan folder. https://github.com/tmk/tmk_keyboard/tree/master/orphan/phantom (https://github.com/tmk/tmk_keyboard/tree/master/orphan/phantom)
Title: Re: TMK keyboard firmware
Post by: kalmlikabohm on Fri, 18 November 2016, 13:03:21
Yet again i have to request your help. Ive soldered in my diodes the wrong way. Now ive read that it is possible to reverse them in software but how? Can anybody tell me?

Look at the matrix.c from the phantom keyboard for an example of wiring with the diodes in the opposite direction to the GH60. https://github.com/tmk/tmk_keyboard/blob/master/keyboard/phantom/matrix.c
So i would need to switch all rows for cols and do the same in the matrix? If so id rather desolder the switches and turn the diode

What happened to this file?
I _might_ have done something similar and am still debugging. Having the option to reverse the scan/diodes in code would be a HUGE help.

Hasu did some housekeeping, they are now in the orphan folder. https://github.com/tmk/tmk_keyboard/tree/master/orphan/phantom (https://github.com/tmk/tmk_keyboard/tree/master/orphan/phantom)

Awesome!

So "reversing" the direction really isn't a programming field of variable, but just redefining the whole matrix? Is this correct? I have a 5 x 7 keyboard, but the diodes run vertically.

Much like Transposing a Matrix? https://en.wikipedia.org/wiki/Transpose
Title: Re: TMK keyboard firmware
Post by: a-c on Fri, 18 November 2016, 13:23:46
Yet again i have to request your help. Ive soldered in my diodes the wrong way. Now ive read that it is possible to reverse them in software but how? Can anybody tell me?

Look at the matrix.c from the phantom keyboard for an example of wiring with the diodes in the opposite direction to the GH60. https://github.com/tmk/tmk_keyboard/blob/master/keyboard/phantom/matrix.c
So i would need to switch all rows for cols and do the same in the matrix? If so id rather desolder the switches and turn the diode

What happened to this file?
I _might_ have done something similar and am still debugging. Having the option to reverse the scan/diodes in code would be a HUGE help.

Hasu did some housekeeping, they are now in the orphan folder. https://github.com/tmk/tmk_keyboard/tree/master/orphan/phantom (https://github.com/tmk/tmk_keyboard/tree/master/orphan/phantom)

Awesome!

So "reversing" the direction really isn't a programming field of variable, but just redlining the whole matrix? Is this correct? I have a 5 x 7 keyboard, but the diodes run vertically.

Yes, you are either strobing the rows and reading the columns or strobing the columns and reading the rows. The Phantom strobes the columns and reads the rows. You will have to post a picture of your wiring, you can do it either way with the diodes connected in rows or columns.
Title: Re: TMK keyboard firmware
Post by: kalmlikabohm on Fri, 18 November 2016, 13:32:47
Yet again i have to request your help. Ive soldered in my diodes the wrong way. Now ive read that it is possible to reverse them in software but how? Can anybody tell me?

Look at the matrix.c from the phantom keyboard for an example of wiring with the diodes in the opposite direction to the GH60. https://github.com/tmk/tmk_keyboard/blob/master/keyboard/phantom/matrix.c
So i would need to switch all rows for cols and do the same in the matrix? If so id rather desolder the switches and turn the diode

What happened to this file?
I _might_ have done something similar and am still debugging. Having the option to reverse the scan/diodes in code would be a HUGE help.

Hasu did some housekeeping, they are now in the orphan folder. https://github.com/tmk/tmk_keyboard/tree/master/orphan/phantom (https://github.com/tmk/tmk_keyboard/tree/master/orphan/phantom)

Awesome!

So "reversing" the direction really isn't a programming field of variable, but just redlining the whole matrix? Is this correct? I have a 5 x 7 keyboard, but the diodes run vertically.

Yes, you are either strobing the rows and reading the columns or strobing the columns and reading the rows. The Phantom strobes the columns and reads the rows. You will have to post a picture of your wiring, you can do it either way with the diodes connected in rows or columns.

Awesome! Ok, I will try to transpose the code then. I have done a hand wire with a numpad tester and it went OK. This is proving a little more difficult.

Do the pin connections have to be contiguous? I skipped many pins because I have yet to add the other half of the Dactyl. I am forgoing the Multiplex chip and just going to have 12 wires bridging from the left to the right.

Thanks for the help A-C.
Title: Re: TMK keyboard firmware
Post by: a-c on Fri, 18 November 2016, 13:41:44
Awesome! Ok, I will try to transpose the code then. I have done a hand wire with a numpad tester and it went OK. This is proving a little more difficult.

Do the pin connections have to be contiguous? I skipped many pins because I have yet to add the other half of the Dactyl. I am forgoing the Multiplex chip and just going to have 12 wires bridging from the left to the right.

Thanks for the help A-C.

Your matrix is wired like the Phantom. What order you use the pins does not matter. On Teensy 2.0 all the pins can do the digital i/o needed for a scanning matrix.
Title: Re: TMK keyboard firmware
Post by: kalmlikabohm on Fri, 18 November 2016, 13:46:06
Awesome! Ok, I will try to transpose the code then. I have done a hand wire with a numpad tester and it went OK. This is proving a little more difficult.

Do the pin connections have to be contiguous? I skipped many pins because I have yet to add the other half of the Dactyl. I am forgoing the Multiplex chip and just going to have 12 wires bridging from the left to the right.

Thanks for the help A-C.

Your matrix is wired like the Phantom. What order you use the pins does not matter. On Teensy 2.0 all the pins can do the digital i/o needed for a scanning matrix.
Hrmm ok. So I am confused why I get NOTHING when I plug it in an load up the firmware. It acts as if the keyboard is not even connected.

Should I un-comment "MATRIX_HAS_GHOST" in Config.h?

I really don't care if I have to define my keymap a bit odd to get this working.

PS: I loaded up the BLINKY test for Teensy 2.0 and it works OK, so the chip seems to be working just fine.

Code: [Select]
// Column 0 is Right Most Column on RIGHT Dactly
// Row 0 is BOTTOM most Row on RIGHT Dactyl

// LEFT... N ... N-1....  .... 1  ... 0 ... RIGHT
// COL:  0  1  2  3  4  5  6
// PIN: F0 F1 F4 F5 F6 F7 B6

// ROW:  0  1  2  3  4
// PIN: D1 D0 B7 B3 B2
Title: Re: TMK keyboard firmware
Post by: jigg4 on Wed, 23 November 2016, 00:07:43
I finally managed to flash my GH60 rev C (my first custom built). I had some troubles with my iso keymap at first, because I only had 63 keys declared. Took me a while to realize what's wrong and that the default keymap has 65 keys and especially 5 keys on the right modifiers side.

Now the only thing missing is the key near the left shift  "<>". What do I have to put in my keymap to receive this key. It is currently mapped as backslash and I get a "#" when I press it. The language of my PC is German.

Title: Re: TMK keyboard firmware
Post by: wooger on Wed, 23 November 2016, 10:59:00
I got my USB-USB converter from hasu a couple of weeks ago, and it's already working pretty great with a modified Space-Fn layout. So far I just modified a Space-Fn preset someone linked to on the online keymap builder and used dfu-programmer to flash it.

At the moment I'm still using Autohotkey to map a few shortcuts, but hope to incorporate these into the TMK firmware with some work.
Ctrl-Q => Alt-F4 (close window)
Ctrl-Space => Windows Key
Ctrl-Tab => Alt-Tab

Noob questions:
#1 - Is it possible to map these key shortcuts in TMK firmware?

#2 - How would I go about doing this? I understand I need to modify a bit of C code grabbed from github, but it's not clear which files I change. Is there a tutorial or some example of similar shortcuts which I can copy?

#3 - One possible problem with my current setup: I'm pretty sure the Ctrl key has been sticking on a few occasions for me when using the converter. This has happened with different keyboards, so it's not the hardware, and has been fixed by tapping Ctrl a few times. Anything to check?

It's probably a bug with the keymap I'm running, but as all I've done is swap a few layer-0 keys around, not sure why.
Title: Re: TMK keyboard firmware
Post by: alh84001 on Thu, 24 November 2016, 07:15:48
Hasu, could TMK be used to convert the Displaywriter keyboard protocol? Here's a relevant page from Displaywriter manual (http://bitsavers.trailing-edge.com/pdf/ibm/6580_Displaywriter/S241-6248-3_Displaywriter_Product_Support_Manual_Feb83.pdf):
More
(http://i.imgur.com/3uWpxGp.png)

Relevant pinouts are shown further down in the manual.

I don't know if frequency of data clock should be determined from the actual Displaywriter system, but other than that it seems pretty straightforward.
Title: Re: TMK keyboard firmware
Post by: kalmlikabohm on Thu, 24 November 2016, 09:01:18
I got my USB-USB converter from hasu a couple of weeks ago, and it's already working pretty great with a modified Space-Fn layout. So far I just modified a Space-Fn preset someone linked to on the online keymap builder and used dfu-programmer to flash it.

At the moment I'm still using Autohotkey to map a few shortcuts, but hope to incorporate these into the TMK firmware with some work.
Ctrl-Q => Alt-F4 (close window)
Ctrl-Space => Windows Key
Ctrl-Tab => Alt-Tab

Noob questions:
#1 - Is it possible to map these key shortcuts in TMK firmware?

#2 - How would I go about doing this? I understand I need to modify a bit of C code grabbed from github, but it's not clear which files I change. Is there a tutorial or some example of similar shortcuts which I can copy?

#3 - One possible problem with my current setup: I'm pretty sure the Ctrl key has been sticking on a few occasions for me when using the converter. This has happened with different keyboards, so it's not the hardware, and has been fixed by tapping Ctrl a few times. Anything to check?

It's probably a bug with the keymap I'm running, but as all I've done is swap a few layer-0 keys around, not sure why.

If the TMK converter is anything like the normal TMK, yes.

1. You will probably need a Macro.
2. See an attempt below. Hopefully this will get you started.

File: Keymap_Poker.c (Or whatever keymap file you want)
The following marcos will produce some gibberish, but at least you know its working!
Code: [Select]

/ enum macro_id {
//    YATTA1,
//    YATTA2,
//    YATTA3,
//    YATTA4,
//   };


onst action_t PROGMEM fn_actions[] = {
    /* Poker Layout */
    // [1] = ACTION_MACRO(YATTA1),  // to Fn overlay
    // [2] = ACTION_MACRO(YATTA2),  // to Fn overlay
.....

// const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
// {
  //  switch (id) {
  //  case YATTA1:
  //     return (record->event.pressed ?
  //             MACRO( T(SLSH), D(LSHIFT), T(9), U(LSHIFT), T(V), END ) :
  //             MACRO_NONE );
  // case YATTA2:
  //     return (record->event.pressed ?
  //             MACRO( T(SLSH), D(LSHIFT), T(9), U(LSHIFT), T(V), END ) :
  //             MACRO_NONE );

.....
Title: Re: TMK keyboard firmware
Post by: hasu on Thu, 24 November 2016, 12:25:17
Hasu, could TMK be used to convert the Displaywriter keyboard protocol? Here's a relevant page from Displaywriter manual (http://bitsavers.trailing-edge.com/pdf/ibm/6580_Displaywriter/S241-6248-3_Displaywriter_Product_Support_Manual_Feb83.pdf):
More
Show Image
(http://i.imgur.com/3uWpxGp.png)

Relevant pinouts are shown further down in the manual.

I don't know if frequency of data clock should be determined from the actual Displaywriter system, but other than that it seems pretty straightforward.

I think so. Nice find, bitsavers is always great resources for old computing.
It doesn't seem to have break codes on most of keys unfortunately, it may be problem when used on modern computers.
Title: Re: TMK keyboard firmware
Post by: hasu on Thu, 24 November 2016, 12:34:19
I got my USB-USB converter from hasu a couple of weeks ago, and it's already working pretty great with a modified Space-Fn layout. So far I just modified a Space-Fn preset someone linked to on the online keymap builder and used dfu-programmer to flash it.

At the moment I'm still using Autohotkey to map a few shortcuts, but hope to incorporate these into the TMK firmware with some work.
Ctrl-Q => Alt-F4 (close window)
Ctrl-Space => Windows Key
Ctrl-Tab => Alt-Tab

Noob questions:
#1 - Is it possible to map these key shortcuts in TMK firmware?

#2 - How would I go about doing this? I understand I need to modify a bit of C code grabbed from github, but it's not clear which files I change. Is there a tutorial or some example of similar shortcuts which I can copy?

#3 - One possible problem with my current setup: I'm pretty sure the Ctrl key has been sticking on a few occasions for me when using the converter. This has happened with different keyboards, so it's not the hardware, and has been fixed by tapping Ctrl a few times. Anything to check?

It's probably a bug with the keymap I'm running, but as all I've done is swap a few layer-0 keys around, not sure why.

It is kindof possible but not simple. You'll need to use ACTION_LAYER_MODS(1, MOD_LCTL) on the control key for example, to define the  'shortcuts' on Layer 2.
https://github.com/tmk/tmk_core/blob/master/doc/keymap.md#35-momentary-switching-with-modifiers

The shortcuts need to be defined as MACRO or FUNCTION. Documentation is sparse, find and check keymap files in github as sample.
https://github.com/tmk/tmk_core/blob/master/doc/keymap.md#23-macro-action
https://github.com/tmk/tmk_core/blob/master/doc/keymap.md#24-function-action

As for Ctrl stuck see this entry.
https://github.com/tmk/tmk_keyboard/wiki/FAQ-Keymap#modifierlayer-stuck
Title: Re: TMK keyboard firmware
Post by: alh84001 on Thu, 24 November 2016, 15:13:10
I think so. Nice find, bitsavers is always great resources for old computing.
It doesn't seem to have break codes on most of keys unfortunately, it may be problem when used on modern computers.

Is there any other board/protocol that doesn't have break codes but has been converted? Any info on general approach on how to handle such situations?

But anyways, manual says the following:
Quote
The data is converted to an eight bit data byte by the keyboard adapter in the system electronics. The data byte contains a seven bit code indicating the key position. The eighth bit in the data byte indicates a key depression and key release for make/break keys or repeat mode for typamatic keys.

If I'm understanding it correctly, if a bit is set (or alternatively, not set) it will be a break code. Or did I completely misunderstand this?
Title: Re: TMK keyboard firmware
Post by: hasu on Thu, 24 November 2016, 16:28:50
You could relay make and pseudo break code to PC at same time when receiving from keyboard.

See 5-9 some modifiers only send break code, I guess.

http://bitsavers.trailing-edge.com/pdf/ibm/6580_Displaywriter/S241-6248-3_Displaywriter_Product_Support_Manual_Feb83.pdf



Sent from my Nexus 5X

Title: Re: TMK keyboard firmware
Post by: alh84001 on Fri, 25 November 2016, 06:33:34
Ah, I see. I wrongly assumed that at least alphas were make/break keys as well. Thanks!
Title: Re: TMK keyboard firmware
Post by: kalmlikabohm on Fri, 25 November 2016, 17:32:33
Hookay. So I've tried getting TMK working on this Dactyl. It seems I can get only ONE "Row" working at a time. Either F0 or F1.
I have switched F1 and F0 in the code and get the whole row working at once. I've tested all the switches and wiring, and it seems OK. Using an Ohm meter.

I'm kinda at a loss of getting more than 1 row working at a time.

Is there anything obvious I am messing up?

Any help would be appreciated.

Title: Re: TMK keyboard firmware
Post by: hasu on Fri, 25 November 2016, 21:47:33
Nice screenshot. What's your editor?
And what's dactyl? Open design keyboard or something?

I can't find anything in the pics unfortunately. Btw, Your Teensy is genuine?



Sent from my Nexus 5X

Title: Re: TMK keyboard firmware
Post by: hasu on Fri, 25 November 2016, 21:48:54
Nice screenshot. What's your editor?
And what's dactyl? Open design keyboard or something?

I can't find anything wrong in the pics unfortunately. Btw, Your Teensy is genuine?



Sent from my Nexus 5X



Title: Re: TMK keyboard firmware
Post by: kalmlikabohm on Fri, 25 November 2016, 23:39:30
Nice screenshot. What's your editor?
And what's dactyl? Open design keyboard or something?

I can't find anything in the pics unfortunately. Btw, Your Teensy is genuine?



Sent from my Nexus 5X
Thanks! I take pride in my Screenshots.
Yes. It is genuine. I bought directly from PJRC.

The Dactyl is opensourced keyboard. https://github.com/adereth/dactyl-keyboard

Dammit ok. I'll look closer at it then. Thanks for looking, this error is escaping me!

GUI is Atom.io the github people. With uh... Operator Mono as a font... Monospaced cursive for comments is so nice to look at.

Sent from my SAMSUNG-SM-G850A using Tapatalk

Title: Re: TMK keyboard firmware
Post by: hasu on Sat, 26 November 2016, 16:46:43
Thanks for the info, it is fun to see feature list of modern editor!

hmm, if you use other pin than F0, F1 for the row what's happen?
And make sure F0 and F1 are not used somewhere esle.
Title: Re: TMK keyboard firmware
Post by: kalmlikabohm on Sat, 26 November 2016, 21:07:25
Thanks for the info, it is fun to see feature list of modern editor!

hmm, if you use other pin than F0, F1 for the row what's happen?
And make sure F0 and F1 are not used somewhere esle.

When using JUST F4, I can get the F4 row just working fine with "ABCDE" etc.

However, as soon as more than 1 row is connected, only the "lower" F row will be active.
Example: F3 works when both F3 and F4 are connected, but F4 row will NOT work.

When I say "connected" I really mean defined properly in the TMK. They are always soldered in.

F0 will work when both F0 and F3 are connected but then row F3 will NOT work - I REALLY thought the wiring looked OK.
All of the rows work individually, just not more than 1 at a time.

Title: Re: TMK keyboard firmware
Post by: hasu on Sat, 26 November 2016, 22:33:24
Smells to me like your wiring has something wrong, if you cannot find any culprit I'd recommend to solder them all again from scratch.

EDIT: Or you can try other firmware like Easy AVR if you believe your hardware is fine.
Title: Re: TMK keyboard firmware
Post by: FSund on Mon, 28 November 2016, 02:27:23
This has probably been answered before, but I couldn't seem to find anything when searching.

I have an ISO 60% GH60 "Satan" keyboard, with TMK firmware. Everything is working as expected, except the "<>" key (right if the small left shift, only on ISO boards), which is putting out "'" (apostrophe) and "*" instead of greater than and smaller than.

What legends should I put on the keys in keyboard-layout-editor to get the correct output?

Edit: I fixed it by setting the key to a function key, and manually setting that to "Non-US \ and |":

(http://i.imgur.com/UePgVKq.png)
Title: Re: TMK keyboard firmware
Post by: ac2ev on Sat, 03 December 2016, 19:28:36
Those are those I was reading. Looks like I might be digging into the code or using something like SharpKeys to re-assign keys. Since I'm a touch typist I may just choose to ignore the legends and program it as a normal layout.

Thank you.

I apologize I'm not quite understanding. Without of the use of secondary "helper" key is there a way in tmk to have a key whose normal operation is

; and 'shifted' operation is +
: and when shift is pressed *

Please reference the keys next to the L key on the attached picture and you'll see they don't match regular keyboards.

For the record I have all the normal keys working with tmk (verified using AquaKeyTest) and these oddball keys are the only ones I need to program.

Title: Re: TMK keyboard firmware
Post by: hasu on Sat, 03 December 2016, 19:44:07
Those are those I was reading. Looks like I might be digging into the code or using something like SharpKeys to re-assign keys. Since I'm a touch typist I may just choose to ignore the legends and program it as a normal layout.

Thank you.

I apologize I'm not quite understanding. Without of the use of secondary "helper" key is there a way in tmk to have a key whose normal operation is

; and 'shifted' operation is +
: and when shift is pressed *

Please reference the keys next to the L key on the attached picture and you'll see they don't match regular keyboards.

For the record I have all the normal keys working with tmk (verified using AquaKeyTest) and these oddball keys are the only ones I need to program.



What layout are you using on your computer now? Note that you have to have plain ANSI keymap on firmware.
The key you are refering is very common here :D
https://en.wikipedia.org/wiki/File:KB_Japanese.svg

EDIT: ah, it was not meaningful. I mean, try JIS layout on your OS and uses KC_SCLN for ';' and  KC_QUOT for ':' on firmware keymap. The keys will spit out as the legend says.
Title: Re: TMK keyboard firmware
Post by: ac2ev on Sun, 04 December 2016, 10:17:16
Very interesting. I will take a look at that. Thank you.
Title: Re: TMK keyboard firmware
Post by: nonosway on Mon, 05 December 2016, 15:22:27
hey,
so I decided to make my first foray into mechanical keyboards! I'm trying to make a numpad using this (https://deskthority.net/workshop-f7/how-to-build-your-very-own-keyboard-firmware-t7177.html) as a firmware guide. It's amazing! And as I flew through it I foolishly thought everything would go really well. I'm working in a Ubuntu VM and when I go to compile the code into .hex it says that I have a fatal error. I used "sudo apt-get install gcc g++" to install both toolchains but I keep getting the same errors. that the dfu is unavailable and stdint.h does not exist. any help would be greatly appreciated!
Title: Re: TMK keyboard firmware
Post by: Tactile on Mon, 05 December 2016, 15:27:23
hey,
so I decided to make my first foray into mechanical keyboards! I'm trying to make a numpad using this (https://deskthority.net/workshop-f7/how-to-build-your-very-own-keyboard-firmware-t7177.html) as a firmware guide. It's amazing! And as I flew through it I foolishly thought everything would go really well. I'm working in a Ubuntu VM and when I go to compile the code into .hex it says that I have a fatal error. I used "sudo apt-get install gcc g++" to install both toolchains but I keep getting the same errors. that the dfu is unavailable and stdint.h does not exist. any help would be greatly appreciated!

Try this:

sudo apt-get install avr-gcc (or maybe gcc-avr)
Title: Re: TMK keyboard firmware
Post by: nonosway on Mon, 05 December 2016, 16:15:43
hey,
so I decided to make my first foray into mechanical keyboards! I'm trying to make a numpad using this (https://deskthority.net/workshop-f7/how-to-build-your-very-own-keyboard-firmware-t7177.html) as a firmware guide. It's amazing! And as I flew through it I foolishly thought everything would go really well. I'm working in a Ubuntu VM and when I go to compile the code into .hex it says that I have a fatal error. I used "sudo apt-get install gcc g++" to install both toolchains but I keep getting the same errors. that the dfu is unavailable and stdint.h does not exist. any help would be greatly appreciated!

Try this:

sudo apt-get install avr-gcc (or maybe gcc-avr)

Hey, it is gcc-avr for the record :) I did that but i'm getting this:
sh: 1: dfu-programmer: not found
sh: 1: dfu-programmer: not found


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




mkdir -p obj_gh60_lufa
Compiling C: keymap_poker.c
avr-gcc -c -mmcu=atmega32u4 -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 -DNKRO_ENABLE -DVERSION=unknown -Os -funsigned-char -funsigned-bitfields -ffunction-sections -fdata-sections -fno-inline-small-functions -fpack-struct -fshort-enums -fno-strict-aliasing -Wall -Wstrict-prototypes -Wa,-adhlns=obj_gh60_lufa/keymap_poker.lst -I. -I../../tmk_core -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_gh60_lufa_keymap_poker.o.d  keymap_poker.c -o obj_gh60_lufa/keymap_poker.o
In file included from keymap_common.h:20:0,
                from keymap_poker.c:2:
/usr/lib/gcc/avr/4.9.2/include/stdint.h:9:26: fatal error: stdint.h: No such file or directory
 # include_next <stdint.h>
                         ^
compilation terminated.
../../tmk_core/rules.mk:557: recipe for target 'obj_gh60_lufa/keymap_poker.o' failed
make: *** [obj_gh60_lufa/keymap_poker.o] Error 1



I'm begining to think it may be a problem with my makefile but i honestly have no idea what i'm doing here hahaha
Title: Re: TMK keyboard firmware
Post by: Tactile on Mon, 05 December 2016, 16:18:36
apt-get install dfu-programmer
Title: Re: TMK keyboard firmware
Post by: nonosway on Mon, 05 December 2016, 16:25:24
Reading package lists... Done
Building dependency tree     
Reading state information... Done
E: Unable to locate package dfu
E: Unable to locate package programmer
 
I got this back
Title: Re: TMK keyboard firmware
Post by: a-c on Mon, 05 December 2016, 16:27:11
apt-get install avr-libc
Title: Re: TMK keyboard firmware
Post by: Tactile on Mon, 05 December 2016, 16:28:12
DFU dash PROGRAMMER

sudo apt-get install dfu-programmer
Title: Re: TMK keyboard firmware
Post by: nonosway on Mon, 05 December 2016, 16:44:38
yeah it's installed correctly, but I keep getting the same error.
Title: Re: TMK keyboard firmware
Post by: Tactile on Mon, 05 December 2016, 16:55:07
yeah it's installed correctly, but I keep getting the same error.

It sounds like the hex file was built ok. If you have dfu-programmer installed you can just flash the hex file yourself.  It's been a while since I did that, so I can't walk you through it. Step 1 would to be to find the hex file and copy it somewhere you can find it easily. then you'd type: dfu-programmer [some stuff] your.hex.file   The man page for dfu-programmer will lay it out for you.

No-one will find this in order to help. Start a new thread asking for help with dfu-programmer. You're 99% done, you just need to flash.
Title: Re: TMK keyboard firmware
Post by: nonosway on Mon, 05 December 2016, 17:00:39
That's very encouraging to hear!I will redirect my question thank you!
Title: Re: TMK keyboard firmware
Post by: Tactile on Mon, 05 December 2016, 17:03:50
That's very encouraging to hear!I will redirect my question thank you!

And be sure to read a-c comment above about avr-libc
Title: Re: TMK keyboard firmware
Post by: a-c on Wed, 07 December 2016, 16:07:17
The power of TMK in a tiny board.

http://www.40percent.club/2016/12/nano-tmk.html (http://www.40percent.club/2016/12/nano-tmk.html)
Title: Re: TMK keyboard firmware
Post by: lemur on Thu, 08 December 2016, 23:47:29
As Koren said, you cannot send mousekey with register_code(), but it seems like media key and system key can be sent.
https://github.com/tmk/tmk_keyboard/blob/master/tmk_core/common/action.c#L419-L424

I think you can fix around here to send mouse keys.(or register_code() should be fixed?)
https://github.com/tmk/tmk_keyboard/blob/33714e55827d1cf52df1d3ff143f03fa34ad1f06/tmk_core/common/action_macro.c#L40-L59

And I originaly designed that macro can send keycodes only of 0x04-0x73 to save memory space. So I didn't think about sending mouse and media key events in macro much.
https://github.com/tmk/tmk_keyboard/blob/33714e55827d1cf52df1d3ff143f03fa34ad1f06/tmk_core/common/action_macro.h#L38-L55

This was filed and will be fixed some later(TM).
https://github.com/tmk/tmk_keyboard/issues/289

Between both of your posts, I was able to fix it, I think.  My testing is far from extensive, but wheel up/down and left click work in a couple different macros for me.

In register_code() I added the following to the end:

    else if IS_MOUSEKEY(code) {
        mousekey_on(code);
        mousekey_send();
    }

And similarly I added the following to unregister_code():

    else if IS_MOUSEKEY(code) {
        mousekey_off(code);
        mousekey_send();
    }

Thanks.

I'd like to bring this post back from the dead just for clarifications sake, maybe it will help those looking, as I did, to make a mouse click work in a macro in TMK.

I don't know what problems this may cause elsewhere..... But after searching around I did as said above, and added the lines in tmk_core/common/action.c, as of my typing this, the first part went on line 431, under the section commented as 'Utilities for actions' in 'void register_code...'  ....and the other block went on line 493 at the end of  'void unregister_code...'

I'm guessing this kind of thing isn't a permanent fix, but it got mouse clicking in a macro working for me.

Clicking a mouse button in a macro is big time super important for the work I do requires lots of clicking on forms to paste stuff in certain places and clicking on words/things of text to copy stuff..  and it seems like this little thing does the trick.... while saving me from doing endless clicks (one button press can now do 3 clicks and ctrl+v!)

below is what the area of the code should look like if your stumbling around, like i was after reading the quoted post, trying to find where to paste the darned stuff.

in my keymap file you just assign the mouse button press in the macro just like you do any other key... in this case I use  T(BTN2)

[attachimg=1]
Title: Re: TMK keyboard firmware
Post by: fiete on Fri, 09 December 2016, 04:18:44
Hi I'm new to selfmade keyboards and their firmware.

Thanks for your great work with tmk.

Just trying to make my own layout based on a german keyboard but there is one key I don't find in the keymap documentation.

So what I want to know is whether there is a way to get the keycode number you referencing in keycode.h
I tried the tool xev under linux but the keycode numbers I'm getting there don't seem to match yours.

Key I'm looking for is on the bottom left of the keyboard and is labeled with the 3 Symbols ><|

Best regards
Fritz
Title: Re: TMK keyboard firmware
Post by: chupanibre on Fri, 09 December 2016, 04:21:53
hi hasu and board,

i recently aquired a cherry mx numpad that i wanted to remap. but it's an usb device, and it seems i need a usb shield for my pro micro clone to make it work. is that true? so far i've only encountered ps2-keyboards that were worth converting, i assumed it would work the same with usb. do i really need to order another piece of circuitry or is there a way around (like one of these green usb to ps2 converters)?

thanks (and sorry if that was a stupid question..)

some pics of the numpad itt: https://www.reddit.com/r/MechanicalKeyboards/comments/4ozx84/review_additional_notes_about_the_20_jelly_comb/ (https://www.reddit.com/r/MechanicalKeyboards/comments/4ozx84/review_additional_notes_about_the_20_jelly_comb/)
and the adapter i mean: https://commons.wikimedia.org/wiki/File:USB_to_PS2_mouse_adapter.jpg (https://commons.wikimedia.org/wiki/File:USB_to_PS2_mouse_adapter.jpg)
Title: Re: TMK keyboard firmware
Post by: hasu on Fri, 09 December 2016, 06:13:59
Hi I'm new to selfmade keyboards and their firmware.

Thanks for your great work with tmk.

Just trying to make my own layout based on a german keyboard but there is one key I don't find in the keymap documentation.

So what I want to know is whether there is a way to get the keycode number you referencing in keycode.h
I tried the tool xev under linux but the keycode numbers I'm getting there don't seem to match yours.

Key I'm looking for is on the bottom left of the keyboard and is labeled with the 3 Symbols ><|

Best regards
Fritz
Use showkeys to show raw scan code, xev displays codes defined in xorg.
And you can refer HID usage table to know USB keyboard codes.

Tapatalk を使用して私の Nexus 5 から送信

Title: Re: TMK keyboard firmware
Post by: FSund on Fri, 09 December 2016, 07:16:04
Hi I'm new to selfmade keyboards and their firmware.

Thanks for your great work with tmk.

Just trying to make my own layout based on a german keyboard but there is one key I don't find in the keymap documentation.

So what I want to know is whether there is a way to get the keycode number you referencing in keycode.h
I tried the tool xev under linux but the keycode numbers I'm getting there don't seem to match yours.

Key I'm looking for is on the bottom left of the keyboard and is labeled with the 3 Symbols ><|

Best regards
Fritz
This seems to be the same problem as I had recently (https://geekhack.org/index.php?topic=41989.msg2310224#msg2310224).

My hack-ish fix is below:
Edit: I fixed it by setting the key to a function key, and manually setting that to "Non-US \ and |":

Show Image
(http://i.imgur.com/UePgVKq.png)

There is probably a more proper way to fix this, but this works for now.
Title: Re: TMK keyboard firmware
Post by: hasu on Fri, 09 December 2016, 11:51:10
It seems to be legitimate code for the key. Confirm it by referring HID usage table specification.

Tapatalk を使用して私の Nexus 5 から送信

Title: Re: TMK keyboard firmware
Post by: slowtyping on Sun, 11 December 2016, 07:36:21
I am a new user of the (very useful) TMK/QMK. I am wondering whether the firmware will allow key chords like those enabled by the popular emacs "keychord" mode (https://www.reddit.com/r/emacs/comments/22hzx7/what_are_your_keychord_abbreviations/), which allows you to press two keys almost simultaneously to produce a command.

For example, I have 'kl' bound to save, so if I hit those two keys at the same time, my file is saved without having to use any modifiders like Ctrl and Alt. It doesn't mean that I can't or don't use the modifiders, but it significantly increases my options and reduces finger and wrist strain.

It may be that this functionality already exists in TMK, in which I case I would be grateful if somebody could point me in the right direction - as I said, I'm still new to this!

Thanks,
ST

Title: Re: TMK keyboard firmware
Post by: fiete on Tue, 13 December 2016, 18:21:21
Hi thanks for your help with my first problem.

perhaps you got an idea regarding the second one.

How can I use the altgr key in tmk as modifier since I cant type e.g. brackets without it if the system im trying to type on got german layout configured.

Thanks in advance!
Title: Re: TMK keyboard firmware
Post by: hasu on Tue, 13 December 2016, 18:33:53
Hi thanks for your help with my first problem.

perhaps you got an idea regarding the second one.

How can I use the altgr key in tmk as modifier since I cant type e.g. brackets without it if the system im trying to type on got german layout configured.

Thanks in advance!

Post pic or schematic of your keyboard and show your codes, preferable to use github.
Excess information doesn't harm while scarce of info makes ti difficult to resolve. We have to speculate your keyboard layout,  keymap or etc.

Can I assume you checked the 'HID usage table' already?
Title: Re: TMK keyboard firmware
Post by: fiete on Tue, 13 December 2016, 18:44:12
wow didnt expect such a fast reply.

My goal is to write my layout in tmk that way that a key press sends the codes that a computer with german layout configured interpretes as expected.
So I can just go to some computer plug in my keyboard and start typing.

German layout looks as you can see here (https://upload.wikimedia.org/wikipedia/commons/thumb/3/36/KB_Germany.svg/550px-KB_Germany.svg.png)

So I just want to know how I can write an {

I already tried: ACTION_MODS_KEY(MOD_RALT, KC_7) without success and also cant find AltGr in HID codes pdf file.

Regards
Fritz
Title: Re: TMK keyboard firmware
Post by: hasu on Tue, 13 December 2016, 18:53:47
ACTION_MODS_KEY() can't accept right side modifiers, always sends left modifiers unfortunately. This is undocumented and should be mentioned in tmk_core/doc/keymap.md.

EDIT: not ture. it accept both left and right mods. I don't know why ACTION_MODS_KEY(MOD_RALT, KC_7) doesn't work.

You have to use 'KC_RALT' for altgr instead.
Title: Re: TMK keyboard firmware
Post by: hasu on Tue, 13 December 2016, 19:32:48
ACTION_MODS_KEY() can't accept right side modifiers, always sends left modifiers unfortunately. This is undocumented and should be mentioned in tmk_core/doc/keymap.md.

EDIT: not ture. it accept both left and right mods. I don't know why ACTION_MODS_KEY(MOD_RALT, KC_7) doesn't work.

You have to use 'KC_RALT' for altgr instead.

Confirmed ACTION_MODS_KEY(MOD_RALT, KC_7) works on my keyboard(HHKB), it yields '{' on German layout on Xorg on Ubuntu16.04.
AltGr key on ISO keyboard is equivalent to Right Alt, use just 'KC_RALT' in TMK.
Title: Re: TMK keyboard firmware
Post by: leizzer on Wed, 14 December 2016, 00:22:44
Hello guys,
first of all a big thanks to the people behind this firmware :)

I'm using chibios with my handwired keyboard (teensy 3.2) and I'm trying to add backlight to it. I know that only a few guys are using teensy 3.2 but it will be more than appreciated your help.

I added the backlight.c and backlight.h trying to copy this https://github.com/skullydazed/tmk_keyboard/tree/master/keyboard/cluepad (that somebody answered to a guy that he could follow that as an example).
But, with chibios it seems that I can't use
Code: [Select]
#include <avr/io.h> because I get an error that it is not defined, and when I remove that line I get
Code: [Select]
[...........]
Compiling chprintf.c
Compiling memstreams.c
Compiling nullstreams.c
Compiling usb_main.c
../../tmk_core/protocol/chibios/usb_main.c: In function 'usb_event_cb':
../../tmk_core/protocol/chibios/usb_main.c:787:3: warning: enumeration value 'USB_EVENT_UNCONFIGURED' not handled in switch [-Wswitch]
   switch(event) {
   ^
Compiling main.c
Compiling keymap_plain.c
Compiling matrix.c
Compiling backlight.c
backlight.c: In function 'led_set':
backlight.c:9:22: warning: unused parameter 'usb_led' [-Wunused-parameter]
 void led_set(uint8_t usb_led)
                      ^
backlight.c: In function 'init_backlight_pin':
backlight.c:17:5: error: 'DDRC' undeclared (first use in this function)
     DDRC |= (1<<12);
     ^
backlight.c:17:5: note: each undeclared identifier is reported only once for each function it appears in
backlight.c:20:5: error: 'TC4H' undeclared (first use in this function)
     TC4H = 0x03;
     ^
backlight.c:21:5: error: 'OCR4C' undeclared (first use in this function)
     OCR4C = 0xFF;
     ^
backlight.c:22:5: error: 'TCCR4A' undeclared (first use in this function)
     TCCR4A = 0b10000010;
     ^
backlight.c:23:5: error: 'TCCR4B' undeclared (first use in this function)
     TCCR4B = 0b00000001;
     ^
backlight.c: In function 'backlight_set':
backlight.c:52:5: error: 'TC4H' undeclared (first use in this function)
     TC4H = pwm_level >> 8;
     ^
backlight.c:53:5: error: 'OCR4A' undeclared (first use in this function)
     OCR4A = 0xFF & pwm_level;
     ^
../../tmk_core/tool/chibios/ChibiOS/os/common/startup/ARMCMx/compilers/GCC/rules.mk:217: recipe for target 'build/obj/backlight.o' failed
make: *** [build/obj/backlight.o] Error 1


I'm also thinking that I should be using
Code: [Select]
TEENSY_PIN12 instead of
Code: [Select]
1<<12

This is my repo https://github.com/leizzer/tmk_keyboard/tree/personal/keyboard/totoro_lc

Thanks again for your time!!
PS: I code for living but I'm not a native C speaker, please be kind explaining
Title: Re: TMK keyboard firmware
Post by: fiete on Wed, 14 December 2016, 01:43:38
Confirmed ACTION_MODS_KEY(MOD_RALT, KC_7) works on my keyboard(HHKB), it yields '{' on German layout on Xorg on Ubuntu16.04.
AltGr key on ISO keyboard is equivalent to Right Alt, use just 'KC_RALT' in TMK.

Thank you very much for testing and fast response!

Will go and implement and report back if I got some problem :-)

Regards
Fritz
Title: Re: TMK keyboard firmware
Post by: fiete on Wed, 14 December 2016, 09:45:29
Hi hasu,

tried that but does not work here on gentoo with german keymap in X.

Can you please tell me what keycode your MOD_RALT sends on your System?
I get with showkey -s the following

Code: [Select]
KC_RALT 0x2a 0x38 0x0c 0x8c 0xaa 0xb8
KC_RCTRL 0x2a 0x08 0x88 0xaa
MOD_RALT 0x2a 0x38 0x08 0xaa 0xb8

And thats what AltGr and right Ctrl send on a normal keyboard

Code: [Select]
AltGr 0xe0 0x38 0xe0 0xb8
RCtrl 0xe0 0x1d 0xe0 0x9d

Do you have an idea where that diffrence comes from? Im nearly sure that I'm doing something wrong.

Is there a way to add those keycodes to kexcodes.h?

Thanks in advance!
Regards
Frity
Title: Re: TMK keyboard firmware
Post by: leizzer on Wed, 14 December 2016, 14:06:36
Hi hasu,

tried that but does not work here on gentoo with german keymap in X.

Can you please tell me what keycode your MOD_RALT sends on your System?
I get with showkey -s the following

Code: [Select]
KC_RALT 0x2a 0x38 0x0c 0x8c 0xaa 0xb8
KC_RCTRL 0x2a 0x08 0x88 0xaa
MOD_RALT 0x2a 0x38 0x08 0xaa 0xb8

And thats what AltGr and right Ctrl send on a normal keyboard

Code: [Select]
AltGr 0xe0 0x38 0xe0 0xb8
RCtrl 0xe0 0x1d 0xe0 0x9d

Do you have an idea where that diffrence comes from? Im nearly sure that I'm doing something wrong.

Is there a way to add those keycodes to kexcodes.h?

Thanks in advance!
Regards
Frity

Have you tried other layouts? (German, English International AltGr with dead keys) Because in Ubuntu I can use AltGr as normal
Are the codes for other keys the same between keyboards?
Title: Re: TMK keyboard firmware
Post by: fiete on Wed, 14 December 2016, 15:03:36
Have you tried other layouts? (German, English International AltGr with dead keys) Because in Ubuntu I can use AltGr as normal
Are the codes for other keys the same between keyboards?

I want it to work with german keyboard set in Xorg. Other keys like e.g. 'a' or 't' got identical keycodes. Also tried an normal usb keyboard to see whether it produces the same codes than my notebooks keyboard (it does).

Any other suggestions what I can do?

Thanks
Fritz
Title: Re: TMK keyboard firmware
Post by: fiete on Wed, 14 December 2016, 15:54:56
Please forget what I wrote about the scancodes. Got a fault in my code. The scancode of KC_RALT and AltGr are the same now. But ACTION_MODS_KEY does not work as expected with KC_RALT and the numbers at the moment. Will go on searching my error.

Regards Fritz
Title: Re: TMK keyboard firmware
Post by: hasu on Wed, 14 December 2016, 17:05:50
Hello guys,
first of all a big thanks to the people behind this firmware :)

I'm using chibios with my handwired keyboard (teensy 3.2) and I'm trying to add backlight to it. I know that only a few guys are using teensy 3.2 but it will be more than appreciated your help.

I added the backlight.c and backlight.h trying to copy this https://github.com/skullydazed/tmk_keyboard/tree/master/keyboard/cluepad (that somebody answered to a guy that he could follow that as an example).
But, with chibios it seems that I can't use
Code: [Select]
#include <avr/io.h> because I get an error that it is not defined, and when I remove that line I get
Code: [Select]
[...........]
Compiling chprintf.c
Compiling memstreams.c
Compiling nullstreams.c
Compiling usb_main.c
../../tmk_core/protocol/chibios/usb_main.c: In function 'usb_event_cb':
../../tmk_core/protocol/chibios/usb_main.c:787:3: warning: enumeration value 'USB_EVENT_UNCONFIGURED' not handled in switch [-Wswitch]
   switch(event) {
   ^
Compiling main.c
Compiling keymap_plain.c
Compiling matrix.c
Compiling backlight.c
backlight.c: In function 'led_set':
backlight.c:9:22: warning: unused parameter 'usb_led' [-Wunused-parameter]
 void led_set(uint8_t usb_led)
                      ^
backlight.c: In function 'init_backlight_pin':
backlight.c:17:5: error: 'DDRC' undeclared (first use in this function)
     DDRC |= (1<<12);
     ^
backlight.c:17:5: note: each undeclared identifier is reported only once for each function it appears in
backlight.c:20:5: error: 'TC4H' undeclared (first use in this function)
     TC4H = 0x03;
     ^
backlight.c:21:5: error: 'OCR4C' undeclared (first use in this function)
     OCR4C = 0xFF;
     ^
backlight.c:22:5: error: 'TCCR4A' undeclared (first use in this function)
     TCCR4A = 0b10000010;
     ^
backlight.c:23:5: error: 'TCCR4B' undeclared (first use in this function)
     TCCR4B = 0b00000001;
     ^
backlight.c: In function 'backlight_set':
backlight.c:52:5: error: 'TC4H' undeclared (first use in this function)
     TC4H = pwm_level >> 8;
     ^
backlight.c:53:5: error: 'OCR4A' undeclared (first use in this function)
     OCR4A = 0xFF & pwm_level;
     ^
../../tmk_core/tool/chibios/ChibiOS/os/common/startup/ARMCMx/compilers/GCC/rules.mk:217: recipe for target 'build/obj/backlight.o' failed
make: *** [build/obj/backlight.o] Error 1


I'm also thinking that I should be using
Code: [Select]
TEENSY_PIN12 instead of
Code: [Select]
1<<12

This is my repo https://github.com/leizzer/tmk_keyboard/tree/personal/keyboard/totoro_lc

Thanks again for your time!!
PS: I code for living but I'm not a native C speaker, please be kind explaining


The code is for AVR and Teensy3.2 you are using has Kinetis, not AVR.
Use Teensy2.0 or write backlight code for Kinetsis yourself.
Title: Re: TMK keyboard firmware
Post by: fiete on Thu, 15 December 2016, 00:56:20
Hi, just a small update from my side. I am able to write { if i bind KC_RALT to a key and press the correspondong number 7. But it does not work if I use it with ACTION_MODS_KEY. Any idea what I might do wrong? Or where i should have a look inside the code?
Regards Fritz

Gesendet von meinem STV100-4 mit Tapatalk

Title: Re: TMK keyboard firmware
Post by: DstroyGH on Fri, 16 December 2016, 08:16:46
Hi There,
I'm trying to compile the firmware , but i keep getting this error

obj_gh60_lufa/common/keymap.o: In function `keymap_fn_to_action':
/mnt/c/Users/Dstroy/Desktop/tmk_keyboard-master/keyboard/gh60/../../tmk_core/common/keymap.c:246: undefined reference to `fn_actions'
/mnt/c/Users/Dstroy/Desktop/tmk_keyboard-master/keyboard/gh60/../../tmk_core/common/keymap.c:246: undefined reference to `fn_actions'

I have removed the word static from keymap.c in the core/common folder and I still get the same error.
Any help would be appreciated.
Title: Re: TMK keyboard firmware
Post by: tjweir on Fri, 16 December 2016, 09:08:39
Hi There,
I'm trying to compile the firmware , but i keep getting this error

obj_gh60_lufa/common/keymap.o: In function `keymap_fn_to_action':
/mnt/c/Users/Dstroy/Desktop/tmk_keyboard-master/keyboard/gh60/../../tmk_core/common/keymap.c:246: undefined reference to `fn_actions'
/mnt/c/Users/Dstroy/Desktop/tmk_keyboard-master/keyboard/gh60/../../tmk_core/common/keymap.c:246: undefined reference to `fn_actions'

I have removed the word static from keymap.c in the core/common folder and I still get the same error.
Any help would be appreciated.

Paste your keymap file, probably missing:
Code: [Select]
const uint16_t PROGMEM fn_actions[] = {};
Title: Re: TMK keyboard firmware
Post by: Kaibz on Fri, 16 December 2016, 16:59:36
Ok so i yesterday my keyboard stops working, i spend the night trying to figure it out, i even switch from a teensy 2.00 ++ to a teensy 2.0 as i thought may be my teensy is damaged, but then again it still didn't work. I was literally going crazy, there was just nothing coming out of my keyboard but the make process was fine. Finally i just plugged it to m yportable computer, and it did work....I really don't understand what is goind on, my 2 computers are running windows 7 (one 32bits the other 64bits) and i am still totally unable to make the keyboard work on my windows 64bits, coud a windows update be responsible? what could i do honestly i m going crazy i can only type/work on my custom keyboard help please
Title: Re: TMK keyboard firmware
Post by: hasu on Fri, 16 December 2016, 17:23:03
Scaned your old posts and I foud you had problem with your keyboard and computer.
https://geekhack.org/index.php?topic=41989.msg2194775#msg2194775
https://geekhack.org/index.php?topic=41989.msg2198920#msg2198920

 I guess your keyboard hardware is iffy.
Title: Re: TMK keyboard firmware
Post by: Kaibz on Fri, 16 December 2016, 18:29:46
:( I see, gonna order another teensy then....

Thanks for answering Hasu !
Title: Re: TMK keyboard firmware
Post by: hasu on Fri, 16 December 2016, 18:37:55
:( I see, gonna order another teensy then....

Thanks for answering Hasu !

what's your keyboard actually? If it is a hand-wired keyboard you would have to check your soldering and wriring with good multimeter before replacing Teensy.
Title: Re: TMK keyboard firmware
Post by: Kaibz on Sat, 17 December 2016, 11:43:52
It is a hand wired keyboard. I did actually i rechecked EVERYTHING and i made tests, this is where i am right now (using windows 7 ultimate 64) If keyboard is plugged before i launch windows, i will be able to use it normally (i am typing this message with it)  if i unplugged it even once, and then plug it back the keyboard won't work and i tried this with the old AND the new install of windows. I am desperate.

EDIT: Fixed the issue just switching to windows 10.

Thanks again to Hasu for creating this firmware. Cheers.
Title: Re: TMK keyboard firmware
Post by: MandrewDavis on Mon, 19 December 2016, 21:13:17
I have an Alps64 and I wanted to build the firmware from the ground up without the web configurator. I know how to flash the hex and have already created a keymap in a notepad file but even after reading through the github wiki and toying with a few of the programs I just cannot figure out how to compile the firmware. Can someone point me in the right direction with Windows 10 64bit? What do I need to install?
Title: Re: TMK keyboard firmware
Post by: Tactile on Mon, 19 December 2016, 21:33:46
I have an Alps64 and I wanted to build the firmware from the ground up without the web configurator. I know how to flash the hex and have already created a keymap in a notepad file but even after reading through the github wiki and toying with a few of the programs I just cannot figure out how to compile the firmware. Can someone point me in the right direction with Windows 10 64bit? What do I need to install?

Step 1 would be to install the Windows Linux subsystem. This will install an Ubuntu command line environment within which you can compile the firmware.  There are other ways to do it but IMO the easiest way to build the firmware within Windows is just build it in Linux.

https://msdn.microsoft.com/en-us/commandline/wsl/install_guide

Then sudo apt-get install gcc-avr avr-libc to get the main tools installed.

I'm throwing this together hurriedly - I'm supposed to be hosting a party right now. Anyway, even though I've probably left something out this should get you started in the right direction.
Title: Re: TMK keyboard firmware
Post by: pabile on Thu, 22 December 2016, 01:34:31
Scenario...
- Default layer on my alps64 uses space to momentary switch to Layer 4 (SpaceFN) and Application key to toggle switch to Layer 1 (T1).
[attach=1]

- Layer 4 has my F rows et al
[attach=2]

- Layer 1 uses a regular space and uses CapsLock to switch to Layer 4
[attach=3]


Now for my question...
In Layer 4, do i need to define CapsLock as L4? How about spacebar as SpaceFN(L4)?
Title: Re: TMK keyboard firmware
Post by: seattle_ice on Thu, 22 December 2016, 04:36:14
Ok, I got to the point where I tried to compile my firmware, and I got the following error. I did install the latest avr gcc just to make sure, but no change:

[attachimg=1]
Title: Re: TMK keyboard firmware
Post by: fiete on Thu, 22 December 2016, 04:42:00
Hi seattle_ice,

have you also installed the packages: avr-libc binutils-avr gcc-avr avrdude

Regards
Fritz
Title: Re: TMK keyboard firmware
Post by: hasu on Thu, 22 December 2016, 05:07:10
Scenario...
- Default layer on my alps64 uses space to momentary switch to Layer 4 (SpaceFN) and Application key to toggle switch to Layer 1 (T1).
(Attachment Link)

- Layer 4 has my F rows et al
(Attachment Link)

- Layer 1 uses a regular space and uses CapsLock to switch to Layer 4
(Attachment Link)


Now for my question...
In Layer 4, do i need to define CapsLock as L4? How about spacebar as SpaceFN(L4)?
Yes, you need. But I would place spaceFN on later 1 and other on higher layer, with this you can use TRNS instead of L4.
Title: Re: TMK keyboard firmware
Post by: pabile on Thu, 22 December 2016, 06:20:57
Yes, you need. But I would place spaceFN on later 1 and other on higher layer, with this you can use TRNS instead of L4.

hi hasu! i actually need at least one layer with regular spacebar for gaming purposes. thanks

edit:
i was re-reading your comment and i didnt think i undertood it at first. but now, i think it made sense. instead of T1, may i could use T5 instead. this way, i dont need to re-declare L4 in my spacebar. i hope i understood it correctly. thanks again for everything, hasu!

update: shoot! there's no T5... i think i'll be needing those alps lock switches.

Title: Re: TMK keyboard firmware
Post by: seattle_ice on Fri, 23 December 2016, 02:46:52
Hi seattle_ice,

have you also installed the packages: avr-libc binutils-avr gcc-avr avrdude

Regards
Fritz

I made sure those were all installed, and I have gotten it to compile now.

I am now getting an error about 'sh: 1: dfu-programmer: not found'

I also do not fully understand the key mapping.  For instance, when I look at the following in the 'keymap_plain.c', I do not understand where the values come from, since it seems like there are about 10 different values used for the same keys in different examples.

Code: [Select]
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,BSLS, \
           CAPS,A,   S,   D,   F,   G,   H,   J,   K,   L,   SCLN,QUOT,NO,  ENT,  \
           LSFT,NO,  Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, SLSH,NO,  RSFT, \
           LCTL,LGUI,LALT,          SPC,                     RALT,RGUI,APP, RCTL),
};
const action_t PROGMEM fn_actions[] = {};
Title: Re: TMK keyboard firmware
Post by: fiete on Fri, 23 December 2016, 02:50:00
I am now getting an error about 'sh: 1: dfu-programmer: not found'

just install the package dfu-programmer
Title: Re: TMK keyboard firmware
Post by: fiete on Fri, 23 December 2016, 02:54:40
I also do not fully understand the key mapping.  For instance, when I look at the following in the 'keymap_plain.c', I do not understand where the values come from, since it seems like there are about 10 different values used for the same keys in different examples.

Code: [Select]
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,BSLS, \
           CAPS,A,   S,   D,   F,   G,   H,   J,   K,   L,   SCLN,QUOT,NO,  ENT,  \
           LSFT,NO,  Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, SLSH,NO,  RSFT, \
           LCTL,LGUI,LALT,          SPC,                     RALT,RGUI,APP, RCTL),
};
const action_t PROGMEM fn_actions[] = {};

Just take a look at keymap_common.h and keycode.h that should answer that question.

The name for the keycodes are derived from an us keyboard. so COMM sends the keycode of the key that produces a comma on us layout.

Regards Fritz
Title: Re: TMK keyboard firmware
Post by: hasu on Fri, 23 December 2016, 02:58:31
Yes, you need. But I would place spaceFN on later 1 and other on higher layer, with this you can use TRNS instead of L4.

hi hasu! i actually need at least one layer with regular spacebar for gaming purposes. thanks

edit:
i was re-reading your comment and i didnt think i undertood it at first. but now, i think it made sense. instead of T1, may i could use T5 instead. this way, i dont need to re-declare L4 in my spacebar. i hope i understood it correctly. thanks again for everything, hasu!

update: shoot! there's no T5... i think i'll be needing those alps lock switches.



Right, to use T5 is another solution for this.
New keymap editor should have T5, check first post of Alps64 again.
Title: Re: TMK keyboard firmware
Post by: henz on Fri, 23 December 2016, 03:01:32
ive updated the KMAC fork, it now supports the kmac mini as well. Havent bothered about the leds though.
Title: Re: TMK keyboard firmware
Post by: TalkingTree on Fri, 23 December 2016, 03:09:20
I am now getting an error about 'sh: 1: dfu-programmer: not found'
Try (re)installing the dfu-programmer

Code: [Select]
sudo apt-get install dfu-programmerReplace apt-get with yum if you're on a Fedora based distribution.


I do not understand where the values come from
If you mean the KC_ constants, You can find them in ./tmk_core/common/keycode.h

it seems like there are about 10 different values used for the same keys in different examples.
There are aliases indeed.


Code: [Select]
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,BSLS, \
           CAPS,A,   S,   D,   F,   G,   H,   J,   K,   L,   SCLN,QUOT,NO,  ENT,  \
           LSFT,NO,  Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, SLSH,NO,  RSFT, \
           LCTL,LGUI,LALT,          SPC,                     RALT,RGUI,APP, RCTL),
};
const action_t PROGMEM fn_actions[] = {};
This is the default layer for a 60% board (GH60?), if you want additional layers, just copy the KEYMAP() block and populate the matrix, every block will count as a layer.
Title: Re: TMK keyboard firmware
Post by: TheDrsh on Fri, 23 December 2016, 18:43:55
Hey,

I read a post before on a different forum about having more columns on a keyboard(I'm making a full keyboard) in the "read_cols" function of matrix.c the it will only return columns less than 8 shifts, so my first 8 columns of the keyboard work but not the rest, I tried using the methods you suggested(1UL<<16), (uint32_t)(1<<16), etc but I cannot seem to get it to work, any suggestions? Also, I've attached my matrix .c file.

EDIT:
Using teensy2.0++
Title: Re: TMK keyboard firmware
Post by: 0xBeFa on Sun, 25 December 2016, 10:58:24
Hey,

I read a post before on a different forum about having more columns on a keyboard(I'm making a full keyboard) in the "read_cols" function of matrix.c the it will only return columns less than 8 shifts, so my first 8 columns of the keyboard work but not the rest, I tried using the methods you suggested(1UL<<16), (uint32_t)(1<<16), etc but I cannot seem to get it to work, any suggestions? Also, I've attached my matrix .c file.

EDIT:
Using teensy2.0++

is your matrix size set up correct? check it in config.h

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

i have 18 colums working on teensy2.0++
Title: Re: TMK keyboard firmware
Post by: 0xBeFa on Sun, 25 December 2016, 11:21:19
QWERTY to QWERTZ Keymap

I made a keymap that mimics an US layout on a PC that is set to German (DE) keyboard layout.
This allows the use of an standard US layout witch is way better for programming c-style languages but also german "Umlaute" can be mapped on additional layers.
Following special characters can be input though layer 3 and 4: ö ü ä ß Ö Ü Ä
Also the degree sign is accessible on layer 3: °

I'm using extended keymap instead of macros. Tested on Win7 and Ubuntu 16.04.
I share the code here if anyone else want to use it.

Code: [Select]
#include "extended_keymap_common.h"
#include "../keymap_rapooV500.h"

// QWERTY to QWERTZ:
// ROW 2, no shift
#define EN_GRAVE     S(KC_EQUAL)
#define EN_MINUS     KC_SLASH
#define EN_EQUAL     S(KC_0)
// ROW 3, no shift
#define EN_BRC_SQ_L  RALT(KC_8)
#define EN_BRC_SQ_R  RALT(KC_9)
#define EN_BSLS      RALT(KC_MINUS)
// ROW 4, no shift
#define EN_SCLN      S(KC_COMM)
#define EN_QUOT      S(KC_NONUS_HASH)
// ROW 5, no shift
#define EN_SLSH      S(KC_7)
// ROW 2, shift
#define EN_TILDE     RALT(KC_RBRACKET)
#define EN_AT        RALT(KC_Q)
#define EN_HASH      KC_NONUS_HASH
#define EN_CRCMFLX   KC_GRV
#define EN_ASTRSK    S(KC_RBRACKET)
#define EN_PLUS      KC_RBRACKET
// ROW 3, shift
#define EN_BRC_CU_L  RALT(KC_7)
#define EN_BRC_CU_R  RALT(KC_0)
#define EN_VSTROKE   RALT(KC_NUBS)
// ROW 4, shift     
#define EN_COLON     S(KC_DOT)
#define EN_DQUOTE    S(KC_2)
// ROW 5, shift     
#define EN_BRC_TR_L  KC_NUBS
#define EN_BRC_TR_R  S(KC_NUBS)
#define EN_QMARK     S(KC_MINUS)

// German Umlaute:
#define DE_sz       KC_MINUS
#define DE_OE       KC_SCLN
#define DE_UE       KC_LBRACKET     
#define DE_AE       KC_QUOTE   
#define DE_DEGREE   S(KC_GRAVE)

#define MY_LAYER_SHIFT 1
#define MY_LAYER_MOD   2
#define MY_LAYER_MODSHIFT 3
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
   [0]=KEYMAP_RAPOOV500(   
// Base Layer:─
// ┌───────────┬───────────┬───────────┬───────────┬───────────┬───────────┬───────────┬───────────┬───────────┬───────────┬───────────┬───────────┬───────────┬───────────┬───────────┐  ┌───────────┬───────────┬───────────┐
// │           │           │           │           │           │           │           │           │           │           │           │           │           │           │           │  │           │           │           │18
     KC_ESC    , KC_F1     , KC_F2     , KC_F3     , KC_F4     , KC_F5     , KC_F6     , KC_F7     , KC_F8     , KC_F9     , KC_F10    , KC_F11    , KC_F12    , KC_NO     , KC_NO     ,    KC_NO     , KC_NO     , KC_NO     ,
// │           │           │           │           │           │           │           │           │           │           │           │           │           │           │           │  │           │           │           │
// ├───────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┴───────────┤  ├───────────┼───────────┼───────────┤
// │ --------  │           │           │           │           │           │           │           │           │           │           │ --------  │---------  │                       │  │           │           │           │17
     EN_GRAVE  , KC_1      , KC_2      , KC_3      , KC_4      , KC_5      , KC_6      , KC_7      , KC_8      , KC_9      , KC_0      , EN_MINUS  , EN_EQUAL  , KC_BSPACE             ,   KC_PSCREEN , KC_NO     , KC_PAUSE  ,
// │           │           │           │           │           │           │           │           │           │           │           │           │           │                       │  │           │           │           │
// ├───────────┴───┬───────┴───┬───────┴───┬───────┴───┬───────┴───┬───────┴───┬───────┴───┬───────┴───┬───────┴───┬───────┴───┬───────┴───┬───────┴───┬───────┴───┬───────────────────┤  ├───────────┼───────────┼───────────┤
// │               │           │           │           │           │           │           │           │           │           │           │-----------│-----------│ -------           │  │           │           │           │17
     KC_TAB        , KC_Q      , KC_W      , KC_E      , KC_R      , KC_T      , KC_Z      , KC_U      , KC_I      , KC_O      , KC_P      ,EN_BRC_SQ_L,EN_BRC_SQ_R, EN_BSLS           ,    KC_INSERT , KC_HOME   , KC_PGUP   ,
// │               │           │           │           │           │           │           │           │           │           │           │           │           │                   │  │           │           │           │
// ├───────────────┴───┬───────┴───┬───────┴───┬───────┴───┬───────┴───┬───────┴───┬───────┴───┬───────┴───┬───────┴───┬───────┴───┬───────┴───┬───────┴───┬───────┴───────────────────┤  ├───────────┼───────────┼───────────┤
// │ to mod layer      │           │           │           │           │           │           │           │           │           │ -------   │ -------   │                           │  │           │           │           │16
     KC_FN2            , KC_A      , KC_S      , KC_D      , KC_F      , KC_G      , KC_H      , KC_J      , KC_K      , KC_L      , EN_SCLN   , EN_QUOT   , KC_ENT                    ,    KC_DELETE , KC_END    , KC_PGDOWN ,
// │                   │           │           │           │           │           │           │           │           │           │           │           │                           │  │           │           │           │
// ├───────────────────┴───┬───────┴───┬───────┴───┬───────┴───┬───────┴───┬───────┴───┬───────┴───┬───────┴───┬───────┴───┬───────┴───┬───────┴───┬───────┴───────────────────────────┤  └───────────┼───────────┼───────────┘
// │ to shift layer        │           │           │           │           │           │           │           │           │           │ -------   │ to shift layer                    │              │           │            13
     KC_FN1                , KC_Y      , KC_X      , KC_C      , KC_V      , KC_B      , KC_N      , KC_M      , KC_COMM   , KC_DOT    , EN_SLSH   , KC_FN1                            ,                KC_UP     ,
// │                       │           │           │           │           │           │           │           │           │           │           │                                   │              │           │           
// ├───────────────────────┴───┬───────┴─────┬─────┴───────────┴───────────┴───────────┴───────────┴───────────┴───────────┴───────────┴───────────┴───┬───────────────────────────────┤  ┌───────────┼───────────┼───────────┐
// │             │             │             │                                                                         │               │               │               │               │  │           │           │           │11
     KC_LCTL     , KC_LGUI     , KC_LALT     , KC_SPC                                                                  , KC_RALT       , KC_RGUI       , KC_RALT       , KC_RCTL       ,    KC_LEFT   , KC_DOWN   , KC_RGHT   )
// │             │             │             │                                                                         │               │               │               │               │  │           │           │           │
// └─────────────┴─────────────┴─────────────┴─────────────────────────────────────────────────────────────────────────┴───────────────┴───────────────┴───────────────┴───────────────┘  └───────────┴───────────┴───────────┘

[...]
Title: Re: TMK keyboard firmware
Post by: pabile on Tue, 27 December 2016, 01:40:34
Right, to use T5 is another solution for this.
New keymap editor should have T5, check first post of Alps64 again.

i just did and find the update so awesome... also used layer tap on caps lock!
thanks, hasu!
Title: Re: TMK keyboard firmware
Post by: splicepoint on Wed, 28 December 2016, 21:49:57
Hi all,

Back after a break. Hoping someone can lend me a hand. I recently reworked my Phantom PCB project from a new PCB and started fresh. After getting all the diodes soldered in, I soldered the Teensy, flashed the hex file from tmk to the unit and used AquaKey to test each switch location before actually putting the MX Browns into the PCB.

I cannot get columns 11 and 12 to work correctly after several hours of troubleshooting. I am pretty confident that the board is soldered correctly, I have tested the connection to the Teensy with a multimeter and everything appears to be in order.

Attached is a link to a zip of my tmk build and an image of the layout ( http://imgur.com/oyygnud (http://imgur.com/oyygnud) )  - all keys in yellow are working (it's TKL). https://www.dropbox.com/s/qfx4hbny198umq3/phantom.zip?dl=0 (https://www.dropbox.com/s/qfx4hbny198umq3/phantom.zip?dl=0) If anyone has any suggestions I am dying to get this thing working this time around. Firmware has really made this mech building experience a frustration and I want to accomplish this first build (second attempt) so that I can stick around and keep this as a hobby. Feeling like I'm in need of a helping hand though.

Just hoping to know whether I'm missing something with the firmware or whether I definitely have a hardware issue on my hands. Just couldn't isolate the issue on my own.

Any help appreciated. Happy to provide more info as well.

Thanks,
Splice

(http://)
Title: Re: TMK keyboard firmware
Post by: hasu on Wed, 28 December 2016, 22:10:08
Splice,
Did you confirm that the columns work well with official Phantom firmware, already? I think this is the easiest way to discriminate between hardware problem and firmware one.

Not that I don't believe your mutltimeter job but people including me often miss something when in trouble in particular :D
Title: Re: TMK keyboard firmware
Post by: splicepoint on Wed, 28 December 2016, 22:23:47
Hi Hasu,

Thanks for the reply. I used some pre-baked Phantom firmware as well as spent several hours working on various tweaks to the build generating my own hex. Nothing would work for those columns. That's when I went back and resoldered everything on those columns and redid those pins to the teensy. Not saying I don't have a hardware issue - I just feel like I'm out of troubleshooting steps and now I'm unsure how what to try to isolate things down. Pretty new at this whole thing.

Thanks,

Splice
Title: Re: TMK keyboard firmware
Post by: hasu on Wed, 28 December 2016, 22:39:54
I think pre-build firmware is enough to test your hardware, if your keyboard don't work with the pre-build firmware it is likely hardware problem, for example, bad soldering or fault on PCB. Perhaps, you can contact seller/supplier of the PCB to get help/info on building keyboard and flash firmware.

To be honest, I'm not sure TMK still works on Phantom, it has not been updated long time.
Title: Re: TMK keyboard firmware
Post by: splicepoint on Wed, 28 December 2016, 22:52:26
Thanks Hasu - I have a feeling it'll work. Maybe it's a hardware issue. I'll investigate further. Any suggestions on alternative form factors which are similar to phantom or on other firmware that would support a phantom? I'm open to buying a new PCB too. Whatever.

Thanks again,
Splice
Title: Re: TMK keyboard firmware
Post by: evangs on Thu, 29 December 2016, 12:41:29
I have a question about ACTION_LAYER_TAP_KEY and ACTION_MODS_TAP_KEY. Is it possible to reference a FN key as the tap key? I have tried this and the firmware builds but when I tap that key nothing happens. When I hold it the proper modifier or layer does happen.

If this is currently not supported, where would the best place be to implement this functionality?
Title: Re: TMK keyboard firmware
Post by: hasu on Thu, 29 December 2016, 18:03:27
I have a question about ACTION_LAYER_TAP_KEY and ACTION_MODS_TAP_KEY. Is it possible to reference a FN key as the tap key? I have tried this and the firmware builds but when I tap that key nothing happens. When I hold it the proper modifier or layer does happen.

If this is currently not supported, where would the best place be to implement this functionality?

Right, unfortunately you can't use FN as TAP_KEY currently at least.

Those TAP_KEYs have 'action_kind' codes 'ACT_LAYER_TAP' and 'ACT_{L|R}MODS_TAP' respectively.
https://github.com/tmk/tmk_keyboard/blob/master/tmk_core/common/action_code.h#L272
https://github.com/tmk/tmk_keyboard/blob/master/tmk_core/common/action_code.h#L216

And behaviours of the actions are defined in switch-case clauses of common/action.c, you will be able to place implementation for your need here.
https://github.com/tmk/tmk_keyboard/blob/master/tmk_core/common/action.c#L247-L305
https://github.com/tmk/tmk_keyboard/blob/master/tmk_core/common/action.c#L99-L132

Title: Re: TMK keyboard firmware
Post by: splicepoint on Sun, 01 January 2017, 13:41:51
I think pre-build firmware is enough to test your hardware, if your keyboard don't work with the pre-build firmware it is likely hardware problem, for example, bad soldering or fault on PCB. Perhaps, you can contact seller/supplier of the PCB to get help/info on building keyboard and flash firmware.

To be honest, I'm not sure TMK still works on Phantom, it has not been updated long time.

Hey Hasu! Just an update. I got my build working. It turns out it was a problem with my poor soldering job on the micro-controller. My Teensy was not making a good connection on a few pins to the PCB.

As far as TMK, it works like a charm on Phantom - no issues there at all.

Thanks again for your help (and the firmware!)
Title: Re: TMK keyboard firmware
Post by: Kaibz on Mon, 02 January 2017, 05:25:48
Can you build tmk firmware on raspbian?
I'm asking as the raspberry pi is ARM based so i don't know if the needed packages (gcc, avr...) will be compatible?
Title: Re: TMK keyboard firmware
Post by: a-c on Mon, 02 January 2017, 06:06:54
Can you build tmk firmware on raspbian?
I'm asking as the raspberry pi is ARM based so i don't know if the needed packages (gcc, avr...) will be compatible?

Works fine. All the required packages are available in the default repositories.
Title: Re: TMK keyboard firmware
Post by: Kaibz on Mon, 02 January 2017, 07:07:33
Thank you a-c.
Title: Re: TMK keyboard firmware
Post by: henz on Mon, 02 January 2017, 13:58:10
id like to explore the possibilty of having a multilanguage keyboard, without having to browse code from the top up, is there such an option to translate to other keycodes?



Edit: Gonna start working on the ALT+numpad code way, let me know if you have a better idea
Title: Re: TMK keyboard firmware
Post by: alh84001 on Thu, 05 January 2017, 16:38:43
I just wired a Pro Micro with 5-pin mini-DIN port and flashed the NEXT converter. Are shift LEDs supported? README states "Figure out a better use for the lock LEDs.  Right now they just light up when you press shift.", but when I press shift, nothing happens.
Title: Re: TMK keyboard firmware
Post by: hasu on Thu, 05 January 2017, 16:42:33
To be honest ICAN' t remember it . But what happens when pressing caps lock?

Tapatalk を使用して私の Nexus 5X から送信

Title: Re: TMK keyboard firmware
Post by: greenwhite on Thu, 05 January 2017, 17:10:59
I apologize if this issue has been resolved somewhere else, but I couldn't find an answer.

I'm using the tmk firmware (which I downloaded 12/16/16).My Caps Lock key toggles on, but when I press it again it stays on instead of turning off.  The only way for me to toggle it off is by pressing the shift key.  Any time I do press the shift key, it toggles Caps off. I would like caps lock to only be toggled by the caps lock key.  Did I miss an option in my configuration?

Thanks for any input.

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

const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
    /*  0 - Default Layer */
    KEYMAP(
             F1,   F2,   F3,   F4,   F5,   F6,   F7,   F8,   F9,  F10,  F11,  F12, \
            ESC, PSCR,  FN0,    C,    V,    W,    F,    K,    J,  INS, HOME, PGUP, \
            FN2,       CAPS,    D,    H,    T,    N,    S,    G,  DEL,  END, PGDN, \
           LGUI,  TAB,          O,    A,    E,    U,    I,    Y,         UP,       \
           LALT,  ENT,  SPC,    R,    L,    B,    M,    P,  FN1, LEFT, DOWN, RGHT, \
           LCTL,             COMM,  DOT,    X,    Q,    Z, RSFT, BSPC, RALT, RCTL ) ,
    /* 1 - Number / Symbol Fn Layer */
    KEYMAP(
           TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS,  TRNS, TRNS, \
           TRNS, TRNS, TRNS,  EQL, PSLS, PAST, PMNS,    9,    0,  TRNS, TRNS, TRNS, \
           TRNS,       TRNS, KP_7, KP_8, KP_9, PPLS, LBRC, RBRC,  TRNS, TRNS, TRNS, \
           TRNS, TRNS,       KP_4, KP_5, KP_6,    4, SLSH, SCLN,        TRNS,       \
           TRNS,  ENT,  SPC, KP_1, KP_2, KP_3,    3,    2, TRNS, TRNS,  TRNS, TRNS, \
           TRNS,             KP_0, PDOT, MINS, BSLS,  GRV, TRNS, TRNS,  TRNS, TRNS ) ,
    /* 2 - Miscelaneous Fn */
    KEYMAP(
           TRNS,  FN3,  FN4, MUTE, VOLD, VOLU, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, \
            FN5, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, \
           NLCK,       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 ) ,
};
const action_t PROGMEM fn_actions[] = {
    [0] = ACTION_LAYER_TAP_KEY(2, KC_PAUS),  // Misc Fn Layer
    [1] = ACTION_LAYER_MOMENTARY(1),  // temp Num Layer
    [2] = ACTION_LAYER_TOGGLE(1),     // toggle Num Layer
    [3] = ACTION_MODS_KEY(MOD_LALT | MOD_LSFT, KC_TAB),
    [4] = ACTION_MODS_KEY(MOD_LALT, KC_TAB),
    [5] = ACTION_MODS_KEY(MOD_LALT | MOD_LCTL, KC_ESC),
};


Code: [Select]
Title: Re: TMK keyboard firmware
Post by: hasu on Thu, 05 January 2017, 17:50:49
greenwhite,
In TMK capslock shouldn't have issue like that, iirc.
your keymap code seems to be ok. I'd suspect your hardware if your keyboard is DIY in particular. And you should start with simple keymap if you are in trouble.

check first post again, you can give information of your keyboard and make all of your codes available somewhere like github to get right answer quickly and save helpful people's precious time.
Title: Re: TMK keyboard firmware
Post by: alh84001 on Thu, 05 January 2017, 18:44:06
To be honest ICAN' t remember it . But what happens when pressing caps lock?

There is no CAPS in default keymap, so I tried it with another keyboard. On my Windows machine, pressing CAPS on another keyboard mirrors it to the NEXT, so I guess I just need to adjust the keymap. Thanks!

One thing I noticed on my Mac (Yosemite), which may be a non-issue, is that CAPS state doesn't get mirrored. When I press CAPS on MacBook Pro keyboard, only that one types in caps, and next board remains in normal mode. The same thing is true for my X68k board (I posted about an issue with its LEDs in x68k converter thread) with stock x68k_usb converter. And pressing CAPS on it (it is defined in stock keymap there), causes only X68k board to type in caps, while built-in MBP board remains in normal mode.
Title: Re: TMK keyboard firmware
Post by: hasu on Thu, 05 January 2017, 19:50:19
To be honest ICAN' t remember it . But what happens when pressing caps lock?

There is no CAPS in default keymap, so I tried it with another keyboard. On my Windows machine, pressing CAPS on another keyboard mirrors it to the NEXT, so I guess I just need to adjust the keymap. Thanks!

One thing I noticed on my Mac (Yosemite), which may be a non-issue, is that CAPS state doesn't get mirrored. When I press CAPS on MacBook Pro keyboard, only that one types in caps, and next board remains in normal mode. The same thing is true for my X68k board (I posted about an issue with its LEDs in x68k converter thread) with stock x68k_usb converter. And pressing CAPS on it (it is defined in stock keymap there), causes only X68k board to type in caps, while built-in MBP board remains in normal mode.

Current NeXT converter use LEDs on both shift keys just as Capslock indicator but it seems you can control the two LEDs respectively as you want. See this code if you are interested.
https://github.com/tmk/tmk_keyboard/blob/master/tmk_core/protocol/next_kbd.c#L86-L109
https://github.com/tmk/tmk_keyboard/blob/master/converter/next_usb/led.c#L53-L60

Yes. How to handle Capslock state depneds on OS,  Windows and Linux(Xorg?) share the state but Mac doesn't, IIRC.
Title: Re: TMK keyboard firmware
Post by: alh84001 on Fri, 06 January 2017, 05:45:41
Thanks for pointing out relevant bits of code. I think I'll just configure caps lock on tapping SHIFT. But for now, I'm just happy I have NEXTs working :)
Title: Re: TMK keyboard firmware
Post by: greenwhite on Fri, 06 January 2017, 09:36:05
greenwhite,
In TMK capslock shouldn't have issue like that, iirc.
your keymap code seems to be ok. I'd suspect your hardware if your keyboard is DIY in particular. And you should start with simple keymap if you are in trouble.

check first post again, you can give information of your keyboard and make all of your codes available somewhere like github to get right answer quickly and save helpful people's precious time.

I will be sure to include all my code next time.  I discovered the issue.  I created a custom keyboard layout using the Keyboard Layout Creator, so that I could reassign punctuation.  In the properties, there is a setting to use the shift key as a toggle.  Changing the setting solved the issue. 
Title: Re: TMK keyboard firmware
Post by: ikno on Sat, 07 January 2017, 18:35:58
I'm trying to use the Virtualbox image.
This is my first time making & flashing a keyboard.
I tried doing it under windows but had more trouble installing than anything.
So i was able to 'make' the build but now when i run make dfu it keeps waiting.
and when i run dfu-programmer it says it 'no device present'.

Am i doing somthing wrong that my keyboard is not linked correctly to my virtualbox? i installed the additional extensions and enabled the USB2.0
There is also a filter on 'Atmel bootloader'

Edit: Got it to work today. Had to run Sudo make dfu for it to find the keyboard.
Title: Re: TMK keyboard firmware
Post by: hasu on Mon, 09 January 2017, 17:19:00
Edit: Got it to work today. Had to run Sudo make dfu for it to find the keyboard.

What 's your controller actually?
I think I had setup udev rules for most of controllers generally used in community.

Title: Re: TMK keyboard firmware
Post by: ikno on Wed, 11 January 2017, 06:00:15
What 's your controller actually?
I think I had setup udev rules for most of controllers generally used in community.

I got the GH60 ver C through falbatech.pl so that would be a ATmega32u4 i think?

I also think that that pcb supports backlight but i don't know how to get it working.
I added a FN1 button to my layout and
[1] = ACTION_BACKLIGHT_TOGGLE(),

I installed sip sockets so i'm trying my LED's in both directions but they won't light up.
Am i missing something?
Title: Re: TMK keyboard firmware
Post by: henz on Thu, 12 January 2017, 05:07:42
i thought id give it a go and try to create support for Orion, having a issue as i cant use dfu for some reason, keeps making my life pretty hard switching back and forth from linux to windows.

Anyone tried the v2 versions of the duck PCBs?
Title: Re: TMK keyboard firmware
Post by: comblups on Sat, 14 January 2017, 16:58:00
I just bought a Teensy 2.0 for an ADB converter, but then I thought, maybe I can make a converter for both ADB an PS/2 to USB in one. Is that possible? In the git repo there are only projects for either one or the other.
Title: Re: TMK keyboard firmware
Post by: alh84001 on Sun, 15 January 2017, 08:38:48
You can move ADB pin, solder each connector to relevant pins and then just program the teensy with ADB or PS/2 converter when you need one. Obviously, that's a hassle to do every now and then, and I was actually planning on trying to combine these two and some other into a single hot-swappable converter. It's just at the "dumb idea" stage, though.
Title: Re: TMK keyboard firmware
Post by: henz on Sun, 15 January 2017, 09:13:29
I just bought a Teensy 2.0 for an ADB converter, but then I thought, maybe I can make a converter for both ADB an PS/2 to USB in one. Is that possible? In the git repo there are only projects for either one or the other.

Id buy another teensy, doesnt cost that much :)
Title: Re: TMK keyboard firmware
Post by: comblups on Sun, 15 January 2017, 09:25:32
Wouldn’t it be possible to merge the firmware codes into one file an flash that onto one Teensy? Then use two pins for ADB and two pins for PS/2 and 5 pin DIN (making it three cables coming out on one side of the case I’m still struggling to come up with, the USB cable as fourth coming out on the other side).

First I thought there were several different key maps in one code file anyway, but I guess, they’re all for the same protocol (e.g. different Apple Keyboards, but all ADB).
Title: Re: TMK keyboard firmware
Post by: alh84001 on Sun, 15 January 2017, 09:34:35
Id buy another teensy, doesnt cost that much :)

For converters, Pro Micro clones are enough, and much cheaper :)
Title: Re: TMK keyboard firmware
Post by: yoobe on Sun, 15 January 2017, 11:36:32
I am using RedScarft II+ with TMK firmware.
I am writing here but I am not use if the issue is in the Firmare..


When I use the keyboard on my laptop plugged on the usb port, I have no issue.
When I use it with a DELL docking station, I have a windows USB error : Device unrecognized.


Do you know what could be the issue? Power Consumption? Bootloader? Firmware?


Thanks
Title: Re: TMK keyboard firmware
Post by: henz on Sun, 15 January 2017, 16:30:38
I am using RedScarft II+ with TMK firmware.
I am writing here but I am not use if the issue is in the Firmare..


When I use the keyboard on my laptop plugged on the usb port, I have no issue.
When I use it with a DELL docking station, I have a windows USB error : Device unrecognized.


Do you know what could be the issue? Power Consumption? Bootloader? Firmware?


Thanks

if its any of the new kind of docking stations i think thats were the problem lies at my last job everyone were trying all kind of things, updating firmware etc to no avail, people just simply stopped using them. What OS are you using? Logs etc give us da info
Title: Re: TMK keyboard firmware
Post by: comblups on Mon, 16 January 2017, 10:07:49
By now I have collected several keyboards I find very cool, so I’d go even further and try to use more than one keyboard on one Teensy at the same time. For rexample one for typing and one for programming, or one loud and clicky and one damped and silent.
Title: Re: TMK keyboard firmware
Post by: ikno on Tue, 17 January 2017, 03:48:48
Haven't gotten my LEDs to work yet but haven't had much time to investigate. Will be doing this later.

I got a question about ACTION_LAYER_TAP_KEY. I'm using spaceFn and sometimes i want to put a space and directly after that us spaceFn.
The first space is printed correctly but then trying to go to the spaceFn layer isn't executed correctly.
Or a lot of spaces get printed for holding space. Or it starts printing the keys i'm using for example L to go to the right.

A use case is during programming. I open { which automatically places an } as well (in my editor) so i want a space so it looks { } instead of {}.
And directly after that move behind the }.

Is there a config i can change to get this to work?
Title: Re: TMK keyboard firmware
Post by: pabile on Tue, 17 January 2017, 04:27:49
Haven't gotten my LEDs to work yet but haven't had much time to investigate. Will be doing this later.

I got a question about ACTION_LAYER_TAP_KEY. I'm using spaceFn and sometimes i want to put a space and directly after that us spaceFn.
The first space is printed correctly but then trying to go to the spaceFn layer isn't executed correctly.
Or a lot of spaces get printed for holding space. Or it starts printing the keys i'm using for example L to go to the right.

A use case is during programming. I open { which automatically places an } as well (in my editor) so i want a space so it looks { } instead of {}.
And directly after that move behind the }.

Is there a config i can change to get this to work?

i have read in another thread that they assign " " (space) in "b". the idea is that you will still have a regular space (that repeats while being held) while holding spaceFN. https://geekhack.org/index.php?topic=51069.0 (https://geekhack.org/index.php?topic=51069.0)
Title: Re: TMK keyboard firmware
Post by: hasu on Tue, 17 January 2017, 17:50:14
Hmm, interesting use case, I filed on github issues.
https://github.com/tmk/tmk_keyboard/issues/428

You are suffering from 'repeat double tap' function. I guess you can tweak this behaviour with editing this part.
https://github.com/tmk/tmk_keyboard/blob/master/tmk_core/common/action.c#L288-L307


Haven't gotten my LEDs to work yet but haven't had much time to investigate. Will be doing this later.

I got a question about ACTION_LAYER_TAP_KEY. I'm using spaceFn and sometimes i want to put a space and directly after that us spaceFn.
The first space is printed correctly but then trying to go to the spaceFn layer isn't executed correctly.
Or a lot of spaces get printed for holding space. Or it starts printing the keys i'm using for example L to go to the right.

A use case is during programming. I open { which automatically places an } as well (in my editor) so i want a space so it looks { } instead of {}.
And directly after that move behind the }.

Is there a config i can change to get this to work?

Title: Re: TMK keyboard firmware
Post by: nemo_gh on Tue, 17 January 2017, 20:03:35
 hi, i hava a question,  for
example if i want to click the space key, its just space, but i hold it
down,  its shift key.   how can i change the C file?
thanks
Title: Re: TMK keyboard firmware
Post by: hasu on Tue, 17 January 2017, 20:22:19
hi, i hava a question,  for
example if i want to click the space key, its just space, but i hold it
down,  its shift key.   how can i change the C file?
thanks

You can use ACTION_MODS_TAP_KEY(MOD_RSFT, KC_SPC) for this purpose.
https://github.com/tmk/tmk_keyboard/blob/master/tmk_core/doc/keymap.md#213-modifier-with-tap-keydual-role

Also you can use keymap editor.
https://goo.gl/HFr1qR
Title: Re: TMK keyboard firmware
Post by: nemo_gh on Tue, 17 January 2017, 21:02:22
hi, i hava a question,  for
example if i want to click the space key, its just space, but i hold it
down,  its shift key.   how can i change the C file?
thanks

You can use ACTION_MODS_TAP_KEY(MOD_RSFT, KC_SPC) for this purpose.
https://github.com/tmk/tmk_keyboard/blob/master/tmk_core/doc/keymap.md#213-modifier-with-tap-keydual-role

Also you can use keymap editor.
https://goo.gl/HFr1qR

hi, i hava a question,  for
example if i want to click the space key, its just space, but i hold it
down,  its shift key.   how can i change the C file?
thanks

You can use ACTION_MODS_TAP_KEY(MOD_RSFT, KC_SPC) for this purpose.
https://github.com/tmk/tmk_keyboard/blob/master/tmk_core/doc/keymap.md#213-modifier-with-tap-keydual-role

Also you can use keymap editor.
https://goo.gl/HFr1qR


thanks   :D
Title: Re: TMK keyboard firmware
Post by: adam.baranyai on Tue, 17 January 2017, 22:29:21
Hey All,

Quite newbie for GH and about a week old with Hasu controller in my HHKB. I've successfully setup the layout I wanted but for some mysterious reason, I can't seem to make oneshot modifier to work with my shift keys.

This is my current setup: https://goo.gl/uIwAtq

I've successfully uploaded it to the keyboard few times already but the feature doesn't work and I'm not sure what am I missing.

After successful firmware upgrade, I've tried to press shift (after releasing shift) then immediately pressing an 'A' character and the result is a small capital 'a' although CAPS LOCK isn't on.

Anyone using oneshot modifier for shift keys on HHKB with Hasu's controller successfully?
Title: Re: TMK keyboard firmware
Post by: ikno on Wed, 18 January 2017, 02:43:37
hi, i hava a question,  for
example if i want to click the space key, its just space, but i hold it
down,  its shift key.   how can i change the C file?
thanks

Have a look at https://github.com/tmk/tmk_keyboard/blob/master/tmk_core/doc/keymap.md#213-modifier-with-tap-keydual-role
Title: Re: TMK keyboard firmware
Post by: Hypersphere on Sat, 21 January 2017, 10:46:40
I have an Alps64 and I wanted to build the firmware from the ground up without the web configurator. I know how to flash the hex and have already created a keymap in a notepad file but even after reading through the github wiki and toying with a few of the programs I just cannot figure out how to compile the firmware. Can someone point me in the right direction with Windows 10 64bit? What do I need to install?
Windows 10 with the Anniversary Edition upgrade now includes the bash shell and a linux subsystem. There is also the option to install CygWin. Nevertheless, I  prefer to use an actual linux machine or to run linux in a VM using VMware Workstation or VirtualBox. I use Linux Mint 17.3 64-bit with the Xfce desktop on both my dedicated linux workstations and in my VMs.

However, if you don't want to build the firmware, the online configurator makes it very easy to generate your hex file. You can then flash the chip in the Alps64 using Atmel FLIP. I have a laptop running Windows 8.1 that I used for this. I encountered problems getting FLIP to run in Windows 10.


Title: Re: TMK keyboard firmware
Post by: yoobe on Sat, 21 January 2017, 11:49:00
I am using RedScarft II+ with TMK firmware.
I am writing here but I am not use if the issue is in the Firmare..


When I use the keyboard on my laptop plugged on the usb port, I have no issue.
When I use it with a DELL docking station, I have a windows USB error : Device unrecognized.


Do you know what could be the issue? Power Consumption? Bootloader? Firmware?


Thanks

if its any of the new kind of docking stations i think thats were the problem lies at my last job everyone were trying all kind of things, updating firmware etc to no avail, people just simply stopped using them. What OS are you using? Logs etc give us da info


We are using windows 7 at work.
When I use my neutrino with a teensy 2.0 + QMK with the same config, I dont have any issue, I only have the issue with the RedScarfII+ VerC.
Title: Re: TMK keyboard firmware
Post by: Cortes on Sat, 21 January 2017, 21:32:36
Hi people!, I came here asking for some help, because I'm totally lost with my personalized keyboard based on teensy 2.0.

First of all, I do not speak English, and I'm translating all this into Uncle google


The question is that this is my second keyboard based on Teensy 2.0, and the functional part of keyboard works correctly, but the question is that this second keyboard sends it backlight and I'm very lost with it.


My idea is to have 2 independent leds, backlight and leds case, and I would use pins B6 and B7

I have these parts of code backlight.c that gave me the user breh:

Code: [Select]
    /*
    Copyright 2013 Mathias Andersson <wraul@dbox.se>

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
    */

    #include "backlight.h"
    #include "eeconfig.h"
    #include "debug.h"

    backlight_config_t backlight_config;

    void backlight_init(void)
    {
        //check signature
        if (!eeconfig_is_enabled()) {
            eeconfig_init();
        }
        backlight_config.raw = eeconfig_read_backlight();
        backlight_set(backlight_config.enable ? backlight_config.level : 0);
    }

    void backlight_increase(void)
    {
        if(backlight_config.level < BACKLIGHT_LEVELS)
        {
            backlight_config.level++;
            backlight_config.enable = 1;
            eeconfig_write_backlight(backlight_config.raw);
        }
        dprintf("backlight increase: %u\n", backlight_config.level);
        backlight_set(backlight_config.level);
    }

    void backlight_decrease(void)
    {
        if(backlight_config.level > 0)
        {
            backlight_config.level--;
            backlight_config.enable = !!backlight_config.level;
            eeconfig_write_backlight(backlight_config.raw);
        }
        dprintf("backlight decrease: %u\n", backlight_config.level);
        backlight_set(backlight_config.level);
    }

    void backlight_toggle(void)
    {
        backlight_config.enable ^= 1;
        eeconfig_write_backlight(backlight_config.raw);
        dprintf("backlight toggle: %u\n", backlight_config.enable);
        backlight_set(backlight_config.enable ? backlight_config.level : 0);
    }

    void backlight_step(void)
    {
        backlight_config.level++;
        if(backlight_config.level > BACKLIGHT_LEVELS)
        {
            backlight_config.level = 0;
        }
        backlight_config.enable = !!backlight_config.level;
        eeconfig_write_backlight(backlight_config.raw);
        dprintf("backlight step: %u\n", backlight_config.level);
        backlight_set(backlight_config.level);
    }

    void backlight_level(uint8_t level)
    {
        backlight_config.level ^= level;
        backlight_config.enable = !!backlight_config.level;
        eeconfig_write_backlight(backlight_config.raw);
        backlight_set(backlight_config.level);
    }

    // Plank Code for Backlight

    //#include <avr/io.h>
    //#include "backlight.h"

    #define CHANNEL OCR1B
    // Plank is OCR1C
    void backlight_init_ports()
    {

        // Setup PB7 as output and output low.
        DDRB |= (1<<6);
        PORTB &= ~(1<<6);
       
        // Use full 16-bit resolution.
        ICR1 = 0xFFFF;

        // I could write a wall of text here to explain... but TL;DW
        // Go read the ATmega32u4 datasheet.
        // And this: http://blog.saikoled.com/post/43165849837/secret-konami-cheat-code-to-high-resolution-pwm-on
       
        // Pin PB7 = OCR1C (Timer 1, Channel C)
       // Pin PB6 = OCR1B (Timer 1, Channel B)
        // Compare Output Mode = Clear on compare match, Channel C = COM1C1=1 COM1C0=0
       // Compare Output Mode = Clear on compare match, Channel C = COM1B1=1 COM1B0=0
        // (i.e. start high, go low when counter matches.)
        // WGM Mode 14 (Fast PWM) = WGM13=1 WGM12=1 WGM11=1 WGM10=0
        // Clock Select = clk/1 (no prescaling) = CS12=0 CS11=0 CS10=1
       
        TCCR1A = _BV(COM1B1) | _BV(WGM11); // = 0b00001010;
        TCCR1B = _BV(WGM13) | _BV(WGM12) | _BV(CS10); // = 0b00011001;

        backlight_init();
    }

    void backlight_set(uint8_t level)
    {
        if ( level == 0 )
        {
            // Turn off PWM control on PB6, revert to output low.
            TCCR1A &= ~(_BV(COM1B1));
            CHANNEL = 0x0;
            // Prevent backlight blink on lowest level
            PORTB &= ~(_BV(PORTB6));
        }
        else if ( level == BACKLIGHT_LEVELS )
        {
            // Prevent backlight blink on lowest level
            PORTB &= ~(_BV(PORTB6));
            // Turn on PWM control of PB6
            TCCR1A |= _BV(COM1B1);
            // Set the brightness
            CHANNEL = 0xFFFF;
        }
        else       
        {
            // Prevent backlight blink on lowest level
            PORTB &= ~(_BV(PORTB6));
            // Turn on PWM control of PB6
            TCCR1A |= _BV(COM1B1);
            // Set the brightness
            CHANNEL = 0xFFFF >> ((BACKLIGHT_LEVELS - level) * ((BACKLIGHT_LEVELS + 1) / 2));
        }
    }

I want to do something like breh does on your numeric keypad, have specific keys (the ones above the arrows) for the regular backlight, power on / off / more brightness / less brightness, and in another layer to control the LEDs of the case.

Here also the complete keyboard configuration:

Https://dl.dropboxusercontent.com/u/5052546/Shiro.rar


Two pics :D
(https://dl.dropboxusercontent.com/u/5052546/PC/Proyecto%20Teclado%202/finwiring1.jpg)

(https://dl.dropboxusercontent.com/u/5052546/PC/Proyecto%20Teclado%202/finwiring2.jpg)
Title: Re: TMK keyboard firmware
Post by: DreymaR on Mon, 23 January 2017, 02:58:24
Any news on using the new Teensy 3.6 with TMK? It's such a beast from the looks of it, with lots and lots of juicy memory for macros. And it has an on-board USB host!  :cool:
Title: Re: TMK keyboard firmware
Post by: philipVick on Tue, 31 January 2017, 14:02:54
Guys,  I definitely need some help.

I decided to build a custom keyboard, but I am not able to generate the hex file to flash into the teensy 2.0.

When I execute 'make gelo' from the shell, I have the following error message:

.Making gelo with keymap default

avr-gcc (GCC) 4.9.3
Copyright (C) 2015 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.

Compiling: keyboards/gelo/gelo.c                                                                   /usr/local/Cellar/avr-gcc/4.9.3/avr/include/util/delay.h: In function '_delay_ms':
<command-line>:0:7: error: 'UL' undeclared (first use in this function)
<command-line>:0:7: note: each undeclared identifier is reported only once for each function it appears in
/usr/local/Cellar/avr-gcc/4.9.3/avr/include/util/delay.h: In function '_delay_us':
<command-line>:0:7: error: 'UL' undeclared (first use in this function)
 [ERRORS]
 |
 |
 |
make[1]: *** [.build/obj_gelo_default/keyboards/gelo/gelo.o] Error 1
make: *** [gelo] Error 1

Here the Makefile
"
QUANTUM_DIR=../../quantum

ifndef MAKEFILE_INCLUDED
   include ../../Makefile
endif

"
rule.mk :

ARCH = BOARD_TEENSY2
MCU = atmega32u4
F_USB = $(F_CPU)

gelo .c
#include "gelo.h"

void matrix_init_kb(void) {

   matrix_init_user();
}
 
gelo .h
#ifndef GELO_H
#define GELO_H

#include "quantum.h"

#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,  \
   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  \
) \
{ \
   { k00, k01, k02, k03, k04, k05,   k06,     k07,    k08,    k09,    k0a, k0b, k0c, k0d }, \
   { k10, k11, k12, k13, k14, k15,   KC_NO, KC_NO,  k16,   k17,    k18, k19, k1a, k1b }, \
   { k20, k21, k22, k23, k24, k25,   k26,   k27,    k28,    k29,    k2a, k2b, k2c, k2d }, \
   { k30, k31, k32, k33, k34, KC_NO, k35,   k36,    k37,    KC_NO,    k38, k39, k3a, k3b }  \
}
#endif

I have no idea how to define this UL variable.
Title: Re: TMK keyboard firmware
Post by: Tactile on Tue, 31 January 2017, 14:06:21
Guys,  I definitely need some help.

I decided to build a custom keyboard, but I am not able to generate the hex file to flash into the teensy 2.0.

When I execute 'make gelo' from the shell, I have the following error message:

.Making gelo with keymap default

avr-gcc (GCC) 4.9.3
Copyright (C) 2015 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.

Compiling: keyboards/gelo/gelo.c                                                                   /usr/local/Cellar/avr-gcc/4.9.3/avr/include/util/delay.h: In function '_delay_ms':
<command-line>:0:7: error: 'UL' undeclared (first use in this function)

...

I have no idea how to define this UL variable.

Have you installed avr-libc?
Title: Re: TMK keyboard firmware
Post by: philipVick on Tue, 31 January 2017, 15:40:13
yes, I did.
Title: Re: TMK keyboard firmware
Post by: kentt on Mon, 06 February 2017, 21:50:23
hasu,

I bought your controller from 1upkeyboards.  I'm assuming it will not work with the new hhkb bluetooth version that came out.  Is that correct?
Title: Re: TMK keyboard firmware
Post by: hasu on Mon, 06 February 2017, 22:17:32
hasu,

I bought your controller from 1upkeyboards.  I'm assuming it will not work with the new hhkb bluetooth version that came out.  Is that correct?

Hi,
That is correct. If you have any other question specific to HHKB Alt controller this thread is proper.
https://geekhack.org/index.php?topic=71517.0

Thanks
Title: HHKB-JP settings on OSX
Post by: rsadek on Sun, 12 February 2017, 14:05:53
I'm working to set up an HHKB-JP w/ Hasu's controller and am confused by the OS settings. It lets me set the input source to US or JP, and under JP there are several options. The board appears to do nothing unless I set these properly. But what do these different settings mean, and how do they relate to how I configure my keymap? For example, if I want to use Hasu's keymap, what is the best OS setting to use?


-R
Title: Re: TMK keyboard firmware
Post by: hasu on Sun, 12 February 2017, 17:06:50
Just use US layout, it is one and real masta race! heh
In fact I use US layout for my keyboards, not JP one.

You may need to select JP layout only if you want to use JIS specific keys in Japanese input method.
Title: Re: TMK keyboard firmware
Post by: rsadek on Sun, 12 February 2017, 20:51:06
Just use US layout, it is one and real masta race! heh
In fact I use US layout for my keyboards, not JP one.

You may need to select JP layout only if you want to use JIS specific keys in Japanese input method.

When I set it to US, I don't get any output from the board.
Title: Re: TMK keyboard firmware
Post by: hasu on Sun, 12 February 2017, 20:56:36
Just use US layout, it is one and real masta race! heh
In fact I use US layout for my keyboards, not JP one.

You may need to select JP layout only if you want to use JIS specific keys in Japanese input method.

When I set it to US, I don't get any output from the board.

Hmm, I never experienced that. Which os are you using?
And how did you set layout? Screen shots would be useful to explain your settings.


EDIT: Most of keys on Japanese keyboard still should work even with US or any other layouts, except for Japanese specific keys like henkan, muhenkan, kana(extra keys on bottom row), keys on left of Backspace and left of Right Shift.
https://en.wikipedia.org/wiki/File:KB_Japanese.svg

EDIT: Ah, found subject of your post says OSX. I don't have any OSX unfortunately and don't know much about how OSX handle keyboard layout. I confirmed Linux and WIndows have no problem there.
Title: Re: TMK keyboard firmware
Post by: rsadek on Tue, 14 February 2017, 09:09:55
Just use US layout, it is one and real masta race! heh
In fact I use US layout for my keyboards, not JP one.

You may need to select JP layout only if you want to use JIS specific keys in Japanese input method.

When I set it to US, I don't get any output from the board.

Hmm, I never experienced that. Which os are you using?
And how did you set layout? Screen shots would be useful to explain your settings.


EDIT: Most of keys on Japanese keyboard still should work even with US or any other layouts, except for Japanese specific keys like henkan, muhenkan, kana(extra keys on bottom row), keys on left of Backspace and left of Right Shift.
https://en.wikipedia.org/wiki/File:KB_Japanese.svg (https://en.wikipedia.org/wiki/File:KB_Japanese.svg)

EDIT: Ah, found subject of your post says OSX. I don't have any OSX unfortunately and don't know much about how OSX handle keyboard layout. I confirmed Linux and WIndows have no problem there.


I am a big dummy. I wasn't waiting long enough for the board to boot up. In fact, I do receive output from the board and everything is just fine with it. So now I can ask you the questions I really want to know about configuring the keymap.


I would like to make the key left of space bar mean that LGUI and LALT have been pressed. What is the correct way to do this? Can it be done so that 3 keys are pressed (LGUI, LALT, LCTRL)?


-R
Title: Re: TMK keyboard firmware
Post by: a-c on Tue, 14 February 2017, 10:26:15

I would like to make the key left of space bar mean that LGUI and LALT have been pressed. What is the correct way to do this? Can it be done so that 3 keys are pressed (LGUI, LALT, LCTRL)?


-R

ACTION_MODS

https://github.com/tmk/tmk_core/blob/master/doc/keymap.md#213-multiple-modifiers (https://github.com/tmk/tmk_core/blob/master/doc/keymap.md#213-multiple-modifiers)
Title: Re: TMK keyboard firmware
Post by: xandwich on Thu, 23 February 2017, 11:49:09
Just compiled onekey_lufa and threw it on a 32u4 pro micro clone, and I've got a question:  lsusb will show the vendor/device IDs that I set in config.h, but not the manufacturer/product strings.  I've tried changing the lufa/descriptor.c lines where ManufacturerString.UnicodeString and ProductString.UnicodeString are specified, but can't get anything to show up in my lsusb output.

Is this a known bug or am I just doing something wrong? 
Title: Re: TMK keyboard firmware
Post by: xandwich on Thu, 23 February 2017, 12:55:58
Problem solved (http://www.avrfreaks.net/comment/1263321#comment-1263321):  lsusb uses a builtin table to look up vendor/product strings.  usb-devices gives the correct values.
Title: Re: TMK keyboard firmware
Post by: tjweir on Mon, 27 February 2017, 19:18:24
I just wanted to thank @hasu for TMK. I just finished a hand-made board and TMK made it simple to get working.

It's a split spacebar, green Alps, KMAC Mini inspired board.

Thanks @hasu!

 (http://i.imgur.com/bRtXNMp.jpg)
Title: Re: TMK keyboard firmware
Post by: Ngt on Sun, 02 April 2017, 09:53:57
Hello everyone!


I read through the Github documentation for TMK and it states that GH60 rev.A and rev.B have been both tested and I wonder if rev.C is compatible as well. Is it?


I feel like I already asked this here but I can't find it though. Please, forgive me if that's a duplicate.


Thanks for your time.
Title: Re: TMK keyboard firmware
Post by: Tactile on Sun, 02 April 2017, 12:14:39
Hello everyone!


I read through the Github documentation for TMK and it states that GH60 rev.A and rev.B have been both tested and I wonder if rev.C is compatible as well. Is it?


I feel like I already asked this here but I can't find it though. Please, forgive me if that's a duplicate.


Thanks for your time.

It works on the GH60 Rev C for programming the keyboard but I had trouble controlling the LEDs. I mean the LEDs on the WASD group, the arrow key group in the lower right corner, the FN key LED on the split right shift, etc.. I wanted to control these LEDs for layer indicators, Num Lock status, and stuff like that, and I had problems figuring out how to control them so I went with QMK instead. I'm not saying you can't do that in TMK, I'm saying it was easier for a dummy like me to do it in QMK.

As far as programming the keys, adding layers, etc. that all works perfectly as far as I can tell.
Title: Re: TMK keyboard firmware
Post by: Ngt on Sun, 02 April 2017, 12:44:48
Hello everyone!


I read through the Github documentation for TMK and it states that GH60 rev.A and rev.B have been both tested and I wonder if rev.C is compatible as well. Is it?


I feel like I already asked this here but I can't find it though. Please, forgive me if that's a duplicate.


Thanks for your time.

It works on the GH60 Rev C for programming the keyboard but I had trouble controlling the LEDs. I mean the LEDs on the WASD group, the arrow key group in the lower right corner, the FN key LED on the split right shift, etc.. I wanted to control these LEDs for layer indicators, Num Lock status, and stuff like that, and I had problems figuring out how to control them so I went with QMK instead. I'm not saying you can't do that in TMK, I'm saying it was easier for a dummy like me to do it in QMK.

As far as programming the keys, adding layers, etc. that all works perfectly as far as I can tell.


Great thank you for your clarification.
Title: Re: TMK keyboard firmware
Post by: leizzer on Tue, 04 April 2017, 14:40:57
Hello,

I did a desktop app to generate keymaps for homemade keyboards and I'm sharing it to give something back to the community.

Github repo: https://github.com/leizzer/electroboard (https://github.com/leizzer/electroboard)

Here is the post with more info https://geekhack.org/index.php?topic=88700.0 (https://geekhack.org/index.php?topic=88700.0)

Cheers~
Title: Re: TMK keyboard firmware
Post by: comblups on Sat, 15 April 2017, 10:21:08
I wanted to change the equals sign on the Numpad of an ISO AEK2 to ».«, so I changed the file converter/adb_usb/keymap_iso.c to this (don’t mind the FN0):

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


const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
    KEYMAP_EXT_ISO(
    ESC, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12,           PSCR,SLCK,PAUS,                   FN0,
    GRV, 1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   MINS,EQL, BSPC,     INS, HOME,PGUP,    NLCK,DOT, PSLS,PAST,
    TAB, Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,   LBRC,RBRC,ENT,      DEL, END, PGDN,    P7,  P8,  P9,  PMNS,
    LCAP,A,   S,   D,   F,   G,   H,   J,   K,   L,   SCLN,QUOT,NUHS,                             P4,  P5,  P6,  PPLS,
    LSFT,NUBS,Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, SLSH,     RSFT,          UP,           P1,  P2,  P3,
    LCTL,LALT,RALT,          SPC,                               RGUI,RCTL,     LEFT,DOWN,RGHT,    P0,       PDOT,PENT
    ),
};

That works fine, but now I have an M0118 (ISO) as well and wanted to use the Power Key as FN-Key and the keys 1 through 0 and the next two as F-Keys, F1 to F12, and swap Arrow Down and Arrow Right to come closer to a T-Nav, so I did this:

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


const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
    KEYMAP_EXT_ISO(
    ESC, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12,           PSCR,SLCK,PAUS,                   FN0,
    GRV, 1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   MINS,EQL, BSPC,     INS, HOME,PGUP,    NLCK,DOT, PSLS,PAST,
    TAB, Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,   LBRC,RBRC,ENT,      DEL, END, PGDN,    P7,  P8,  P9,  PMNS,
    LCAP,A,   S,   D,   F,   G,   H,   J,   K,   L,   SCLN,QUOT,NUHS,                             P4,  P5,  P6,  PPLS,
    LSFT,NUBS,Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, SLSH,     RSFT,          UP,           P1,  P2,  P3,
    LCTL,LALT,RALT,          SPC,                               RGUI,RCTL,     LEFT,DOWN,RGHT,    P0,       PDOT,PENT
    ),
    KEYMAP_M0118_ISO(
    FN0,
    ESC, 1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   MINS,EQL, BSPC,     NLCK,DOT, PSLS,PAST,
    TAB, Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,   LBRC,RBRC, ENT,     P7,  P8,  P9,  PMNS,
    LCAP,A,   S,   D,   F,   G,   H,   J,   K,   L,   SCLN,QUOT,NUHS,          P4,  P5,  P6,  PPLS,
    LSFT,NUBS,Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, SLSH,RSFT,  UP,     P1,  P2,  P3,
    LCTL,LALT,RALT,          SPC,                          LEFT,DOWN,RGHT,     P0,       PDOT,PENT
    ),
    KEYMAP_M0118_ISO(
    FN0,
    TRNS,F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12, 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,TRNS,TRNS,     TRNS,TRNS,TRNS,
    TRNS,TRNS,TRNS,         TRNS,                          TRNS,TRNS,TRNS,     TRNS,TRNS     ,TRNS
    ),
};

const action_t PROGMEM fn_actions[] = {
    ACTION_LAYER_MOMENTARY(1)
};

When I hit the Power Key, everything’s a mess (a lot of keys don’t do anything, the others produce wrong characters) and I have to unplug the Teensy and plug it back in again. Apart from that, the arrow keys are not swapped. What am I doing wrong?
Title: Re: TMK keyboard firmware
Post by: hasu on Sat, 15 April 2017, 14:55:37
Power key is magic key in ADB converter, so you can remap it very limitedly.
https://github.com/tmk/tmk_keyboard/tree/master/converter/adb_usb#magic-command

Remove this line to disable magic key, your keymap will work.
https://github.com/tmk/tmk_keyboard/blob/master/converter/adb_usb/config.h#L55

Title: Re: TMK keyboard firmware
Post by: comblups on Sat, 15 April 2017, 16:39:11
That doesn’t seem to work, I get errors in the make process.

Using the Power Key isn’t very comfortable, so I changed the keymap:

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


const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
    KEYMAP_EXT_ISO(
    ESC, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12,           PSCR,SLCK,PAUS,                   FN0,
    GRV, 1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   MINS,EQL, BSPC,     INS, HOME,PGUP,    NLCK,DOT, PSLS,PAST,
    TAB, Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,   LBRC,RBRC,ENT,      DEL, END, PGDN,    P7,  P8,  P9,  PMNS,
    LCAP,A,   S,   D,   F,   G,   H,   J,   K,   L,   SCLN,QUOT,NUHS,                             P4,  P5,  P6,  PPLS,
    LSFT,NUBS,Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, SLSH,     RSFT,          UP,           P1,  P2,  P3,
    LCTL,LALT,RALT,          SPC,                               RGUI,RCTL,     LEFT,DOWN,RGHT,    P0,       PDOT,PENT
    ),
    KEYMAP_M0118_ISO(
    FN0,
    ESC, 1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   MINS,EQL, BSPC,     FN3, DOT, PSLS,PAST,
    FN1, Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,   LBRC,FN2, ENT,      P7,  P8,  P9,  PMNS,
    LCAP,A,   S,   D,   F,   G,   H,   J,   K,   L,   SCLN,QUOT,NUHS,          P4,  P5,  P6,  PPLS,
    LSFT,NUBS,Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, SLSH,RSFT,  UP,     P1,  P2,  P3,
    LCTL,LALT,RALT,          SPC,                          LEFT,DOWN,RGHT,     P0,       PDOT,PENT
    ),
    KEYMAP_M0118_ISO(
    FN0,
    TRNS,F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12, TRNS,     FN3, TRNS,TRNS,TRNS,
    FN1, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,FN2, TRNS,     INS, HOME,PGUP,TRNS,
    TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,          DEL, END, PGDN,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 action_t PROGMEM fn_actions[] = {
    ACTION_MODS_KEY(MOD_LCTL | MOD_LALT, KC_DEL),
    ACTION_LAYER_TAP_KEY(1, KC_TAB),
    ACTION_LAYER_TAP_KEY(1, KC_RBRC),
    ACTION_LAYER_TOGGLE(1),
};

But that doesn’t work, FN1, FN2 and FN3 are being ignored. The numlock key is still a numlock, the arrow keys are not swapped, only PEQL gives DOT. I think, only the first layer is in use. Do I have to define two seperate const uint8_t PROGMEM keymaps, one for each keyboard model?
Title: Re: TMK keyboard firmware
Post by: hasu on Sat, 15 April 2017, 17:39:59
That doesn’t seem to work, I get errors in the make process.

Ah, coment out this line, instead of removing line in config.h
https://github.com/tmk/tmk_keyboard/blob/master/converter/adb_usb/Makefile#L77

Layer0 defined with KEYMAP_EXT_ISO() is used regardless of which keyboard you are using. You have to place FN3 on layer0(KEYMAP_EXT_ISO) even if your keyboard is M0118.

You can't have two different keymaps for both AEK and M0118 in one firmware.
Title: Re: TMK keyboard firmware
Post by: comblups on Sat, 15 April 2017, 18:18:31
Does that mean, I can’t swap the arrow keys on the M0118 without swapping them on the AEKII?

PS: I just noticed, the right most column on the M0118 from top to bottom is *, +, -, Enter, but *, -, +, Enter on the AEKII. Apple really liked to change layouts …

PPS: And Enter has to be one row down, next to NUHS (hash sign). This is what I’m using at the moment, works perfect:

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


const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
    KEYMAP_M0118_ISO(
    FN0,
    ESC, 1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   MINS,EQL, BSPC,     FN3, DOT, PSLS,PAST,
    FN1, Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,   LBRC,FN2,           P7,  P8,  P9,  PPLS,
    LCAP,A,   S,   D,   F,   G,   H,   J,   K,   L,   SCLN,QUOT,NUHS,ENT,      P4,  P5,  P6,  PMNS,
    LSFT,NUBS,Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, SLSH,RSFT,  UP,     P1,  P2,  P3,
    LCTL,LALT,RALT,          SPC,                          LEFT,DOWN,RGHT,     P0,       PDOT,PENT
    ),
    KEYMAP_M0118_ISO(
    FN0,
    TRNS,F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12, TRNS,     FN3, TRNS,TRNS,TRNS,
    FN1, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,FN2,           INS, HOME,PGUP,TRNS,
    TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,      DEL, END, PGDN,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 action_t PROGMEM fn_actions[] = {
    ACTION_MODS_KEY(MOD_LCTL | MOD_LALT, KC_DEL),
    ACTION_LAYER_TAP_KEY(1, KC_TAB),
    ACTION_LAYER_TAP_KEY(1, KC_RBRC),
    ACTION_LAYER_TOGGLE(1),
};

Arrows swapped, F-keys and proper nav cluster instead of deactivated numpad.

PPPS: No, there’s one flaw, of course …

This is better:

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


const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
    KEYMAP_M0118_ISO(
    FN0,
    ESC, 1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   MINS,EQL, BSPC,     FN1, DOT, PSLS,PAST,
    FN2, Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,   LBRC,FN3,           P7,  P8,  P9,  PPLS,
    LCAP,A,   S,   D,   F,   G,   H,   J,   K,   L,   SCLN,QUOT,NUHS,ENT,      P4,  P5,  P6,  PMNS,
    LSFT,NUBS,Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, SLSH,RSFT,  UP,     P1,  P2,  P3,
    LCTL,LALT,RALT,          SPC,                          LEFT,DOWN,RGHT,     P0,       PDOT,PENT
    ),
    KEYMAP_M0118_ISO(
    FN0,
    TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,     FN1, TRNS,TRNS,TRNS,
    FN2, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,FN3,           INS, HOME,PGUP,TRNS,
    TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,     DEL, END, PGDN,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
    ),
    KEYMAP_M0118_ISO(
    FN0,
    TRNS,F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12, TRNS,     TRNS,TRNS,TRNS,TRNS,
    FN2, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,FN3,           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
    ),
};

const action_t PROGMEM fn_actions[] = {
    ACTION_MODS_KEY(MOD_LCTL | MOD_LALT, KC_DEL),
    ACTION_LAYER_TOGGLE(1),
    ACTION_LAYER_TAP_KEY(2, KC_TAB),
    ACTION_LAYER_TAP_KEY(2, KC_RBRC),
};
Title: Re: TMK keyboard firmware
Post by: Bucake on Mon, 08 May 2017, 13:11:47
howdy,

i would really appreciate some direction / feedback on my first attempt at making fn_functions.
so far, i've just been going through the documentation, used google, and used existing files as references.
this is for the hhkb with hasu's alt controller.


to keep things small for now, i'm trying to create a key(function) that acts as a toggle for a small, simple loop:
the idea is to press an fn key and have it repeat a keycode at a given rate, and when the button is pressed again i want this loop to stop.
by concept it's obviously very simple, but as a newb and possibly idiot, i'm currently not having an easy time :<

below i've pasted my current keymap.c (removed the layers for readability).
in action_function i've made two loops and below that, the function id's that call the loops.


- mostly, i just want to know if i'm on the right track at all?
- are both functions possible, or is wait_ms not something that can be used like this (or at all)?
- is it necessary to #include <stdbool.h> in this file in order to use bool?
- should it be void bool?


i'm sure i am doing a lot wrong, sorry about that

Code: [Select]
#include <stdbool.h>
#include "keymap_common.h"

const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
// layers removed
};

enum function_id
{
SPAM_A,
SPAM_B,
};

static uint16_t loopa_start;

void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) {

bool spama_on = false;

void aloop() {
while spama_on = true {
sendchar(KC_A);
loopa_start = timer_read();
while spama_on = true {
if (timer_elapsed(loopa_start) < 1000) {
// do nothing
} else {
break;
}
}
break;
}
break;
}

bool spamb_on = false;

void bloop() {
do {
sendchar(KC_B);
wait_ms(1000);
} while spamb_on = true;
break;
}

switch (id) {
case SPAM_A:
if spama_on = false {
spama_on = true;
aloop();
} else {
spama_on = false;
}
break;
case SPAM_B:
if spamb_on = false {
spamb_on = true;
bloop();
} else {
spamb_on = false;
}
break;

}
}

const action_t PROGMEM fn_actions[] = {
[0] = ACTION_LAYER_MOMENTARY(1), // F1 - F8 Left
[1] = ACTION_LAYER_MOMENTARY(2), // F9 - F12 and Navigation Left
[2] = ACTION_LAYER_MOMENTARY(3), // Numpad Right
[3] = ACTION_FUNCTION(SPAM_A), // Spam A
[4] = ACTION_FUNCTION(SPAM_B), // Spam B
};
Title: Re: TMK keyboard firmware
Post by: hasu on Tue, 09 May 2017, 00:27:20
To implement key repeat in firmeare is not so simple. With USB keyboard key repetition should be handled on host and keyboard doesn't have the function generally so you will need some hassles.

TMK also doesn't handle key repetition and you get only two events when press and release  a key and no event during holding it. And basically you cannot use loop code in  action_function() it will stop all other keyboard tasks and make your keyboard unresponsive.

You can probably use timer interrupt for your purpose instead of loop, controller has unused timer, iirc. Google AVR timer and consult with datasheet to learn.
Title: Re: TMK keyboard firmware
Post by: sadchi on Sun, 14 May 2017, 08:40:32
SOLVED
Title: Re: TMK keyboard firmware
Post by: mrbishop on Fri, 19 May 2017, 11:12:01
probably already been answered but i'll ask anyway . i have a TMK compatible board that i want the led back light to be on all the time.  how and where do i program that?
Title: Re: TMK keyboard firmware
Post by: hasu on Fri, 19 May 2017, 17:48:26
probably already been answered but i'll ask anyway . i have a TMK compatible board that i want the led back light to be on all the time.  how and where do i program that?


No universal answer and it depends on keyboard design and firmware writer but I guess you can use these hooks.
https://github.com/tmk/tmk_keyboard/blob/master/tmk_core/common/hook.h#L28-L34

And see this also.
https://github.com/tmk/tmk_keyboard/issues/304
Title: Re: TMK keyboard firmware
Post by: hasu on Tue, 30 May 2017, 20:47:38
Now fixed Modifier/Layer key stuck problem finally.
https://github.com/tmk/tmk_keyboard/tree/master/tmk_core#20170530

See this wiki entry. https://github.com/tmk/tmk_keyboard/wiki/FAQ-Keymap#modifierlayer-stuck If you need old keymap behaviour for some reason define NO_TRACK_KEY_PRESS in your config.h. This is virtually equivalent to QMK's PREVENT_STUCK_MODIFIERS. https://github.com/qmk/qmk_firmware/pull/182

With this fix the biggest limitaiotn of TMK keymap were removed. Modifier and layer switch keys cannot be stuck virtually even if you want to have very strange keymap :D You have to compile to get this fix worked, keymap editor is not updated yet.

Report if you have any problem with this fix.
Title: Re: TMK keyboard firmware
Post by: tapinos on Sun, 25 June 2017, 05:27:43
Hi,
I've almost finished programming my Minorca and everything is (sort of) working apart from the backslash (i.e. the \| character). Before it drives me completely crazy, I hope you could help me...
I'm using my Minorca attached to a MacBook Air running macOS Sierra 10.12.5. When I attached the keyboard the first time, I tried to have it recognized but the process failed: it asked me to press the key next to the left shift and it worked but then it asked me to press the key next to the right shift and it didn't work. So I manually chose the ISO layout given that I'm Italian.
In the keymap_minorca.c file, I tried the following keycodes with no success:

- NUBS prints <
- BSLS prints ù
- COMM prints ,

Anyway, here it's the complete file:

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

const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
    /* 0: default
* ,-----------------------------------------------.
* |ESC|  Q|  W|  E|  R|  T|  Y|  U|  I|  O|  P|BPS|
    * |-----------------------------------------------|
    * |TAB |  A|  S|  D|  F|  G|  H|  J|  K|  L|   ENT|
    * |-----------------------------------------------|
    * |LSFT  |  Z|  X|  C|  V|  B|  N|  M|  ,|  .| RSF|
    * `-----------------------------------------------'
    * |LCTL|LALT|LGUI|SPC     |     FN2| FN3|   -| FN1|
    * `-----------------------------------------------'
    */
   
KEYMAP(ESC,   Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P, BSPC, \
TAB,   A,   S,   D,   F,   G,   H,   J,   K,   L,   ENT, \
LSFT,  Z,   X,   C,   V,   B,    N,   M,   COMM,DOT, RSFT, \
LCTL,  LALT, LGUI,   SPC,     FN2,      FN3, SLSH, FN1),
   
    /* 1: arrow + numfunc (FN1)
* ,-----------------------------------------------.
* |\  |  1|  2|  3|  4|  5|  6|  7|  8|  9|  0|  '|
    * |-----------------------------------------------|
    * |TRN |TRN|TRN|TRN|TRN|INS|HOM|PGU|TRN|UP |   ENT|
    * |-----------------------------------------------|
    * |<     |TRN|TRN|TRN|TRN|DEL|END|PGD|LFT|RGH| RSF|
    * `-----------------------------------------------'
    * |TRN |TRN |TRN |TRN     |     TRN| TRN| DWN| FN1|
    * `-----------------------------------------------'
    */
   
KEYMAP(NUBS,   1,   2,   3,   4,   5,   6,   7,   8,   9,   0, MINS, \
TRNS,  TRNS,TRNS,TRNS,TRNS,INS,HOME,PGUP,TRNS,UP, ENT, \
NUBS,  TRNS, TRNS, TRNS, TRNS, DEL,  END, PGDN, LEFT,RIGHT, RSFT, \
TRNS,   TRNS,TRNS,    TRNS,         TRNS,      TRNS, DOWN, FN1),

    /* 2: italian accents (FN2)
* ,-----------------------------------------------.
* |TRN|TRN|TRN|èé |TRN|TRN|TRN|ù  |ì  |ò  |TRN|TRN|
    * |-----------------------------------------------|
    * |TRN |à  |TRN|TRN|TRN|TRN|TRN|TRN|TRN|TRN|   TRN|
    * |-----------------------------------------------|
    * |TRN   |TRN|TRN|TRN|TRN|TRN|TRN|TRN|TRN|TRN| TRN|
    * `-----------------------------------------------'
    * |TRN |TRN |TRN |TRN     |     FN2| TRN| TRN| FN1|
    * `-----------------------------------------------'
    */

KEYMAP(TRNS, TRNS, TRNS, LBRC,TRNS,TRNS,TRNS,BSLS,EQL,SCLN,TRNS,TRNS, \
TRNS, QUOT,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,  \
TRNS,TRNS,TRNS,TRNS, TRNS,TRNS,   TRNS,TRNS,TRNS,TRNS, TRNS, \
TRNS,  TRNS,TRNS,   TRNS,      FN2,  TRNS, TRNS, FN1),

    /* 3: layout (FN3)
* ,-----------------------------------------------.
* |TRN|PRV|PLY|NXT|MU |VD |VU |TRN|TRN|ì  |TRN|PWR|
    * |-----------------------------------------------|
    * |TRN |TRN|TRN|LSF|RSF|PAU|TRN|TRN|è  |+  |   TRN|
    * |-----------------------------------------------|
    * |TRN   |TRN|TRN|TRN|TRN|TRN|TRN|ò  |à  |ù  | TRN|
    * `-----------------------------------------------'
    * |TRN |TRN |TRN |TRN     |     TRN| FN3| TRN| TRN|
    * `-----------------------------------------------'
    */

KEYMAP(TRNS, MRWD, MPLY, MFFD, MUTE, VOLD, VOLU, TRNS, TRNS, EQL, TRNS, PWR, \
TRNS, TRNS,TRNS,LSFT,RSFT,PAUS,TRNS,TRNS,LBRC,RBRC,TRNS,  \
TRNS,TRNS,TRNS,TRNS, TRNS,TRNS,   TRNS,SCLN,QUOT,BSLS, TRNS, \
TRNS,  TRNS,TRNS,   TRNS,      TRNS,  FN3, TRNS, TRNS),
};
const uint16_t PROGMEM fn_actions[] = {
    [1] = ACTION_LAYER_MOMENTARY(1),  // toggle arrow + numfunc overlay
    [2] = ACTION_LAYER_MOMENTARY(2),  // to italian accents
    [3] = ACTION_LAYER_MOMENTARY(3),  // to Layout selector
};

Any advice?

Thanks in advance!
Title: Re: TMK keyboard firmware
Post by: TalkingTree on Sun, 25 June 2017, 05:43:20
everything is (sort of) working apart from the backslash (i.e. the \| character).
[...]
- NUBS prints <
- BSLS prints ù
- COMM prints ,
Try GRV.
Title: Re: TMK keyboard firmware
Post by: tapinos on Sun, 25 June 2017, 10:28:53
It worked! Thanks a lot! It was driving me crazy!
Title: Re: TMK keyboard firmware
Post by: Hypersphere on Sun, 25 June 2017, 15:49:41
Now fixed Modifier/Layer key stuck problem finally.
https://github.com/tmk/tmk_keyboard/tree/master/tmk_core#20170530

See this wiki entry. https://github.com/tmk/tmk_keyboard/wiki/FAQ-Keymap#modifierlayer-stuck If you need old keymap behaviour for some reason define NO_TRACK_KEY_PRESS in your config.h. This is virtually equivalent to QMK's PREVENT_STUCK_MODIFIERS. https://github.com/qmk/qmk_firmware/pull/182

With this fix the biggest limitaiotn of TMK keymap were removed. Modifier and layer switch keys cannot be stuck virtually even if you want to have very strange keymap :D You have to compile to get this fix worked, keymap editor is not updated yet.

Report if you have any problem with this fix.
Hasu, thanks so much for your ongoing dedication to this great project!
Title: Re: TMK keyboard firmware
Post by: xauser on Wed, 28 June 2017, 12:02:17
I face a serious problem with my latest tmk build. TMK crashes for me on my production keyboard and I have to reconnect usb connection. I'm not yet sure what is causing my keymap/firmware to crash but I can reproduce it.

* Use a keymap with space fn
* Press and hold space

In my terminal app (urxvt) I don't get a single whitespace nor repeating spaces
In vi I get some whitespaces and then an usb disconnect with keyboard booting to bootloader
Even on windows in vi I get the usb disconnect.

I don't have more debug information as of yet but my daily workflow is affected by this bug so I have to find
a workaround soon. Will revert back in git history as a next step.
Title: Re: TMK keyboard firmware
Post by: hasu on Wed, 28 June 2017, 22:04:14
I face a serious problem with my latest tmk build. TMK crashes for me on my production keyboard and I have to reconnect usb connection. I'm not yet sure what is causing my keymap/firmware to crash but I can reproduce it.

* Use a keymap with space fn
* Press and hold space

In my terminal app (urxvt) I don't get a single whitespace nor repeating spaces
In vi I get some whitespaces and then an usb disconnect with keyboard booting to bootloader
Even on windows in vi I get the usb disconnect.

I don't have more debug information as of yet but my daily workflow is affected by this bug so I have to find
a workaround soon. Will revert back in git history as a next step.

I don't have problem like that so far on my HHKB Alt at least. I've also used kindof space fn daily.
let us know if you find clue.

Title: Re: TMK keyboard firmware
Post by: xauser on Thu, 29 June 2017, 11:29:19
I did some more tests today and identified commit

commit ba2883fd9ab040fc670ad729e6cddd4c67c8188c
Author: tmk <hasu@tmk-kbd.com>
Date:   Fri May 26 12:03:30 2017 +0900

    core: Fix for stuck key problem #441

being the culprit. The commit message says ....

Define NO_TRACK_KEY_PRESS to get old behaviour

And doing this gives me normal behaviour back without crashes.

For the moment I will test this setup to prove it's really stable for my daily work.
Title: Re: TMK keyboard firmware
Post by: hasu on Thu, 29 June 2017, 16:26:04
I did some more tests today and identified commit

commit ba2883fd9ab040fc670ad729e6cddd4c67c8188c
Author: tmk <hasu@tmk-kbd.com>
Date:   Fri May 26 12:03:30 2017 +0900

    core: Fix for stuck key problem #441

being the culprit. The commit message says ....

Define NO_TRACK_KEY_PRESS to get old behaviour

And doing this gives me normal behaviour back without crashes.

For the moment I will test this setup to prove it's really stable for my daily work.

Ah, good catch! I thought this #441 fix doesn't affect most of users... but a few still suffer.
With this fix builtin keymap actions should work as before but user defined actions may not work.

Can you post your keymap when you get time? I'm interested.
Title: Re: TMK keyboard firmware
Post by: Eugene94 on Sat, 08 July 2017, 12:38:56
Hello everyone! I have recently bought a HHKB Type-S along with a USB-USB Converter. I would like to have my "Fn" key switched with my "Caps" key, but I cannot seem to find where the "Fn" key is located on the TMK Keymap Editor...
[attachimg=1]
This is a shortened link https://goo.gl/tNGHBK (https://goo.gl/tNGHBK) to the TMK Keymap Editor with my desired layout. I hope there is a way to configure the layout that would switch the keys :thumb:
Title: Re: TMK keyboard firmware
Post by: hasu on Sat, 08 July 2017, 17:23:17
Hi Eugene94,
First, you cannot remap 'Fn' key with USB-USB converter because the key doesn't send out keycode. This is one of limitation of the converter described in first post, check 'Limitation' section. https://geekhack.org/index.php?topic=69169.0
You need HHKB Alt controller to remap 'Fn' key. https://geekhack.org/index.php?topic=12047.0

Second, use 'L1' action to validate Layer 1, it is located in 'Layer Switching and etc.' tab of Keymap Editor.


Try this. I'd recommed to retain F1-F12, navigation and arrow key on Layer 0 to make original 'Fn' usable. With this keymap you can still use Fn+L for PageUp for example.
https://goo.gl/3CXUZf
Title: Re: TMK keyboard firmware
Post by: Eugene94 on Sat, 08 July 2017, 18:35:32
Hi Eugene94,
First, you cannot remap 'Fn' key with USB-USB converter because the key doesn't send out keycode. This is one of limitation of the converter described in first post, check 'Limitation' section. https://geekhack.org/index.php?topic=69169.0
You need HHKB Alt controller to remap 'Fn' key. https://geekhack.org/index.php?topic=12047.0

Second, use 'L1' action to validate Layer 1, it is located in 'Layer Switching and etc.' tab of Keymap Editor.


Try this. I'd recommed to retain F1-F12, navigation and arrow key on Layer 0 to make original 'Fn' usable. With this keymap you can still use Fn+L for PageUp for example.
https://goo.gl/3CXUZf

This worked perfectly! Thank you. I am also curious what difference does it make to make a key "NO" or "TRNS"?
Title: Re: TMK keyboard firmware
Post by: hasu on Sun, 09 July 2017, 01:38:18
Hi Eugene94,
First, you cannot remap 'Fn' key with USB-USB converter because the key doesn't send out keycode. This is one of limitation of the converter described in first post, check 'Limitation' section. https://geekhack.org/index.php?topic=69169.0
You need HHKB Alt controller to remap 'Fn' key. https://geekhack.org/index.php?topic=12047.0

Second, use 'L1' action to validate Layer 1, it is located in 'Layer Switching and etc.' tab of Keymap Editor.


Try this. I'd recommed to retain F1-F12, navigation and arrow key on Layer 0 to make original 'Fn' usable. With this keymap you can still use Fn+L for PageUp for example.
https://goo.gl/3CXUZf

This worked perfectly! Thank you. I am also curious what difference does it make to make a key "NO" or "TRNS"?

Great. you can refer this for 'TRNS' and layer precedence.
https://github.com/tmk/tmk_keyboard/blob/master/tmk_core/doc/keymap.md#02-layer-precedence-and-transparency
Title: Re: TMK keyboard firmware
Post by: pabile on Sun, 09 July 2017, 23:00:23
hi hasu & GH. i created firmware yesterday using the online editor. it has four layers. flashed to alps64 and work fine for a several minutes. after i restart my pc, the default layer became L3 (4th layer). i tried to reflash the firmware but still same result. i tried to generate another copy several times but still the same. i tried to generate 2 layers and it worked. i tried to recreate my 4-layer layout, flash to alps64 but still no good, 4th layer is still default.

does anyone experience this? this is my 2nd alps64 and not the first time to flash this board, used to work fine at first but need to modify layout/keymap. my first board has 3 layers and working fine for months now.

if it will help, L0 is default with Space FN, Caps Fn and another standard Fn button.
Title: Re: TMK keyboard firmware
Post by: hasu on Sun, 09 July 2017, 23:57:21
pabile,
It seems Bootmagic is accidentally eabled, you need to clear config in EEPROM.

First, download default frimware from Editor and flash it.  http://www.tmk-kbd.com/tmk_keyboard/editor/unimap/?alps64
Second, Plug-in while pressing Space and Backspace(top right key).
Now, your keyboard should be normal.

If this problem is reproduced you will have to check and fix your soldering.

See this for Bootmagic if needed.
https://github.com/tmk/tmk_keyboard/#boot-magic-configuration---virtual-dip-switch
Title: Re: TMK keyboard firmware
Post by: pabile on Mon, 10 July 2017, 00:05:55
noted with thanks, hasu. i'll try this when i get back home later this evening. may i ask how does one enables bootmagic? through key combination? just asking to avoid it in future.

thanks for the quicky reply  :thumb:
Title: Re: TMK keyboard firmware
Post by: pabile on Mon, 10 July 2017, 07:47:51
First, download default frimware from Editor and flash it.  http://www.tmk-kbd.com/tmk_keyboard/editor/unimap/?alps64
Second, Plug-in while pressing Space and Backspace(top right key).
Now, your keyboard should be normal.

hi hasu! just letting you know that your instructions above fixed my board. your alps64 and tmk really are amazing  :-*
Title: Re: TMK keyboard firmware
Post by: pOngey on Sun, 16 July 2017, 08:23:08
Hi Hasu,

I decided to create a hand-wired mechanical keyboard a while back in time and it was a tough journey; but it was really fun. I got everything connected and finally was able to generate a hex file earlier today (from my office's mac) after struggling with Windows and comma placements.

So, thinking that I finally got the hex file generated, I decided to flash it to my keeb. I am using Teensy.exe to flash the hex file to my Teensy 2.0, but after rebooting, the keyboard seems not to work... My PC also starts giving USB connecting/disconnecting sound effects in a loop for a while. After a couple of cycles, my Teensy turns into 'Program Mode' and nothing happens...

I reflashed the Teensy with slow_blink.hex and it's working fine. I'm too afraid to reflash it with my keyboard hex file.

Would you say the problem is from the hardware rather than a software issue?


-pOngey
Title: Re: TMK keyboard firmware
Post by: hasu on Sun, 16 July 2017, 16:35:22
Hi Hasu,

I decided to create a hand-wired mechanical keyboard a while back in time and it was a tough journey; but it was really fun. I got everything connected and finally was able to generate a hex file earlier today (from my office's mac) after struggling with Windows and comma placements.

So, thinking that I finally got the hex file generated, I decided to flash it to my keeb. I am using Teensy.exe to flash the hex file to my Teensy 2.0, but after rebooting, the keyboard seems not to work... My PC also starts giving USB connecting/disconnecting sound effects in a loop for a while. After a couple of cycles, my Teensy turns into 'Program Mode' and nothing happens...

I reflashed the Teensy with slow_blink.hex and it's working fine. I'm too afraid to reflash it with my keyboard hex file.

Would you say the problem is from the hardware rather than a software issue?


-pOngey

Not sure what the problem exactly is but TMK has function to turn keyboard into program mode and you can disable it  with uncomment 'COMMAND_ENABLE' and 'BOOTMAGIC_ENABLE' in your Makefile.
Title: Re: TMK keyboard firmware
Post by: pOngey on Mon, 17 July 2017, 00:21:23
Hi Hasu,

I decided to create a hand-wired mechanical keyboard a while back in time and it was a tough journey; but it was really fun. I got everything connected and finally was able to generate a hex file earlier today (from my office's mac) after struggling with Windows and comma placements.

So, thinking that I finally got the hex file generated, I decided to flash it to my keeb. I am using Teensy.exe to flash the hex file to my Teensy 2.0, but after rebooting, the keyboard seems not to work... My PC also starts giving USB connecting/disconnecting sound effects in a loop for a while. After a couple of cycles, my Teensy turns into 'Program Mode' and nothing happens...

I reflashed the Teensy with slow_blink.hex and it's working fine. I'm too afraid to reflash it with my keyboard hex file.

Would you say the problem is from the hardware rather than a software issue?


-pOngey

Not sure what the problem exactly is but TMK has function to turn keyboard into program mode and you can disable it  with uncomment 'COMMAND_ENABLE' and 'BOOTMAGIC_ENABLE' in your Makefile.

Thank you for your reply, I will give it a try.

And thank you for your great supports!

-pOngey
Title: Re: TMK keyboard firmware
Post by: spwath on Mon, 17 July 2017, 12:26:35
I'm having issues with making my firmware, not sure why.
I made this post about it, maybe should have made this post here.
https://geekhack.org/index.php?topic=90630.0
Title: Re: TMK keyboard firmware
Post by: _haru on Mon, 24 July 2017, 06:46:32
Thinking of getting one of these for an upcoming project, seeing as the Atmega32u2 is supported by TMK: https://www.mattairtech.com/index.php/development-boards/atmega32u2-usb-development-board-arduino-compatible.html

Which bootloader should i buy it with? Will the stock Arduino compatible one work or do I need the DFU one? If so, which DFU bootloader, the Atmel one or the other one?
Title: Re: TMK keyboard firmware
Post by: Tactile on Mon, 24 July 2017, 12:17:32
Thinking of getting one of these for an upcoming project, seeing as the Atmega32u2 is supported by TMK: https://www.mattairtech.com/index.php/development-boards/atmega32u2-usb-development-board-arduino-compatible.html

Which bootloader should i buy it with? Will the stock Arduino compatible one work or do I need the DFU one? If so, which DFU bootloader, the Atmel one or the other one?

Between the offered choices the main difference is simply what tool you plan to use to program it. The two DFU options are for using FLIP from Atmel (http://www.atmel.com/tools/flip.aspx). The CDC bootloader won't work with FLIP, but works with AVRDUDE (http://www.nongnu.org/avrdude/). I've used both tools and it wouldn't matter to me. If they say the CDC bootloader is recommended, that's what I'd go with.
Title: Re: TMK keyboard firmware
Post by: _haru on Mon, 24 July 2017, 17:18:44
Thinking of getting one of these for an upcoming project, seeing as the Atmega32u2 is supported by TMK: https://www.mattairtech.com/index.php/development-boards/atmega32u2-usb-development-board-arduino-compatible.html

Which bootloader should i buy it with? Will the stock Arduino compatible one work or do I need the DFU one? If so, which DFU bootloader, the Atmel one or the other one?

Between the offered choices the main difference is simply what tool you plan to use to program it. The two DFU options are for using FLIP from Atmel (http://www.atmel.com/tools/flip.aspx). The CDC bootloader won't work with FLIP, but works with AVRDUDE (http://www.nongnu.org/avrdude/). I've used both tools and it wouldn't matter to me. If they say the CDC bootloader is recommended, that's what I'd go with.

Will either of them cause issues with getting TMK on the chips? I've heard that the Arduino bootloader might conflict with it.
Title: Re: TMK keyboard firmware
Post by: hasu on Mon, 24 July 2017, 17:33:57
no issue will come up. you can use any program method, tmk doesn't depend on bootloader. you don't have to even have bootloader if you have programmer like avrisp mkII.
Title: Re: TMK keyboard firmware
Post by: _haru on Mon, 24 July 2017, 17:44:11
no issue will come up. you can use any program method, tmk doesn't depend on bootloader. you don't have to even have bootloader if you have programmer like avrisp mkII.

Awesome, thanks!
Title: Re: TMK keyboard firmware
Post by: Eugene94 on Tue, 08 August 2017, 00:12:57
Hasu, I was wondering if it was at all possible to use my USB to USB converter as a USB flash drive. This idea occurred to me when I realized that the device was saving the custom keyboard layout and I wondered if it could save more... How much data can the device store? Could it be used to store text like a keylogger?
http://www.keelog.com/ps2_hardware_keylogger.html (http://www.keelog.com/ps2_hardware_keylogger.html)

Do you think that the TMK layout hex files would work on the devices in the link above?
Title: Re: TMK keyboard firmware
Post by: hasu on Tue, 08 August 2017, 00:28:36
1kb of eeprom can be used for storage and also rest part of flash if bootloader API can be  used.

I'm not sure about the last question but no probably.
Title: Re: TMK keyboard firmware
Post by: Trente on Wed, 09 August 2017, 15:50:32
Hey Hasu, I have a question about building a alternative controller and using TMK firmware with it, and I would really want some suggestion from you if possible.

Recently I got a 1800 style keyboard but unfortunately it was no longer working. So I am planning to do some hand wiring and build an alternative controller for it. The problem I am facing is to find a proper controller board. Since I am having a much larger matrix than 60% keyboard, (if I did not misunderstand the concept) I would need for input pins on the controller board. But it seems the commonly used tenssy 2.0 and pro micro board don't have this much inputs. So I am wondering if you have some good suggestion on controller board I can use to achieve my goal?

Thank you very much
Title: Re: TMK keyboard firmware
Post by: hasu on Wed, 09 August 2017, 16:04:01
Teensy 2.0++ if it's number of pins is enough for your needs.
Title: Re: TMK keyboard firmware
Post by: Trente on Wed, 09 August 2017, 17:19:56
I think I got 19 columns and 7 rows, so it sounds barely enough on tenssy 2.0++
Title: Re: TMK keyboard firmware
Post by: _haru on Wed, 09 August 2017, 19:03:40
I think I got 19 columns and 7 rows, so it sounds barely enough on tenssy 2.0++

The MattairTech 32U4 development board might work. I've got the 32U2 version in the mail right now.
Title: Re: TMK keyboard firmware
Post by: Trente on Wed, 09 August 2017, 19:46:11
The MattairTech 32U4 development board might work. I've got the 32U2 version in the mail right now.

Gotcha, thanks for the advice, I will look into it
Title: Re: TMK keyboard firmware
Post by: _haru on Wed, 09 August 2017, 23:45:51
The MattairTech 32U4 development board might work. I've got the 32U2 version in the mail right now.

Gotcha, thanks for the advice, I will look into it

 :thumb:
Title: Re: TMK keyboard firmware
Post by: Trente on Thu, 10 August 2017, 01:45:59
By the way, since I have absolutely no background in any electrical engineering, I would be very glad if someone and point out some good direction for me. I took the night looking into some forum, and got a plan about how the matrix should be wired up. What I came up with is a 8*13 matrix now (after some rearrangement and cleaning up). Thus, I am wondering if development boards like tenssy 2.0 or audrino pro micro or audrino micro has enough input pins for this size of matrix, and what are the pins that is OK to use on these type of board if I want to used them to build handwire keyboards?
Title: Re: TMK keyboard firmware
Post by: TalkingTree on Thu, 10 August 2017, 01:50:28
I am wondering if development boards like tenssy 2.0 or audrino pro micro or audrino micro has enough input pins for this size of matrix, and what are the pins that is OK to use on these type of board if I want to used them to build handwire keyboards?
ATMega32u4 has 26 I/O pins so either of the breakout boards you mentioned would cover a 8*13 matrix. Pins wise, you can use any indifferently for your matrix.
Title: Re: TMK keyboard firmware
Post by: Trente on Thu, 10 August 2017, 02:08:54
ATMega32u4 has 26 I/O pins so either of the breakout boards you mentioned would cover a 8*13 matrix. Pins wise, you can use any indifferently for your matrix.

So if I didn't misunderstand, this means any pin including those labeled as GND or 3v or whatever would work in same way? Also, though this could be already out of my reach, but if I would like to add in led support, not in switch ones, but just three indicator LEDs (CapsLock,NumLock etc), how many extra pins or what extra stuff I need to add in to get the stuff working?
Title: Re: TMK keyboard firmware
Post by: TalkingTree on Thu, 10 August 2017, 06:19:44
any pin including those labeled as GND or 3v or whatever would work in same way?
No, only I/O pins. They are generally labelled like F1, B4 or PF1, PB4 etc.

Also, though this could be already out of my reach, but if I would like to add in led support, not in switch ones, but just three indicator LEDs (CapsLock,NumLock etc), how many extra pins or what extra stuff I need to add in to get the stuff working?
The easiest way for LED indicators is to use a pin for each indicator. Being your matrix a 8*13, you have five free pins so you're good.
Title: Re: TMK keyboard firmware
Post by: jjanssen1 on Wed, 13 September 2017, 19:00:43
Hi Everyone,

I am designing/building an ATTINY85 two key macropad, and I was wondering if there is a way to use TMK on it, either alongside or instead of V-USB?


Thanks
-Josh
Title: Re: TMK keyboard firmware
Post by: hasu on Wed, 13 September 2017, 19:09:21
Hi Everyone,

I am designing/building an ATTINY85 two key macropad, and I was wondering if there is a way to use TMK on it, either alongside or instead of V-USB?


Thanks
-Josh

TMK includes V-USB already but with default config firmware will overrun flash size of the tiny chip.
I can remember that I managed to use TMK with 16KB flash with removing some features at some point, you will have to configure without many featutres and even shave some code to fit it into 8KB.

You can try to compile TMK onekey project for TINY85 to know it size.
Title: Re: TMK keyboard firmware
Post by: hasu on Thu, 14 September 2017, 09:33:53
To compile for ATtiny85 some tweaks was needed, putsed these commits to repo.

* bf20626 onekey: Add settings for Xtal-less V-USB
* 1c2f2b6 core: Remove unused file in vusb
* 4dc2fb5 onekey: Fix for V-USB of ATtiny85 and key scan
* 45f6e5c core: Fix for build option NO_ACTION_LAYER
* 956f806 core: Fix for ATtiny85

With those commits firmware size is under 6KB now and it works on ATtiny85!
To configure V-USB with crystal-less internal RC oscillator I refered to this page.
Connect D- to PB1, D+ to PB2 and switch between PB0 and GND.
http://codeandlife.com/2012/02/22/v-usb-with-attiny45-attiny85-without-a-crystal/

Quote

$ cd keyboard/onekey
$ make -f Makefile.vusb

...

Size after:
   text    data     bss     dec     hex filename
   5518      14     254    5786    169a onekey_vusb.elf

-------- end --------

(https://i.imgur.com/sNa302Jh.jpg)
Title: Re: TMK keyboard firmware
Post by: online on Thu, 21 September 2017, 18:39:53
Hi all

I'm pretty new to TMK. I'm trying to assign Fn keys as a macro key using import Fn in TMK Keymap Generator.
However, the keys do not register as a macro. Below is the code.

"0":["ACTION_LAYER_MOMENTARY",1],"4":["ACTION_LAYER_MOMENTARY","2"],"11":["ACTION_MODS_KEY(MOD_LSFT, KC_1)"],"12":["ACTION_MODS_KEY(MOD_LSFT, KC_1)"],"13":["ACTION_MODS_KEY(MOD_LSFT, KC_1)"]

Could anyone can shed some light please?
Title: Re: TMK keyboard firmware
Post by: alh84001 on Mon, 02 October 2017, 13:24:11
Hi hasu,

What are the chances of getting a PC 8801 converter?
Title: Re: TMK keyboard firmware
Post by: hasu on Tue, 03 October 2017, 18:24:15
Hi hasu,

What are the chances of getting a PC 8801 converter?

I for one have no plan. Can you work on it? If so I can help you.
Title: Re: TMK keyboard firmware
Post by: hoapham98 on Fri, 27 October 2017, 11:03:12
Hi Hasu, I have a problem with demux in matrix.c. I used a 74HC138 to demux columns. The matrix scaned fine but I had a problem with DEBOUNCE. Althought I set DEBOUNCE to 5 but it didn't work. I press 'A' one time but it show 6 'A'. I tested with onekey and debounce worked fine. Please help me!
This is my matrix.c
Code: [Select]
/*
Copyright 2013 Mathias Andersson <wraul@dbox.se>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdint.h>
#include <stdbool.h>
#include <avr/io.h>
#include <util/delay.h>
#include "print.h"
#include "debug.h"
#include "util.h"
#include "matrix.h"


#ifndef DEBOUNCE
#   define DEBOUNCE 5
#endif

static uint8_t debouncing = DEBOUNCE;

/* matrix state(1:on, 0:off) */
static matrix_row_t matrix[MATRIX_ROWS];
static matrix_row_t matrix_debouncing[MATRIX_ROWS];

static uint8_t read_rows(void);
static void init_rows(void);
static void unselect_cols(void);
static void select_col(uint8_t col);

inline
uint8_t matrix_rows(void)
{
    return MATRIX_ROWS;
}

inline
uint8_t matrix_cols(void)
{
    return MATRIX_COLS;
}

void matrix_init(void)
{
    unselect_cols();
    init_rows();
    // initialize matrix state: all keys off
    for (uint8_t i=0; i < MATRIX_ROWS; i++)  {
        matrix[i] = 0;
        matrix_debouncing[i] = 0;
    }
}

uint8_t matrix_scan(void)
{
    for (uint8_t col = 0; col < MATRIX_COLS; col++) {  // 0-5
        select_col(col);
        _delay_us(3); // TODO: Determine the correct value needed here.
        uint8_t rows = read_rows();

        for (uint8_t row = 0; row < MATRIX_ROWS; row++) {  // 0-1
            bool prev_bit = matrix_debouncing[row] & ((matrix_row_t)1<<col);
            bool curr_bit = rows & (1<<row);
            if (prev_bit != curr_bit) {
                matrix_debouncing[row] ^= ((matrix_row_t)1<<col);
                debouncing = DEBOUNCE;
            }
        }
        unselect_cols();
    }

    if (debouncing) {
        if (--debouncing) {
            _delay_ms(5);
        } else {
            for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
                matrix[i] = matrix_debouncing[i];
            }
        }
    }

    return 1;
}

bool matrix_is_modified(void)
{
    if (debouncing) return false;
    return true;
}

inline
bool matrix_is_on(uint8_t row, uint8_t col)
{
    return (matrix[row] & ((matrix_row_t)1<<col));
}

inline
matrix_row_t matrix_get_row(uint8_t row)
{
    return matrix[row];
}

void matrix_print(void)
{
    print("\nr/c 0123456789ABCDEF\n");
    for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
        xprintf("%02X: %032lb\n", row, bitrev32(matrix_get_row(row)));
    }
}

uint8_t matrix_key_count(void)
{
    uint8_t count = 0;
    for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
        count += bitpop32(matrix[i]);
    }
    return count;
}

/* Row pin configuration
 * row: 0   1
 * pin: B0  B1
 */
static void init_rows(void)
{
    // Input_pullup (DDR:0, PORT:1)
    DDRB  &= ~((1<<0) | (1<<1));
    PORTB |= ((1<<0) | (1<<1));
}

static uint8_t read_rows(void)
{
    return (PINB&(1<<0) ? 0 : (1<<0)) |
           (PINB&(1<<1) ? 0 : (1<<1));
}


/* Columns 0 - 4
 * These columns uses 74HC138 3 to 8 bit demultiplexers.
 * col / pin:    PB2  PB3  PB4
 * 0:             0    0    0
 * 1:             1    0    0
 * 2:             0    1    0
 * 3:             1    1    0
 * 4:             0    0    1
 */
static void unselect_cols(void)
{
    DDRB |= ((1<<2) | (1<<3) | (1<<4));
    PORTB &= ~((1<<2) | (1<<3) | (1<<4));
}

static void select_col(uint8_t col)
{
    // Output high (DDR:1, PORT:1) to select
    switch (col) {
        case 0:
            break;
        case 1:
            PORTB |= (1<<2);
            break;
        case 2:
            PORTB |= (1<<3);
            break;
        case 3:
            PORTB |= (1<<2) | (1<<3);
            break;
        case 4:
            PORTB |= (1<<4);
            break;
    }
}
Title: Re: TMK keyboard firmware
Post by: hasu on Fri, 27 October 2017, 19:27:45
hoapham98, I can't find anything wong with quick glance. this is not problem but you better use _delay_ms(1) instead of 5.


I would be helpful to implement your own different debounce from scratch when your debug doesn't go well. And refering to this 'timer based' debouncing code may be useful.
https://github.com/tmk/tmk_keyboard/blob/master/keyboard/onekey/onekey.c

Title: Re: TMK keyboard firmware
Post by: Sifo on Thu, 09 November 2017, 17:54:42
Hey hasu, as we discussed I'm trying to get TMK to work for my current gaming needs.

What this user describes with QMK is the same experience I'm having with both QMK and TMK. Using Metalliqaz' easyAVR firmware makes it possible to do the combination for me but I'm having key bouncing issues with his firmware.

https://github.com/qmk/qmk_firmware/issues/1950

Using any of my other custom keyboards (TX87, lightsaver, NERD2.0, b.face, etc) doesn't have this problem.

I'm not 100% sure what the problem is but I read somewhere it could have something to do with polling rate (needs to be 1000hz). Is there anywhere in TMK where I can set that?

The keyboard is a GH60 rev. C, I'm using Windows 10 64bit and my keymap is as follows (this might have errors because I wrote it up really quick at work, at home the keymap compiles with no errors):

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

/*
 * Sifo
 */
const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
    /* Default
     * ,-----------------------------------------------------------.
     * |Esc|  1|  2|  3|  4|  5|  6|  7|  8|  9|  0|  -|  =|  \|Del|
     * |-----------------------------------------------------------|
     * |Tab  |  Q|  W|  E|  R|  T|  Y|  U|  I|  O|  P|  [|  ]| Bspc|
     * |-----------------------------------------------------------|
     * |LCtl  |  A|  S|  D|  F|  G|  H|  J|  K|  L|  ;|  '|Enter   |
     * |-----------------------------------------------------------|
     * |Shift   |  Z|  X|  C|  V|  B|  N|  M|  ,|  .|    Shift     |
     * |-----------------------------------------------------------|
     * |Fn0 |Gui |Alt |      Space             |Fn1 |Alt |LCtl|RCtl|
     * `-----------------------------------------------------------'
     */
    KEYMAP_ANSI(
        ESC, 1,   2,   3,   4,   5,   6,   7,   8,   9,   0,MINS,EQL,BSLS,DEL, \
        TAB, Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,   LBRC,RBRC,BSPC, \
        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,  \
        FN0,LGUI,LALT,          SPC,                     FN1,RALT, LCTL, RCTL),
    /* Fn1
     * ,-----------------------------------------------------------.
     * |Grv| P1| P2| P3| P4| P5| P6| P7|P8|P9|P0|PMNS|PPLS|PAST|   |
     * |-----------------------------------------------------------|
     * |Bspc |Del| Up|Ent|Hom|   |   |   |Ins|   |   |   |   |     |
     * |-----------------------------------------------------------|
     * |Caps  |Lef|Dwn|Rig|End|   |   |   |   |   |   |   |        |
     * |-----------------------------------------------------------|
     * |Shift  |NLck|PgDn|PgUp|PScr|ScLk|Paus|  |  |PDOT|PSLS|Shift|
     * |-----------------------------------------------------------|
     * |    |    |    |                        |    |RGui| App|    |
     * `-----------------------------------------------------------'
     */
    KEYMAP_ANSI(
        GRV, P1,  P2,  P3,  P4,  P5,  P6,  P7,  P8,  P9,P0,PMNS,PPLS,PAST,TRNS \
        BSPC,DEL,  UP,  ENT,HOME,TRNS,TRNS,TRNS,INS,TRNS,TRNS,TRNS,TRNS,TRNS,  \
        CAPS,LEFT,DOWN,RIGHT,END,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,    PENT,  \
        TRNS,NLCK,PGDN,PGUP,PSCR,SLCK,PAUS,TRNS,TRNS,PDOT,PSLS,          TRNS, \
        TRNS,TRNS,TRNS,          TRNS,                     TRNS,RGUI, APP,TRNS),
    /* Fn2
     * ,-----------------------------------------------------------.
     * |   | F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|   |   |
     * |-----------------------------------------------------------|
     * |     |   |   |   |   |   |   |   |   |   |   |   |   |     |
     * |-----------------------------------------------------------|
     * |      |   |   |   |   |   |   |   |   |   |   |   |        |
     * |-----------------------------------------------------------|
     * |        |   |   |   |   |   |   |   |   |   |   |          |
     * |-----------------------------------------------------------|
     * |    |    |    |                        |    |RGui |App |   |
     * `-----------------------------------------------------------'
     */
    KEYMAP_ANSI(
        TRNS, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12,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,RGUI,APP, TRNS),
};
const action_t PROGMEM fn_actions[] = {
    [0] = ACTION_LAYER_MOMENTARY(1),
    [1] = ACTION_LAYER_MOMENTARY(2)
};


The strangest part about this is that even setting up a macro to perfectly press Space + C at the same time will not work consistently via TMK or QMK, but manually doing it via metalliqaz' firmware works flawlessly.
Title: Re: TMK keyboard firmware
Post by: hasu on Thu, 09 November 2017, 19:39:54
Interesting.
You never get crouch jump at all with TMK? or you can get it occasionally?

In TMK USB polling of default keyboard(endpoint 1) requests 10ms interval(100Hz) for purpose of wide compatibility to computers. Try NKRO keyboard instead if you need 1ms interval. But I don't think this is problem, if this is true you won't be able to play the game with Realforce and HHKB.

To get the action timing is really critical? I watched people fail to jump through window many times in some youtube videos :)
Maybe, scan rate of switch matrix is too slow then?


Can you try elitekeyboards.com's Switchhitter and post logs of  key strokes of 'space + c'?
I like to see log from TMK keyboard and one of keyboards without problem.
Title: Re: TMK keyboard firmware
Post by: Sifo on Thu, 09 November 2017, 19:44:37
Interesting.
You never get crouch jump at all with TMK? or you can get it occasionally?

In TMK USB polling of default keyboard(endpoint 1) requests 10ms interval(100Hz) for purpose of wide compatibility to computers. Try NKRO keyboard instead if you need 1ms interval. But I don't think this is problem, if this is true you won't be able to play the game with Realforce and HHKB.

To get the action timing is really critical? I watched people fail to jump through window many times in some youtube videos :)
Maybe, scan rate of switch matrix is too slow then?


Can you try elitekeyboards.com's Switchhitter and post logs of  key strokes of 'space + c'?
I like to see log from TMK keyboard and one of keyboards without problem.

I can get it occasionally, maybe 1/10 times? I can also try NKRO on tmk when I get home.

I wouldn't say the timing is critical because a macro doesn't work via TMK but will work with Razer keyboards lol... but people have reported that it is easier on some keyboards than others, some guess that it might have to do with polling.

If you suspect it's the matrix scan rate, I can try adjusting it via metalliqaz' firmware since it has a built in console to play with the timings and report any difference.

I don't have a realforce or hhkb to test, but I can show you my switchhitter logs later tonight with different keyboards. I can even show you the difference between TMK vs metalliqaz' firmware on the same keyboard as well.
Title: Re: TMK keyboard firmware
Post by: Sifo on Thu, 09 November 2017, 23:09:24
First update: switching to NKRO with shift + shift + N works, crouch jump 100% success rate now.

Is there a better way to enable NKRO as default?

Or is there a way to have 6kro with 1ms polling rate?

Title: Re: TMK keyboard firmware
Post by: hasu on Thu, 09 November 2017, 23:22:54
These are SwitchHitter logs of my keyboards on Thinkpad x201s/windows 10.
Hm, I don't find obvious problem in TMK keyboards. They can send two press events sequentially in 8ms apart as expected. TMK NKRO sends in 5ms apart in log below,  I guess the 5ms resolution is limitation of SwitchHitter or Windows because with xev on Linux it can send events in 1ms apart.


PS/2 internal keyboard:
15:58.0882 Space (0x20, BIOS 0x39) DOWN
15:58.0887 C (0x43, BIOS 0x2E) DOWN
15:58.0978 Space (0x20, BIOS 0x39) UP -> 97ms
15:58.0983 C (0x43, BIOS 0x2E) UP -> 97ms
16:00.0813 Space (0x20, BIOS 0x39) DOWN
16:00.0817 C (0x43, BIOS 0x2E) DOWN
16:00.0891 Space (0x20, BIOS 0x39) UP -> 77ms
16:00.0896 C (0x43, BIOS 0x2E) UP -> 77ms
16:04.0616 Space (0x20, BIOS 0x39) DOWN
16:04.0621 C (0x43, BIOS 0x2E) DOWN
16:04.0677 Space (0x20, BIOS 0x39) UP -> 62ms
16:04.0682 C (0x43, BIOS 0x2E) UP -> 62ms


Cherry G80-3600(10ms):
28:39.0352 C (0x43, BIOS 0x2E) DOWN
28:39.0360 Space (0x20, BIOS 0x39) DOWN
28:39.0472 Space (0x20, BIOS 0x39) UP -> 112ms
28:39.0488 C (0x43, BIOS 0x2E) UP -> 136ms
28:40.0376 C (0x43, BIOS 0x2E) DOWN
28:40.0392 Space (0x20, BIOS 0x39) DOWN
28:40.0472 C (0x43, BIOS 0x2E) UP -> 96ms
28:40.0480 Space (0x20, BIOS 0x39) UP -> 88ms
28:41.0368 C (0x43, BIOS 0x2E) DOWN
28:41.0376 Space (0x20, BIOS 0x39) DOWN
28:41.0448 C (0x43, BIOS 0x2E) UP -> 80ms
28:41.0464 Space (0x20, BIOS 0x39) UP -> 88ms
28:42.0312 C (0x43, BIOS 0x2E) DOWN
28:42.0328 Space (0x20, BIOS 0x39) DOWN
28:42.0416 Space (0x20, BIOS 0x39) UP -> 88ms
28:42.0432 C (0x43, BIOS 0x2E) UP -> 120ms


HHKB Pro2 with TMK Alt controller(NKRO/1ms):
19:12.0658 C (0x43, BIOS 0x2E) DOWN
19:12.0663 Space (0x20, BIOS 0x39) DOWN
19:12.0757 Space (0x20, BIOS 0x39) UP -> 93ms
19:12.0772 C (0x43, BIOS 0x2E) UP -> 114ms
19:16.0287 Space (0x20, BIOS 0x39) DOWN
19:16.0294 C (0x43, BIOS 0x2E) DOWN
19:16.0386 Space (0x20, BIOS 0x39) UP -> 99ms
19:16.0393 C (0x43, BIOS 0x2E) UP -> 99ms
19:19.0134 Space (0x20, BIOS 0x39) DOWN
19:19.0140 C (0x43, BIOS 0x2E) DOWN
19:19.0253 Space (0x20, BIOS 0x39) UP -> 120ms
19:19.0260 C (0x43, BIOS 0x2E) UP -> 120ms
19:21.0319 Space (0x20, BIOS 0x39) DOWN
19:21.0325 C (0x43, BIOS 0x2E) DOWN
19:21.0417 Space (0x20, BIOS 0x39) UP -> 99ms
19:21.0424 C (0x43, BIOS 0x2E) UP -> 99ms
19:24.0617 C (0x43, BIOS 0x2E) DOWN
19:24.0622 Space (0x20, BIOS 0x39) DOWN
19:24.0730 Space (0x20, BIOS 0x39) UP -> 107ms
19:24.0737 C (0x43, BIOS 0x2E) UP -> 121ms


HHKB Pro2 with TMK Alt controller(6KRO/10ms):
42:49.0785 C (0x43, BIOS 0x2E) DOWN
42:49.0793 Space (0x20, BIOS 0x39) DOWN
42:49.0849 Space (0x20, BIOS 0x39) UP -> 56ms
42:49.0857 C (0x43, BIOS 0x2E) UP -> 72ms
42:57.0593 C (0x43, BIOS 0x2E) DOWN
42:57.0601 Space (0x20, BIOS 0x39) DOWN
42:57.0665 C (0x43, BIOS 0x2E) UP -> 72ms
42:57.0673 Space (0x20, BIOS 0x39) UP -> 72ms
43:00.0249 Space (0x20, BIOS 0x39) DOWN
43:00.0256 C (0x43, BIOS 0x2E) DOWN
43:00.0336 C (0x43, BIOS 0x2E) UP -> 80ms
43:00.0344 Space (0x20, BIOS 0x39) UP -> 96ms
43:02.0169 Space (0x20, BIOS 0x39) DOWN
43:02.0177 C (0x43, BIOS 0x2E) DOWN
43:02.0265 Space (0x20, BIOS 0x39) UP -> 96ms
43:02.0273 C (0x43, BIOS 0x2E) UP -> 96ms
43:13.0705 Space (0x20, BIOS 0x39) DOWN
43:13.0712 C (0x43, BIOS 0x2E) DOWN
43:13.0792 C (0x43, BIOS 0x2E) UP -> 80ms
43:13.0800 Space (0x20, BIOS 0x39) UP -> 96ms



HHKB Pro2 with Topre original controller(10ms):
46:54.0396 Space (0x20, BIOS 0x39) DOWN
46:54.0412 C (0x43, BIOS 0x2E) DOWN
46:54.0500 C (0x43, BIOS 0x2E) UP -> 88ms
46:54.0507 Space (0x20, BIOS 0x39) UP -> 112ms
47:01.0412 Space (0x20, BIOS 0x39) DOWN
47:01.0419 C (0x43, BIOS 0x2E) DOWN
47:01.0500 Space (0x20, BIOS 0x39) UP -> 88ms
47:01.0516 C (0x43, BIOS 0x2E) UP -> 96ms
47:02.0573 C (0x43, BIOS 0x2E) DOWN
47:02.0580 Space (0x20, BIOS 0x39) DOWN
47:02.0636 Space (0x20, BIOS 0x39) UP -> 56ms
47:02.0652 C (0x43, BIOS 0x2E) UP -> 80ms
47:03.0588 Space (0x20, BIOS 0x39) DOWN
47:03.0595 C (0x43, BIOS 0x2E) DOWN
47:03.0676 C (0x43, BIOS 0x2E) UP -> 80ms
47:03.0684 Space (0x20, BIOS 0x39) UP -> 96ms
47:04.0596 C (0x43, BIOS 0x2E) DOWN
47:04.0603 Space (0x20, BIOS 0x39) DOWN
47:04.0659 Space (0x20, BIOS 0x39) UP -> 56ms
47:04.0675 C (0x43, BIOS 0x2E) UP -> 80ms



Alps64(10ms):
20:47.0951 Space (0x20, BIOS 0x39) DOWN
20:47.0959 C (0x43, BIOS 0x2E) DOWN
20:48.0087 Space (0x20, BIOS 0x39) UP -> 136ms
20:48.0095 C (0x43, BIOS 0x2E) UP -> 136ms
20:49.0639 C (0x43, BIOS 0x2E) DOWN
20:49.0647 Space (0x20, BIOS 0x39) DOWN
20:49.0767 Space (0x20, BIOS 0x39) UP -> 120ms
20:49.0775 C (0x43, BIOS 0x2E) UP -> 136ms
20:51.0551 Space (0x20, BIOS 0x39) DOWN
20:51.0559 C (0x43, BIOS 0x2E) DOWN
20:51.0671 C (0x43, BIOS 0x2E) UP -> 112ms
20:51.0695 Space (0x20, BIOS 0x39) UP -> 144ms
20:52.0943 C (0x43, BIOS 0x2E) DOWN
20:52.0951 Space (0x20, BIOS 0x39) DOWN
20:53.0087 Space (0x20, BIOS 0x39) UP -> 136ms
20:53.0094 C (0x43, BIOS 0x2E) UP -> 152ms



Alps64 NKRO(1ms):
26:37.0078 Space (0x20, BIOS 0x39) DOWN
26:37.0083 C (0x43, BIOS 0x2E) DOWN
26:37.0162 C (0x43, BIOS 0x2E) UP -> 79ms
26:37.0179 Space (0x20, BIOS 0x39) UP -> 101ms
26:39.0240 Space (0x20, BIOS 0x39) DOWN
26:39.0245 C (0x43, BIOS 0x2E) DOWN
26:39.0315 C (0x43, BIOS 0x2E) UP -> 69ms
26:39.0322 Space (0x20, BIOS 0x39) UP -> 81ms
26:41.0095 Space (0x20, BIOS 0x39) DOWN
26:41.0100 C (0x43, BIOS 0x2E) DOWN
26:41.0180 C (0x43, BIOS 0x2E) UP -> 80ms
26:41.0200 Space (0x20, BIOS 0x39) UP -> 105ms
26:43.0361 Space (0x20, BIOS 0x39) DOWN
26:43.0366 C (0x43, BIOS 0x2E) DOWN
26:43.0413 C (0x43, BIOS 0x2E) UP -> 47ms
26:43.0429 Space (0x20, BIOS 0x39) UP -> 68ms
26:45.0305 Space (0x20, BIOS 0x39) DOWN
26:45.0309 C (0x43, BIOS 0x2E) DOWN
26:45.0365 C (0x43, BIOS 0x2E) UP -> 55ms
26:45.0373 Space (0x20, BIOS 0x39) UP -> 69ms



Title: Re: TMK keyboard firmware
Post by: hasu on Thu, 09 November 2017, 23:27:14
First update: switching to NKRO with shift + shift + N works, crouch jump 100% success rate now.

Is there a better way to enable NKRO as default?

Or is there a way to have 6kro with 1ms polling rate?



Great.
Logs of your keyboards is still helpful to tack down the problem, post them when you get time, plz.


Isn't NKRO default when you build with that option? I can't remember. Check FAQ on wiki.
To get 1ms polling  you just need to change report descriptor, iirc.
Title: Re: TMK keyboard firmware
Post by: Sifo on Thu, 09 November 2017, 23:32:11
First update: switching to NKRO with shift + shift + N works, crouch jump 100% success rate now.

Is there a better way to enable NKRO as default?

Or is there a way to have 6kro with 1ms polling rate?



Great.
Logs of your keyboards is still helpful to tack down the problem, post them when you get time, plz.


Isn't NKRO default when you build with that option? I can't remember. Check FAQ on wiki.
To get 1ms polling  you just need to change report descriptor, iirc.

ok I will get you the logs when I can.

NKRO is not on by default, the default makefile I believe has NKRO_ENABLE = yes

I think bootmagic is on by default too. Says default is Space + N but doesn't work for me to toggle NKRO. I will have more details later!

EDIT: commented out bootmagic and now NKRO is on by default. will provide logs when I can later.
Title: Re: TMK keyboard firmware
Post by: Sifo on Fri, 10 November 2017, 01:53:52
Logs, 10 tries each of Space + C simultaneously:

EasyAVR via Metalliqaz:
Code: [Select]
42:53.0182 C (0x43, BIOS 0x2E) DOWN
42:53.0183 Space (0x20, BIOS 0x39) DOWN
42:53.0276 C (0x43, BIOS 0x2E) UP -> 94ms
42:53.0278 Space (0x20, BIOS 0x39) UP -> 95ms
42:53.0700 C (0x43, BIOS 0x2E) DOWN
42:53.0701 Space (0x20, BIOS 0x39) DOWN
42:53.0809 C (0x43, BIOS 0x2E) UP -> 109ms
42:53.0811 Space (0x20, BIOS 0x39) UP -> 110ms
42:54.0136 C (0x43, BIOS 0x2E) DOWN
42:54.0137 Space (0x20, BIOS 0x39) DOWN
42:54.0229 C (0x43, BIOS 0x2E) UP -> 92ms
42:54.0247 Space (0x20, BIOS 0x39) UP -> 109ms
42:54.0552 C (0x43, BIOS 0x2E) DOWN
42:54.0553 Space (0x20, BIOS 0x39) DOWN
42:54.0632 C (0x43, BIOS 0x2E) UP -> 80ms
42:54.0656 Space (0x20, BIOS 0x39) UP -> 103ms
42:55.0037 C (0x43, BIOS 0x2E) DOWN
42:55.0040 Space (0x20, BIOS 0x39) DOWN
42:55.0124 C (0x43, BIOS 0x2E) UP -> 87ms
42:55.0128 Space (0x20, BIOS 0x39) UP -> 88ms
42:55.0561 C (0x43, BIOS 0x2E) DOWN
42:55.0562 Space (0x20, BIOS 0x39) DOWN
42:55.0626 C (0x43, BIOS 0x2E) UP -> 66ms
42:55.0628 Space (0x20, BIOS 0x39) UP -> 67ms
42:55.0979 C (0x43, BIOS 0x2E) DOWN
42:55.0980 Space (0x20, BIOS 0x39) DOWN
42:56.0050 C (0x43, BIOS 0x2E) UP -> 71ms
42:56.0053 Space (0x20, BIOS 0x39) UP -> 72ms
42:56.0536 C (0x43, BIOS 0x2E) DOWN
42:56.0537 Space (0x20, BIOS 0x39) DOWN
42:56.0600 C (0x43, BIOS 0x2E) UP -> 64ms
42:56.0601 Space (0x20, BIOS 0x39) UP -> 64ms
42:57.0026 C (0x43, BIOS 0x2E) DOWN
42:57.0028 Space (0x20, BIOS 0x39) DOWN
42:57.0099 C (0x43, BIOS 0x2E) UP -> 73ms
42:57.0100 Space (0x20, BIOS 0x39) UP -> 72ms
42:57.0469 C (0x43, BIOS 0x2E) DOWN
42:57.0471 Space (0x20, BIOS 0x39) DOWN
42:57.0540 C (0x43, BIOS 0x2E) UP -> 72ms
42:57.0542 Space (0x20, BIOS 0x39) UP -> 72ms

TMK 6KRO
Code: [Select]
50:42.0321 C (0x43, BIOS 0x2E) DOWN
50:42.0328 Space (0x20, BIOS 0x39) DOWN
50:42.0416 C (0x43, BIOS 0x2E) UP -> 96ms
50:42.0424 Space (0x20, BIOS 0x39) UP -> 96ms
50:42.0744 C (0x43, BIOS 0x2E) DOWN
50:42.0752 Space (0x20, BIOS 0x39) DOWN
50:42.0833 C (0x43, BIOS 0x2E) UP -> 88ms
50:42.0841 Space (0x20, BIOS 0x39) UP -> 88ms
50:43.0209 C (0x43, BIOS 0x2E) DOWN
50:43.0217 Space (0x20, BIOS 0x39) DOWN
50:43.0289 C (0x43, BIOS 0x2E) UP -> 80ms
50:43.0297 Space (0x20, BIOS 0x39) UP -> 80ms
50:43.0633 C (0x43, BIOS 0x2E) DOWN
50:43.0641 Space (0x20, BIOS 0x39) DOWN
50:43.0745 C (0x43, BIOS 0x2E) UP -> 112ms
50:43.0761 Space (0x20, BIOS 0x39) UP -> 120ms
50:44.0121 C (0x43, BIOS 0x2E) DOWN
50:44.0129 Space (0x20, BIOS 0x39) DOWN
50:44.0193 C (0x43, BIOS 0x2E) UP -> 72ms
50:44.0208 Space (0x20, BIOS 0x39) UP -> 80ms
50:44.0560 C (0x43, BIOS 0x2E) DOWN
50:44.0568 Space (0x20, BIOS 0x39) DOWN
50:44.0632 C (0x43, BIOS 0x2E) UP -> 72ms
50:44.0640 Space (0x20, BIOS 0x39) UP -> 72ms
50:44.0976 C (0x43, BIOS 0x2E) DOWN
50:44.0985 Space (0x20, BIOS 0x39) DOWN
50:45.0056 C (0x43, BIOS 0x2E) UP -> 80ms
50:45.0065 Space (0x20, BIOS 0x39) UP -> 80ms
50:45.0416 C (0x43, BIOS 0x2E) DOWN
50:45.0424 Space (0x20, BIOS 0x39) DOWN
50:45.0481 C (0x43, BIOS 0x2E) UP -> 64ms
50:45.0505 Space (0x20, BIOS 0x39) UP -> 80ms
50:45.0889 C (0x43, BIOS 0x2E) DOWN
50:45.0897 Space (0x20, BIOS 0x39) DOWN
50:45.0969 C (0x43, BIOS 0x2E) UP -> 80ms
50:45.0977 Space (0x20, BIOS 0x39) UP -> 80ms
50:46.0305 C (0x43, BIOS 0x2E) DOWN
50:46.0313 Space (0x20, BIOS 0x39) DOWN
50:46.0393 C (0x43, BIOS 0x2E) UP -> 88ms
50:46.0401 Space (0x20, BIOS 0x39) UP -> 88ms

TMK NKRO
Code: [Select]
51:55.0322 C (0x43, BIOS 0x2E) DOWN
51:55.0323 Space (0x20, BIOS 0x39) DOWN
51:55.0419 C (0x43, BIOS 0x2E) UP -> 98ms
51:55.0420 Space (0x20, BIOS 0x39) UP -> 98ms
51:55.0865 C (0x43, BIOS 0x2E) DOWN
51:55.0866 Space (0x20, BIOS 0x39) DOWN
51:55.0974 C (0x43, BIOS 0x2E) UP -> 109ms
51:55.0974 Space (0x20, BIOS 0x39) UP -> 109ms
51:56.0806 C (0x43, BIOS 0x2E) DOWN
51:56.0807 Space (0x20, BIOS 0x39) DOWN
51:56.0912 C (0x43, BIOS 0x2E) UP -> 106ms
51:56.0912 Space (0x20, BIOS 0x39) UP -> 106ms
51:57.0328 C (0x43, BIOS 0x2E) DOWN
51:57.0329 Space (0x20, BIOS 0x39) DOWN
51:57.0425 C (0x43, BIOS 0x2E) UP -> 97ms
51:57.0426 Space (0x20, BIOS 0x39) UP -> 97ms
51:58.0030 C (0x43, BIOS 0x2E) DOWN
51:58.0030 Space (0x20, BIOS 0x39) DOWN
51:58.0120 C (0x43, BIOS 0x2E) UP -> 91ms
51:58.0121 Space (0x20, BIOS 0x39) UP -> 91ms
51:58.0773 C (0x43, BIOS 0x2E) DOWN
51:58.0773 Space (0x20, BIOS 0x39) DOWN
51:58.0858 C (0x43, BIOS 0x2E) UP -> 86ms
51:58.0866 Space (0x20, BIOS 0x39) UP -> 93ms
51:59.0312 C (0x43, BIOS 0x2E) DOWN
51:59.0313 Space (0x20, BIOS 0x39) DOWN
51:59.0399 C (0x43, BIOS 0x2E) UP -> 86ms
51:59.0407 Space (0x20, BIOS 0x39) UP -> 93ms
51:59.0888 C (0x43, BIOS 0x2E) DOWN
51:59.0888 Space (0x20, BIOS 0x39) DOWN
51:59.0986 C (0x43, BIOS 0x2E) UP -> 98ms
51:59.0996 Space (0x20, BIOS 0x39) UP -> 108ms
52:00.0571 C (0x43, BIOS 0x2E) DOWN
52:00.0572 Space (0x20, BIOS 0x39) DOWN
52:00.0660 C (0x43, BIOS 0x2E) UP -> 90ms
52:00.0667 Space (0x20, BIOS 0x39) UP -> 96ms
52:01.0167 C (0x43, BIOS 0x2E) DOWN
52:01.0168 Space (0x20, BIOS 0x39) DOWN
52:01.0252 C (0x43, BIOS 0x2E) UP -> 84ms
52:01.0253 Space (0x20, BIOS 0x39) UP -> 84ms

b.face
Code: [Select]
58:11.0027 C (0x43, BIOS 0x2E) DOWN
58:11.0028 Space (0x20, BIOS 0x39) DOWN
58:11.0135 C (0x43, BIOS 0x2E) UP -> 128ms
58:11.0136 Space (0x20, BIOS 0x39) UP -> 108ms
58:11.0616 C (0x43, BIOS 0x2E) DOWN
58:11.0617 Space (0x20, BIOS 0x39) DOWN
58:11.0712 C (0x43, BIOS 0x2E) UP -> 96ms
58:11.0720 Space (0x20, BIOS 0x39) UP -> 103ms
58:12.0104 C (0x43, BIOS 0x2E) DOWN
58:12.0105 Space (0x20, BIOS 0x39) DOWN
58:12.0200 C (0x43, BIOS 0x2E) UP -> 96ms
58:12.0201 Space (0x20, BIOS 0x39) UP -> 96ms
58:12.0639 C (0x43, BIOS 0x2E) DOWN
58:12.0640 Space (0x20, BIOS 0x39) DOWN
58:12.0720 C (0x43, BIOS 0x2E) UP -> 80ms
58:12.0721 Space (0x20, BIOS 0x39) UP -> 80ms
58:13.0096 C (0x43, BIOS 0x2E) DOWN
58:13.0097 Space (0x20, BIOS 0x39) DOWN
58:13.0176 C (0x43, BIOS 0x2E) UP -> 80ms
58:13.0184 Space (0x20, BIOS 0x39) UP -> 87ms
58:13.0560 C (0x43, BIOS 0x2E) DOWN
58:13.0561 Space (0x20, BIOS 0x39) DOWN
58:13.0648 C (0x43, BIOS 0x2E) UP -> 88ms
58:13.0648 Space (0x20, BIOS 0x39) UP -> 88ms
58:14.0919 C (0x43, BIOS 0x2E) DOWN
58:14.0920 Space (0x20, BIOS 0x39) DOWN
58:15.0024 C (0x43, BIOS 0x2E) UP -> 104ms
58:15.0025 Space (0x20, BIOS 0x39) UP -> 104ms
58:15.0360 Space (0x20, BIOS 0x39) DOWN
58:15.0368 C (0x43, BIOS 0x2E) DOWN
58:15.0432 C (0x43, BIOS 0x2E) UP -> 64ms
58:15.0448 Space (0x20, BIOS 0x39) UP -> 88ms
58:15.0872 C (0x43, BIOS 0x2E) DOWN
58:15.0873 Space (0x20, BIOS 0x39) DOWN
58:15.0943 C (0x43, BIOS 0x2E) UP -> 72ms
58:15.0951 Space (0x20, BIOS 0x39) UP -> 79ms
58:16.0256 C (0x43, BIOS 0x2E) DOWN
58:16.0256 Space (0x20, BIOS 0x39) DOWN
58:16.0319 C (0x43, BIOS 0x2E) UP -> 64ms
58:16.0327 Space (0x20, BIOS 0x39) UP -> 71ms

I also confirmed in game, only TMK 6KRO does not work.

Interestingly, the b.face is 6KRO.
Title: Re: TMK keyboard firmware
Post by: hasu on Fri, 10 November 2017, 02:34:32
Thanks,
hmm, its cause seems to be polling rate against my expectation.
I guess b.face and EasyAVR uses 1ms as polling interval.

I can't understand why steam or pubg guys keep this issue unfixed, this will eliminate users of classic keyboards with 10ms polling including Realforce, HHKB and many many others :p

And this issue exists only on WIndows? (Assuming steam is multi platform and supports Mac and Linux.)
Title: Re: TMK keyboard firmware
Post by: Sifo on Fri, 10 November 2017, 02:55:54
Thanks,
hmm, its cause seems to be polling rate against my expectation.
I guess b.face and EasyAVR uses 1ms as polling interval.

I can't understand why steam or pubg guys keep this issue unfixed, this will eliminate users of classic keyboards with 10ms polling including Realforce, HHKB and many many others :p

And this issue exists only on WIndows? (Assuming steam is multi platform and supports Mac and Linux.)

pubg is the most poorly spaghetti coded game i've ever seen so that's why. but they are supposedly adding a new feature in the game so you can vault with 1 key. I guess at that point this will be obsolete, but I just wanted to figure it out for the mean time lol.

I can't confirm on Mac or Linux since i only have a windows machine at the moment.

But just in case, what would be the steps to enable 1ms polling for 6kro? I'm not sure what file contains the report descriptor
Title: Re: TMK keyboard firmware
Post by: hasu on Fri, 10 November 2017, 05:29:35
See line 309 of tmk_core/protocol/lufa/descriptor.c to change ".PollingIntervalMS".
Title: Re: TMK keyboard firmware
Post by: Sifo on Sat, 11 November 2017, 00:28:49
everything working perfectly now, 6kro with 1000hz polling rate, thank you so much hasu!
Title: Re: TMK keyboard firmware
Post by: BrintaVett on Sun, 12 November 2017, 15:13:41
Edit: moved this to another topic.

Title: Re: TMK keyboard firmware
Post by: Ngt on Tue, 14 November 2017, 15:06:22
Hello Hasu!


Thanks you for the great project it is really cool. I finished building my board and flashed TMK on it with a modified version of SpaceFn. I wonder where can I play with the activation time of the space key? I'd like to try with a longer activation time. It doesn't feel smooth to me with the default value but I can't figure out where the parameter is in the source code. Thanks for the help.
Title: Re: TMK keyboard firmware
Post by: hasu on Tue, 14 November 2017, 18:35:02
Hello Hasu!


Thanks you for the great project it is really cool. I finished building my board and flashed TMK on it with a modified version of SpaceFn. I wonder where can I play with the activation time of the space key? I'd like to try with a longer activation time. It doesn't feel smooth to me with the default value but I can't figure out where the parameter is in the source code. Thanks for the help.

SpaceFn is just one of example layouts using 'dual-role key' technique and coined by spiceBar. Dual-role key is proper word  for discussion and search in this case, though.
https://en.wikipedia.org/wiki/Modifier_key#Dual-role_keys

You can use this thread for gneral discussion of usage and implementation of dual role key.
https://geekhack.org/index.php?topic=41685.50


TMK implememtation of the dual role key is called as 'Tap key' in its doc and source. You can find code here. I guess what you are finding is TAPPING_TERM value which can be changed in confih.h.

https://github.com/tmk/tmk_keyboard/blob/5f6550a0be8b332f24ad6a7798e1237b2970ef85/tmk_core/common/action_tapping.c
https://github.com/tmk/tmk_core/blob/master/doc/keymap.md#4-tapping
Title: Re: TMK keyboard firmware
Post by: Ngt on Wed, 15 November 2017, 05:06:43
Hello Hasu!


Thanks you for the great project it is really cool. I finished building my board and flashed TMK on it with a modified version of SpaceFn. I wonder where can I play with the activation time of the space key? I'd like to try with a longer activation time. It doesn't feel smooth to me with the default value but I can't figure out where the parameter is in the source code. Thanks for the help.

SpaceFn is just one of example layouts using 'dual-role key' technique and coined by spiceBar. Dual-role key is proper word  for discussion and search in this case, though.
https://en.wikipedia.org/wiki/Modifier_key#Dual-role_keys (https://en.wikipedia.org/wiki/Modifier_key#Dual-role_keys)

You can use this thread for gneral discussion of usage and implementation of dual role key.
https://geekhack.org/index.php?topic=41685.50 (https://geekhack.org/index.php?topic=41685.50)


TMK implememtation of the dual role key is called as 'Tap key' in its doc and source. You can find code here. I guess what you are finding is TAPPING_TERM value which can be changed in confih.h.

https://github.com/tmk/tmk_keyboard/blob/5f6550a0be8b332f24ad6a7798e1237b2970ef85/tmk_core/common/action_tapping.c (https://github.com/tmk/tmk_keyboard/blob/5f6550a0be8b332f24ad6a7798e1237b2970ef85/tmk_core/common/action_tapping.c)
https://github.com/tmk/tmk_core/blob/master/doc/keymap.md#4-tapping (https://github.com/tmk/tmk_core/blob/master/doc/keymap.md#4-tapping)


Alright thank you for the clarification. I didn't know the proper term indeed. I'll check that out. Have a good day.  :thumb:
Title: Re: TMK keyboard firmware
Post by: mech0nly on Sat, 30 December 2017, 07:40:55
​Hello,

Long story short, I successfully converted my L3 TKL87 PCB to TMK. (thanks to xauser who ported it) ;)
But when I enabled NKRO in Makefile and tried to build the firmware, I got this error
https://drive.google.com/open?id=1wPlM6pYNdwibq7yYsHYYDW3pULFq8pII

I think it has something to do with host.c/.h
How can I implement NKRO on V-USB?
Really need this feature for gaming :)

Thank you.
Title: Re: TMK keyboard firmware
Post by: hasu on Sat, 30 December 2017, 19:26:43
​Hello,

Long story short, I successfully converted my L3 TKL87 PCB to TMK. (thanks to xauser who ported it) ;)
But when I enabled NKRO in Makefile and tried to build the firmware, I got this error
https://drive.google.com/open?id=1wPlM6pYNdwibq7yYsHYYDW3pULFq8pII

I think it has something to do with host.c/.h
How can I implement NKRO on V-USB?
Really need this feature for gaming :)

Thank you.

TMK doesn't support NKRO on V-USB.
I would be happy to help if you have time to implement it!

You will have to start with looking into codes in vusb protocol directory.
https://github.com/tmk/tmk_keyboard/tree/master/tmk_core/protocol/vusb
Title: Re: TMK keyboard firmware
Post by: felixer on Mon, 01 January 2018, 21:14:48
Finally building my own keyboard, it's 6 rows 19 columns, also trying to use a teensy 3.2. After putting in all the work to make the keyboard_common.h and keyboard_plain.c look like i thought it needed to it doesn't compile. I realized after looking at the one key example it don't think this is how these two files are supposed to work for the teensy 3.2? Does any one have an example of a keyboard configuration for the teensy 3.x or LC?
 
here is what probably would have worked for teensy 2.0 s:
Code: [Select]
#ifndef KEYMAP_COMMON_H
#define KEYMAP_COMMON_H

#include <stdint.h>
#include <stdbool.h>
#include "keycode.h"
#include "action.h"
#include "action_macro.h"
#include "action_util.h"
#include "report.h"
#include "host.h"
#include "print.h"
#include "debug.h"
#include "keymap.h"
#ifndef KEYMAP_COMMON_H
#define KEYMAP_COMMON_H


/* felix1 proto */
#define KEYMAP( \
    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, K1F, K1G, K1H, K1I, \
    K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, K2D, K2E, K2F, K2G, K2H, K2I, \
    K30, K31, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B,      K3D, K3E, K3F, K3G, K3H,      \
    K40, K41, K42, K43, K44, K45, K46, K47, K48, K49, K4A,      K4C, K4D, K4E, K4F, K4G, K4H, K4I, \
    K50, K51, K52,           K55,                K59, K5A,      K5C, K5D, K5E, K5F,      K5H,      \
) { \
    { 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_##0E, KC_NO  , KC_NO  , KC_NO  , KC_NO   }, \
    { 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_##1E, KC_##1F, KC_##1G, KC_##1H, KC_##1I }, \
    { 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_##2E, KC_##2F, KC_##2G, KC_##2H, KC_##2I }, \
    { 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_##3E, KC_##3F, KC_##3G, KC_##3H, KC_NO }, \
    { KC_##K40, KC_##K41, KC_##K42, KC_##K43, KC_##C44, KC_##K45, KC_##K46, KC_##K47, KC_##K48, KC_##K49, KC_##K4A, KC_NO   , KC_##K4C, KC_##K4D, KC_##4E, KC_##4F, KC_##4G, KC_##4H, KC_##4I }, \
    { KC_##K50, KC_##K51, KC_##K52, KC_NO,    KC_NO,    KC_##K55, KC_NO   ,    KC_NO,    KC_NO, KC_##K59, KC_##K5A, KC_NO   , KC_##K5C, KC_##K5D, KC_##5E, KC_##5F, KC_NO  , KC_##5H, KC_NO }  \
}

#endif

#endif

and keyboard_plain.c :

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

const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
    /* Layer 0: Default Layer
     * ,--------------------------------------------------------------------------------------------.
     * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|         |  DEL |
     * |--------------------------------------------------------------------------------------------|
     * | ` |  1|  2|  3|  4|  5|  6|  7|  8|  9|  0|  -|  =|    BSp  |  PSRC|     |  /  |  *  |  -  |
     * |--------------------------------------------------------------------------------------------|
     * |Tab  |  Q|  W|  E|  R|  T|  Y|  U|  I|  O|  P|  [|  ]|    \  | PGUP |  7  |  8  |  9  |
     * |---------------------------------------------------------------------------------------  +  |
     * |Contro|  A|  S|  D|  F|  G|  H|  J|  K|  L|  ;|  '|Enter     | PGDN |  4  |  5  |  6  |
     * |--------------------------------------------------------------------------------------------|
     * |Shift   |  Z|  X|  C|  V|  B|  N|  M|  ,|  .|  /|Shift | UP  |      |  1  |  2  |  3  |
     * |---------------------------------------------------------------------------------------  -  |
     * | Ctrl |Gui|Alt  |      Space      |Alt|    Ctrl |LEFT | DOWN | RIGHT|     0     |  .  |
     * `--------------------------------------------------------------------------------------------'
     */
    KEYMAP(ESC,    F1,   F2,   F3,  F4,   F5,  F6,  F7,   F8,    F9,   F10,  F11,  F12,            DEL ,                         \
           GRV,     1,    2,    3,   4,    5,   6,   7,    8,     9,     0,  MINS,  EQL,   BSPC,   PSRC, NMLK, KPDV, KPMU, KPMN, \
           TAB,     Q,    W,    E,   R,    T,   Y,   U,    I,     O,     P,  LBRC, RBRC,   BSLS,   PGUP, KP_7, KP_8, KP_9, KPAD, \
           LCTL,    A,    S,    D,   F,    G,   H,   J,    K,     L,  SCLN,  QUOT,          ENT,   PGDN, KP_4, KP_5, KP_6,       \
           LSFT,    Z,    X,    C,   V,    B,   N,   M, COMM,   DOT,  SLSH,        RSFT,    UP ,       , KP_1, KP_2, KP_3, KPEN, \
           LCTL, LGUI, LALT,             SPC,                  RALT,  RCTL,        LEFT,   DOWN, RIGHT , KP_0      , KPDT       ),
};

const action_t PROGMEM fn_actions[] = {};
Title: Re: TMK keyboard firmware
Post by: Giorgio on Wed, 07 March 2018, 06:36:18
Hello, I'm thinking of purchasing the usb to usb controller from Hasu. Does it recognize multiple keyboards and change layout according to predefined chosen layouts? Is it possible to have additional memory on the controller, for example 1Mega Byte? thanks
Title: Re: TMK keyboard firmware
Post by: hasu on Wed, 07 March 2018, 18:19:57
Hello, I'm thinking of purchasing the usb to usb controller from Hasu. Does it recognize multiple keyboards and change layout according to predefined chosen layouts? Is it possible to have additional memory on the controller, for example 1Mega Byte? thanks

USB-USB converter can recognize four keyboards by default and remap them depeding on your keymap definition. But note that you can have just one keymap, not four.
No USB memory  support.
Title: Re: TMK keyboard firmware
Post by: Giorgio on Thu, 08 March 2018, 02:09:24
Hello, I'm thinking of purchasing the usb to usb controller from Hasu. Does it recognize multiple keyboards and change layout according to predefined chosen layouts? Is it possible to have additional memory on the controller, for example 1Mega Byte? thanks

USB-USB converter can recognize four keyboards by default and remap them depeding on your keymap definition. But note that you can have just one keymap, not four.
No USB memory  support.

How much free space is there after flashing one layout? Would it be possible to install a bigger chip? Thanks
Title: Re: TMK keyboard firmware
Post by: hasu on Thu, 08 March 2018, 09:09:43
Hello, I'm thinking of purchasing the usb to usb controller from Hasu. Does it recognize multiple keyboards and change layout according to predefined chosen layouts? Is it possible to have additional memory on the controller, for example 1Mega Byte? thanks

USB-USB converter can recognize four keyboards by default and remap them depeding on your keymap definition. But note that you can have just one keymap, not four.
No USB memory  support.

How much free space is there after flashing one layout? Would it be possible to install a bigger chip? Thanks

Around 2.5-6.0KB, It depends on build configuration.
https://github.com/tmk/tmk_keyboard/blob/master/tmk_core/doc/build.md#2-features
https://geekhack.org/index.php?topic=69169.msg2569912#msg2569912
Title: Re: TMK keyboard firmware
Post by: Giorgio on Fri, 09 March 2018, 03:43:43
Sorry to bother you again, could you build the controller with a bigger chip, for example a 128k one (or bigger), to have more storage writable space? How much would it cost? thank you.

Someone was considering to use the ATxmega128A4U https://deskthority.net/keyboards-f2/atxmega-keyboard-controller-t9106.html
Title: Re: TMK keyboard firmware
Post by: hasu on Fri, 09 March 2018, 04:23:20
Sorry to bother you again, could you build the controller with a bigger chip, for example a 128k one (or bigger), to have more storage writable space? How much would it cost? thank you.

Someone was considering to use the ATxmega128A4U https://deskthority.net/keyboards-f2/atxmega-keyboard-controller-t9106.html
No, I wont' do that for you. Though, if you willing to pay me 500USD I may consider :D
Title: Re: TMK keyboard firmware
Post by: vvp on Fri, 09 March 2018, 04:54:34
Someone was considering to use the ATxmega128A4U https://deskthority.net/keyboards-f2/atxmega-keyboard-controller-t9106.html
It was me. Depends what firmware you are starting with. If you have a LUFA based ATmega firmware (and no port layer for ARM for it) then it is easy to port it to ATXmega. Otherwise go with some ARM. They are cheaper and bigger.
Title: Re: TMK keyboard firmware
Post by: senso on Fri, 09 March 2018, 05:45:12
I'm waiting for the PSoC 6 BLE to be a bit more widespread/for Cypress to release one of those 10-20$ dev-board, USB, BLE, battery charger, and a lot more goodies all in one nice package.

Atmega32u4 is way too expensive for what it is, and after Atmel was bought by Microchip I cant stand it, always hated Microchip, got screwed over by erratas one too many times, analog chips that didn't meet the specs(well they did, I just cant skim a Microchip datasheet, either read it all or better not touch them), a stupid PicKit3 that cost me 60€ that never worked, waited 1 month to get a new one shipped because mine was one of the early batches with a botched bootloader that killed itself when updating the firmware.

Microchip will slowly kill the atmega, that and having a massive project built around the RFA2 and see the price jump from 4€ to 10€ a piece, thanks for killing 1 year of work with a price jack-up..
Title: Re: TMK keyboard firmware
Post by: Giorgio on Fri, 09 March 2018, 11:06:38
Would it be possible to add some external eeprom storage?
Title: Re: TMK keyboard firmware
Post by: senso on Fri, 09 March 2018, 16:08:03
To run code?

No, the atmega only executes code from its internal flash.
Title: Re: TMK keyboard firmware
Post by: Giorgio on Fri, 09 March 2018, 16:16:42
To run code?

No, the atmega only executes code from its internal flash.

To store data
Title: Re: TMK keyboard firmware
Post by: ErgoMacros on Fri, 09 March 2018, 17:12:36
Adding external EEPROM looks doable... requires 2 IO pins, see here for 32K bytes:
  http://www.hobbytronics.co.uk/arduino-external-eeprom

That could be a lot of layers!
Not fast to switch in a new set of layers, but all you need.
Title: Re: TMK keyboard firmware
Post by: slava on Sat, 24 March 2018, 09:59:51
Is it possible to control lock lights using TMK converter (e.g. PS/2)? E.g. I want to use when a certain layer is enabled.
Title: Re: TMK keyboard firmware
Post by: hasu on Sat, 24 March 2018, 11:49:02
Is it possible to control lock lights using TMK converter (e.g. PS/2)? E.g. I want to use when a certain layer is enabled.

You can control them with 'ps2_host_set_led()'.
This is code for default behaivour for lock lights.
https://github.com/tmk/tmk_keyboard/blob/master/converter/ps2_usb/led.c#L23-L33
Title: Re: TMK keyboard firmware
Post by: slava on Sun, 25 March 2018, 12:16:05
Is it possible to control lock lights using TMK converter (e.g. PS/2)? E.g. I want to use when a certain layer is enabled.

You can control them with 'ps2_host_set_led()'.
This is code for default behaivour for lock lights.
https://github.com/tmk/tmk_keyboard/blob/master/converter/ps2_usb/led.c#L23-L33

Thanks!

A small update to my problem: I decided to modify my ADB-USB converter firmware first.
macOS does not support num lock, so I decided to solve this problem with the TMK. See layers 5 and 6 in the attached file.
All works ok, but, as I already said, I want to control the num lock to highlight the current layer.

As far as I understand I need to write a custom 'action_layer' function, like I did with the 'action_function' to support spacecadet-style shift key.

In this custom 'action_layer'  function I need to call 'led_set'  to turn on or off the num lock light.
Which is a but puzzling for me. Do you have an example of such custom function or could you help me here?
Title: Re: TMK keyboard firmware
Post by: hasu on Sun, 25 March 2018, 18:29:54
You are right but in this case you can also use hook API to control the LED when layer state is changed.
https://github.com/tmk/tmk_keyboard/blob/master/tmk_core/doc/hook.txt
https://github.com/tmk/tmk_keyboard/blob/51326077b085ad5c82cb0ea7c63405364c052cd5/tmk_core/common/hook.h

This code is for my FC660C controller which lights up its LED when Layer1 is turned on.
https://github.com/tmk/tmk_keyboard/blob/22f6cb273e347214bee1c31182764155a584a942/keyboard/fc660c/unimap_emu.c#L57-L65
Title: Re: TMK keyboard firmware
Post by: slava on Mon, 26 March 2018, 02:56:54
You are right but in this case you can also use hook API to control the LED when layer state is changed.
https://github.com/tmk/tmk_keyboard/blob/master/tmk_core/doc/hook.txt
https://github.com/tmk/tmk_keyboard/blob/51326077b085ad5c82cb0ea7c63405364c052cd5/tmk_core/common/hook.h

This code is for my FC660C controller which lights up its LED when Layer1 is turned on.
https://github.com/tmk/tmk_keyboard/blob/22f6cb273e347214bee1c31182764155a584a942/keyboard/fc660c/unimap_emu.c#L57-L65

Ok, thx

Is it how it should look like? I want to enable the LED if layer 2 is on, and disable it if layer 0 is on.

Code: [Select]
void hook_layer_change(uint32_t layer_state)
{
    if (layer_state & (2L<<1)) {
      // turn num lock on if layer 2 is enabled
    } else if (layer_state & (0L<<1)) {
      // turn num lock off if layer 0 is enabled
    }
}

I also looked into the source code of 'led_set'
Code: [Select]
void led_set(uint8_t usb_led)
{
    adb_host_kbd_led(ADB_ADDR_KEYBOARD, ~usb_led);
}

and 'adb_host_kbd_led'

Code: [Select]
// send state of LEDs
void adb_host_kbd_led(uint8_t addr, uint8_t led)
{
    // Listen Register2
    //  upper byte: not used
    //  lower byte: bit2=ScrollLock, bit1=CapsLock, bit0=NumLock
    adb_host_listen(addr, 2, 0, led & 0x07);
}

I'm not good on low-level programming. Could you give an example when 'led_set' turns on and off the num lock  LED for and ADB keyboard?

Thanks.
Title: Re: TMK keyboard firmware
Post by: slava on Tue, 27 March 2018, 07:06:17
Looks like I found how to control lock lights for my case, but I still don't know where is the current state of LED is stored or how to get it.
My code turn all LEDs off except the num lock as you can see from the code.

Code: [Select]
void hook_layer_change(uint32_t layer_state)
{
    if (layer_state & (2L<<1)) {
      // turn num lock on if layer 2 is enabled
      led_set(0x1);
    } else if (~layer_state & (2L<<1)) {
      led_set(0x0);
      // turn num lock off if layer 0 is enabled
    }
}
Title: Re: TMK keyboard firmware
Post by: slava on Tue, 27 March 2018, 11:47:09
If somebody is interested how I solved the problem:

Code: [Select]
void hook_layer_change(uint32_t layer_state) {
    uint8_t current_led_state = host_keyboard_leds();
    // If the 2nd layer is enabled then set
    // the numlock state to ON in the LED state byte
    if((default_layer_state | layer_state) == 1<<2) {
      current_led_state = current_led_state | 0x1);
    }
    led_set(current_led_state);
}

// When you trun the capslock off then
// the numlock LED will be turned off as well
// Thus we need to modify this function to prevent this
void hook_keyboard_leds_change(uint8_t led_status) {
  uint8_t adjusted_led_status = led_status;
  if((default_layer_state | layer_state) == 1<<2)
  {
    // Again if the 2nd layer is enabled, then we need
    // to set the numlock LED state to ON in the LED state byte
    adjusted_led_status = led_status | 0x1;
  }
  keyboard_set_leds(adjusted_led_status);
}
Title: Re: TMK keyboard firmware
Post by: Giorgio on Wed, 09 May 2018, 11:43:41
How do I program the usb2usb converter? It will take days to understand the stuff...

What keyboard editor do you use to configure your layouts?
Which one?
https://tkg.io/
http://www.tmk-kbd.com/tmk_keyboard/
http://kb.sized.io/

Then you download the .c file, you replace the file that you find in the downloaded github tmk mirror, and you flash the firmware using a dfu-programmer?

Currently on windows cygwin with no administrator rights :-)

thanks
Title: Re: TMK keyboard firmware
Post by: Giorgio on Thu, 10 May 2018, 14:12:13
I managed to install an ubuntu virtual machine.
The atmel chip is seen by the system, it shows up in dmesg (new fulls speed device found etc atm32u4dfu, but there's no method known to man to program it.
avrdude not working
make dfu not working
nothing
Title: Re: TMK keyboard firmware
Post by: hasu on Thu, 10 May 2018, 18:37:15
I managed to install an ubuntu virtual machine.
The atmel chip is seen by the system, it shows up in dmesg (new fulls speed device found etc atm32u4dfu, but there's no method known to man to program it.
avrdude not working
make dfu not working
nothing

how did you run 'avrdude' and what error message did you get?
Title: Re: TMK keyboard firmware
Post by: JianYang on Fri, 11 May 2018, 03:27:06
I managed to install an ubuntu virtual machine.
The atmel chip is seen by the system, it shows up in dmesg (new fulls speed device found etc atm32u4dfu, but there's no method known to man to program it.
avrdude not working
make dfu not working
nothing

make dfu never worked for me. I assume that you have installed dfu-programmer?

I always just program manually:
https://github.com/tmk/tmk_keyboard/wiki/FAQ-Build
Code: [Select]
$ sudo dfu-programmer atmega32u4 erase --force
$ sudo dfu-programmer atmega32u4 flash your.hex
$ sudo dfu-programmer atmega32u4 reset
Title: Re: TMK keyboard firmware
Post by: RollyRee on Sat, 12 May 2018, 09:50:48
Hey @Hasu, thanks for making this great software! Unfortunately, I'm having some problems with flashing the firmware. I'm using an OSOYOO Pro Micro (5V/16 mHz) on OS X. When using dfu-programmer to flash, the command "sudo dfu-programmer atmega32u4 flash adb_usb_lufa.hex" results in an error of "no device found".

When using AVRdude to flash, "sudo avrdude -patmega32u4 -cavr109 -P/dev/tty.usbmodem1411  -b57600   -D -Uflash:w:adb_usb_leonardo.hex:i -v" results in the error of "avrdude: ser_open(): can't open device /dev/tty.usbmodem1411": Device not configured".

Any idea what's going on? Could it be because my Pro Micro is currently running Blinky while I'm trying to flash the firmware?

Title: Re: TMK keyboard firmware
Post by: JianYang on Sun, 13 May 2018, 04:45:41
Hey @Hasu, thanks for making this great software! Unfortunately, I'm having some problems with flashing the firmware. I'm using an OSOYOO Pro Micro (5V/16 mHz) on OS X. When using dfu-programmer to flash, the command "sudo dfu-programmer atmega32u4 flash adb_usb_lufa.hex" results in an error of "no device found".

When using AVRdude to flash, "sudo avrdude -patmega32u4 -cavr109 -P/dev/tty.usbmodem1411  -b57600   -D -Uflash:w:adb_usb_leonardo.hex:i -v" results in the error of "avrdude: ser_open(): can't open device /dev/tty.usbmodem1411": Device not configured".

Any idea what's going on? Could it be because my Pro Micro is currently running Blinky while I'm trying to flash the firmware?



You can only upload when the device is in the bootloader. IIRC, with DFU, it will be in the bootloader for about 2 seconds after powerup/reset. During this window, you need to run "sudo dfu-programmer atmega32u4 erase". Keep in mind that it will only work after the os has registered the device, so you probably have less than a 1 second window to do this. I recommend spamming this command until it succeeds. Then you can flash and reset with the commands in my previous post.

If you want to use avrdude, you would need to have the ISP connected with a AVRISP or an arduino to simulate one. But this method could wipe your bootloader, so I do not recommend it.

How did you manage to program blinky?
Title: Re: TMK keyboard firmware
Post by: Giorgio on Tue, 15 May 2018, 10:36:55
Fantastic usb_usb converter. Now it works perfectly. I had some trouble because it was in a virtual machine, with an old vmware version.

I can't understand how can I have a key to reboot the converter without pressing the button on the device. How do I define in keymap.c an fn0 key to enter into program mode? I've tried many examples but they all fail. Thanks
Title: Re: TMK keyboard firmware
Post by: hasu on Thu, 17 May 2018, 18:47:46
Fantastic usb_usb converter. Now it works perfectly. I had some trouble because it was in a virtual machine, with an old vmware version.

I can't understand how can I have a key to reboot the converter without pressing the button on the device. How do I define in keymap.c an fn0 key to enter into program mode? I've tried many examples but they all fail. Thanks

If you use Keymap file BTLD keycode should work for you. You don't have to define FN0 yourself, just use BTLD.

Meanwhile, BTLD code doesn't work in Actionmap or Unimap this will be fixed later. The issue was filed in github. https://github.com/tmk/tmk_keyboard/issues/557
Workaround for this is to define a function like below.
Code: [Select]
diff --git a/converter/usb_usb/unimap.c b/converter/usb_usb/unimap.c
index 0f34ece..70a9c84 100644
--- a/converter/usb_usb/unimap.c
+++ b/converter/usb_usb/unimap.c
@@ -15,9 +15,13 @@ You should have received a copy of the GNU General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 #include "unimap_trans.h"
+#include "wait.h"
+#include "bootloader.h"
 
 
 #define AC_FN0 ACTION_LAYER_MOMENTARY(1)
+#undef  AC_BTLD
+#define AC_BTLD ACTION_FUNCTION(1)
 
 #ifdef KEYMAP_SECTION_ENABLE
 const action_t actionmaps[][UNIMAP_ROWS][UNIMAP_COLS] __attribute__ ((section (".keymap.keymaps"))) = {
@@ -39,7 +43,20 @@ const action_t actionmaps[][UNIMAP_ROWS][UNIMAP_COLS] PROGMEM = {
     ESC, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12, INS, DEL,      TRNS,TRNS,TRNS,    TRNS,TRNS,TRNS,TRNS,
     TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PSCR,SLCK,PAUS,UP,  INS,      TRNS,     TRNS,TRNS,TRNS,    TRNS,TRNS,TRNS,TRNS,
     TRNS,VOLD,VOLU,MUTE,TRNS,TRNS,TRNS,TRNS,HOME,PGUP,LEFT,RGHT,     TRNS,TRNS,                        TRNS,TRNS,TRNS,TRNS,
-    TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,END, PGDN,DOWN,     TRNS,TRNS,          PGUP,         TRNS,TRNS,TRNS,TRNS,
+    TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,BTLD,TRNS,TRNS,END, PGDN,DOWN,     TRNS,TRNS,          PGUP,         TRNS,TRNS,TRNS,TRNS,
     TRNS,TRNS,TRNS,TRNS,          TRNS,          TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,     HOME,PGDN,END,     TRNS,     TRNS,TRNS
     ),
 };
+
+
+void action_function(keyrecord_t *record, uint8_t id, uint8_t opt)
+{
+    switch (id) {
+        case 1:
+            clear_keyboard();
+            wait_ms(50);
+            bootloader_jump(); // not return
+            break;
+    }
+}
+
Title: Re: TMK keyboard firmware
Post by: Giorgio on Fri, 18 May 2018, 02:29:49
Thanks, I can confirm that the BTLD keycode works perfectly in keymap.c, allowing to reprogram the converter with the "sudo make dfu" command.

You need first to type "sudo make dfu", and then to use the BTLD code, or the keyboard will stop working until the next replug; probably I'll hide the BTLD behind a macro or something similar.
Title: Re: TMK keyboard firmware
Post by: RollyRee on Sat, 19 May 2018, 18:26:53
Hey @Hasu, thanks for making this great software! Unfortunately, I'm having some problems with flashing the firmware. I'm using an OSOYOO Pro Micro (5V/16 mHz) on OS X. When using dfu-programmer to flash, the command "sudo dfu-programmer atmega32u4 flash adb_usb_lufa.hex" results in an error of "no device found".

When using AVRdude to flash, "sudo avrdude -patmega32u4 -cavr109 -P/dev/tty.usbmodem1411  -b57600   -D -Uflash:w:adb_usb_leonardo.hex:i -v" results in the error of "avrdude: ser_open(): can't open device /dev/tty.usbmodem1411": Device not configured".

Any idea what's going on? Could it be because my Pro Micro is currently running Blinky while I'm trying to flash the firmware?



You can only upload when the device is in the bootloader. IIRC, with DFU, it will be in the bootloader for about 2 seconds after powerup/reset. During this window, you need to run "sudo dfu-programmer atmega32u4 erase". Keep in mind that it will only work after the os has registered the device, so you probably have less than a 1 second window to do this. I recommend spamming this command until it succeeds. Then you can flash and reset with the commands in my previous post.

If you want to use avrdude, you would need to have the ISP connected with a AVRISP or an arduino to simulate one. But this method could wipe your bootloader, so I do not recommend it.

How did you manage to program blinky?

I programmed Blinky using the Arduino IDE software. I just pressed compile, and uploaded it, and it worked.
Maybe something with the fact that it's an OSOYOO pro micro and incompatible with DFU? I think someone told me that...
Sorry for the late response!
Title: Re: TMK keyboard firmware
Post by: JianYang on Sun, 20 May 2018, 06:49:41
If
I programmed Blinky using the Arduino IDE software. I just pressed compile, and uploaded it, and it worked.
Maybe something with the fact that it's an OSOYOO pro micro and incompatible with DFU? I think someone told me that...
Sorry for the late response!

You can see the command used to program it in arduino if you enable 'show verbose output during:' in settings. Then just modify it to upload your hex file instead.
Title: Re: TMK keyboard firmware
Post by: Giorgio on Sun, 20 May 2018, 08:08:38
Is there any guide to learn more about tmk beside what's on the repository? Thanks
Title: Re: TMK keyboard firmware
Post by: RollyRee on Sun, 20 May 2018, 11:22:44
If
I programmed Blinky using the Arduino IDE software. I just pressed compile, and uploaded it, and it worked.
Maybe something with the fact that it's an OSOYOO pro micro and incompatible with DFU? I think someone told me that...
Sorry for the late response!

You can see the command used to program it in arduino if you enable 'show verbose output during:' in settings. Then just modify it to upload your hex file instead.

Thanks for the help! However, Bash outputs the following when I type in the command you mentioned: "Connecting to programmer: .avrdude: butterfly_recv(): programmer is not responding". What's going on?
Title: Re: TMK keyboard firmware
Post by: JianYang on Mon, 21 May 2018, 01:41:08
Thanks for the help! However, Bash outputs the following when I type in the command you mentioned: "Connecting to programmer: .avrdude: butterfly_recv(): programmer is not responding". What's going on?

I suspect the avrdude command might be preceded by a command to reset the device or something along those lines. Does it still work when you program blinky from avrdude?
Title: Re: TMK keyboard firmware
Post by: RollyRee on Wed, 23 May 2018, 18:52:54
Typing in avrdude -c avrisp -p atmega32u4 -U flash:w:blink.hex

Gives an error of

avrdude: ser_open(): can't open device "unknown": No such file or directory

avrdude done.  Thank you.
Title: Re: TMK keyboard firmware
Post by: JianYang on Thu, 24 May 2018, 04:07:52
Typing in avrdude -c avrisp -p atmega32u4 -U flash:w:blink.hex

Gives an error of

avrdude: ser_open(): can't open device "unknown": No such file or directory

avrdude done.  Thank you.


Because the command is incomplete. You did not specify the port. Copy the entire line from arduino output. Also check the preceding commands for a python script or other command that resets the avr.
Title: Re: TMK keyboard firmware
Post by: RollyRee on Fri, 25 May 2018, 17:37:33
I just have a quick question (I think I'm pretty close to figuring it out myself  :)). When typing

make -f Makefile.<variant> clean
make -f Makefile.<variant>

What does the <variant> refer to? I'm trying to build adb_usb if that helps.
Title: Re: TMK keyboard firmware
Post by: JianYang on Sat, 26 May 2018, 00:24:13
I just have a quick question (I think I'm pretty close to figuring it out myself  :)). When typing

make -f Makefile.<variant> clean
make -f Makefile.<variant>

What does the <variant> refer to? I'm trying to build adb_usb if that helps.

If you look in the folder, there are usually two files, Makefile.lufa and Makefile.pjrc . If you are programming to a teensy, use Makefile.pjrc, if you have a lufa-based bootloader, use Makefile.lufa.
Title: Re: TMK keyboard firmware
Post by: sth on Mon, 18 June 2018, 17:44:48
many apologies if this was posted previously but i have started noticing lately that my tmk keyboards cause a weird kb/mouse input 'lockup' on multiple Linux distros. sometimes it will work fine and then out of nowhere my mouse cursor will freeze and will not track until i click the mouse button.

i confirmed this with two tmk boards (hhkb1 controller and a gh60) and the same behavior persists across both boards. i do not experience the issue with a stock hhkb pro1 so i thought i'd start here and see if anyone else has experienced this.

unfortunately i do not have any hardware windows machines to test this on and i don't use a keyboard often with my fiance's macbook so i have no data there either.
Title: Re: TMK keyboard firmware
Post by: hasu on Mon, 18 June 2018, 18:19:05
many apologies if this was posted previously but i have started noticing lately that my tmk keyboards cause a weird kb/mouse input 'lockup' on multiple Linux distros. sometimes it will work fine and then out of nowhere my mouse cursor will freeze and will not track until i click the mouse button.

i confirmed this with two tmk boards (hhkb1 controller and a gh60) and the same behavior persists across both boards. i do not experience the issue with a stock hhkb pro1 so i thought i'd start here and see if anyone else has experienced this.

unfortunately i do not have any hardware windows machines to test this on and i don't use a keyboard often with my fiance's macbook so i have no data there either.

Any output in log files when the lockup happens?

You have used the keyboards without problem before, and you see the 'lockup' happens lately, right?
Then, did you update firmware, keymap, OS or PC hardware lately?

I'd try to use default/plain keymap first.


EDIT: and use trusty USB cable,  Ive seen people have various problems with cheap or badly crafted cables out of spec.
Title: Re: TMK keyboard firmware
Post by: sth on Mon, 18 June 2018, 18:30:52
many apologies if this was posted previously but i have started noticing lately that my tmk keyboards cause a weird kb/mouse input 'lockup' on multiple Linux distros. sometimes it will work fine and then out of nowhere my mouse cursor will freeze and will not track until i click the mouse button.

i confirmed this with two tmk boards (hhkb1 controller and a gh60) and the same behavior persists across both boards. i do not experience the issue with a stock hhkb pro1 so i thought i'd start here and see if anyone else has experienced this.

unfortunately i do not have any hardware windows machines to test this on and i don't use a keyboard often with my fiance's macbook so i have no data there either.

Any output in log files when the lockup happens?

You have used the keyboards without problem before, and you see the 'lockup' happens lately, right?
Then, did you update firmware, keymap, OS or PC hardware lately?

I'd try to use default/plain keymap first.


ok i will try to reflash with a default keymap and i'll check my logs.
i have not updated firmware, keymap or hardware lately but I normally use a rolling release linux distro so my kernel and other software changes often. however, i noticed this on ubuntu as well which doesn't receive nearly as many kernel updates. it actually started happening last year but it was intermittent and then i switched to a non-tmk board for an unrelated reason so i forgot all about it :))
Title: Re: TMK keyboard firmware
Post by: RollyRee on Sat, 08 September 2018, 10:28:57
So I'm pretty new to this stuff, and I just can't manage to flash the adb_usb software on my OSOYOO Pro Micro. If anyone has the time, could they go over the whole process in a simple way? Thanks!
Title: Re: TMK keyboard firmware
Post by: Tactile on Sat, 08 September 2018, 16:54:56
So I'm pretty new to this stuff, and I just can't manage to flash the adb_usb software on my OSOYOO Pro Micro. If anyone has the time, could they go over the whole process in a simple way? Thanks!

What computer operating system?
Title: Re: TMK keyboard firmware
Post by: RollyRee on Sun, 09 September 2018, 11:49:01
Sorry, forgot to mention that. I'm using OS X for this.
Title: Re: TMK keyboard firmware
Post by: 624245305 on Sun, 14 October 2018, 02:19:10
I seem to have a problem. The make in QMK compiles the HEX file, but the LED indicator of CAPS/NUMLK/SCRLK is not configured, and I don't know how to configure the PIN pin. I seem to have perfected about the matrix, of course I have not enabled the FN layer.(http://)
Title: Re: TMK keyboard firmware
Post by: thebeae on Wed, 28 November 2018, 22:56:12
Figured out my issue disregard :)
Title: Re: TMK keyboard firmware
Post by: PierceSutton on Tue, 08 January 2019, 21:33:18
How would I set up the code is I wanted a key, IE spacebar, that when pressed for an extended period of time would register in it being tapped multiple times rather than being held down.
I would like to bhop in csgo without having to use my scroll to jump :)
It would be cool If I could set this up as a secondary layer also.
Title: Re: TMK keyboard firmware
Post by: Harima on Tue, 16 April 2019, 02:30:48
Hi guys I have a question. I want to make a macro that lets me hold down a key and rapidly taps it as I hold down. For example, I want to hold down Keypad 0 (P0) and have the firmware repeatedly tap P0 so I don't have to manually keep mashing on P0, which would help tremendously on a game I play with a ton of text boxes. I skimmed through the github but I might have missed it. Is it possible?
Title: Re: TMK keyboard firmware
Post by: henz on Thu, 25 April 2019, 05:00:46
Hi guys I have a question. I want to make a macro that lets me hold down a key and rapidly taps it as I hold down. For example, I want to hold down Keypad 0 (P0) and have the firmware repeatedly tap P0 so I don't have to manually keep mashing on P0, which would help tremendously on a game I play with a ton of text boxes. I skimmed through the github but I might have missed it. Is it possible?

It totally is, but you have to write your macros yourself, i have made a macro which writes the swedish characters åäö when im using a US layout. so not having to switch between languages.
Title: Re: TMK keyboard firmware
Post by: Harima on Fri, 26 April 2019, 02:02:24
Hi guys I have a question. I want to make a macro that lets me hold down a key and rapidly taps it as I hold down. For example, I want to hold down Keypad 0 (P0) and have the firmware repeatedly tap P0 so I don't have to manually keep mashing on P0, which would help tremendously on a game I play with a ton of text boxes. I skimmed through the github but I might have missed it. Is it possible?

It totally is, but you have to write your macros yourself, i have made a macro which writes the swedish characters åäö when im using a US layout. so not having to switch between languages.

Thanks, but I just searched the thread and hasu said key repeating is not easy to implement in the firmware
Title: Re: TMK keyboard firmware
Post by: PancakeMSTR on Sat, 27 July 2019, 14:22:16
I'm trying to wrap my head around TMK, and am having some trouble. Hasu directed me here to get help.

I'm hoping this will inform me generally on how to do this, but I'll stick to a concrete example for this discussion.

Recently, I was successful in using TMK to convert my Zenith Z-150 to usb. What I did was download the TMK repo and used the xt_usb (https://github.com/tmk/tmk_keyboard/tree/master/converter/xt_usb) converter to produce a hex file for my Zenith. Note that I built the hex from source, just cause I prefer doing it that way. This worked really well, and I am now at the point where I'm working remapping the keys.


Note that I understand how to remap the keys with the default xt layout - just find the key you want to remap in the  keymap.c file and change it's function.

That being said, I'd like to be able to change the physical layout in the keymap.c file, as I've encountered this problem before. That is, the keymap.c file for the xt_usb converter matches the physical layout of the IBM F XT identically:
Code: [Select]
    /* IBM XT keyboard layout
     * ,-------.  ,--------------------------------------------------------------------------.
     * | F1| F2|  |Esc|  1|  2|  3|  4|  5|  6|  7|  8|  9|  0|  -|  =|  BS  |NumLck |ScrLck |
     * |-------|  |--------------------------------------------------------------------------|
     * | F3| F4|  | Tab |  Q|  W|  E|  R|  T|  Y|  U|  I|  O|  P|  [|  ] |   |  7|  8|  9|  -|
     * |-------|  |------------------------------------------------------|Ent|---------------|
     * | F5| F6|  | Ctrl |  A|  S|  D|  F|  G|  H|  J|  K|  L|  ;|  '|  `|   |  4|  5|  6|   |
     * |-------|  |----------------------------------------------------------------------|   |
     * | F7| F8|  |Shif|  \|  Z|  X|  C|  V|  B|  N|  M|  ,|  .|  /|Shift|  *|  1|  2|  3|  +|
     * |-------|  |----------------------------------------------------------------------|   |
     * | F9|F10|  |  Alt  |               Space                  |CapsLck|   0   |   .   |   |
     * `-------'  `--------------------------------------------------------------------------'
     */

for which the keymap is
Code: [Select]
    KEYMAP_XT( \
    F1,  F2,    ESC, 1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   MINS,EQL, BSPC,     NLCK,     SLCK,
    F3,  F4,    TAB, Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,   LBRC,RBRC,     P7,  P8,  P9,  PMNS,
    F5,  F6,    LCTL,A,   S,   D,   F,   G,   H,   J,   K,   L,   SCLN,QUOT,GRV, ENT, P4,  P5,  P6,
    F7,  F8,    LSFT,BSLS,Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, SLSH,RSFT,PAST,P1,  P2,  P3,  PPLS,
    F9,  F10,   LALT,                    SPC,                          CAPS,          P0,       PDOT
    ),

On the other hand, the Zenith Z150's physical layout is

Code: [Select]
    /* Zenith Z150
     * ,-------.  ,--------------------------------------------------------------------------.
     * | F1| F2|  |Esc|  1|  2|  3|  4|  5|  6|  7|  8|  9|  0|  -|  =|  BS  |NumLck |ScrLck |
     * |-------|  |--------------------------------------------------------------------------|
     * | F3| F4|  | Tab |  Q|  W|  E|  R|  T|  Y|  U|  I|  O|  P|  [|  ] |   |  7|  8|  9|  -|
     * |-------|  |------------------------------------------------------|Ent|---------------|
     * | F5| F6|  | Ctrl |  A|  S|  D|  F|  G|  H|  J|  K|  L|  ;|  '|       |  4|  5|  6|  +|
     * |-------|  |--------------------------------------------------------------------------|
     * | F7| F8|  | Shift  |  Z|  X|  C|  V|  B|  N|  M|  ,|  .|  /|Shift|  *|  1|  2|  3|Ent|
     * |-------|  |----------------------------------------------------------------------|   |
     * | F9|F10|  |  Alt  | \|            Space                  |CapsLck|   0   |   .   |   |
     * `-------'  `--------------------------------------------------------------------------'
     */   

For which I'd like the corresponding keymap to be
Code: [Select]
    KEYMAP_ZENITHZ150( \
    F1,  F2,    ESC, 1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   MINS,EQL, BSPC, GRV,NLCK,     SLCK,
    F3,  F4,    TAB, Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,   LBRC,RBRC,     P7,  P8,  P9,  PMNS,
    F5,  F6,    LCTL,A,   S,   D,   F,   G,   H,   J,   K,   L,   SCLN,QUOT, ENT, P4,  P5,  P6,PPLS.
    F7,  F8,    LSFT,Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, SLSH,RSFT,PAST,P1,  P2,  P3,  PADENT(?),
    F9,  F10,   LALT,BSLS,                SPC,                          CAPS,          P0,       PDOT
    ),

I'm not sure what I need to modify to make this change though, and was really hoping you could help me work through the process. I'd love to learn about this!

Let me know if you have any questions or would like me to clarify anything. Thanks so much!

**************************************************************************
Additionally, I ran into a problem while trying to remap that I'm having trouble solving. I'd like to have the caps lock key on my Zenith behave like a layer toggle button. I've come up with the following

Code: [Select]
const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
    /* IBM XT keyboard layout
     * ,-------.  ,--------------------------------------------------------------------------.
     * | F1| F2|  |Esc|  1|  2|  3|  4|  5|  6|  7|  8|  9|  0|  -|  =|  BS  |NumLck |ScrLck |
     * |-------|  |--------------------------------------------------------------------------|
     * | F3| F4|  | Tab |  Q|  W|  E|  R|  T|  Y|  U|  I|  O|  P|  [|  ] |   |  7|  8|  9|  -|
     * |-------|  |------------------------------------------------------|Ent|---------------|
     * | F5| F6|  | Ctrl |  A|  S|  D|  F|  G|  H|  J|  K|  L|  ;|  '|  `|   |  4|  5|  6|   |
     * |-------|  |----------------------------------------------------------------------|   |
     * | F7| F8|  |Shif|  \|  Z|  X|  C|  V|  B|  N|  M|  ,|  .|  /|Shift|  *|  1|  2|  3|  +|
     * |-------|  |----------------------------------------------------------------------|   |
     * | F9|F10|  |  Alt  |               Space                  |CapsLck|   0   |   .   |   |
     * `-------'  `--------------------------------------------------------------------------'
     */

    KEYMAP_XT( \
    F1,  F2,    ESC, 1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   MINS,EQL, BSPC,     NLCK,     SLCK,
    F3,  F4,    TAB, Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,   LBRC,RBRC,     P7,  P8,  P9,  PMNS,
    F5,  F6,    CAPS,A,   S,   D,   F,   G,   H,   J,   K,   L,   SCLN,QUOT,GRV, ENT, P4,  P5,  P6,
    F7,  F8,    LSFT,LALT,Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, SLSH,RSFT,PAST,P1,  P2,  P3,  PPLS,
    F9,  F10,   LCTRL,                    SPC,                          FN2,          P0,       PDOT
    ),   

    KEYMAP_XT( \
    F1,  F2,    ESC, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10,   MINS,EQL, BSPC,     NLCK,     SLCK,
    F3,  F4,    TAB, Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,   LBRC,RBRC,     P7,  P8,  P9,  PMNS,
    F5,  F6,    CAPS,A,   S,   D,   F,   G,   H,   J,   K,   L,   SCLN,QUOT,GRV, ENT, P4,  P5,  P6,
    F7,  F8,    LSFT,LGUI,Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, SLSH,RSFT,PAST,P1,  P2,  P3,  PPLS,
    F9,  F10,   LCTRL,                    SPC,                          TRNS,          P0,       PDOT
    ),       


};

with

Code: [Select]
const action_t PROGMEM fn_actions[] = {
        ACTION_LAYER_TOGGLE(1), //FN2
};

But it's not working, and I can't figure out why. Does someone know what's going on here?
Title: Re: TMK keyboard firmware
Post by: hasu on Sun, 28 July 2019, 18:03:10
To define KEYMAP_ZENITHZ150 in keymap_common.h or unimap_common.h for your Zenith 150:

For keymap_common.h, see how KEYMAP_XT is defined in the file. I hope that this looks obvious for coders.

It is macro definition which takes 83 parameters(IBM XT has that number of physiical keys).
https://en.wikipedia.org/wiki/C_preprocessor#Macro_definition_and_expansion

For example, XT protocol scan code for 'F1' is 0x3B and 'Space' is 0x39. So it uses 'K3B' and 'K39' as parameter for the keys respectively in first part of the '#define'. You can rearrange the first part for your keyboard physical layout.

The second part defines array of keymapping which conveters XT scan codes to TMK keycodes. The array has 8x16 space and its 128 elements correspond to XT scan codes 0x00-7F in order. Place 'KC_NO' in element if your keyboard doesn't have key for scan code the element indicates. Otherwise use 'KC_##Kxx', which is expanded for TMK keycode when it is compiled, as you define in your keymap.


Code: [Select]
/* IBM XT keyobard layout
 * ,-------.  ,--------------------------------------------------------------------------.
 * | F1| F2|  |Esc|  1|  2|  3|  4|  5|  6|  7|  8|  9|  0|  -|  =|  BS  |NumLck |ScrLck |
 * |-------|  |--------------------------------------------------------------------------|
 * | F3| F4|  | Tab |  Q|  W|  E|  R|  T|  Y|  U|  I|  O|  P|  [|  ] |   |  7|  8|  9|  -|
 * |-------|  |------------------------------------------------------|Ent|---------------|
 * | F5| F6|  | Ctrl |  A|  S|  D|  F|  G|  H|  J|  K|  L|  ;|  '|  `|   |  4|  5|  6|   |
 * |-------|  |----------------------------------------------------------------------|   |
 * | F7| F8|  |Shif|  \|  Z|  X|  C|  V|  B|  N|  M|  ,|  .|  /|Shift|  *|  1|  2|  3|  +|
 * |-------|  |----------------------------------------------------------------------|   |
 * | F9|F10|  |  Alt  |               Space                  |CapsLck|   0   |   .   |   |
 * `-------'  `--------------------------------------------------------------------------'
 * Scan code set 1
 * ,-------.  ,--------------------------------------------------------------------------.
 * | 3B| 3C|  | 01| 02| 03| 04| 05| 06| 07| 08| 09| 0A| 0B| 0C| 0D|  0E  |  45   |  46   |
 * |-------|  |--------------------------------------------------------------------------|
 * | 3D| 3E|  | 0F  | 10| 11| 12| 13| 14| 15| 16| 17| 18| 19| 1A| 1B |   | 47| 48| 49| 4A|
 * |-------|  |------------------------------------------------------| 1C|---------------|
 * | 3F| 40|  | 1D   | 1E| 1F| 20| 21| 22| 23| 24| 25| 26| 27| 28| 29|   | 4B| 4C| 4D|   |
 * |-------|  |----------------------------------------------------------------------|   |
 * | 41| 42|  | 2A | 2B| 2C| 2D| 2E| 2F| 30| 31| 32| 33| 34| 35|  36 | 37| 4F| 50| 51| 4E|
 * |-------|  |----------------------------------------------------------------------|   |
 * | 43| 44|  |  38   |              39                      |  3A   |  52   |  53   |   |
 * `-------'  `--------------------------------------------------------------------------'
 */
#define KEYMAP_XT( \
    K3B,K3C,  K01,K02,K03,K04,K05,K06,K07,K08,K09,K0A,K0B,K0C,K0D,K0E,    K45,    K46, \
    K3D,K3E,  K0F,K10,K11,K12,K13,K14,K15,K16,K17,K18,K19,K1A,K1B,    K47,K48,K49,K4A, \
    K3F,K40,  K1D,K1E,K1F,K20,K21,K22,K23,K24,K25,K26,K27,K28,K29,K1C,K4B,K4C,K4D,     \
    K41,K42,  K2A,K2B,K2C,K2D,K2E,K2F,K30,K31,K32,K33,K34,K35,K36,K37,K4F,K50,K51,K4E, \
    K43,K44,  K38,                    K39,                    K3A,    K52,    K53      \
) { \
    { KC_NO,    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_##K0E, KC_##K0F }, \
    { 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_##K1F }, \
    { 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_##K2E, KC_##K2F }, \
    { 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_##K3E, KC_##K3F }, \
    { KC_##K40, KC_##K41, KC_##K42, KC_##K43, KC_##K44, KC_##K45, KC_##K46, KC_##K47 }, \
    { KC_##K48, KC_##K49, KC_##K4A, KC_##K4B, KC_##K4C, KC_##K4D, KC_##K4E, KC_##K4F }, \
    { KC_##K50, KC_##K51, KC_##K52, KC_##K53, KC_NO,    KC_NO,    KC_NO,    KC_NO    }, \
    { KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO    }, \
    { KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO    }, \
    { KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO    }, \
    { KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO    }, \
    { KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO    }  \
}


**************************************************************************
It is FN0. Use FN0 instead of FN2.
Title: Re: TMK keyboard firmware
Post by: PancakeMSTR on Mon, 29 July 2019, 09:11:16
Thanks hasu. Info is very useful, I'll try working with it and get back to you.
Title: Re: TMK keyboard firmware
Post by: PancakeMSTR on Sun, 04 August 2019, 16:37:29
Got it! Thanks Hasu!
Title: Re: TMK keyboard firmware
Post by: PancakeMSTR on Sat, 07 September 2019, 13:32:10
Having a new problem with TMK (and QMK, but hopefully solving the problem in TMK will help solve the problem in QMK).

I'm trying to convert a NMB (Hi-Tek) RT101+ (https://deskthority.net/wiki/NMB_RT-100/RT-8200_series) to USB. It has a switch that can toggle between AT/XT. I have it set to AT mode and I'm trying to use TMK's ps2-usb (https://github.com/tmk/tmk_keyboard/tree/master/converter/ps2_usb) converter to convert it to USB. Note that the keyboard works flawlessly with a blue cube ps2/usb converter.

I'm trying to use a pro micro, which is possibly causing problems. I don't have a teensy 2.0 on hand to test, but I'd prefer to get this working with a pro micro anyway as I have some other AT/ps2 keyboards to convert and if I can use a pro micro it's a lot cheaper.

NOTE: I JUST noticed that I'm supposed to have pull up resistors, which I DO NOT have soldered in. I will test this, but I'm also not sure where to put them. Can anyone tell me where they are supposed to go? Thanks

This image (https://imgur.com/a/WDXwOqy) shows how I've wired things up.

Here's what I've tried (with TMK at least, I've done some testing with Soarer's and QMK and neither of those are working either):

- Tried building TMK ps2usb firmware (just make in tmk_keyboard/converter/ps2_usb)
Behavior: No output, no device recognized by windows (i.e. no "device plugged in" ding).
I tried this both with the default pinout (Clock PD1, Data PD0) and with the pins assigned as I actually have them wired (Clock PD3, Data PD2). Both versions exhibit identical behavior.


- Tried building ps2_usb rev1, which is supposed to use USART engine (make -f Makefile.rev1).
Behavior: Device recognized ding/jingle from windows, but no output from keyboard. HID listen shows the following:
Code: [Select]
Waiting for device:.......
Listening:
TMK:unknown/LUFA
USB configured.
Keyboard start.
Again, I tried this with the default pinout (Clock PD5, Data PD2) and my wiring (Clock PD3, Data PD2). Same behavior.

- Tried building ps2_usb rev2, which is supposed to use USART engine (make -f Makefile.rev2). I think the behavior is identical to rev1.
As usual, I tried this with the default pinout (Clock PD5, Data PD2) and my wiring (Clock PD3, Data PD2).


So, ideally, I'd like to get the interrupt (default?) method working, since it's "recommended," and failing that I'd like to get any version working. I'll give pull up resistors a try and see if that does it, but otherwise I'm at a loss and need help.

Thanks! And please let me know if I need to clarify anything!


--------------------------------------------------------------------------------
Update: Still not working
--------------------------------------------------------------------------------

Changed wiring to this  (https://imgur.com/a/WDXwOqy) and added pull up resistors. Tried all three ps2_usb variants (default make, make rev1, and make rev2), and none work. I also tried jumping J1 for 5V operation, to no effect.

- For default make (just running make in the ps2_usb directory), I get nothing at all. When I plug it into my windows computer I don't even get the "Device connected" sound. So, no change to behavior.

- For make rev1 (#make -f Makefile.rev1), at least windows recognizes that something was plugged in (Device connected sound plays), and HID listen sees something plugged in, but I can't get any output.

- Behavior for make rev2 (#make -f Makefile.rev2) is identical to default make, i.e. windows doesn't even think anything got plugged in.






Title: Re: TMK keyboard firmware
Post by: hasu on Sat, 07 September 2019, 19:54:13
PancakeMSTR,
Use rev1 firmware for pro micro. (rev2 is for newer TMK converter with ATMega32u2, not for you at all.)

By default pin configuration for rev1 are PD2 and PD5 with USART. BTW, rev1 firmware is for old TMK converter with ATMega32u4.
https://github.com/tmk/tmk_keyboard/blob/master/converter/ps2_usb/Makefile.rev1#L13-L15

So you have to use PD2 and PD5 with default rev1 firmware and the covnerter should work.

And try other ps/2 keyboard than  NMB (Hi-Tek) RT101+ if it doesn't work.
Title: Re: TMK keyboard firmware
Post by: PancakeMSTR on Sun, 08 September 2019, 17:49:17
Hasu,

Thanks for getting back to me. I tested the ps2_usb converter with a different keyboard, one that's labeled "AT only" and has a ps2 connector. Long story short, I'm getting the same behavior, i.e. no output.

Here's a diagram (https://imgur.com/dyeaok5) of how I have things wired up. I didn't draw the GND and VCC line but they just run to GND and VCC on the pro micro.

As you can see, I wired the clock line into PD3 (TX0), because the pro micro does not have a PD5 pin. I correspondingly adjusted the pinout for PS2_USE_USART in config_rev1.h to use PD3 for clock:

Code: [Select]
/*
 * PS/2 USART
 */
#ifdef PS2_USE_USART
#if defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__)
/* XCK for clock line and RXD for data line */
#define PS2_CLOCK_PORT  PORTD
#define PS2_CLOCK_PIN   PIND
#define PS2_CLOCK_DDR   DDRD
#define PS2_CLOCK_BIT   3//5
#define PS2_DATA_PORT   PORTD
#define PS2_DATA_PIN    PIND
#define PS2_DATA_DDR    DDRD
#define PS2_DATA_BIT    2

Then, to build the firmware, I ran

Code: [Select]
make -f clean Makefile.rev1
make -f Makefile.rev1

and wrote the hex file ps2_usb_rev1.hex to my pro micro.

I'm still hoping we can figure out how to get this working on a pro micro. What can I try next?
Title: Re: TMK keyboard firmware
Post by: hasu on Sun, 08 September 2019, 19:07:54
You can't configure pins for USART, pins for USART is fixed and not configurable.
If PD5 is not available on pro micro then, you have to use BUSYWAIT or INT backend.
You can configure pins freely for BUSYWAIT in config_rev1.h.
Or copy INT pin configuration in config_rev2.h to config_rev.h. And use PD0 and PD1. Don't change pins if you are not familiar with the MCU.

I think this works but I don't have time and pro miro available in hand to test this at this point.
Apparently current README and pin configuration is not useful for usual DIYers, I'll update them when I get time.



Hasu,

Thanks for getting back to me. I tested the ps2_usb converter with a different keyboard, one that's labeled "AT only" and has a ps2 connector. Long story short, I'm getting the same behavior, i.e. no output.

Here's a diagram (https://imgur.com/dyeaok5) of how I have things wired up. I didn't draw the GND and VCC line but they just run to GND and VCC on the pro micro.

As you can see, I wired the clock line into PD3 (TX0), because the pro micro does not have a PD5 pin. I correspondingly adjusted the pinout for PS2_USE_USART in config_rev1.h to use PD3 for clock:

Code: [Select]
/*
 * PS/2 USART
 */
#ifdef PS2_USE_USART
#if defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__)
/* XCK for clock line and RXD for data line */
#define PS2_CLOCK_PORT  PORTD
#define PS2_CLOCK_PIN   PIND
#define PS2_CLOCK_DDR   DDRD
#define PS2_CLOCK_BIT   3//5
#define PS2_DATA_PORT   PORTD
#define PS2_DATA_PIN    PIND
#define PS2_DATA_DDR    DDRD
#define PS2_DATA_BIT    2

Then, to build the firmware, I ran

Code: [Select]
make -f clean Makefile.rev1
make -f Makefile.rev1

and wrote the hex file ps2_usb_rev1.hex to my pro micro.

I'm still hoping we can figure out how to get this working on a pro micro. What can I try next?


Title: Re: TMK keyboard firmware
Post by: PancakeMSTR on Sun, 08 September 2019, 20:31:57
You can't configure pins for USART, pins for USART is fixed and not configurable.
If PD5 is not available on pro micro then, you have to use BUSYWAIT or INT backend.
You can configure pins freely for BUSYWAIT in config_rev1.h.
Or copy INT pin configuration in config_rev2.h to config_rev.h. And use PD0 and PD1. Don't change pins if you are not familiar with the MCU.

I think this works but I don't have time and pro miro available in hand to test this at this point.
Apparently current README and pin configuration is not useful for usual DIYers, I'll update them when I get time.

I'll give it a try, see what I can do. Thanks for working with me, Hasu.


Hasu - I'm having a little trouble understanding exactly what you mean by "copy INT pin configuration in config_rev2.h to config_rev.h"? Would you mind elaborating?
Title: Re: TMK keyboard firmware
Post by: PancakeMSTR on Sun, 08 September 2019, 22:25:58
--------------------------------
Update: Got it working
--------------------------------

Hasu -
Gave what you said to try a shot. Here's precisely what I did:

Copied the following from config_rev2.h

Code: [Select]
/*
 * PS/2 Pin interrupt
 */
#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   1
#define PS2_DATA_PORT   PORTD
#define PS2_DATA_PIN    PIND
#define PS2_DATA_DDR    DDRD
#define PS2_DATA_BIT    0
#define PS2_INT_INIT()  do {    \
    EICRA |= ((1<<ISC11) |      \
              (0<<ISC10));      \
} while (0)
#define PS2_INT_ON()  do {      \
    EIMSK |= (1<<INT1);         \
} while (0)
#define PS2_INT_OFF() do {      \
    EIMSK &= ~(1<<INT1);        \
} while (0)
#define PS2_INT_VECT    INT1_vect
#endif

Into config_rev1.h (literally just copy-pasted it at the bottom).

Then, in Makefile.rev1, I changed it to use interrupt method instead of USART, i.e. changed the following lines

Code: [Select]
PS2_USE_USART = yes
PS2_USE_INT = no
PS2_USE_BUSYWAIT = no

to

Code: [Select]
PS2_USE_USART = no
PS2_USE_INT = yes
PS2_USE_BUSYWAIT = no

rebuild everything, flashed, and everything is working perfectly. I typed this comment using the second AT keyboard I switched to.

Here is the wiring diagram (https://imgur.com/9yIqWVe), for reference.

As usual, Thanks so much for working with me Hasu! I really appreciate the help, I probably would not have been able to get these keyboards converted without it.



Title: Re: TMK keyboard firmware
Post by: hasu on Sun, 08 September 2019, 22:36:48
PancakeMSTR,
Great.

I just updated github repository and first post of TMK PS/2 converter thread. It may make a bit easier for those unfamiliar with TMK and AVR controllers hoepfully... This update may break your changes in your repo, though.

https://geekhack.org/index.php?topic=14618.0
Title: Re: TMK keyboard firmware
Post by: PancakeMSTR on Mon, 09 September 2019, 09:46:18
Hasu -

I wanted to try your new version of ps2_usb, which mentions using Makefile.32u4, but I don't see any such file in the ps2_usb folder. Am I missing something?
Title: Re: TMK keyboard firmware
Post by: hasu on Mon, 09 September 2019, 17:57:38
Ah, thanks for letting me know. Pushed the file to repo now.
Post in the TMK PS/2 converter if you have further PS/2 converter specific topic.
Title: Re: TMK keyboard firmware
Post by: PancakeMSTR on Sat, 21 September 2019, 18:03:12
Hi Hasu,
I'm hoping you can help me understand Unimap a little bit. I'm trying to set it up with the xt_usb converter to remap my Model F XT.

I've played around with it a bit and I'm just hoping you could give a short explanation of each piece.

I'm looking at (my slightly edited version) of unimap_common.h (https://github.com/tmk/tmk_keyboard/blob/master/converter/xt_usb/unimap_common.h). There are three arrays, and I'd like to better understand each of them.

The first is #define UNIMAP_XT. I'm guessing that this array just specifies all the keycodes for the keys physically on the keyboard, so this is like the "physical keycode map":
Code: [Select]
#define UNIMAP_XT( \
    K3B,K3C,  K01,K02,K03,K04,K05,K06,K07,K08,K09,K0A,K0B,K0C,K0D,K0E,    K45,    K46, \
    K3D,K3E,  K0F,K10,K11,K12,K13,K14,K15,K16,K17,K18,K19,K1A,K1B,K1C,K47,K48,K49,K4A, \
    K3F,K40,  K1D,K1E,K1F,K20,K21,K22,K23,K24,K25,K26,K27,K28,K29,    K4B,K4C,K4D,K4E, \
    K41,K42,  K2A,K2B,K2C,K2D,K2E,K2F,K30,K31,K32,K33,K34,K35,K36,K37,K4F,K50,K51,    \
    K43,K44,  K38,                    K39,                    K3A,    K52,    K53      \
)

I don't, however, understand how this relates to the "UNIMAP" array directly below it
Code: [Select]
UNIMAP( \
            NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO,                                      \
    K01,    K3B,K3C,K3D,K3E,K3F,K40,K41,K42,K43,K44,NO, NO,       NO, K46,NO,       NO, NO, NO,  \
    K29,K02,K03,K04,K05,K06,K07,K08,K09,K0A,K0B,K0C,K0D,NO, K0E,  NO, NO, NO,   K45,NO, K37,K4A, \
    K0F,K10,K11,K12,K13,K14,K15,K16,K17,K18,K19,K1A,K1B,    K2B,  NO, NO, NO,   K47,K48,K49,K4E, \
    K3A,K1E,K1F,K20,K21,K22,K23,K24,K25,K26,K27,K28,    NO, K1C,                K4B,K4C,K4D,NO,  \
    K2A,NO, K2C,K2D,K2E,K2F,K30,K31,K32,K33,K34,K35,    NO, K36,      NO,       K4F,K50,K51,NO,  \
    K1D,NO, NO, NO,         K39,        NO, NO, NO, NO, NO, NO,   NO, NO, NO,       K52,K53,NO   \
)

Nor do I understand what role the last array, "unimap_trans", plays
Code: [Select]
const uint8_t PROGMEM unimap_trans[MATRIX_ROWS][MATRIX_COLS] = {
    { UNIMAP_NO,    UNIMAP_ESC,   UNIMAP_1,     UNIMAP_2,     UNIMAP_3,     UNIMAP_4,     UNIMAP_5,     UNIMAP_6     }, /* 00-07 */
    { UNIMAP_7,     UNIMAP_8,     UNIMAP_9,     UNIMAP_0,     UNIMAP_MINUS, UNIMAP_EQUAL, UNIMAP_BSPACE,UNIMAP_TAB   }, /* 08-0F */
    { UNIMAP_Q,     UNIMAP_W,     UNIMAP_E,     UNIMAP_R,     UNIMAP_T,     UNIMAP_Y,     UNIMAP_U,     UNIMAP_I     }, /* 10-17 */
    { UNIMAP_O,     UNIMAP_P,     UNIMAP_LBRC,  UNIMAP_RBRC,  UNIMAP_ENTER, UNIMAP_LCTL,  UNIMAP_A,     UNIMAP_S,    }, /* 18-1F */
    { UNIMAP_D,     UNIMAP_F,     UNIMAP_G,     UNIMAP_H,     UNIMAP_J,     UNIMAP_K,     UNIMAP_L,     UNIMAP_SCLN  }, /* 20-27 */
    { UNIMAP_QUOTE, UNIMAP_GRAVE, UNIMAP_LSHIFT,UNIMAP_BSLASH,UNIMAP_Z,     UNIMAP_X,     UNIMAP_C,     UNIMAP_V,    }, /* 28-2F */
    { UNIMAP_B,     UNIMAP_N,     UNIMAP_M,     UNIMAP_COMMA, UNIMAP_DOT,   UNIMAP_SLASH, UNIMAP_RSHIFT,UNIMAP_PAST  }, /* 30-37 */
    { UNIMAP_LALT,  UNIMAP_SPACE, UNIMAP_CAPS,  UNIMAP_F1,    UNIMAP_F2,    UNIMAP_F3,    UNIMAP_F4,    UNIMAP_F5    }, /* 38-3F */
    { UNIMAP_F6,    UNIMAP_F7,    UNIMAP_F8,    UNIMAP_F9,    UNIMAP_F10,   UNIMAP_NLCK,  UNIMAP_SLCK,  UNIMAP_P7    }, /* 40-47 */
    { UNIMAP_P8,    UNIMAP_P9,    UNIMAP_PMNS,  UNIMAP_P4,    UNIMAP_P5,    UNIMAP_P6,    UNIMAP_PPLS,  UNIMAP_P1    }, /* 48-4F */
    { UNIMAP_P2,    UNIMAP_P3,    UNIMAP_P0,    UNIMAP_PDOT,  UNIMAP_PSCR,  UNIMAP_PAUSE, UNIMAP_NUHS,  UNIMAP_F11   }, /* 50-57 */
    { UNIMAP_F12,   UNIMAP_PEQL,  UNIMAP_LGUI,  UNIMAP_RGUI,  UNIMAP_APP,   UNIMAP_NO,    UNIMAP_NO,    UNIMAP_NO    }, /* 58-5F */
    { UNIMAP_UP,    UNIMAP_LEFT,  UNIMAP_DOWN,  UNIMAP_RIGHT, UNIMAP_F13,   UNIMAP_F14,   UNIMAP_F15,   UNIMAP_F16   }, /* 60-67 */
    { UNIMAP_F17,   UNIMAP_F18,   UNIMAP_F19,   UNIMAP_F20,   UNIMAP_F21,   UNIMAP_F22,   UNIMAP_F23,   UNIMAP_PENT  }, /* 68-6F */
    { UNIMAP_KANA,  UNIMAP_INSERT,UNIMAP_DELETE,UNIMAP_RO,    UNIMAP_HOME,  UNIMAP_END,   UNIMAP_F24,   UNIMAP_PGUP  }, /* 70-77 */
    { UNIMAP_PGDN,  UNIMAP_HENK,  UNIMAP_RCTL,  UNIMAP_MHEN,  UNIMAP_RALT,  UNIMAP_JYEN,  UNIMAP_PCMM,  UNIMAP_PSLS  }, /* 78-7F */
};

I'd really appreciate it if you could just give me a quick overview of what the purpose of these arrays is. Thank you !
Title: Re: TMK keyboard firmware
Post by: hasu on Tue, 24 September 2019, 02:00:49
This 'UNIMAP_XT' macro definition would be just useful if your keyboard is IBM XT keyboard because the definition corresponds to physical layout of the keyboard.

https://github.com/tmk/tmk_keyboard/blob/master/converter/xt_usb/unimap_common.h#L45-L84

But it is not necessarily required, you can use universal layout macro 'UNIMAP' as you can see in unimap.c. In fact the 'UNIMAP_XT' is not used anywhere and not useful for XT keyboard that has more keys than IBM XT.

https://github.com/tmk/tmk_keyboard/blob/master/converter/xt_usb/unimap.c#L48-L75

Universal 128-key layout 'UNIMAP()' macro is defined in tmk_core/common/unimap.h and you can use the layout for all of keyobards and converters with unimap.

https://github.com/tmk/tmk_keyboard/blob/master/tmk_core/common/unimap.h#L18-L74

Array  'unimap_trans' defines how key of keyboard matrix is mapped to key of the universal 128-key layout. For example, 'A'(0x1E) key of XT keyboard which is lcoated in [3][6] of matrix is mapped to 'A' key of unimap(UNIMAP_A).

https://github.com/tmk/tmk_keyboard/blob/master/converter/xt_usb/unimap_common.h#L90
Title: Re: TMK keyboard firmware
Post by: PancakeMSTR on Tue, 24 September 2019, 09:47:55
Okay, thanks for the explanation Hasu. I've started to figure it out a bit on my own but this information is still very useful
Title: Re: TMK keyboard firmware
Post by: PancakeMSTR on Sat, 19 October 2019, 17:55:24
Hi Hasu,
I've encountered a new problem that, despite my best efforts, I can't seem to solve.

I have an SSK I'm trying to convert to USB and I've successfully gotten it to work with the tmk terminal-to-usb converter. Unfortunately, this particular converter seems kind of old, and I can't get macros or action functions or layers to work the way I need them to. Hoping you can look at my keymap and identify any sources of error.

For example, I've assigned FN0 to ACTION_LAYER_MOMENTARY(1), which should switch to layer 1, but it doesn't seem to actually do anything. I don't know why.

Anyway, hope you can help. Let me know if you'd like me to clarify anything.

Code: [Select]
/*
Copyright 2012 Jun Wako <wakojun@gmail.com>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#include <stdint.h>
#include <stdbool.h>
#include "keycode.h"
#include "print.h"
#include "debug.h"
#include "util.h"
#include "keymap.h"
#include "report.h"
#include "print.h"

#include "action.h"
#include "action_macro.h"
#include "action_util.h"



/*
 * IBM Terminal keyboard 6110345(122keys)/1392595(102keys)
 * http://geekhack.org/showthread.php?10737-What-Can-I-Do-With-a-Terminal-Model-M
 * http://www.seasip.info/VintagePC/ibm_1391406.html
 *
 * Keymap array:
 *     8 bytes
 *   +---------+
 *  0|         |
 *  :|         | 0x00-0x87
 *  ;|         |
 * 17|         |
 *   +---------+
 */
/*
 * IBM Terminal keyboard 1399625, 101-key
 */

#define KEYMAP_SSK( \
    K08,    K07,K0F,K17,K1F,K27,K2F,K37,K3F,K47,K4F,K56,K5E,  K57,K5F,K62, \
                                                                          \
    K0E,K16,K1E,K26,K25,K2E,K36,K3D,K3E,K46,K45,K4E,K55,K66,  K67,K6E,K6F, \
    K0D,K15,K1D,K24,K2D,K2C,K35,K3C,K43,K44,K4D,K54,K5B,K5C,  K64,K65,K6D, \
    K14,K1C,K1B,K23,K2B,K34,K33,K3B,K42,K4B,K4C,K52,    K5A, \
    K12,    K1A,K22,K21,K2A,K32,K31,K3A,K41,K49,K4A,    K59,      K63, \
    K11,    K19,            K29,                K39,    K58,  K61,K60,K6A \
) { \
    { KC_NO,    KC_NO   , KC_NO,    KC_NO   , KC_NO   , KC_NO   , KC_NO   , KC_##K07 }, \
    { KC_##K08, KC_NO   , KC_NO   , KC_NO   , KC_NO   , KC_##K0D, KC_##K0E, KC_##K0F }, \
    { KC_NO   , KC_##K11, KC_##K12, KC_NO   , KC_##K14, KC_##K15, KC_##K16, KC_##K17 }, \
    { KC_NO   , KC_##K19, KC_##K1A, KC_##K1B, KC_##K1C, KC_##K1D, KC_##K1E, KC_##K1F }, \
    { KC_NO   , KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_##K27 }, \
    { KC_NO   , KC_##K29, KC_##K2A, KC_##K2B, KC_##K2C, KC_##K2D, KC_##K2E, KC_##K2F }, \
    { KC_NO   , KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_##K35, KC_##K36, KC_##K37 }, \
    { KC_NO   , KC_##K39, KC_##K3A, KC_##K3B, KC_##K3C, KC_##K3D, KC_##K3E, KC_##K3F }, \
    { KC_NO   , KC_##K41, KC_##K42, KC_##K43, KC_##K44, KC_##K45, KC_##K46, KC_##K47 }, \
    { KC_NO   , KC_##K49, KC_##K4A, KC_##K4B, KC_##K4C, KC_##K4D, KC_##K4E, KC_##K4F }, \
    { KC_NO   , KC_NO   , KC_##K52, KC_NO   , KC_##K54, KC_##K55, KC_##K56, KC_##K57 }, \
    { KC_##K58, KC_##K59, KC_##K5A, KC_##K5B, KC_##K5C, KC_NO   , KC_##K5E, KC_##K5F }, \
    { KC_##K60, KC_##K61, KC_##K62, KC_##K63, KC_##K64, KC_##K65, KC_##K66, KC_##K67 }, \
    { KC_NO   , KC_NO, KC_##K6A, KC_NO, KC_NO, KC_##K6D, KC_##K6E, KC_##K6F }, \
    { KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, \
    { KC_NO   , KC_NO, KC_NO, KC_NO   , KC_NO, KC_NO, KC_NO, KC_NO    }, \
    { KC_NO,    KC_NO,    KC_NO,    KC_NO   , KC_NO, KC_NO,    KC_NO,    KC_NO,   }, \
}


const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
/* 101-key keymaps
 */
    /* 0: default
     * ,---.   ,---------------. ,---------------. ,---------------. ,-----------.
     * |Esc|   |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Pau|
     * `---'   `---------------' `---------------' `---------------' `-----------'
     * ,-----------------------------------------------------------. ,-----------. ,---------------.
     * |  `|  1|  2|  3|  4|  5|  6|  7|  8|  9|  0|  -|  =|Backspa| |Ins|Hom|PgU| |NmL|  /|  *|  -|
     * |-----------------------------------------------------------| |-----------| |---------------|
     * |Tab  |  Q|  W|  E|  R|  T|  Y|  U|  I|  O|  P|  [|  ]|    \| |Del|End|PgD| |  7|  8|  9|   |
     * |-----------------------------------------------------------| `-----------' |-----------|  +|
     * |CapsLo|  A|  S|  D|  F|  G|  H|  J|  K|  L|  ;|  '|Return  |               |  4|  5|  6|   |
     * |-----------------------------------------------------------|     ,---.     |---------------|
     * |Shift   |  Z|  X|  C|  V|  B|  N|  M|  ,|  ,|  /|Shift     |     |Up |     |  1|  2|  3|   |
     * |-----------------------------------------------------------| ,-----------. |-----------|Ent|
     * |Ctrl|    |Alt |          Space              |Alt |    |Ctrl| |Lef|Dow|Rig| |      0|  .|   |
     * `----'    `---------------------------------------'    `----' `-----------' `---------------'
     */

    // Default
    KEYMAP_SSK(
     ESC,       F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9, F10, F11, F12,     PSCR,SLCK, 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,                   
    LSFT,        Z,   X,   C,   V,   B,   N,   M,COMM, DOT,SLSH,     RSFT,            UP,     
    LCTL,     LALT,                SPC,                    FN0,     RCTL,     LEFT,DOWN,RGHT
    ),

    // Momentary
    KEYMAP_SSK(
     ESC,       F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9, F10, F11, F12,     FN1,FN2,FN3,

     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,                   
    LSFT,        Z,   X,   C,   V,   B,   N,   M,COMM, DOT,SLSH,     RSFT,            UP,     
    LCTL,     LALT,                A,                    TRNS,     RCTL,     LEFT,DOWN,RGHT
    ),   

};

/* id for user defined functions */
enum function_id {
    PROMICRO_RESET,
    PROMICRO_PROGRAM,   
    TEST,
};

const action_t PROGMEM fn_actions[] = {   
    [0] = ACTION_LAYER_MOMENTARY(1),   
    [1] = ACTION_FUNCTION(PROMICRO_RESET),
    [2] = ACTION_FUNCTION_TAP(PROMICRO_PROGRAM),
    [3] = ACTION_FUNCTION_TAP(TEST),

};

const uint8_t PROGMEM fn_layer[] = {
};

const uint8_t PROGMEM fn_keycode[] = {
};



void action_function(keyrecord_t *record, uint8_t id, uint8_t opt)
{
    switch(id) {
        case PROMICRO_RESET:
            promicro_bootloader_jmp(false);
            break;
        case PROMICRO_PROGRAM:
            promicro_bootloader_jmp(true);
            break;
        case TEST:
          return (record->event.pressed ?
              MACRO( T(T),T(E),T(S),T(T), END ) :
              MACRO_NONE);
        default:
            break;
    }
}


Title: Re: TMK keyboard firmware
Post by: hasu on Sat, 19 October 2019, 18:33:38
You will have to start with its keymap.c then, change and test it gradually. Don't change much at once.
Title: Re: TMK keyboard firmware
Post by: hasu on Sat, 19 October 2019, 18:41:43
And you want to  refer this doc.
https://github.com/tmk/tmk_keyboard/blob/master/tmk_core/doc/keymap.md#5-legacy-keymap
Title: Re: TMK keyboard firmware
Post by: PancakeMSTR on Sun, 20 October 2019, 01:29:29
Okay - so I'm not sure if the action stuff works with legacy keymap. Is there some way I can execute the pro micro reset function with legacy keymap?
Title: Re: TMK keyboard firmware
Post by: hasu on Tue, 22 October 2019, 06:34:49
You cannot use user defined action with the legacy keymap.
Keycode KC_BTLD may work for the purpose.

Okay - so I'm not sure if the action stuff works with legacy keymap. Is there some way I can execute the pro micro reset function with legacy keymap?

Title: Re: TMK keyboard firmware
Post by: PancakeMSTR on Tue, 22 October 2019, 11:35:57
You cannot use user defined action with the legacy keymap.
Keycode KC_BTLD may work for the purpose.

Okay - so I'm not sure if the action stuff works with legacy keymap. Is there some way I can execute the pro micro reset function with legacy keymap?

Saved my life again. Thanks Hasu, worked perfectly.
Title: Re: TMK keyboard firmware
Post by: Zustiur on Wed, 25 March 2020, 07:36:12
For some reason I'm only getting row0 and row 1 to work and my one LED only glows very dimly, which I suspect means it's being strobed instead of just being on. I'm certain that it's a firmware issue because I can't find any electrical errors and even tried shorting a wire between the relevant pins on the chip to trigger key presses from other rows. Can someone help me spot the error please? I'm sure I'm missing something simple here. I just can't see it.
My pins are as follows:
Row0=F0
Row1=F1
Row2=F4
Row3=F5
Row4=F6
Row5=F7

Col0=D0
Col1=D1
Col2=D2
Col3=D3
Col4=D5
Col5=D4
Col6=D7

LED = B6

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         OneHandRevA4
#define DESCRIPTION     t.m.k. keyboard firmware for OneHandRevA4

/* key matrix size */
#define MATRIX_ROWS 6
#define MATRIX_COLS 7

/* 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)) \
)



/*
 * Feature disable options
 *  These options are also useful to firmware size reduction.
 */

/* disable debug print */
//#define NO_DEBUG

/* disable print */
//#define NO_PRINT

/* disable action features */
//#define NO_ACTION_LAYER
//#define NO_ACTION_TAPPING
//#define NO_ACTION_ONESHOT
//#define NO_ACTION_MACRO
//#define NO_ACTION_FUNCTION

#endif

LED.c
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
        DDRB &= ~(1<<6);
PORTB |= (1<<6); //Switch LED On


    } else {
        // Hi-Z
        DDRB |= (1<<6);
        PORTB &= ~(1<<6); //Switch LED Off
    }
}

Matrix.c
Code: [Select]
#include <stdint.h>
#include <stdbool.h>
#include <avr/io.h>
#include <util/delay.h>
#include "print.h"
#include "debug.h"
#include "util.h"
#include "matrix.h"


#ifndef DEBOUNCE
#   define DEBOUNCE 5
#endif
static uint8_t debouncing = DEBOUNCE;

/* matrix state(1:on, 0:off) */
static matrix_row_t matrix[MATRIX_ROWS];
static matrix_row_t matrix_debouncing[MATRIX_ROWS];

static matrix_row_t read_cols(void);
static void init_cols(void);
static void unselect_rows(void);
static void select_row(uint8_t row);


inline
uint8_t matrix_rows(void)
{
    return MATRIX_ROWS;
}

inline
uint8_t matrix_cols(void)
{
    return MATRIX_COLS;
}

void matrix_init(void)
{
    // initialize row and col
    unselect_rows();
    init_cols();

    // initialize matrix state: all keys off
    for (uint8_t i=0; i < MATRIX_ROWS; i++) {
        matrix[i] = 0;
        matrix_debouncing[i] = 0;
    }
}

uint8_t matrix_scan(void)
{
    for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
        select_row(i);
        _delay_us(30);  // without this wait read unstable value.
        matrix_row_t cols = read_cols();
        if (matrix_debouncing[i] != cols) {
            matrix_debouncing[i] = cols;
            if (debouncing) {
                debug("bounce!: "); debug_hex(debouncing); debug("\n");
            }
            debouncing = DEBOUNCE;
        }
        unselect_rows();
    }

    if (debouncing) {
        if (--debouncing) {
            _delay_ms(1);
        } else {
            for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
                matrix[i] = matrix_debouncing[i];
            }
        }
    }

    return 1;
}

bool matrix_is_modified(void)
{
    if (debouncing) return false;
    return true;
}

inline
bool matrix_is_on(uint8_t row, uint8_t col)
{
    return (matrix[row] & ((matrix_row_t)1<<col));
}

inline
matrix_row_t matrix_get_row(uint8_t row)
{
    return matrix[row];
}

void matrix_print(void)
{
    print("\nr/c 0123456789ABCDEF\n");
    for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
        phex(row); print(": ");
        pbin_reverse16(matrix_get_row(row));
        print("\n");
    }
}

uint8_t matrix_key_count(void)
{
    uint8_t count = 0;
    for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
        count += bitpop16(matrix[i]);
    }
    return count;
}

/* Column pin configuration
 * col: 0   1   2   3   4   5   6
 * pin: D0  D1  D2  D3  D5  D4  D7
 */
static void  init_cols(void)
{
    // Input with pull-up(DDR:0, PORT:1)
    DDRD  &= ~(1<<7 | 1<<5 | 1<<4 | 1<<3 | 1<<2 | 1<<1 | 1<<0); //F7, F4, F1, F0 and so on...
PORTD |=  (1<<7 | 1<<5 | 1<<4 | 1<<3 | 1<<2 | 1<<1 | 1<<0);
}

static matrix_row_t read_cols(void)
{
    return (PIND&(1<<0) ? 0 : (1<<0)) | //Pin D0 = Col0
           (PIND&(1<<1) ? 0 : (1<<1)) | //Pin D1 = Col 1 and so on.
           (PIND&(1<<2) ? 0 : (1<<2)) |
           (PIND&(1<<3) ? 0 : (1<<3)) |
           (PIND&(1<<5) ? 0 : (1<<4)) |
           (PIND&(1<<4) ? 0 : (1<<5)) |
   (PIND&(1<<7) ? 0 : (1<<6));
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////
/* Row pin configuration
 * row: 0   1   2   3   4   5
 * pin: F0  F1  F4  F5  F6  F7
 */
static void unselect_rows(void)
{
    // Hi-Z(DDR:0, PORT:0) to unselect
//These are unselected with a binary code, in reverse column order: 76543210
//          76543210
DDRF  &= ~0b11110011;
PORTF &= ~0b11110011;

}


static void select_row(uint8_t row)
{
    // Output low(DDR:1, PORT:0) to select
    switch (row) {
        case 0: //Row 0 = Pin F0
            DDRF  |= (1<<0);
            PORTF &= ~(1<<0);
            break;
        case 1: //Row 1 = Pin F1... and so on
            DDRF  |= (1<<1);
            PORTF &= ~(1<<1);
            break;
        case 2:
            DDRF  |= (1<<4);
            PORTF &= ~(1<<4);
            break;
        case 3:
            DDRF  |= (1<<5);
            PORTF &= ~(1<<5);
            break;
        case 4:
            DDRF  |= (1<<6);
            PORTF &= ~(1<<6);
            break;
case 5:
DDRF  |= (1<<7);
            PORTF &= ~(1<<7);
            break;
    }
}

Title: Re: TMK keyboard firmware
Post by: hasu on Wed, 25 March 2020, 08:43:23
By default part of Port F(4-7 probably) is reserved for JTAG or something in some AVR, if I can remember correctly. You have to fiddle some register to use the Port F  pins as general IO instead of JTAG debug.
Check data sheet or use google. This is kind of FAQ you can find info easily.
Title: Re: TMK keyboard firmware
Post by: Zustiur on Thu, 26 March 2020, 03:21:34
Ahhh of course, that will be it. Thanks Hasu. I was tricked by it being whole rows and convinced myself it was an error in my code. I forgot about JTAG! I knew about that weeks ago but forgot while I waited for my boards to arrive from JLCPCB.
You're a legend.
I don't know where I'd be without your awesome firmware.
Title: Re: TMK keyboard firmware
Post by: Crossharu on Wed, 15 April 2020, 02:34:08
Hi all -

I’ve been having some trouble with my custom keyboard that uses TMK firmware and have come to my wits end so I’m hoping one of you may be able to help!

I initially built (hand soldered) the board a few years ago and after a bit of messing around with the code it worked perfectly for years. Then one summer I noticed that it started malfunctioning in a weird way - when pressing any key on a particular column, either some or all of the other keys in that column would fire. I couldn’t solve it so I put the keyboard aside for a few months. The next winter I came back to it and it was working fine again but then when the summer came around I had further problems (making me think it was heat related) so I had a play around with denounce and got it to catch any additional key presses that were triggered.

Fast forward to earlier this week and the problems start up again during a patch of particularly warm weather. Once the weather got a bit cooler again it seemed to resolve itself. I thought about buying a heat sink for the teensy controller but then decided first to flash a new version of TMK to it. I did that yesterday and unfortunately that seemed to break my LGUI key but everything else works fine. I tried various fixes but in the end reverted to my old firmware backup. Now the LGUI key is broken in that firmware as well when it worked perfectly previously! I’ve checked the soldering and it’s all good and all other keys are working.

I’d be really really grateful if anyone has any idea on either of these issues. I’m starting to think that I might need to get a new controller and solder it in...

Thanks!
Title: Re: TMK keyboard firmware
Post by: ississ on Wed, 15 April 2020, 15:04:32
Hi

I just completed my third keyboard build with tmk firmware.
This last one is a keyboard-mouse combo for my engraver (to save table space and make something useful from old parts lying around).
I decided to add a middle button to the touchpad which can normally handle only 2 buttons and connected it to the keyboard matrix.

The problem is, if I press the middle button and move the mouse the firmware sends middle button release. The original mouse buttons stay pressed until released independent of mouse movement.
Middle button works as it should as long as the mouse is not moved.

Have anyone tried this kind of setup before (ps/2 mouse with added buttons) ?
Any other ideas ?

Firmware runs on A-Star 32U4 mini SV
Touchpad controller is Synaptics T1006 connected to controller with INT version (for some reason uart version didn't work).
Keyboard matrix is from an old laptop.

[attach=1]
Title: Re: TMK keyboard firmware
Post by: hasu on Wed, 15 April 2020, 17:33:39
Scroll with middle button seems to be enabled. Check this.

https://github.com/tmk/tmk_keyboard/blob/master/tmk_core/protocol/ps2_mouse.h#L46
Title: Re: TMK keyboard firmware
Post by: ississ on Thu, 16 April 2020, 13:35:21
Yes, that seems to be set on my header file too.

Is this setting related to scrolling text terminal/web browser by clicking middle button and then moving the mouse ?
Should I unset it to be able to keep the middle button pressed independent of mouse movement ?

What I'm after is that the middle button stays pressed as long as the physical button is pressed. This is required for the programs, for example Autodesk fusion 360 the model is rotated by pressing the middle button and then moving the mouse. Same for Repetier-Host (middle = pan) and Linuxcnc Axis interface.

I checked with xinput and the kbd/mouse sends a middle button release as soon as the mouse is moved with the button still pressed.
Same functionality in Linux and Windows (10), functionality is same on both environments.

Here is a simple event viewer output, #184 & #185 show immediate mouseup and move after that for middle button. The athers work ok and the butt6on stays pressed while moving.[attach=1]
Title: Re: TMK keyboard firmware
Post by: hasu on Thu, 16 April 2020, 16:12:41
Yes and yes.
Title: Re: TMK keyboard firmware
Post by: ississ on Thu, 16 April 2020, 17:11:51
Yes and yes.

Thanks for the quick answer.
I tested a couple of configurations and found out that disabling PS2_MOUSE_SCROLL_BTN_MASK and setting MOUSEKEY_ENABLE = yes results in same behaviour, button is released when moved. Without mouse keys the middle button is not sent at all.

So I ended up disabling both mouse keys and PS2_MOUSE_SCROLL_BTN_MASK and tweaking a bit in ps2_mouse.c and keyboard.c so that the middle mouse button state is saved while checking the matrix and added to every mouse packet read from the touchpad.

This is not-so-nice way but now it works, I'll live with that.
Title: Re: TMK keyboard firmware
Post by: marcosalcocer on Tue, 09 June 2020, 07:05:49
Hi, I am having a hard time programming the Spanish characters " ñ " and " ´ " through the tmk-kbd editor. Overall I have placed all the other keys where I want them. Is there a way to do this through the editor?
Title: Re: TMK keyboard firmware
Post by: suicidal_orange on Tue, 09 June 2020, 07:19:47
Are you using a Spanish layout setting on your operating system?  If so you need to pretend you have an American keyboard and use the names as seen on that and they will output correctly.
Title: Re: TMK keyboard firmware
Post by: hasu on Tue, 09 June 2020, 08:09:32
Hi, I am having a hard time programming the Spanish characters " ñ " and " ´ " through the tmk-kbd editor. Overall I have placed all the other keys where I want them. Is there a way to do this through the editor?

What is your OS and keyobard layout on your OS?
How do you usually get the charactors?
Title: Re: TMK keyboard firmware
Post by: marcosalcocer on Wed, 10 June 2020, 19:08:19
I'm running MacOS... I am used to programming the output on the OS but I wanted to use the controller to not have to do that every time I switch my computer.
Title: Re: TMK keyboard firmware
Post by: hasu on Wed, 10 June 2020, 19:35:57
I'm running MacOS... I am used to programming the output on the OS but I wanted to use the controller to not have to do that every time I switch my computer.

I don't have Mac and don't know Spanish at all.
But I think you can register 'ñ' with a key next to 'L'(regardless of its marking, ';' on US layout) if you are using default keymap. Your keyboard should work as normal Spanish keyboard with default keymap.

(https://upload.wikimedia.org/wikipedia/commons/7/74/KB_Spanish.svg)

(https://d25rq8gxcq0p71.cloudfront.net/language-guide/758/int%20keyboard.jpg)
Title: Re: TMK keyboard firmware
Post by: marcosalcocer on Thu, 11 June 2020, 08:08:28
Yes this is how I normally use it but this only happens when the output is set in the computer OS not directly from the board. I want  native layout that has the ñ next to the L, and the ; to be moved elsewhere. The problems is that when I move the ; key my ñ appears where ever I moved the ;
Title: Re: TMK keyboard firmware
Post by: Zustiur on Fri, 12 June 2020, 08:13:38
I'm not sure if this is the appropriate thread for my current problem, but I don't know where else to post it right now.

I've just received 5 boards from JLCPCB and have soldered on the USB and SPI plugs on two of the 5 so that I can program and test them. For some reason, they are not being detected by USB, but only after I program them. This has me very puzzled. The first one I didn't test before programming. The second I did.

Specifically:
Board 1 steps:
Soldered on the USB and 6 pin header.
Connected SPI programmer
Attempted to disable JTAG fuse bit. AVRDude stated that it detected a change and would I like to roll back. I tried saying No, but this just sat there doing nothing until I hit Ctrl-C.
Programmed the hex file.
Disabled the JTAG fuse bit- no problem this time. (I've noticed this before, I don't seem to be able to disable JTAG until the chip has a hex on it?)
Disconnected SPI programmer, plugged in USB. Windows does not detect it.

Board 2 steps:
Soldered on the USB and 6 pin header.
Tested USB connectivity multiple times. Confirmed in Event Viewer that it detected and installed the driver for Atmel usb dfu.
Removed from USB, Connected SPI programmer
Programmed the hex file.
Disconnected SPI programmer, plugged in USB. Windows does not detect it.
Connected SPI programmer again, programmed with a different hex which I know is valid (albeit not the right columns etc for this keyboard).
Disconnected SPI programmer, plugged in USB. Windows does not detect it.

Am I missing something obvious again? Does this sound like a firmware error?



Nevermind. I WAS missing something so extremely obvious, I'm surprised the error message didn't jump out at me more.
I hadn't actually gone to the folder that my .hex files were in, so when I programmed the ISP it got erased and then nothing got programmed.
Title: Re: TMK keyboard firmware
Post by: hasu on Fri, 12 June 2020, 08:38:44
Yes this is how I normally use it but this only happens when the output is set in the computer OS not directly from the board. I want  native layout that has the ñ next to the L, and the ; to be moved elsewhere. The problems is that when I move the ; key my ñ appears where ever I moved the ;



I'm assuming you are using 'Spanish' layout on your computer and you have to press shift key and ',' key to get character ';' on computer. Is that right.

If so you can use 'ACTION_MODS_KEY' to send Shift and ',' key at same time. See a key next to 'L' in this Editor.

https://bit.ly/3dVLSTp

You can edit action like that with 'Code Edit' tab. Try it.
Title: Re: TMK keyboard firmware
Post by: marcosalcocer on Fri, 12 June 2020, 08:46:48
Perfect! This is the sort of workaround I will be very comfortable with. I'll check it out and get back if there are any issues.
Title: Re: TMK keyboard firmware
Post by: hasu on Fri, 12 June 2020, 08:54:33
I think you need help for your hardware first  before firmware?
You may need to create new thread for your project anyway.

Posting source code, photo of the pcb, schematics and microcontroller model number in your thread would be useful to get help. Also AVRdude message output may be helpful.
Provide information as much as possible there.


I'm not sure if this is the appropriate thread for my current problem, but I don't know where else to post it right now.

I've just received 5 boards from JLCPCB and have soldered on the USB and SPI plugs on two of the 5 so that I can program and test them. For some reason, they are not being detected by USB, but only after I program them. This has me very puzzled. The first one I didn't test before programming. The second I did.

Specifically:
Board 1 steps:
Soldered on the USB and 6 pin header.
Connected SPI programmer
Attempted to disable JTAG fuse bit. AVRDude stated that it detected a change and would I like to roll back. I tried saying No, but this just sat there doing nothing until I hit Ctrl-C.
Programmed the hex file.
Disabled the JTAG fuse bit- no problem this time. (I've noticed this before, I don't seem to be able to disable JTAG until the chip has a hex on it?)
Disconnected SPI programmer, plugged in USB. Windows does not detect it.

Board 2 steps:
Soldered on the USB and 6 pin header.
Tested USB connectivity multiple times. Confirmed in Event Viewer that it detected and installed the driver for Atmel usb dfu.
Removed from USB, Connected SPI programmer
Programmed the hex file.
Disconnected SPI programmer, plugged in USB. Windows does not detect it.
Connected SPI programmer again, programmed with a different hex which I know is valid (albeit not the right columns etc for this keyboard).
Disconnected SPI programmer, plugged in USB. Windows does not detect it.

Am I missing something obvious again? Does this sound like a firmware error?

Title: Re: TMK keyboard firmware
Post by: Zustiur on Fri, 12 June 2020, 09:18:56
Thanks Hasu. I think I've worked on too many things today. My brain is fried. It was a really stupid mistake. I've edited my post above.

I've got most of the board working now. Think there may be an issue in my matrix file somewhere because my thumb keys aren't registering. I'll figure that out tomorrow though.
Title: Re: TMK keyboard firmware
Post by: Alectardy98 on Mon, 04 January 2021, 21:37:23
Need some help with LED toggle on layer switching.

I want to use my layer one as a num lock, and indicate it though the num lock led. It seems to work but when I hit the Caps lock it turns off the num lock led but the keyboard stays in layer 1. How can I modify my code to make it work
Code: [Select]
bool my_led_status = 0;

hook_layer_change(uint32_t layer_state)
{

    if (layer_state & (1L<<1)) {
            // LED is off, so let's turn it on
            led_set(host_keyboard_leds() | (1<<USB_LED_NUM_LOCK));
            my_led_status = 1;
     } else {
            // LED is on, so let's turn it off
            led_set(host_keyboard_leds() & ~(1<<USB_LED_NUM_LOCK));
            my_led_status = 0;
     }

}
Title: Re: TMK keyboard firmware
Post by: hasu on Mon, 04 January 2021, 22:46:59
You can change default lock indicator behaviour with:
Code: [Select]
void hook_keyboard_leds_change(uint8_t led_status);
Title: Re: TMK keyboard firmware
Post by: Alectardy98 on Mon, 04 January 2021, 23:27:27
I am new to C and dont Realy know how I would apply that to do what I want
Title: Re: TMK keyboard firmware
Post by: Alectardy98 on Mon, 04 January 2021, 23:28:10
could you link where i can find more info
Title: Re: TMK keyboard firmware
Post by: hasu on Mon, 04 January 2021, 23:37:20
You can find the function here.
https://github.com/tmk/tmk_keyboard/blob/6271878a021fcf578b71e2b7e97cd43786efa7dd/tmk_core/common/hook.h#L82

And there is documentation about hook API here. But you will have read source codes to get more info somehow.
https://github.com/tmk/tmk_keyboard/blob/master/tmk_core/doc/hook.md
Title: Re: TMK keyboard firmware
Post by: Alectardy98 on Mon, 04 January 2021, 23:49:08
My code is working how I want it to, It is just the caps lock that is reseting the nun lock light, how can I disable that?



Title: Re: TMK keyboard firmware
Post by: Alectardy98 on Tue, 05 January 2021, 12:32:42
I Think what I have to do is disassociate the Num Lock led from the AT scan, so the num lock would no longer trigger the light
I think when the caps lock key is pressed, it checks to see what toggles are set pc side and changes the LEDs accordingly, which turns off my fake num lock light
Title: Re: TMK keyboard firmware
Post by: Alectardy98 on Tue, 05 January 2021, 15:29:25
This almost works, but the caps lock will triger the num lock and the caps lock led on first press and only the first press, otherwise, it works as it should

Code: [Select]
bool my_led_status = 1;

hook_layer_change(uint32_t layer_state)
{
    if (my_led_status);

        if (layer_state & (1L<<1)) {
            // LED is off, so let's turn it on
            led_set(host_keyboard_leds() | (1<<USB_LED_NUM_LOCK));
            my_led_status = 1;
        } else {
            // LED is on, so let's turn it off
            led_set(host_keyboard_leds() & ~(1<<USB_LED_NUM_LOCK));
            my_led_status = 0;
           
     }
   
}

hook_keyboard_leds_change(uint8_t led_status)
{
    if (my_led_status)
            {
                // LED is on, so let's turn it off
                led_set(host_keyboard_leds() | (1<<USB_LED_NUM_LOCK));
            }
            else
            {
                // LED is off, so let's turn it on
                led_set(host_keyboard_leds() & ~(1<<USB_LED_NUM_LOCK));            }
        }
   
Title: Re: TMK keyboard firmware
Post by: Alectardy98 on Tue, 05 January 2021, 17:30:31
I was able to make it work, but it might not be the cleanest. I am new to coding

Code: [Select]
bool my_led_status = 1;

hook_layer_change(uint32_t layer_state)
{
    if (my_led_status);

        if (layer_state & (1L<<1)) {
            // LED is off, so let's turn it on
            led_set(host_keyboard_leds() | (1<<USB_LED_NUM_LOCK));
            my_led_status = 1;
        } else {
            // LED is on, so let's turn it off
            led_set(host_keyboard_leds() & ~(1<<USB_LED_NUM_LOCK));
            my_led_status = 0;
           
     }
   
}


hook_keyboard_leds_change(uint8_t led_status)
{
    if (my_led_status)
            {
                // LED is off, so let's turn it on
                led_set(host_keyboard_leds() | (1<<USB_LED_NUM_LOCK));
                my_led_status = 1;
            }
            else
            {
                // LED is on, so let's turn it off
                led_set(host_keyboard_leds() & ~(1<<USB_LED_NUM_LOCK));
                my_led_status = 0;
            }
        }
   
hook_late_init(void)
{
if (my_led_status)

    {
        led_set(host_keyboard_leds() & ~(1<<USB_LED_NUM_LOCK));
        my_led_status = 0;
    }
}
Title: Re: TMK keyboard firmware
Post by: hasu on Tue, 05 January 2021, 21:04:04
Looks good enough.
I think you don't need 'hook_late_init'.

Code: [Select]
#include "host.h"
#include "led.h"
bool my_led_status = 0;

void hook_layer_change(uint32_t layer_state)
{
    if (layer_state & (1L<<1)) {
        // LED is off, so let's turn it on
        led_set(host_keyboard_leds() | (1<<USB_LED_NUM_LOCK));
        my_led_status = 1;
    } else {
        // LED is on, so let's turn it off
        led_set(host_keyboard_leds() & ~(1<<USB_LED_NUM_LOCK));
        my_led_status = 0;
    }
}


void hook_keyboard_leds_change(uint8_t led_status)
{
    if (my_led_status)
    {
        // LED is off, so let's turn it on
        led_set(host_keyboard_leds() | (1<<USB_LED_NUM_LOCK));
        my_led_status = 1;
    }
    else
    {
        // LED is on, so let's turn it off
        led_set(host_keyboard_leds() & ~(1<<USB_LED_NUM_LOCK));
        my_led_status = 0;
    }
}

If you care about initial state of indicators refer this issue.
https://github.com/tmk/tmk_keyboard/issues/665
Title: Re: TMK keyboard firmware
Post by: hasu on Fri, 29 January 2021, 08:07:05
casualdehid,
T0 and Lt0 doesn't work as you expected.
These actions are confusing and make no sense for users. I'll look into them to improve the TOGGLE behaviour but it will take some time.

You can use ACTION_LAYER_SET_CLEAR(0) instead of T0, this aciton disables all layers except for layer 0 at once.
https://github.com/tmk/tmk_keyboard/blob/master/tmk_core/doc/keymap.md#229-set-layer

But the action is not supported well in Keymap Editor yet, you have to edit the action with 'Code Edit' tab.
Check the action on Layer 3.
https://bit.ly/2MeJZZg

There is no alternative to Lt0 at this time.


OK. Lets start discussing that layer switching.
I'd like to check if layer switch problem on your keymap is specific to 'power key'.
Share your keymap URL using 'URL Shortener' button on Keymap editor or you can just attach hex file here.
I filmed my issue:
(Attachment Link)

Title: Re: TMK keyboard firmware
Post by: casualdehid on Mon, 01 February 2021, 16:15:40
For now, I'm using Power On as an improvised Fn layer 2 button (5x to toggle, press and hold for switch), and Esc as ESC+Layer 1 on hold on my M0118.
Title: Re: TMK keyboard firmware
Post by: casualdehid on Tue, 02 February 2021, 07:08:53
For now, I'm using Power On as an improvised Fn layer 2 button (5x to toggle, press and hold for switch), and Esc as ESC+Layer 1 on hold on my M0118.
Hi there
I've been using my M0118 since yesterday, and decided on two different firmwares for the two keyboards (M0118 and AEKII). However, I noticed that I have problems with multifunction buttons (action_layer_tap_key specifically) being slow for key combinations. For example: I have LT3/grave on my escape, and when I want to hit F5, i have to switch to layer 3 to do so. And it's a key combination i press frequently and very fast, I usually get 05 into my code instead of F5, because it won't switch in time, because I'm not holding it down for enough time. Is there a way to turn on "0 delay" on key combinations in the firmware? I think a few people would have problems with this, because for them it'd switch layers when they only wanted a key combination on the current layer, without switching. Maybe I'm askint a bit too much with this question. Sorry guys in advance.
Title: Re: TMK keyboard firmware
Post by: hasu on Wed, 03 February 2021, 08:24:16
This has no "0 delay" support. With that configuration you won't be able to type '05' quickly.

You can change behavior of 'tap key' with TAPPING_TERM somewhat, btw.
https://github.com/tmk/tmk_keyboard/wiki/FAQ-Keymap#tap-keydual-role-key-doesnt-work-for-me
Title: Re: TMK keyboard firmware
Post by: casualdehid on Wed, 03 February 2021, 12:01:53
This has no "0 delay" support. With that configuration you won't be able to type '05' quickly.

You can change behavior of 'tap key' with TAPPING_TERM somewhat, btw.
https://github.com/tmk/tmk_keyboard/wiki/FAQ-Keymap#tap-keydual-role-key-doesnt-work-for-me

I have the exact opposite problem, it outputs 05 instead of F5  :))
But this will definietly help on my problems.
Thanks again!
Title: Re: TMK keyboard firmware
Post by: PancakeMSTR on Fri, 23 April 2021, 10:25:02
I'm working on converting my Northgate Omnikey, and  it has this really weird ">/<"  key,  which as far as I can tell does NOT send the Non-US-BackSlash code, but instead seems to be the macro "Shift+," hardwired/hardcoded into the keyboard. I.e., pressing the button effectively presses "shift+," really fast.

I'd love to find some way to get this key to behave like the windows key if possible, specifically I could use help writing a TMK function that would send the LGUI code if "Shift" and "," are pressed within really quick succession of each other, or something.

If anyone can help, please let me know. Thanks.
Title: Re: TMK keyboard firmware
Post by: mfritsche on Fri, 30 April 2021, 09:44:18
EDIT: Never mind, found the answer two postings above  :blank:

Hi,

is there an equivalent of IGNORE_MOD_TAP_INTERRUPT (QMK) in TMK?

I have configured home row mods, but without that setting, those are do not work well as I am not very disciplined with the order my fingers lift of the keys.

Title: Re: TMK keyboard firmware
Post by: hasu on Fri, 30 April 2021, 22:22:09
I don't think you can discriminate between the ">/<" key and Shift+"," typed by you. Or very difficult if possible.

You will have to see how the keyboad sends scan codes for the key closely first.

I'm working on converting my Northgate Omnikey, and  it has this really weird ">/<"  key,  which as far as I can tell does NOT send the Non-US-BackSlash code, but instead seems to be the macro "Shift+," hardwired/hardcoded into the keyboard. I.e., pressing the button effectively presses "shift+," really fast.

I'd love to find some way to get this key to behave like the windows key if possible, specifically I could use help writing a TMK function that would send the LGUI code if "Shift" and "," are pressed within really quick succession of each other, or something.

If anyone can help, please let me know. Thanks.

Title: Re: TMK keyboard firmware
Post by: PancakeMSTR on Thu, 06 May 2021, 17:18:20
I don't think you can discriminate between the ">/<" key and Shift+"," typed by you. Or very difficult if possible.

You will have to see how the keyboad sends scan codes for the key closely first.

I'm working on converting my Northgate Omnikey, and  it has this really weird ">/<"  key,  which as far as I can tell does NOT send the Non-US-BackSlash code, but instead seems to be the macro "Shift+," hardwired/hardcoded into the keyboard. I.e., pressing the button effectively presses "shift+," really fast.

I'd love to find some way to get this key to behave like the windows key if possible, specifically I could use help writing a TMK function that would send the LGUI code if "Shift" and "," are pressed within really quick succession of each other, or something.

If anyone can help, please let me know. Thanks.

I'm pretty much positive it's just sending 'Shift + <' really fast, but I did try to use HID listen to see the codes. I couldn't get it to work, it seems to recognize when I plug the keyboard in, but nothing comes though when I actually press keys. If you have a suggestion, I definitely would like to try HID listen again.
Title: Re: TMK keyboard firmware
Post by: hasu on Thu, 06 May 2021, 17:58:20
which version of firmware are you using?
And what is your converter hardware?

I'm assuming that the keyboard speaks PS/2 protocol,  you can use IBMPC converter firmware.
Title: Re: TMK keyboard firmware
Post by: PancakeMSTR on Fri, 07 May 2021, 11:04:05
I'm using ps2_usb, although I will give IBMPC a try, looks interesting. I'm not sure which firmware I'm using or how to check, not anything recent, though. I'll update to the latest from your repo.
Title: Re: TMK keyboard firmware
Post by: ingvarha on Mon, 15 November 2021, 04:40:41
Just wanted to say thanks. By https://github.com/tmk/tmk_keyboard/commit/c205a56657d795bd45a2d0a4eb4e36bd61c92486 I can now use my old ND TDV 5020 including the NOTIS keys.

Ingvar

[attachimg=1]
[attachimg=2]
Title: Re: TMK keyboard firmware
Post by: hasu on Mon, 15 November 2021, 07:42:40
Thanks for your report!
Title: Re: TMK keyboard firmware
Post by: U47 on Mon, 03 January 2022, 21:42:19
What a board! 😍

Just wanted to say thanks. By https://github.com/tmk/tmk_keyboard/commit/c205a56657d795bd45a2d0a4eb4e36bd61c92486 I can now use my old ND TDV 5020 including the NOTIS keys.

Ingvar

(Attachment Link)
(Attachment Link)
Title: Re: TMK keyboard firmware
Post by: HerbalNekoTea on Wed, 20 April 2022, 23:27:19
Hi, i have someone in my DM over discord asking for a SGI to USB adapter, for a SGI 9500801, i tried to see if a registry editing would make it work over ps/2 to usb adapter (the kind with both mouse+KB combo), i was wondering if your PS/2 to USB firmware handle the SGI scancode. Thank you.
Title: Re: TMK keyboard firmware
Post by: hasu on Thu, 21 April 2022, 00:10:45
I don't know about the keyboard much. According to info on the net it is not PS/2, the converter won't work.

what does "registry editiong" means?
Title: Re: TMK keyboard firmware
Post by: HerbalNekoTea on Thu, 21 April 2022, 21:21:31
I don't know about the keyboard much. According to info on the net it is not PS/2, the converter won't work.

what does "registry editiong" means?
There was a bug with windows 10 having a issue with PS/2 port on desktop not working for mouse or keyboard, there's a registry value to edit on Windows 10 that fix it and seem to fix most of the time the issue of PS/2 keyboard not working on windows 10.