I have been working at this for a while, and it just wont work. When I try to build it, it says there are a ton of errors, all undeclared variables for the keyboard layout, like Y, U, I, O, P, ect...
It builds fine with the stock code, with no changes, but it wont for my layout. Anyone know whats wrong, or anyone really nice want to do it?
Here is the code I have now
MATRIX
#include <stdint.h>
#include <stdbool.h>
#include <avr/io.h>
#include <util/delay.h>
#include "print.h"
#include "debug.h"
#include "util.h"
#include "matrix.h"
#ifndef DEBOUNCE
# define DEBOUNCE 5
#endif
static uint8_t debouncing = DEBOUNCE;
/* matrix state(1:on, 0:off) */
static matrix_row_t matrix[MATRIX_ROWS];
static matrix_row_t matrix_debouncing[MATRIX_ROWS];
static matrix_row_t read_cols(void);
static void init_cols(void);
static void unselect_rows(void);
static void select_row(uint8_t row);
void matrix_init(void)
{
// initialize row and col
unselect_rows();
init_cols();
// initialize matrix state: all keys off
for (uint8_t i=0; i < MATRIX_ROWS; i++) {
matrix[i] = 0;
matrix_debouncing[i] = 0;
}
}
uint8_t matrix_scan(void)
{
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
select_row(i);
_delay_us(30); // without this wait read unstable value.
matrix_row_t cols = read_cols();
if (matrix_debouncing[i] != cols) {
matrix_debouncing[i] = cols;
if (debouncing) {
debug("bounce!: "); debug_hex(debouncing); debug("\n");
}
debouncing = DEBOUNCE;
}
unselect_rows();
}
if (debouncing) {
if (--debouncing) {
_delay_ms(1);
} else {
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
matrix[i] = matrix_debouncing[i];
}
}
}
return 1;
}
inline
matrix_row_t matrix_get_row(uint8_t row)
{
return matrix[row];
}
/* Column pin configuration
*COL: 1 2 3 4 5 6 7
*PIN: F0 F1 F4 F5 F6 F7 B6
*/
static void init_cols(void)
{
// Input with pull-up(DDR:0, PORT:1)
DDRF &= ~(1<<0 | 1<<1 | 1<<4 | 1<<5 | 1<<6 | 1<<7);
PORTF |= (1<<0 | 1<<1 | 1<<4 | 1<<5 | 1<<6 | 1<<7);
DDRB &= ~(1<<6);
PORTB |= (1<<6);
}
static matrix_row_t read_cols(void)
{
return (PINF&(1<<0) ? 0 : (1<<0)) |
(PINF&(1<<1) ? 0 : (1<<1)) |
(PINF&(1<<4) ? 0 : (1<<2)) |
(PINF&(1<<5) ? 0 : (1<<3)) |
(PINF&(1<<6) ? 0 : (1<<4)) |
(PINF&(1<<7) ? 0 : (1<<5)) |
(PINB&(1<<6) ? 0 : (1<<6)) ;
}
/* Row pin configuration
* ROW: 1 2 3 4 5 6
* PIN: D0 B7 B3 B2 B1 B0
*/
static void unselect_rows(void)
{
// Hi-Z(DDR:0, PORT:0) to unselect
DDRD &= ~0b10000000;
PORTD &= ~0b10000000;
DDRB &= ~0b11110001;
PORTB &= ~0b11110001;
}
static void select_row(uint8_t row)
{
// Output low(DDR:1, PORT:0) to select
switch (row) {
case 0:
DDRD |= (1<<0);
PORTD &= ~(1<<0);
break;
case 1:
DDRB |= (1<<7);
PORTB &= ~(1<<7);
break;
case 2:
DDRB |= (1<<3);
PORTB &= ~(1<<3);
break;
case 3:
DDRB |= (1<<2);
PORTB &= ~(1<<2);
break;
case 4:
DDRB |= (1<<1);
PORTB &= ~(1<<1);
break;
case 5:
DDRB |= (1<<0);
PORTB &= ~(1<<0);
break;
}
}
KEYMAP COMMON
#ifndef KEYMAP_COMMON_H
#define KEYMAP_COMMON_H
#include <stdint.h>
#include <stdbool.h>
#include "keycode.h"
#include "action.h"
#include "action_macro.h"
#include "report.h"
#include "host.h"
#include "print.h"
#include "debug.h"
#include "keymap.h"
/* GH60 keymap definition macro
* K2C, K31 and K3C are extra keys for ISO
*/
#define KEYMAP( \
K00, K01, K02, K03, K04, K05, K06, \
K10, K11, K12, K13, K14, K16, \
K20, K21, K22, K23, K24, K25, K26, \
K30, K31, K32, K33, K34, K36, \
K40, K41, K42, K43, K44, K45, K46, \
K50, K52, K53, K54, K55, K56, \
) { \
{ KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06}, \
{ 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_##K40, KC_##K41, KC_##K42, KC_##K43, KC_##K44, KC_NO, KC_##K46}, \
{ KC_##K50, KC_NO, KC_##K52, KC_##K53, KC_##K54, KC_##K55, KC_##K56} \
}
/* 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
#include "keymap_common.h"
const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
KEYMAP(F6, F7, F8, F9, F10, F11, F12, \
6, 7, 8, 9, 0, BSPC, \
Y, U, I, O, P, LBRC, RBRC, \
H, J, K, L, SCL, ENT, \
N, M, COMM, DOT, SLSH, QUOT, EQL,\
SPC, FN1, DEL, MUTE, BSLS, MINS ),
KEYMAP(TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, \
TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, \
TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, \
TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, \
TRNS, TRNS, TRNS, TRNS, TRNS, UP, TRNS,\
TRNS, TRNS, TNS, LEFT, DOWN, RGHT ),
};
const uint16_t PROGMEM fn_actions[] = {
[0] = ACTION_LAYER_MOMENTARY(1),
};
keymap poker seems to be where the issues are. I did the rest of the code too, but I dont think the issues are there, so I didnt put it up here.
Any ideas on whats wrong? I cant figure it out.