How to build your very own keyboard firmware
-
- Location: China
- Main keyboard: xd75,amj60,cospad,xd96,staryu
- Main mouse: anker
- Favorite switch: red
- DT Pro Member: -
I do not use Atmel's MCU to design my keyboard,I use the STC15W4K32S MCU.So,can I use the QMK firmware?How should I alter it?My programme's ability is very very bad.Who can help me?The STC15W4K32S is 89C51 series's MCU.
- Quartz64
- Location: Russia
- Main keyboard: Kinesis Contoured (Kailh Box Black, Koala)
- Main mouse: Elecom Huge
- Favorite switch: Durock Koala
- DT Pro Member: 0253
- Contact:
TMK and QMK support AVR MCUs and some ARM MCUs via ChibiOS.
I can't find any specs of STC15W4K32S, but you say that it is compatible with Atmel 89C51. It's a different architecture (Intel 8051) and it has only 4KB of internal flash which makes it impossible to port QMK on it even if you have the required exprerience.
-
- Location: Australia
- DT Pro Member: -
Hi, can some help with the layering. The file compiles if I don't put anything in the PROGMEM fn_actions function. But if I try to add some layer action. I get the same 4 errors on each line
warning: (near initialization for 'fn_action[0]')
error: field name not in record or union initializer
error:(near initialization for 'fn_action[0]')
warning: braces around scalar initializer
I don't know if anything is wrong with the code inside the function, because I pretty much just copy pasted it.
{
[0] = ACTION_LAYER_TOGGLE(0),
[1] = ACTION_LAYER_TOGGLE(1),
[2] = ACTION_LAYER_TOGGLE(2)
};
warning: (near initialization for 'fn_action[0]')
error: field name not in record or union initializer
error:(near initialization for 'fn_action[0]')
warning: braces around scalar initializer
I don't know if anything is wrong with the code inside the function, because I pretty much just copy pasted it.
{
[0] = ACTION_LAYER_TOGGLE(0),
[1] = ACTION_LAYER_TOGGLE(1),
[2] = ACTION_LAYER_TOGGLE(2)
};
-
- Location: land of the rusty beamsprings
- DT Pro Member: -
maybe this has some information: https://github.com/tmk/tmk_keyboard/issues/378
-
- Location: United Arab Emirates
- DT Pro Member: -
Okay, so I've been working on the code for a numpad project I've been doing for a while now and I finished. I've compiled everything and ran the firmware properly. My only issue that it seems like my code is either totally incorrect or I did my wiring improperly. Only the key I assigned as PAUS works and it writes the whole row that is above it. I'm a total newbie and this is the first time I do anything related to coding so expect a lot of dumb mistakes. UPDATE So I've fixed an issue that I had in the matrix coding and now I'm sure it's all correct. My issue is, the same key I mentioned earlier functions and nothing else does. I think my issue is wiring, does anyone else think the same?
Spoiler:
Spoiler:
Spoiler:
Spoiler:
-
- DT Pro Member: -
was able to fix some errors still need some help here are current error codestrey1901 wrote: 12 Jan 2019, 03:03 Was wondering if i could get some help trying to compile getting this error messageKeymap_poker.cSpoiler:Keymap_common fileSpoiler:and the matrix fileSpoiler:First time trying this out could really use some hints or help! thanks in advance!Spoiler:
Spoiler:
Spoiler:
Spoiler:
Spoiler:
- tentator
- Location: ZH, CH
- Main keyboard: MX blue tentboard
- Main mouse: Pointing Stick
- Favorite switch: Cherry MX Blue and Model F BS
- DT Pro Member: -
I bet you are missing a , there in keymap_common.h and maybe even a closed } .. try to start over from the working example maybe and watch out not to remove the , and { () } structure..
kr, tent
kr, tent
-
- DT Pro Member: -
thanks i was able to get it to compile but im just getting random strings of letters from only certain keys, i may need to go back and do some wiring with solid core wire? not sure ill try that and see if i get better results thanks for the help.tentator wrote: 12 Jan 2019, 23:16 I bet you are missing a , there in keymap_common.h and maybe even a closed } .. try to start over from the working example maybe and watch out not to remove the , and { () } structure..
kr, tent
-
- Location: Serbia Belgrade
- Main keyboard: Dactyl Mauform 5x6
Hello all, just stuck on this error while building fw, anyone can help or tell me what i did wrong.
Keymap : https://pastebin.com/4a5dKe48
Keymap Comm : https://pastebin.com/BrTv5U5y
Config : https://pastebin.com/k7qjEPmp
Matrix : https://pastebin.com/pH3KC2nx
Makefile : https://pastebin.com/8vcY5qs5
Error :
Keymap : https://pastebin.com/4a5dKe48
Keymap Comm : https://pastebin.com/BrTv5U5y
Config : https://pastebin.com/k7qjEPmp
Matrix : https://pastebin.com/pH3KC2nx
Makefile : https://pastebin.com/8vcY5qs5
Error :
Spoiler:
- softservejazmine
- Location: United States
- Main keyboard: OLKB|Gateron Red
- Main mouse: Razer Basilisk
- Favorite switch: Gateron Reds
Hi, I'm having an issue compiling. When I try to compile it says this:
mkdir -p obj_gh60_lufa
Compiling C: keymap_poker.c
avr-gcc -c -mmcu=atmega32u4 -gdwarf-2 -DF_CPU=16000000UL -DINTERRUPT_CONTROL_ENDPOINT -DBOOTLOADER_SIZE=4096 -DF_USB=16000000UL -DARCH=ARCH_AVR8 -DUSB_DEVICE_ONLY -DUSE_FLASH_DESCRIPTORS -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)" -DFIXED_CONTROL_ENDPOINT_SIZE=8 -DFIXED_NUM_CONFIGURATIONS=1 -DPROTOCOL_LUFA -DBOOTMAGIC_ENABLE -DMOUSEKEY_ENABLE -DMOUSE_ENABLE -DEXTRAKEY_ENABLE -DCONSOLE_ENABLE -DCOMMAND_ENABLE -DNKRO_ENABLE -DVERSION=unknown -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_gh60_lufa/keymap_poker.lst -I. -I../../tmk_core -I../../tmk_core/protocol/lufa -I../../tmk_core/protocol/lufa/LUFA-git -I../../tmk_core/common -std=gnu99 -include config.h -MMD -MP -MF .dep/obj_gh60_lufa_keymap_poker.o.d keymap_poker.c -o obj_gh60_lufa/keymap_poker.o
In file included from keymap_common.h:20:0,
from keymap_poker.c:1:
/usr/lib/gcc/avr/5.4.0/include/stdint.h:9:26: fatal error: stdint.h: No such file or directory
compilation terminated.
Any help would be greatly appreciated!
Edit: I'm stupid. Didn't install all the libs I needed. Oof.
mkdir -p obj_gh60_lufa
Compiling C: keymap_poker.c
avr-gcc -c -mmcu=atmega32u4 -gdwarf-2 -DF_CPU=16000000UL -DINTERRUPT_CONTROL_ENDPOINT -DBOOTLOADER_SIZE=4096 -DF_USB=16000000UL -DARCH=ARCH_AVR8 -DUSB_DEVICE_ONLY -DUSE_FLASH_DESCRIPTORS -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)" -DFIXED_CONTROL_ENDPOINT_SIZE=8 -DFIXED_NUM_CONFIGURATIONS=1 -DPROTOCOL_LUFA -DBOOTMAGIC_ENABLE -DMOUSEKEY_ENABLE -DMOUSE_ENABLE -DEXTRAKEY_ENABLE -DCONSOLE_ENABLE -DCOMMAND_ENABLE -DNKRO_ENABLE -DVERSION=unknown -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_gh60_lufa/keymap_poker.lst -I. -I../../tmk_core -I../../tmk_core/protocol/lufa -I../../tmk_core/protocol/lufa/LUFA-git -I../../tmk_core/common -std=gnu99 -include config.h -MMD -MP -MF .dep/obj_gh60_lufa_keymap_poker.o.d keymap_poker.c -o obj_gh60_lufa/keymap_poker.o
In file included from keymap_common.h:20:0,
from keymap_poker.c:1:
/usr/lib/gcc/avr/5.4.0/include/stdint.h:9:26: fatal error: stdint.h: No such file or directory
compilation terminated.
Any help would be greatly appreciated!
Edit: I'm stupid. Didn't install all the libs I needed. Oof.
Hello
I have been using the tutorial in this topic to configure a keyboard I built, I found it very well documented and it helped a lot.
However I have a strange issue now that I loaded it in the teensy I used in my keyboard,
The 4 first rows work perfectly but the lower ones act weird, when I type Z, X, C and so on I get something like &AQW
I checked the wiring and all seems good with no apparent shorts
Please tell me if you have an idea as to what happens and if I need to upload info to help solve this.
I will still try to find the solution myself but I would greatly appreciate it if one of you can help
And besides tell me if I have to make a presentation of myself on the forum and I will gladly do it
Thanks in advance
I have been using the tutorial in this topic to configure a keyboard I built, I found it very well documented and it helped a lot.
However I have a strange issue now that I loaded it in the teensy I used in my keyboard,
The 4 first rows work perfectly but the lower ones act weird, when I type Z, X, C and so on I get something like &AQW
I checked the wiring and all seems good with no apparent shorts
Please tell me if you have an idea as to what happens and if I need to upload info to help solve this.
I will still try to find the solution myself but I would greatly appreciate it if one of you can help
And besides tell me if I have to make a presentation of myself on the forum and I will gladly do it
![Wink ;)](./images/smilies/icon_e_wink.gif)
Thanks in advance
- snacksthecat
- ✶✶✶✶
- Location: USA
- Main keyboard: SSK
- Main mouse: BenQ ZOWIE EC1-A
- DT Pro Member: 0205
- Contact:
Could you please post your files? I can take a look and see if anything jumps out at me.tackleberry wrote: 19 May 2019, 19:36 Hello
I have been using the tutorial in this topic to configure a keyboard I built, I found it very well documented and it helped a lot.
However I have a strange issue now that I loaded it in the teensy I used in my keyboard,
The 4 first rows work perfectly but the lower ones act weird, when I type Z, X, C and so on I get something like &AQW
I checked the wiring and all seems good with no apparent shorts
Please tell me if you have an idea as to what happens and if I need to upload info to help solve this.
I will still try to find the solution myself but I would greatly appreciate it if one of you can help
And besides tell me if I have to make a presentation of myself on the forum and I will gladly do it![]()
Thanks in advance
Thanks a lot,
Matrix.c :
config.h :
keymap_common.h :
keymap_poker.c :
Makefile :
I think that's it
I use tmk, and I modified the GH60 in order to do this
Matrix.c :
Code: Select all
/*
* 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);
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;
}
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: B7 D0 D1 D2 D3 D4 D5 C0 C1 C2 C3 C4 C5 C6
*/
static void init_cols(void)
{
// Input with pull-up(DDR:0, PORT:1)
DDRB &= ~(1<<7);
PORTB |= (1<<7);
DDRD &= ~(1<<5 | 1<<4 | 1<<3 | 1<<2 | 1<<1 | 1<<0);
PORTD |= (1<<5 | 1<<4 | 1<<3 | 1<<2 | 1<<1 | 1<<0);
DDRC &= ~(1<<6 | 1<<5 | 1<<4 | 1<<3 | 1<<2 | 1<<1 | 1<<0);
PORTC |= (1<<6 | 1<<5 | 1<<4 | 1<<3 | 1<<2 | 1<<1 | 1<<0);
}
static matrix_row_t read_cols(void)
{
return (PINB&(1<<7) ? 0 : (1<<0)) |
(PIND&(1<<0) ? 0 : (1<<1)) |
(PIND&(1<<1) ? 0 : (1<<2)) |
(PIND&(1<<2) ? 0 : (1<<3)) |
(PIND&(1<<3) ? 0 : (1<<4)) |
(PIND&(1<<4) ? 0 : (1<<5)) |
(PIND&(1<<5) ? 0 : (1<<6)) |
(PINC&(1<<0) ? 0 : (1<<7)) |
(PINC&(1<<1) ? 0 : (1<<8)) |
(PINC&(1<<2) ? 0 : (1<<9)) |
(PINC&(1<<3) ? 0 : (1<<10)) |
(PINC&(1<<4) ? 0 : (1<<11)) |
(PINC&(1<<5) ? 0 : (1<<12)) |
(PINC&(1<<6) ? 0 : (1<<13));
}
/* Row pin configuration
* row: 0 1 2 3 4 5 7
* pin: F0 F1 F2 F3 F4 F5 F6
*/
static void unselect_rows(void)
{
// Hi-Z(DDR:0, PORT:0) to unselect
DDRF &= ~0b00101111;
PORTF &= ~0b00101111;
}
static void select_row(uint8_t row)
{
// Output low(DDR:1, PORT:0) to select
switch (row) {
case 0:
DDRF |= (1<<0);
PORTF &= ~(1<<0);
break;
case 1:
DDRF |= (1<<1);
PORTF &= ~(1<<1);
break;
case 2:
DDRF |= (1<<2);
PORTF &= ~(1<<2);
break;
case 3:
DDRF |= (1<<3);
PORTF &= ~(1<<3);
break;
case 4:
DDRF |= (1<<4);
PORTF &= ~(1<<4);
break;
case 5:
DDRF |= (1<<5);
PORTF &= ~(1<<5);
break;
case 6:
DDRF |= (1<<6);
PORTF &= ~(1<<6);
break;
}
}
Code: Select all
#ifndef CONFIG_H
#define CONFIG_H
/* USB Device descriptor parameter */
#define VENDOR_ID 0xFEED
#define PRODUCT_ID 0x6060
#define DEVICE_VER 0x0001
#define MANUFACTURER geekhack
#define PRODUCT GH60
#define DESCRIPTION t.m.k. keyboard firmware for GH60
/* key matrix size */
#define MATRIX_ROWS 7
#define MATRIX_COLS 14
/* define if matrix has ghost */
//#define MATRIX_HAS_GHOST
/* Set 0 if debouncing isn't needed */
#define DEBOUNCE 5
/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */
#define LOCKING_SUPPORT_ENABLE
/* Locking resynchronize hack */
#define LOCKING_RESYNC_ENABLE
/* key combination for command */
#define IS_COMMAND() ( \
keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \
)
/*
* Feature disable options
* These options are also useful to firmware size reduction.
*/
/* disable debug print */
//#define NO_DEBUG
/* disable print */
//#define NO_PRINT
/* disable action features */
//#define NO_ACTION_LAYER
//#define NO_ACTION_TAPPING
//#define NO_ACTION_ONESHOT
//#define NO_ACTION_MACRO
//#define NO_ACTION_FUNCTION
#endif
Code: Select all
#ifndef KEYMAP_COMMON_H
#define KEYMAP_COMMON_H
#include <stdint.h>
#include <stdbool.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"
/* GH60 keymap definition macro
* K2C, K31 and K3C are extra keys for ISO
*/
#define KEYMAP_ANSI( \
K00, K0C, \
K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, \
K20, K21, K22, K23, K24, K25, K27, K28, K29, K2A, K2B, K2C, K2D, \
K30, K31, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3C, K3D, \
K41, K42, K43, K44, K45, K47, K48, K49, K4A, K4B, K4C, \
K50, K52, K54, K56, K57, K59, K5A, K5B, K5C, K5D, \
K60, K61 , K63, K6A, K6B, K6C \
) { \
{ KC_##K00, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_##K0C, KC_NO }, \
{ KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17, KC_##K18, KC_##K19, KC_##K1A, KC_##K1B, KC_##K1C, KC_##K1D }, \
{ KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_NO, 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_NO, KC_##K41, KC_##K42, KC_##K43, KC_##K44, KC_##K45, KC_NO, KC_##K47, KC_##K48, KC_##K49, KC_##K4A, KC_##K4B, KC_##K4C, KC_NO }, \
{ KC_##K50, KC_NO, KC_##K52, KC_NO, KC_##K54, KC_NO, KC_##K56, KC_##K57, KC_NO, KC_##K59, KC_##K5A, KC_##K5B, KC_##K5C, KC_##K5D }, \
{ KC_##K60, KC_##K61, KC_NO, KC_##K63, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_##K6A, KC_##K6B, KC_##K6C, KC_NO } \
}
#define KEYMAP_HHKB( \
K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D, K49,\
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, K2D, \
K30, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3D, K3C, \
K40, K41, K42, K45, K4A, K4B, K4C, K4D \
) 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, NO, K2D, \
K30, NO, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3C, K3D, \
K40, K41, K42, K45, K49, K4A, K4B, K4C, K4D \
)
#endif
Code: Select all
#include "keymap_common.h"
const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
/* 0: qwerty */
KEYMAP_ANSI(
ESC, BSPC ,\
HOME, 1, 2, 3, 4, 5, DEL, 6, 7, 8, 9, 0, MINS, EQL ,\
TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC, RBRC ,\
LSFT, A, S, D, F, G, ENT, H, J, K, L, SCLN, QUOT, RSFT ,\
Z, X, C, V, B, N, M, COMM, DOT, SLSH, BSLS ,\
LCTL, LALT, F5, QUOT, SPC, RALT, PGUP, UP, PGDN, RCTL ,\
CAPS, FN0, F2, LEFT, DOWN, RGHT \
),
/* 1: FN 1 */
KEYMAP_ANSI(
TRNS, TRNS ,\
TRNS, F1, F2, F3, F4, F5, INS, F6, F7, F8, F9, F10, F11, F12 ,\
TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, KP_PLUS, 7, 8, 9, WAKE, TRNS ,\
TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, ENT , TRNS, MINS, 4, 5, 6, SLEP, TRNS ,\
CUT , COPY, PASTE, TRNS, TRNS, TRNS, SLSH, 1, 2, 3, PSCR ,\
TRNS, TRNS, TRNS, TRNS, BSLS, KP_ASTERISK,0, DOT, COMMA,TRNS ,\
TRNS, TRNS, TRNS, TRNS, TRNS, TRNS \
),
};
//const uint16_t PROGMEM fn_actions[] = {
const action_t PROGMEM fn_actions[] = {
[0] = ACTION_LAYER_MOMENTARY(1)//,
//[1] = ACTION_LAYER_TAP_KEY(0, KC_ESC),
//[2] = ACTION_LAYER_TOGGLE(1)
};
Code: Select all
# Target file name (without extension).
TARGET = gh60_lufa
# Directory common source filess exist
TMK_DIR = ../../tmk_core
# Directory keyboard dependent files exist
TARGET_DIR = .
# project specific files
SRC = matrix.c \
led.c
ifdef KEYMAP
SRC := keymap_$(KEYMAP).c $(SRC)
else
SRC := keymap_poker.c $(SRC)
endif
CONFIG_H = config.h
# MCU name
MCU = at90usb1287
#MCU = atmega32u4
# Processor frequency.
# This will define a symbol, F_CPU, in all source code files equal to the
# processor frequency in Hz. You can then use this symbol in your source code to
# calculate timings. Do NOT tack on a 'UL' at the end, this will be done
# automatically to create a 32-bit value in your source code.
#
# This will be an integer division of F_USB below, as it is sourced by
# F_USB after it has run through any CPU prescalers. Note that this value
# does not *change* the processor frequency - it should merely be updated to
# reflect the processor speed set externally so that the code can use accurate
# software delays.
F_CPU = 16000000
#
# LUFA specific
#
# Target architecture (see library "Board Types" documentation).
ARCH = AVR8
# Input clock frequency.
# This will define a symbol, F_USB, in all source code files equal to the
# input clock frequency (before any prescaling is performed) in Hz. This value may
# differ from F_CPU if prescaling is used on the latter, and is required as the
# raw input clock is fed directly to the PLL sections of the AVR for high speed
# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
# at the end, this will be done automatically to create a 32-bit value in your
# source code.
#
# If no clock division is performed on the input clock inside the AVR (via the
# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
F_USB = $(F_CPU)
# Interrupt driven control endpoint task(+60)
OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT
# Boot Section Size in *bytes*
# Teensy halfKay 512
# Teensy++ halfKay 1024
# Atmel DFU loader 4096
# LUFA bootloader 4096
# USBaspLoader 2048
OPT_DEFS += -DBOOTLOADER_SIZE=4096
# Build Options
# comment out to disable the options.
#
BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000)
MOUSEKEY_ENABLE = yes # Mouse keys(+4700)
EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
CONSOLE_ENABLE = yes # Console for debug(+400)
COMMAND_ENABLE = yes # Commands for debug and configuration
#SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend
#NKRO_ENABLE = yes # USB Nkey Rollover
# Optimize size but this may cause error "relocation truncated to fit"
#EXTRALDFLAGS = -Wl,--relax
# Search Path
VPATH += $(TARGET_DIR)
VPATH += $(TMK_DIR)
include $(TMK_DIR)/protocol/lufa.mk
include $(TMK_DIR)/common.mk
include $(TMK_DIR)/rules.mk
I use tmk, and I modified the GH60 in order to do this
- snacksthecat
- ✶✶✶✶
- Location: USA
- Main keyboard: SSK
- Main mouse: BenQ ZOWIE EC1-A
- DT Pro Member: 0205
- Contact:
Not sure if this is your exact problem but it is one issue. The rows setup you have is this:
but should be like this:
Code: Select all
/* Row pin configuration
* row: 0 1 2 3 4 5 7
* pin: F0 F1 F2 F3 F4 F5 F6
*/
static void unselect_rows(void)
{
// Hi-Z(DDR:0, PORT:0) to unselect
DDRF &= ~0b00101111;
PORTF &= ~0b00101111;
}
Code: Select all
/* Row pin configuration
* row: 0 1 2 3 4 5 7
* pin: F0 F1 F2 F3 F4 F5 F6
*/
static void unselect_rows(void)
{
// Hi-Z(DDR:0, PORT:0) to unselect
DDRF &= ~0b01111111;
PORTF &= ~0b01111111;
}
Well done, this has solved the issue, all the keys work perfectly. Thank you
There is one last thing I have to fix: the FN key does not work, but I am not sure of what I wrote about this part
![Very Happy :D](./images/smilies/icon_e_biggrin.gif)
There is one last thing I have to fix: the FN key does not work, but I am not sure of what I wrote about this part
-
- Location: Ireland
- Main keyboard: Working on it
- Main mouse: Logitech MX Vertical
- Favorite switch: Still deciding
-- EDIT: I already figured this out with the help of Hasu on GitHub --
Hello! I know I'm getting quite late to this thread but I wanted to check in and see if I can get some help.
I'm having trouble compiling, I'm getting the following message:
../../tmk_core/protocol/lufa.mk:12: *** LUFA may be too old or not found: try 'git submodule update --init'. Stop.
I've been researching why this is happening for a few days now and I can't make any progress. I'm really new to this, it's the first time I'm using the terminal (besides copying and pasting some stuff sporadically) and I'm just starting to learn programming. I'm learning a lot but it is quite frustrating too.
I've obviously followed the steps of the tutorial very carefully. I'm running MacOs 10.15.4 and I have tried installing Mojave on another partition too, but I get the same error. I tried to use Ubuntu on VirtualBox but I can't get that to work, it freezes all the time.
Thanks for putting such a complete tutorial together by the way!
Hello! I know I'm getting quite late to this thread but I wanted to check in and see if I can get some help.
I'm having trouble compiling, I'm getting the following message:
../../tmk_core/protocol/lufa.mk:12: *** LUFA may be too old or not found: try 'git submodule update --init'. Stop.
I've been researching why this is happening for a few days now and I can't make any progress. I'm really new to this, it's the first time I'm using the terminal (besides copying and pasting some stuff sporadically) and I'm just starting to learn programming. I'm learning a lot but it is quite frustrating too.
I've obviously followed the steps of the tutorial very carefully. I'm running MacOs 10.15.4 and I have tried installing Mojave on another partition too, but I get the same error. I tried to use Ubuntu on VirtualBox but I can't get that to work, it freezes all the time.
Thanks for putting such a complete tutorial together by the way!
Dude
you must use OLDER https://github.com/tmk/tmk_core
Then it works flawlessly.
Also be sure you use
sudo apt-get install build-essential
sudo apt-get install gcc-avr avr-libc avrdude
you must use OLDER https://github.com/tmk/tmk_core
Then it works flawlessly.
Also be sure you use
sudo apt-get install build-essential
sudo apt-get install gcc-avr avr-libc avrdude
-
- Location: sp
- Main keyboard: g413
- Main mouse: g203
- Favorite switch: brown
Edit: Don't ignore LED's pin if you are not using it
haha, working!
Hi!
I may be late on this post too, but i'm trying and it compiled ok, but it presses random keys in the moment i connect it. Teensy is not soldered to any cable, so no shorts possible.
If someone could check would be great!:
keymap_common.h
Makefile:
matrix.c:
keymap_poker.c:
Thanks!
![Wink ;)](./images/smilies/icon_e_wink.gif)
Hi!
I may be late on this post too, but i'm trying and it compiled ok, but it presses random keys in the moment i connect it. Teensy is not soldered to any cable, so no shorts possible.
If someone could check would be great!:
keymap_common.h
Code: Select all
/*
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 "keycode.h"
#include "action.h"
#include "action_macro.h"
#include "report.h"
#include "host.h"
#include "print.h"
#include "debug.h"
#include "keymap.h"
/* 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, \
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, K2D, \
K30, K31, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3D, \
K40, K41, K42, K45, K49, K4A, 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_##K1D }, \
{ KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_##K27, KC_##K28, KC_##K29, KC_##K2A, KC_##K2B, KC_NO, 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_NO, KC_##K3D }, \
{ KC_##K40, KC_##K41, KC_##K42, KC_NO, KC_NO, KC_##K45, KC_NO, KC_NO, KC_NO, KC_##K49, KC_##K4A, KC_NO, KC_##K4C, KC_##K4D } \
}
/* ANSI variant. No extra keys for ISO */
#define KEYMAP_ANSI( \
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, K2D, \
K30, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3D, \
K40, K41, K42, K45, K4A, K4B, K4C, K4D \
) 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, NO, K2D, \
K30, NO, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, NO, K3D, \
K40, K41, K42, K45, NO, K4A, K4B, K4C, K4D \
)
#define KEYMAP_HHKB( \
K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D, K49,\
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, K2D, \
K30, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3D, K3C, \
K40, K41, K42, K45, K4A, K4B, K4C, K4D \
) 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, NO, K2D, \
K30, NO, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3C, K3D, \
K40, K41, K42, K45, K49, K4A, K4B, K4C, K4D \
)
#endif
Code: Select all
# Target file name (without extension).
TARGET = gh60_lufa
# Directory common source filess exist
TMK_DIR = ../../tmk_core
# Directory keyboard dependent files exist
TARGET_DIR = .
# project specific files
SRC = matrix.c \
led.c
ifdef KEYMAP
SRC := keymap_$(KEYMAP).c $(SRC)
else
SRC := keymap_poker.c $(SRC)
endif
CONFIG_H = config.h
# MCU name
#MCU = at90usb1287
MCU = atmega32u4
# Processor frequency.
# This will define a symbol, F_CPU, in all source code files equal to the
# processor frequency in Hz. You can then use this symbol in your source code to
# calculate timings. Do NOT tack on a 'UL' at the end, this will be done
# automatically to create a 32-bit value in your source code.
#
# This will be an integer division of F_USB below, as it is sourced by
# F_USB after it has run through any CPU prescalers. Note that this value
# does not *change* the processor frequency - it should merely be updated to
# reflect the processor speed set externally so that the code can use accurate
# software delays.
F_CPU = 16000000
#
# LUFA specific
#
# Target architecture (see library "Board Types" documentation).
ARCH = AVR8
# Input clock frequency.
# This will define a symbol, F_USB, in all source code files equal to the
# input clock frequency (before any prescaling is performed) in Hz. This value may
# differ from F_CPU if prescaling is used on the latter, and is required as the
# raw input clock is fed directly to the PLL sections of the AVR for high speed
# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
# at the end, this will be done automatically to create a 32-bit value in your
# source code.
#
# If no clock division is performed on the input clock inside the AVR (via the
# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
F_USB = $(F_CPU)
# Interrupt driven control endpoint task(+60)
OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT
# Boot Section Size in *bytes*
# Teensy halfKay 512
# Teensy++ halfKay 1024
# Atmel DFU loader 4096
# LUFA bootloader 4096
# USBaspLoader 2048
OPT_DEFS += -DBOOTLOADER_SIZE=4096
# Build Options
# comment out to disable the options.
#
BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000)
MOUSEKEY_ENABLE = yes # Mouse keys(+4700)
EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
CONSOLE_ENABLE = yes # Console for debug(+400)
COMMAND_ENABLE = yes # Commands for debug and configuration
#SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend
NKRO_ENABLE = yes # USB Nkey Rollover
# Optimize size but this may cause error "relocation truncated to fit"
#EXTRALDFLAGS = -Wl,--relax
# Search Path
VPATH += $(TARGET_DIR)
VPATH += $(TMK_DIR)
include $(TMK_DIR)/protocol/lufa.mk
include $(TMK_DIR)/common.mk
include $(TMK_DIR)/rules.mk
Code: Select all
*/
/*
* 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 "timer.h"
#include "matrix.h"
#ifndef DEBOUNCE
# define DEBOUNCE 5
#endif
static bool debouncing = false;
static uint16_t debouncing_time = 0;
/* 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);
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(1); // delay for settling
matrix_row_t cols = read_cols();
if (matrix_debouncing[i] != cols) {
if (debouncing) {
dprintf("bounce: %d %d@%02X\n", timer_elapsed(debouncing_time), i, matrix_debouncing[i]^cols);
}
matrix_debouncing[i] = cols;
debouncing = true;
debouncing_time = timer_read();
}
unselect_rows();
}
if (debouncing && timer_elapsed(debouncing_time) >= DEBOUNCE) {
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
matrix[i] = matrix_debouncing[i];
}
debouncing = false;
}
return 1;
}
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: F7 B6 B5 B4 D7 C7 C6 D3 D2 D1 D0 B7 B3 B2 (Rev.A)
* pin: B7 (Rev.B)
*/
static void init_cols(void)
{
// Input with pull-up(DDR:0, PORT:1)
DDRF &= ~(1<<7);
PORTF |= (1<<7);
DDRD &= ~(1<<7 | 1<<0 | 1<<1 | 1<<2 | 1<<3);
PORTD |= (1<<7 | 1<<0 | 1<<1 | 1<<2 | 1<<3);
DDRC &= ~(1<<7 | 1<<6);
PORTC |= (1<<7 | 1<<6);
DDRB &= ~(1<<7 | 1<<6 | 1<< 5 | 1<<4 | 1<<3 | 1<<2);
PORTB |= (1<<7 | 1<<6 | 1<< 5 | 1<<4 | 1<<3 | 1<<2);
}
/* Column pin configuration
* col: 0 1 2 3 4 5 6 7 8 9 10 11 12 13
* pin: F7 B6 B5 B4 D7 C7 C6 D3 D2 D1 D0 B7 B3 B2 (Rev.A)
* pin: B7 (Rev.B)
*/
static matrix_row_t read_cols(void)
{
return (PINF&(1<<7) ? 0 : (1<<0)) |
(PINB&(1<<6) ? 0 : (1<<1)) |
(PINB&(1<<5) ? 0 : (1<<2)) |
(PINB&(1<<4) ? 0 : (1<<3)) |
(PIND&(1<<7) ? 0 : (1<<4)) |
(PINC&(1<<7) ? 0 : (1<<5)) |
(PINC&(1<<6) ? 0 : (1<<6)) |
(PIND&(1<<3) ? 0 : (1<<7)) |
(PIND&(1<<2) ? 0 : (1<<8)) | // Rev.A and B
(PIND&(1<<1) ? 0 : (1<<9)) |
(PIND&(1<<0) ? 0 : (1<<10)) |
(PINB&(1<<7) ? 0 : (1<<11)) |
(PINB&(1<<3) ? 0 : (1<<12)) |
(PINB&(1<<2) ? 0 : (1<<13));
}
/* Column pin configuration
* col: 0 1 2 3 4 5 6 7 8 9 10 11 12 13
* pin: F7 B6 B5 B4 D7 C7 C6 D3 D2 D1 D0 B7 B3 B2 (Rev.A)
* pin: B7 (Rev.B)
*/
/* Row pin configuration
* row: 0 1 2 3 4
* pin: F0 F1 F4 F5 F6
*/
static void unselect_rows(void)
{
// Hi-Z(DDR:0, PORT:0) to unselect
DDRD &= ~0b01110011;
PORTD &= ~0b01110011;
}
static void select_row(uint8_t row)
{
// Output low(DDR:1, PORT:0) to select
switch (row) {
case 0:
DDRF |= (1<<0);
PORTF &= ~(1<<0);
break;
case 1:
DDRF |= (1<<1);
PORTF &= ~(1<<1);
break;
case 2:
DDRF |= (1<<4);
PORTF &= ~(1<<4);
break;
case 3:
DDRF |= (1<<5);
PORTF &= ~(1<<5);
break;
case 4:
DDRF |= (1<<6);
PORTF &= ~(1<<6);
break;
}
}
Code: Select all
#include "keymap_common.h"
const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
/*0:QWERTY*/
KEYMAP(ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0,QUOT,PSLS,BSPC, \
TAB, Q, W, E, R, T, Y, U, I, O, P,LBRC,RBRC,PPLS, \
CAPS, A, S, D, F, G, H, J, K, L, EQL,SLSH, ENT, \
LSFT,BSLS, Z, X, C, V, B, N, M,COMM, DOT,MINS, RSFT, \
LCTL,LGUI,LALT, SPC, RALT, FN0, APP,RCTL),
/*1:FN0*/
KEYMAP(TRNS, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, DEL, \
TRNS,TRNS, UP, NO,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PSCR,HOME, END, INS, \
TRNS,LEFT,DOWN,RGHT,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PGUP, TRNS, \
TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PGDN, TRNS, \
TRNS,PAUS,TRNS, CALC, MUTE,TRNS,VOLD,VOLU),
};
const action_t PROGMEM fn_actions[] = {
[0] = ACTION_LAYER_MOMENTARY(1)
};
Thanks!