How to build your very own keyboard firmware

User avatar
matt3o
-[°_°]-

25 Sep 2016, 16:48

I updated the windows section, I haven't tested atmelstudio personally, but it looks the best options for windows. Please let me know how it works for you.

User avatar
scottc

25 Sep 2016, 17:12

Last time I did this on Windows for a friend, I used the now-native "Bash for Ubuntu for Windows 10" and just installed all of the Linux packages. Worked perfectly for everything apart from flashing, which I did with some standard GUI tool.

TenkaiX

26 Sep 2016, 00:26

Rejerh wrote: I think you have to have it no matter what, even if you don't have FN keys
Okay, I'll put that back in and try :)

TenkaiX

26 Sep 2016, 00:27

matt3o wrote: I updated the windows section, I haven't tested atmelstudio personally, but it looks the best options for windows. Please let me know how it works for you.
I'm doing the project on Mac but I'll test atmelstudio later

TenkaiX

26 Sep 2016, 00:30

TenkaiX wrote:
Rejerh wrote: I think you have to have it no matter what, even if you don't have FN keys
Okay, I'll put that back in and try :)
No way. If this keyboard works I praise you mate, I'll praise you all the way. The compiling worked lets see if the keyboard works now !!!


YAY it works! Just a few keys must be soldered badly but it works <3!!!

Rejerh

26 Sep 2016, 01:58

TenkaiX wrote:
TenkaiX wrote:
Rejerh wrote: I think you have to have it no matter what, even if you don't have FN keys
Okay, I'll put that back in and try :)
No way. If this keyboard works I praise you mate, I'll praise you all the way. The compiling worked lets see if the keyboard works now !!!


YAY it works! Just a few keys must be soldered badly but it works <3!!!
I am glad I could help with my very little knowledge mate!

User avatar
hasu

26 Sep 2016, 23:45

Rejerh wrote: Has anyone attempted to use some sort of backlight with just one PWM pin?
I saw the numerous posts from ROFLmonster which are quite interesting.
Unfortunately I don't understand much of what he did in the part where he manages the led strip and changes the colors and all.
I couldn't find the posts in this thread, where are the posts you are refering? Can you post a link?
In my current set up I have all my leds connected to the +5V while I have a transistor on a PWM pin (PD7 of the teensy 2.0).
The idea is to change the leds' intensity by changing the frequency at which the transistor opens and closes (pretty simple and classic stuff I think). All leds will have the same intensity but I don't mind at all.

I am not sure where to start. At the moment I have something a bit silly where I have set up the pin (PD7) to HIGH when I press the capslock key. This is allowing to have the keyboard lighted up but I cannot control intensity nor switch it back off without unplugging the keyboard.

Using layers and FN keys like ROFLmonster did sounds like a good idea but I am not sure how to manage the PWM value (Arduino made that really simple with the analogWrite(), not sure how to do that within AVR).

Can someone help me out please?
You can start learning from Arduino repository if you are familiar with it. And consult with datasheet of your controller ATmega32u4.(maybe, "15. 10-bit High Speed Timer/Counter4"?)
https://github.com/arduino/Arduino/blob ... log.c#L104

Rejerh

27 Sep 2016, 03:53

ROFLmonster wrote:
Kaibz wrote:
ROFLmonster wrote: Thanks everyone for your help! Once I finish it I'll make sure to post a few pictures!
And will you also post......your code? :oops:
No problem, but it fits my specific layout and pinout (which is also included as a .PNG), not sure how that'll help you.

The .rar contains only the modified GH60 library since I didn't change anything else, including the WS2812B RGB LED strip libraries I used which can be found in full here: https://github.com/cpldcpu/light_ws2812 ... apa102_AVR

It's a bit messy, towards the end I just wanted to finish everything, but if something's not clear I'd be glad to help.

Mediafire link just in case:
http://www.mediafire.com/download/r958zpn0tw2g65p
Hey Hasu, sorry for not quoting the posts.
In the pages 3-5 of this thread there are a few exchanges which ends with this last post where ROFLmonster posts his code. In it there is some code that manages his Led strip which I don't really understand.

As for my problem, I will check the link that you posted from Arduino.
Thanks a lot!

Rejerh

29 Sep 2016, 17:49

For whoever is interested, after quite some difficulties and still wondering how everything works I managed to make my backlight work.

My set up is as follows:
1- All my 69 Leds with some resistors in series (be careful to take strong enough resistors so you don't try to get more than 500mA out of the USB port) are connected in parallel to the VCC and to one of the outside pins of a transistor (not the middle one).
2- The transistor has its middle pin connected to PD7 on a teensy 2.0 and its last pin connected to the GND.
The idea is to control the PWM on the PD7 to make the transistor open and close more or less to control the brightness of the Leds

To do this I have followed the implementation of ROFLmonster (see in this Thread on page 3-5).
1- I have added a backlight.h in the same folder as keymap_poker.c.

Here is the code in it:

Code: Select all

#define BACKLIGHT_OFF 2
#define BACKLIGHT_ON 3
#define BACKLIGHT_INCREASE 4
#define BACKLIGHT_DECREASE 5

void decrease(void);
void increase(void);
void turn_off();
void turn_on(void);
void set_pwm_value(void);
void init_pwm(void);
2- I have modified my keymap_poker.c to manage tap actions on FN key strokes. To do that I have added 2 FN layers.
The first one has all the features I wanted from my FN0 key and the second one has the controlling FN keys (2-5) that will modify the brightness of my LEDS.

Here is the code:

Code: Select all

#include "keymap_common.h"
#include <avr/io.h>
#include "backlight.h"
#include <stdlib.h>
#include <time.h>

const int step = 205;
int pwm_cycle = 0; //full cycle is reached at 2047

int is_init = 0;

const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
	KEYMAP(ESC,  1,    2,    3,   4,   5,   6,   7,    8,    9,    0, MINS,   EQL, BSPC,   INS, HOME, \
           TAB,  Q,    W,    E,   R,   T,   Y,   U,    I,    O,    P, LBRC,  RBRC, BSLASH,   DEL, END,  \
           CAPS, A,    S,    D,   F,   G,   H,   J,    K,    L, SCLN, QUOT,         ENT,              \
           LSFT,    Z,    X,    C,   V,   B,   N,   M, COMM,  DOT, SLSH,           RSFT,    UP,        \
           LCTL, LGUI, LALT,         SPC,                    RALT,  FN0,     RCTL,  LEFT, DOWN, RIGHT),
	
	/* 1: FN 1 */
    KEYMAP(GRAVE,   F1,   F2,   F3,   F4,   F5,   F6,   F7,   F8,   F9,   F10,   F11,   F12, TRNS, MEDIA_PLAY_PAUSE, PGUP, 				\
            TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS,  PSCR,  SLCK, PAUSE, FN1,       MEDIA_STOP, PGDN,				\
            TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS,  TRNS,  TRNS,        TRNS,                                   	\
            LSFT, TRNS, TRNS, CALC, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS,  TRNS,               RSFT,             VOLU,            		\
            LCTL, APP, LALT,             TRNS,             RALT, TRNS,         RCTL,         MEDIA_PREV_TRACK, VOLD, MEDIA_NEXT_TRACK),
	
	/* 2: FN 2 */
    KEYMAP(GRAVE,   F1,   F2,   F3,   F4,   F5,   F6,   F7,   F8,   F9,   F10,   F11,   F12, TRNS, MEDIA_PLAY_PAUSE, PGUP, 				\
            TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS,  PSCR,  SLCK, PAUSE, TRNS,       MEDIA_STOP, PGDN,				\
            TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS,  TRNS,  TRNS,        TRNS,                                   	\
            LSFT, TRNS, TRNS, CALC, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS,  TRNS,               RSFT,             FN4,            		\
            LCTL, APP, LALT,             TRNS,             RALT, TRNS,         RCTL,          FN2,             FN5, FN3),

};

const action_t PROGMEM fn_actions[] = {
	[0] = ACTION_LAYER_MOMENTARY(1),
	[1] = ACTION_LAYER_MOMENTARY(2),
	[2] = ACTION_FUNCTION_TAP(BACKLIGHT_OFF),
	[3] = ACTION_FUNCTION_TAP(BACKLIGHT_ON),
	[4] = ACTION_FUNCTION_TAP(BACKLIGHT_INCREASE),
	[5] = ACTION_FUNCTION_TAP(BACKLIGHT_DECREASE),
};

int min(int a, int b)
{
	if (a <= b){return a;}
	else{return b;}
}

int max(int a, int b)
{
	if (a >= b){return a;}
	else{return b;}
}

void init_pwm()
{
	DDRD |= (1 << 7);
	TCCR4B = 0x01;
	TCCR4C = 0x09;
	TCCR4D = 0x00;
	TCCR4E = 0x40;
	TC4H = 7; 
	OCR4C = 0xFF;	
	is_init = 1;
}

void turn_off()
{	
	pwm_cycle = 0;
	set_pwm_value();
}

void turn_on()
{	
	pwm_cycle = 2047;
	set_pwm_value();
}

void set_pwm_value()
{	
	if(!is_init)
	{
		init_pwm();
	}
	pwm_cycle = min(max(0, pwm_cycle),2047);
	pwm_cycle &= 0x7FF;  // restrict to 11 bits
	TC4H = (pwm_cycle >> 8);
	OCR4D = pwm_cycle & 0x00FF;
}

void action_function(keyrecord_t *record, uint8_t id, uint8_t opt)
{
	switch (id)
	{
		case BACKLIGHT_OFF:
			turn_off(0);			
			break;
		case BACKLIGHT_ON:			
			turn_on();						
			break;
		case BACKLIGHT_INCREASE:
			increase();
			break;
		case BACKLIGHT_DECREASE:
			decrease();
			break;
		default:
			turn_off(0);
			break;
	}
}

void increase()
{
	pwm_cycle = pwm_cycle + step;
	set_pwm_value();
}

void decrease()
{
	pwm_cycle = pwm_cycle - step;
	set_pwm_value();
}
I hope it will help someone. At least it works great for me.

Thanks to hasu and flabbergast for pointing me in the right directions!

ianp

29 Sep 2016, 18:17

I apologize if this is not the right sub to post this question, but I'm stuck and couldn't find a more appropriate place :)

Using the following matrix wired to my Teensy 2.0 as indicated:

Image

I'm having a hard time figuring out exactly how to make this work using Haus's Keyboard Firmware (https://github.com/tmk/tmk_keyboard)

I've attempted to make the appropriate adjustments to the matrix and layout within the code, but for some reason caps is now "J" and alt is "K". That's all I've managed to get working so far. :)

I was wondering if anyone could offer some pointers or possibly insight on what I should modify to get this working?

Thank you!

TenkaiX

11 Oct 2016, 13:07

Hello,
So you're using hasu's code not gh60?
If you're using gh60 I could possibly help you write up a bit of code in my spare time.
I too was struggling but with the help of Hasu, Matt3o and Rejerh I created my very own keyboard

Hopefully I didn't reply too late >.<

User avatar
hasu

13 Oct 2016, 22:18

Hi,
I made virtualbox VM image for compile source codes the other day.
Try this if you have trouble on setup GCC toolchain and development tools.
https://github.com/tmk/tmk_keyboard/wik ... VirtualBox
I tested this on Windows10 but it should work on Mac too.

Also check here.
https://github.com/tmk/tmk_keyboard/wiki#build-firmware

hypkx
Chasing the Dream

14 Oct 2016, 14:06

I have a problem, my satan gh60 didn't work correct. I changed the files of the qmk satan gh60 rgb keyboard firmware, everthing functioned fine, after I flashed the firmware (linux) it didn't work. The keyboard worked some months ago pretty good, but for stupid reasons I erased the firmware and the original files are used are not anymore existend. Now the most keys dont work and the 4-5 that work puts out the wrong characters, for example the "r" a "s". Is there something wrong in my keymap (I tried the stock hex files and then my modified ones, but no difference). The rgb strip work and I just modified the keymap and satan.h.
That is my keyboard:
Spoiler:
Image
satan.h

Code: Select all

#ifndef SATAN_H
#define SATAN_H

#include "matrix.h"
#include "keymap_common.h"
#include "backlight.h"
#include "rgblight.h"
#include <stddef.h>

// This a shortcut to help you visually see your layout.
// The following is an example using the Planck MIT layout
// The first section contains all of the arguements
// The second converts the arguments into a two-dimensional array
#define KEYMAP( \
	k00, k01, k02, k03, k04, k05, k06, k07, k08, k09, k0a, k0b, k0c, k0d, \
	k10, k11, k12, k13, k14, k15, k16, k17, k18, k19, k1a, k1b, k1c, k1d, \
	k20, k21, k22, k23, k24, k25, k26, k27, k28, k29, k2a, k2b, k2c,      \
	k30, k31, k32, k33, k34, k35, k36, k37, k38, k39, k3a, k3b,      k3d, \
	k40,      k42,                k46,                     k4b,      k4d\
) \
{ \
		{k00, k01, k02, k03, 	k04, 	k05, k06, 	k07, 	k08, 	k09, 	k0a, 	k0b, 	k0c, 	k0d}, \
		{k10, k11, k12, k13, 	k14, 	k15, k16, 	k17, 	k18, 	k19, 	k1a, 	k1b, 	k1c, 	k1d}, \
		{k20, k21, k22, k23, 	k24, 	k25, k26, 	k27, 	k28, 	k29, 	k2a, 	k2b, 	k2c, 	KC_NO}, \
		{k30, k31, k32, k33, 	k34, 	k35, k36, 	k37, 	k38, 	k39, 	k3a, 	k3b, 	KC_NO, 	k3d}, \
		{k40, KC_NO, k42, KC_NO, KC_NO, KC_NO, k46, KC_NO, KC_NO, KC_NO,  KC_NO,      k4b, 	KC_NO, 	k4d}  \
}

void * matrix_init_user(void);
void * matrix_scan_user(void);

#endif



//#define KEYMAP( \
//	k00, k01, k02, k03, k04, k05, k06, k07, k08, k09, k0a, k0b, k0c, k0d, \
//	k10, k11, k12, k13, k14, k15, k16, k17, k18, k19, k1a, k1b, k1c, k1d, \
//	k20, k21, k22, k23, k24, k25, k26, k27, k28, k29, k2a, k2b, k2c,      \
//	k30, k31, k32, k33, k34, k35, k36, k37, k38, k39, k3a, k3b,      k3d, \
//	k40,      k42,                k46,                     k4b,      k4d \
//) \
//{ \
//		{k00, k01, k02, k03, 	k04, 	k05, k06, 	k07, 	k08, 	k09, 	k0a, 	k0b, k0c, 	k0d}, \
//		{k10, k11, k12, k13, 	k14, 	k15, k16, 	k17, 	k18, 	k19, 	k1a, 	k1b, k1c, 	k1d}, \
//		{k20, k21, k22, k23, 	k24, 	k25, k26, 	k27, 	k28, 	k29, 	k2a, 	k2b, k2c, KC_NO}, \
//		{k30, k31, k32, k33, 	k34, 	k35, k36, 	k37, 	k38, 	k39, 	k3a, 	k3b, KC_NO, 	k3d}, \
//		{k40, KC_NO, k42, KC_NO, KC_NO,	KC_NO, 	k46, KC_NO, KC_NO, KC_NO,	KC_NO, 	k4b, 	KC_NO, 	k4d}  \
//}

Code: Select all

// This is the canonical layout file for the Quantum project. If you want to add another keyboard,
// this is the style you want to emulate.

#include "satan.h"

// Each layer gets a name for readability, which is then used in the keymap matrix below.
// The underscores don't mean anything - you can have a layer called STUFF or any other name.
// Layer names don't all need to be of the same length, obviously, and you can also skip them
// entirely and just use numbers.
#define _BW 0
#define _FL 1
// #define _MV 3

const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  /* Keymap _BW: (Base Windows) Windows Default Layer
   * ,-----------------------------------------------------------.
   * |Esc~| 1|  2|  3|  4|  5|  6|  7|  8|  9|  0|  -|  =|Backsp|Backsp (!!!NOTE!!! THE RIGHT MOST BUTTON ON THE SPLIT BS IS k49 on the grid (satan.h)!!|
   * |-----------------------------------------------------------|
   * |Tab  |  Q|  W|  E|  R|  T|  Y|  U|  I|  O|  P|  [|  ]|    \|
   * |-----------------------------------------------------------|
   * |CAPS/FL|  A|  S|  D|  F|  G|  H|  J|  K|  L|  ;|  '|Return |
   * |-----------------------------------------------------------|
   * |Shift|shift   |  Z|  X|  C|  V|  B|  N|  M|  ,|  .|  /|Shift  |Backlight step|
   * |-----------------------------------------------------------|
   * |Ctrl|Gui |Alt |      Space            |Alt |FN  |CTRL      |
   * `-----------------------------------------------------------'
   *
*/
[_BW] = KEYMAP(
  F(0),    KC_1,    KC_2,   KC_3,   KC_4,   KC_5,   KC_6,   KC_7,   KC_8,   KC_9,    KC_0,     KC_MINS,  KC_EQL,   KC_BSPC, \
  KC_TAB,  KC_Q,    KC_W,   KC_E,   KC_R,   KC_T,   KC_Y,   KC_U,   KC_I,   KC_O,    KC_P,     KC_LBRC,  KC_RBRC,  KC_ENT, \
  KC_TRNS, KC_A,    KC_S,   KC_D,   KC_F,   KC_G,   KC_H,   KC_J,   KC_K,   KC_L,    KC_SCLN,  KC_QUOT,  KC_BSLS, \
  KC_LSFT, KC_LSFT, KC_Z,   KC_X,   KC_C,   KC_V,   KC_B,   KC_N,   KC_M,   KC_COMM, KC_DOT,   KC_SLSH,  KC_RSFT, \
  KC_LCTL,          KC_LALT,                KC_SPC,                                                      KC_RALT,  MO(1) ),

  /* Keymap _FL: Function Layer
   * ,-----------------------------------------------------------.
   * |  `| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Delete |
   * |-----------------------------------------------------------|
   * |  |  |Up | f(1)|f(2)|f(3)|f(4)|f(5)|f(6)|f(7)|f(8)|BL_DEC|BL_INC|BL_TOGG|
   * |-----------------------------------------------------------|
   * |  |Lef|Dow|Rig|   |   |   |   |  |     |home| pgup|BL_STEP |
   * |-----------------------------------------------------------|
   * |   |    |    |  |  |  |  |   |   |   | end| pgdn |     |   |
   * |-----------------------------------------------------------|
   * |    |    |    |                              |     |   |   |
   * `-----------------------------------------------------------'
   */
 [_FL] = KEYMAP(
   KC_GRV,  KC_F1,   KC_F2,     KC_F3,    KC_F4,   KC_F5,   KC_F6,   KC_F7,   KC_F8,   KC_F9,     KC_F10,    KC_F11,    KC_F12,    KC_DEL,  \
   KC_TRNS, KC_TRNS, KC_UP,     F(1),     F(2),    F(3),    F(4),    F(5),    F(6),    F(7),      F(8),      BL_DEC,    BL_INC,    BL_TOGG, \
   KC_TRNS, KC_LEFT, KC_DOWN,   KC_RGHT,  KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,   KC_HOME,   KC_PGUP,   BL_STEP, \
   KC_TRNS, KC_TRNS, KC_TRNS,   KC_TRNS,  KC_TRNS, KC_TRNS, KC_TRNS, KC_VOLD, KC_VOLU, KC_MUTE,   KC_END,    KC_PGDN,     KC_TRNS, \
   KC_TRNS,          KC_TRNS,          KC_TRNS,                                                              KC_TRNS,      KC_TRNS),
 
};


enum function_id {
    SHIFT_ESC,
    RGBLED_TOGGLE,
    RGBLED_STEP_MODE,
    RGBLED_INCREASE_HUE,
    RGBLED_DECREASE_HUE,
    RGBLED_INCREASE_SAT,
    RGBLED_DECREASE_SAT,
    RGBLED_INCREASE_VAL,
    RGBLED_DECREASE_VAL,
};

const uint16_t PROGMEM fn_actions[] = {
  [0]  = ACTION_FUNCTION(SHIFT_ESC),
  [1]  = ACTION_FUNCTION(RGBLED_TOGGLE),
  [2]  = ACTION_FUNCTION(RGBLED_STEP_MODE),
  [3]  = ACTION_FUNCTION(RGBLED_INCREASE_HUE),
  [4]  = ACTION_FUNCTION(RGBLED_DECREASE_HUE),
  [5]  = ACTION_FUNCTION(RGBLED_INCREASE_SAT),
  [6]  = ACTION_FUNCTION(RGBLED_DECREASE_SAT),
  [7]  = ACTION_FUNCTION(RGBLED_INCREASE_VAL),
  [8]  = ACTION_FUNCTION(RGBLED_DECREASE_VAL),
//  [9]  = ACTION_LAYER_ON(_FL, ON_PRESS),
//  [10] = ACTION_LAYER_OFF(_FL, ON_PRESS),
//  [11] = ACTION_LAYER_TAP_KEY(_FL, KC_CAPS),
};

#define MODS_CTRL_MASK  (MOD_BIT(KC_LSHIFT)|MOD_BIT(KC_RSHIFT))
void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) {
  static uint8_t shift_esc_shift_mask;
  switch (id) {
    case SHIFT_ESC:
      shift_esc_shift_mask = get_mods()&MODS_CTRL_MASK;
      if (record->event.pressed) {
        if (shift_esc_shift_mask) {
          add_key(KC_GRV);
          send_keyboard_report();
        } else {
          add_key(KC_ESC);
          send_keyboard_report();
        }
      } else {
        if (shift_esc_shift_mask) {
          del_key(KC_GRV);
          send_keyboard_report();
        } else {
          del_key(KC_ESC);
          send_keyboard_report();
        }
      }
      break;
    case RGBLED_TOGGLE:
      //led operations
      if (record->event.pressed) {
        rgblight_toggle();
      }

      break;
    case RGBLED_INCREASE_HUE:
      if (record->event.pressed) {
        rgblight_increase_hue();
      }
      break;
    case RGBLED_DECREASE_HUE:
      if (record->event.pressed) {
        rgblight_decrease_hue();
      }
      break;
    case RGBLED_INCREASE_SAT:
      if (record->event.pressed) {
        rgblight_increase_sat();
      }
      break;
    case RGBLED_DECREASE_SAT:
      if (record->event.pressed) {
        rgblight_decrease_sat();
      }
      break;
      case RGBLED_INCREASE_VAL:
        if (record->event.pressed) {
          rgblight_increase_val();
        }
        break;
      case RGBLED_DECREASE_VAL:
        if (record->event.pressed) {
          rgblight_decrease_val();
        }
        break;
      case RGBLED_STEP_MODE:
        if (record->event.pressed) {
          rgblight_step();
        }
        break;
  }
}


const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
{
  // MACRODOWN only works in this function
      switch(id) {
        case 0:
          return (record->event.pressed ? MACRO( D(LSFT) ,T(H) , U(LSFT), T(E), T(L), T(L), T(O), END ) :MACRO( END ));
          break;
        case 1:
          return (record->event.pressed ? MACRO(D(LSFT),T(A),T(S),T(D),U(LSFT),T(F),T(G),T(H), END ) :MACRO( END ));
          break;
      }
    return MACRO_NONE;
};
Would be fine if somebody can help me.

hypkx
Chasing the Dream

17 Oct 2016, 11:37

Nobody have a clue? Could the controller be some kinf damaged or have I shortened something?

User avatar
Laser
emacs -nw

17 Oct 2016, 12:26

I'd just (re)start from the beginning - clone qmk in a new folder, go the satan folder, create a new keymap layout folder based on an existing one, tweak that and the makefile and so on (i.e. re-think it over) ... I have a Satan GH60 and I did that recently (in Arch Linux). I made a HHKB-like layout (to fit with the plate) - but I never had to modify `satan.h` (?)

EDIT: This may help (or not), anyway: workshop-f7/satan-gh60-keymap-configura ... 14700.html
Last edited by Laser on 17 Oct 2016, 12:47, edited 1 time in total.

hypkx
Chasing the Dream

17 Oct 2016, 12:29

Laser wrote: I'd just (re)start from the beginning - clone qmk in a new folder, go the satan folder, create a new keymap layout folder based on an existing one, tweak that and the makefile and so on (i.e. re-think it over) ... I have a Satan GH60 and I did that recently (in Arch Linux). I made a HHKB-like layout (to fit with the plate) - but I never had to modify `satan.h` (?)
I will try that, I thought I had to modify it to, but it is long time ago where did something like that, so maybe you're right, I will post results.

User avatar
Eszett

17 Oct 2016, 21:25

Hi! I have a question, how can I get KC_PWR or KC_POWER to take any effect? On my Windows 7 those scancodes do nothing. My PC meets the hardware requirements with ACPI, and ICH9+. With HID_listen I get these reports:
Attachments
2.jpg
2.jpg (64.62 KiB) Viewed 8634 times

User avatar
Laser
emacs -nw

17 Oct 2016, 21:29

What happens when you press the Power button on your computer (i.e. is Windows configured to actually do something)? KC_PWR should work on Windows, according to https://github.com/tmk/tmk_keyboard/wik ... oesnt-work (but you probably know that already).

User avatar
Eszett

17 Oct 2016, 21:42

Hi Laser. The physical Powerbutton on my PC shuts my OS (Win7) down. Yes, I've read that FAQ article, and according to HID_listen, KC_POWER does at least send a "keyboard_report", KC_PWR does not. According to the "USB HID usage table", the value "66" is correct: "0x66 Keyboard Power". However, my PC doesn't react to it.

User avatar
Laser
emacs -nw

17 Oct 2016, 22:51

What follows is just a supposition: your keyboard may not be allowed to shut down the computer - in the similar way a USB device (mouse, keyboard etc.) has to be allowed to "wake the computer" from sleep. This can be disabled/enabled at two levels, which should be checked (if supposition is true ...): in BIOS, and then at Windows keyboard driver - power management level (e.g. probably like here).

User avatar
hasu

18 Oct 2016, 01:56

In addition to what Laser pointed out you have to know KC_PWR is a system control key while KC_POWER is a normal keyboard key. System control keys and media control keys are called as 'extra keys' in TMK.

Unfortunately current tmk_core doesn't spit debug print for the system control keys, to see them on hid_listen apply this patch, you will find output like below. If you don't find it you should build with 'EXTRAKEY_ENABLE'.
system: 0081
system: 0000

Code: Select all

diff --git a/tmk_core/common/host.c b/tmk_core/common/host.c
index e9b7916..e1fa52d 100644
--- a/tmk_core/common/host.c
+++ b/tmk_core/common/host.c
@@ -54,7 +54,7 @@ void host_keyboard_send(report_keyboard_t *report)
     (*driver->send_keyboard)(report);
 
     if (debug_keyboard) {
-        dprint("keyboard_report: ");
+        dprint("keyboard: ");
         for (uint8_t i = 0; i < KEYBOARD_REPORT_SIZE; i++) {
             dprintf("%02X ", report->raw[i]);
         }
@@ -75,6 +75,10 @@ void host_system_send(uint16_t report)
 
     if (!driver) return;
     (*driver->send_system)(report);
+
+    if (debug_keyboard) {
+        dprintf("system: %04X\n", report);
+    }
 }
 
 void host_consumer_send(uint16_t report)
@@ -84,6 +88,10 @@ void host_consumer_send(uint16_t report)
 
     if (!driver) return;
     (*driver->send_consumer)(report);
+
+    if (debug_keyboard) {
+        dprintf("consumer: %04X\n", report);
+    }
 }
 
 uint16_t host_last_sysytem_report(void)

User avatar
Eszett

18 Oct 2016, 06:37

Hi Laser. It seems to me that In the properties of "USB Root Hub" or "HID conform Device" (I hope I translated it correctly to it's english naming) I can control if the Compuer may turn off the device to save power, but I can't control if the Devices may shut down the Computer. In BIOS I found indeed a setting, that prevented the keyboard from shutting down the Computer. I changed the setting properly, but unfortunately, the scancodes still don't work :-(

User avatar
Eszett

18 Oct 2016, 06:54

Hi hasu. I've applied your patch, and indeed, HID listen reports 0081 and 0000 as the "system codes". So far, so good. That means, the scancodes are sent properly, just my system ignores them, right? So it isn't actually a problem of the firmware of the keyboard ...

User avatar
hasu

18 Oct 2016, 10:40

Then, it may be worth checking this FAQ entry. Windows can cache device driver setting wrongly and you have to clear it manually in some situations.
https://github.com/tmk/tmk_keyboard/wik ... not-change

User avatar
Laser
emacs -nw

18 Oct 2016, 11:47

Eszett wrote: Hi Laser. It seems to me that In the properties of "USB Root Hub" or "HID conform Device" (I hope I translated it correctly to it's english naming) I can control if the Compuer may turn off the device to save power, but I can't control if the Devices may shut down the Computer. In BIOS I found indeed a setting, that prevented the keyboard from shutting down the Computer. I changed the setting properly, but unfortunately, the scancodes still don't work :-(
You'll (probably!) have to change that BIOS setting which, after you boot again/afterwards into Windows, finally allows you to control if the Devices may shut down the Computer, *and* also change that (so, 2 settings, one in BIOS, one in Windows). It may be the BIOS setting you found, or another one, in the lines of "Wake up on ...".

User avatar
Eszett

18 Oct 2016, 23:28

@hasu Hm, I don't see how this would solve the issue..
@Laser There is no checkbox "Device may shutdown computer", not even after I've changed the BIOS settings.

ibandreas

20 Oct 2016, 18:13

Thanks so much for providing this tutorial. I am reverse engineering the keyboard on an old Minitel device which has 16 pins and have an 8X8 grid where pressing the key closes the connection between row x and col y. I cant really peer inside without breaking the keyboard - I dont think there are any diodes and I think they are simply switches directly wired to the output pins in a matrix which I have solved for. I didnt hook anything up to the led pin and actually i didnt use or alter the led.c file at all nor hook up any leds to any pins which I hope is optional.

I was able to follow all of the instrutions and make the gh60_lufa.hex file and write it to the Teensy 2 ++. At least I think so. The log showed downloading file... compete. But after this nothing happens. I am expecting the keyboard to immediately start working but it doesnt seem to be recognized at all by my mac. Pressing keys does nothing.

Looking forward to any guidance you can give me on this. Im hoping there is some kind of logic missing for this particular kind of direct link keyboard wiring scheme.

Attached are all of my gh60 modified files.
Attachments
Archive.zip
(255.48 KiB) Downloaded 190 times

ibandreas

21 Oct 2016, 10:07

And heres a picture of the keyboard I am trying to bring back to life.
Attachments
Minitel keys
Minitel keys
Minitel keys.png (997.62 KiB) Viewed 8486 times

User avatar
dorf

27 Oct 2016, 19:09

Can someone help me?
I'm having trouble getting all keys working as I want them to. PCB is GH60 rev.c from Falbatech

Column 3 and 11 are not working at all. Right shift is not working but FN works as right shift.

Keyboard layout.
Image

keymap_common.h

Code: Select all

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

Code: Select all

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

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

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

Code: Select all

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

Andster29

29 Oct 2016, 21:55

I have been trying to compile the firmware for a while not. I can not seem to get it to work no matter what I try. Here is my gh60 file with all the modifications I made to pin out. Could somebody be kind enough to compile it for me?

https://drive.google.com/open?id=0B3a7z ... XByNXItRUE

Post Reply

Return to “Workshop”