TMK code help please!

fuszybear

17 Jan 2016, 03:42

Using the GH60 template i changed it to a JD40 i made and hand wired
folowing this guide http://deskthority.net/workshop-f7/how- ... t7177.html
I have no clue what im doing wrong, when trying to compile the make file it get a list of errors

Code: Select all


C:\Users\Jakub\Desktop\tmk_keyboard-master\keyboard\gh60>make -f makefile
/usr/bin/sh: dfu-programmer: command not found
/usr/bin/sh: dfu-programmer: command not found

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


mkdir -p obj_gh60_lufa
Compiling C: keymap_poker.c
avr-gcc -c -mmcu=atmega32u4 -gdwarf-2 -DF_CPU=16000000UL -DINTERRUPT_CONTROL_END
POINT -DBOOTLOADER_SIZE=4096 -DF_USB=16000000UL -DARCH=ARCH_AVR8 -DUSB_DEVICE_ON
LY -DUSE_FLASH_DESCRIPTORS -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB
_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)" -DFIXED_CONTROL_ENDPOINT_SIZE=8  -DFIXED_N
UM_CONFIGURATIONS=1 -DPROTOCOL_LUFA -DBOOTMAGIC_ENABLE -DMOUSEKEY_ENABLE -DMOUSE
_ENABLE -DEXTRAKEY_ENABLE -DCONSOLE_ENABLE -DCOMMAND_ENABLE -DNKRO_ENABLE -DVERS
ION=unknown -Os -funsigned-char -funsigned-bitfields -ffunction-sections -fdata-
sections -fno-inline-small-functions -fpack-struct -fshort-enums -fno-strict-ali
asing -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/LU
FA-git -I../../tmk_core/common -std=gnu99 -include config.h -MMD -MP -MF .dep/ob
j_gh60_lufa_keymap_poker.o.d  keymap_poker.c -o obj_gh60_lufa/keymap_poker.o
In file included from keymap_poker.c:1:
keymap_common.h:22:58: error: parameter name missing
keymap_poker.c:5: warning: implicit declaration of function 'KEYMAP'
keymap_poker.c:5: error: 'ESC' undeclared here (not in a function)
keymap_poker.c:5: error: 'Q' undeclared here (not in a function)
keymap_poker.c:5: error: 'W' undeclared here (not in a function)
keymap_poker.c:5: error: 'E' undeclared here (not in a function)
keymap_poker.c:5: error: 'R' undeclared here (not in a function)
keymap_poker.c:5: error: 'T' undeclared here (not in a function)
keymap_poker.c:5: error: 'Y' undeclared here (not in a function)
keymap_poker.c:5: error: 'U' undeclared here (not in a function)
keymap_poker.c:5: error: 'I' undeclared here (not in a function)
keymap_poker.c:5: error: 'O' undeclared here (not in a function)
keymap_poker.c:5: error: 'P' undeclared here (not in a function)
keymap_poker.c:5: error: 'BSPC' undeclared here (not in a function)
keymap_poker.c:6: error: 'TAB' undeclared here (not in a function)
keymap_poker.c:6: error: 'A' undeclared here (not in a function)
keymap_poker.c:6: error: 'S' undeclared here (not in a function)
keymap_poker.c:6: error: 'D' undeclared here (not in a function)
keymap_poker.c:6: error: 'F' undeclared here (not in a function)
keymap_poker.c:6: error: 'G' undeclared here (not in a function)
keymap_poker.c:6: error: 'H' undeclared here (not in a function)
keymap_poker.c:6: error: 'J' undeclared here (not in a function)
keymap_poker.c:6: error: 'K' undeclared here (not in a function)
keymap_poker.c:6: error: 'L' undeclared here (not in a function)
keymap_poker.c:6: error: 'ENT' undeclared here (not in a function)
keymap_poker.c:7: error: 'LSFT' undeclared here (not in a function)
keymap_poker.c:7: error: 'Z' undeclared here (not in a function)
keymap_poker.c:7: error: 'X' undeclared here (not in a function)
keymap_poker.c:7: error: 'C' undeclared here (not in a function)
keymap_poker.c:7: error: 'V' undeclared here (not in a function)
keymap_poker.c:7: error: 'B' undeclared here (not in a function)
keymap_poker.c:7: error: 'N' undeclared here (not in a function)
keymap_poker.c:7: error: 'M' undeclared here (not in a function)
keymap_poker.c:7: error: 'DOT' undeclared here (not in a function)
keymap_poker.c:7: error: 'FN0' undeclared here (not in a function)
keymap_poker.c:8: error: 'LALT' undeclared here (not in a function)
keymap_poker.c:8: error: 'FN1' undeclared here (not in a function)
keymap_poker.c:8: error: 'FN2' undeclared here (not in a function)
keymap_poker.c:8: error: 'SPC' undeclared here (not in a function)
keymap_poker.c:8: error: 'PAUS' undeclared here (not in a function)
keymap_poker.c:8: error: 'RALT' undeclared here (not in a function)
keymap_poker.c:5: warning: missing braces around initializer
keymap_poker.c:5: warning: (near initialization for 'keymaps[0]')
keymap_poker.c:5: error: initializer element is not constant
keymap_poker.c:5: error: (near initialization for 'keymaps[0][0][0]')
keymap_poker.c:10: error: 'F1' undeclared here (not in a function)
keymap_poker.c:10: error: 'F2' undeclared here (not in a function)
keymap_poker.c:10: error: 'F3' undeclared here (not in a function)
keymap_poker.c:10: error: 'F4' undeclared here (not in a function)
keymap_poker.c:10: error: 'F5' undeclared here (not in a function)
keymap_poker.c:10: error: 'F6' undeclared here (not in a function)
keymap_poker.c:10: error: 'F7' undeclared here (not in a function)
keymap_poker.c:10: error: 'F8' undeclared here (not in a function)
keymap_poker.c:10: error: 'F9' undeclared here (not in a function)
keymap_poker.c:10: error: 'F10' undeclared here (not in a function)
keymap_poker.c:10: error: 'F11' undeclared here (not in a function)
keymap_poker.c:10: error: 'F12' undeclared here (not in a function)
keymap_poker.c:11: error: 'TRNS' undeclared here (not in a function)
keymap_poker.c:11: error: 'PGUP' undeclared here (not in a function)
keymap_poker.c:11: error: 'UP' undeclared here (not in a function)
keymap_poker.c:12: error: 'PGDN' undeclared here (not in a function)
keymap_poker.c:12: error: 'LEFT' undeclared here (not in a function)
keymap_poker.c:12: error: 'RGHT' undeclared here (not in a function)
keymap_poker.c:13: error: 'CALC' undeclared here (not in a function)
keymap_poker.c:13: error: 'HOME' undeclared here (not in a function)
keymap_poker.c:13: error: 'DOWN' undeclared here (not in a function)
keymap_poker.c:14: error: 'LGUI' undeclared here (not in a function)
keymap_poker.c:14: error: 'PSCR' undeclared here (not in a function)
keymap_poker.c:14: error: 'RCTL' undeclared here (not in a function)
keymap_poker.c:10: error: initializer element is not constant
keymap_poker.c:10: error: (near initialization for 'keymaps[0][0][1]')
make: *** [obj_gh60_lufa/keymap_poker.o] Error 1

C:\Users\Jakub\Desktop\tmk_keyboard-master\keyboard\gh60>

http://imgur.com/NB86ujl
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   7   8   9   10  11  
 * pin: F7  B0  B1  B2  B3  B7  D0  D1  D2  D3  C6  C7   (Rev.A)
 */
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<<4);
    PORTD |=  (1<<7 | 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 | 1<<0);
    PORTB |=  (1<<7 | 1<<6 | 1<< 5 | 1<<4 | 1<<3 | 1<<1 | 1<<0);
}
static void  init_cols(void)
{
    // Input with pull-up(DDR:0, PORT:1)
    DDRF  &= ~(1<<7);
    PORTF |=  (1<<7);
    DDRB  &= ~(1<<7 | 1<<6 | 1<<5 | 1<<4 | 1<<3 | 1<<2 | 1<<1 | 1<<0);
    PORTB |=  (1<<7 | 1<<6 | 1<<5 | 1<<4 | 1<<3 | 1<<2 | 1<<1 | 1<<0);
    DDRD  &= ~(1<<7 | 1<<3 | 1<<2 | 1<<1 | 1<<0);
    PORTD |=  (1<<7 | 1<<3 | 1<<2 | 1<<1 | 1<<0);
    DDRC  &= ~(1<<7);
    PORTC |=  (1<<7);
}

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

/* Row pin configuration
 * row: 0   1   2   3  
 * pin: D7  B4  B5  B6  
 */
static void unselect_rows(void)
{
    DDRB &= ~(1<<4 | 1<<5 | 1<<6); 
    PORTB |= (1<<4 | 1<<5 | 1<<6); 
	DDRD &= ~(1<<7); 
    PORTD |= (1<<7); 
}
static void select_row(uint8_t row)
{
    // Output low(DDR:1, PORT:0) to select
    switch (row) {
        case 0:
            DDRD  |= (1<<7);
            PORTD &= ~(1<<7);
            break;
        case 1:
            DDRB  |= (1<<4);
            PORTB &= ~(1<<4);
            break;
        case 2:
            DDRB  |= (1<<5);
            PORTB &= ~(1<<5);
            break;
        case 3:
            DDRB  |= (1<<6);
            PORTB &= ~(1<<6);
            break;
    }
}
keymap_common.H

Code: Select all

#ifndef KEYMAP_COMMON_H
#define KEYMAP_COMMON_H

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


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

#define KEYMAP( \
    K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, \
    K10, K11, K12, K13, K14, K15, K16, K17, K18, K19,    , K1B, \
    K20,    , K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, \
    K30, K31,      K33,           K36,                K3A, K3B, \
) { \
    { KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07, KC_##K08, KC_##K09, KC_##K0A, KC_##K0B, }, \
    { KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17, KC_##K18, KC_##K19, KC_NO,    KC_##K1B, }, \
    { KC_##K20, KC_NO,    KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_##K27, KC_##K28, KC_##K29, KC_##K2A, KC_##K2B, }, \
    { KC_##K30, KC_##K31, KC_NO,    KC_##K33, KC_NO,    KC_NO,    KC_##K36, KC_NO,    KC_NO,    KC_NO,    KC_##K3A, KC_##K3B, }, \
}

/* 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
keymap_poker.c

Code: Select all

#include "keymap_common.h"

const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
    /* 0: qwerty */
	KEYMAP(ESC,  Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,  BSPC, \
           TAB,  A,   S,   D,   F,   G,   H,   J,   K,   L,       ENT,  \
           LSFT,      Z,   X,   C,   V,   B,   N,   M, DOT,       FN0,  \
           LALT, FN1,      FN2,           SPC,             PAUS,  RALT),   
    /* 1: FN 1 */
    KEYMAP(F1,   F2,   F3,   F4,   F5,   F6,   F7,   F8,   F9,   F10,  F11,  F12,  \
           TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, PGUP, UP,   \
           TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, PGDN, LEFT, RGHT, \
           LGUI, TRNS,       TRNS,              SPC,             TRNS, PSCR, RCTL),
};
const uint16_t PROGMEM fn_actions[] = {
  [0] = ACTION_LAYER_MOMENTARY(1),
  [1] = ACTION_LAYER_TAP_KEY(1, KC_ESC),
  [2] = ACTION_LAYER_TOGGLE(2)
};
led.c

Code: Select all

#include <avr/io.h>
#include "stdint.h"
#include "led.h"


void led_set(uint8_t usb_led)
{
    if (usb_led & (1<<USB_LED_CAPS_LOCK)) {
        // output low
        DDRD |= (1<<6);
        PORTD &= ~(1<<6);
    } else {
        // Hi-Z
        DDRD &= ~(1<<6);
        PORTD &= ~(1<<6);
    }
}

User avatar
Ray

17 Jan 2016, 04:03

In most cases, the first error message is the relevant one: "keymap_common.h:22:58: error: parameter name missing"
Your keymap macro in keymap_common.h has a list of parameters, separated by commas. You have two commas following each other without a parameter name in between.
Remove the duplicate commas and try again.

The following errors are because you don't have a valid keymap macro.

fuszybear

17 Jan 2016, 04:14

ok i fixed the commas, but it didnt change anything. what does a is a valid keymap macro?

User avatar
Ray

17 Jan 2016, 11:02

Look at the first error you get from make. If you fixed the commas, it should have changed to another error (or eventually no error, when you get rid of all of them). You did fix it for both occasions, did you?

Getting compilation errors is a normal thing, not only for beginners. But as a beginner, 99% of the time you should ignore every error/warning after the first. For 1% the next might give a clue as well. Long journeys start with the first step. And usually the messages further down get fixed automatically when you fix the first.

The KEYMAP macro is the thing that starts with "#define KEYMAP". Frankly it doesn't do much, just formatting the code before the preprocessor hands it over to the actual compiler. It inserts "KC_" before the keys, so you don't have to type them every time (also makes it easier to understand visually). It also inserts some "KC_NO" for the places in your matrix where you don't have switches. It can also "rearrange" some keys for you, when your key layout is different from your wired matrix.
In essence the KEYMAP macro has to be set once and someone has to spend some brainpower while doing it, and that makes the keymaps (in keymap_poker.c) much easier to understand and you don't have do spend the brainpower every time you do a change.

nicstreet

17 Jan 2016, 16:09

keymap_common.h - Line 24, no comma needed after "K3B" at the end of the line. In each case as already mentioned troubleshoot the first error, it's likely that the others will drop off once all the syntax is correct.

Ensure your makefile has appropriate settings for the AVR you are using.

Sometimes, leave it a few hours...walk away and do something else and return with a clear head.

miguel

22 May 2016, 05:50

Hey, I received a very similar error message while compiling my code as well. I am so confused(I am very new to this sort of thing) and was wondering if this problem was ever solved. Thanks!

Here's my code and error:


Error:

Code: Select all

C:\Users\Miguel\Desktop\tmk_keyboard-master\keyboard\gh60>make -f Makefile

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


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_poker.c:1:0:
keymap_common.h:47:1: error: parameter name missing
 ) { \
 ^
keymap_poker.c:5:5: warning: implicit declaration of function 'KEYMAP' [-Wimplicit-function-declaration]
     KEYMAP(ESC,  F1,   F2,   F3,   F4,   F5,   F6,   F7,   F8,   F9,   F9,    F10,  F11,   F12,  PSCR ,  Q,  PAUS,  \
     ^
keymap_poker.c:5:12: error: 'ESC' undeclared here (not in a function)
     KEYMAP(ESC,  F1,   F2,   F3,   F4,   F5,   F6,   F7,   F8,   F9,   F9,    F10,  F11,   F12,  PSCR ,  Q,  PAUS,  \
            ^
keymap_poker.c:5:18: error: 'F1' undeclared here (not in a function)
     KEYMAP(ESC,  F1,   F2,   F3,   F4,   F5,   F6,   F7,   F8,   F9,   F9,    F10,  F11,   F12,  PSCR ,  Q,  PAUS,  \
                  ^
keymap_poker.c:5:24: error: 'F2' undeclared here (not in a function)
     KEYMAP(ESC,  F1,   F2,   F3,   F4,   F5,   F6,   F7,   F8,   F9,   F9,    F10,  F11,   F12,  PSCR ,  Q,  PAUS,  \
                        ^
keymap_poker.c:5:30: error: 'F3' undeclared here (not in a function)
     KEYMAP(ESC,  F1,   F2,   F3,   F4,   F5,   F6,   F7,   F8,   F9,   F9,    F10,  F11,   F12,  PSCR ,  Q,  PAUS,  \
                              ^
keymap_poker.c:5:36: error: 'F4' undeclared here (not in a function)
     KEYMAP(ESC,  F1,   F2,   F3,   F4,   F5,   F6,   F7,   F8,   F9,   F9,    F10,  F11,   F12,  PSCR ,  Q,  PAUS,  \
                                    ^
keymap_poker.c:5:42: error: 'F5' undeclared here (not in a function)
     KEYMAP(ESC,  F1,   F2,   F3,   F4,   F5,   F6,   F7,   F8,   F9,   F9,    F10,  F11,   F12,  PSCR ,  Q,  PAUS,  \
                                          ^
keymap_poker.c:5:48: error: 'F6' undeclared here (not in a function)
     KEYMAP(ESC,  F1,   F2,   F3,   F4,   F5,   F6,   F7,   F8,   F9,   F9,    F10,  F11,   F12,  PSCR ,  Q,  PAUS,  \
                                                ^
keymap_poker.c:5:54: error: 'F7' undeclared here (not in a function)
     KEYMAP(ESC,  F1,   F2,   F3,   F4,   F5,   F6,   F7,   F8,   F9,   F9,    F10,  F11,   F12,  PSCR ,  Q,  PAUS,  \
                                                      ^
keymap_poker.c:5:60: error: 'F8' undeclared here (not in a function)
     KEYMAP(ESC,  F1,   F2,   F3,   F4,   F5,   F6,   F7,   F8,   F9,   F9,    F10,  F11,   F12,  PSCR ,  Q,  PAUS,  \
                                                            ^
keymap_poker.c:5:66: error: 'F9' undeclared here (not in a function)
     KEYMAP(ESC,  F1,   F2,   F3,   F4,   F5,   F6,   F7,   F8,   F9,   F9,    F10,  F11,   F12,  PSCR ,  Q,  PAUS,  \
                                                                  ^
keymap_poker.c:5:79: error: 'F10' undeclared here (not in a function)
     KEYMAP(ESC,  F1,   F2,   F3,   F4,   F5,   F6,   F7,   F8,   F9,   F9,    F10,  F11,   F12,  PSCR ,  Q,  PAUS,  \
                                                                               ^
keymap_poker.c:5:85: error: 'F11' undeclared here (not in a function)
     KEYMAP(ESC,  F1,   F2,   F3,   F4,   F5,   F6,   F7,   F8,   F9,   F9,    F10,  F11,   F12,  PSCR ,  Q,  PAUS,  \
                                                                                     ^
keymap_poker.c:5:92: error: 'F12' undeclared here (not in a function)
     KEYMAP(ESC,  F1,   F2,   F3,   F4,   F5,   F6,   F7,   F8,   F9,   F9,    F10,  F11,   F12,  PSCR ,  Q,  PAUS,  \
                                                                                            ^
keymap_poker.c:5:98: error: 'PSCR' undeclared here (not in a function)
     KEYMAP(ESC,  F1,   F2,   F3,   F4,   F5,   F6,   F7,   F8,   F9,   F9,    F10,  F11,   F12,  PSCR ,  Q,  PAUS,  \
                                                                                                  ^
keymap_poker.c:5:106: error: 'Q' undeclared here (not in a function)
     KEYMAP(ESC,  F1,   F2,   F3,   F4,   F5,   F6,   F7,   F8,   F9,   F9,    F10,  F11,   F12,  PSCR ,  Q,  PAUS,  \
                                                                                                          ^
keymap_poker.c:5:110: error: 'PAUS' undeclared here (not in a function)
     KEYMAP(ESC,  F1,   F2,   F3,   F4,   F5,   F6,   F7,   F8,   F9,   F9,    F10,  F11,   F12,  PSCR ,  Q,  PAUS,  \
                                                                                                              ^
keymap_poker.c:6:13: error: 'MUTE' undeclared here (not in a function)
             MUTE,     1,     2,  3,  4,   5,  6,   7,   8,   9,   0,  MINS,  EQL,  BSPC,  INST, HOME, PGUP, \
             ^
keymap_poker.c:6:71: error: 'MINS' undeclared here (not in a function)
             MUTE,     1,     2,  3,  4,   5,  6,   7,   8,   9,   0,  MINS,  EQL,  BSPC,  INST, HOME, PGUP, \
                                                                       ^
keymap_poker.c:6:78: error: 'EQL' undeclared here (not in a function)
             MUTE,     1,     2,  3,  4,   5,  6,   7,   8,   9,   0,  MINS,  EQL,  BSPC,  INST, HOME, PGUP, \
                                                                              ^
keymap_poker.c:6:84: error: 'BSPC' undeclared here (not in a function)
             MUTE,     1,     2,  3,  4,   5,  6,   7,   8,   9,   0,  MINS,  EQL,  BSPC,  INST, HOME, PGUP, \
                                                                                    ^
keymap_poker.c:6:91: error: 'INST' undeclared here (not in a function)
             MUTE,     1,     2,  3,  4,   5,  6,   7,   8,   9,   0,  MINS,  EQL,  BSPC,  INST, HOME, PGUP, \
                                                                                           ^
keymap_poker.c:6:97: error: 'HOME' undeclared here (not in a function)
             MUTE,     1,     2,  3,  4,   5,  6,   7,   8,   9,   0,  MINS,  EQL,  BSPC,  INST, HOME, PGUP, \
                                                                                                 ^
keymap_poker.c:6:103: error: 'PGUP' undeclared here (not in a function)
             MUTE,     1,     2,  3,  4,   5,  6,   7,   8,   9,   0,  MINS,  EQL,  BSPC,  INST, HOME, PGUP, \
                                                                                                       ^
keymap_poker.c:7:12: error: 'TAB' undeclared here (not in a function)
            TAB,  Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,   LBRC,RBRC,BSLS,  DEL, END,  PGDN,   \
            ^
keymap_poker.c:7:23: error: 'W' undeclared here (not in a function)
            TAB,  Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,   LBRC,RBRC,BSLS,  DEL, END,  PGDN,   \
                       ^
keymap_poker.c:7:28: error: 'E' undeclared here (not in a function)
            TAB,  Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,   LBRC,RBRC,BSLS,  DEL, END,  PGDN,   \
                            ^
keymap_poker.c:7:33: error: 'R' undeclared here (not in a function)
            TAB,  Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,   LBRC,RBRC,BSLS,  DEL, END,  PGDN,   \
                                 ^
keymap_poker.c:7:38: error: 'T' undeclared here (not in a function)
            TAB,  Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,   LBRC,RBRC,BSLS,  DEL, END,  PGDN,   \
                                      ^
keymap_poker.c:7:43: error: 'Y' undeclared here (not in a function)
            TAB,  Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,   LBRC,RBRC,BSLS,  DEL, END,  PGDN,   \
                                           ^
keymap_poker.c:7:48: error: 'U' undeclared here (not in a function)
            TAB,  Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,   LBRC,RBRC,BSLS,  DEL, END,  PGDN,   \
                                                ^
keymap_poker.c:7:53: error: 'I' undeclared here (not in a function)
            TAB,  Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,   LBRC,RBRC,BSLS,  DEL, END,  PGDN,   \
                                                     ^
keymap_poker.c:7:58: error: 'O' undeclared here (not in a function)
            TAB,  Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,   LBRC,RBRC,BSLS,  DEL, END,  PGDN,   \
                                                          ^
keymap_poker.c:7:63: error: 'P' undeclared here (not in a function)
            TAB,  Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,   LBRC,RBRC,BSLS,  DEL, END,  PGDN,   \
                                                               ^
keymap_poker.c:7:68: error: 'LBRC' undeclared here (not in a function)
            TAB,  Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,   LBRC,RBRC,BSLS,  DEL, END,  PGDN,   \
                                                                    ^
keymap_poker.c:7:73: error: 'RBRC' undeclared here (not in a function)
            TAB,  Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,   LBRC,RBRC,BSLS,  DEL, END,  PGDN,   \
                                                                         ^
keymap_poker.c:7:78: error: 'BSLS' undeclared here (not in a function)
            TAB,  Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,   LBRC,RBRC,BSLS,  DEL, END,  PGDN,   \
                                                                              ^
keymap_poker.c:7:85: error: 'DEL' undeclared here (not in a function)
            TAB,  Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,   LBRC,RBRC,BSLS,  DEL, END,  PGDN,   \
                                                                                     ^
keymap_poker.c:7:96: error: 'PGDN' undeclared here (not in a function)
            TAB,  Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,   LBRC,RBRC,BSLS,  DEL, END,  PGDN,   \
                                                                                                ^
keymap_poker.c:8:12: error: 'LCTL' undeclared here (not in a function)
            LCTL, A,   S,   D,   F,   G,   H,   J,   K,   L,   SCLN,QUOT,ENT,            \
            ^
keymap_poker.c:8:18: error: 'A' undeclared here (not in a function)
            LCTL, A,   S,   D,   F,   G,   H,   J,   K,   L,   SCLN,QUOT,ENT,            \
                  ^
keymap_poker.c:8:23: error: 'S' undeclared here (not in a function)
            LCTL, A,   S,   D,   F,   G,   H,   J,   K,   L,   SCLN,QUOT,ENT,            \
                       ^
keymap_poker.c:8:28: error: 'D' undeclared here (not in a function)
            LCTL, A,   S,   D,   F,   G,   H,   J,   K,   L,   SCLN,QUOT,ENT,            \
                            ^
keymap_poker.c:8:33: error: 'F' undeclared here (not in a function)
            LCTL, A,   S,   D,   F,   G,   H,   J,   K,   L,   SCLN,QUOT,ENT,            \
                                 ^
keymap_poker.c:8:38: error: 'G' undeclared here (not in a function)
            LCTL, A,   S,   D,   F,   G,   H,   J,   K,   L,   SCLN,QUOT,ENT,            \
                                      ^
keymap_poker.c:8:43: error: 'H' undeclared here (not in a function)
            LCTL, A,   S,   D,   F,   G,   H,   J,   K,   L,   SCLN,QUOT,ENT,            \
                                           ^
keymap_poker.c:8:48: error: 'J' undeclared here (not in a function)
            LCTL, A,   S,   D,   F,   G,   H,   J,   K,   L,   SCLN,QUOT,ENT,            \
                                                ^
keymap_poker.c:8:53: error: 'K' undeclared here (not in a function)
            LCTL, A,   S,   D,   F,   G,   H,   J,   K,   L,   SCLN,QUOT,ENT,            \
                                                     ^
keymap_poker.c:8:58: error: 'L' undeclared here (not in a function)
            LCTL, A,   S,   D,   F,   G,   H,   J,   K,   L,   SCLN,QUOT,ENT,            \
                                                          ^
keymap_poker.c:8:63: error: 'SCLN' undeclared here (not in a function)
            LCTL, A,   S,   D,   F,   G,   H,   J,   K,   L,   SCLN,QUOT,ENT,            \
                                                               ^
keymap_poker.c:8:68: error: 'QUOT' undeclared here (not in a function)
            LCTL, A,   S,   D,   F,   G,   H,   J,   K,   L,   SCLN,QUOT,ENT,            \
                                                                    ^
keymap_poker.c:8:73: error: 'ENT' undeclared here (not in a function)
            LCTL, A,   S,   D,   F,   G,   H,   J,   K,   L,   SCLN,QUOT,ENT,            \
                                                                         ^
keymap_poker.c:9:12: error: 'LSFT' undeclared here (not in a function)
            LSFT, Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, SLSH,RSFT,  UP,      \
            ^
keymap_poker.c:9:18: error: 'Z' undeclared here (not in a function)
            LSFT, Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, SLSH,RSFT,  UP,      \
                  ^
keymap_poker.c:9:23: error: 'X' undeclared here (not in a function)
            LSFT, Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, SLSH,RSFT,  UP,      \
                       ^
keymap_poker.c:9:28: error: 'C' undeclared here (not in a function)
            LSFT, Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, SLSH,RSFT,  UP,      \
                            ^
keymap_poker.c:9:33: error: 'V' undeclared here (not in a function)
            LSFT, Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, SLSH,RSFT,  UP,      \
                                 ^
keymap_poker.c:9:38: error: 'B' undeclared here (not in a function)
            LSFT, Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, SLSH,RSFT,  UP,      \
                                      ^
keymap_poker.c:9:43: error: 'N' undeclared here (not in a function)
            LSFT, Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, SLSH,RSFT,  UP,      \
                                           ^
keymap_poker.c:9:48: error: 'M' undeclared here (not in a function)
            LSFT, Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, SLSH,RSFT,  UP,      \
                                                ^
keymap_poker.c:9:53: error: 'COMM' undeclared here (not in a function)
            LSFT, Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, SLSH,RSFT,  UP,      \
                                                     ^
keymap_poker.c:9:58: error: 'DOT' undeclared here (not in a function)
            LSFT, Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, SLSH,RSFT,  UP,      \
                                                          ^
keymap_poker.c:9:63: error: 'SLSH' undeclared here (not in a function)
            LSFT, Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, SLSH,RSFT,  UP,      \
                                                               ^
keymap_poker.c:9:68: error: 'RSFT' undeclared here (not in a function)
            LSFT, Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, SLSH,RSFT,  UP,      \
                                                                    ^
keymap_poker.c:9:75: error: 'UP' undeclared here (not in a function)
            LSFT, Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, SLSH,RSFT,  UP,      \
                                                                           ^
keymap_poker.c:10:19: error: 'WIN' undeclared here (not in a function)
            LCTL,  WIN,  LALT,            SPC,                     RALT,  WIN, PAUS, RCTL, LEFT, DOWN, RGHT),
                   ^
keymap_poker.c:10:25: error: 'LALT' undeclared here (not in a function)
            LCTL,  WIN,  LALT,            SPC,                     RALT,  WIN, PAUS, RCTL, LEFT, DOWN, RGHT),
                         ^
keymap_poker.c:10:42: error: 'SPC' undeclared here (not in a function)
            LCTL,  WIN,  LALT,            SPC,                     RALT,  WIN, PAUS, RCTL, LEFT, DOWN, RGHT),
                                          ^
keymap_poker.c:10:67: error: 'RALT' undeclared here (not in a function)
            LCTL,  WIN,  LALT,            SPC,                     RALT,  WIN, PAUS, RCTL, LEFT, DOWN, RGHT),
                                                                   ^
keymap_poker.c:10:85: error: 'RCTL' undeclared here (not in a function)
            LCTL,  WIN,  LALT,            SPC,                     RALT,  WIN, PAUS, RCTL, LEFT, DOWN, RGHT),
                                                                                     ^
keymap_poker.c:10:91: error: 'LEFT' undeclared here (not in a function)
            LCTL,  WIN,  LALT,            SPC,                     RALT,  WIN, PAUS, RCTL, LEFT, DOWN, RGHT),
                                                                                           ^
keymap_poker.c:10:97: error: 'DOWN' undeclared here (not in a function)
            LCTL,  WIN,  LALT,            SPC,                     RALT,  WIN, PAUS, RCTL, LEFT, DOWN, RGHT),
                                                                                                 ^
keymap_poker.c:10:103: error: 'RGHT' undeclared here (not in a function)
            LCTL,  WIN,  LALT,            SPC,                     RALT,  WIN, PAUS, RCTL, LEFT, DOWN, RGHT),
                                                                                                       ^
../../tmk_core/rules.mk:550: recipe for target 'obj_gh60_lufa/keymap_poker.o' failed
make: *** [obj_gh60_lufa/keymap_poker.o] Error 1

C:\Users\Miguel\Desktop\tmk_keyboard-master\keyboard\gh60>
config.h:

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    MiguelAbalos
#define PRODUCT         20$Project
#define DESCRIPTION     dank

/* key matrix size */
#define MATRIX_ROWS 6
#define MATRIX_COLS 18

/* 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
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     7    8    9   10   11  12   13  14  15   16  17 
 * pin: B0  B1  B2   B7  B3  E6  D0  D1  D2  D3  C6  B4  D5  B5  D7  D4  C7  B6
 */


static void  init_cols(void)
{
    // Input with pull-up(DDR:0, PORT:1)



    //DDRF  &= ~(1<<7 | 1<<6 | 1<<5 | 1<<4 | 1<<1 | 1<<0);
    //PORTF |=  (1<<7 | 1<<6 | 1<<5 | 1<<4 | 1<<1 | 1<<0);

    DDRE  &= ~(1<<6);
    PORTE |=  (1<<6);

    DDRD  &= ~(1<<7 | 1<<5 | 1<<4 | 1<<3 | 1<<2 | 1<<1 | 1<<0);
    PORTD |=  (1<<7 | 1<<5 | 1<<4 | 1<<3 | 1<<2 | 1<<1 | 1<<0);

    DDRC  &= ~(1<<7 | 1<<6);
    PORTC |=  (1<<7 | 1<<6);

    DDRB  &= ~(1<<7 | 1<<6 | 1<< 5 | 1<<4 | 1<<3 | 1<<2 | 1<<1 | 1<<0);
    PORTB |=  (1<<7 | 1<<6 | 1<< 5 | 1<<4 | 1<<3 | 1<<2 | 1<<1 | 1<<0);
}


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




/* Row pin configuration
 * row: 0    1    2    3    4    5 
 * pin: F0  F1  F4  F5  F6  F7
 */


static void unselect_rows(void)
{
    // Hi-Z(DDR:0, PORT:0) to unselect
    DDRD  &= ~0b11110011;
    PORTD &= ~0b11110011;
}



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;
        case 5:
            DDRF  |= (1<<7);
            PORTF &= ~(1<<7);
            break;
    }
}

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 <avr/pgmspace.h>
#include "keycode.h"
#include "action.h"
#include "action_macro.h"
#include "report.h"
#include "host.h"
#include "print.h"
#include "debug.h"
#include "keymap.h"


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


/* GH60 keymap definition macro
 * K2C, K31 and  K3C are extra keys for ISO
 */
#define KEYMAP( \
    K00,         K02, K03, K04, K05, K06, K07, K08, K09,          K0B, K0C, K0D,  K0E, K0F, K0G, K0H, \
    K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C,           K1E, K1F, K1G, K1H, \
    K20,         K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, K2D,  K2E, K2F, K2G, K2H, \
    K30,         K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3C,           K3E,  \
    K40, K41,         K43, K44, K45, K46, K47, K48, K49, K4A, K4B, K4C,           K4E,         K4G, \
    K50, K51,         K53,                          K57,                           K5B, K5C, K5D,  K5E, K5F, K5G, K5H, \
) { \
    { KC_##K00, KC_NO     , KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07, KC_##K08, KC_##K09, KC_NO       , KC_##K0B, KC_##K0C, KC_##K0D, KC_##K0E, KC_##K0F, KC_##K0G,  KC_##K0H }, \
    { 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_##K1E, KC_##K1F, KC_##K1G,  KC_##K1H }, \
    { KC_##K20, KC_NO     , KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_##K27, KC_##K28, KC_##K29, KC_##K2A, KC_##K2B, KC_##K2C, KC_##K2D, KC_##K2E, KC_##K2F, KC_##K2G,  KC_##K2H }, \
    { KC_##K30, KC_NO     , KC_##K32, KC_##K33, KC_##K34, KC_##K35, KC_##K36, KC_##K37, KC_##K38, KC_##K39, KC_##K3A, KC_##K3B, KC_##K3C, KC_NO       , KC_##K3E, KC_NO     , KC_NO       ,  KC_NO       }, \
    { KC_##K40, KC_##K41, KC_NO     , KC_##K43, KC_##K44, KC_##K45, KC_##K46, KC_##K47, KC_##K48, KC_##K49, KC_##K4A, KC_##K4B, KC_##K4C, KC_NO       , KC_##K4E, KC_NO     , KC_##K4G,  KC_NO       }, \
    { KC_##K50, KC_##K51, KC_NO     , KC_##K53, KC_NO      , KC_NO      , KC_NO     , KC_##K57, KC_NO      , KC_NO     , KC_##K5A, KC_##K5B, KC_##K5C, KC_##K5D, KC_##K5E, KC_##K5F, KC_##K5G,  KC_##K5H }, \
}

/* 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

keymap_poker.c:

Code: Select all

#include "keymap_common.h"

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

    KEYMAP(ESC,  F1,   F2,   F3,   F4,   F5,   F6,   F7,   F8,   F9,   F9,    F10,  F11,   F12,  PSCR ,  Q,  PAUS,  \
            MUTE,     1,     2,  3,  4,   5,  6,   7,   8,   9,   0,  MINS,  EQL,  BSPC,  INST, HOME, PGUP, \
           TAB,  Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,   LBRC,RBRC,BSLS,  DEL, END,  PGDN,   \
           LCTL, 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,  WIN,  LALT,            SPC,                     RALT,  WIN, PAUS, RCTL, LEFT, DOWN, RGHT),

};


const uint16_t PROGMEM fn_actions[] = {


};


User avatar
flabbergast

22 May 2016, 08:47

You current error is caused by this:
In your keymap_common.h:

Code: Select all

K5F, K5G, K5H, \
) { \
    { KC_##K00, KC_NO     , KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07, KC_##K08, KC_##K09, KC_NO       , KC_##K0B, KC_##K0C, KC_##K0D, KC_##K0E, KC_##K0F, KC_##K0G,  KC_##K0H }, \
There should be no comma after 'K5H', i.e. it should look like this:

Code: Select all

K5F, K5G, K5H \
) { \
    { KC_##K00, KC_NO     , KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07, KC_##K08, KC_##K09, KC_NO       , KC_##K0B, KC_##K0C, KC_##K0D, KC_##K0E, KC_##K0F, KC_##K0G,  KC_##K0H }, \
It is hard to understand what the C compiler is saying when you're starting; in this case the relevant bit is this message:

Code: Select all

keymap_common.h:47:1: error: parameter name missing
 ) { \
 ^

miguel

22 May 2016, 18:47

Thank you so much!!! It successfully compiled!!!! Now I ran into a different problem: I uploaded it to my controller but when I plugged it in to my computer a whole bunch of random key began to go off but only for about 10 seconds, then it stopped.

Side note: Is there anywhere I can find abbreviations for the different keys in the keyboard? I just placed an "x" where i couldnt find it(windows key, insert key, tilda, etc.)

User avatar
flabbergast

22 May 2016, 19:10

They are in the sources here and here. Not sure, they may also be explained on the wiki, but I can never find it.

miguel

23 May 2016, 04:15

Okay, checked my code, realized I had ports F initialized in the columns function even though they weren't functions. when I tried to compile this time, I got this strange message:

Code: Select all


matrix.c: In function 'read_cols':
matrix.c:165:5: warning: left shift count >= width of type [enabled by default]
     return (PINB&(1<<6) ? 0 : (1<<17)) |
     ^
matrix.c:166:12: warning: left shift count >= width of type [enabled by default]
            (PINC&(1<<7) ? 0 : (1<<16)) |
            ^
I checked my code in that file but everything seemed to be fine.

Updated matrix.c file:

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     7    8    9   10   11  12   13  14  15   16  17 
 * pin: B0  B1  B2   B7  B3  E6  D0  D1  D2  D3  C6  B4  D5  B5  D7  D4  C7  B6
 */


static void  init_cols(void)
{
    // Input with pull-up(DDR:0, PORT:1)



    DDRE  &= ~(1<<6);
    PORTE |=  (1<<6);

    DDRD  &= ~(1<<7 | 1<<5 | 1<<4 | 1<<3 | 1<<2 | 1<<1 | 1<<0);
    PORTD |=  (1<<7 | 1<<5 | 1<<4 | 1<<3 | 1<<2 | 1<<1 | 1<<0);

    DDRC  &= ~(1<<7 | 1<<6);
    PORTC |=  (1<<7 | 1<<6);

    DDRB  &= ~(1<<7 | 1<<6 | 1<< 5 | 1<<4 | 1<<3 | 1<<2 | 1<<1 | 1<<0);
    PORTB |=  (1<<7 | 1<<6 | 1<< 5 | 1<<4 | 1<<3 | 1<<2 | 1<<1 | 1<<0);
}


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




/* Row pin configuration
 * row: 0    1    2    3    4    5 
 * pin: F0  F1  F4  F5  F6  F7
 */


static void unselect_rows(void)
{
    // Hi-Z(DDR:0, PORT:0) to unselect
    DDRD  &= ~0b11110011;
    PORTD &= ~0b11110011;
}



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;
        case 5:
            DDRF  |= (1<<7);
            PORTF &= ~(1<<7);
            break;
    }
}


User avatar
flabbergast

23 May 2016, 08:57

That error refers to this.

Post Reply

Return to “Workshop”