geekhack
geekhack Community => Keyboards => Topic started by: spwath on Mon, 17 July 2017, 12:11:58
-
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.
-
#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} \
}
};
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.
The entire K30-K36 row is missing.
Try this.
#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_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_NO, KC_##K36}, \
{ 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} \
}
};
-
Hmm, that is an issue. But I just fixed it, doesn't appear to be the issue.
I realize another error, TNS instead of TRNS, but that doesn't appear to be the main issue still.
Here is the error I get:
guest-QErMhI@tim-asus:~/Desktop/tmk_keyboard-master/keyboard/gh60$ make -f Makefile
sh: 1: dfu-programmer: not found
sh: 1: dfu-programmer: not found
-------- begin --------
avr-gcc (GCC) 4.8.2
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:42:1: error: parameter name missing
) { \
^
keymap_poker.c:4:2: warning: implicit declaration of function ‘KEYMAP’ [-Wimplicit-function-declaration]
KEYMAP(F6, F7, F8, F9, F10, F11, F12, \
^
keymap_poker.c:4:9: error: ‘F6’ undeclared here (not in a function)
KEYMAP(F6, F7, F8, F9, F10, F11, F12, \
^
keymap_poker.c:4:13: error: ‘F7’ undeclared here (not in a function)
KEYMAP(F6, F7, F8, F9, F10, F11, F12, \
^
keymap_poker.c:4:17: error: ‘F8’ undeclared here (not in a function)
KEYMAP(F6, F7, F8, F9, F10, F11, F12, \
^
keymap_poker.c:4:21: error: ‘F9’ undeclared here (not in a function)
KEYMAP(F6, F7, F8, F9, F10, F11, F12, \
^
keymap_poker.c:4:25: error: ‘F10’ undeclared here (not in a function)
KEYMAP(F6, F7, F8, F9, F10, F11, F12, \
^
keymap_poker.c:4:30: error: ‘F11’ undeclared here (not in a function)
KEYMAP(F6, F7, F8, F9, F10, F11, F12, \
^
keymap_poker.c:4:35: error: ‘F12’ undeclared here (not in a function)
KEYMAP(F6, F7, F8, F9, F10, F11, F12, \
^
keymap_poker.c:5:24: error: ‘BSPC’ undeclared here (not in a function)
6, 7, 8, 9, 0, BSPC, \
^
keymap_poker.c:6:6: error: ‘Y’ undeclared here (not in a function)
Y, U, I, O, P, LBRC, RBRC, \
^
keymap_poker.c:6:10: error: ‘U’ undeclared here (not in a function)
Y, U, I, O, P, LBRC, RBRC, \
^
keymap_poker.c:6:14: error: ‘I’ undeclared here (not in a function)
Y, U, I, O, P, LBRC, RBRC, \
^
keymap_poker.c:6:18: error: ‘O’ undeclared here (not in a function)
Y, U, I, O, P, LBRC, RBRC, \
^
keymap_poker.c:6:22: error: ‘P’ undeclared here (not in a function)
Y, U, I, O, P, LBRC, RBRC, \
^
keymap_poker.c:6:25: error: ‘LBRC’ undeclared here (not in a function)
Y, U, I, O, P, LBRC, RBRC, \
^
keymap_poker.c:6:31: error: ‘RBRC’ undeclared here (not in a function)
Y, U, I, O, P, LBRC, RBRC, \
^
keymap_poker.c:7:6: error: ‘H’ undeclared here (not in a function)
H, J, K, L, SCL, ENT, \
^
keymap_poker.c:7:9: error: ‘J’ undeclared here (not in a function)
H, J, K, L, SCL, ENT, \
^
keymap_poker.c:7:12: error: ‘K’ undeclared here (not in a function)
H, J, K, L, SCL, ENT, \
^
keymap_poker.c:7:15: error: ‘L’ undeclared here (not in a function)
H, J, K, L, SCL, ENT, \
^
keymap_poker.c:7:18: error: ‘SCL’ undeclared here (not in a function)
H, J, K, L, SCL, ENT, \
^
keymap_poker.c:7:24: error: ‘ENT’ undeclared here (not in a function)
H, J, K, L, SCL, ENT, \
^
keymap_poker.c:8:6: error: ‘N’ undeclared here (not in a function)
N, M, COMM, DOT, SLSH, QUOT, EQL,\
^
keymap_poker.c:8:9: error: ‘M’ undeclared here (not in a function)
N, M, COMM, DOT, SLSH, QUOT, EQL,\
^
keymap_poker.c:8:12: error: ‘COMM’ undeclared here (not in a function)
N, M, COMM, DOT, SLSH, QUOT, EQL,\
^
keymap_poker.c:8:18: error: ‘DOT’ undeclared here (not in a function)
N, M, COMM, DOT, SLSH, QUOT, EQL,\
^
keymap_poker.c:8:23: error: ‘SLSH’ undeclared here (not in a function)
N, M, COMM, DOT, SLSH, QUOT, EQL,\
^
keymap_poker.c:8:29: error: ‘QUOT’ undeclared here (not in a function)
N, M, COMM, DOT, SLSH, QUOT, EQL,\
^
keymap_poker.c:8:35: error: ‘EQL’ undeclared here (not in a function)
N, M, COMM, DOT, SLSH, QUOT, EQL,\
^
keymap_poker.c:9:6: error: ‘SPC’ undeclared here (not in a function)
SPC, FN1, DEL, MUTE, BSLS, MINS ),
^
keymap_poker.c:9:12: error: ‘FN1’ undeclared here (not in a function)
SPC, FN1, DEL, MUTE, BSLS, MINS ),
^
keymap_poker.c:9:17: error: ‘DEL’ undeclared here (not in a function)
SPC, FN1, DEL, MUTE, BSLS, MINS ),
^
keymap_poker.c:9:22: error: ‘MUTE’ undeclared here (not in a function)
SPC, FN1, DEL, MUTE, BSLS, MINS ),
^
keymap_poker.c:9:28: error: ‘BSLS’ undeclared here (not in a function)
SPC, FN1, DEL, MUTE, BSLS, MINS ),
^
keymap_poker.c:9:34: error: ‘MINS’ undeclared here (not in a function)
SPC, FN1, DEL, MUTE, BSLS, MINS ),
^
keymap_poker.c:10:9: error: ‘TRNS’ undeclared here (not in a function)
KEYMAP(TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, \
^
keymap_poker.c:14:36: error: ‘UP’ undeclared here (not in a function)
TRNS, TRNS, TRNS, TRNS, TRNS, UP, TRNS,\
^
keymap_poker.c:15:21: error: ‘TNS’ undeclared here (not in a function)
TRNS, TRNS, TNS, LEFT, DOWN, RGHT ),
^
keymap_poker.c:15:27: error: ‘LEFT’ undeclared here (not in a function)
TRNS, TRNS, TNS, LEFT, DOWN, RGHT ),
^
keymap_poker.c:15:33: error: ‘DOWN’ undeclared here (not in a function)
TRNS, TRNS, TNS, LEFT, DOWN, RGHT ),
^
keymap_poker.c:15:39: error: ‘RGHT’ undeclared here (not in a function)
TRNS, TRNS, TNS, LEFT, DOWN, RGHT ),
^
keymap_poker.c:21:2: warning: braces around scalar initializer [enabled by default]
[0] = ACTION_LAYER_MOMENTARY(1),
^
keymap_poker.c:21:2: warning: (near initialization for ‘fn_actions[0]’) [enabled by default]
keymap_poker.c:21:2: error: field name not in record or union initializer
keymap_poker.c:21:2: error: (near initialization for ‘fn_actions[0]’)
make: *** [obj_gh60_lufa/keymap_poker.o] Error 1
-
Are you using the Linux Bash Shell under Windows? Last I used there was some major bugs that didn't allow proper compilation of the software. If that's the case, you might want to download a computer emulator (namely VirtualBox) and install Linux there.
-
Are you using the Linux Bash Shell under Windows? Last I used there was some major bugs that didn't allow proper compilation of the software. If that's the case, you might want to download a computer emulator (namely VirtualBox) and install Linux there.
I was using a computer actually running Ubuntu.
-
Alright, nevermind that.
Would you please zip everything together and attach it here?
-
Alright, nevermind that.
Would you please zip everything together and attach it here?
Here.
I did it twice too, the first time it had this error, I changed a bunch of things, same error again.
So I started over, and I got the same error.
-
Here, I fixed your code.
In the header file you had a comma after the last element in the keymap and in the actual keymap file you had tabs as spacers. Also you declared a SCL which points to nothing. I assumed it was a scroll lock so I changed it to SCLK.
Everything else looked good.
Unzip this archive in your tmk/keyboard/ folder.
-
Here, I fixed your code.
In the header file you had a comma after the last element in the keymap and in the actual keymap file you had tabs as spacers. Also you declared a SCL which points to nothing. I assumed it was a scroll lock so I changed it to SCLK.
Everything else looked good.
Unzip this archive in your tmk/keyboard/ folder.
Thank you so much, that built properly. However, something else is wrong now. Uploaded to teensy, was fine. But keyboard just spams ]=]=]=]=]=]=]=]=]= forever, and opens infinite new tabs in edge. That might be a hardware issue though, ill have to check my connnections.
-
But keyboard just spams ]=]=]=]=]=]=]=]=]= forever, and opens infinite new tabs in edge. That might be a hardware issue though, ill have to check my connnections.
Sorry for the late reply, I went to bed after that.
I believe the issue is in the matrix, particularly in this bit of code
static void unselect_rows(void)
{
// Hi-Z(DDR:0, PORT:0) to unselect
DDRD &= ~0b10000000;
PORTD &= ~0b10000000;
DDRB &= ~0b11110001;
PORTB &= ~0b11110001;
}
I don't know how you wired your keyboard, but my wild guess is that the error is here.
As you can tell by the function's name, you have to unselect rows, if you do the other way around, the keys will be repeated endlessly.
Just try and invert zero and ones and see how the keyboard behaves.
-
But keyboard just spams ]=]=]=]=]=]=]=]=]= forever, and opens infinite new tabs in edge. That might be a hardware issue though, ill have to check my connnections.
Sorry for the late reply, I went to bed after that.
I believe the issue is in the matrix, particularly in this bit of code
static void unselect_rows(void)
{
// Hi-Z(DDR:0, PORT:0) to unselect
DDRD &= ~0b10000000;
PORTD &= ~0b10000000;
DDRB &= ~0b11110001;
PORTB &= ~0b11110001;
}
I don't know how you wired your keyboard, but my wild guess is that the error is here.
As you can tell by the function's name, you have to unselect rows, if you do the other way around, the keys will be repeated endlessly.
Just try and invert zero and ones and see how the keyboard behaves.
That makes sense, i selected rows with that and wondered why it was called unselect rows. I'll try that.
-
But keyboard just spams ]=]=]=]=]=]=]=]=]= forever, and opens infinite new tabs in edge. That might be a hardware issue though, ill have to check my connnections.
Sorry for the late reply, I went to bed after that.
I believe the issue is in the matrix, particularly in this bit of code
static void unselect_rows(void)
{
// Hi-Z(DDR:0, PORT:0) to unselect
DDRD &= ~0b10000000;
PORTD &= ~0b10000000;
DDRB &= ~0b11110001;
PORTB &= ~0b11110001;
}
I don't know how you wired your keyboard, but my wild guess is that the error is here.
As you can tell by the function's name, you have to unselect rows, if you do the other way around, the keys will be repeated endlessly.
Just try and invert zero and ones and see how the keyboard behaves.
That almost made it work. Keyboard works normally, but numbers activate F keys, as to the F keys. Also, my f10 0 P ; / collumn doesn't work. and the keys in the bottom row activate the whole column.
-
Keyboard works normally, but numbers activate F keys, as to the F keys. Also, my f10 0 P ; / collumn doesn't work. and the keys in the bottom row activate the whole column.
A close up picture of your wired teensy would help debugging, also, check your diodes.
-
Keyboard works normally, but numbers activate F keys, as to the F keys. Also, my f10 0 P ; / collumn doesn't work. and the keys in the bottom row activate the whole column.
A close up picture of your wired teensy would help debugging, also, check your diodes.
Bit unique, split keyboard, only one half done.
Pin config:
/* 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
*/
-
There's one thing that I overlooked as well.
When unselecting rows, the pin used must be set to zero, but the sequence goes from 7 to 0.
So the code should actually look like this.
static void unselect_rows(void)
{
// Hi-Z(DDR:0, PORT:0) to unselect
DDRB &= ~0b0111000;
PORTB &= ~0b0111000;
DDRD &= ~0b00000001;
PORTD &= ~0b00000001;
}
-
There's one thing that I overlooked as well.
When unselecting rows, the pin used must be set to zero, but the sequence goes from 7 to 0.
So the code should actually look like this.
static void unselect_rows(void)
{
// Hi-Z(DDR:0, PORT:0) to unselect
DDRB &= ~0b0111000;
PORTB &= ~0b0111000;
DDRD &= ~0b00000001;
PORTD &= ~0b00000001;
}
BUt 7-0 is still 8 numbers, so shouldn't mine be right? unless I'm misunderstanding this part.
-
BUt 7-0 is still 8 numbers, so shouldn't mine be right? unless I'm misunderstanding this part.
Yes, eight numbers meaning eight bits in the port. If I'm reading your code right, you had your pins backwards.
-
BUt 7-0 is still 8 numbers, so shouldn't mine be right? unless I'm misunderstanding this part.
Yes, eight numbers meaning eight bits in the port. If I'm reading your code right, you had your pins backwards.
The first port in your code has only 7 numbers.
-
BUt 7-0 is still 8 numbers, so shouldn't mine be right? unless I'm misunderstanding this part.
Yes, eight numbers meaning eight bits in the port. If I'm reading your code right, you had your pins backwards.
you are right though, I was backwards. Ill try fixing that.
EDIT:
wait, no, its correct, isn't it?
EDIT2:
I see what you mean now....
-
Any luck?
-
Any luck?
No. Oddly enough, when i switch the numbers around, it acts the exact same as it did flipped the other way...
-
Any luck?
No. Oddly enough, when i switch the numbers around, it acts the exact same as it did flipped the other way...
Then you probably have to invert the high/low state of the rows, like so:
static void unselect_rows(void)
{
// Hi-Z(DDR:0, PORT:0) to unselect
DDRB &= ~0b01111000;
PORTB &= ~0b10000111;
DDRD &= ~0b00000001;
PORTD &= ~0b11111110;
}