Author Topic: TMK keyboard firmware  (Read 819798 times)

0 Members and 2 Guests are viewing this topic.

Offline skebitz

  • Posts: 2
  • Location: Sweden
Re: TMK keyboard firmware
« Reply #400 on: Tue, 27 May 2014, 07:56:45 »
Ah, thanks! :)

Offline bitemyweewee

  • Posts: 3
  • Location: Melbourne Australia
Re: TMK keyboard firmware
« Reply #401 on: Sat, 31 May 2014, 04:42:53 »
Heya!

I've been following the guide by matt3o over at deskthority on how to use your code for teensy to build yourself a new keyboard.
What I'm actually doing is converting an old terminal keyboard to usb just by soldering onto it's IC because I believe the protocol is unknown.
Here's the original thread: http://deskthority.net/keyboards-f2/adds-1010-green-alps-teardown-t7984.html


Here's what I've configured so far:

Matrix:


config.h:
Code: [Select]
/* key matrix size */
#define MATRIX_ROWS 9
#define MATRIX_COLS 13

matrix.c
Code: [Select]
static void  init_cols(void)
{
    // Input with pull-up(DDR:0, PORT:1)
    DDRD  &= ~(1<<1 | 1<<2 | 1<<3 | 1<<4 | 1<<5 | 1<<6 | 1<<7);
    PORTD |=  (1<<1 | 1<<2 | 1<<3 | 1<<4 | 1<<5 | 1<<6 | 1<<7);
    DDRE  &= ~(1<<0 | 1<<1);
    PORTE |=  (1<<0 | 1<<1);
    DDRC  &= ~(1<<0 | 1<<1 | 1<<2 | 1<<3 | 1<<4);
    PORTC |=  (1<<0 | 1<<1 | 1<<2 | 1<<3 | 1<<4);
}

static matrix_row_t read_cols(void)
{
    return (PIND&(1<<1) ? 0 : (1<<0)) |
           (PIND&(1<<2) ? 0 : (1<<1)) |
           (PIND&(1<<3) ? 0 : (1<<2)) |
           (PIND&(1<<4) ? 0 : (1<<3)) |
           (PIND&(1<<5) ? 0 : (1<<4)) |
           (PIND&(1<<7) ? 0 : (1<<5)) |
           (PINE&(1<<0) ? 0 : (1<<6)) |
           //((PINB&(1<<0) && PINB&(1<<7)) ? 0 : (1<<8)) |     // Rev.A and B
           (PINE&(1<<1) ? 0 : (1<<7)) |
           (PINC&(1<<0) ? 0 : (1<<8)) |
           (PINC&(1<<1) ? 0 : (1<<9)) |
           (PINC&(1<<2) ? 0 : (1<<10)) |
           (PINC&(1<<3) ? 0 : (1<<11)) |
           (PINC&(1<<4) ? 0 : (1<<12));
}

/* Row pin configuration
 * row: 0   1   2   3   4
 * pin: D0  D1  D2  D3  D5
 */
static void unselect_rows(void)
{
    // Hi-Z(DDR:0, PORT:0) to unselect
    DDRB  &= ~0b11111111;
    PORTB &= ~0b11111111;
    DDRD  &= ~0b00000001;
    PORTD &= ~0b00000001;
}

static void select_row(uint8_t row)
{
    // Output low(DDR:1, PORT:0) to select
    switch (row) {
        case 0:
            DDRB  |= (1<<0);
            PORTB &= ~(1<<0);
            break;
        case 1:
            DDRB  |= (1<<1);
            PORTB &= ~(1<<1);
            break;
        case 2:
            DDRB  |= (1<<2);
            PORTB &= ~(1<<2);
            break;
        case 3:
            DDRB  |= (1<<3);
            PORTB &= ~(1<<3);
            break;
        case 4:
            DDRB  |= (1<<4);
            PORTB &= ~(1<<4);
            break;
        case 5:
            DDRB  |= (1<<5);
            PORTB &= ~(1<<5);
            break;
        case 6:
            DDRB  |= (1<<6);
            PORTB &= ~(1<<6);
            break;
        case 7:
            DDRB  |= (1<<7);
            PORTB &= ~(1<<7);
            break;
        case 8:
            DDRD  |= (1<<0);
            PORTD &= ~(1<<0);
            break;   
    }
}

led.c:
Code: [Select]
void led_set(uint8_t usb_led)
{
    if (usb_led & (1<<USB_LED_CAPS_LOCK)) {
        // output low
        DDRD |= (1<<6);
        PORTD &= ~(1<<6);
    } else {
        // Hi-Z
        DDRD &= ~(1<<6);
        PORTD &= ~(1<<6);
    }
}

keymap_common.h:
Code: [Select]
#define KEYMAP( \
    K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, \
    K10, K11, K12, K13,      K15, K16, K17, K18, K19, K1A, \
    K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, \
    K30, K31, K32,      K34, K35, K36, K37, K38, K39, K3A, \
    K40, K41, K42, K43, K44, K45, K46, K47,      K49, K4A, \
                                                           K5B, K5C, \
    K60, K61, K62, K63, K64, K65, K66, K67, K68, \
    K70, K71, K72, K73, K74, K75, K76, K77, K78, \
    K80, K81, K82, K83, K84, K85, K86, K87, K88, K89\                                                       
) { \
    { KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07, KC_##K08, KC_##K09, KC_##K0A }, \
    { KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_NO   , KC_##K15, KC_##K16, KC_##K17, KC_##K18, KC_##K19, KC_##K1A }, \
    { KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_##K27, KC_##K28, KC_##K29, KC_##K2A }, \
    { KC_##K30, KC_##K31, KC_##K32, KC_NO   , KC_##K34, KC_##K35, KC_##K36, KC_##K37, KC_##K38, KC_##K39, KC_##K3A }, \
    { KC_##K40, KC_##K41, KC_##K42, KC_##K43, KC_##K44, KC_##K45, KC_##K46, KC_##K47, KC_NO   , KC_##K49, KC_##K4A }, \
    { KC_NO   , KC_NO   , KC_NO   , KC_NO   , KC_NO   , KC_NO   , KC_NO   , KC_NO   , KC_NO   , KC_NO   , KC_NO   , KC_##5B , KC_5C }, \
    { KC_##K60, KC_##K61, KC_##K62, KC_##K63, KC_##K64, KC_##K65, KC_##K66, KC_##K67, KC_##K68 }, \
    { KC_##K70, KC_##K71, KC_##K72, KC_##K73, KC_##K74, KC_##K75, KC_##K76, KC_##K77, KC_##K78 }, \
    { KC_##K80, KC_##K81, KC_##K82, KC_##K83, KC_##K84, KC_##K85, KC_##K86, KC_##K87, KC_##K88, KC_##K89 }, \
}

I don't know what the names are for the extended keys when making a KEYMAP() in the keymap_poker.c file, as the guide's only for 60% keyboards.
I hope I've been as transparent as possible, I'm not sure what other information to include.

Thanks!

Offline hasu

  • Thread Starter
  • Posts: 3471
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: TMK keyboard firmware
« Reply #402 on: Sat, 31 May 2014, 16:01:13 »
I think you give enough code and pics, but not sure your problem exactly.

KEYMAP is just a macro or syntax sugar to define keymap array which have keycode each matrix slot.

Read README.md and doc/keymap.md yet?
https://github.com/tmk/tmk_keyboard/blob/master/README.md
https://github.com/tmk/tmk_keyboard/blob/master/doc/keymap.md

And see code of other keyboards like phantom, lightsaber or kmac, they have more keys than gh60.

Offline bitemyweewee

  • Posts: 3
  • Location: Melbourne Australia
Re: TMK keyboard firmware
« Reply #403 on: Sun, 01 June 2014, 03:09:47 »
Thanks for the links,

Here's what I've been able to come up with:
keymap_poker.c:
Code: [Select]
const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
    /* 0: qwerty */
    KEYMAP(KC_0, KC_EQL, KC_MINS, KC_GRV, KC_BSPC, KC_F1, KC_F2, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, \
           KC_O, KC_P, KC_LBRC, KC_RBRC, KC_LGUI, KC_LALT, KC_7, KC_8, KC_9, KC_PMNS, \
           KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, KC_UP, KC_DOWN, KC_P4, KC_P5, KC_P6, KC_COMM, \
           KC_COMM, KC_DOT, KC_SLSH, KC_BSLS, KC_LEFT, KC_RGHT, KC_P1, KC_P2, KC_P3, KC_PENT, KC_ENT, \
           KC_M, KC_N, KC_B, KC_V, KC_C, KC_X, KC_Z, KC_SPC, KC_P0, KC_PDOT, \
           KC_LSFT, KC_LCTL, \
           KC_J, KC_H, KC_G, KC_F, KC_D, KC_S, KC_A, KC_CAPS, KC_DEL, \
           KC_I, KC_U, KC_Y, KC_T, KC_R, KC_E, KC_W, KC_Q, KC_TAB, \
           KC_9, KC_8, KC_7, KC_6, KC_5, KC_4, KC_3, KC_2, KC_1, KC_ESC),
};

const uint16_t PROGMEM fn_actions[] = {

};

Though when I run make -f Makefile in the gh60 dir i get the error:
Code: [Select]
-------- begin --------
sh: 1: avr-gcc: not found
make: *** [gccversion] Error 127
And it creates a dir named obj_gh60_lufa instead of a hex file

Offline eviltobz

  • Posts: 95
Re: TMK keyboard firmware
« Reply #404 on: Sun, 01 June 2014, 04:28:07 »
looks to me like you need to get the avr gcc cross compiler for your platform (or if you have installed it, make sure it's in your path). i'm on a mac, so i use http://www.obdev.at/products/crosspack/index.html if you're on windows, linux, or something else exotic you'll need to find an appropriate one elsewhere

Offline bitemyweewee

  • Posts: 3
  • Location: Melbourne Australia
Re: TMK keyboard firmware
« Reply #405 on: Sun, 01 June 2014, 05:15:21 »
Thanks for that! Got the compiler, it now compiles.

but...
Code: [Select]
mkdir -p obj_gh60_lufa
Compiling C: keymap_poker.c
avr-gcc -c -mmcu=at90usb1287 -gdwarf-2 -DF_CPU=16000000UL -DINTERRUPT_CONTROL_ENDPOINT -DBOOTLOADER_SIZE=4096 -DF_USB=16000000UL -DARCH=ARCH_AVR8 -DUSB_DEVICE_ONLY -DUSE_FLASH_DESCRIPTORS -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)" -DFIXED_CONTROL_ENDPOINT_SIZE=8  -DFIXED_NUM_CONFIGURATIONS=1 -DPROTOCOL_LUFA -DBOOTMAGIC_ENABLE -DMOUSEKEY_ENABLE -DMOUSE_ENABLE -DEXTRAKEY_ENABLE -DCONSOLE_ENABLE -DCOMMAND_ENABLE -DVERSION=unknown -Os -funsigned-char -funsigned-bitfields -ffunction-sections -fno-inline-small-functions -fpack-struct -fshort-enums -fno-strict-aliasing -Wall -Wstrict-prototypes -Wa,-adhlns=obj_gh60_lufa/keymap_poker.lst -I. -I../.. -I../../protocol/lufa -I../../protocol/lufa/LUFA-120730 -I../../common -std=gnu99 -include config.h -MMD -MP -MF .dep/obj_gh60_lufa_keymap_poker.o.d  keymap_poker.c -o obj_gh60_lufa/keymap_poker.o
keymap_poker.c:1:5: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘:’ token
In file included from /usr/lib/gcc/avr/4.7.2/include/stdint.h:3:0,
                 from keymap_common.h:20,
                 from keymap_poker.c:2:
/usr/lib/gcc/avr/4.7.2/../../../avr/include/stdint.h:159:1: error: unknown type name ‘int8_t’
/usr/lib/gcc/avr/4.7.2/../../../avr/include/stdint.h:213:1: error: unknown type name ‘int8_t’
In file included from keymap_common.h:26:0,
                 from keymap_poker.c:2:
../../common/report.h:141:5: error: unknown type name ‘int8_t’
../../common/report.h:142:5: error: unknown type name ‘int8_t’
../../common/report.h:143:5: error: unknown type name ‘int8_t’
../../common/report.h:144:5: error: unknown type name ‘int8_t’
In file included from keymap_common.h:28:0,
                 from keymap_poker.c:2:
../../common/print.h:75:25: error: unknown type name ‘int8_t’
In file included from keymap_poker.c:2:0:
keymap_common.h:49:53: warning: backslash and newline separated by space [enabled by default]
keymap_poker.c:14:72: error: macro "KEYMAP" passed 84 arguments, but takes just 82
keymap_poker.c:6:5: error: ‘KEYMAP’ undeclared here (not in a function)
make: *** [obj_gh60_lufa/keymap_poker.o] Error 1

I don't know how to debug this unfortunately, I'm not a programmer. What does it mean?

Offline domoaligato

  • * Exquisite Elder
  • Posts: 1672
  • Location: USA
  • All your base are belong to us!
    • All your base are belong to us!
Re: TMK keyboard firmware
« Reply #406 on: Sun, 01 June 2014, 12:39:08 »
Please compile the base firmware without edits first to make sure the compiler is working correctly with the code.

Offline bcg

  • Posts: 112
Re: TMK keyboard firmware
« Reply #407 on: Sun, 01 June 2014, 13:10:26 »
Thanks for that! Got the compiler, it now compiles.

but...
Code: [Select]
mkdir -p obj_gh60_lufa
Compiling C: keymap_poker.c
avr-gcc -c -mmcu=at90usb1287 -gdwarf-2 -DF_CPU=16000000UL -DINTERRUPT_CONTROL_ENDPOINT -DBOOTLOADER_SIZE=4096 -DF_USB=16000000UL -DARCH=ARCH_AVR8 -DUSB_DEVICE_ONLY -DUSE_FLASH_DESCRIPTORS -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)" -DFIXED_CONTROL_ENDPOINT_SIZE=8  -DFIXED_NUM_CONFIGURATIONS=1 -DPROTOCOL_LUFA -DBOOTMAGIC_ENABLE -DMOUSEKEY_ENABLE -DMOUSE_ENABLE -DEXTRAKEY_ENABLE -DCONSOLE_ENABLE -DCOMMAND_ENABLE -DVERSION=unknown -Os -funsigned-char -funsigned-bitfields -ffunction-sections -fno-inline-small-functions -fpack-struct -fshort-enums -fno-strict-aliasing -Wall -Wstrict-prototypes -Wa,-adhlns=obj_gh60_lufa/keymap_poker.lst -I. -I../.. -I../../protocol/lufa -I../../protocol/lufa/LUFA-120730 -I../../common -std=gnu99 -include config.h -MMD -MP -MF .dep/obj_gh60_lufa_keymap_poker.o.d  keymap_poker.c -o obj_gh60_lufa/keymap_poker.o
keymap_poker.c:1:5: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘:’ token
In file included from /usr/lib/gcc/avr/4.7.2/include/stdint.h:3:0,
                 from keymap_common.h:20,
                 from keymap_poker.c:2:
/usr/lib/gcc/avr/4.7.2/../../../avr/include/stdint.h:159:1: error: unknown type name ‘int8_t’
/usr/lib/gcc/avr/4.7.2/../../../avr/include/stdint.h:213:1: error: unknown type name ‘int8_t’
In file included from keymap_common.h:26:0,
                 from keymap_poker.c:2:
../../common/report.h:141:5: error: unknown type name ‘int8_t’
../../common/report.h:142:5: error: unknown type name ‘int8_t’
../../common/report.h:143:5: error: unknown type name ‘int8_t’
../../common/report.h:144:5: error: unknown type name ‘int8_t’
In file included from keymap_common.h:28:0,
                 from keymap_poker.c:2:
../../common/print.h:75:25: error: unknown type name ‘int8_t’
In file included from keymap_poker.c:2:0:
keymap_common.h:49:53: warning: backslash and newline separated by space [enabled by default]
keymap_poker.c:14:72: error: macro "KEYMAP" passed 84 arguments, but takes just 82
keymap_poker.c:6:5: error: ‘KEYMAP’ undeclared here (not in a function)
make: *** [obj_gh60_lufa/keymap_poker.o] Error 1

I don't know how to debug this unfortunately, I'm not a programmer. What does it mean?

It means that your keymap has 2 extra keys defined in it that shouldn't be there.  You have specified 84 keys but only 82 are supported for your board.
:wq!

Offline Smasher816

  • HHKB Master
  • Posts: 538
  • Location: return STATE_MISSOURI;
Re: TMK keyboard firmware
« Reply #408 on: Sun, 01 June 2014, 15:10:47 »
I made a simple c file to test the rn-42 bluesmirf HID module. This connects to my phone and writes out messages just fine. See here http://ix.io/cKq

I am now attempting to use the TMK firware to talk to this module. My first simple test is making main.c call "serial_send('a');" in a loop. When plugging this into my uart->usb and examining the output I am getting '�' instead of the letter 'a'. I assume that this means my serial configuration is incorrect.

The RN-42 is specified as follows. However hardware flow control not needed and the device will function fine with only Vcc,GND,RX,TX connected.
Code: [Select]
• Baud rate 115,200
• 8 bits
• No Parity
• 1 stop bit
• Hardware flow control enabled

and this is my code from config.h
Code: [Select]
/* USART configuration
 *     asynchronous, 115200baud, 8-data bit, non parity, 1-stop bit, no flow control
 */
#define SERIAL_UART_BAUD       115200
#define SERIAL_UART_DATA       UDR1
#define SERIAL_UART_UBRR       ((F_CPU/(16UL*SERIAL_UART_BAUD))-1)
#define SERIAL_UART_RXD_VECT   USART1_RX_vect
#define SERIAL_UART_TXD_READY  (UCSR1A&(1<<UDRE1))
#define SERIAL_UART_INIT()     do { \
    UBRR1L = (uint8_t) SERIAL_UART_UBRR;       /* baud rate */ \
    UBRR1H = (uint8_t) (SERIAL_UART_UBRR>>8);  /* baud rate */ \
    UCSR1B = (1<<TXEN1);                /* TX: enable */ \
    UCSR1C = (0<<UPM11) | (0<<UPM10) | /* parity: none(00), even(01), odd(11) */ \
             (0<<UCSZ12) | (1<<UCSZ11) | (1<<UCSZ10); /* data-8bit(011) */ \
    sei(); \
} while(0)

I know that this UART code will work http://www.pjrc.com/teensy/uart.html, but I am not sure how to use Hasu's files.

Thanks for the help.
« Last Edit: Sun, 01 June 2014, 15:13:37 by Smasher816 »

Offline abjr

  • Posts: 171
  • Location: Connecticut
    • abjr.org
Re: TMK keyboard firmware
« Reply #409 on: Mon, 02 June 2014, 21:23:06 »
I'm missing something here .... if I have a keymap like:

KEYMAP(ESC, ..., ..., RSFT, FN0);

How can I do (like a Leopold):

1) FN0 + ESC ==  `
2) RSFT + ESC == ~

I know I could put GRV on the top level and do FN0+GRV == ESC or even leave ESC on the default layer and do

1) FN0 + ESC == `
2) FN0 + RSFT + ESC == ~

but I'd like ESC on the default layer and I'd like to avoid using 2 modifiers for one character.

Thanks.

-abjr

CM QFR | magicforce 68 (Gateron) | magicforce 68 (Outemu) | Acros 6311-K

Offline hasu

  • Thread Starter
  • Posts: 3471
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: TMK keyboard firmware
« Reply #410 on: Tue, 03 June 2014, 09:23:51 »
See converter/pc98_usb/matrix.c if you want to know how to use protocol/serial_uart.c.
It should be noted that serial_recv() is non-blocking receive while serial_receiv2() is blocking version. Ya, bad naming :D


I know that this UART code will work http://www.pjrc.com/teensy/uart.html, but I am not sure how to use Hasu's files.


Offline hasu

  • Thread Starter
  • Posts: 3471
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: TMK keyboard firmware
« Reply #411 on: Tue, 03 June 2014, 09:32:29 »
abjr, you can write your own 'Function Action' for that ESC behaviour. But documentation is very sparse and you will need to look into source codes. If you want to try start with seeing keyboard/hhkb/keymap_hasu.c which has a sample 'Function'.
https://github.com/tmk/tmk_keyboard/blob/master/doc/keymap.md#24-function-action

Offline Smasher816

  • HHKB Master
  • Posts: 538
  • Location: return STATE_MISSOURI;
Re: TMK keyboard firmware
« Reply #412 on: Tue, 03 June 2014, 09:32:46 »
I looked at that file. I see stuff like serial_send(0x96) which is all I need (no receiving). Unfortunately trying to send a simple character such as serial_send('a'); does not output correctly to the computer. When using my example code with the teensy library it works fine. I assume this means that I did not set up the UART configuration for your functions correctly. Although I am not sure what is wrong...

Offline hasu

  • Thread Starter
  • Posts: 3471
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: TMK keyboard firmware
« Reply #413 on: Tue, 03 June 2014, 09:37:53 »
hmm, I don't know why. At least your configuration seems to be correct.
If you can provide your source code repository on github or somewhere, I'll check more.

Offline Smasher816

  • HHKB Master
  • Posts: 538
  • Location: return STATE_MISSOURI;
Re: TMK keyboard firmware
« Reply #414 on: Tue, 03 June 2014, 09:41:19 »
Thanks Hasu. I'll upload it once I am home.

Offline hasu

  • Thread Starter
  • Posts: 3471
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: TMK keyboard firmware
« Reply #415 on: Fri, 20 June 2014, 09:12:02 »
CortexM/mbed port is coming.
PS/2 converter works like a charm now. Too many todo but promising.


Offline bcg

  • Posts: 112
Re: TMK keyboard firmware
« Reply #416 on: Fri, 20 June 2014, 20:19:52 »
This is going to be awesome.

BTW what is the black keyboard on left?
:wq!

Offline hasu

  • Thread Starter
  • Posts: 3471
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: TMK keyboard firmware
« Reply #417 on: Fri, 20 June 2014, 21:44:58 »
Poker X :) I use this to test my converter, it can speak PS/2.

Offline Leimi

  • Posts: 21
Re: TMK keyboard firmware
« Reply #418 on: Mon, 30 June 2014, 03:12:52 »
Hey,

I'm having trouble seeing if keyboards with Topre switchs (I actually have the Leopold FC660C in mind) would work with the PS/2 <> USB adapter?

Offline Eszett

  • Posts: 543
  • Supporting the communities Geekhack & Deskthority
Re: TMK keyboard firmware
« Reply #419 on: Sat, 05 July 2014, 02:44:30 »
(delete)
« Last Edit: Sat, 05 July 2014, 13:48:10 by Eszett »

Offline l_b

  • Posts: 26
    • vanutsteen.nl => nerds only
Re: TMK keyboard firmware
« Reply #420 on: Mon, 07 July 2014, 16:01:28 »
Thanks for the firmware!

I have something in mind but I don't know if it's possible with the current firmware:

keydown + other key = momentary layer switching
tap = toggle layer

It sounds a bit like ACTION_LAYER_TAP_TOGGLE() but without the 5 taps.

Does anyone know how I can achieve this? I can set TAPPING_TOGGLE to 1 but it feels a bit nasty. Is it made for the behaviour I want?

Offline hasu

  • Thread Starter
  • Posts: 3471
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: TMK keyboard firmware
« Reply #421 on: Mon, 07 July 2014, 21:24:01 »
hmm,
if you set TAPPING_TOGGLE to 1 you will get what you want.
Or you can write code for yourself in keymap.c.

Offline l_b

  • Posts: 26
    • vanutsteen.nl => nerds only
Re: TMK keyboard firmware
« Reply #422 on: Tue, 08 July 2014, 01:43:09 »
Thanks. I'll first try with setting TAPPING_TOGGLE to 1. I was just confused because of the default value of 5 which doesn't make sense to me. But maybe my brain is just wired differently :)

Offline wuqe

  • Posts: 105
  • Location: WA, USA
Re: TMK keyboard firmware
« Reply #423 on: Tue, 08 July 2014, 13:59:55 »
I set mine to 2 so it's a little more easily accessible but not triggered by accident. I've left it that way for six months now, and it rarely (though occasionally) turns on without my meaning to.

Offline l_b

  • Posts: 26
    • vanutsteen.nl => nerds only
Re: TMK keyboard firmware
« Reply #424 on: Sat, 12 July 2014, 18:18:49 »
Thanks for the help. I wrote a custom action_function() and it's working beautifully now. I now have this in the fn_actions[]:

Code: [Select]
ACTION_FUNCTION_TAP(CUSTOM_LAYER_TAP_TOGGLE),
Code: [Select]
        case CUSTOM_LAYER_TAP_TOGGLE:
            xprintf("\n\ntap.count: %d", record->tap.count);
            xprintf("\n\nevent.pressed: %d", record->event.pressed);

            if (record->tap.count > 0) {
                if (record->event.pressed) {
                    print("\nlayer_invert");
                    layer_invert(1);
                }
            } else {
                if (record->event.pressed) {
                    print("\nlayer_on");
                    layer_on(1);
                } else {
                    print("\nlayer_off");
                    layer_off(1);
                }
            }
            break;

What would be a good way to make the layer (1) more configurable? Can I do something like

Code: [Select]
ACTION_FUNCTION_TAP(CUSTOM_LAYER_TAP_TOGGLE, 1),
ACTION_FUNCTION_TAP(CUSTOM_LAYER_TAP_TOGGLE, 2),

Or should I put the functionality from inside the switch statement in a separate function and do something like:

Code: [Select]
        case CUSTOM_LAYER_TAP_TOGGLE_1:
            my_custom_function(1, record);
        break;
        case CUSTOM_LAYER_TAP_TOGGLE_2:
            my_custom_function(2, record);
        break;

Offline kako

  • Posts: 7
Re: TMK keyboard firmware
« Reply #425 on: Sun, 13 July 2014, 21:27:26 »
.
« Last Edit: Wed, 23 July 2014, 22:26:52 by kako »

Offline xauser

  • Posts: 97
Re: TMK keyboard firmware
« Reply #426 on: Fri, 18 July 2014, 13:33:05 »
Hello,

I'm looking for a way to control num lock state from tmk firmware. In detail I want some kind of action function to enable / disable num lock state. Something like.... "if I press 'k' switch to layer 4 and activate num lock".

Any idea?

Offline Smasher816

  • HHKB Master
  • Posts: 538
  • Location: return STATE_MISSOURI;
Re: TMK keyboard firmware
« Reply #427 on: Fri, 18 July 2014, 14:30:17 »
Hello,

I'm looking for a way to control num lock state from tmk firmware. In detail I want some kind of action function to enable / disable num lock state. Something like.... "if I press 'k' switch to layer 4 and activate num lock".

Any idea?

I believe according to the USB HID protocol the numlock state is controlled by the computer OS. The keyboard just says "Hey I want to toggle numlock" and the computer then replies with if it is enabled or not. For instance I can run a command line program that changed the numlock state (and turns on/off the led) without physically pressing that button. It is the same deal with capslock and is why pressing the capslock key on my external keyboard turns on the led on my laptop (since the OS keeps them both synced together).

Offline xauser

  • Posts: 97
Re: TMK keyboard firmware
« Reply #428 on: Fri, 18 July 2014, 14:42:09 »

I believe according to the USB HID protocol the numlock state is controlled by the computer OS. The keyboard just says "Hey I want to toggle numlock" and the computer then replies with if it is enabled or not. For instance I can run a command line program that changed the numlock state (and turns on/off the led) without physically pressing that button. It is the same deal with capslock and is why pressing the capslock key on my external keyboard turns on the led on my laptop (since the OS keeps them both synced together).

That makes sense, yet the os will trigger all this after it received NUMLOCK keycode I guess. So I want to have an fn action function to send this keycode and then do some kind of layer switching.


Offline Smasher816

  • HHKB Master
  • Posts: 538
  • Location: return STATE_MISSOURI;
Re: TMK keyboard firmware
« Reply #429 on: Fri, 18 July 2014, 14:47:11 »
The TMK firmware lets you write your own custom function for different keys. You should be able to accomplish what you want with that.

Offline xauser

  • Posts: 97
Re: TMK keyboard firmware
« Reply #430 on: Sat, 19 July 2014, 14:41:39 »
Just want to report that I got what I was looking for. I use a much better mapping for the numpad now. My lightsaber gets better and better. Thank you hasu!

Offline thp777

  • Posts: 140
Re: TMK keyboard firmware
« Reply #431 on: Fri, 25 July 2014, 21:24:55 »
Im having trouble getting my code to build. Giving errors relating to the keymap.c file and keycap_common.h file.
Not really a programmer so im not sure what im doing wrong.
Ive followed guides and triplechecked everything.
its a 6 column 5 row matrix connected to a teesnsy 2.0
Can someone check my code for me and share the Hex if you can get it to successfully compile?
heres the code built under the gh60 folder https://www.dropbox.com/sh/04ayndkwkn87yq4/AAA_IO-XEigpclsuowHF7_gza

Offline hasu

  • Thread Starter
  • Posts: 3471
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: TMK keyboard firmware
« Reply #432 on: Fri, 25 July 2014, 22:13:43 »
It would be helpful in general to also post "error output" in addtion to source.

In many case error messages is not intuitive and dificult to understand, but still very useful to fix your code. Reading them carefully is better than checking code yourself five times :D To understand error messages you will need a lot of exeprience and patience unfortunately.

With these three fixes I could compiled your source. Try this patch. Good luck with your project!

Code: [Select]
diff --git a/keymap_common.h b/keymap_common.h
index 3ad9b6a..1645eea 100644
--- a/keymap_common.h
+++ b/keymap_common.h
@@ -40,7 +40,7 @@ extern const uint16_t fn_actions[];
     K10, K11, K12, K13, K14, K15, \
     K20, K21, K22, K23, K24, K25, \
     K30, K31, K32, K33, K34, K35, \
-       K40, K41, K42, K43, K44, K45, \
+       K40, K41, K42, K43, K44, K45 \
        ) \
 { \
        { KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05}, \
diff --git a/keymap_poker.c b/keymap_poker.c
index 9c2e8ab..4a28c8e 100644
--- a/keymap_poker.c
+++ b/keymap_poker.c
@@ -7,7 +7,7 @@ const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
         LCTL,Z,   X,   C,   V,   B, \
         LALT,PAUS,CAPS, FN0, FN1, SPC),
     KEYMAP(ESC, F1, F2, F3,  F4,  F5,  \
-        TRNS,TRNS, UP, TRNS,VOLU,PGUP. \
+        TRNS,TRNS, UP, TRNS,VOLU,PGUP, \
         TRNS,LEFT,DOWN,RGHT,VOLD,PGDN, \
         TRNS,TRNS, TRNS,TRNS,MUTE,DEL, \
         TRNS,LGUI,TRNS,TRNS,TRNS,TRNS),
diff --git a/matrix.c b/matrix.c
index 50ef81e..927ef9a 100644
--- a/matrix.c
+++ b/matrix.c
@@ -154,7 +154,7 @@ static matrix_row_t read_cols(void)
            (PINF&(1<<5) ? 0 : (1<<2)) |
            (PINF&(1<<4) ? 0 : (1<<3)) |
            (PINF&(1<<1) ? 0 : (1<<4)) |
-           (PINF&(1<<0) ? 0 : (1<<5)) |
+           (PINF&(1<<0) ? 0 : (1<<5));
 
 }

Offline thp777

  • Posts: 140
Re: TMK keyboard firmware
« Reply #433 on: Fri, 25 July 2014, 23:09:32 »
Thank you so much. That worked and i realize where i messed up at. Now this is built and working after only 8 hours. 
edit: it seems the top key on each row activates the entire row. hmm not sure whats going on there guess its time to look over my code and wiring again
« Last Edit: Fri, 25 July 2014, 23:21:28 by thp777 »

Offline hasu

  • Thread Starter
  • Posts: 3471
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: TMK keyboard firmware
« Reply #434 on: Fri, 25 July 2014, 23:51:31 »
Great.
Photo of DIY keyboard always  amuse me Thanks.

Offline thp777

  • Posts: 140
Re: TMK keyboard firmware
« Reply #435 on: Fri, 25 July 2014, 23:56:40 »
Figured it out. thanks so much
« Last Edit: Sat, 26 July 2014, 00:13:33 by thp777 »

Offline Melvang

  • Exquisite Lord of Bumfluff
  • * Maker
  • Posts: 4398
  • Location: Waterloo, IA
  • Melvang's Desktop Customs
Re: TMK keyboard firmware
« Reply #436 on: Sat, 26 July 2014, 01:12:35 »
Just wondering but what programming language is the source files written in?
OG Kishsaver, Razer Orbweaver clears and reds with blue LEDs, and Razer Naga Epic.   "Great minds crawl in the same sewer"  Uncle Rich

Offline hasu

  • Thread Starter
  • Posts: 3471
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: TMK keyboard firmware
« Reply #437 on: Sat, 26 July 2014, 02:14:48 »
Most part is written in C. Also C++ is used a little.

Offline Melvang

  • Exquisite Lord of Bumfluff
  • * Maker
  • Posts: 4398
  • Location: Waterloo, IA
  • Melvang's Desktop Customs
Re: TMK keyboard firmware
« Reply #438 on: Sat, 26 July 2014, 03:08:59 »
Thanks hash.  I am currently teaching myself C but my uncle sent me an older C++ book and was wondering how relevant they would be. 

Would it be possible to write the program to get the requisite .hex file from something that was programmed in a different language such as Python?
OG Kishsaver, Razer Orbweaver clears and reds with blue LEDs, and Razer Naga Epic.   "Great minds crawl in the same sewer"  Uncle Rich

Offline hasu

  • Thread Starter
  • Posts: 3471
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: TMK keyboard firmware
« Reply #439 on: Sat, 26 July 2014, 07:08:34 »
I dont think you can use Python to get MCU binary, but you can write firmware with languages other than C, for example, BASIC at least.

I found this. You can also use Ada!
http://sourceforge.net/projects/avr-ada/

EDIT: hmm, after reading several times I'm not sure I can understand what you said now. Too complex English sentence to me :D
« Last Edit: Sat, 26 July 2014, 07:53:49 by hasu »

Offline Melvang

  • Exquisite Lord of Bumfluff
  • * Maker
  • Posts: 4398
  • Location: Waterloo, IA
  • Melvang's Desktop Customs
Re: TMK keyboard firmware
« Reply #440 on: Sat, 26 July 2014, 07:59:47 »
You understood correct hash.  A lot of people have told me that C is fairly difficult to understand for a first language to learn programming.  I was wondering if any other languages would work for the job.  It isn't that I don't want to learn it, just wondering if there was options.  Just wondering but what does MCU stand for.  I am guessing Machine Code something.
OG Kishsaver, Razer Orbweaver clears and reds with blue LEDs, and Razer Naga Epic.   "Great minds crawl in the same sewer"  Uncle Rich

Offline hasu

  • Thread Starter
  • Posts: 3471
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: TMK keyboard firmware
« Reply #441 on: Sat, 26 July 2014, 21:21:13 »
Certainly C is not the easiest lang but I'm pretty sure it is the first lang you should learn when you want to play with MCU(microcontroller unit) like AVR or Cortex. I think difficulty of learning C is that you need to know underlying hardware to some extent, while high-level lang like Python offers far better abstraction layer of underlying system and you can forget hardware. But device with MCU like keyboard is very small system comprised of few of simple peripherals and relatively comprehesible unlike huge modern computer system, such as PC.

So I'd say, C on MCU is not so hard as on PC. Good luck!

I'm never a computer language savvy, just my humble opinion.
« Last Edit: Sat, 26 July 2014, 21:25:12 by hasu »

Offline Melvang

  • Exquisite Lord of Bumfluff
  • * Maker
  • Posts: 4398
  • Location: Waterloo, IA
  • Melvang's Desktop Customs
Re: TMK keyboard firmware
« Reply #442 on: Sat, 26 July 2014, 21:29:08 »
Certainly C is not the easiest lang but I'm pretty sure it is the first lang you should learn when you want to play with MCU(microcontroller unit) like AVR or Cortex. I think difficulty of learning C is that you need to know underlying hardware to some extent, while high-level lang like Python offers far better abstraction layer of underlying system and you can forget hardware. But device with MCU like keyboard is very small system comprised of few of simple peripherals and relatively comprehesible unlike huge modern computer system PC.

So I'd say, C on MCU is not so hard as on PC. Good luck!

I'm never a computer language savvy, just my humble opinion.

Thank you for the insight hasu.  I have a physical book and a PDF version of another book that I am using for C and my uncle sent me a book that he used when learning C++.  I guess I was just wondering if there was any other options. 

In the future if I wanted to make a program with a GUI that a person could use for custom layouts and such I am guessing I will want to use something like python for the interface to output to C or C++ program and then that would compile into the .hex file.  But that won't be for quite a while.
OG Kishsaver, Razer Orbweaver clears and reds with blue LEDs, and Razer Naga Epic.   "Great minds crawl in the same sewer"  Uncle Rich

Offline sakai4eva

  • Posts: 281
Re: TMK keyboard firmware
« Reply #443 on: Sat, 23 August 2014, 15:22:57 »
OK. I'm gonna dive in to the TMK firmware because I feel that it's time to do this already.

So... assuming I only use Windows 8 for spreadsheet and gaming, what do I have to do to get started with this?

Offline abjr

  • Posts: 171
  • Location: Connecticut
    • abjr.org
Re: TMK keyboard firmware
« Reply #444 on: Sat, 23 August 2014, 16:43:46 »
OK. I'm gonna dive in to the TMK firmware because I feel that it's time to do this already.

So... assuming I only use Windows 8 for spreadsheet and gaming, what do I have to do to get started with this?

Start with this: http://deskthority.net/workshop-f7/how-to-build-your-very-own-keyboard-firmware-t7177.html
CM QFR | magicforce 68 (Gateron) | magicforce 68 (Outemu) | Acros 6311-K

Offline sakai4eva

  • Posts: 281
Re: TMK keyboard firmware
« Reply #445 on: Sun, 24 August 2014, 04:49:53 »
OK. I'm gonna dive in to the TMK firmware because I feel that it's time to do this already.

So... assuming I only use Windows 8 for spreadsheet and gaming, what do I have to do to get started with this?

Start with this: http://deskthority.net/workshop-f7/how-to-build-your-very-own-keyboard-firmware-t7177.html

Thanks. I'll be back once I hit another hiccup :P

Offline yakitysax

  • Posts: 51
Re: TMK keyboard firmware
« Reply #446 on: Thu, 28 August 2014, 20:05:01 »
Thank you so much. That worked and i realize where i messed up at. Now this is built and working after only 8 hours. 
edit: it seems the top key on each row activates the entire row. hmm not sure whats going on there guess its time to look over my code and wiring again
Show Image


I use one of the 3DConnexion products as well, can you show how you have hooked the 3d mouse in the keyboard? Do you use it in the firmware at all or what?

Offline yakitysax

  • Posts: 51
Re: TMK keyboard firmware
« Reply #447 on: Thu, 28 August 2014, 20:06:19 »
.
« Last Edit: Thu, 28 August 2014, 20:10:07 by yakitysax »

Offline yicaoyimu

  • Posts: 1133
  • Location: San Jose, CA
Re: TMK keyboard firmware
« Reply #448 on: Fri, 12 September 2014, 21:30:28 »
A question about TMK firmware. Is it possible to remap ctrl+x to alt+x? The closest thing I've found is key action, which could assign strokes of modifiers and a key to one key. But what I want is assign strokes of a modifier and a key to strokes of another modifier and a key.
KMAC2 - Matrix Lab 8XV2.0 - TGR Jane v2 CE - KBD8X MKII - Meridian - Matrix Lab Noah - Fallacy x2 - MGA Standard - Geon Frog mini - Amano - Ciel60 - Prime_Elise - Matrix Lab 6XV3.0 aka Corsa

Offline Charger

  • Posts: 168
Re: TMK keyboard firmware
« Reply #449 on: Sat, 13 September 2014, 04:30:19 »
I really wish i could figure out how to do makefiles again since although i was able to compile my first keyboard i had problems compiling on my desktop but was able to do it on my laptop as i recall however now i cant seem to get either to work

even when i try and do it to unedited files i get this

More
C:\Users\k\Desktop\tmk_keyboard-master\keyboard\gh60>make -f makefile
      0 [main] sh 7908 sync_with_child: child 5812(0x164) died before initializa
tion with status code 0xC0000142
    235 [main] sh 7908 sync_with_child: *** child state waiting for longjmp
/usr/bin/sh: fork: Resource temporarily unavailable
      0 [main] sh 12776 sync_with_child: child 2928(0x164) died before initializ
ation with status code 0xC0000142
    244 [main] sh 12776 sync_with_child: *** child state waiting for longjmp
/usr/bin/sh: fork: Resource temporarily unavailable

-------- begin --------
avr-gcc (WinAVR 20100110) 4.3.3
Copyright (C) 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

      0 [main] sh 9952 sync_with_child: child 7584(0x15C) died before initializa
tion with status code 0xC0000142
    411 [main] sh 9952 sync_with_child: *** child state waiting for longjmp
/usr/bin/sh: fork: Resource temporarily unavailable

mkdir -p obj_gh60_lufa
Compiling C: keymap_poker.c
avr-gcc -c -mmcu=atmega32u4 -gdwarf-2 -DF_CPU=16000000UL -DINTERRUPT_CONTROL_END
POINT -DBOOTLOADER_SIZE=4096 -DF_USB=16000000UL -DARCH=ARCH_AVR8 -DUSB_DEVICE_ON
LY -DUSE_FLASH_DESCRIPTORS -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB
_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)" -DFIXED_CONTROL_ENDPOINT_SIZE=8  -DFIXED_N
UM_CONFIGURATIONS=1 -DPROTOCOL_LUFA -DBOOTMAGIC_ENABLE -DMOUSEKEY_ENABLE -DMOUSE
_ENABLE -DEXTRAKEY_ENABLE -DCONSOLE_ENABLE -DCOMMAND_ENABLE -DVERSION= -Os -funs
igned-char -funsigned-bitfields -ffunction-sections -fno-inline-small-functions
-fpack-struct -fshort-enums -fno-strict-aliasing -Wall -Wstrict-prototypes -Wa,-
adhlns=obj_gh60_lufa/keymap_poker.lst -I. -I../.. -I../../protocol/lufa -I../../
protocol/lufa/LUFA-120730 -I../../common -std=gnu99 -include config.h -MMD -MP -
MF .dep/obj_gh60_lufa_keymap_poker.o.d  keymap_poker.c -o obj_gh60_lufa/keymap_p
oker.o
make: *** [obj_gh60_lufa/keymap_poker.o] Error -1073741502