Author Topic: TMK keyboard firmware  (Read 568494 times)

0 Members and 1 Guest are viewing this topic.

Offline primitiveType

  • Posts: 38
Re: TMK keyboard firmware
« Reply #550 on: Tue, 27 January 2015, 15:03:49 »
Quick question ... Does TMK/Teensy support 104-key?

Technically yes, but the electrical layout is not going to match the physical row and column layout.  There just is not enough pins.  Though you should be able to use a Teensy 2.0++ version for extra pins and work just fine.  For example a full size layout will be 22 columns and 6 rows which is 28 pins plus 4 for 3 lock LEDs.  The standard Teensy does not have that many pins, but if you are creative with the electrical layout you can go 10x11 matrix for a total of 110 switches possible.

ok, I've never handwired a board before so that's slightly intimidating, but I think I understand what you mean and feel like I can probably do it with a bit of stumbling.

So when I make the keymap for TMK, I will have to write it out as it is logically- and TMK will work with the 10x11 matrix. I imagine it will be a bit painful writing it out like that without getting confused, but that's ok.

Offline Kaibz

  • Posts: 48
  • Location: AFK but not too much
Re: TMK keyboard firmware
« Reply #551 on: Wed, 28 January 2015, 08:10:55 »
May is ask if that would be possible (if using a Teensy 2.0++) to output the Layer status and caps lock status to an LCD ?(16X2 connected to the Teensy 2.0++)

I mean i understand it would require code modifications to the firmware, but would it be really hard to do for a beginner and would it potentially compromise the responsiveness of the keyboard?
Sharing the knowledge

Offline xauser

  • Posts: 97
Re: TMK keyboard firmware
« Reply #552 on: Sat, 31 January 2015, 08:44:55 »
I have a problem when using the combination of layer tap key and layer toggle. If I do

FN0 = ACTION_LAYER_TAP_KEY(2, RGUI) -> FN1 = ACTION_LAYER_TOGGLE(1)

I expect that I toggled layer 1 after FN0 is released but instead I'm trapped in layer 2. Seems the first macro does not work as I expect. I'm back to momentary layer switching for now as this works:

FN0 = ACTION_LAYER_MOMENTARY(2) -> FN1 =  ACTION_LAYER_TOGGLE(1)

Offline hasu

  • Thread Starter
  • Posts: 3144
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: TMK keyboard firmware
« Reply #553 on: Sat, 31 January 2015, 09:40:07 »
Hmm, I can't understand your problem.

Can you show all your keymap layers and key sequence you typed in fact?
You mean you typed like FN0(down), FN0(up), FN1(down) and FN1(up)?

BTW, RGUI is modifier and it is not useful to tap modifier in most cases.

TMK products:HHKB Alt  ⌨ConvertersAlps64FC660C AltFC980C Alt

Offline vicibz

  • Posts: 20
  • Location: Ibiza
Re: TMK keyboard firmware
« Reply #554 on: Mon, 23 February 2015, 14:01:44 »
I'm trying to implement The Pegasus Hoof support and almost got it right except for a few double keystrokes and a few more non-working keys.
I'll have to debug and double check the matrix and layout, but in case someone wants to help, here's my commit:
https://github.com/vpont/tmk_keyboard/compare/tmk:master...master

Thanks!

Edit: Found and fixed. It's 100% working now :)
« Last Edit: Mon, 23 February 2015, 14:26:29 by vicibz »

Offline vicibz

  • Posts: 20
  • Location: Ibiza
Re: TMK keyboard firmware
« Reply #555 on: Tue, 24 February 2015, 04:34:21 »
I'm messing with layers and I'm obtaining weird behaviour:
First things first: My keymap

As you see I have three layers defined:
Layer 1 is activated by pressing Fn0
Layer 2 is activated by pressing Fn0 + RgtCtl

It works fine but i.e. when I press Fn0 + RgtCtl + Esc I get the calculator and then I release all three keys and press Esc again the calculator opens up again, when I should be back in Layer 0.

What's wrong?
Thanks!

Offline spiceBar

  • Posts: 998
    • ChessTiger.com
Re: TMK keyboard firmware
« Reply #556 on: Tue, 24 February 2015, 05:16:58 »
I'm messing with layers and I'm obtaining weird behaviour:
First things first: My keymap

As you see I have three layers defined:
Layer 1 is activated by pressing Fn0
Layer 2 is activated by pressing Fn0 + RgtCtl

It works fine but i.e. when I press Fn0 + RgtCtl + Esc I get the calculator and then I release all three keys and press Esc again the calculator opens up again, when I should be back in Layer 0.

What's wrong?
Thanks!


Yeah, it happened to me as well.

If you release FN0 first, then RCTL, a key release for FN1 is never generated, because there is no FN1 in the first layer.

Offline vicibz

  • Posts: 20
  • Location: Ibiza
Re: TMK keyboard firmware
« Reply #557 on: Tue, 24 February 2015, 05:35:41 »
Yeah, it happened to me as well.

If you release FN0 first, then RCTL, a key release for FN1 is never generated, because there is no FN1 in the first layer.

Thanks for confirming, looks like we did hit a bug then, didn't we?
Shouldn't all keys that don't belong to a layer after layer change be released?

Offline spiceBar

  • Posts: 998
    • ChessTiger.com
Re: TMK keyboard firmware
« Reply #558 on: Tue, 24 February 2015, 07:17:19 »
Yeah, it happened to me as well.

If you release FN0 first, then RCTL, a key release for FN1 is never generated, because there is no FN1 in the first layer.

Thanks for confirming, looks like we did hit a bug then, didn't we?
Shouldn't all keys that don't belong to a layer after layer change be released?

I'm pretty sure Hasu knows about this, and there may be a sensible reason for this behavior.

I believe the correct thing would be to send a release event for all previous pending key press events sent by that key, but there may be corner cases for which this would fail.

At this point, you should avoid putting modifiers or layer change keys in secondary layers. If you do it anyway, these keys must have the same function and name in all the layers: this way the key release event is always correctly sent.

Or maybe Hasu has a special way to deal with this?

Offline hasu

  • Thread Starter
  • Posts: 3144
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: TMK keyboard firmware
« Reply #559 on: Tue, 24 February 2015, 07:27:33 »

If you release FN0 before Fn1 it'll happen. In that case Layer 1 is already disabled  when right bottom key is released and the key is interpreted as RCtl not Fn1 then, Layer 2 is stuck in the end.

Place Fn1 on Layer 2 also.
TMK products:HHKB Alt  ⌨ConvertersAlps64FC660C AltFC980C Alt

Offline hasu

  • Thread Starter
  • Posts: 3144
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: TMK keyboard firmware
« Reply #560 on: Tue, 24 February 2015, 07:56:24 »
Ah, as spiceBar said you better place Fn1 on Layer 0.
You can not place modifier and Fn on same key, practically.

It is by desgin not bug but current keymap system inroduces some limitations and not-intuitive behaviours. I hope next keymap system fixes these limitations.
TMK products:HHKB Alt  ⌨ConvertersAlps64FC660C AltFC980C Alt

Offline ladoga

  • Posts: 5
  • Location: Earth
Re: TMK keyboard firmware
« Reply #561 on: Tue, 24 February 2015, 17:52:32 »
Hi.

Just chiming in to ask if someone has hacked support for using Caps Lock/Scroll Lock LEDs for Fn Lock? (LED on when FN layer is active)

Offline araif

  • Posts: 13
Re: TMK keyboard firmware
« Reply #562 on: Thu, 26 February 2015, 05:28:07 »
Hello,
I'm trying to implement backlight with a bunch of leds connected to a single pin and trying to control voltage and so backlight intensity, I've copied code from the lightsaber keyboard and removed all but one pin config, but I'm unable to have different backlights intensities, only one is available. What are the steps to get this working? thanks

Offline hasu

  • Thread Starter
  • Posts: 3144
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: TMK keyboard firmware
« Reply #563 on: Thu, 26 February 2015, 18:05:16 »
ladoga, check FAQ which has an related entry, IIRC.

araif, I think it depneds on your hardware design. Doing a wild guess, maybe you need PWM?
TMK products:HHKB Alt  ⌨ConvertersAlps64FC660C AltFC980C Alt

Offline araif

  • Posts: 13
Re: TMK keyboard firmware
« Reply #564 on: Thu, 26 February 2015, 19:17:24 »
araif, I think it depneds on your hardware design. Doing a wild guess, maybe you need PWM?

I saw the sleep led example and I was able to get something similar working, with a bit of work in that direction I should get something usable,

another question is this, I have a trackpoint module that is connected to PD5 for clock and PD4 for data, I'm copying code from onekey and using busywait method, what I see is that the keyboard that is controlled from the same teensy lags really hard for various keys, they are recognized only if I fire multiple events holding a key, maybe the problem is the ps2 events from the mouse spamming the interrupts or something, I was trying also to use the ps2 interrupt version with no success, how can I fix this, is more info needed to debug this on your side? thanks


Offline hasu

  • Thread Starter
  • Posts: 3144
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: TMK keyboard firmware
« Reply #565 on: Thu, 26 February 2015, 19:41:17 »
another question is this, I have a trackpoint module that is connected to PD5 for clock and PD4 for data, I'm copying code from onekey and using busywait method, what I see is that the keyboard that is controlled from the same teensy lags really hard for various keys, they are recognized only if I fire multiple events holding a key, maybe the problem is the ps2 events from the mouse spamming the interrupts or something, I was trying also to use the ps2 interrupt version with no success, how can I fix this, is more info needed to debug this on your side? thanks

Send me your keyboard if you want me to debug :)
At first you have to find exactly where your problem are located on, you'll be able to use debug print of timer for this purpose.
TMK products:HHKB Alt  ⌨ConvertersAlps64FC660C AltFC980C Alt

Offline araif

  • Posts: 13
Re: TMK keyboard firmware
« Reply #566 on: Thu, 26 February 2015, 21:19:18 »
Send me your keyboard if you want me to debug :)
At first you have to find exactly where your problem are located on, you'll be able to use debug print of timer for this purpose.

:D that's not exactly what I intended but thanks anyway, that keyboard is a standard atomic short space keyboard with this pinout I'm doing (not sure if there is a standard, I connected them based on comfort while soldering)

Code: [Select]
/* Column pin configuration
 * col: 14 13 12 11 10 9  8  7  6  5  4  3  2  1  0
 * pin: F0 F1 F4 F5 F6 F7 B6 B5 B4 D7 B0 B1 B2 B3 B7
 */

/* Row pin configuration
 * row: 0  1  2  3 4
 * pin: D1 D0 D2 D3 C6
 */



#ifdef PS2_USE_BUSYWAIT
#   define PS2_CLOCK_PORT  PORTD
#   define PS2_CLOCK_PIN   PIND
#   define PS2_CLOCK_DDR   DDRD
#   define PS2_CLOCK_BIT   5
#   define PS2_DATA_PORT   PORTD
#   define PS2_DATA_PIN    PIND
#   define PS2_DATA_DDR    DDRD
#   define PS2_DATA_BIT    4
#endif


regarding the interrupt mode, should I do something particular to make it work? would that be better than busy wait in terms of power and resources usage?

EDIT:
with hid_listen I see a *LOT* and fast of events like this, is this normal?

Code: [Select]
5680d ps2_mouse raw: [08|00 00]
5691d ps2_mouse raw: [08|00 00]
5703d ps2_mouse raw: [08|00 00]
5714d ps2_mouse raw: [08|00 00]
5725d ps2_mouse raw: [08|00 00]
5737d ps2_mouse raw: [08|0000]
5748d ps2_mouse raw: [08|00 00]
5760d ps2_mouse raw: [08|00 00]

« Last Edit: Thu, 26 February 2015, 21:25:44 by araif »

Offline hasu

  • Thread Starter
  • Posts: 3144
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: TMK keyboard firmware
« Reply #567 on: Thu, 26 February 2015, 21:33:20 »
I don't use PS/2 mouse or TrackPoint long time so I don't remmeber it is normal. You have to source code and see whether it is just a info message or error message.


Did you already see my PM?
Quote
I don't think it doesn't work with ps2_interrupt.c but I didn't try it myself.

You'll need to place proper interrupt configuration on PD5 with editting PS2_INT_INIT of config.h.
I use INT1 interrupt on PD1 while you are using PD5 which has different interrupt PCINT5, you need different intialized code for that.
TMK products:HHKB Alt  ⌨ConvertersAlps64FC660C AltFC980C Alt

Offline araif

  • Posts: 13
Re: TMK keyboard firmware
« Reply #568 on: Thu, 26 February 2015, 21:54:13 »
I don't use PS/2 mouse or TrackPoint long time so I don't remmeber it is normal. You have to source code and see whether it is just a info message or error message.


Did you already see my PM?
Quote
I don't think it doesn't work with ps2_interrupt.c but I didn't try it myself.

You'll need to place proper interrupt configuration on PD5 with editting PS2_INT_INIT of config.h.
I use INT1 interrupt on PD1 while you are using PD5 which has different interrupt PCINT5, you need different intialized code for that.

sorry I missed the pm, no it's not an error, it is printed in ps2_mouse when executing the ps2_mouse_task, I think that the trackpoint floods with events  (maybe due to polling?), and other key events for the keyboard cannot be delivered, so the original problem.

For the reset code I'm trying with this but this leads to nothing working anymore...

Code: [Select]

/* PS/2 mouse interrupt version */
#ifdef PS2_USE_INT
/* uses INT1 for clock line(ATMega32U4) */
#define PS2_CLOCK_PORT  PORTD
#define PS2_CLOCK_PIN   PIND
#define PS2_CLOCK_DDR   DDRD
#define PS2_CLOCK_BIT   5
#define PS2_DATA_PORT   PORTD
#define PS2_DATA_PIN    PIND
#define PS2_DATA_DDR    DDRD
#define PS2_DATA_BIT    4

#define PS2_INT_INIT()  do {    \
    EICRA |= ((1<<ISC11) |      \
              (0<<ISC10));      \
} while (0)
#define PS2_INT_ON()  do {      \
    EIMSK |= (1<<PCINT5);         \
} while (0)
#define PS2_INT_OFF() do {      \
    EIMSK &= ~(1<<PCINT5);        \
} while (0)
#define PS2_INT_VECT    INT1_vect
#endif


Offline araif

  • Posts: 13
Re: TMK keyboard firmware
« Reply #569 on: Thu, 26 February 2015, 22:24:22 »
ok I resoldered and isolated few components I had flying for testing and this ps2<->keyboard "ghosting" seems disappeared, for today I declare it as gone, I'll check better tomorrow :) . If you have more pointers on how to configure the interrupt version though that will be really welcome (I feel that it should be the way to go instead of busy waiting).

Offline hasu

  • Thread Starter
  • Posts: 3144
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: TMK keyboard firmware
« Reply #570 on: Thu, 26 February 2015, 23:15:38 »
This code prints these message and which indicates pollings are occured each 11ms and no mouse movement. hmm, it takes too long for iteration?

https://github.com/tmk/tmk_keyboard/blob/master/protocol/ps2_mouse.c#L88-L92

Ignore 'd'.
Quote
5680d ps2_mouse raw: [08|00 00]
5691d ps2_mouse raw: [08|00 00]
5703d ps2_mouse raw: [08|00 00]
5714d ps2_mouse raw: [08|00 00]
5725d ps2_mouse raw: [08|00 00]
5737d ps2_mouse raw: [08|0000]
5748d ps2_mouse raw: [08|00 00]
5760d ps2_mouse raw: [08|00 00]

You are using stream mode and 'busy wait' impl? I don't think this combination works well.

You may want to know how long this part of code takes. This part can take long time in some situation.
https://github.com/tmk/tmk_keyboard/blob/master/protocol/ps2_mouse.c#L79-L83

Because ps2_host_recv_response() can block 25ms in the worst case.
https://github.com/tmk/tmk_keyboard/blob/master/protocol/ps2_busywait.c#L124



To eanble 'interrupt' impl...

AVR interrupt PCINT and INT is not same you'll have to use different initialize code. My original code is for INT and doesn't not work with PCINT.

Consult with datasheet of your MCU(ATMega32u4?). Registers EICRA and EIMSK are used only for INT, you have to find register names for PCINT in the document.
TMK products:HHKB Alt  ⌨ConvertersAlps64FC660C AltFC980C Alt

Offline araif

  • Posts: 13
Re: TMK keyboard firmware
« Reply #571 on: Fri, 27 February 2015, 08:36:20 »
are you sude PD5 is pcint5 ? on the datasheet I see (XCK1/CTS) PD5 http://www.atmel.com/images/doc7766.pdf  , is that even possible to use interrupts on that pin?

Offline hasu

  • Thread Starter
  • Posts: 3144
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: TMK keyboard firmware
« Reply #572 on: Fri, 27 February 2015, 09:02:18 »
Ah, PCINT5 is for PB5. PD5 cannot be used with pin interrupt, perhaps.
TMK products:HHKB Alt  ⌨ConvertersAlps64FC660C AltFC980C Alt

Offline araif

  • Posts: 13
Re: TMK keyboard firmware
« Reply #573 on: Fri, 27 February 2015, 09:05:19 »
then maybe I can use usart there with pd5 on clock and pd4 for data? How should I modify the implementation you have on onekey to get this working?

as you probably understood I'm no expert here.

EDIT:
also, maybe to use the interrupt version I can switch a pin used for the keyboard matrix (used for the third row now) that it's on PD1 and continue using PD4 for data from the trackpoint, would that work? So using PD1 for clock, PD4 for data , and PD5 for third row of the keyboard matrix.
« Last Edit: Fri, 27 February 2015, 09:10:34 by araif »

Offline hasu

  • Thread Starter
  • Posts: 3144
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: TMK keyboard firmware
« Reply #574 on: Fri, 27 February 2015, 09:20:47 »
You need to use PD2 for data (RXD) in case of UART .
TMK products:HHKB Alt  ⌨ConvertersAlps64FC660C AltFC980C Alt

Offline araif

  • Posts: 13
Re: TMK keyboard firmware
« Reply #575 on: Fri, 27 February 2015, 09:28:40 »
must I use pd2 also in case of interrupt version? and so given I have to switch a pin that now is used for the keyboard matrix, is that better to use the interrupt version or usart?

the two options would be:
1) int version: pd1 for clock, pd4 for data , pd5 for keyboard row
2) usart version: pd5 for clock, pd2 for data, pd4 for keyboard row

also, thanks for the answers, you are really helping me out!

Offline hasu

  • Thread Starter
  • Posts: 3144
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: TMK keyboard firmware
« Reply #576 on: Fri, 27 February 2015, 09:48:07 »
Yes. You're right. In UART PD2 as Data and PD5 as Clock have to be used.  In interrupt mode you can use any pin as Data and any INT or PCINT pin as Clock.
TMK products:HHKB Alt  ⌨ConvertersAlps64FC660C AltFC980C Alt

Offline araif

  • Posts: 13
Re: TMK keyboard firmware
« Reply #577 on: Fri, 27 February 2015, 10:06:32 »
ok, should I choose the interrupt version or usart? what is better?

thanks again.
« Last Edit: Fri, 27 February 2015, 12:42:57 by araif »

Offline araif

  • Posts: 13
Re: TMK keyboard firmware
« Reply #578 on: Fri, 27 February 2015, 12:57:42 »
.
« Last Edit: Fri, 27 February 2015, 14:31:29 by araif »

Offline hasu

  • Thread Starter
  • Posts: 3144
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: TMK keyboard firmware
« Reply #579 on: Fri, 27 February 2015, 19:08:27 »
hmm, USART version reduces intterupts in comparison to the other but no perceivable difference, I think.
I'd use Interrupt version, it is more flexible in terms of pin configuration.
TMK products:HHKB Alt  ⌨ConvertersAlps64FC660C AltFC980C Alt

Offline p3lim

  • Posts: 106
  • Location: Norway
Re: TMK keyboard firmware
« Reply #580 on: Sun, 01 March 2015, 20:48:17 »
Finished soldering my keyboard yesterday, flashed the firmware on it today (Teensy2) with gh60 (before changing the matrix), it would fire random media keys at it's own will (calculator, browser, email, mute my sound etc).
After I changed the required parts in matrix.c it doesn't do anything at all.

I tried using PJRC's hid_listen, it finds the device but it doesn't print out anything at all.

Are there any other debug steps I could take, or could any of you help me? I'm on IRC (same username).

Relevant parts:
More
My keyboard's physical matrix:
http://www.keyboard-layout-editor.com/#/layouts/830542b7fea07184e3a44d58e00292fa

matrix.c
Code: [Select]
static void init_cols(void)
{
DDRF &= ~(1<<7 | 1<<6 | 1<<5 | 1<<4 | 1<<1 | 1<<0);
PORTF |= (1<<7 | 1<<6 | 1<<5 | 1<<4 | 1<<1 | 1<<0);
DDRB &= ~(1<<6 | 1<<5 | 1<<4);
PORTB |= (1<<6 | 1<<5 | 1<<4);
DDRD &= ~(1<<7 | 1<<3 | 1<<2);
PORTD |= (1<<7 | 1<<3 | 1<<2);
DDRC &= ~(1<<7 | 1<<6);
PORTC |= (1<<7 | 1<<6);
}

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

static void unselect_rows(void)
{
DDRB &= ~0b10001111;
PORTB &= ~0b10001111;
}

static void select_row(uint8_t row)
{
switch (row) {
case 0:
DDRB  |= (1<<0);
PORTB &= ~(1<<0);
break;
case 1:
DDRB  |= (1<<1);
PORTB &= ~(1<<1);
break;
case 2:
DDRB  |= (1<<2);
PORTB &= ~(1<<2);
break;
case 3:
DDRB  |= (1<<3);
PORTB &= ~(1<<3);
break;
case 4:
DDRB  |= (1<<7);
PORTB &= ~(1<<7);
break;
}
}

keymap_common.h
Code: [Select]
#define KEYMAP( \
K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D, \
K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, \
K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, \
K30, K31, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B,      K3D, \
K40, K41, K42,                K46,           K49, K4A, K4B,      K4D \
) { \
{ KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07, KC_##K08, KC_##K09, KC_##K0A, KC_##K0B, KC_##K0C, KC_##K0D }, \
{ KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17, KC_##K18, KC_##K19, KC_##K1A, KC_##K1B, KC_##K1C, KC_##K1D }, \
{ KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_##K27, KC_##K28, KC_##K29, KC_##K2A, KC_##K2B, KC_##K2C, KC_NO    }, \
{ KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_##K35, KC_##K36, KC_##K37, KC_##K38, KC_##K39, KC_##K3A, KC_##K3B, KC_NO,    KC_##K3D }, \
{ KC_##K40, KC_##K41, KC_##K42, KC_NO,    KC_NO,    KC_NO,    KC_##K46, KC_NO,    KC_NO,    KC_##K49, KC_##K4A, KC_##K4B, KC_NO,    KC_##K4D } \
}

keymap_plain.c (I modified the Makefile to use this as default)
Code: [Select]
#include "keymap_common.h"

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

Also changed the boot section size in the Makefile to match the Teensy halfKay (512 bytes).

« Last Edit: Sun, 01 March 2015, 23:04:55 by p3lim »

Offline vicibz

  • Posts: 20
  • Location: Ibiza
Re: TMK keyboard firmware
« Reply #581 on: Mon, 02 March 2015, 05:41:54 »
Also changed the boot section size in the Makefile to match the Teensy halfKay (512 bytes).

In a quick "review" those code bits look fine to me.
I would start by leaving the boot section as it was, with the LUFA bootloader (OPT_DEFS += -DBOOTLOADER_SIZE=4096).

Offline p3lim

  • Posts: 106
  • Location: Norway
Re: TMK keyboard firmware
« Reply #582 on: Mon, 02 March 2015, 05:59:55 »
Also changed the boot section size in the Makefile to match the Teensy halfKay (512 bytes).

In a quick "review" those code bits look fine to me.
I would start by leaving the boot section as it was, with the LUFA bootloader (OPT_DEFS += -DBOOTLOADER_SIZE=4096).

Which would be the default setting for the gh60 driver, which I flashed unmodified first as a test.
As an update I've tested the teensy with different stuff PJRC provides from their website, and they all work fine. Later today I'll get my multimeter out and verify every connection for continuity, just to eliminate any faults in my soldering.

Offline hasu

  • Thread Starter
  • Posts: 3144
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: TMK keyboard firmware
« Reply #583 on: Mon, 02 March 2015, 10:21:41 »
Multimeter is the best tool and first thing to do when it comes to DIY hardware :D

You will need 'debug_enable=yes' in matrix_init() unless your matrix works well.
https://github.com/tmk/tmk_keyboard/wiki/FAQ#cant-get-message-on-console

If you are on Windows, just replug in another USB ports.
https://github.com/tmk/tmk_keyboard/wiki/FAQ-Build#edit-configuration-but-not-change

And check this. I think this is not needed if you are using Teensy, though.
https://github.com/tmk/tmk_keyboard/wiki/FAQ#using-pf4-7-pins-of-usb-avr


Finished soldering my keyboard yesterday, flashed the firmware on it today (Teensy2) with gh60 (before changing the matrix), it would fire random media keys at it's own will (calculator, browser, email, mute my sound etc).
After I changed the required parts in matrix.c it doesn't do anything at all.

I tried using PJRC's hid_listen, it finds the device but it doesn't print out anything at all.

Are there any other debug steps I could take, or could any of you help me? I'm on IRC (same username).
TMK products:HHKB Alt  ⌨ConvertersAlps64FC660C AltFC980C Alt

Offline p3lim

  • Posts: 106
  • Location: Norway
Re: TMK keyboard firmware
« Reply #584 on: Mon, 02 March 2015, 10:45:40 »
Just went over with a multimeter to test the diodes and continuity, everything works well, even tested the pins on the teensy (with a driver from PJRC and shorting the pins), all of that works well.
I'll take a look at those links you provided and come back to you.

Edit: checked the properties for the keyboard, found this:

« Last Edit: Mon, 02 March 2015, 10:53:21 by p3lim »

Offline wowmate

  • Posts: 3
Re: TMK keyboard firmware
« Reply #585 on: Wed, 04 March 2015, 02:22:43 »
Im 100% illiterate when it comes to coding and I wondering how I could have pwm control for a single pin for leds. I also looked at the led.c file of multiple builds but can't figure out why some have "DDR", "PORT", "|". or "&" there are too many variations  I don't understand.
I would like it to just be toggleable. Thanks in advance.

Offline hasu

  • Thread Starter
  • Posts: 3144
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: TMK keyboard firmware
« Reply #586 on: Wed, 04 March 2015, 03:27:55 »
p3lim,
Ive never seen that message actually(is it on windows8?) but it just smells like very Windows driver cache problem. Just try another ports, removing driver of keyboard completely or using new VIDID pair.
TMK products:HHKB Alt  ⌨ConvertersAlps64FC660C AltFC980C Alt

Offline hasu

  • Thread Starter
  • Posts: 3144
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: TMK keyboard firmware
« Reply #587 on: Wed, 04 March 2015, 03:38:15 »
Post your schematic to let us know how you connect the LEDs.
and forget PWM for a while, looks like you need to learn some things to use it.  At first learn how you can turn on a LED solid.


Im 100% illiterate when it comes to coding and I wondering how I could have pwm control for a single pin for leds. I also looked at the led.c file of multiple builds but can't figure out why some have "DDR", "PORT", "|". or "&" there are too many variations  I don't understand.
I would like it to just be toggleable. Thanks in advance.
TMK products:HHKB Alt  ⌨ConvertersAlps64FC660C AltFC980C Alt

Offline p3lim

  • Posts: 106
  • Location: Norway
Re: TMK keyboard firmware
« Reply #588 on: Wed, 04 March 2015, 05:42:09 »
p3lim,
Ive never seen that message actually(is it on windows8?) but it just smells like very Windows driver cache problem. Just try another ports, removing driver of keyboard completely or using new VIDID pair.

I found it was corrupted drivers, had to run Windows in safe-mode to delete them (uninstalling would not do it, it would just reinstall the same corrupted drivers), that sorted it for me. And yes, it was on Windows 8 (.1).

Offline tlem

  • Posts: 20
Re: TMK keyboard firmware
« Reply #589 on: Wed, 04 March 2015, 08:24:03 »
Im 100% illiterate when it comes to coding and I wondering how I could have pwm control for a single pin for leds. I also looked at the led.c file of multiple builds but can't figure out why some have "DDR", "PORT", "|". or "&" there are too many variations  I don't understand.
I would like it to just be toggleable. Thanks in advance.

If you want to learn it yourself, check out these
http://en.wikipedia.org/wiki/Bitwise_operations_in_C
https://www.youtube.com/watch?v=ZhIRRyhfhLM
You will also want to read the datasheet for your chip

Offline wowmate

  • Posts: 3
Re: TMK keyboard firmware
« Reply #590 on: Wed, 04 March 2015, 09:40:55 »
Post your schematic to let us know how you connect the LEDs.
and forget PWM for a while, looks like you need to learn some things to use it.  At first learn how you can turn on a LED solid.


Im 100% illiterate when it comes to coding and I wondering how I could have pwm control for a single pin for leds. I also looked at the led.c file of multiple builds but can't figure out why some have "DDR", "PORT", "|". or "&" there are too many variations  I don't understand.
I would like it to just be toggleable. Thanks in advance.

The reason why I want or rather need pwm is because I would like to use 50ish leds and pin number D6  on a teensy 2.0 for pwm.

I have stock files from tmk


Offline hasu

  • Thread Starter
  • Posts: 3144
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: TMK keyboard firmware
« Reply #591 on: Wed, 04 March 2015, 15:27:23 »
I don't know how you can control the 50ish LEDs with one PWM pin. You have idea or reference of design?
TMK products:HHKB Alt  ⌨ConvertersAlps64FC660C AltFC980C Alt

Offline wowmate

  • Posts: 3
Re: TMK keyboard firmware
« Reply #592 on: Wed, 04 March 2015, 17:35:00 »
I don't know how you can control the 50ish LEDs with one PWM pin. You have idea or reference of design?

just in parallel pin12  and ground or i need to split the pins thats ok too. i just want full backlighting with pwm or otherwise i wouldn't have enough current
« Last Edit: Wed, 04 March 2015, 17:51:58 by wowmate »

Offline p3lim

  • Posts: 106
  • Location: Norway
Re: TMK keyboard firmware
« Reply #593 on: Mon, 09 March 2015, 07:55:18 »
Is it possible to add a repeating action as a function?
As an example: if key A is held, send the A key every 50ms.

Offline QuiGonJinn

  • Posts: 16
Re: TMK keyboard firmware
« Reply #594 on: Mon, 09 March 2015, 08:53:50 »
Quick question ... Does TMK/Teensy support 104-key?

Technically yes, but the electrical layout is not going to match the physical row and column layout.  There just is not enough pins.  Though you should be able to use a Teensy 2.0++ version for extra pins and work just fine.  For example a full size layout will be 22 columns and 6 rows which is 28 pins plus 4 for 3 lock LEDs.  The standard Teensy does not have that many pins, but if you are creative with the electrical layout you can go 10x11 matrix for a total of 110 switches possible.

ok, I've never handwired a board before so that's slightly intimidating, but I think I understand what you mean and feel like I can probably do it with a bit of stumbling.

So when I make the keymap for TMK, I will have to write it out as it is logically- and TMK will work with the 10x11 matrix. I imagine it will be a bit painful writing it out like that without getting confused, but that's ok.

Actually I find it much easier to use some kind of decoding technique,  and control for example 16 matrix rows with 4 controller pins.
« Last Edit: Mon, 09 March 2015, 09:02:09 by QuiGonJinn »

Offline l_b

  • Posts: 26
    • vanutsteen.nl => nerds only
Re: TMK keyboard firmware
« Reply #595 on: Wed, 11 March 2015, 16:49:06 »
I added initial support for Masdrop Infinity which based on mbed(cortex-M) and is not full fucinton yet; mouse keys, media keys, NKRO and etc.
https://github.com/tmk/tmk_keyboard/tree/master/keyboard/infinity

I don't think many users are around here yet, but if you have it try this.

Do you think media keys (and nkro) will be implemented? I'd love to use the tmk firmware with the infinity. Using it on my ergodox was awesome.

Offline hasu

  • Thread Starter
  • Posts: 3144
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: TMK keyboard firmware
« Reply #596 on: Wed, 11 March 2015, 17:05:10 »
I'll implement those functions for cortex controller finally in some point of future, but I don't know when.
TMK products:HHKB Alt  ⌨ConvertersAlps64FC660C AltFC980C Alt

Offline swill

  • * Elevated Elder
  • Posts: 3365
  • Location: Canada eh
  • builder & enabler
    • swillkb.com
Re: TMK keyboard firmware
« Reply #597 on: Wed, 11 March 2015, 17:44:01 »
Is it possible to add a repeating action as a function?
As an example: if key A is held, send the A key every 50ms.

If he does add this functionality, I would recommend actually implementing it like this.

If a key is held for more than 500ms, then start repeating the key every 50ms (or whatever configurable value).

This will reduce the illusion of debounce if people don't press and release quickly.  This is how most keyboards handle that...

Offline admiralvorian

  • Posts: 324
  • Location: United States
  • DIY
Re: TMK keyboard firmware
« Reply #598 on: Wed, 11 March 2015, 18:49:41 »
I am trying to customize the keymap for kairyu's custom firmware (supports backlight) for an abostudio ghpad (red scarf I) but no matter what changes i make on the keymap, they do not appear after flashing the device.

first i clone https://github.com/kairyu/tmk_keyboard_custom

then edit /leyboard/ghpad/keymap_redscarf.c and make it look like this: http://pastebin.com/GX7qtyZs all number keys are "1" for testing

then I run
Code: [Select]

make KEYMAP=redscarf VERBOSE=1

here is the terminal output : http://pastebin.com/XShRpHQg here

then I do


Code: [Select]
sudo make dfu

which runs "sudo dfu-programmer atmega32u4 erase; sudo dfu-programmer atmega32u4 flash ghpad_lufa.hex; sudo dfu-programmer atmega32u4 reset" and all commands appear to execute successfully.

*note: I also copy any keymap file to "keymap_custom.c" edit that and compile with KEYMAP=custom; still the same result, keymap on device does not change after flashing

I know this is a modified version of your firmware, if i should talk to someone else please let me know.
« Last Edit: Wed, 11 March 2015, 19:03:07 by admiralvorian »
Darude Status:
☐ Not Sandstorm
☑ Sandstorm                                               wts wtt wtb

Offline hasu

  • Thread Starter
  • Posts: 3144
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: TMK keyboard firmware
« Reply #599 on: Wed, 11 March 2015, 19:21:00 »
I'm not much interested in developing gaming functions, but in assisting people having difficultiy with normal keyboard.
That said, OS repeating config seems to do fairly good job in both Mac and Windows.

Repeating in firmware will be a bit of a work with referencing timer. It is difficult or impossible to implement in keymap file at this time.

Is it possible to add a repeating action as a function?
As an example: if key A is held, send the A key every 50ms.

If he does add this functionality, I would recommend actually implementing it like this.

If a key is held for more than 500ms, then start repeating the key every 50ms (or whatever configurable value).

This will reduce the illusion of debounce if people don't press and release quickly.  This is how most keyboards handle that...

TMK products:HHKB Alt  ⌨ConvertersAlps64FC660C AltFC980C Alt