Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*.hex
/*.eep
/*.cof
/*.elf
/*.map
/*.sym
/*.lss
/.dep
/obj_kc60_lufa
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ TMK_DIR = ./tmk_core/tmk_core
TARGET_DIR = .

# project specific files
SRC = keymap_common.c \
matrix.c \
SRC = matrix.c \
led.c

ifdef KEYMAP
Expand Down Expand Up @@ -119,8 +118,9 @@ 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
#BACKLIGHT_ENABLE = yes
NKRO_ENABLE = yes # USB Nkey Rollover
#BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality


# Optimize size but this may cause error "relocation truncated to fit"
#EXTRALDFLAGS = -Wl,--relax
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ DIY compact keyboard by Massdrop.
## Build
Move to this directory then just run `make` like:

$ git submodule update tmk_core
$ git submodule update --init --recursive
$ make

Use `make -f Makefile.pjrc` if you want to use PJRC stack but I find no reason to do so now.
Expand Down
30 changes: 0 additions & 30 deletions keymap_common.c

This file was deleted.

7 changes: 1 addition & 6 deletions keymap_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.

#include <stdint.h>
#include <stdbool.h>
#include <avr/pgmspace.h>
#include "keycode.h"
#include "action.h"
#include "action_macro.h"
Expand All @@ -30,10 +29,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "keymap.h"


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


/* KC60 keymap definition macro
* K2C, K31 and K3C are extra keys for ISO
*/
Expand All @@ -51,7 +46,7 @@ extern const uint16_t fn_actions[];
{ KC_##K40, KC_##K41, KC_##K42, KC_NO, KC_NO, KC_##K45, KC_NO, KC_NO, KC_NO, KC_##K49, KC_##K4A, KC_##K4B, KC_##K4C, KC_##K4D } \
}

/* ANSI valiant. No extra keys for ISO */
/* ANSI variant. No extra keys for ISO */
#define KEYMAP_ANSI( \
K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D, \
K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, \
Expand Down
2 changes: 1 addition & 1 deletion keymap_default.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
/*
* Fn action definition
*/
const uint16_t PROGMEM fn_actions[] = {
const action_t PROGMEM fn_actions[] = {
[0] = ACTION_LAYER_MOMENTARY(1), /* Monentary layout 1 */
[1] = ACTION_LAYER_TOGGLE(1), /* Toggle layout */
[2] = ACTION_MODS_KEY(MOD_LSFT, KC_DEL), /* Cut */
Expand Down
2 changes: 1 addition & 1 deletion keymap_spacefn.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
/*
* Fn action definition
*/
const uint16_t PROGMEM fn_actions[] = {
const action_t PROGMEM fn_actions[] = {
[0] = ACTION_LAYER_TAP_KEY(1, KC_SPACE), /* SpaceFn layout 1 */
[1] = ACTION_LAYER_MOMENTARY(1), /* Momentary layout 1 */
[2] = ACTION_MODS_KEY(MOD_LSFT, KC_DEL), /* Cut */
Expand Down
78 changes: 15 additions & 63 deletions matrix.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,16 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "print.h"
#include "debug.h"
#include "util.h"
#include "timer.h"
#include "matrix.h"


#ifndef DEBOUNCE
# define DEBOUNCE 5
# define DEBOUNCE 5
#endif
static uint8_t debouncing = DEBOUNCE;
static bool debouncing = false;
static uint16_t debouncing_time = 0;


/* matrix state(1:on, 0:off) */
static matrix_row_t matrix[MATRIX_ROWS];
Expand All @@ -43,18 +46,6 @@ 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)
{
// disable JTAG
Expand All @@ -76,76 +67,41 @@ 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.
_delay_us(1); // delay for settling
matrix_row_t cols = read_cols();
if (matrix_debouncing[i] != cols) {
matrix_debouncing[i] = cols;
if (debouncing) {
debug("bounce!: "); debug_hex(debouncing); debug("\n");
dprintf("bounce: %d %d@%02X\n", timer_elapsed(debouncing_time), i, matrix_debouncing[i]^cols);
}
debouncing = DEBOUNCE;
matrix_debouncing[i] = cols;
debouncing = true;
debouncing_time = timer_read();
}
unselect_rows();
}

if (debouncing) {
if (--debouncing) {
_delay_ms(1);
} else {
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
matrix[i] = matrix_debouncing[i];
}
if (debouncing && timer_elapsed(debouncing_time) >= DEBOUNCE) {
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
matrix[i] = matrix_debouncing[i];
}
debouncing = false;
}

return 1;
}

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
* pin: F1 F0 E6 D7 D6 D4 C7 C6 B7 B5 B4 B3 B1 B0 (Rev.BLE)
* pin: F1 F0 E6 D7 D6 D4 C7 C6 B7 B5 B4 B3 B1 B0
*/
static void init_cols(void)
{

// Input with pull-up(DDR:0, PORT:1)
DDRF &= ~(1<<PF1 | 1<<PF0);
PORTF |= (1<<PF1 | 1<<PF0);
DDRE &= ~(1<<PE6);
Expand All @@ -156,7 +112,6 @@ static void init_cols(void)
PORTC |= (1<<PC7 | 1<<PC6);
DDRB &= ~(1<<PB7 | 1<<PB5 | 1<<PB4 | 1<<PB3 | 1<<PB1 | 1<<PB0);
PORTB |= (1<<PB7 | 1<<PB5 | 1<<PB4 | 1<<PB3 | 1<<PB1 | 1<<PB0);

}

static matrix_row_t read_cols(void)
Expand All @@ -183,17 +138,14 @@ static matrix_row_t read_cols(void)
*/
static void unselect_rows(void)
{
// Hi-Z(DDR:0, PORT:0) to unselect
DDRD &= ~(1<<PD0 | 1<<PD1 | 1<<PD5);
PORTD &= ~(1<<PD0 | 1<<PD1 | 1<<PD5);

DDRF &= ~(1<<PF6 | 1<<PF7);
PORTF &= ~(1<<PF6 | 1<<PF7);
}

static void select_row(uint8_t row)
{
// Output low(DDR:1, PORT:0) to select
switch (row) {
case 0:
DDRD |= (1<<0);
Expand Down
2 changes: 1 addition & 1 deletion tmk_core
Submodule tmk_core updated 2181 files