How to build your very own keyboard firmware
-
- Location: Australia
- DT Pro Member: -
Hey!
I'm new to all of this and am currently stuck on creating or making the actual Hex file. I have tried several ways and I still keep getting errors on both PC and Mac. I'm running out of options and was hoping that someone could be nice enough to compile my files <3
I'm new to all of this and am currently stuck on creating or making the actual Hex file. I have tried several ways and I still keep getting errors on both PC and Mac. I'm running out of options and was hoping that someone could be nice enough to compile my files <3
-
- Location: Australia
- DT Pro Member: -
Well, I have done everything twice. It's saying there is a pathing error or something like that in cmd.
It says:
makefile:132: ../../tmk_core/protocol/lufa.mk: No such file or directory
makefile:133 ../../tmk_core/common.mk: No such file or directory
makefile:134 ../../tmk_core/rules.mk: No such file or directory
make: *** No rule to make targt '../../tmk_core/rules.mk'. Stop.
And yes I have modified the files for my matrix.
It says:
makefile:132: ../../tmk_core/protocol/lufa.mk: No such file or directory
makefile:133 ../../tmk_core/common.mk: No such file or directory
makefile:134 ../../tmk_core/rules.mk: No such file or directory
make: *** No rule to make targt '../../tmk_core/rules.mk'. Stop.
And yes I have modified the files for my matrix.
-
- Chasing the Dream
- Location: Berlin
- Main keyboard: redscarf III
- DT Pro Member: -
There is a folder with the name tmk kbd master in which every stuff is in. I think you modified the files in gh60 folder? To compile the stuff you need to go in your cmd and run the "make" script. I thought that you copied the gh60 folder outside the tmk master folder, because the script cant find the needed files (which should be in the tmk sub folders) to compile.
-
- Location: Australia
- DT Pro Member: -
http://imgur.com/a/q9eEV < That's what it looks like.
-
- Location: Australia
- DT Pro Member: -
Okay so now I'm stuck again. It's unable to determine if a key is a functionable or not in the keymap_poker.c file.
I tried my code and Matt3o but both came up with the same error. Could someone please try help me solve this, I've been working on this for over 7 hours with no luck.
I tried my code and Matt3o but both came up with the same error. Could someone please try help me solve this, I've been working on this for over 7 hours with no luck.
-
- Location: Australia
- DT Pro Member: -
So I'm getting the (make:*** [gh60_lufa.efl] Error 1. My codes are:
Matrix.c:
Keymap_pocker.c:
and my
keymap_common.c:
Please guys I've been doing this for over 10 hours and still no progress ;(
Matrix.c:
Code: Select all
/*
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
* pin: F6 F5 F4 F3 F2 F1 F0 (Rev.A)
*/
static void init_cols(void)
{
// Input with pull-up(DDR:0, PORT:1)
DDRF &= ~(1<<6 | 1<<5 | 1<<4 | 1<<3 | 1<<2 | 1<<1 | 1<<0);
PORTF |= (1<<6 | 1<<5 | 1<<4 | 1<<3 | 1<<2 | 1<<1 | 1<<0);
}
static matrix_row_t read_cols(void)
{
return (PINF&(1<<6) ? 0 : (1<<0)) |
(PINF&(1<<5) ? 0 : (1<<1)) |
(PINF&(1<<4) ? 0 : (1<<2)) |
(PINF&(1<<3) ? 0 : (1<<3)) |
(PINF&(1<<2) ? 0 : (1<<4)) |
(PINF&(1<<1) ? 0 : (1<<5)) |
(PINF&(1<<0) ? 0 : (1<<6));
}
/* Row pin configuration
* row: 0 1 2 3 4
* pin: D3 D2 D1 D0 B7
*/
static void unselect_rows(void)
{
// Hi-Z(DDR:0, PORT:0) to unselect
DDRD &= ~0b00001111;
PORTD &= ~0b00001111;
DDRB &= ~0b10000000;
PORTB &= ~0b10000000;
}
static void select_row(uint8_t row)
{
// Output low(DDR:1, PORT:0) to select
switch (row) {
case 0:
DDRD |= (1<<3);
PORTD &= ~(1<<3);
break;
case 1:
DDRD |= (1<<2);
PORTD &= ~(1<<2);
break;
case 2:
DDRD |= (1<<1);
PORTD &= ~(1<<1);
break;
case 3:
DDRD |= (1<<0);
PORTD &= ~(1<<0);
break;
case 4:
DDRB |= (1<<7);
PORTB &= ~(1<<7);
break;
}
}
Code: Select all
#include "keymap_common.h"
const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
/* 0: qwerty */
KEYMAP(F1, F2, F3, F4, F5, \
1, 2, 3, 4, BSPC, P, \
Q, W, E, R, T, Y, C, \
LCTL, S, D, F, G, B, \
TAB, LSFT, A, V),
/* 1: FN 1 */
KEYMAP(F1, F2, F3, F4, F5, \
TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, \
TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, \
TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, \
TRNS, TRNS, TRNS, TRNS),
};
const uint16_t PROGMEM fn_actions[] = {
[0] = ACTION_LAYER_MOMENTARY(1),
};
keymap_common.c:
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, \
K10, K11, K12, K13, K14, K17, \
K20, K21, K22, K23, K24, K25, K27, \
K30, K31, K32, K33, K34, K37, \
K40, K41, K42, K43 \
) { \
{ KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_NO, KC_NO, KC_NO }, \
{ KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_NO, KC_NO, KC_##K17 }, \
{ KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_NO, KC_##K27 }, \
{ KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_NO, KC_NO, KC_##K37 }, \
{ KC_##K40, KC_##K41, KC_##K42, KC_##K43, KC_NO, KC_NO, KC_NO, KC_NO } \
}
/* ANSI valiant. 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
Please guys I've been doing this for over 10 hours and still no progress ;(
- matt3o
- -[°_°]-
- Location: Italy
- Main keyboard: WhiteFox
- Main mouse: Anywhere MX
- Favorite switch: Anything, really
- DT Pro Member: 0030
- Contact:
I need to know the exact error you are given
-
- Location: Australia
- DT Pro Member: -
So here is the error that it's giving me:
http://imgur.com/TJykA7I
And these are my files:
http://imgur.com/a/ga6Mz
Hope you can help <3
http://imgur.com/TJykA7I
And these are my files:
http://imgur.com/a/ga6Mz
Hope you can help <3
-
- Location: Australia
- DT Pro Member: -
New update on my errors:
I re unpacked the .rar file containing the tmk_keyboard-master files and then replaced the files with mine and I got this error: http://imgur.com/5eOlzzz
Not sure what I'm doing wrong..
I re unpacked the .rar file containing the tmk_keyboard-master files and then replaced the files with mine and I got this error: http://imgur.com/5eOlzzz
Not sure what I'm doing wrong..
- matt3o
- -[°_°]-
- Location: Italy
- Main keyboard: WhiteFox
- Main mouse: Anywhere MX
- Favorite switch: Anything, really
- DT Pro Member: 0030
- Contact:
okay post your keyboard directory, I'll try to compile it here.
- Wodan
- ISO Advocate
- Location: ISO-DE
- Main keyboard: Intense Rotation!!!
- Main mouse: Logitech G903
- Favorite switch: ALL OF THEM
- DT Pro Member: -
I wish that kind of support was available in some areas of my daily job, commerciallymatt3o wrote: ↑okay post your keyboard directory, I'll try to compile it here.
-
- Location: Australia
- DT Pro Member: -
How do I do that? Do I just post the codes or ? If so here you go:matt3o wrote: ↑okay post your keyboard directory, I'll try to compile it here.
keymap_common:
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, \
K10, K11, K12, K13, K14, K17, \
K20, K21, K22, K23, K24, K25, K27, \
K30, K31, K32, K33, K34, K37, \
K40, K41, K42, K43 \
) { \
{ KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_NO, KC_NO, KC_NO }, \
{ KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_NO, KC_NO, KC_##K17 }, \
{ KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_NO, KC_##K27 }, \
{ KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_NO, KC_NO, KC_##K37 }, \
{ KC_##K40, KC_##K41, KC_##K42, KC_##K43, KC_NO, KC_NO, KC_NO, KC_NO } \
}
/* ANSI valiant. 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
#include "keymap_common.h"
const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
/* 0: qwerty */
KEYMAP(F1, F2, F3, F4, F5, \
1, 2, 3, 4, BSPC, P, \
Q, W, E, R, T, Y, C, \
LCTL, S, D, F, G, B, \
TAB, LSFT, A, V),
/* 1: FN 1 */
KEYMAP(F1, F2, F3, F4, F5, \
TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, \
TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, \
TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, \
TRNS, TRNS, TRNS, TRNS),
};
const uint16_t PROGMEM fn_actions[] = {
[0] = ACTION_LAYER_MOMENTARY(1),
};
Code: Select all
#----------------------------------------------------------------------------
# On command line:
#
# make all = Make software.
#
# make clean = Clean out built project files.
#
# make coff = Convert ELF to AVR COFF.
#
# make extcoff = Convert ELF to AVR Extended COFF.
#
# make program = Download the hex file to the device.
# Please customize your programmer settings(PROGRAM_CMD)
#
# make teensy = Download the hex file to the device, using teensy_loader_cli.
# (must have teensy_loader_cli installed).
#
# make dfu = Download the hex file to the device, using dfu-programmer (must
# have dfu-programmer installed).
#
# make flip = Download the hex file to the device, using Atmel FLIP (must
# have Atmel FLIP installed).
#
# make dfu-ee = Download the eeprom file to the device, using dfu-programmer
# (must have dfu-programmer installed).
#
# make flip-ee = Download the eeprom file to the device, using Atmel FLIP
# (must have Atmel FLIP installed).
#
# make debug = Start either simulavr or avarice as specified for debugging,
# with avr-gdb or avr-insight as the front end for debugging.
#
# make filename.s = Just compile filename.c into the assembler code only.
#
# make filename.i = Create a preprocessed source file for use in submitting
# bug reports to the GCC project.
#
# To rebuild project do "make clean" then "make 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 - not yet supported in LUFA
# 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
/*
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
* pin: F6 F5 F4 F3 F2 F1 F0 (Rev.A)
*/
static void init_cols(void)
{
// Input with pull-up(DDR:0, PORT:1)
DDRF &= ~(1<<6 | 1<<5 | 1<<4 | 1<<3 | 1<<2 | 1<<1 | 1<<0);
PORTF |= (1<<6 | 1<<5 | 1<<4 | 1<<3 | 1<<2 | 1<<1 | 1<<0);
}
static matrix_row_t read_cols(void)
{
return (PINF&(1<<6) ? 0 : (1<<0)) |
(PINF&(1<<5) ? 0 : (1<<1)) |
(PINF&(1<<4) ? 0 : (1<<2)) |
(PINF&(1<<3) ? 0 : (1<<3)) |
(PINF&(1<<2) ? 0 : (1<<4)) |
(PINF&(1<<1) ? 0 : (1<<5)) |
(PINF&(1<<0) ? 0 : (1<<6));
}
/* Row pin configuration
* row: 0 1 2 3 4
* pin: D3 D2 D1 D0 B7
*/
static void unselect_rows(void)
{
// Hi-Z(DDR:0, PORT:0) to unselect
DDRD &= ~0b00001111;
PORTD &= ~0b00001111;
DDRB &= ~0b10000000;
PORTB &= ~0b10000000;
}
static void select_row(uint8_t row)
{
// Output low(DDR:1, PORT:0) to select
switch (row) {
case 0:
DDRD |= (1<<3);
PORTD &= ~(1<<3);
break;
case 1:
DDRD |= (1<<2);
PORTD &= ~(1<<2);
break;
case 2:
DDRD |= (1<<1);
PORTD &= ~(1<<1);
break;
case 3:
DDRD |= (1<<0);
PORTD &= ~(1<<0);
break;
case 4:
DDRB |= (1<<7);
PORTB &= ~(1<<7);
break;
}
}
Code: Select all
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/>.
*/
#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 5
#define MATRIX_COLS 7
/* 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
-
- Location: Australia
- DT Pro Member: -
Hi there!
First of all thanks a lot for the guide it is amazing!
Secondly, I am having a hard time to compile even the unchanged source code (I tried the GH60 and the HHKB). I am running WinAvr on windows 10 (I already updated the 'faulty' .dll mentionned in a previous page). When I execute make -f Makefile I get some weird (at least for me) error in the keymap.c file (or tree.c ?) Also I created my own layout (a 68%) and when I run the make it gives me the exact same error. I am started to think that there might be something wrong with my version of WinAvr or something like that. Could someone please try to compile my folder on a different OS? (I have attached a zip of the folder with my keymap_poker.c, etc.) Thanks a lot
First of all thanks a lot for the guide it is amazing!
Secondly, I am having a hard time to compile even the unchanged source code (I tried the GH60 and the HHKB). I am running WinAvr on windows 10 (I already updated the 'faulty' .dll mentionned in a previous page). When I execute make -f Makefile I get some weird (at least for me) error in the keymap.c file (or tree.c ?) Also I created my own layout (a 68%) and when I run the make it gives me the exact same error. I am started to think that there might be something wrong with my version of WinAvr or something like that. Could someone please try to compile my folder on a different OS? (I have attached a zip of the folder with my keymap_poker.c, etc.) Thanks a lot
-
- Location: Australia
- DT Pro Member: -
Ok, I finally manage to reach this post in my reading of all the posts and this is exactly the problem I was encountering.flabbergast wrote: ↑I like to go vanilla with installations, so:
1) Installed cygwin (one package to select on top of the 'recommended' installation is make; I also installed git). This is really an installer. After installation, the "Cygwin64 Terminal" icon drops one into a familiar shell (oh the relief...)
2) Downloaded avr-gcc. That's a zip, so just unpack it somewhere (I used d:\avr-gcc). Add d:\avr-gcc\bin to PATH (google. it's in 'advanced system settings' -> 'environment variables')
After this {EDIT: probably a reboot}, I just downloaded and unpacked tmk_keyboard, go into cygwin shell, cd to tmk_keyboard_master/keyboard/gh60 and run make. Compiles fine.
However Jack Humbert seems to recommend the inferno tools.
Two thumbs up mate, this is the fix for the unstable WinAvr problem under new windowes. Like you mentionned, it would probably be wise if Matteo could tell people under windows to follow your fix!
Thanks a lot!
- hasu
- Location: Japan
- Main keyboard: HHKB
- Main mouse: HHKB
- Favorite switch: Topre
- DT Pro Member: -
Matt3o, what about removing WinAVR link from the first post?
It seems like many people have problem with WinAVR and report it here and there, while Mac and Linux users seldom do that. I don't think WinAVR is good option anymore.
It seems like many people have problem with WinAVR and report it here and there, while Mac and Linux users seldom do that. I don't think WinAVR is good option anymore.
- matt3o
- -[°_°]-
- Location: Italy
- Main keyboard: WhiteFox
- Main mouse: Anywhere MX
- Favorite switch: Anything, really
- DT Pro Member: 0030
- Contact:
yeah that's probably a good ideahasu wrote: ↑Matt3o, what about removing WinAVR link from the first post?
It seems like many people have problem with WinAVR and report it here and there, while Mac and Linux users seldom do that. I don't think WinAVR is good option anymore.
-
- Main keyboard: RealForce 87U 55g Uniform
- Main mouse: Zowie FK2
- Favorite switch: Topre
- DT Pro Member: -
Install homebrew, and then use it to install dfu-programmer.TenkaiX wrote:After trying to do everything in MAC Terminal, I came with these errors. Hopefully someone can help me fix this ;(
I've been working too long on this.
Sent from my iPhone
-
- Location: Australia
- DT Pro Member: -
Okay,
Progress: Everything was good until I got back to the keymap_common.h and keymap_poker.c
Something in my coding is screwing up the compile as I went through slowly and copied pasted the directory gh60 and kept trying to see if what I add was stopping the compile. Everything was good up to that.
Someone please for the love of god, Look through my code and tell me why I'm getting this.
keymap_common.h:
and keymap_poker.c
PS: I don't have an function layers. Here are some pictures of my actual designs and what not.
Progress: Everything was good until I got back to the keymap_common.h and keymap_poker.c
Something in my coding is screwing up the compile as I went through slowly and copied pasted the directory gh60 and kept trying to see if what I add was stopping the compile. Everything was good up to that.
Someone please for the love of god, Look through my code and tell me why I'm getting this.
keymap_common.h:
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( \
K00, K01, K02, K03, K04, \
K10, K11, K12, K13, K14, K16, \
K20, K21, K22, K23, K24, K25, K26, \
K30, K31, K32, K33, K34, K36, \
K40, K41, K42, K43 \
) { \
{ KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04 }, \
{ KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_NO, KC_##K16 }, \
{ KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26 }, \
{ KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_NO, KC_##K36 }, \
{ KC_##K40, KC_##K41, KC_##K42, KC_##K43 } \
}
/* ANSI valiant. 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
#include "keymap_common.h"
const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
KEYMAP(F1, F2, F3, F4, F5, \
1, 2, 3, 4, 5, P, \
Q, W, E, R, T, Y, C, \
A, S, D, F, G, B, \
V, LCTL, TAB, LSFT),
};
- Attachments
-
- Error.png (227.62 KiB) Viewed 11549 times
-
- Matrix 3.jpg (933.51 KiB) Viewed 11573 times
-
- Matrix 2.jpg (805.94 KiB) Viewed 11573 times
-
- Matrix.jpg (933.46 KiB) Viewed 11573 times
-
- Location: Australia
- DT Pro Member: -
In your keymap_poker.c, did you remove the following code?TenkaiX wrote: ↑Okay,
Progress: Everything was good until I got back to the keymap_common.h and keymap_poker.c
Something in my coding is screwing up the compile as I went through slowly and copied pasted the directory gh60 and kept trying to see if what I add was stopping the compile. Everything was good up to that.
Someone please for the love of god, Look through my code and tell me why I'm getting this.
keymap_common.h:and keymap_poker.cCode: 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( \ K00, K01, K02, K03, K04, \ K10, K11, K12, K13, K14, K16, \ K20, K21, K22, K23, K24, K25, K26, \ K30, K31, K32, K33, K34, K36, \ K40, K41, K42, K43 \ ) { \ { KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04 }, \ { KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_NO, KC_##K16 }, \ { KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26 }, \ { KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_NO, KC_##K36 }, \ { KC_##K40, KC_##K41, KC_##K42, KC_##K43 } \ } /* ANSI valiant. 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
PS: I don't have an function layers. Here are some pictures of my actual designs and what not.Code: Select all
#include "keymap_common.h" const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { KEYMAP(F1, F2, F3, F4, F5, \ 1, 2, 3, 4, 5, P, \ Q, W, E, R, T, Y, C, \ A, S, D, F, G, B, \ V, LCTL, TAB, LSFT), };
Code: Select all
const action_t PROGMEM fn_actions[] = {
};
-
- Location: Australia
- DT Pro Member: -
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.
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?
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.
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?