Author Topic: Teensy HHKB Controller (Write up)  (Read 67530 times)

0 Members and 1 Guest are viewing this topic.

Offline jmolino

  • Posts: 44
  • Some folks look for answers,others look for fights
Re: Teensy HHKB Controller (Write up)
« Reply #50 on: Sun, 22 June 2014, 00:30:47 »
My connection is wrong.... PF0 and PF1 should be PE6 and PE7... GRRRR!  I read this page to get that debugged:

https://github.com/tmk/tmk_keyboard/blob/master/keyboard/hhkb/doc/HHKB.txt Down where it says "Connector Cable"... time to de-solder and re-solder (I've never done either of these! LOL ---- oh what fun it is to try something new!)

I wonder how many people simply stop at switching keycaps, and never get into the meat of things.....maybe that should have been me LOL!

Offline jmolino

  • Posts: 44
  • Some folks look for answers,others look for fights
Re: Teensy HHKB Controller (Write up)
« Reply #51 on: Sun, 22 June 2014, 00:36:08 »
BTW - that "No-Clean" Wick by NTE worked like a charm!  sucked up the solder and let me pull off the mis-connected wires!  (Smasher - sorry to muddy up your thread - I'll start a new one if I feel the need to post for help more).....  Peace!
« Last Edit: Sun, 22 June 2014, 18:25:21 by jmolino »

Offline Smasher816

  • HHKB Master
  • Thread Starter
  • Posts: 538
  • Location: return STATE_MISSOURI;
Re: Teensy HHKB Controller (Write up)
« Reply #52 on: Sun, 22 June 2014, 19:20:06 »
No problem jmolino. Sorry for the late reply I was out camping with the family (so no cell service). You get everything worked out?

Yeah keyboards are a crazy hobby. Just spent 100 on new soldering gear. If you talked to me last year I would have had no interest in it.

Offline jmolino

  • Posts: 44
  • Some folks look for answers,others look for fights
Re: Teensy HHKB Controller (Write up)
« Reply #53 on: Mon, 23 June 2014, 01:15:26 »
For anybody on linux trying to do this, be sure to compile the "teensy_loader_cli" program and install it in a directory on your path (I used /usr/bin) so that when you run "make teensy", it can properly find the  loader program.

Offline Smasher816

  • HHKB Master
  • Thread Starter
  • Posts: 538
  • Location: return STATE_MISSOURI;
Re: Teensy HHKB Controller (Write up)
« Reply #54 on: Mon, 23 June 2014, 09:15:42 »
For anybody on linux trying to do this, be sure to compile the "teensy_loader_cli" program and install it in a directory on your path (I used /usr/bin) so that when you run "make teensy", it can properly find the  loader program.

That is a fair point. Make sure you check your distributions package manager, it might already be around for you to install. I used this on Arch Linux https://aur.archlinux.org/packages/teensy_loader_cli/.

If you are on ubuntu this might work "sudo apt-get install teensy-loader-cli" https://launchpad.net/~astraw/+archive/ppa/+build/1916915. If the name stays incorrect like that you can try making a symlink from teensy-loader-cli to teensy_loader_cli.

Offline runcom

  • Posts: 62
  • Location: Berlin
  • Topre lover
Re: Teensy HHKB Controller (Write up)
« Reply #55 on: Tue, 22 July 2014, 08:18:51 »
just a quick queston, does someone managed to make something to hold the teensy 2.0 in the hhkb? :)
Don't be a dumbass, always be kind to people, here and afk

Offline Smasher816

  • HHKB Master
  • Thread Starter
  • Posts: 538
  • Location: return STATE_MISSOURI;
Re: Teensy HHKB Controller (Write up)
« Reply #56 on: Tue, 22 July 2014, 08:32:41 »

Offline admiralvorian

  • Posts: 324
  • Location: United States
  • DIY
Re: Teensy HHKB Controller (Write up)
« Reply #57 on: Tue, 22 July 2014, 10:59:07 »
The double-sided tape I haven't tried, though it looks like something that would work well. I used some high-temp hot glue, first a small dab underneath the teensy then some lines that rise up on the PCB slightly from the floor of the case. It's held in like a rock and perfectly fits the HHKB hole for the connector.

Darude Status:
☐ Not Sandstorm
☑ Sandstorm                                               wts wtt wtb

Offline runcom

  • Posts: 62
  • Location: Berlin
  • Topre lover
Re: Teensy HHKB Controller (Write up)
« Reply #58 on: Tue, 22 July 2014, 12:58:20 »
The double-sided tape I haven't tried, though it looks like something that would work well. I used some high-temp hot glue, first a small dab underneath the teensy then some lines that rise up on the PCB slightly from the floor of the case. It's held in like a rock and perfectly fits the HHKB hole for the connector.

Have you applied the glue directly under the pcb also?
« Last Edit: Wed, 23 July 2014, 14:26:34 by runcom »
Don't be a dumbass, always be kind to people, here and afk

Offline fog

  • Posts: 58
  • Location: Seattle
  • actual synthetic
    • Solarized
Re: Teensy HHKB Controller (Write up)
« Reply #59 on: Tue, 23 September 2014, 03:34:44 »
Here's my first pass at my own mod with added USB hub:



The appropriate response to that hotmelt glue job is "THE HORROR, THE HORROR" in your best Colonel Kurtz.

I had to puzzle out the tmk firmware a bit since it's changed quite a bit since the original thread post. Hasu clearly moves fast. Smasher816's write up and this DA post helped in getting to a working state (and since I'm typing on it now, I declare initial victory).

I'm running a tweaked (both in terms of timings and layers) SpaceFN layout. Really like it so far.

The one thing I want to add to this board is a feature that LOVE on the Leopold FC660M: Escape takes the place of the grave/tilde key, but Shift-Esc still produces a tilde (lesser used grave is banished to fn-Esc). I'm not entirely sure how to proceed in modifying the TMK firmware to produce this result. I'll continue to explore things, but any TMK pros out there that could weigh in would be appreciated.

Also, for anyone looking at the current TMK firmware and not sure what to mod to match Smasher816's pinout, I'm happy to load the relevant files to up to a gist...
Ethan Schoonover / http://ethanschoonover.com
HHKB / Leopold FC660M + Clueboard PCB / Nullbits Tidbit / Various custom boards

Offline abjr

  • Posts: 171
  • Location: Connecticut
    • abjr.org
Re: Teensy HHKB Controller (Write up)
« Reply #60 on: Tue, 23 September 2014, 12:50:46 »
Very nice!

The one thing I want to add to this board is a feature that LOVE on the Leopold FC660M: Escape takes the place of the grave/tilde key, but Shift-Esc still produces a tilde (lesser used grave is banished to fn-Esc).

In fact I asked hasu this exact question here. His reply was 2 posts later. Basically it's doable, but I haven't tried it yet.
CM QFR | magicforce 68 (Gateron) | magicforce 68 (Outemu) | Acros 6311-K

Offline fog

  • Posts: 58
  • Location: Seattle
  • actual synthetic
    • Solarized
Re: Teensy HHKB Controller (Write up)
« Reply #61 on: Tue, 23 September 2014, 21:35:51 »
In fact I asked hasu this exact question here. His reply was 2 posts later. Basically it's doable, but I haven't tried it yet.

Awesome, thanks! I'll give it a go.
Ethan Schoonover / http://ethanschoonover.com
HHKB / Leopold FC660M + Clueboard PCB / Nullbits Tidbit / Various custom boards

Offline Smasher816

  • HHKB Master
  • Thread Starter
  • Posts: 538
  • Location: return STATE_MISSOURI;
Re: Teensy HHKB Controller (Write up)
« Reply #62 on: Tue, 23 September 2014, 23:21:00 »
Here's my first pass at my own mod with added USB hub:

Show Image


The appropriate response to that hotmelt glue job is "THE HORROR, THE HORROR" in your best Colonel Kurtz.

I had to puzzle out the tmk firmware a bit since it's changed quite a bit since the original thread post. Hasu clearly moves fast. Smasher816's write up and this DA post helped in getting to a working state (and since I'm typing on it now, I declare initial victory).

I'm running a tweaked (both in terms of timings and layers) SpaceFN layout. Really like it so far.

The one thing I want to add to this board is a feature that LOVE on the Leopold FC660M: Escape takes the place of the grave/tilde key, but Shift-Esc still produces a tilde (lesser used grave is banished to fn-Esc). I'm not entirely sure how to proceed in modifying the TMK firmware to produce this result. I'll continue to explore things, but any TMK pros out there that could weigh in would be appreciated.

Also, for anyone looking at the current TMK firmware and not sure what to mod to match Smasher816's pinout, I'm happy to load the relevant files to up to a gist...

Interesting project. It does look pretty horrible - but hey, if it works, then it works. Congrats! Somehow I feel there might be a better way by cannibalizing a usb hub and just plugging the teensy into that instead of hacking into the stock board. I'm not sure about that though.

Would you mind making the gist? I actually haven't updated much since I initially flashed the board, so I am still on an older version of the TMK code. So it would be nice to get updated again and update the OP. I could probably figure it out, but no sense in reinventing the wheel if it has already been done before.

Offline fog

  • Posts: 58
  • Location: Seattle
  • actual synthetic
    • Solarized
Re: Teensy HHKB Controller (Write up)
« Reply #63 on: Wed, 24 September 2014, 00:08:37 »
Interesting project. It does look pretty horrible - but hey, if it works, then it works. Congrats! Somehow I feel there might be a better way by cannibalizing a usb hub and just plugging the teensy into that instead of hacking into the stock board. I'm not sure about that though.

Would you mind making the gist? I actually haven't updated much since I initially flashed the board, so I am still on an older version of the TMK code. So it would be nice to get updated again and update the OP. I could probably figure it out, but no sense in reinventing the wheel if it has already been done before.

I agree. I thought about alternate controllers that could function as a usb hub, but that's outside my past experience and thought I'd just take the "easy" way out and strip down a usb hub.

FWIW, I originally machined an aluminum plate that fit into the HHKB PCB recess, and then mounted different usb plugs to it. Rock solid and perfectly aligned. Then, at around 3am Saturday one of my mini USB pins failed. I was using an otherwise nice, rugged amphenol connector which I screw mounted to the HHKB case... looks good and was secure.

Then the smaller usb2.0 four port hub I was using gave out after surviving transplant.

Anyhow, after the mini usb failed, I was going to just hardwire a cable in but then figured I was either going to make this work or I was going to keep trying until it worked, so I just dremeled it (with vacuum suction and a half face respirator, mind). I don't like cutting off options but in this case was very happy with the results.

So I have a replacement hub and the new amphenol mini usb connector coming in and once they arrive I'm going to clean up the hack job. Will also replace the ribbon cable with one that is thinner.

I do agree that there is probably an even nicer way to mount all these, maybe a circuit board (generic or custom).
Ethan Schoonover / http://ethanschoonover.com
HHKB / Leopold FC660M + Clueboard PCB / Nullbits Tidbit / Various custom boards

Offline Smasher816

  • HHKB Master
  • Thread Starter
  • Posts: 538
  • Location: return STATE_MISSOURI;
Re: Teensy HHKB Controller (Write up)
« Reply #64 on: Wed, 24 September 2014, 00:16:36 »
Ohh, I see. I saw the stock controller still in there and just assumed that it was for the hub. But I guess you are using another board for the actual hub features and just using the stock controller for the plugs. You could probably save some space by just buying two usb ports separately and connecting your wires to that (just tack them down with some tape/glue).

Offline fog

  • Posts: 58
  • Location: Seattle
  • actual synthetic
    • Solarized
Re: Teensy HHKB Controller (Write up)
« Reply #65 on: Wed, 24 September 2014, 00:26:15 »
Ohh, I see. I saw the stock controller still in there and just assumed that it was for the hub. But I guess you are using another board for the actual hub features and just using the stock controller for the plugs. You could probably save some space by just buying two usb ports separately and connecting your wires to that (just tack them down with some tape/glue).

Yes, that was the original plan... here's a quick shot (low quality and that's a teensy 3, not a 2, just for scale) of the parts I'll be putting in (that skinny guy is usb four port).



I'll post again here once I get the gists up. I think I'll upload the repo as it stands and will try to point out the specific changes I made as well.
Ethan Schoonover / http://ethanschoonover.com
HHKB / Leopold FC660M + Clueboard PCB / Nullbits Tidbit / Various custom boards

Offline fog

  • Posts: 58
  • Location: Seattle
  • actual synthetic
    • Solarized
Re: Teensy HHKB Controller (Write up)
« Reply #66 on: Sun, 05 October 2014, 15:07:11 »
Here's revision 2 of my HHKB with usb hub. This is more or less the original version I intended, having installed the replacement parts (usb mini in, usb2 four port hub). This also has a thumb drive internally, keeping both external ports available.



I will post the code I'm working on as mentioned previously. Now that this is back together I want to address one or two bugs and then will get the repo online.
Ethan Schoonover / http://ethanschoonover.com
HHKB / Leopold FC660M + Clueboard PCB / Nullbits Tidbit / Various custom boards

Offline Smasher816

  • HHKB Master
  • Thread Starter
  • Posts: 538
  • Location: return STATE_MISSOURI;
Re: Teensy HHKB Controller (Write up)
« Reply #67 on: Sun, 05 October 2014, 15:31:17 »
Looking good fog.

Offline fog

  • Posts: 58
  • Location: Seattle
  • actual synthetic
    • Solarized
Re: Teensy HHKB Controller (Write up)
« Reply #68 on: Sun, 05 October 2014, 21:37:19 »
Here's a minor revision (quick and dirty shield for cable retention) and a shot of the bottom where I put a hole in to do a hard reset on the teensy (for when magic keys aren't enough).



Ethan Schoonover / http://ethanschoonover.com
HHKB / Leopold FC660M + Clueboard PCB / Nullbits Tidbit / Various custom boards

Offline fog

  • Posts: 58
  • Location: Seattle
  • actual synthetic
    • Solarized
Re: Teensy HHKB Controller (Write up)
« Reply #69 on: Mon, 06 October 2014, 17:48:17 »
Here's a repo with the current working configuration. I added some notes at the top of the main README. The customized file list (not all critical changes and there is at least one unused keymap in this commit) are listed in this commit:

https://github.com/altercation/tmk_firrmware_hhkb_teensy2/commit/b1725e96a633bdb5ff54d397260b66210cbedead

The critical changes were in:

  • keyboard/hhkb/hhkb_avr.h
  • keyboard/hhkb/Makefile.pjrc (I used the plain Makefile as well, but currently build off of the .pjrc Makefile)

Note that the bootloader size in Makefile.pjrc is listed as 2048 in that commit. This is probably not correct. I was testing different values as I couldn't get magic keys to successfully reset to the bootloader (they worked other than that). Still not working. Could be a bootloader offset issue or something else.
« Last Edit: Mon, 06 October 2014, 17:50:57 by fog »
Ethan Schoonover / http://ethanschoonover.com
HHKB / Leopold FC660M + Clueboard PCB / Nullbits Tidbit / Various custom boards

Offline fog

  • Posts: 58
  • Location: Seattle
  • actual synthetic
    • Solarized
Re: Teensy HHKB Controller (Write up)
« Reply #70 on: Tue, 07 October 2014, 00:36:57 »
I've just added a first pass custom function to make Esc function like a Leopold FC660M, where pressing Esc normally does just that, while Shift+Esc produces a tilde.

The function and associated keymaps, etc. are in this commit: https://github.com/altercation/tmk_firrmware_hhkb_teensy2/commit/3d8f4f94b5b489796903660e0f21bb5c3445fd72

I don't think it's perfect yet (I've had a couple weird instances where I feel like there is a stuck modifier) but that might not be due to this function. YMMV.
Ethan Schoonover / http://ethanschoonover.com
HHKB / Leopold FC660M + Clueboard PCB / Nullbits Tidbit / Various custom boards

Offline Smasher816

  • HHKB Master
  • Thread Starter
  • Posts: 538
  • Location: return STATE_MISSOURI;
Re: Teensy HHKB Controller (Write up)
« Reply #71 on: Tue, 07 October 2014, 00:57:46 »
Very strange. I remember wiring a reply but I don't see it here anyone. Ohh well, I guess I can try to rewrite it.

You got some serious balls to do permanent case mods like that, but it seems to be turning out well. Congrats.

Thanks for the repo, the hhkb_avr.c file will be useful if I ever update the firmware on mine. As far as the magic boot loader reset combo, it works fine with the normal makefilw and the size set to 512 for me. Have you tried that in your pjrc file yet?

Offline fog

  • Posts: 58
  • Location: Seattle
  • actual synthetic
    • Solarized
Re: Teensy HHKB Controller (Write up)
« Reply #72 on: Tue, 07 October 2014, 01:25:25 »
Very strange. I remember wiring a reply but I don't see it here anyone. Ohh well, I guess I can try to rewrite it.

You got some serious balls to do permanent case mods like that, but it seems to be turning out well. Congrats.

There was probably a glass of red wine involved. Maybe 1.5 glasses. It was a damn the torpedoes moment.

Thanks for the repo, the hhkb_avr.c file will be useful if I ever update the firmware on mine. As far as the magic boot loader reset combo, it works fine with the normal makefilw and the size set to 512 for me. Have you tried that in your pjrc file yet?

Just tried it again. I was also pretty certain that 512 is the correct value, but when I shift+shift+pause with 'sudo hid_listen' running the device disconnects successfully as though rebooting but it never successfully reboots.

Are you using the lufa bootloader instead of the teensy original halfkay? I suspect that might solve this for me, but just a hunch.

Also, I just added another function for those interested, which makes backspace a dual mode key (when shifted, it returns a pipe). Code in my sample keymap here: https://github.com/altercation/tmk_firrmware_hhkb_teensy2/blob/master/keyboard/hhkb/keymap_es.c
Ethan Schoonover / http://ethanschoonover.com
HHKB / Leopold FC660M + Clueboard PCB / Nullbits Tidbit / Various custom boards

Offline hasu

  • Posts: 3471
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: Teensy HHKB Controller (Write up)
« Reply #73 on: Tue, 07 October 2014, 01:44:41 »
Nice mod. We seldom see unreversible modification on HHKB like this here, I like your work!

As for modifier stuck, *basically* you should place same modifier(and Fn) on a key position between layers. This rule comes from current TMK keymap design limitation.

I mean, you cannot place LALT there in Layer 2, LCTL should be there instead because you have LCTL on the key on Layer 0. (Line 66) And LANG4, LANG5 and SPC on Line 68 also infringe the rule.

https://github.com/altercation/tmk_firrmware_hhkb_teensy2/blob/3d8f4f94b5b489796903660e0f21bb5c3445fd72/keyboard/hhkb/keymap_es.c#L66

For example,
1) on Layer 0 you press LCTL(and hold it) - <LCTL press event>
2) hold FN1 down to move into Layer 2 - LCTL is still down
3) on Layer 2 you release the ex-LCTL(now LALT) key - this fires just <LALT release event>(not LCTL)


Voila, LCTL is stuck now :) Never occur <LCTL release event> here.


I don't think it's perfect yet (I've had a couple weird instances where I feel like there is a stuck modifier) but that might not be due to this function. YMMV.

Offline fog

  • Posts: 58
  • Location: Seattle
  • actual synthetic
    • Solarized
Re: Teensy HHKB Controller (Write up)
« Reply #74 on: Tue, 07 October 2014, 13:09:08 »
Nice mod. We seldom see unreversible modification on HHKB like this here, I like your work!

Thanks! I still think going with a custom PCB from you is probably a better route, but I got lucky and everything worked out.

As for modifier stuck, *basically* you should place same modifier(and Fn) on a key position between layers. This rule comes from current TMK keymap design limitation.
...<snip>...
Voila, LCTL is stuck now :) Never occur <LCTL release event> here.

This makes complete sense and is very clear, thank you *so* much, Hasu. I'll rework the layouts based on that.
Ethan Schoonover / http://ethanschoonover.com
HHKB / Leopold FC660M + Clueboard PCB / Nullbits Tidbit / Various custom boards

Offline Smasher816

  • HHKB Master
  • Thread Starter
  • Posts: 538
  • Location: return STATE_MISSOURI;
Re: Teensy HHKB Controller (Write up)
« Reply #75 on: Tue, 07 October 2014, 13:56:42 »
Nice mod. We seldom see unreversible modification on HHKB like this here, I like your work!

Thanks! I still think going with a custom PCB from you is probably a better route, but I got lucky and everything worked out.

But then you would not have had USB support since hasu's pcv doesn't support that and he has no plans on adding it.

Offline fog

  • Posts: 58
  • Location: Seattle
  • actual synthetic
    • Solarized
Re: Teensy HHKB Controller (Write up)
« Reply #76 on: Tue, 07 October 2014, 14:13:46 »
But then you would not have had USB support since hasu's pcv doesn't support that and he has no plans on adding it.

True, and given my current "laptop" setup, that usb hub is a requirement when I'm mobile.
Ethan Schoonover / http://ethanschoonover.com
HHKB / Leopold FC660M + Clueboard PCB / Nullbits Tidbit / Various custom boards

Offline fog

  • Posts: 58
  • Location: Seattle
  • actual synthetic
    • Solarized
Re: Teensy HHKB Controller (Write up)
« Reply #77 on: Wed, 08 October 2014, 17:53:20 »
Here's a snapshot of my keymap with new fixes suggested by Hasu above: https://github.com/altercation/tmk_firrmware_hhkb_teensy2/blob/432fae840fa46aba3fe03d34c8598f1dfe93eaa9/keyboard/hhkb/keymap_es.c

Note that the above link is to a specific commit, so if you are reading this from THE FUTURE you probably should also check the current master for that file (or more likely I've reforked Hasu's repo and am now properly rebasing off it).
Ethan Schoonover / http://ethanschoonover.com
HHKB / Leopold FC660M + Clueboard PCB / Nullbits Tidbit / Various custom boards

Offline deci

  • Posts: 206
  • Location: san diego
Re: Teensy HHKB Controller (Write up)
« Reply #78 on: Wed, 29 October 2014, 05:59:09 »
Thanks so much to Smasher for this guide and thanks to Hasu for this great firmware.

Got everything wired up and custom keycodes working without much difficulty.

The amount of cool stuff you can do with TMK is awesome.

Thanks for making this process so painless. I love my hhkb so much more now. ;D

Offline Smasher816

  • HHKB Master
  • Thread Starter
  • Posts: 538
  • Location: return STATE_MISSOURI;
Re: Teensy HHKB Controller (Write up)
« Reply #79 on: Wed, 29 October 2014, 18:38:16 »
Glad it helped. Enjoy your HHKB

Offline pharaoh

  • Posts: 40
  • Location: Nj
Re: Teensy HHKB Controller (Write up)
« Reply #80 on: Fri, 31 October 2014, 19:45:28 »
I just stumbled upon this thread, read through all of it, immediately bought the components to try it out.  I can't wait to make my HH  happier!
hhkb type-s| jd40 | jd45 | keycool87

Offline jdcarpe

  • * Curator
  • Posts: 8852
  • Location: Odessa, TX
  • Live long, and prosper.
Re: Teensy HHKB Controller (Write up)
« Reply #81 on: Fri, 21 November 2014, 08:19:10 »
Here's a minor revision (quick and dirty shield for cable retention) and a shot of the bottom where I put a hole in to do a hard reset on the teensy (for when magic keys aren't enough).

Show Image


Show Image


This mod is awesome! Programmable Teensy controller, USB hub retained (added), and a flash drive, wow. Maybe next you will replace the flash drive with a MicroSD card slot mounted in the side of your HHKB!! :D
KMAC :: LZ-GH :: WASD CODE :: WASD v2 :: GH60 :: Alps64 :: JD45 :: IBM Model M :: IBM 4704 "Pingmaster"

http://jd40.info :: http://jd45.info


in memoriam

"When I was a kid, I used to take things apart and never put them back together."

Offline fog

  • Posts: 58
  • Location: Seattle
  • actual synthetic
    • Solarized
Re: Teensy HHKB Controller (Write up)
« Reply #82 on: Sat, 22 November 2014, 13:30:16 »
This mod is awesome! Programmable Teensy controller, USB hub retained (added), and a flash drive, wow. Maybe next you will replace the flash drive with a MicroSD card slot mounted in the side of your HHKB!! :D

Hey thanks! Big fan of your work!

I think the slot is a great idea. I did look at a couple hubs that also have built in card readers. Maybe will revisit those.
Ethan Schoonover / http://ethanschoonover.com
HHKB / Leopold FC660M + Clueboard PCB / Nullbits Tidbit / Various custom boards

Offline blackvan

  • Posts: 7
Re: Teensy HHKB Controller (Write up)
« Reply #83 on: Fri, 24 April 2015, 10:37:13 »
I have the teensy all wired up and installed (great writ up on that front btw) but I am stuck in the programming part. In the OP it says "Open matrix.c and scroll down to this line "#elif defined(__AVR_ATmega32U4__)" but I do not see this line or the quoted init block in matrix.c of the current TMK repo. I see this line mentioned in hhkb_avr.h but the code is not the same as what is in the thread so I am not sure what to change.

Does anything need to be changed or was TMK updated at some point so that this teensy wiring is now included standard? I'm not really a coder so any help would be great.

Offline lifow

  • Posts: 2
Re: Teensy HHKB Controller (Write up)
« Reply #84 on: Tue, 23 June 2015, 13:53:24 »
I have the teensy all wired up and installed (great writ up on that front btw) but I am stuck in the programming part. In the OP it says "Open matrix.c and scroll down to this line "#elif defined(__AVR_ATmega32U4__)" but I do not see this line or the quoted init block in matrix.c of the current TMK repo. I see this line mentioned in hhkb_avr.h but the code is not the same as what is in the thread so I am not sure what to change.

Does anything need to be changed or was TMK updated at some point so that this teensy wiring is now included standard? I'm not really a coder so any help would be great.

I'm in the same position. Did you go ahead and try it without any modification? Any luck?


Offline Drew Baumann

  • Posts: 27
Re: Teensy HHKB Controller (Write up)
« Reply #85 on: Sat, 08 August 2015, 03:26:37 »
I have the teensy all wired up and installed (great writ up on that front btw) but I am stuck in the programming part. In the OP it says "Open matrix.c and scroll down to this line "#elif defined(__AVR_ATmega32U4__)" but I do not see this line or the quoted init block in matrix.c of the current TMK repo. I see this line mentioned in hhkb_avr.h but the code is not the same as what is in the thread so I am not sure what to change.

Does anything need to be changed or was TMK updated at some point so that this teensy wiring is now included standard? I'm not really a coder so any help would be great.

I'm in the same position. Did you go ahead and try it without any modification? Any luck?



I did the original wiring and spent some time messing around with the files only to have failing results. I looked up the wiring details in Hasu's writeup on github and changed two wires. After that I had success with normal unmodified builds. Attached is an image highlighting the wires I needed to change.



Offline fog

  • Posts: 58
  • Location: Seattle
  • actual synthetic
    • Solarized
Re: Teensy HHKB Controller (Write up)
« Reply #86 on: Tue, 20 October 2015, 14:23:47 »
I've added a cleaned up hhkb_teensy keyboard variant to the current TMK code that targets this modification specifically (replacing the HHKB Pro 2 controller board with a Teensy 2.0).

I've posted it here: https://github.com/altercation/tmk_keyboard/tree/master/keyboard/hhkb_teensy .

I don't know if it's a pull request worthy, but I may submit it to the official TMK project if there is interest.

-Ethan
Ethan Schoonover / http://ethanschoonover.com
HHKB / Leopold FC660M + Clueboard PCB / Nullbits Tidbit / Various custom boards

Offline undersea

  • Posts: 1
  • Location: Hochiminh/Vietnam
Re: Teensy HHKB Controller (Write up)
« Reply #87 on: Fri, 21 April 2017, 09:29:58 »
Dear anyone,

Could you please help me this one ?
I am using Teensy 2.0 ++ for Controller of HHKB Pro2. I was successfully with this guide.
Now it isn't stable, I desoldering the pin B0-B6 and F0-F1 & GRD +5V

I solder it with Pin A0-A6 and D0-D1 and another GRD, +5V.

I know I have to re-program and change pin in hhkb_avr.h. I dont know about C++
The teensy PCB could programmed with TMK firmware successfully. But I dont know how to change PIN, PORT, DDR for working.
Now Windows can regconize board, but couldn't type anything.
I use Switch Hitter to test keyboard.

Thanks in advance.

Offline hbar

  • Posts: 1
Re: Teensy HHKB Controller (Write up)
« Reply #88 on: Mon, 24 July 2017, 03:56:09 »
I know I'm digging out an old thread here, but I just converted a HHKB to TMK with a Pro Micro board, and I thought this could be useful to people like me who hate loose wires:
174057-0
What I did was to align the ZH connector (1.5mm pitch), with its pins 2 and 12 already bent towards their friend pins 1 and 13, with the 2.54mm pitch of the contacts on the board as well as possible.  I turns out that three pins (5, 7, and 9) would interfere with their neighbours, so I bent them upward slightly and soldered three wires to them so they connect to the other side of the board:
174059-1
Of course, VCC and GND aren't in the right place, so we need two more wires to connect them (VCC runs underneath the board, tucked between the PCB and the connector body, so the underside of the assembly is still rather flat).  Now we can keep this board in place with some double-sided tape right behind the DIP-switch cover, the original HHKB cable is long enough to reach there.  One drawback is that the pin assignment is completely random, therefore about 20 lines in the firmware must be changed to accommodate this.  Also, two controller pins are shorted to GND and VCC, respectively, so we better make sure they are configured as inputs.

Offline joric

  • Posts: 136
Re: Teensy HHKB Controller (Write up)
« Reply #89 on: Thu, 09 May 2019, 16:52:33 »
Did you make it work or not? I'm trying to do the same but the remapping seems hard. I was going to do something like this but your "random" proximity-based mapping seems more viable :) Maybe I'll use yours. I was mostly doing that for nRFMicro and pins on Nordic controllers are all equal so there's no real preference.

Would look somewhat like this (the riser board locks in place without glue):

« Last Edit: Sat, 11 May 2019, 17:14:37 by joric »

Offline joric

  • Posts: 136
Re: Teensy HHKB Controller (Write up)
« Reply #90 on: Sat, 11 May 2019, 04:05:31 »
Alternative "Hbar" HHKB Pro 2 - Pro Micro wiring (from the photos above):



Code: [Select]
#define HHKB_PINS_PRO_MICRO_HBAR{ B2, B3, D7, B1, C6, F7, D4, F6, F5 }               /* Pro Micro Hbar */

#define HHKB_PINS HHKB_PINS_PRO_MICRO_HBAR
#undef HHKB_POWER_SAVING

enum {
    HHKB_KEY_PIN = 0,    /* ~KEY: Low(0) when key is pressed (input with pullup) */
    HHKB_KEY_PREV_PIN,   /* HYS: High(1) when key is pressed (output) */
    HHKB_ROW_BIT0_PIN,   /* A(bit0) select row 0-7 (output) */
    HHKB_ROW_BIT1_PIN,   /* B(bit1) select row 0-7 (output) */
    HHKB_ROW_BIT2_PIN,   /* C(bit2) select row 0-7 (output) */
    HHKB_COL_BIT0_PIN,   /* A(bit0) select column 0-7 (output) */
    HHKB_COL_BIT1_PIN,   /* B(bit1) select column 0-7 (output) */
    HHKB_COL_BIT2_PIN,   /* C(bit2) select column 0-7 (output) */
    HHKB_COL_SELECT_PIN, /* ~D(enable) Low(0) enables selected column (output) */
#ifdef HHKB_POWER_SAVING
    HHKB_POWER_PIN,
#endif
#ifdef HHKB_JP
    HHKB_JP_COL_BIT3_PIN,   /* ~Enable of Z2   row0-7  (output) */
    HHKB_JP_COL_BIT4_PIN,   /* ~Enable of Z3   row8-15 (output) */
#endif
/*
    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.
*/
    HHKB_PIN_COUNT
} HHKB_pins_enum;

static const pin_t HHKB_pins[HHKB_PIN_COUNT] = HHKB_PINS;

static inline void KEY_ENABLE(void) { writePinLow(HHKB_pins[HHKB_COL_SELECT_PIN]); }
static inline void KEY_UNABLE(void) { writePinHigh(HHKB_pins[HHKB_COL_SELECT_PIN]); }
static inline bool KEY_STATE(void) { return readPin(HHKB_pins[HHKB_KEY_PIN]); }
static inline void KEY_PREV_ON(void) { writePinHigh(HHKB_pins[HHKB_KEY_PREV_PIN]); }
static inline void KEY_PREV_OFF(void) { writePinLow(HHKB_pins[HHKB_KEY_PREV_PIN]); }

static inline void KEY_POWER_ON(void) {
    writePinHigh(HHKB_pins[HHKB_POWER_PIN]); // MOS FET switch on
    /* Without this wait you will miss or get false key events. */
    _delay_ms(5);                       // wait for powering up
}
static inline void KEY_POWER_OFF(void) {
    writePinLow(HHKB_pins[HHKB_POWER_PIN]);  // MOS FET switch off
}
static inline bool KEY_POWER_STATE(void) { return PORTD & (1<<4); }
#else
static inline void KEY_POWER_ON(void) {}
static inline void KEY_POWER_OFF(void) {}
static inline bool KEY_POWER_STATE(void) { return true; }
#endif

static inline void KEY_INIT(void)
{
    setPinInputHigh(HHKB_pins[HHKB_KEY_PIN]);
    setPinOutput(HHKB_pins[HHKB_ROW_BIT0_PIN]);
    setPinOutput(HHKB_pins[HHKB_ROW_BIT1_PIN]);
    setPinOutput(HHKB_pins[HHKB_ROW_BIT2_PIN]);
    setPinOutput(HHKB_pins[HHKB_COL_BIT0_PIN]);
    setPinOutput(HHKB_pins[HHKB_COL_BIT1_PIN]);
    setPinOutput(HHKB_pins[HHKB_COL_BIT2_PIN]);
    setPinOutput(HHKB_pins[HHKB_COL_SELECT_PIN]);
    setPinOutput(HHKB_pins[HHKB_KEY_PREV_PIN]);
#ifdef HHKB_POWER_SAVING
    setPinOutput(HHKB_pins[HHKB_POWER_PIN]);
#endif
#ifdef HHKB_JP
    setPinOutput(HHKB_pins[HHKB_JP_COL_BIT3]);
    setPinOutput(HHKB_pins[HHKB_JP_COL_BIT4]);
#endif
    KEY_UNABLE();
    KEY_PREV_OFF();
    KEY_POWER_OFF();
}

#define SET_PIN_COND(PIN, COND) if (COND) writePinHigh(PIN); else writePinLow(PIN);

static inline void KEY_SELECT(uint8_t ROW, uint8_t COL)
{
    SET_PIN_COND(HHKB_pins[HHKB_ROW_BIT0_PIN], ROW & 1);
    SET_PIN_COND(HHKB_pins[HHKB_ROW_BIT1_PIN], ROW & 2);
    SET_PIN_COND(HHKB_pins[HHKB_ROW_BIT2_PIN], ROW & 4);

    SET_PIN_COND(HHKB_pins[HHKB_COL_BIT0_PIN], COL & 1);
    SET_PIN_COND(HHKB_pins[HHKB_COL_BIT1_PIN], COL & 2);
    SET_PIN_COND(HHKB_pins[HHKB_COL_BIT2_PIN], COL & 4);
}


Not tested, so try at your own risk.

Upd. regarding that:

Quote
Now we can keep this board in place with some double-sided tape right behind the DIP-switch cover, the original HHKB cable is long enough to reach there.

I found it to be false on my Pro 2 maybe I just haven't tried hard enough maybe my Pro 2 has shorter wires but there's almost no wiggle room and I afraid to damage the cable in process. So I don't know if it's really a viable stragegy to solder the JST connector directly to the Pro Micro. I will use the extender cable.
« Last Edit: Sat, 11 May 2019, 12:46:46 by joric »

Offline joric

  • Posts: 136
Re: Teensy HHKB Controller (Write up)
« Reply #91 on: Sat, 11 May 2019, 17:11:43 »
« Last Edit: Sat, 11 May 2019, 22:05:31 by joric »