Author Topic: TMK keyboard firmware  (Read 559017 times)

0 Members and 1 Guest are viewing this topic.

Offline hasu

  • Thread Starter
  • Posts: 3125
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: TMK keyboard firmware
« Reply #450 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.
TMK products:HHKB Alt  ⌨ConvertersAlps64FC660C AltFC980C Alt

Offline hasu

  • Thread Starter
  • Posts: 3125
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: TMK keyboard firmware
« Reply #451 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

TMK products:HHKB Alt  ⌨ConvertersAlps64FC660C AltFC980C Alt

Offline Charger

  • Posts: 166
Re: TMK keyboard firmware
« Reply #452 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

Offline hasu

  • Thread Starter
  • Posts: 3125
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: TMK keyboard firmware
« Reply #453 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

TMK products:HHKB Alt  ⌨ConvertersAlps64FC660C AltFC980C Alt

Offline Charger

  • Posts: 166
Re: TMK keyboard firmware
« Reply #454 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

Offline domoaligato

  • * Exquisite Elder
  • Posts: 1662
  • Location: USA
  • All your base are belong to us!
    • All your base are belong to us!
Re: TMK keyboard firmware
« Reply #455 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

Offline Charger

  • Posts: 166
Re: TMK keyboard firmware
« Reply #456 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

Offline domoaligato

  • * Exquisite Elder
  • Posts: 1662
  • Location: USA
  • All your base are belong to us!
    • All your base are belong to us!
Re: TMK keyboard firmware
« Reply #457 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
« Last Edit: Mon, 15 September 2014, 12:48:39 by domoaligato »

Offline Charger

  • Posts: 166
Re: TMK keyboard firmware
« Reply #458 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
« Last Edit: Mon, 15 September 2014, 13:23:38 by Charger »

Offline domoaligato

  • * Exquisite Elder
  • Posts: 1662
  • Location: USA
  • All your base are belong to us!
    • All your base are belong to us!
Re: TMK keyboard firmware
« Reply #459 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.

Offline Charger

  • Posts: 166
Re: TMK keyboard firmware
« Reply #460 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.

Offline domoaligato

  • * Exquisite Elder
  • Posts: 1662
  • Location: USA
  • All your base are belong to us!
    • All your base are belong to us!
Re: TMK keyboard firmware
« Reply #461 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?
« Last Edit: Mon, 15 September 2014, 20:44:05 by domoaligato »

Offline Charger

  • Posts: 166
Re: TMK keyboard firmware
« Reply #462 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

Offline domoaligato

  • * Exquisite Elder
  • Posts: 1662
  • Location: USA
  • All your base are belong to us!
    • All your base are belong to us!
Re: TMK keyboard firmware
« Reply #463 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

Offline ComradeSniper

  • HHKB Pro
  • * Esteemed Elder
  • Posts: 1086
  • Location: Montana
Re: TMK keyboard firmware
« Reply #464 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?

Offline Charger

  • Posts: 166
Re: TMK keyboard firmware
« Reply #465 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
« Last Edit: Tue, 16 September 2014, 02:20:32 by Charger »

Offline domoaligato

  • * Exquisite Elder
  • Posts: 1662
  • Location: USA
  • All your base are belong to us!
    • All your base are belong to us!
Re: TMK keyboard firmware
« Reply #466 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

Offline ComradeSniper

  • HHKB Pro
  • * Esteemed Elder
  • Posts: 1086
  • Location: Montana
Re: TMK keyboard firmware
« Reply #467 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.
« Last Edit: Tue, 16 September 2014, 11:05:05 by ComradeSniper »

Offline esoomenona

  • Gnillort?
  • Posts: 5323
Re: TMK keyboard firmware
« Reply #468 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?

Offline hasu

  • Thread Starter
  • Posts: 3125
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: TMK keyboard firmware
« Reply #469 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
TMK products:HHKB Alt  ⌨ConvertersAlps64FC660C AltFC980C Alt

Offline ComradeSniper

  • HHKB Pro
  • * Esteemed Elder
  • Posts: 1086
  • Location: Montana
Re: TMK keyboard firmware
« Reply #470 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.

Offline hasu

  • Thread Starter
  • Posts: 3125
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: TMK keyboard firmware
« Reply #471 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.

TMK products:HHKB Alt  ⌨ConvertersAlps64FC660C AltFC980C Alt

Offline hasu

  • Thread Starter
  • Posts: 3125
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: TMK keyboard firmware
« Reply #472 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

TMK products:HHKB Alt  ⌨ConvertersAlps64FC660C AltFC980C Alt

Offline primitiveType

  • Posts: 38
Re: TMK keyboard firmware
« Reply #473 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  :-[

Offline hasu

  • Thread Starter
  • Posts: 3125
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: TMK keyboard firmware
« Reply #474 on: Sun, 28 September 2014, 20:38:47 »
TMK products:HHKB Alt  ⌨ConvertersAlps64FC660C AltFC980C Alt

Offline Moralless

  • Posts: 526
  • Location: Sydney, Australia
Re: TMK keyboard firmware
« Reply #475 on: Thu, 02 October 2014, 11:21:19 »
Hello, I actually posted a thread about my problem here before seeing this thread and was wondering if anyone has had any similar problems as me and how they solved it.

Offline zeroni13

  • Posts: 97
  • Location: Oslo, Norway
Re: TMK keyboard firmware
« Reply #476 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?
My phantom build: http://bit.ly/1rEjqp5

Offline hasu

  • Thread Starter
  • Posts: 3125
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: TMK keyboard firmware
« Reply #477 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?
TMK products:HHKB Alt  ⌨ConvertersAlps64FC660C AltFC980C Alt

Offline zeroni13

  • Posts: 97
  • Location: Oslo, Norway
Re: TMK keyboard firmware
« Reply #478 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
« Last Edit: Sun, 05 October 2014, 11:58:54 by zeroni13 »
My phantom build: http://bit.ly/1rEjqp5

Offline Lubed Up Slug

  • Posts: 79
Re: TMK keyboard firmware
« Reply #479 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?

Offline domoaligato

  • * Exquisite Elder
  • Posts: 1662
  • Location: USA
  • All your base are belong to us!
    • All your base are belong to us!
Re: TMK keyboard firmware
« Reply #480 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.

Offline Lubed Up Slug

  • Posts: 79
Re: TMK keyboard firmware
« Reply #481 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?

Offline strict

  • TKL Zealot
  • Posts: 1921
  • Location: PA
Re: TMK keyboard firmware
« Reply #482 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

Realforce EK45 (Silenced)  |  Realforce 87UW (45g)  |  Realforce 87UWS (Variable)
Filco MJ2 TKL (Cherry Clears)  |  Phantom 87 (78g Gateron Clears)  |  Phantom 86 (67g Zealios)


Offline Lubed Up Slug

  • Posts: 79
Re: TMK keyboard firmware
« Reply #483 on: Mon, 06 October 2014, 15:33:55 »

Offline domoaligato

  • * Exquisite Elder
  • Posts: 1662
  • Location: USA
  • All your base are belong to us!
    • All your base are belong to us!
Re: TMK keyboard firmware
« Reply #484 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

Offline epicepee

  • Posts: 35
Re: TMK keyboard firmware
« Reply #485 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?

Offline fog

  • Posts: 57
  • Location: Seattle
  • actual synthetic
    • Solarized
Re: TMK keyboard firmware
« Reply #486 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.
Ethan Schoonover / http://ethanschoonover.com
HHKB Pro 2 Blank / Leopold FC660M Clears / Keycool 84 Blacks

Offline hasu

  • Thread Starter
  • Posts: 3125
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: TMK keyboard firmware
« Reply #487 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
TMK products:HHKB Alt  ⌨ConvertersAlps64FC660C AltFC980C Alt

Offline Moralless

  • Posts: 526
  • Location: Sydney, Australia
Re: TMK keyboard firmware
« Reply #488 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:
79325-0

Then re-did it to make it look like this:
79327-1

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:
79329-2

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):
79331-3 79325-4

And here's the code of only the parts I've modified:

matrix.c: (dropbox link)
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):
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)
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
};

Offline hasu

  • Thread Starter
  • Posts: 3125
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: TMK keyboard firmware
« Reply #489 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;
TMK products:HHKB Alt  ⌨ConvertersAlps64FC660C AltFC980C Alt

Offline Moralless

  • Posts: 526
  • Location: Sydney, Australia
Re: TMK keyboard firmware
« Reply #490 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 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;
    }
}

79336-0

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.
« Last Edit: Fri, 10 October 2014, 08:21:39 by moralles »

Offline hasu

  • Thread Starter
  • Posts: 3125
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: TMK keyboard firmware
« Reply #491 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
TMK products:HHKB Alt  ⌨ConvertersAlps64FC660C AltFC980C Alt

Offline Moralless

  • Posts: 526
  • Location: Sydney, Australia
Re: TMK keyboard firmware
« Reply #492 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.

Offline robskillz

  • Posts: 3
Re: TMK keyboard firmware
« Reply #493 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!

Offline hasu

  • Thread Starter
  • Posts: 3125
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: TMK keyboard firmware
« Reply #494 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
TMK products:HHKB Alt  ⌨ConvertersAlps64FC660C AltFC980C Alt

Offline robskillz

  • Posts: 3
Re: TMK keyboard firmware
« Reply #495 on: Sun, 12 October 2014, 17:38:16 »
Thanks for the tip :)

Offline primitiveType

  • Posts: 38
Re: TMK keyboard firmware
« Reply #496 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
« Last Edit: Wed, 15 October 2014, 16:14:31 by primitiveType »

Offline hasu

  • Thread Starter
  • Posts: 3125
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: TMK keyboard firmware
« Reply #497 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
TMK products:HHKB Alt  ⌨ConvertersAlps64FC660C AltFC980C Alt

Offline primitiveType

  • Posts: 38
Re: TMK keyboard firmware
« Reply #498 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

Offline xybre

  • Posts: 113
  • Location: Chicago, IL
  • clickityclackclickityclack
    • Music and Stuff
Re: TMK keyboard firmware
« Reply #499 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.
GON NerD 60 & Duck Eagle & Unicomp Ultra Classic & Das Keyboard Ultimate