Author Topic: TMK keyboard firmware  (Read 825049 times)

0 Members and 3 Guests are viewing this topic.

Offline mrbishop

  • * Maker
  • Posts: 799
  • Location: South Carolina USA
  • Evil Genius
    • Bishop Computer Design web
Re: TMK keyboard firmware
« Reply #1500 on: Wed, 15 June 2016, 12:24:07 »
Using the Bootmagic or Magic key combo to jump to bootloader will probably not work. Convenient if you don't want to leave a hole in your case to access the reset button.

Don't forget to change the bootloader size in the Makefile.

it is very much a teensy ++

this is a full key keyboard https://geekhack.org/index.php?topic=82671.0

typing on it now.
thanks again for taking a look and the knowledge about the D6 pin

it was changed to the 90USB1268 or were you talking about something else?

update just checked its set to 4096 but eveything is working currently. what are the issues that could become if this is not changed to  Teensy++ halfKay 1024

i already made a hole for it in the design. good to know tho :) :thumb:
Projects
Build to give back, 40% | Alps/Matias Removal ToolUltraHack 67% Hackdura  | ErgoDox case
                             
    

Offline Hypersphere

  • Posts: 1886
  • Location: USA
Re: TMK keyboard firmware
« Reply #1501 on: Wed, 15 June 2016, 12:35:25 »
I wanted to add a cautionary note about winavr. I learned the hard way to take care when installing this. When I installed winavr, without thinking, I accepted its offer to modify my path. It overwrote my path, leaving only the path to itself. Luckily, I was able to restore my path by using regedit -- this process becomes much more difficult if you have rebooted your machine more than once after the install. It appears that winavr was last updated in 2010.

My own preference is to use linux to do things like compiling code, using either a dedicated linux machine or a linux VM. However, for things like flashing a chip, I have found that Atmel FLIP in Windows works nicely.

Offline deductivemonkee

  • Posts: 572
  • Location: Canada BC
  • Professional Lurker
Re: TMK keyboard firmware
« Reply #1502 on: Wed, 15 June 2016, 18:13:23 »
I keep getting the error while compiling:
Code: [Select]
C:\Users\Matt\Desktop\tmk\keyboard\alps64>make flip
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
ECHO is off.
mkdir -p obj_alps64
Compiling C: keymap_plain.c
avr-gcc -c -mmcu=atmega32u2 -gdwarf-2 -DF_CPU=16000000UL -DINTERRUPT_CONTROL_ENDPOINT -DNO_LIMITED_CONTROLLER_CONNECT -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= -Os -funsigned-char -funsigned-bitfields -ffunction-sections -fdata-sections -fno-inline-small-functions -fpack-struct -fshort-enums -fno-strict-aliasing -Wall -Wstrict-prototypes -Wa,-adhlns=obj_alps64/keymap_plain.lst -IC -I/Users/Matt/Desktop/tmk/keyboard/alps64 -IC -I/Users/Matt/Desktop/tmk/tmk_core -IC -I/Users/Matt/Desktop/tmk/tmk_core/protocol/lufa -IC -I/Users/Matt/Desktop/tmk/tmk_core/protocol/lufa/LUFA-git -IC -I/Users/Matt/Desktop/tmk/tmk_core/common -std=gnu99 -include config.h -MMD -MP -MF .dep/obj_alps64_keymap_plain.o.d  keymap_plain.c -o obj_alps64/keymap_plain.o
keymap_plain.c:41:1: fatal error: opening dependency file .dep/obj_alps64_keymap_plain.o.d: No such file or directory
 };
 ^
compilation terminated.
C:/Users/Matt/Desktop/tmk/tmk_core/rules.mk:550: recipe for target 'obj_alps64/keymap_plain.o' failed
make: *** [obj_alps64/keymap_plain.o] Error 1

Any ideas?

If you are using old WinAVR use other new tool. it doesn't support ATMega32u2 of Alps64 PCB.
If you are editting  keymap_plain.c something is wrong there. Check your change again.

I was using cygwin and flip. I will check my code and report back :thumb:

Code: [Select]
#include "keymap_common.h"

const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {

    [0] = KEYMAP( \
        ESC, 1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   MINS,EQL, NO, BSPC, \
        TAB, Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,   LBRC,RBRC,BSLS, \
        CAPS,A,   S,   D,   F,   G,   H,   J,   K,   L,   SCLN,QUOT,ENT,  \
        LSFT,NO,Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, SLSH,RSFT,NO, \
        LCTL,FN0,LALT,          SPC,                     APP, RALT,FN1,RCTRL),
    [1] = KEYMAP( \
        GRV, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12, NO, DEL, \
        TRNS,TRNS,UP,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS, TRNS,TRNS, \
        TRNS,LEFT,DOWN,RIGHT,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \
        TRNS,NO,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS,TRNS,TRNS,NO, \
        TRNS,TRNS,TRNS,          TRNS,                    TRNS,TRNS,TRNS,TRNS),
    [2] = KEYMAP( \
        GRV, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12, NO, DEL, \
        TRNS,TRNS,TRNS,TRNS,INS,HOME,PGUP,TRNS,UP,TRNS,TRNS, TRNS, TRNS,TRNS, \
        TRNS,TRNS,TRNS,TRNS,DEL,END,PGDN,LEFT,DOWN,RIGHT,TRNS,TRNS,TRNS, \
        TRNS,NO,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,MUTE, VOLD,VOLU,TRNS,NO, \
        TRNS,TRNS,TRNS,          MPLY,                    TRNS,TRNS,TRNS,TRNS),
};

const uint16_t fn_actions[] PROGMEM = {
    [0]  = ACTION_LAYER_MOMENTARY(1),
    [1]  = ACTION_LAYER_MOMENTARY(2),
   
};


Am I not seeing something? It all looks correct to me...

EDIT: I tried to compile with hasu's keymap, same error. There is an error in the Makefile I am assuming.
« Last Edit: Wed, 15 June 2016, 18:32:07 by Deductivemonkee »
oh yeah I saw that crazy **** if that doesn't win I'm deleting my account

/ orthodox - 78g zealios / alps64 - mtsc / sentraq s-60x rgb - gat blues / let's split - 67g zealios / let's split - 67g zealios /

Offline hasu

  • Thread Starter
  • Posts: 3472
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: TMK keyboard firmware
« Reply #1503 on: Wed, 15 June 2016, 18:38:39 »
Deductivemonkee,
hmm, your keymap code seems to be ok.
What is you gcc actually? Can you post output of 'avr-gcc -v'?
I'm still gussing you are using old gcc which doesn't support the controller from WINAVR.

Offline deductivemonkee

  • Posts: 572
  • Location: Canada BC
  • Professional Lurker
Re: TMK keyboard firmware
« Reply #1504 on: Wed, 15 June 2016, 18:56:19 »
Deductivemonkee,
hmm, your keymap code seems to be ok.
What is you gcc actually? Can you post output of 'avr-gcc -v'?
I'm still gussing you are using old gcc which doesn't support the controller from WINAVR.

That's the only text that my terminal spat out, I was using MHV, I will try atmel studio instead.
oh yeah I saw that crazy **** if that doesn't win I'm deleting my account

/ orthodox - 78g zealios / alps64 - mtsc / sentraq s-60x rgb - gat blues / let's split - 67g zealios / let's split - 67g zealios /

Offline deductivemonkee

  • Posts: 572
  • Location: Canada BC
  • Professional Lurker
Re: TMK keyboard firmware
« Reply #1505 on: Wed, 15 June 2016, 19:17:26 »
I am using atmel avr toolchain now, and it spits out the same code. I think that there is an error in the Makefile. Also, what is keymap_editor and Makefile.keymap_editor?
oh yeah I saw that crazy **** if that doesn't win I'm deleting my account

/ orthodox - 78g zealios / alps64 - mtsc / sentraq s-60x rgb - gat blues / let's split - 67g zealios / let's split - 67g zealios /

Offline hasu

  • Thread Starter
  • Posts: 3472
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: TMK keyboard firmware
« Reply #1506 on: Wed, 15 June 2016, 20:03:51 »
hmm, I copied your keymap code into file name keymap_test.c and I could compilied  it with 'make KEYMAP=test' without any problem. I'm using avr-gcc4.9.2 and avr-libc1.8.0 on ubuntu and Atmel AVR toolchan 3.5.0 on windows10.

Running 'make clean' then 'make' is not helpful?

They are used to build firmware for keymap editor. You don't have to use them usually.

Offline deductivemonkee

  • Posts: 572
  • Location: Canada BC
  • Professional Lurker
Re: TMK keyboard firmware
« Reply #1507 on: Wed, 15 June 2016, 20:09:34 »
I am using atmel studio and I get this error with anything. I even tried to compile the base gh60 code.
This is the error when i run'make'
Code: [Select]
C:\Users\Matt\Desktop\tmk\keyboard\alps64>make
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
ECHO is off.
-------- begin --------
avr-gcc (AVR_8_bit_GNU_Toolchain_3.5.2_1680) 4.9.2
Copyright (C) 2014 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.

-f was unexpected at this time.
C:/Users/Matt/Desktop/tmk/tmk_core/rules.mk:395: recipe for target 'sizebefore' failed
make: *** [sizebefore] Error 255

C:\Users\Matt\Desktop\tmk\keyboard\alps64>
oh yeah I saw that crazy **** if that doesn't win I'm deleting my account

/ orthodox - 78g zealios / alps64 - mtsc / sentraq s-60x rgb - gat blues / let's split - 67g zealios / let's split - 67g zealios /

Offline hasu

  • Thread Starter
  • Posts: 3472
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: TMK keyboard firmware
« Reply #1508 on: Wed, 15 June 2016, 20:28:08 »
why are you using cmd.exe? I don't know if windows command prompt works for firmware build.

If you have Cygwin installed why don't you use bash? I think you have to just set path to Atmel  avr toolchain and run make.

EDIT: check this again.
https://github.com/tmk/tmk_keyboard/blob/master/tmk_core/doc/build.md#build-firmware-and-program-controller
« Last Edit: Wed, 15 June 2016, 20:32:19 by hasu »

Offline deductivemonkee

  • Posts: 572
  • Location: Canada BC
  • Professional Lurker
Re: TMK keyboard firmware
« Reply #1509 on: Wed, 15 June 2016, 20:34:30 »
why are you using cmd.exe? I don't know if windows command prompt works for firmware build.

If you have Cygwin installed why don't you use bash? I think you have to just set path to Atmel  avr toolchain and run make.

EDIT: check this again.
https://github.com/tmk/tmk_keyboard/blob/master/tmk_core/doc/build.md#build-firmware-and-program-controller

I was using atmel studio terminal, cygwin would't recognize make.
oh yeah I saw that crazy **** if that doesn't win I'm deleting my account

/ orthodox - 78g zealios / alps64 - mtsc / sentraq s-60x rgb - gat blues / let's split - 67g zealios / let's split - 67g zealios /

Offline hasu

  • Thread Starter
  • Posts: 3472
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: TMK keyboard firmware
« Reply #1510 on: Wed, 15 June 2016, 20:46:10 »
why are you using cmd.exe? I don't know if windows command prompt works for firmware build.

If you have Cygwin installed why don't you use bash? I think you have to just set path to Atmel  avr toolchain and run make.

EDIT: check this again.
https://github.com/tmk/tmk_keyboard/blob/master/tmk_core/doc/build.md#build-firmware-and-program-controller

I was using atmel studio terminal, cygwin would't recognize make.

ah, ok. I'll have to write the document more detail in step by step form when I got time.

Offline Morituri

  • Posts: 17
  • Location: Western USA
Re: TMK keyboard firmware
« Reply #1511 on: Wed, 15 June 2016, 20:46:45 »
First of all I want to thank Hasu and everybody who has helped for this fantastic keyboard controller software.  I've got a keyboard build in mind to make a keyboard that is very different in functionality than most, so I really need to completely read this and completely understand it - and then start modding....   :D

First thing; is there any reason why buffering is not the best way to solve the 6KRO BIOS vs. NKRO keyboard problem?  If the user mashes fifteen keys in the time it takes to send one packet, why doesn't the keyboard buffer the unsent ones and send the next six of them 250 µseconds later in another packet and the last three 250 µseconds later in the packet after that?  I ask because first, it seems weird and complicated for the thing to claim to be two different keyboards.  Second, I'm going to have to implement buffering anyway to extend it to do user-defined long macro playbacks.  User-defined macros can be longer than 128 characters, so they'll potentially exceed single packets in the HID protocol anyway.

Second, I'm going to want to implement something like an asian input mode in the controller.  That means the keyboard does not emits its output until the keys are released.   Gamers hate it but typists doing complicated unicode documents love it, because it allows combining modifiers and combining accents without screwing about with an altgr key.
We're going to solve strong AI.  Then it's going to solve us.

Offline hasu

  • Thread Starter
  • Posts: 3472
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: TMK keyboard firmware
« Reply #1512 on: Wed, 15 June 2016, 21:18:13 »
First thing; is there any reason why buffering is not the best way to solve the 6KRO BIOS vs. NKRO keyboard problem?  If the user mashes fifteen keys in the time it takes to send one packet, why doesn't the keyboard buffer the unsent ones and send the next six of them 250 µseconds later in another packet and the last three 250 µseconds later in the packet after that?  I ask because first, it seems weird and complicated for the thing to claim to be two different keyboards.  Second, I'm going to have to implement buffering anyway to extend it to do user-defined long macro playbacks.  User-defined macros can be longer than 128 characters, so they'll potentially exceed single packets in the HID protocol anyway.

Hi,
I'm not sure what "6KRO vs NKRO problem" and "keyboard buffer" you refered exactly are.
But I think most of keyboards have kind of buffer and send just one key event(press/release) per packet(HID keyboard report). If you send two events with a report host cannot recognize which key is first event and which is second.

Offline Morituri

  • Posts: 17
  • Location: Western USA
Re: TMK keyboard firmware
« Reply #1513 on: Wed, 15 June 2016, 22:24:50 »
Actually I've never seen a system get confused about what order the keystrokes are in; it reads the packet from lowest (serial first) to highest (serial last) address and applies the strokes in order.  ALL strokes in the packet though will use the same combination of modifier bits.

6KRO vs NKRO is about the BIOS requiring a board with a "Bootable" mode for interacting with/configuring the BIOS, where it uses only small HID packets (which have room for no more than 6 keystrokes per packet, plus eight modifier-key bits).  It is supposed to emit a signal to the keyboard that boot is over, so the keyboard can start using extended HID codes and bigger packets if it wants to - but many BIOSes don't. 

If the bootable keyboard ever emits a larger packet, or a packet with an extended HID code, before the OS loads while doing BIOS configuration, the results are very unpredictable.  Mostly they ignore the whole packet, but some of them hang and have to be powered off because you can't get out of the BIOS setup, and a few of them (mostly Gateway) can hang with corrupted BIOS information.  That can make them crash so hard you have to flash the BIOS to get them to boot up ever again. 

Once the operating system loads, it is fully prepared to accept larger HID packets.  But the computer BIOS has to have sent the message for the keyboard to ever know that. So the keyboard controller, the BIOS, and the Operating System all have to agree on this or else whenever someone hits more than six keys too fast, the whole packet gets lost.  As a result most keyboard controllers never enable bigger packets, and implement 6-key rollover regardless of what the keyboard can sense.  If the user presses more than six keys at once some keystrokes get dropped on the floor, and the NKRO that gamers want for ridiculously time-sensitive play is reduced to 6KRO.

This is a nonissue with typing, but gamers sometimes actually do press more than six keys that fast, or trigger macros that try to. 
We're going to solve strong AI.  Then it's going to solve us.

Offline Morituri

  • Posts: 17
  • Location: Western USA
Re: TMK keyboard firmware
« Reply #1514 on: Wed, 15 June 2016, 22:45:55 »
I reread the USB specification. 

Now I understand the issue better. 

The Keyboard is constantly reporting the entire list of currently depressed keys - but the BIOS (in boot mode) is not guaranteed to be able to understand reports of more than six simultaneously pressed keys.

And therefore when someone has seven different keys all pressed at once, a USB keyboard if still in boot mode may report only six of them.  Once initialized the keyboard will get a Get_Protocol message that should allow it to switch from Boot Protocol to Report Protocol.  The Report protocol may use longer reports than the Boot Protocol, but most keyboards implement only the Boot Protocol and use it as the Report Protocol as well. 

The result is that they implement 6KRO, as that will fit into the Boot Protocol, and report a "Ghosting" state if a seventh key is simultaneously pressed. This causes Gamers to scream "augh!  I want my N-Key Rollover!"  and go find a PS/2 keyboard, which reports events rather than states and therefore handles NKRO just fine.  The alternatives are to actually have a Report Protocol that's different from the Boot Protocol, or to pretend to be more than one keyboard. 

Also, you are absolutely right that according to the spec the computer has no requirement to infer any sequence of operations within a packet.  If two events (key-up or key-down) have changed the state between moments when the state is  reported, the computer has the right to assume that these events happened in either order.  As far as I know there's nothing that ever handles it in any order other than lowest-to-highest, but ... you are correct to report states that differ by only a single event if it is important to the user to preserve sequence.
« Last Edit: Thu, 16 June 2016, 01:18:33 by Morituri »
We're going to solve strong AI.  Then it's going to solve us.

Offline Kaibz

  • Posts: 48
  • Location: AFK but not too much
Re: TMK keyboard firmware
« Reply #1515 on: Thu, 16 June 2016, 05:58:23 »
Does anyone have any idea why i get to the windows recovery screen when i let my TMK keyboard plugged when booting up? Or any hint of where the issue might come from or if anyone has had the same issue before?

The keyboard + TMK firmware works great otherwise, it's just that 1 time out of 5, when plugged in while windows is booting up, it brings me to the windows recovery screen.



Sharing the knowledge

Offline tokyo

  • Posts: 17
Re: TMK keyboard firmware
« Reply #1516 on: Thu, 16 June 2016, 16:18:18 »
layer_state variable not seem to reflect currently active momentary layers, I am using 20160525 downloaded codes not latest
        [1] = ACTION_LAYER_TAP_KEY(2, KC_SPC)   //momentary layer
        [11] = ACTION_LAYER_TOGGLE(2),   //toggle layer, which works fine
  below is my code, see LSFT_DQT

Code: [Select]

#include "keymap_common.h"
#include "action_util.h"
#include "action_layer.h"


const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = {
       
       
    KEYMAP_ALL(
              F13, F14, F15, F16, F17, F18, F19, F20, F21, F22, F23, F24,

              ESC,      F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12,           PSCR,SLCK,PAUS,    VOLD,VOLU,MUTE,PWR,     HELP,
    GRV, 1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   MINS,EQL, JYEN,BSPC,     INS, HOME,PGUP,    NLCK,PSLS,PAST,PMNS,    STOP,AGIN,
    FN6, Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,   LBRC,RBRC,     BSLS,     DEL, END, PGDN,    P7,  P8,  P9,  PPLS,    MENU,UNDO,
    FN5,A,   S,   D,   F,   G,   H,   J,   K,   L,   SCLN,QUOT,     NUHS,ENT,                         P4,  P5,  P6,  PCMM,    SLCT,COPY,
    FN7,NUBS,Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, SLSH,     RO,  FN8,          UP,           P1,  P2,  P3,  PEQL,    EXEC,PSTE,
    LCTL,LGUI,LALT,FN2,HANJ,     FN1,      HAEN,FN0, FN3,RALT,RGUI,APP, RCTL,     LEFT,DOWN,RGHT,    P0,       PDOT,PENT,    FIND, CUT
    ),

   
   
    [1] = \
    KEYMAP_ALL(
              F13, F14, F15, F16, F17, F18, F19, F20, F21, F22, F23, F24,
    ESC,      F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12,           PSCR,SLCK,PAUS,    VOLD,VOLU,MUTE,PWR,     HELP,
    GRV, 1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   MINS,EQL, FN0,BSPC,     INS, HOME,PGUP,    NLCK,PSLS,PAST,PMNS,    STOP,AGIN,
    TRNS, TRNS,   FN15,   E,   FN19,   T,   Y,   U,   I,   O,   P,   LBRC,RBRC,     BSLS,     DEL, END, PGDN,    P7,  P8,  P9,  PPLS,    MENU,UNDO,
    CAPS,FN18,   FN17,   D,   F,   G,   H,   J,   K,   L,   SCLN,QUOT,     NUHS,ENT,                         P4,  P5,  P6,  PCMM,    SLCT,COPY,
    TRNS,TRNS,FN10,   TRNS,   FN16,   V,   B,   N,   M,   COMM,DOT, SLSH,     RO,  FN8,          UP,           P1,  P2,  P3,  PEQL,    EXEC,PSTE,
    TRNS,TRNS,TRNS,MHEN,TRNS,     FN11,      TRNS,TRNS, FN3,RALT,RGUI,APP, RCTL,     LEFT,DOWN,RGHT,    P0,       PDOT,PENT,    FIND, CUT
            ),

   

   
   
   
   
   
   
   
   

   
   
   
    [2] = \
    KEYMAP(
    TRNS, TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS, TRNS, TRNS,           PSCR,SLCK,BRK,
    TRNS, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12, TRNS,      INS, HOME,PGUP,    NLCK,PSLS,PAST,PMNS,
    TRNS, ESC,FN15,PGUP,  FN4,F12, JYEN,PGUP,TRNS,HOME, TRNS,  TRNS,  TRNS,  TRNS,     DEL, END, PGDN,    P7,  P8,  P9,
    TRNS,TRNS,  LEFT,PGDN,RGHT,TRNS,  LEFT,DOWN,UP,  RGHT,KP_PLUS,  TRNS,       TRNS,                         P4,  P5,  P6,  PPLS,
    FN7,FN10,  DEL,  EQL,  TRNS,  BSPC,  END,FN9,FN13,FN14, TRNS,          TRNS,          UP,           P1,  P2,  P3,
    FN20,TRNS,TRNS,          TRNS,                     TRNS,TRNS,TRNS, TRNS,     LEFT,DOWN,RGHT,    P0,       PDOT,PENT
            ),
   
   

    [3] =                                       \
    KEYMAP(
    TRNS, TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS, TRNS, TRNS,           PSCR,SLCK,BRK,
    TRNS, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12, TRNS,      INS, HOME,PGUP,    NLCK,PSLS,PAST,PMNS,
    TRNS, TRNS,TRNS,TRNS,  TRNS,TRNS, TRNS,TRNS,F4,TRNS, TRNS,  TRNS,  TRNS,  TRNS,     DEL, END, PGDN,    P7,  P8,  P9,
    TRNS,TRNS,  FN12,DOWN,TAB,TRNS,  FN12,DOWN,UP,  TAB,TRNS,  TRNS,       TRNS,                         P4,  P5,  P6,  PPLS,
    TRNS,TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,TRNS,TRNS,TRNS, TRNS,          TRNS,          UP,           P1,  P2,  P3,
    TRNS,TRNS,TRNS,          TRNS,                     TRNS,TRNS,TRNS, TRNS,     FN12,DOWN,TAB,    P0,       PDOT,PENT
            ),
   
   
    [4] = \
    KEYMAP(
    TRNS, TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS, TRNS, TRNS,           PSCR,SLCK,BRK,
    TRNS, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12, TRNS,      INS, HOME,PGUP,    NLCK,PSLS,PAST,PMNS,
    TRNS, TRNS,TRNS,TRNS,  TRNS,TRNS, TRNS,TRNS,TRNS,TRNS, TRNS,  TRNS,  TRNS,  TRNS,     DEL, END, PGDN,    P7,  P8,  P9,
    TRNS,TRNS,  LEFT,DOWN,RGHT,TRNS,  LEFT,DOWN,UP,  RIGHT,TRNS,  TRNS,       TRNS,                         P4,  P5,  P6,  PPLS,
    TRNS,TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,TRNS,TRNS,TRNS, TRNS,          TRNS,          UP,           P1,  P2,  P3,
    TRNS,TRNS,TRNS,          TRNS,                     TRNS,TRNS,TRNS, TRNS,     LEFT,DOWN,RGHT,    P0,       PDOT,PENT
            ),
   
   
    [5] = \
    KEYMAP(
    TRNS, TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS, TRNS, TRNS,           PSCR,SLCK,BRK,
    TRNS, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12, TRNS,      INS, HOME,PGUP,    NLCK,PSLS,PAST,PMNS,
    NO, FN9,  NO,  NO,  TRNS,  NO,  WH_L,WH_D,MS_U,WH_U,WH_R,WBAK,WFWD,NO,      DEL, END, PGDN,    P7,  P8,  P9,
    LCTL,ACL0,ACL1,ACL2,ACL2,NO,  MS_L,MS_D,MS_U,MS_R,TRNS,NO,       ENT,                         P4,  P5,  P6,  PPLS,
    LSFT,FN10,  NO,  NO,  NO,  BTN3,BTN2,FN10,BTN4,BTN5,NO,            RSFT,          UP,           P1,  P2,  P3,
    LCTL,LGUI,LALT,          BTN1,                    RALT,TRNS,TRNS,RCTL,     LEFT,DOWN,RGHT,    P0,       PDOT,PENT
            ),
   






    [6] =                                       \
    KEYMAP(
    TRNS, TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS, TRNS, TRNS,           PSCR,SLCK,BRK,
    TRNS, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12, TRNS,      INS, HOME,PGUP,    NLCK,PSLS,PAST,PMNS,
    TRNS, ESC,TRNS,PGUP,  FN4,F12, JYEN,PGUP,TRNS,HOME, TRNS,  TRNS,  TRNS,  TRNS,     DEL, END, PGDN,    P7,  P8,  P9,
    TRNS,TRNS,  LEFT,PGDN,RGHT,TRNS,  LEFT,DOWN,UP,  RGHT,KP_PLUS,  TRNS,       TRNS,                         P4,  P5,  P6,  PPLS,
    TRNS,FN10,  DEL,  EQL,  TRNS,  BSPC,  END,FN9,FN13,FN14, TRNS,          TRNS,          UP,           P1,  P2,  P3,
    TRNS,TRNS,TRNS,          TRNS,                     TRNS,TRNS,TRNS, TRNS,     LEFT,DOWN,RGHT,    P0,       PDOT,PENT
            )
};



enum function_id {
        LALT_TAB,
        LSFT_DQT,
        TGGL_MOD,


};


const uint16_t fn_actions[] PROGMEM = {

        [0] = ACTION_MODS_TAP_KEY(MOD_RSFT, KC_ENT),
       
        [1] = ACTION_LAYER_TAP_KEY(2, KC_SPC)   ,
        [2] = ACTION_MODS_TAP_KEY(MOD_LALT, KC_RO),
        [3] = ACTION_LAYER_TAP_KEY(1, KC_BSPC)   ,

        [4] = ACTION_LAYER_TOGGLE(6),
       
        [5] = ACTION_MODS_TAP_KEY(MOD_LCTL, KC_RBRC),
        [6] = ACTION_FUNCTION_TAP(LALT_TAB),
        [7] = ACTION_FUNCTION_TAP(LSFT_DQT),
       
       
        [8] = ACTION_MODS_TAP_TOGGLE(MOD_RSFT),

        [9] = ACTION_LAYER_TOGGLE(5),

        [10] = ACTION_LAYER_SET_CLEAR(0),
        [11] = ACTION_LAYER_TOGGLE(2),
        [12] = ACTION_MODS_KEY(MOD_RSFT, KC_TAB),
        [13] = ACTION_MODS_KEY(MOD_RSFT | MOD_RCTL, KC_TAB),
        [14] = ACTION_MODS_KEY(MOD_RCTL, KC_TAB),
       


        [15] = ACTION_FUNCTION_OPT(TGGL_MOD, MOD_LGUI),
        [16] = ACTION_FUNCTION_OPT(TGGL_MOD, MOD_LCTL),
        [17] = ACTION_FUNCTION_OPT(TGGL_MOD, MOD_LSFT),
        [18] = ACTION_FUNCTION_OPT(TGGL_MOD, MOD_LALT),
        [19] = ACTION_LAYER_TAP_KEY(5, KC_R),

        [20] = ACTION_MODS_KEY(MOD_LALT, KC_PSCR)
};




void action_function(keyrecord_t *record, uint8_t id, uint8_t opt)
{
       
       
       
       

    switch (id) {
        case LALT_TAB:
            if (record->event.pressed) {
                if (record->tap.count > 0 && !record->tap.interrupted) {
                        if (record->tap.interrupted) {

                                layer_on(3);
                        register_mods(MOD_BIT(KC_LALT));

                        register_code(KC_TAB);
                        unregister_code(KC_TAB);
                    }
                } else {
                    layer_on(3);
                    register_mods(MOD_BIT(KC_LALT));

                    register_code(KC_TAB);
                        unregister_code(KC_TAB);
                }
            } else {
                if (record->tap.count > 0 && !(record->tap.interrupted)) {
                       
                       
                    register_code(KC_TAB);
                    unregister_code(KC_TAB);
                   
                   
                    record->tap.count = 0;
                } else {
                    unregister_mods(MOD_BIT(KC_LALT));
                    layer_off(3);
                }
            }
            break;
    case TGGL_MOD:


            if (record->event.pressed) {
                    if (opt & get_mods()) {
                            unregister_mods(opt);
                    } else {
                            register_mods(opt);
                    }
            }
            break;

    case LSFT_DQT:
            if (record->event.pressed) {
                if (record->tap.count > 0 && !record->tap.interrupted) {
                        if (record->tap.interrupted) {

                                register_mods(MOD_BIT(KC_LSHIFT));
                    }
                } else {
                        register_mods(MOD_BIT(KC_LSHIFT));
                }
            } else {
                if (record->tap.count > 0 && !(record->tap.interrupted)) {


                        add_weak_mods(MOD_BIT(KC_LSHIFT));



                        if(2 & layer_state)
                        {
                        register_code(KC_2);
                        unregister_code(KC_2);
                    }
                    else
                    {
                        register_code(KC_7);
                        unregister_code(KC_7);
                    }
                    del_weak_mods(MOD_BIT(KC_LSHIFT));

                    record->tap.count = 0;
                } else {
                    unregister_mods(MOD_BIT(KC_LSHIFT));
                }
            }
            break;           
           
           
           
           
           
           
           
           
           
           
           
           
           
           
           
           
           
           
           
           
           
           
           
           
           
           
           
           
           
           
    }
}

Offline greenwhite

  • Posts: 15
Re: TMK keyboard firmware
« Reply #1517 on: Sat, 18 June 2016, 16:40:26 »
I'm having an issue trying to get my keyboard up and running.  I'm designing a custom one-handed keyboard.  Here is the layout:  http://www.keyboard-layout-editor.com/#/gists/26d2adaa022322bf6e7a71a1d37396e4

[ Attachment Invalid Or Does Not Exist ]

I started with the gh60 code as base.  I changed to row count to 6 and column count to 12 in the config.h file.

I changed the following in matrix.c:

Code: [Select]
/* Column pin configuration
 * col: 0   1   2   3   4   5   6   7   8   9   10  11
 * pin: F1  F0  B6  F4  F5  F6  F7  B5  B4  C5  D5  D2
  */
static void  init_cols(void)
{
    // Input with pull-up(DDR:0, PORT:1)
    DDRF  &= ~(1<<7 | 1<<6 1<<5 | 1<<4 | 1<<1 | 1<<0);
    PORTF |=  (1<<7 | 1<<6 1<<5 | 1<<4 | 1<<1 | 1<<0);
    DDRD  &= ~(1<<5 | 1<<2);
    PORTD |=  (1<<5 | 1<<2);
    DDRC  &= ~(1<<5);
    PORTC |=  (1<<5);
    DDRB  &= ~(1<<6 | 1<< 5 | 1<<4);
    PORTB |=  (1<<6 | 1<< 5 | 1<<4);
}

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

/* Row pin configuration
 * row: 0   1   2   3   4   5
 * pin: D1  D0  B7  B3  B1  B0
 */
static void unselect_rows(void)
{
    // Hi-Z(DDR:0, PORT:0) to unselect
    DDRD  &= ~0b00000011;
    PORTD &= ~0b00000011;
DDRB  &= ~0b10001011;
    PORTB &= ~0b10001011;
}

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

I changed keymap_common.c:
Code: [Select]
#ifndef KEYMAP_COMMON_H
#define KEYMAP_COMMON_H

#include <stdint.h>
#include <stdbool.h>
#include <avr/pgmspace.h>
#include "keycode.h"
#include "action.h"
#include "action_macro.h"
#include "report.h"
#include "host.h"
#include "print.h"
#include "debug.h"
#include "keymap.h"


extern const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS];
extern const uint16_t fn_actions[];


/* */
#define KEYMAP( \
    K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, \
    K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, \
    K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, \
    K30, K31,      K33, K34, K35, K36, K37, K38,      K3A,      \
    K40, K41, K42, K43, K44, K45, K46, K47, K48, K49, K4A, K4B, \
K50,           K53, K54, K55, K56, K57, K58, K59, K5A, K5B \
) { \
    { 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_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17, KC_##K18, KC_##K19, KC_##K1A, KC_##K1B, \
    { 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_##K30, KC_##K31, KC_NO,    KC_##K33, KC_##K34, KC_##K35, KC_##K36, KC_##K37, KC_##K38, KC_NO,    KC_##K3A, KC_NO, \
    { KC_##K40, KC_##K41, KC_##K42, KC_##K43, KC_##K44, KC_##K45, KC_##K46, KC_##K47, KC_##K48, KC_##K49, KC_##K4A, KC_##K4B, \
{ KC_##K50, KC_NO,    KC_NO,    KC_##K53, KC_##K54, KC_##K55, KC_##K56, KC_##K57, KC_##K58, KC_##K59, KC_##K5A, KC_##K5B, \
}


#endif

And keymap_poker.c:
Code: [Select]
#include "keymap_common.h"

const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
    /* 0: qwerty */
    KEYMAP(
         F1,   F2,   F3,   F4,   F5,   F6,   F7,   F8,   F9,  F10,  F11,  F12, \
        ESC, PSCR, PAUS,    G,    F,    B,    V,    K,    J,  INS, HOME, PGUP, \
       CAPS, SLCK, BSPC,    D,    T,    H,    R,    N,    W,  DEL,  END, PGDN, \
       LGUI,  TAB,          A,    E,    I,    O,    U,    Y,         UP,       \
       LALT,  ENT,  SPC,    L,    S,    C,    M,    P,    Y, LEFT, DOWN, RGHT, \
   LCTL,     ,     , COMM,  DOT,    X,    Q,    Z, RSFT, RGUI, RALT, RCTL ),
   

};
const uint16_t PROGMEM fn_actions[] = {
    /* Poker Layout */
 /*   [0] = ACTION_LAYER_MOMENTARY(6),  // to Fn overlay
    [1] = ACTION_LAYER_TOGGLE(4),     // toggle arrow overlay
    [2] = ACTION_LAYER_TOGGLE(5),     // toggle Esc overlay
    [3] = ACTION_MODS_KEY(MOD_RCTL|MOD_RSFT, KC_ESC), // Task(RControl,RShift+Esc)
    [4] = ACTION_LAYER_MOMENTARY(7),  // to Layout selector
    [5] = ACTION_DEFAULT_LAYER_SET(0),  // set qwerty layout
    [6] = ACTION_DEFAULT_LAYER_SET(1),  // set colemak layout
    [7] = ACTION_DEFAULT_LAYER_SET(2),  // set dvorak layout
    [8] = ACTION_DEFAULT_LAYER_SET(3),  // set workman layout
*/
};

I know commenting out the function won't access my function layers, but I was just trying to get my base layer of letters to work before trying to figure out the function layer (which I"m sure I will have more questions about.)

When I try typing on the keyboard, I get strange  results.  Only a small subset of keys work and they keys that do work result in the wrong character.  For example when I push what should be F4, I get P.  Pushing F5 gives O.  F10 is T, F11 is tab, and insert is 5. 

I'm not sure if anyone can help, but I thought I would ask.

Offline a-c

  • Posts: 196
  • Location: USA
Re: TMK keyboard firmware
« Reply #1518 on: Sat, 18 June 2016, 16:57:24 »
I'm having an issue trying to get my keyboard up and running.  I'm designing a custom one-handed

Missing pipe:
Code: [Select]
    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);

Also B7 is used in led.c comment it out or it will conflict with your rows.
« Last Edit: Sat, 18 June 2016, 16:59:15 by a-c »

Offline greenwhite

  • Posts: 15
Re: TMK keyboard firmware
« Reply #1519 on: Sat, 18 June 2016, 17:42:21 »
Thanks.  I fixed that, but now I get a bunch of warnings and an error when compiling.  I get the following warnings:
-keymap_poker.c:5: warning: braces around scalar initializer
-keymap_poker.c:5: warning: (near initialization for 'keymaps[0][0][12]')
-keymap_poker.c:5: warning: excess elements in scaler initializer

The bottom two are repeated a bunch of times, and then once for line 14 and three times for line 27.

An error pops up after the line 14 errors:
-keymap_poker.c:14: error: expected'}' before';' token.


Edit:  I got it to work. I was missing the '}' in the keycap_common.  I compiled.  Still having the same issues that I started with, but most keys are now working properly, so thats a start. 
« Last Edit: Sat, 18 June 2016, 18:05:04 by greenwhite »

Offline Hypersphere

  • Posts: 1886
  • Location: USA
Re: TMK keyboard firmware
« Reply #1520 on: Sat, 18 June 2016, 18:44:36 »
Thanks, hasu, for creating the firmware and for your keyboard and converter projects. I have an Alps64 keyboard that I have successfully programmed with a HHKB layout. I have also been using the USB-USB converter, and it works beautifully with the online configurator GUI for generating hex files. I have then used Atmel FLIP for Windows to flash the hex files to the USB-USB converter for a HHKB layout.

Thus far, I have tested the following keyboards and found them to work with the USB-USB converter:

+ CM Novatouch
+ CM QFS TKL
+ IBM Model M SSK (with Orihalcon SDL to USB cable)
+ KBP V60MTS-C
+ KBP V60MTS-Q
+ Pok3r
+ Topre Realforce 87UB45
+ Topre Realforce 87UB55
+ WASD Keyboards V2 TKL

In addition, the USB-USB converter works when connected to a powered USB hub that is in turn connected to a KVM switch (Iogear DVI 4-port). I connect keyboards to the USB-USB converter through a non-powered switchable USB hub (Sabrent).

I remap CapsLock as L_Ctrl and (on TKL boards) Scroll Lock on the navigation island as Num Lock. For CapsLock, I use Fn+Tab. The lock indicator LEDs work with the USB-USB converter.

Finally, the USB-USB converter works with Synergy software (virtual KM switch), using a Windows 10 server and Linux clients (Linux Mint 17.3 64-bit Xfce).

Here is my setup:

C1, C2, C3 --- KVM + Synergy --- pUSBhub --- USB-USB-Converter --- npsUSBhub --- K1, K2, K3

C1, etc. = computer 1, etc.
pUSBhub = powered USB hub
KVM = Iogear DVI 4-port switch
Synergy = software KM
npsUSBhub = non-powered switched USB hub
K1, etc. = Keyboard 1, etc.

The setup has 1 Windows and 2 Linux computers mutually sharing 3 monitors and a keyboard and mouse. The mouse is connected to the powered USB hub. Keyboards that are not using the USB-USB converter can also be connected to the powered USB hub. Keyboards that are using the USB-USB converter are connected to it via the unpowered switched USB hub.

The USB-USB converter is connected to the USB hubs using highly flexible short USB cables to provide strain relief:(https://www.amazon.com/gp/product/B00MXCTDTC/ref=oh_aui_detailpage_o05_s00?ie=UTF8&psc=1)

The USB-USB converter has proved to be a highly versatile and extremely useful tool!



« Last Edit: Sun, 19 June 2016, 13:32:09 by Hypersphere »

Offline gelmoak

  • Posts: 5
Re: TMK keyboard firmware
« Reply #1521 on: Sat, 25 June 2016, 17:26:19 »
Hi I made a thread about a problem I have with the TMK firmware and I was told to post here. The link to the thread is: https://geekhack.org/index.php?topic=83033.0. Would greatly appreciate any help as I would like to get the keyboard working.

Offline mrbishop

  • * Maker
  • Posts: 799
  • Location: South Carolina USA
  • Evil Genius
    • Bishop Computer Design web
Re: TMK keyboard firmware
« Reply #1522 on: Sun, 26 June 2016, 16:08:14 »
can anyone help me with adding a NeoPixel 8 Led strip to my keyboard and having it controlled by TMK? or resources?
Projects
Build to give back, 40% | Alps/Matias Removal ToolUltraHack 67% Hackdura  | ErgoDox case
                             
    

Offline sithlord

  • Posts: 48
Re: TMK keyboard firmware
« Reply #1523 on: Wed, 29 June 2016, 00:37:45 »
Hi Haku,

Thanks for building TMK and sharing your work with everyone.

I've used it to customize my Planck and MiniVan boards which use TMK.

I have run into a problem with getting macros working in TMK for the MiniVan board.

I'm not sure I am doing it right. I can get the layout flashed correctly, but when I try to add a macro, it fails.

Do you or someone else have some examples of using a macro so I can test this?

Thank you for your help.

Edit:

Never mind, I figured it out.
« Last Edit: Wed, 29 June 2016, 23:05:45 by sithlord »

Offline Criterus

  • Posts: 38
Re: TMK keyboard firmware
« Reply #1524 on: Wed, 29 June 2016, 16:36:08 »
I'm trying to get a set of modified drivers to compile and I've got something going on I can't quite figure out. I keep getting the following errors when I try to compile.




Here is my matrix.c  kepmap_comm.h and keymap.c 

My matrix is 16x4

Code: [Select]
/*
Copyright 2012 Jun Wako <wakojun@gmail.com>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

/*
 * scan matrix
 */
#include <stdint.h>
#include <stdbool.h>
#include <avr/io.h>
#include <util/delay.h>
#include "print.h"
#include "debug.h"
#include "util.h"
#include "matrix.h"


#ifndef DEBOUNCE
#   define DEBOUNCE 5
#endif
static uint8_t debouncing = DEBOUNCE;

/* matrix state(1:on, 0:off) */
static matrix_row_t matrix[MATRIX_ROWS];
static matrix_row_t matrix_debouncing[MATRIX_ROWS];

static matrix_row_t read_cols(void);
static void init_cols(void);
static void unselect_rows(void);
static void select_row(uint8_t row);


inline
uint8_t matrix_rows(void)
{
    return MATRIX_ROWS;
}

inline
uint8_t matrix_cols(void)
{
    return MATRIX_COLS;
}

void matrix_init(void)
{
    // initialize row and col
    unselect_rows();
    init_cols();

    // initialize matrix state: all keys off
    for (uint8_t i=0; i < MATRIX_ROWS; i++) {
        matrix[i] = 0;
        matrix_debouncing[i] = 0;
    }
}

uint8_t matrix_scan(void)
{
    for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
        select_row(i);
        _delay_us(30);  // without this wait read unstable value.
        matrix_row_t cols = read_cols();
        if (matrix_debouncing[i] != cols) {
            matrix_debouncing[i] = cols;
            if (debouncing) {
                debug("bounce!: "); debug_hex(debouncing); debug("\n");
            }
            debouncing = DEBOUNCE;
        }
        unselect_rows();
    }

    if (debouncing) {
        if (--debouncing) {
            _delay_ms(1);
        } else {
            for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
                matrix[i] = matrix_debouncing[i];
            }
        }
    }

    return 1;
}

bool matrix_is_modified(void)
{
    if (debouncing) return false;
    return true;
}

inline
bool matrix_is_on(uint8_t row, uint8_t col)
{
    return (matrix[row] & ((matrix_row_t)1<<col));
}

inline
matrix_row_t matrix_get_row(uint8_t row)
{
    return matrix[row];
}

void matrix_print(void)
{
    print("\nr/c 0123456789ABCDEF\n");
    for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
        phex(row); print(": ");
        pbin_reverse16(matrix_get_row(row));
        print("\n");
    }
}

uint8_t matrix_key_count(void)
{
    uint8_t count = 0;
    for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
        count += bitpop16(matrix[i]);
    }
    return count;
}

/* Column pin configuration
 * col: 0   1   2   3   4   5   6   7   8   9   10  11  12  13  14  15 
 * pin: B0  B1  B2  B3  B7  D1  D2  D3  C6  C7  D6  D7  B4  B5  B6  F7  (Rev.A)
 * pin: //  //  //  //  //  //  //  //  //  //  // //   //  //  //  //                                 
 */
static void  init_cols(void)
{
    // Input with pull-up(DDR:0, PORT:1)
    DDRF  &= ~(1<<7);
    PORTF |=  (1<<7);
   
//DDRE  &= ~(1<<6);
    //PORTE |=  (1<<6);
   
DDRD  &= ~(1<<7 |1<<6|1<<3 |1<<2 | 1<<1);
    PORTD |=  (1<<7 |1<<6|1<<3 |1<<2 | 1<<1);
   
DDRC  &= ~(1<<7 | 1<<6);
    PORTC |=  (1<<7 | 1<<6);
   
DDRB  &= ~(1<<7 | 1<<6 | 1<<5 | 1<< 4 | 1<<3 | 1<<2 | 1<<1 | 1<<0);
    PORTB |=  (1<<7 | 1<<6 | 1<<5 | 1<< 4 | 1<<3 | 1<<2 | 1<<1 | 1<<0);
}

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

/* Row pin configuration
 * row: 0   1   2   3 
 * pin: F6  F5  F4  F1 
 */
static void unselect_rows(void)
{
    // Hi-Z(DDR:0, PORT:0) to unselect
    DDRF  &= ~0b01110010;
    PORTF &= ~0b01110010;
}

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

Code: [Select]
/*
Copyright 2012,2013 Jun Wako <wakojun@gmail.com>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef KEYMAP_COMMON_H
#define KEYMAP_COMMON_H

#include <stdint.h>
#include <stdbool.h>
#include <avr/pgmspace.h>
#include "keycode.h"
#include "action.h"
#include "action_macro.h"
#include "report.h"
#include "host.h"
#include "print.h"
#include "debug.h"
#include "keymap.h"


extern const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS];
extern const uint16_t fn_actions[];


/* GH60 keymap definition macro
 * K2C, K31 and  K3C are extra keys for ISO
 */
#define KEYMAP( \
    K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D, K0E, K0F, \
    K10, K11, K12, K13, K14, K15, K16, K17, K18, K19,      K1B, K1C, K1D, K1E, K1F, \
    K20,      K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, K2D, K2E, K2F, \
    K30, K31,                     K36,           K39, k3A, K3B,      K3D, K3E       \
) {\
    { 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_##K0E, KC_##K0F, }, \
    { KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17, KC_##K18, KC_##K19, KC_NO,    KC_##K1B, KC_##K1C, KC_##K1D  KC_##K1E, KC_##K1F, }, \
    { KC_##K20, KC_NO,    KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_##K27, KC_##K28, KC_##K29, KC_##K2A, KC_##K2B, KC_##K2C, KC_##K2D  KC_##K2E, KC_##K2F, }, \
    { KC_##K30, KC_##K31, KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_##K36, KC_NO,    KC_NO,    KC_##K39, KC_##K3A, KC_##K3B, KC_NO,    KC_##K3D  KC_##K3E, KC_NO     }, \ }

#endif


Code: [Select]
#include "keymap_common.h"

const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {

KEYMAP( ESC,  Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,   BSPC, 7, 8, 9, MINS, \
TAB,  A,   S,   D,   F,   G,   H,   J,   K,   L,        ENT,  4, 5, 6, PLUS, \
LSFT, Z,   X,   C,   V,   B,   N,   M,      QUOT, LBRC, DOT,  1, 2, 3, ENT,  \
LCTL, LALT,              SPC,               FN0, RBRC, COMM,  0, DOT),
};

const uint16_t PROGMEM fn_actions[] = {};


Is there anything obvious I am missing.
« Last Edit: Wed, 29 June 2016, 16:40:43 by Criterus »

Offline hasu

  • Thread Starter
  • Posts: 3472
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: TMK keyboard firmware
« Reply #1525 on: Thu, 30 June 2016, 00:21:35 »
Criterus,
you missed commas in KEYMAP macro definition around ##K1D, ##K2D and ##K3D
and missed to captialize of k3A.

Offline Chaosghoul

  • Posts: 4
Re: TMK keyboard firmware
« Reply #1526 on: Sun, 03 July 2016, 02:37:04 »
Hey everyone,

Thank you for sharing your code Hasu.
I am a absolute beginner to Arduino/Teensy programming. I have already wired a 106-key (german layout with numpad) and wanted to alter your code and upload it. I have imported everything into the Arduino (I'm on windows) and altered the keymap and config files to my needs.
When I click on upload or check though, I get a TON of compiling errors in all kinds of files (most noticable in the avr files) which I am not able to solve on my own :(

Could you help me please?

I have attached my keymap files to this.
My layout is 6 rows and 21 columns. I have soldered my 6 rows bottom to top to pins 24-29 and my columns to pins 1-21.

Kind regards,
Jakob

Offline hasu

  • Thread Starter
  • Posts: 3472
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: TMK keyboard firmware
« Reply #1527 on: Sun, 03 July 2016, 02:59:50 »
Hi,
Tmk is not compatible with arduino. Read README, docs and issues on Github.com first. I think it takes a week at least to understand how to use this if you are not familiar with these things. Take time.

If you are still interested in using tmk with arduino see this issue and try bgould's repo. https://github.com/tmk/tmk_keyboard/issues/364

Sent from my Nexus 5X using Tapatalk

« Last Edit: Sun, 03 July 2016, 03:04:30 by hasu »

Offline Chaosghoul

  • Posts: 4
Re: TMK keyboard firmware
« Reply #1528 on: Sun, 03 July 2016, 03:10:41 »
Hi Hasu,

Thank you for replying.
If Arduino is not the software to use here, I don't have a problem with switching to something else. I've tried to find out what programming environment you used, but the readme doesn't state this :(

Phew, an additional week to do this would be quite hard to set aside for this project. With work and everything else, I barely got the wiring done over the course of three weeks :(
Would there be someone interested in doing the code for me for a donation? In a way so I can just copy-paste the whole thing, upload and be done with it?

Kind regards,
Jakob

Offline Chaosghoul

  • Posts: 4
Re: TMK keyboard firmware
« Reply #1529 on: Mon, 04 July 2016, 01:17:29 »
Heyho, me again.

So after some googling, I found out that there is a bigger readme than the one that is included in the github files, so sorry for stating that there is not a lot in your readme.

I have altered the code with winavr now and after fiddling around for a while I got it to compile and make a .hex file (jay!).

I now wanted to upload the code using the teensy uploader, only to find out that the code is for teensy 2.0 (I have a teensy 3.2 wired up).
I found out that the whitefox used a teensy 3.2 as well and tried to copy some of the code from that makefile and put it into mine (which gave me a lot of errors). I also tried using the whitefox code and altering it to my needs (which gave me a lt of compiling errors I am not able to decipher :( ).

Could you help me make this code work for teensy 3.2? I have attached the complete code of what I was able to compile and tun into a .hex. I also think my matrix.c is still wrong, but I unfortunately wasn't able to get behind the coding and alter it to my needs. Could you guide me to where to read up on that?

Thanks in advance,
Jakob
« Last Edit: Mon, 04 July 2016, 01:24:03 by Chaosghoul »

Offline rrrsss

  • Posts: 24
Re: TMK keyboard firmware
« Reply #1530 on: Mon, 04 July 2016, 11:19:41 »
can anyone help me with adding a NeoPixel 8 Led strip to my keyboard and having it controlled by TMK? or resources?

it's a ws2812 protocol rgb light right?

https://github.com/rafael-azevedo/tmk_splitkeyboard

on the erglowdox and c44 it has implementation for it. the rgb pin is configured on the config.h file.
i haven't tried it myself, but the results are very pretty:
http://imgur.com/gallery/3vRUa
http://imgur.com/gallery/M445Z

Offline mrbishop

  • * Maker
  • Posts: 799
  • Location: South Carolina USA
  • Evil Genius
    • Bishop Computer Design web
Re: TMK keyboard firmware
« Reply #1531 on: Mon, 04 July 2016, 11:21:45 »
can anyone help me with adding a NeoPixel 8 Led strip to my keyboard and having it controlled by TMK? or resources?

it's a ws2812 protocol rgb light right?

https://github.com/rafael-azevedo/tmk_splitkeyboard

on the erglowdox and c44 it has implementation for it. the rgb pin is configured on the config.h file.
i haven't tried it myself, but the results are very pretty:
http://imgur.com/gallery/3vRUa
http://imgur.com/gallery/M445Z

awesome thanks.
i happen to have a neopixel lying around and my keyboard case bottom is clear so i figured why not.
Projects
Build to give back, 40% | Alps/Matias Removal ToolUltraHack 67% Hackdura  | ErgoDox case
                             
    

Offline MOZ

  • KING OF THE NEWBIES
  • * Maker
  • Posts: 3981
  • Location: Jo'burg
  • Busy making stuff
Re: TMK keyboard firmware
« Reply #1532 on: Tue, 05 July 2016, 01:58:24 »
If you want to use the Neopixel, might I suggest QMK. It has support for RGB (WS2812/B) built in, just set the pin, and keys to change colors and done.

Offline tokyo

  • Posts: 17
Re: TMK keyboard firmware
« Reply #1533 on: Sat, 09 July 2016, 18:03:03 »
Still stuck with this problem, help please :-*
layer_state variable not seem to reflect currently active momentary layers, I am using 20160525 downloaded codes not latest
        [1] = ACTION_LAYER_TAP_KEY(2, KC_SPC)   //momentary layer
        [11] = ACTION_LAYER_TOGGLE(2),   //toggle layer, which works fine
  below is my code, see LSFT_DQT

Code: [Select]

#include "keymap_common.h"
#include "action_util.h"
#include "action_layer.h"


const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = {
       
       
    KEYMAP_ALL(
              F13, F14, F15, F16, F17, F18, F19, F20, F21, F22, F23, F24,

              ESC,      F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12,           PSCR,SLCK,PAUS,    VOLD,VOLU,MUTE,PWR,     HELP,
    GRV, 1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   MINS,EQL, JYEN,BSPC,     INS, HOME,PGUP,    NLCK,PSLS,PAST,PMNS,    STOP,AGIN,
    FN6, Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,   LBRC,RBRC,     BSLS,     DEL, END, PGDN,    P7,  P8,  P9,  PPLS,    MENU,UNDO,
    FN5,A,   S,   D,   F,   G,   H,   J,   K,   L,   SCLN,QUOT,     NUHS,ENT,                         P4,  P5,  P6,  PCMM,    SLCT,COPY,
    FN7,NUBS,Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, SLSH,     RO,  FN8,          UP,           P1,  P2,  P3,  PEQL,    EXEC,PSTE,
    LCTL,LGUI,LALT,FN2,HANJ,     FN1,      HAEN,FN0, FN3,RALT,RGUI,APP, RCTL,     LEFT,DOWN,RGHT,    P0,       PDOT,PENT,    FIND, CUT
    ),

   
   
    [1] = \
    KEYMAP_ALL(
              F13, F14, F15, F16, F17, F18, F19, F20, F21, F22, F23, F24,
    ESC,      F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12,           PSCR,SLCK,PAUS,    VOLD,VOLU,MUTE,PWR,     HELP,
    GRV, 1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   MINS,EQL, FN0,BSPC,     INS, HOME,PGUP,    NLCK,PSLS,PAST,PMNS,    STOP,AGIN,
    TRNS, TRNS,   FN15,   E,   FN19,   T,   Y,   U,   I,   O,   P,   LBRC,RBRC,     BSLS,     DEL, END, PGDN,    P7,  P8,  P9,  PPLS,    MENU,UNDO,
    CAPS,FN18,   FN17,   D,   F,   G,   H,   J,   K,   L,   SCLN,QUOT,     NUHS,ENT,                         P4,  P5,  P6,  PCMM,    SLCT,COPY,
    TRNS,TRNS,FN10,   TRNS,   FN16,   V,   B,   N,   M,   COMM,DOT, SLSH,     RO,  FN8,          UP,           P1,  P2,  P3,  PEQL,    EXEC,PSTE,
    TRNS,TRNS,TRNS,MHEN,TRNS,     FN11,      TRNS,TRNS, FN3,RALT,RGUI,APP, RCTL,     LEFT,DOWN,RGHT,    P0,       PDOT,PENT,    FIND, CUT
            ),

   

   
   
   
   
   
   
   
   

   
   
   
    [2] = \
    KEYMAP(
    TRNS, TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS, TRNS, TRNS,           PSCR,SLCK,BRK,
    TRNS, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12, TRNS,      INS, HOME,PGUP,    NLCK,PSLS,PAST,PMNS,
    TRNS, ESC,FN15,PGUP,  FN4,F12, JYEN,PGUP,TRNS,HOME, TRNS,  TRNS,  TRNS,  TRNS,     DEL, END, PGDN,    P7,  P8,  P9,
    TRNS,TRNS,  LEFT,PGDN,RGHT,TRNS,  LEFT,DOWN,UP,  RGHT,KP_PLUS,  TRNS,       TRNS,                         P4,  P5,  P6,  PPLS,
    FN7,FN10,  DEL,  EQL,  TRNS,  BSPC,  END,FN9,FN13,FN14, TRNS,          TRNS,          UP,           P1,  P2,  P3,
    FN20,TRNS,TRNS,          TRNS,                     TRNS,TRNS,TRNS, TRNS,     LEFT,DOWN,RGHT,    P0,       PDOT,PENT
            ),
   
   

    [3] =                                       \
    KEYMAP(
    TRNS, TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS, TRNS, TRNS,           PSCR,SLCK,BRK,
    TRNS, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12, TRNS,      INS, HOME,PGUP,    NLCK,PSLS,PAST,PMNS,
    TRNS, TRNS,TRNS,TRNS,  TRNS,TRNS, TRNS,TRNS,F4,TRNS, TRNS,  TRNS,  TRNS,  TRNS,     DEL, END, PGDN,    P7,  P8,  P9,
    TRNS,TRNS,  FN12,DOWN,TAB,TRNS,  FN12,DOWN,UP,  TAB,TRNS,  TRNS,       TRNS,                         P4,  P5,  P6,  PPLS,
    TRNS,TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,TRNS,TRNS,TRNS, TRNS,          TRNS,          UP,           P1,  P2,  P3,
    TRNS,TRNS,TRNS,          TRNS,                     TRNS,TRNS,TRNS, TRNS,     FN12,DOWN,TAB,    P0,       PDOT,PENT
            ),
   
   
    [4] = \
    KEYMAP(
    TRNS, TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS, TRNS, TRNS,           PSCR,SLCK,BRK,
    TRNS, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12, TRNS,      INS, HOME,PGUP,    NLCK,PSLS,PAST,PMNS,
    TRNS, TRNS,TRNS,TRNS,  TRNS,TRNS, TRNS,TRNS,TRNS,TRNS, TRNS,  TRNS,  TRNS,  TRNS,     DEL, END, PGDN,    P7,  P8,  P9,
    TRNS,TRNS,  LEFT,DOWN,RGHT,TRNS,  LEFT,DOWN,UP,  RIGHT,TRNS,  TRNS,       TRNS,                         P4,  P5,  P6,  PPLS,
    TRNS,TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,TRNS,TRNS,TRNS, TRNS,          TRNS,          UP,           P1,  P2,  P3,
    TRNS,TRNS,TRNS,          TRNS,                     TRNS,TRNS,TRNS, TRNS,     LEFT,DOWN,RGHT,    P0,       PDOT,PENT
            ),
   
   
    [5] = \
    KEYMAP(
    TRNS, TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS, TRNS, TRNS,           PSCR,SLCK,BRK,
    TRNS, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12, TRNS,      INS, HOME,PGUP,    NLCK,PSLS,PAST,PMNS,
    NO, FN9,  NO,  NO,  TRNS,  NO,  WH_L,WH_D,MS_U,WH_U,WH_R,WBAK,WFWD,NO,      DEL, END, PGDN,    P7,  P8,  P9,
    LCTL,ACL0,ACL1,ACL2,ACL2,NO,  MS_L,MS_D,MS_U,MS_R,TRNS,NO,       ENT,                         P4,  P5,  P6,  PPLS,
    LSFT,FN10,  NO,  NO,  NO,  BTN3,BTN2,FN10,BTN4,BTN5,NO,            RSFT,          UP,           P1,  P2,  P3,
    LCTL,LGUI,LALT,          BTN1,                    RALT,TRNS,TRNS,RCTL,     LEFT,DOWN,RGHT,    P0,       PDOT,PENT
            ),
   






    [6] =                                       \
    KEYMAP(
    TRNS, TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS, TRNS, TRNS,           PSCR,SLCK,BRK,
    TRNS, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12, TRNS,      INS, HOME,PGUP,    NLCK,PSLS,PAST,PMNS,
    TRNS, ESC,TRNS,PGUP,  FN4,F12, JYEN,PGUP,TRNS,HOME, TRNS,  TRNS,  TRNS,  TRNS,     DEL, END, PGDN,    P7,  P8,  P9,
    TRNS,TRNS,  LEFT,PGDN,RGHT,TRNS,  LEFT,DOWN,UP,  RGHT,KP_PLUS,  TRNS,       TRNS,                         P4,  P5,  P6,  PPLS,
    TRNS,FN10,  DEL,  EQL,  TRNS,  BSPC,  END,FN9,FN13,FN14, TRNS,          TRNS,          UP,           P1,  P2,  P3,
    TRNS,TRNS,TRNS,          TRNS,                     TRNS,TRNS,TRNS, TRNS,     LEFT,DOWN,RGHT,    P0,       PDOT,PENT
            )
};



enum function_id {
        LALT_TAB,
        LSFT_DQT,
        TGGL_MOD,


};


const uint16_t fn_actions[] PROGMEM = {

        [0] = ACTION_MODS_TAP_KEY(MOD_RSFT, KC_ENT),
       
        [1] = ACTION_LAYER_TAP_KEY(2, KC_SPC)   ,
        [2] = ACTION_MODS_TAP_KEY(MOD_LALT, KC_RO),
        [3] = ACTION_LAYER_TAP_KEY(1, KC_BSPC)   ,

        [4] = ACTION_LAYER_TOGGLE(6),
       
        [5] = ACTION_MODS_TAP_KEY(MOD_LCTL, KC_RBRC),
        [6] = ACTION_FUNCTION_TAP(LALT_TAB),
        [7] = ACTION_FUNCTION_TAP(LSFT_DQT),
       
       
        [8] = ACTION_MODS_TAP_TOGGLE(MOD_RSFT),

        [9] = ACTION_LAYER_TOGGLE(5),

        [10] = ACTION_LAYER_SET_CLEAR(0),
        [11] = ACTION_LAYER_TOGGLE(2),
        [12] = ACTION_MODS_KEY(MOD_RSFT, KC_TAB),
        [13] = ACTION_MODS_KEY(MOD_RSFT | MOD_RCTL, KC_TAB),
        [14] = ACTION_MODS_KEY(MOD_RCTL, KC_TAB),
       


        [15] = ACTION_FUNCTION_OPT(TGGL_MOD, MOD_LGUI),
        [16] = ACTION_FUNCTION_OPT(TGGL_MOD, MOD_LCTL),
        [17] = ACTION_FUNCTION_OPT(TGGL_MOD, MOD_LSFT),
        [18] = ACTION_FUNCTION_OPT(TGGL_MOD, MOD_LALT),
        [19] = ACTION_LAYER_TAP_KEY(5, KC_R),

        [20] = ACTION_MODS_KEY(MOD_LALT, KC_PSCR)
};




void action_function(keyrecord_t *record, uint8_t id, uint8_t opt)
{
       
       
       
       

    switch (id) {
        case LALT_TAB:
            if (record->event.pressed) {
                if (record->tap.count > 0 && !record->tap.interrupted) {
                        if (record->tap.interrupted) {

                                layer_on(3);
                        register_mods(MOD_BIT(KC_LALT));

                        register_code(KC_TAB);
                        unregister_code(KC_TAB);
                    }
                } else {
                    layer_on(3);
                    register_mods(MOD_BIT(KC_LALT));

                    register_code(KC_TAB);
                        unregister_code(KC_TAB);
                }
            } else {
                if (record->tap.count > 0 && !(record->tap.interrupted)) {
                       
                       
                    register_code(KC_TAB);
                    unregister_code(KC_TAB);
                   
                   
                    record->tap.count = 0;
                } else {
                    unregister_mods(MOD_BIT(KC_LALT));
                    layer_off(3);
                }
            }
            break;
    case TGGL_MOD:


            if (record->event.pressed) {
                    if (opt & get_mods()) {
                            unregister_mods(opt);
                    } else {
                            register_mods(opt);
                    }
            }
            break;

    case LSFT_DQT:
            if (record->event.pressed) {
                if (record->tap.count > 0 && !record->tap.interrupted) {
                        if (record->tap.interrupted) {

                                register_mods(MOD_BIT(KC_LSHIFT));
                    }
                } else {
                        register_mods(MOD_BIT(KC_LSHIFT));
                }
            } else {
                if (record->tap.count > 0 && !(record->tap.interrupted)) {


                        add_weak_mods(MOD_BIT(KC_LSHIFT));



                        if(2 & layer_state)
                        {
                        register_code(KC_2);
                        unregister_code(KC_2);
                    }
                    else
                    {
                        register_code(KC_7);
                        unregister_code(KC_7);
                    }
                    del_weak_mods(MOD_BIT(KC_LSHIFT));

                    record->tap.count = 0;
                } else {
                    unregister_mods(MOD_BIT(KC_LSHIFT));
                }
            }
            break;           
           
           
           
           
           
           
           
           
           
           
           
           
           
           
           
           
           
           
           
           
           
           
           
           
           
           
           
           
           
           
    }
}

Offline hasu

  • Thread Starter
  • Posts: 3472
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: TMK keyboard firmware
« Reply #1534 on: Sat, 09 July 2016, 18:16:20 »
Describe detail of what you expect and what you really get.

Offline Chaosghoul

  • Posts: 4
Re: TMK keyboard firmware
« Reply #1535 on: Wed, 13 July 2016, 00:18:10 »
Heyho,

me again.
With help of a friend I figured most of the stuff out and everything works so far, except one thing: numpad comma. I have a physical numpad on my keyboard, all the keys work, just the comma doesn't for some reason.
I have tried a keyboard tester and I can see that the physical key works and also if I program the keypad comma to be something else (e.g. DOT) it works, but neither PCMM, nor KP_COMMA work for me :(

Any ideas on this?

Offline hasu

  • Thread Starter
  • Posts: 3472
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: TMK keyboard firmware
« Reply #1536 on: Wed, 13 July 2016, 01:05:58 »
Heyho,

me again.
With help of a friend I figured most of the stuff out and everything works so far, except one thing: numpad comma. I have a physical numpad on my keyboard, all the keys work, just the comma doesn't for some reason.
I have tried a keyboard tester and I can see that the physical key works and also if I program the keypad comma to be something else (e.g. DOT) it works, but neither PCMM, nor KP_COMMA work for me :(

Any ideas on this?

I think most of system/layouts don't support the keycode. Accroding to spec it seems to exist for Brazillian keyboard layout.
Try changing your layout to Brazillian and report whether it works or not. I'm curious.

HID Usage Tables Version 1.12 p.59
Quote
Keypad Comma is the appropriate usage for the Brazilian keypad period (.) key. This represents the closest possible
match, and system software should do the correct mapping based on the current locale setting.

Offline kitten_paw

  • Posts: 2
Re: TMK keyboard firmware
« Reply #1537 on: Thu, 14 July 2016, 04:16:34 »
Hi,

I am trying to create a couple of layers for the tmk firmware with an ISO 105 key keyboard. I am using the German keymap on my system, where I have to use RALT+8 to get the [ character, RALT+0 to get } and so on. This is extremely annoying for programming, of course, which is why I've been using the US keymap when programming and switching back and forth.

Now my idea is that I'd like to have a "programming layer" that basically mimics the US layout when active. For example when I press the ü key I want to get ü on the default layer and [ on the programming layer, without having to change the system keymap. I know I can achieve this for a single key by making ü a FN key with ACTION_MODS_KEY, but this means a) that I have to waste a function key and b) that I can't use shift+ü to get { (at least I don't know how).

So basically my question is, how can I set up the KEYMAP that my programming layer sends the correct keycodes on the German keymap to mimic the US keymap?

I created my intended layer layout here: http://www.keyboard-layout-editor.com/#/gists/3f4485a4bef29532c9d25c522d221037
The black labels are the default layer, the red key toggles the programming layer, and the red labels are the characters that I want to get when the programming layer is active (upper labels are Shift+key), without having to change the keymap in the OS. I hope this makes a little more sense now.

Disclaimer: I posted more or less the same thing on deskthority.

[edit: Implemented a solution]
So, for now I have implemented it using FN keys and MACROs, thanks to the tmk github wiki. I think it's an ugly solution, but it works. So here's my keymap that, when using a German OS keymap, has German layout on the default layer and a US layout on two seperate programming layers. Maybe somebody finds this useful.

Code: [Select]

const uint8_t PROGMEM keymaps[][MATRIX_COLS][MATRIX_ROWS] = {
    /* Layer 0: Standard ANSI layer */
    KEYMAP(\
         ESC, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11,  F12,        PSCR,SLCK,PAUS,                         \
         GRV, 1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   MINS, EQL,BSPC,   INS, HOME,PGUP,    NLCK,PSLS,PAST,PMNS, \
         TAB, Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,   LBRC,RBRC,BSLS,   DEL, END, PGDN,    P7,  P8,  P9,  PPLS, \
         RALT,A,   S,   D,   F,   G,   H,   J,   K,   L,   SCLN,QUOT,      ENT,                      P4,  P5,  P6,        \
         LSFT,NUBS,Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, SLSH,     RSFT,        UP,           P1,  P2,  P3,  PENT, \
         LCTL,LGUI,LALT,               SPC,                FN0, FN1,  FN2,RCTL,   LEFT,DOWN,RGHT,    P0,  PDOT),          \
    /* Layer 1: programming layer 1*/
    KEYMAP(\
          ESC,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,        TRNS,TRNS,TRNS,                         \
         TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,SLSH,FN11,TRNS,   TRNS,TRNS,TRNS,    TRNS,TRNS,TRNS,TRNS, \
         TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,FN12,FN13,FN16,   TRNS,TRNS,TRNS,    TRNS,TRNS,TRNS,TRNS, \
         TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,FN14,FN15,     TRNS,                      TRNS,TRNS,TRNS,      \
         FN26,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,FN17,     TRNS,        TRNS,         TRNS,TRNS,TRNS,TRNS, \
         TRNS,TRNS,TRNS,               TRNS,               TRNS,TRNS,TRNS,TRNS,   TRNS,TRNS,TRNS,    TRNS,TRNS),
    /* Layer 2: programming layer 2*/
    KEYMAP(\
          ESC,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,        TRNS,TRNS,TRNS,                         \
         TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,FN18,RBRC,TRNS,   TRNS,TRNS,TRNS,    TRNS,TRNS,TRNS,TRNS, \
         TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,FN19,FN20,FN23,   TRNS,TRNS,TRNS,    TRNS,TRNS,TRNS,TRNS, \
         TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,FN21,FN22,     TRNS,                      TRNS,TRNS,TRNS,      \
         TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,NUBS,FN24,FN25,     TRNS,        TRNS,         TRNS,TRNS,TRNS,TRNS, \
         TRNS,TRNS,TRNS,               TRNS,               TRNS,TRNS,TRNS,TRNS,   TRNS,TRNS,TRNS,    TRNS,TRNS),
    /* Layer 3: media layer */
    KEYMAP(\
          FN3,  NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,        MPRV,MPLY,MNXT,                         \
           NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,     NO,  NO,VOLU,      NO,  NO,  NO,  NO, \
           NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,     NO,MUTE,VOLD,      NO,  NO,  NO,  NO, \
           NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,       NO,                        NO,  NO,  NO,      \
           NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,       NO,          NO,           NO,  NO,  NO,  NO, \
           NO,  NO,  NO,                 NO,                 NO,  NO,  NO,  NO,     NO,  NO,  NO,      NO,  NO),
    /* Layer 4: Mouse layer */
    KEYMAP(\
          FN3,  NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,          NO,  NO,  NO,                         \
           NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,     NO,  NO,  NO,      NO,  NO,  NO,  NO, \
           NO,  NO,  NO,MS_U,  NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,     NO,  NO,  NO,      NO,  NO,  NO,  NO, \
           NO,  NO,MS_L,MS_D,MS_R,  NO,WH_L,WH_D,WH_U,WH_R,  NO,  NO,       NO,                        NO,  NO,  NO,      \
           NO,  NO,  NO,  NO,  NO,  NO,  NO,BTN2,BTN3,  NO,  NO,  NO,       NO,          NO,           NO,  NO,  NO,  NO, \
           NO,  NO,  NO,               BTN1,                 NO,  NO,  NO,  NO,     NO,  NO,  NO,      NO,  NO)

};
enum macro_id {
    UNDERSCORE,
    EQUAL,
    RBRACE_L,
    CBRACE_L,
    RBRACE_R,
    CBRACE_R,
    SEMICOLON,
    COLON,
    APOSTROPHE,
    QUOTE,
    BACKSLASH,
    PIPE,
    GREATERTHAN,
    SLASH,
    QUESTION
};

static const uint16_t PROGMEM fn_actions[] = {
    [0] = ACTION_LAYER_TOGGLE(4),
    [1] = ACTION_LAYER_TOGGLE(1),
    [2] = ACTION_LAYER_MOMENTARY(3),
    [3] = ACTION_LAYER_SET_CLEAR(0),
    [11] = ACTION_MACRO(EQUAL),
    [12] = ACTION_MACRO(RBRACE_L),
    [13] = ACTION_MACRO(RBRACE_R),
    [14] = ACTION_MACRO(SEMICOLON),
    [15] = ACTION_MACRO(APOSTROPHE),
    [16] = ACTION_MACRO(BACKSLASH),
    [17] = ACTION_MACRO(SLASH),
    [18] = ACTION_MACRO(UNDERSCORE),
    [19] = ACTION_MACRO(CBRACE_L),
    [20] = ACTION_MACRO(CBRACE_R),
    [21] = ACTION_MACRO(COLON),
    [22] = ACTION_MACRO(QUOTE),
    [23] = ACTION_MACRO(PIPE),
    [24] = ACTION_MACRO(GREATERTHAN),
    [25] = ACTION_MACRO(QUESTION),
    [26] = ACTION_LAYER_MOMENTARY(2)
};

const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
{
    keyevent_t event = record->event;
    //uint8_t tap_count = record->tap_count;

    switch (id) {
        case EQUAL:
            return (event.pressed ?
                    MACRO( D(LSHIFT), T(0), U(LSHIFT), END ) :
                    MACRO( END ) );
        case RBRACE_L:
            return (event.pressed ?
                    MACRO( D(RALT), T(8), U(RALT), END ) :
                    MACRO( END ) );
        case RBRACE_R:
            return (event.pressed ?
                    MACRO( D(RALT), T(9), U(RALT), END ) :
                    MACRO( END ) );
        case SEMICOLON:
            return (event.pressed ?
                    MACRO( D(LSHIFT), T(COMM), U(LSHIFT), END ):
                    MACRO( END ) );
        case APOSTROPHE:
            return (event.pressed ?
                    MACRO( D(LSHIFT), T(BSLS), U(LSHIFT), END ):
                    MACRO( END ) );
        case BACKSLASH:
            return (event.pressed ?
                    MACRO( D(RALT), T(MINS), U(RALT), END ):
                    MACRO( END ) );
        case SLASH:
            return (event.pressed ?
                    MACRO( D(LSHIFT), T(7), U(LSHIFT), END ) :
                    MACRO( END ) );
        case UNDERSCORE:
            return (event.pressed ?
                    MACRO( D(LSHIFT), T(SLSH), U(LSHIFT), END ) :
                    MACRO( END ) );
        case CBRACE_L:
            return (event.pressed ?
                    MACRO( D(RALT), T(7), U(RALT), END ) :
                    MACRO( END ) );
        case CBRACE_R:
            return (event.pressed ?
                    MACRO( D(RALT), T(0), U(RALT), END ) :
                    MACRO( END ) );
        case COLON:
            return (event.pressed ?
                    MACRO( D(LSHIFT), T(DOT), U(LSHIFT), END ) :
                    MACRO( END ) );
        case QUOTE:
            return (event.pressed ?
                    MACRO( D(LSHIFT), T(2), U(LSHIFT), END ) :
                    MACRO( END ) );
        case PIPE:
            return (event.pressed ?
                    MACRO( D(RALT), T(NUBS), U(RALT), END ) :
                    MACRO( END ) );
        case GREATERTHAN:
            return (event.pressed ?
                    MACRO( D(LSHIFT), T(NUBS), U(LSHIFT), END ) :
                    MACRO( END ) );
        case QUESTION:
            return (event.pressed ?
                    MACRO( D(LSHIFT), T(MINS), U(LSHIFT), END ) :
                    MACRO( END ) );
    }
    return MACRO_NONE;
}
« Last Edit: Thu, 14 July 2016, 08:15:41 by kitten_paw »

Offline xauser

  • Posts: 97
Re: TMK keyboard firmware
« Reply #1538 on: Thu, 14 July 2016, 15:53:54 »
@kitten_paw

Nice apporach for developers that insist on german keymap. I would suggest another mind set and switch over to us international keymap. You have to learn the new positions for the german umlauts (4 keys) but get everything you
want in one keymap without any tmk or os magic. 
« Last Edit: Thu, 14 July 2016, 16:17:39 by xauser »

Offline kitten_paw

  • Posts: 2
Re: TMK keyboard firmware
« Reply #1539 on: Fri, 15 July 2016, 06:00:20 »
@xauser

First of all thank you very much for pointing this out to me, I didn't know this variant even existed. I have already activated it on my laptop, where I use a US layout.
Still, I have to write a lot more prose than I have to write code, so I actually think I will keep the German layout as my main layout on my PC. The idea of having these layers was one of my main motivators behind getting a keyboard with replaceable and programmable controller, so don't go and spoil it for me ;)

Offline MrMen

  • Posts: 25
Re: TMK keyboard firmware
« Reply #1540 on: Sun, 17 July 2016, 16:56:04 »
Hi guys.
I'd like to use TMK with my HHKB and bepo French layout. To do so, I have to use many (too much) macros.

I recently saw actiomap and I'd like to give it a try. I investigate the alps64 example but I can't figure out how to modify the Makefile.rn42

Does anyone has a hint for me ?

Thank you.

Offline nikchi

  • Posts: 5
Re: TMK keyboard firmware
« Reply #1541 on: Sun, 17 July 2016, 17:40:20 »
I'm using https://deskthority.net/w/images/1/11/Voice_of_Reason_Components.PNG

It runs a ATMEGA32U2 and bpiphany has a working fork of TMK for his controllers. It also compiles and runs fine on the main TMK fork. I want to use the protocol/bluefruit stuff. How would I make this work? The controller has the TX and RX pins broken out.

I've added in this code to my config.h. What else should I do to make this work before I try this entire thing?

Code: [Select]
#ifdef __AVR_ATmega32U2__
    #define SERIAL_UART_BAUD       9600
    #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)
#else
#   error "USART configuration is needed."
#endif

Offline hasu

  • Thread Starter
  • Posts: 3472
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: TMK keyboard firmware
« Reply #1542 on: Sun, 17 July 2016, 17:57:13 »
I'm using https://deskthority.net/w/images/1/11/Voice_of_Reason_Components.PNG

It runs a ATMEGA32U2 and bpiphany has a working fork of TMK for his controllers. It also compiles and runs fine on the main TMK fork. I want to use the protocol/bluefruit stuff. How would I make this work? The controller has the TX and RX pins broken out.

I've added in this code to my config.h. What else should I do to make this work before I try this entire thing?

Code: [Select]
#ifdef __AVR_ATmega32U2__
    #define SERIAL_UART_BAUD       9600
    #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)
#else
#   error "USART configuration is needed."
#endif

See converter/x68k_usb/config.h, it appears to have USART configuration for 32U2 and I remember it works.
And of course you have to read datasheet, first.

Offline nikchi

  • Posts: 5
Re: TMK keyboard firmware
« Reply #1543 on: Sun, 17 July 2016, 19:51:02 »
Thanks for the reply!

The issue now is how to get the serial working. Ideally I want to send both through usb and through serial

Offline hasu

  • Thread Starter
  • Posts: 3472
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: TMK keyboard firmware
« Reply #1544 on: Mon, 18 July 2016, 19:35:36 »
Thanks for the reply!

The issue now is how to get the serial working. Ideally I want to send both through usb and through serial

You can refer hhkb/rn42 codes which switches between two protocols USB(lufa) and Bluetooth(rn42) dynamically.
https://github.com/tmk/tmk_keyboard/blob/master/keyboard/hhkb/rn42/main.c#L75-L79

Offline RichardRahl

  • Posts: 5
Re: TMK keyboard firmware
« Reply #1545 on: Thu, 04 August 2016, 08:44:39 »
Dear Geekhack community,

I am trying to make a firmware for my laptop keyboard because I put a raspberry pi inside my old laptop and I want to use my original keyboard with it.

This keyboard got a 26 wire flat ribbon cable. I made a pcb to be able to connect it with a teensy lc I purchased recently. I am done with the wiring and started with the programing. I learned to program with C but it was a long time ago and I forgot a lot. I used this site and program as a starting point http://www.40percent.club/2016/07/teensy-lc-fastest-van.html.
I modified the original program, taking out the led components adding my keyboard matrix and surprisingly I could compile the program with tones of warnings. I believe I attached the modified program to this post.

Again, surprisingly some of the buttons actually work, but most of them are not. I was trying to figure out the problem for some time now and have some idea but that's not enough.

I figured out the keyboard matrix by connecting it to a raspberry Pi writing a little program and connecting one pin to ground ... I went throw all the pins and came up with the matrix. 17 columns and 8 rows and 1 wire was use for some other thing I am not sure what. I connected all 17 cols to teensy lc 0-16 pins and the 8 rows to 17-24. I attach the keyboard matrix as well with 3 pictures.

I would appreciate any help you can give me with the program.

thank you,

RR

Offline a-c

  • Posts: 196
  • Location: USA
Re: TMK keyboard firmware
« Reply #1546 on: Thu, 04 August 2016, 13:26:09 »
You need this delay. Uncomment this line in the matrix.c

wait_us(30);  // without this wait read unstable value.

Pin 13 also has a LED attached to it which may cause problems. If you are out of pins you can try removing the LED.

Offline RichardRahl

  • Posts: 5
Re: TMK keyboard firmware
« Reply #1547 on: Thu, 04 August 2016, 14:05:08 »
Thank you for your answer.

wait_us(30); makes no difference as it is right now. I tried to compile the program with a hundred different way altering the program, including that one. :(

I will leave out pin 13 and see what happens but I thing someting fundamental is wrong with my program just dont know what... :(

Thanks!!

Offline a-c

  • Posts: 196
  • Location: USA
Re: TMK keyboard firmware
« Reply #1548 on: Thu, 04 August 2016, 14:14:36 »
Thank you for your answer.

wait_us(30); makes no difference as it is right now. I tried to compile the program with a hundred different way altering the program, including that one. :(

I will leave out pin 13 and see what happens but I thing someting fundamental is wrong with my program just dont know what... :(

Thanks!!

Since it is a Teensy you can try programming a simple Arduino sketch that works like your Pi one and see if the switches are making connections like you expect.

Offline RichardRahl

  • Posts: 5
Re: TMK keyboard firmware
« Reply #1549 on: Fri, 05 August 2016, 13:19:03 »
Hi guys! I have found the problem. :) I didn't modify the config.h .

I changed the number of rows and cols and woala... :) It is still not 100% but a lot better than before. I think now pin 13 is messing with me, I am not sure tho.
I thought I missed something basic. :)

I looked into it. When I push a button in pin19 the keyboard will type two letters on pin18 and pin19 at the same time. - Interesting - But when I push a button on pin18 it will only type the right letter. :)

I am still thrilled that I found the problem I had before.