Author Topic: TMK keyboard firmware  (Read 564568 times)

0 Members and 1 Guest are viewing this topic.

Offline Rose

  • Posts: 62
  • Location: Raleigh, NC
Re: TMK keyboard firmware
« Reply #700 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.

Offline VinnyCordeiro

  • Posts: 432
Re: TMK keyboard firmware
« Reply #701 on: Fri, 15 May 2015, 10:42:39 »
At his Project Zeta post, 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.

Offline p3lim

  • Posts: 106
  • Location: Norway
Re: TMK keyboard firmware
« Reply #702 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
« Last Edit: Fri, 15 May 2015, 12:04:00 by p3lim »

Offline tweis

  • Posts: 15
  • Location: sanfrancisco
Re: TMK keyboard firmware
« Reply #703 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
« Last Edit: Fri, 15 May 2015, 11:40:13 by tweis »
kŻl es-87 clears w/ pbt doubleshot

Offline tjweir

  • * Exquisite Elder
  • Posts: 1039
  • Location: Toronto
Re: TMK keyboard firmware
« Reply #704 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.

Offline tweis

  • Posts: 15
  • Location: sanfrancisco
Re: TMK keyboard firmware
« Reply #705 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. Can you check to see if Prev/Next keys work in Spotify?
kŻl es-87 clears w/ pbt doubleshot

Offline hasu

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

Offline hasu

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

TMK products:HHKB Alt  ⌨ConvertersAlps64FC660C AltFC980C Alt

Offline p3lim

  • Posts: 106
  • Location: Norway
Re: TMK keyboard firmware
« Reply #708 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.
« Last Edit: Sat, 16 May 2015, 06:14:39 by p3lim »

Offline hasu

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

Offline p3lim

  • Posts: 106
  • Location: Norway
Re: TMK keyboard firmware
« Reply #710 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.

Offline hasu

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

TMK products:HHKB Alt  ⌨ConvertersAlps64FC660C AltFC980C Alt

Offline p3lim

  • Posts: 106
  • Location: Norway
Re: TMK keyboard firmware
« Reply #712 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.

Offline hasu

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

Offline mpigg

  • Posts: 3
Re: TMK keyboard firmware
« Reply #714 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.
« Last Edit: Sun, 17 May 2015, 11:52:24 by mpigg »

Offline p3lim

  • Posts: 106
  • Location: Norway
Re: TMK keyboard firmware
« Reply #715 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.

Offline hasu

  • Thread Starter
  • Posts: 3131
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: TMK keyboard firmware
« Reply #716 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
« Last Edit: Fri, 22 May 2015, 20:00:04 by hasu »
TMK products:HHKB Alt  ⌨ConvertersAlps64FC660C AltFC980C Alt

Offline Spopepro

  • Posts: 229
Re: TMK keyboard firmware
« Reply #717 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).
« Last Edit: Fri, 22 May 2015, 17:15:12 by Spopepro »

Offline Spopepro

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

Offline hasu

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

Offline plegnic

  • Posts: 71
  • Location: Atlanta
  • Treble Booty. Bass Guitar.
Re: TMK keyboard firmware
« Reply #720 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... * log.txt (88.29 kB - downloaded 81 times.)

Ideas? Should I just uninstall this thing and go for WinAVR even though it isn't recommended?
Planck MIT layout [MX Clears] (in-progress) | QuickFire Storm TK [MX Brown] | Poker II [MX Blue]

Offline wakko

  • Posts: 96
  • Location: Austin, TX
Re: TMK keyboard firmware
« Reply #721 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.
« Last Edit: Tue, 02 June 2015, 13:50:27 by wakko »
NOOB
KUL ES-87

Offline VinnyCordeiro

  • Posts: 432
Re: TMK keyboard firmware
« Reply #722 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.
« Last Edit: Wed, 03 June 2015, 08:25:32 by VinnyCordeiro »

Offline wakko

  • Posts: 96
  • Location: Austin, TX
Re: TMK keyboard firmware
« Reply #723 on: Wed, 03 June 2015, 00:34:53 »
Thanks. Will check.
NOOB
KUL ES-87

Offline Yeitso

  • Posts: 10
  • Location: Sweden
Re: TMK keyboard firmware
« Reply #724 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?

Offline hasu

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

Offline VinnyCordeiro

  • Posts: 432
Re: TMK keyboard firmware
« Reply #726 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:
  • How to assign a pin of a microcontroller (for instance an ATmega32U4) for backlighting control
  • Code for the backlighting control
The few results that I found were a bit confusing for me.  :-[

Offline hasu

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

Offline VinnyCordeiro

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

Offline hasu

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

Offline VinnyCordeiro

  • Posts: 432
Re: TMK keyboard firmware
« Reply #730 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. :))

Offline hasu

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

Offline Yeitso

  • Posts: 10
  • Location: Sweden
Re: TMK keyboard firmware
« Reply #732 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

Offline hasu

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

Offline trauring

  • Posts: 94
    • off on a tangent
Re: TMK keyboard firmware
« Reply #734 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.

Offline a-c

  • Posts: 196
  • Location: USA
Re: TMK keyboard firmware
« Reply #735 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.

Offline Zukoi

  • Posts: 64
  • Location: Florida
  • ****posting at 90wpm
Re: TMK keyboard firmware
« Reply #736 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.

Offline hasu

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

Offline Zukoi

  • Posts: 64
  • Location: Florida
  • ****posting at 90wpm
Re: TMK keyboard firmware
« Reply #738 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?).

Offline hasu

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

Offline Zukoi

  • Posts: 64
  • Location: Florida
  • ****posting at 90wpm
Re: TMK keyboard firmware
« Reply #740 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...

Offline ambergrismonger

  • Posts: 7
  • Location: Portland, OR
Re: TMK keyboard firmware
« Reply #741 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



Offline hasu

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

Offline lifow

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

Offline hasu

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

Offline sth

  • 2 girls 1 cuprubber
  • Posts: 3438
Re: TMK keyboard firmware
« Reply #745 on: Fri, 26 June 2015, 02:19:44 »
test post from hhkb pro1, great success! now to start changing layouts... thanks again hasu.
11:48 -!- SmallFry [~SmallFry@unaffiliated/smallfry] has quit [Ping timeout: 245 seconds] ... rest in peace

Offline QuiGonJinn

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

Offline flabbergast

  • Posts: 234
  • Location: UK
Re: TMK keyboard firmware
« Reply #747 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.
« Last Edit: Sat, 11 July 2015, 08:39:27 by flabbergast »

Offline QuiGonJinn

  • Posts: 16
Re: TMK keyboard firmware
« Reply #748 on: Sat, 11 July 2015, 08:42:16 »
Thanks for the quick reply. Lufa library is only supported for native USB MCUs?

Offline flabbergast

  • Posts: 234
  • Location: UK
Re: TMK keyboard firmware
« Reply #749 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 ;)