From 8451031e0a36861236fa2af702dd34798f9e2855 Mon Sep 17 00:00:00 2001 From: Kai Ryu Date: Thu, 21 Nov 2013 12:33:03 +0900 Subject: [PATCH 01/33] Add custom backlight feature --- common/backlight.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/common/backlight.c b/common/backlight.c index 00dc04a0..f13d9dbc 100644 --- a/common/backlight.c +++ b/common/backlight.c @@ -33,6 +33,16 @@ void backlight_init(void) void backlight_increase(void) { +#ifdef BACKLIGHT_CUSTOM + if (backlight_config.enable) { + if (backlight_config.level < BACKLIGHT_LEVELS) { + backlight_config.level++; + eeconfig_write_backlight(backlight_config.raw); + } + dprintf("backlight custom increase: %u\n", backlight_config.level); + backlight_set(backlight_config.level); + } +#else if(backlight_config.level < BACKLIGHT_LEVELS) { backlight_config.level++; @@ -41,10 +51,22 @@ void backlight_increase(void) } dprintf("backlight increase: %u\n", backlight_config.level); backlight_set(backlight_config.level); +#endif } void backlight_decrease(void) { +#ifdef BACKLIGHT_CUSTOM + if (backlight_config.enable) { + if(backlight_config.level > 1) + { + backlight_config.level--; + eeconfig_write_backlight(backlight_config.raw); + } + dprintf("backlight custom decrease: %u\n", backlight_config.level); + backlight_set(backlight_config.level); + } +#else if(backlight_config.level > 0) { backlight_config.level--; @@ -53,6 +75,7 @@ void backlight_decrease(void) } dprintf("backlight decrease: %u\n", backlight_config.level); backlight_set(backlight_config.level); +#endif } void backlight_toggle(void) From 01e895e931e7b06b9fbafea8738c348def88a945 Mon Sep 17 00:00:00 2001 From: Kai Ryu Date: Thu, 21 Nov 2013 12:35:34 +0900 Subject: [PATCH 02/33] Add *.swp to .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index c25d41d2..36d378de 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ *.map *.sym tags +*.swp From d926950e1783e136d5744f8a7fab7b043d9ff42c Mon Sep 17 00:00:00 2001 From: Kai Ryu Date: Thu, 21 Nov 2013 13:00:45 +0900 Subject: [PATCH 03/33] New feature to support external keymap in eeprom --- common.mk | 11 ++++- common/keyboard.c | 5 +++ common/keymap_ex.c | 102 +++++++++++++++++++++++++++++++++++++++++++++ common/keymap_ex.h | 62 +++++++++++++++++++++++++++ 4 files changed, 179 insertions(+), 1 deletion(-) create mode 100644 common/keymap_ex.c create mode 100644 common/keymap_ex.h diff --git a/common.mk b/common.mk index 5b70db94..350558f8 100644 --- a/common.mk +++ b/common.mk @@ -53,7 +53,11 @@ ifdef PS2_MOUSE_ENABLE OPT_DEFS += -DPS2_MOUSE_ENABLE endif -ifdef $(or MOUSEKEY_ENABLE, PS2_MOUSE_ENABLE) +ifdef MOUSEKEY_ENABLE + OPT_DEFS += -DMOUSE_ENABLE +endif + +ifdef PS4_MOUSE_ENABLE OPT_DEFS += -DMOUSE_ENABLE endif @@ -73,6 +77,11 @@ ifdef KEYMAP_SECTION_ENABLE EXTRALDFLAGS = -Wl,-L$(TOP_DIR),-Tldscript_keymap_avr5.x endif +ifdef KEYMAP_EX_ENABLE + SRC += $(COMMON_DIR)/keymap_ex.c + OPT_DEFS += -DKEYMAP_EX_ENABLE +endif + # Version string OPT_DEFS += -DVERSION=$(shell (git describe --always --dirty || echo 'unknown') 2> /dev/null) diff --git a/common/keyboard.c b/common/keyboard.c index 601e3abe..4ad92eb6 100644 --- a/common/keyboard.c +++ b/common/keyboard.c @@ -32,6 +32,7 @@ along with this program. If not, see . #include "eeconfig.h" #include "mousekey.h" #include "backlight.h" +#include "keymap_ex.h" #ifdef MATRIX_HAS_GHOST @@ -67,6 +68,10 @@ void keyboard_init(void) #ifdef BACKLIGHT_ENABLE backlight_init(); #endif + +#ifdef KEYMAP_EX_ENABLE + keymap_init(); +#endif } /* diff --git a/common/keymap_ex.c b/common/keymap_ex.c new file mode 100644 index 00000000..082e3207 --- /dev/null +++ b/common/keymap_ex.c @@ -0,0 +1,102 @@ +/* +Copyright 2013 Kai Ryu + +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 . +*/ + +#include +#include +#include "eeconfig.h" +#include "keymap_ex.h" +#include "debug.h" + +#ifdef KEYMAP_EX_ENABLE + +void keymap_init(void) { + if (!check_keymap_in_eeprom()) { + write_keymap_to_eeprom(); + } +} + +bool check_keymap_in_eeprom(void) { + return false; +} + +void write_keymap_to_eeprom(void) { + uint16_t checksum = EECONFIG_MAGIC_NUMBER; + const uint16_t *fn_actions = fn_actions_pointer(); + const uint8_t *keymaps = keymaps_pointer(); + // write fn_actions + if (fn_actions != NULL) { + uint16_t size_of_fn_actions = fn_actions_size(); + for (uint16_t i = 0; i < FN_ACTIONS_SIZE_EX; i++) { + uint16_t fn_action = 0; + if (i < size_of_fn_actions) { + fn_action = pgm_read_word(fn_actions + i); + } + eeconfig_write_keymap_fn_action(i, fn_action); + checksum ^= fn_action; + } + } + // write keymaps + if (keymaps != NULL) { + uint16_t size_of_keymaps = keymaps_size(); + for (uint16_t i = 0; i < KEYMAPS_SIZE_EX; i++) { + uint8_t keymap = 0; + if (i < size_of_keymaps) { + keymap = pgm_read_byte(keymaps + i); + } + eeconfig_write_keymap_key_by_index(i, keymap); + uint16_t keymap_word = keymap; + if (i & 1) { + keymap_word = keymap << 8; + } + checksum ^= keymap_word; + } + } + // write checksum + eeprom_write_word(&((keymap_ex_t*)EECONFIG_KEYMAP_EX)->checksum, checksum); +} + +uint8_t eeconfig_read_keymap_key(uint8_t layer, uint8_t row, uint8_t col) { + //return eeprom_read_byte(&((keymap_ex_t*)(EECONFIG_KEYMAP_EX))->keymaps[layer][row][col]); + return eeprom_read_byte((void*)(EECONFIG_KEYMAP_KEYMAPS + KEY_OFFSET(layer, row, col))); +} + +void eeconfig_write_keymap_key(uint8_t layer, uint8_t row, uint8_t col, uint8_t key) { + //return eeprom_write_byte(&((keymap_ex_t*)(EECONFIG_KEYMAP_EX))->keymaps[layer][row][col], key); + return eeprom_write_byte((void*)(EECONFIG_KEYMAP_KEYMAPS + KEY_OFFSET(layer, row, col)), key); +} + +uint8_t eeconfig_read_keymap_key_by_index(uint16_t index) { + //return eeprom_read_byte(((keymap_ex_t*)(EECONFIG_KEYMAP_EX)) + index); + return eeprom_read_byte((void*)(EECONFIG_KEYMAP_KEYMAPS + index)); +} + +void eeconfig_write_keymap_key_by_index(uint16_t index, uint8_t key) { + //return eeprom_write_byte(((keymap_ex_t*)(EECONFIG_KEYMAP_EX)) + index, key); + return eeprom_write_byte((void*)(EECONFIG_KEYMAP_KEYMAPS + index), key); +} + +uint16_t eeconfig_read_keymap_fn_action(uint8_t index) { + //return eeprom_read_word(&((keymap_ex_t*)(EECONFIG_KEYMAP_EX))->fn_actions[index]); + return eeprom_read_word((void*)(EECONFIG_KEYMAP_FN_ACTIONS + FN_ACTION_OFFSET(index))); +} + +void eeconfig_write_keymap_fn_action(uint8_t index, uint16_t fn_action) { + //return eeprom_write_word(&((keymap_ex_t*)(EECONFIG_KEYMAP_EX))->fn_actions[index], fn_action); + return eeprom_write_word((void*)(EECONFIG_KEYMAP_FN_ACTIONS + FN_ACTION_OFFSET(index)), fn_action); +} + +#endif diff --git a/common/keymap_ex.h b/common/keymap_ex.h new file mode 100644 index 00000000..b15c3fe1 --- /dev/null +++ b/common/keymap_ex.h @@ -0,0 +1,62 @@ +/* +Copyright 2013 Kai Ryu + +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 . +*/ + +#ifndef KEYMAP_EX_H +#define KEYMAP_EX_H + +#ifdef KEYMAP_EX_ENABLE + +#include +#include + +#define EECONFIG_KEYMAP_EX 0x10 +#define FN_ACTIONS_COUNT 8 +#define KEYMAPS_COUNT 8 + +typedef struct { + uint16_t checksum; + uint16_t fn_actions[FN_ACTIONS_COUNT]; + uint8_t keymaps[KEYMAPS_COUNT][MATRIX_ROWS][MATRIX_COLS]; +} keymap_ex_t; + +#define EECONFIG_KEYMAP_CHECKSUM (EECONFIG_KEYMAP_EX) +#define EECONFIG_KEYMAP_FN_ACTIONS (EECONFIG_KEYMAP_EX + sizeof(uint16_t)) +#define EECONFIG_KEYMAP_KEYMAPS (EECONFIG_KEYMAP_FN_ACTIONS + sizeof(uint16_t) * FN_ACTIONS_COUNT) + +#define FN_ACTIONS_SIZE_EX (sizeof(uint16_t) * FN_ACTIONS_COUNT) +#define KEYMAPS_SIZE_EX (sizeof(uint8_t) * KEYMAPS_COUNT * MATRIX_ROWS * MATRIX_COLS) +#define FN_ACTION_OFFSET(index) (sizeof(uint16_t) * index) +#define KEY_OFFSET(layer, row, col) (sizeof(uint8_t) * (layer * MATRIX_ROWS * MATRIX_COLS + row * MATRIX_COLS + col)) + +void keymap_init(void); +bool check_keymap_in_eeprom(void); +void write_keymap_to_eeprom(void); +uint8_t eeconfig_read_keymap_key(uint8_t layer, uint8_t row, uint8_t col); +void eeconfig_write_keymap_key(uint8_t layer, uint8_t row, uint8_t col, uint8_t key); +uint8_t eeconfig_read_keymap_key_by_index(uint16_t index); +void eeconfig_write_keymap_key_by_index(uint16_t index, uint8_t key); +uint16_t eeconfig_read_keymap_fn_action(uint8_t index); +void eeconfig_write_keymap_fn_action(uint8_t index, uint16_t fn_action); + +const uint8_t* keymaps_pointer(void); +const uint16_t* fn_actions_pointer(void); +uint16_t keymaps_size(void); +uint16_t fn_actions_size(void); + +#endif + +#endif From 91f86df368565f4af1f1fb5dc590a78b2a43041c Mon Sep 17 00:00:00 2001 From: Kai Ryu Date: Thu, 21 Nov 2013 13:44:32 +0900 Subject: [PATCH 04/33] Fix confusion of size and count --- common/keymap_ex.c | 16 +++++++++------- common/keymap_ex.h | 7 +++---- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/common/keymap_ex.c b/common/keymap_ex.c index 082e3207..cb67e8f4 100644 --- a/common/keymap_ex.c +++ b/common/keymap_ex.c @@ -30,7 +30,9 @@ void keymap_init(void) { } bool check_keymap_in_eeprom(void) { - return false; + uint16_t checksum_in_eeprom = eeprom_read_word(&((keymap_ex_t*)EECONFIG_KEYMAP_EX)->checksum); + uint16_t checksum = EECONFIG_MAGIC_NUMBER; + return (checksum_in_eeprom == checksum); } void write_keymap_to_eeprom(void) { @@ -39,10 +41,10 @@ void write_keymap_to_eeprom(void) { const uint8_t *keymaps = keymaps_pointer(); // write fn_actions if (fn_actions != NULL) { - uint16_t size_of_fn_actions = fn_actions_size(); - for (uint16_t i = 0; i < FN_ACTIONS_SIZE_EX; i++) { + uint16_t fn_actions_count_in_flash = fn_actions_count(); + for (uint16_t i = 0; i < FN_ACTIONS_COUNT; i++) { uint16_t fn_action = 0; - if (i < size_of_fn_actions) { + if (i < fn_actions_count_in_flash) { fn_action = pgm_read_word(fn_actions + i); } eeconfig_write_keymap_fn_action(i, fn_action); @@ -51,10 +53,10 @@ void write_keymap_to_eeprom(void) { } // write keymaps if (keymaps != NULL) { - uint16_t size_of_keymaps = keymaps_size(); - for (uint16_t i = 0; i < KEYMAPS_SIZE_EX; i++) { + uint16_t keys_count_in_flash = keys_count(); + for (uint16_t i = 0; i < KEYS_COUNT; i++) { uint8_t keymap = 0; - if (i < size_of_keymaps) { + if (i < keys_count_in_flash) { keymap = pgm_read_byte(keymaps + i); } eeconfig_write_keymap_key_by_index(i, keymap); diff --git a/common/keymap_ex.h b/common/keymap_ex.h index b15c3fe1..be229b10 100644 --- a/common/keymap_ex.h +++ b/common/keymap_ex.h @@ -37,8 +37,7 @@ typedef struct { #define EECONFIG_KEYMAP_FN_ACTIONS (EECONFIG_KEYMAP_EX + sizeof(uint16_t)) #define EECONFIG_KEYMAP_KEYMAPS (EECONFIG_KEYMAP_FN_ACTIONS + sizeof(uint16_t) * FN_ACTIONS_COUNT) -#define FN_ACTIONS_SIZE_EX (sizeof(uint16_t) * FN_ACTIONS_COUNT) -#define KEYMAPS_SIZE_EX (sizeof(uint8_t) * KEYMAPS_COUNT * MATRIX_ROWS * MATRIX_COLS) +#define KEYS_COUNT (KEYMAPS_COUNT * MATRIX_ROWS * MATRIX_COLS) #define FN_ACTION_OFFSET(index) (sizeof(uint16_t) * index) #define KEY_OFFSET(layer, row, col) (sizeof(uint8_t) * (layer * MATRIX_ROWS * MATRIX_COLS + row * MATRIX_COLS + col)) @@ -54,8 +53,8 @@ void eeconfig_write_keymap_fn_action(uint8_t index, uint16_t fn_action); const uint8_t* keymaps_pointer(void); const uint16_t* fn_actions_pointer(void); -uint16_t keymaps_size(void); -uint16_t fn_actions_size(void); +uint16_t keys_count(void); +uint16_t fn_actions_count(void); #endif From eb8b8010438617a15096ea25f0e0f977540a45ea Mon Sep 17 00:00:00 2001 From: Kai Ryu Date: Fri, 22 Nov 2013 10:58:02 +0900 Subject: [PATCH 05/33] Fix some debug codes --- common/keymap_ex.c | 6 ++++++ common/keymap_ex.h | 2 ++ 2 files changed, 8 insertions(+) diff --git a/common/keymap_ex.c b/common/keymap_ex.c index cb67e8f4..3d55c08c 100644 --- a/common/keymap_ex.c +++ b/common/keymap_ex.c @@ -32,6 +32,12 @@ void keymap_init(void) { bool check_keymap_in_eeprom(void) { uint16_t checksum_in_eeprom = eeprom_read_word(&((keymap_ex_t*)EECONFIG_KEYMAP_EX)->checksum); uint16_t checksum = EECONFIG_MAGIC_NUMBER; + for (uint16_t i = 0; i < KEYMAP_SIZE; i += 2) { + checksum ^= eeprom_read_word((void*)(EECONFIG_KEYMAP_FN_ACTIONS + i)); + } +#ifdef DEBUG + eeprom_write_word((void*)(EECONFIG_KEYMAP_DEBUG), checksum); +#endif return (checksum_in_eeprom == checksum); } diff --git a/common/keymap_ex.h b/common/keymap_ex.h index be229b10..435547a0 100644 --- a/common/keymap_ex.h +++ b/common/keymap_ex.h @@ -33,11 +33,13 @@ typedef struct { uint8_t keymaps[KEYMAPS_COUNT][MATRIX_ROWS][MATRIX_COLS]; } keymap_ex_t; +#define EECONFIG_KEYMAP_DEBUG (EECONFIG_KEYMAP_EX - sizeof(uint16_t)) #define EECONFIG_KEYMAP_CHECKSUM (EECONFIG_KEYMAP_EX) #define EECONFIG_KEYMAP_FN_ACTIONS (EECONFIG_KEYMAP_EX + sizeof(uint16_t)) #define EECONFIG_KEYMAP_KEYMAPS (EECONFIG_KEYMAP_FN_ACTIONS + sizeof(uint16_t) * FN_ACTIONS_COUNT) #define KEYS_COUNT (KEYMAPS_COUNT * MATRIX_ROWS * MATRIX_COLS) +#define KEYMAP_SIZE (sizeof(uint16_t) * FN_ACTIONS_COUNT + sizeof(uint8_t) * KEYS_COUNT) #define FN_ACTION_OFFSET(index) (sizeof(uint16_t) * index) #define KEY_OFFSET(layer, row, col) (sizeof(uint8_t) * (layer * MATRIX_ROWS * MATRIX_COLS + row * MATRIX_COLS + col)) From 334ae50bc30a4a97fe213389c06ee2d055839216 Mon Sep 17 00:00:00 2001 From: Kai Ryu Date: Mon, 2 Dec 2013 11:22:34 +0900 Subject: [PATCH 06/33] Change checksum algorism --- common/keymap_ex.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/common/keymap_ex.c b/common/keymap_ex.c index 3d55c08c..0c01f707 100644 --- a/common/keymap_ex.c +++ b/common/keymap_ex.c @@ -33,7 +33,7 @@ bool check_keymap_in_eeprom(void) { uint16_t checksum_in_eeprom = eeprom_read_word(&((keymap_ex_t*)EECONFIG_KEYMAP_EX)->checksum); uint16_t checksum = EECONFIG_MAGIC_NUMBER; for (uint16_t i = 0; i < KEYMAP_SIZE; i += 2) { - checksum ^= eeprom_read_word((void*)(EECONFIG_KEYMAP_FN_ACTIONS + i)); + checksum += eeprom_read_word((void*)(EECONFIG_KEYMAP_FN_ACTIONS + i)); } #ifdef DEBUG eeprom_write_word((void*)(EECONFIG_KEYMAP_DEBUG), checksum); @@ -54,7 +54,7 @@ void write_keymap_to_eeprom(void) { fn_action = pgm_read_word(fn_actions + i); } eeconfig_write_keymap_fn_action(i, fn_action); - checksum ^= fn_action; + checksum += fn_action; } } // write keymaps @@ -70,7 +70,7 @@ void write_keymap_to_eeprom(void) { if (i & 1) { keymap_word = keymap << 8; } - checksum ^= keymap_word; + checksum += keymap_word; } } // write checksum From ac5b5ff533fc4f4471bfbbb3e27082b1258ed01f Mon Sep 17 00:00:00 2001 From: Kai Ryu Date: Fri, 10 Jan 2014 09:14:11 +0900 Subject: [PATCH 07/33] Add some flexible define for keymap_ex --- common/keymap_ex.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/common/keymap_ex.h b/common/keymap_ex.h index 435547a0..e64bace6 100644 --- a/common/keymap_ex.h +++ b/common/keymap_ex.h @@ -24,8 +24,12 @@ along with this program. If not, see . #include #define EECONFIG_KEYMAP_EX 0x10 -#define FN_ACTIONS_COUNT 8 +#ifndef FN_ACTIONS_COUNT +#define FN_ACTIONS_COUNT 32 +#endif +#ifndef KEYMAPS_COUNT #define KEYMAPS_COUNT 8 +#endif typedef struct { uint16_t checksum; From fe4e5696a71a174d87400a65de3c4d228996f3ac Mon Sep 17 00:00:00 2001 From: Kai Ryu Date: Sat, 11 Jan 2014 22:17:36 +0900 Subject: [PATCH 08/33] Fix for an issue about backlight on --- common/backlight.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/common/backlight.c b/common/backlight.c index f13d9dbc..a0b2ce50 100644 --- a/common/backlight.c +++ b/common/backlight.c @@ -81,6 +81,12 @@ void backlight_decrease(void) void backlight_toggle(void) { backlight_config.enable ^= 1; + if (backlight_config.enable) + { + if (backlight_config.level == 0) { + backlight_config.level = 1; + } + } eeconfig_write_backlight(backlight_config.raw); dprintf("backlight toggle: %u\n", backlight_config.enable); backlight_set(backlight_config.enable ? backlight_config.level : 0); From 44845ab9dd4f98487ec73a8a88787024153b76df Mon Sep 17 00:00:00 2001 From: Kai Ryu Date: Sat, 11 Jan 2014 22:24:32 +0900 Subject: [PATCH 09/33] Add files for led matrix --- common/led_matrix.c | 20 ++++++++++++++++++++ common/led_matrix.h | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 common/led_matrix.c create mode 100644 common/led_matrix.h diff --git a/common/led_matrix.c b/common/led_matrix.c new file mode 100644 index 00000000..2a1e83d2 --- /dev/null +++ b/common/led_matrix.c @@ -0,0 +1,20 @@ +/* +Copyright 2013,2014 Kai Ryu + +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 . +*/ + +#include +#include +#include "led_matrix.h" diff --git a/common/led_matrix.h b/common/led_matrix.h new file mode 100644 index 00000000..f683ff09 --- /dev/null +++ b/common/led_matrix.h @@ -0,0 +1,41 @@ +/* +Copyright 2013,2014 Kai Ryu + +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 . +*/ + +#ifndef LED_MATRIX_H +#define LED_MATRIX_H + +#include +#include + +typedef struct { + union { + int8_t delta; + struct { + bool direction:1; + } + } + uint8_t value; +} led_matrix_element_t; + +uint8_t led_matrix_rows(void); +uint8_t led_matrix_cols(void); +void led_matrix_init(void); +void led_matrix_enable(void); +void led_matrix_disable(void); +uint8_t led_matrix_scan(void); + +#endif From f691f13ba2c118dc3665c265963386f9e15a148e Mon Sep 17 00:00:00 2001 From: Kai Ryu Date: Mon, 13 Jan 2014 22:04:24 +0900 Subject: [PATCH 10/33] Some implementations of led matrix --- common/led_matrix.c | 29 +++++++++++++++++++++++++++++ common/led_matrix.h | 6 ++++++ 2 files changed, 35 insertions(+) diff --git a/common/led_matrix.c b/common/led_matrix.c index 2a1e83d2..77e52e48 100644 --- a/common/led_matrix.c +++ b/common/led_matrix.c @@ -18,3 +18,32 @@ along with this program. If not, see . #include #include #include "led_matrix.h" + +#define LED_MATRIX_TIMER_TOP F_CPU/(256*64)/LED_MATRIX_ROWS + +void led_matrix_init(void) +{ + /* Timer1 setup */ + /* CTC mode */ + TCCR1B |= (1<> 8) & 0xFF; + OCR1AL = LED_MATRIX_TIMER_TOP & 0xFF; + SREG = sreg; +} + +void led_matrix_enable(void) +{ + /* Enable Compare Match Interrupt */ + TIMSK1 |= _BV(OCIE1A); +} + +void led_matrix_disable(void) +{ + /* Disable Compare Match Interrupt */ + TIMSK1 &= ~_BV(OCIE1A); +} diff --git a/common/led_matrix.h b/common/led_matrix.h index f683ff09..eb242446 100644 --- a/common/led_matrix.h +++ b/common/led_matrix.h @@ -31,11 +31,17 @@ typedef struct { uint8_t value; } led_matrix_element_t; +#ifdef LED_MATRIX_ENABLE uint8_t led_matrix_rows(void); uint8_t led_matrix_cols(void); void led_matrix_init(void); void led_matrix_enable(void); void led_matrix_disable(void); uint8_t led_matrix_scan(void); +#else +#define led_matrix_rows() +#define led_matrix_cols() +#define led_matrix_init() +#endif #endif From 6961b3d44abe8fa9397d8ce2a1b74ee3829da3bb Mon Sep 17 00:00:00 2001 From: Kai Ryu Date: Tue, 14 Jan 2014 16:12:21 +0900 Subject: [PATCH 11/33] Some more implementation of led matrix --- common.mk | 5 +++++ common/keyboard.c | 5 +++++ common/led_matrix.c | 42 ++++++++++++++++++++++++++++++++++++++++++ common/led_matrix.h | 32 +++++++++++++++++++++++++------- 4 files changed, 77 insertions(+), 7 deletions(-) diff --git a/common.mk b/common.mk index c8809c0c..bef00a3c 100644 --- a/common.mk +++ b/common.mk @@ -69,6 +69,11 @@ ifdef KEYMAP_EX_ENABLE OPT_DEFS += -DKEYMAP_EX_ENABLE endif +ifdef LED_MATRIX_ENABLE + SRC += $(COMMON_DIR)/led_matrix.c + OPT_DEFS += -DLED_MATRIX_ENABLE +endif + # Version string OPT_DEFS += -DVERSION=$(shell (git describe --always --dirty || echo 'unknown') 2> /dev/null) diff --git a/common/keyboard.c b/common/keyboard.c index 48a67e4a..c5de65ef 100644 --- a/common/keyboard.c +++ b/common/keyboard.c @@ -62,6 +62,11 @@ void keyboard_init(void) { timer_init(); matrix_init(); + +#ifdef LED_MATRIX_ENABLE + led_matrix_init(); +#endif + #ifdef PS2_MOUSE_ENABLE ps2_mouse_init(); #endif diff --git a/common/led_matrix.c b/common/led_matrix.c index 77e52e48..e5a4629f 100644 --- a/common/led_matrix.c +++ b/common/led_matrix.c @@ -17,12 +17,17 @@ along with this program. If not, see . #include #include +#include #include "led_matrix.h" #define LED_MATRIX_TIMER_TOP F_CPU/(256*64)/LED_MATRIX_ROWS +static led_matrix_element_t led_matrix[LED_MATRIX_ROWS][LED_MATRIX_COLS]; + void led_matrix_init(void) { + led_matrix_unselect_rows(); + led_matrix_write_cols(0); /* Timer1 setup */ /* CTC mode */ TCCR1B |= (1<. #include #include +#if (LED_MATRIX_COLS <= 8) +typedef uint8_t led_matrix_row_t; +#elif (LED_MATRIX_COLS <= 16) +typedef uint16_t led_matrix_row_t; +#elif (LED_MATRIX_COLS <= 32) +typedef uint32_t led_matrix_row_t; +#else +#error "LED_MATRIX_COLS: invalid value" +#endif + typedef struct { union { int8_t delta; struct { bool direction:1; - } - } + }; + }; uint8_t value; } led_matrix_element_t; #ifdef LED_MATRIX_ENABLE -uint8_t led_matrix_rows(void); -uint8_t led_matrix_cols(void); void led_matrix_init(void); void led_matrix_enable(void); void led_matrix_disable(void); -uint8_t led_matrix_scan(void); +void led_matrix_init_cols(void); +led_matrix_row_t led_matrix_make_cols(uint8_t row, uint8_t pwm); +void led_matrix_set_value(uint8_t row, uint8_t col, uint8_t value); +void led_matrix_set_delta(uint8_t row, uint8_t col, int8_t delta); +extern void led_matrix_write_cols(led_matrix_row_t cols); +extern void led_matrix_unselect_rows(void); +extern void led_matrix_select_row(uint8_t row); #else -#define led_matrix_rows() -#define led_matrix_cols() #define led_matrix_init() +#define led_matrix_enable() +#define led_matrix_disable() +#define led_matrix_init_cols() +#define led_matrix_write_cols() +#define led_matrix_unselect_rows() +#define led_matrix_select_row() #endif #endif From e550ba99abd815e0790acb9c894f2d00313eb12d Mon Sep 17 00:00:00 2001 From: Ralf Schmitt Date: Sat, 22 Mar 2014 12:41:45 +0100 Subject: [PATCH 12/33] Lightsaber clean ups --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index a561b38e..6596dc33 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,7 @@ You can find some keyboard specific projects under `converter` and `keyboard` di * [IIgs_Standard](keyboard/IIgs/) - Apple [IIGS] keyboard mod(by JeffreySung) * [macway](keyboard/macway/) - [Compact keyboard mod][GH_macway] [retired] * [KMAC](keyboard/kmac/) - Korean custom keyboard +* [Lightsaber](keyboard/lightsaber/) - Korean custom keyboard [GH_macway]: http://geekhack.org/showwiki.php?title=Island:11930 [GH_hhkb]: http://geekhack.org/showwiki.php?title=Island:12047 From e0b37553acda4665b31da433c1326358ab4d5d4e Mon Sep 17 00:00:00 2001 From: Johan Isacsson Date: Thu, 27 Mar 2014 23:59:25 +0100 Subject: [PATCH 13/33] Show correct function name for default layer set --- doc/keymap.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/keymap.md b/doc/keymap.md index 7ef7430c..3d78fc9c 100644 --- a/doc/keymap.md +++ b/doc/keymap.md @@ -269,7 +269,7 @@ Default Layer is a layer which always is valid and referred to when actions is n This sets Default Layer to given parameter `layer` and activate it. - ACTION_DEFAULT_LAYER(layer) + ACTION_DEFAULT_LAYER_SET(layer) #### 2.2.2 Momentary From 1c80d8d41ce77026182863c75ba80c8408160afa Mon Sep 17 00:00:00 2001 From: Kai Ryu Date: Tue, 8 Apr 2014 17:59:31 +0900 Subject: [PATCH 14/33] Extend reset eeconfig of bootmagic to reset keymap too --- common/bootmagic.c | 1 + common/eeconfig.c | 7 +++++++ common/keymap_ex.c | 6 +++++- common/keymap_ex.h | 3 ++- 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/common/bootmagic.c b/common/bootmagic.c index 036d4904..311a02f2 100644 --- a/common/bootmagic.c +++ b/common/bootmagic.c @@ -30,6 +30,7 @@ void bootmagic(void) /* eeconfig clear */ if (bootmagic_scan_keycode(BOOTMAGIC_KEY_EEPROM_CLEAR)) { + eeconfig_disable(); eeconfig_init(); } diff --git a/common/eeconfig.c b/common/eeconfig.c index 5bd47dc6..5aadf1c5 100644 --- a/common/eeconfig.c +++ b/common/eeconfig.c @@ -2,6 +2,7 @@ #include #include #include "eeconfig.h" +#include "keymap_ex.h" void eeconfig_init(void) { @@ -13,6 +14,9 @@ void eeconfig_init(void) #ifdef BACKLIGHT_ENABLE eeprom_write_byte(EECONFIG_BACKLIGHT, 0); #endif +#ifdef KEYMAP_EX_ENABLE + keymap_ex_init(); +#endif } void eeconfig_enable(void) @@ -22,6 +26,9 @@ void eeconfig_enable(void) void eeconfig_disable(void) { +#ifdef KEYMAP_EX_ENABLE + keymap_ex_disable(); +#endif eeprom_write_word(EECONFIG_MAGIC, 0xFFFF); } diff --git a/common/keymap_ex.c b/common/keymap_ex.c index 0c01f707..99859c06 100644 --- a/common/keymap_ex.c +++ b/common/keymap_ex.c @@ -23,12 +23,16 @@ along with this program. If not, see . #ifdef KEYMAP_EX_ENABLE -void keymap_init(void) { +void keymap_ex_init(void) { if (!check_keymap_in_eeprom()) { write_keymap_to_eeprom(); } } +void keymap_ex_disable(void) { + eeprom_write_word((void*)EECONFIG_KEYMAP_CHECKSUM, eeprom_read_word((void*)EECONFIG_KEYMAP_CHECKSUM) + 1); +} + bool check_keymap_in_eeprom(void) { uint16_t checksum_in_eeprom = eeprom_read_word(&((keymap_ex_t*)EECONFIG_KEYMAP_EX)->checksum); uint16_t checksum = EECONFIG_MAGIC_NUMBER; diff --git a/common/keymap_ex.h b/common/keymap_ex.h index e64bace6..ee6ff8c6 100644 --- a/common/keymap_ex.h +++ b/common/keymap_ex.h @@ -47,7 +47,8 @@ typedef struct { #define FN_ACTION_OFFSET(index) (sizeof(uint16_t) * index) #define KEY_OFFSET(layer, row, col) (sizeof(uint8_t) * (layer * MATRIX_ROWS * MATRIX_COLS + row * MATRIX_COLS + col)) -void keymap_init(void); +void keymap_ex_init(void); +void keymap_ex_disable(void); bool check_keymap_in_eeprom(void); void write_keymap_to_eeprom(void); uint8_t eeconfig_read_keymap_key(uint8_t layer, uint8_t row, uint8_t col); From 59772673889cfb9d8d78b7c25a1bad80aef0a1f0 Mon Sep 17 00:00:00 2001 From: Kai Ryu Date: Tue, 8 Apr 2014 18:05:39 +0900 Subject: [PATCH 15/33] Add PS2 mouse support for gh60 --- common/keyboard.c | 10 +++++++--- protocol/ps2.h | 1 + 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/common/keyboard.c b/common/keyboard.c index c5de65ef..933eb780 100644 --- a/common/keyboard.c +++ b/common/keyboard.c @@ -68,7 +68,9 @@ void keyboard_init(void) #endif #ifdef PS2_MOUSE_ENABLE - ps2_mouse_init(); + if (ps2_enabled()) { + ps2_mouse_init(); + } #endif #ifdef BOOTMAGIC_ENABLE @@ -80,7 +82,7 @@ void keyboard_init(void) #endif #ifdef KEYMAP_EX_ENABLE - keymap_init(); + keymap_ex_init(); #endif } @@ -133,7 +135,9 @@ MATRIX_LOOP_END: #endif #ifdef PS2_MOUSE_ENABLE - ps2_mouse_task(); + if (ps2_enabled()) { + ps2_mouse_task(); + } #endif // update LED diff --git a/protocol/ps2.h b/protocol/ps2.h index 483eea72..703e0c27 100644 --- a/protocol/ps2.h +++ b/protocol/ps2.h @@ -90,6 +90,7 @@ uint8_t ps2_host_send(uint8_t data); uint8_t ps2_host_recv_response(void); uint8_t ps2_host_recv(void); void ps2_host_set_led(uint8_t usb_led); +uint8_t ps2_enabled(void); /* Check port settings for clock and data line */ From b5fb2dbc1ed53d2e6756b5b03566a7cb3efbcc94 Mon Sep 17 00:00:00 2001 From: Ralf Schmitt Date: Tue, 8 Apr 2014 21:02:46 +0200 Subject: [PATCH 16/33] New macro: ACTION_BACKLIGHT_LEVEL(level) To have full control of the backlight level. --- common/action.c | 5 ++++- common/action_code.h | 18 +++++++++++------- common/backlight.c | 8 ++++++++ common/backlight.h | 7 +++---- doc/keymap.md | 4 ++++ 5 files changed, 30 insertions(+), 12 deletions(-) diff --git a/common/action.c b/common/action.c index e6938f5a..fddb97c5 100644 --- a/common/action.c +++ b/common/action.c @@ -294,7 +294,7 @@ void process_action(keyrecord_t *record) #ifdef BACKLIGHT_ENABLE case ACT_BACKLIGHT: if (!event.pressed) { - switch (action.backlight.id) { + switch (action.backlight.opt) { case BACKLIGHT_INCREASE: backlight_increase(); break; @@ -307,6 +307,9 @@ void process_action(keyrecord_t *record) case BACKLIGHT_STEP: backlight_step(); break; + case BACKLIGHT_LEVEL: + backlight_level(action.backlight.level); + break; } } break; diff --git a/common/action_code.h b/common/action_code.h index 8df86b11..50112d4d 100644 --- a/common/action_code.h +++ b/common/action_code.h @@ -87,7 +87,7 @@ along with this program. If not, see . * 1100|1111| id(8) Macro record? * * ACT_BACKLIGHT(1101): - * 1101|xxxx| id(8) Backlight commands + * 1101|opt |level(8) Backlight commands * * ACT_COMMAND(1110): * 1110|opt | id(8) Built-in Command exec @@ -163,7 +163,9 @@ typedef union { uint8_t kind :4; } usage; struct action_backlight { - uint8_t id :8; + uint8_t level :8; + uint8_t opt :4; + uint8_t kind :4; } backlight; struct action_command { uint8_t id :8; @@ -282,21 +284,23 @@ enum layer_pram_tap_op { /* * Extensions */ -enum backlight_id { +enum backlight_opt { BACKLIGHT_INCREASE = 0, BACKLIGHT_DECREASE = 1, BACKLIGHT_TOGGLE = 2, BACKLIGHT_STEP = 3, + BACKLIGHT_LEVEL = 4, }; /* Macro */ #define ACTION_MACRO(id) ACTION(ACT_MACRO, (id)) #define ACTION_MACRO_TAP(id) ACTION(ACT_MACRO, FUNC_TAP<<8 | (id)) #define ACTION_MACRO_OPT(id, opt) ACTION(ACT_MACRO, (opt)<<8 | (id)) /* Backlight */ -#define ACTION_BACKLIGHT_INCREASE() ACTION(ACT_BACKLIGHT, BACKLIGHT_INCREASE) -#define ACTION_BACKLIGHT_DECREASE() ACTION(ACT_BACKLIGHT, BACKLIGHT_DECREASE) -#define ACTION_BACKLIGHT_TOGGLE() ACTION(ACT_BACKLIGHT, BACKLIGHT_TOGGLE) -#define ACTION_BACKLIGHT_STEP() ACTION(ACT_BACKLIGHT, BACKLIGHT_STEP) +#define ACTION_BACKLIGHT_INCREASE() ACTION(ACT_BACKLIGHT, BACKLIGHT_INCREASE << 8) +#define ACTION_BACKLIGHT_DECREASE() ACTION(ACT_BACKLIGHT, BACKLIGHT_DECREASE << 8) +#define ACTION_BACKLIGHT_TOGGLE() ACTION(ACT_BACKLIGHT, BACKLIGHT_TOGGLE << 8) +#define ACTION_BACKLIGHT_STEP() ACTION(ACT_BACKLIGHT, BACKLIGHT_STEP << 8) +#define ACTION_BACKLIGHT_LEVEL(level) ACTION(ACT_BACKLIGHT, BACKLIGHT_LEVEL << 8 | level) /* Command */ #define ACTION_COMMAND(id, opt) ACTION(ACT_COMMAND, (opt)<<8 | (addr)) /* Function */ diff --git a/common/backlight.c b/common/backlight.c index 00dc04a0..558ad9b0 100644 --- a/common/backlight.c +++ b/common/backlight.c @@ -75,3 +75,11 @@ void backlight_step(void) dprintf("backlight step: %u\n", backlight_config.level); backlight_set(backlight_config.level); } + +void backlight_level(uint8_t level) +{ + backlight_config.level ^= level; + backlight_config.enable = !!backlight_config.level; + eeconfig_write_backlight(backlight_config.raw); + backlight_set(backlight_config.level); +} diff --git a/common/backlight.h b/common/backlight.h index 685c422a..525ec8bb 100644 --- a/common/backlight.h +++ b/common/backlight.h @@ -24,18 +24,17 @@ along with this program. If not, see . typedef union { uint8_t raw; struct { - bool enable:1; - uint8_t level:7; + bool enable :1; + uint8_t level :7; }; } backlight_config_t; void backlight_init(void); - void backlight_increase(void); void backlight_decrease(void); void backlight_toggle(void); void backlight_step(void); - void backlight_set(uint8_t level); +void backlight_level(uint8_t level); #endif diff --git a/doc/keymap.md b/doc/keymap.md index 3d78fc9c..11feeac2 100644 --- a/doc/keymap.md +++ b/doc/keymap.md @@ -444,6 +444,10 @@ Step through backlight levels. ACTION_BACKLIGHT_STEP() +Turn a specific backlight level on or off. + + ACTION_BACKLIGHT_LEVEL(1) + #### 2.5.2 Turn on / off backlight Turn the backlight on and off without changing level. From b4f3febe8dff3289ba6d05f02c4ae6914f5981be Mon Sep 17 00:00:00 2001 From: Kai Ryu Date: Tue, 15 Apr 2014 16:28:48 +0900 Subject: [PATCH 17/33] New branch for breathing led feature --- common.mk | 5 ++ common/backlight.c | 36 ++++++++++++-- common/backlight.h | 3 ++ common/breathing_led.c | 106 +++++++++++++++++++++++++++++++++++++++++ common/breathing_led.h | 39 +++++++++++++++ common/eeconfig.c | 8 ++++ common/eeconfig.h | 6 +++ 7 files changed, 199 insertions(+), 4 deletions(-) create mode 100644 common/breathing_led.c create mode 100644 common/breathing_led.h diff --git a/common.mk b/common.mk index bef00a3c..09561cba 100644 --- a/common.mk +++ b/common.mk @@ -54,6 +54,11 @@ ifdef SLEEP_LED_ENABLE OPT_DEFS += -DNO_SUSPEND_POWER_DOWN endif +ifdef BREATHING_LED_ENABLE + SRC += $(COMMON_DIR)/breathing_led.c + OPT_DEFS += -DBREATHING_LED_ENABLE +endif + ifdef BACKLIGHT_ENABLE SRC += $(COMMON_DIR)/backlight.c OPT_DEFS += -DBACKLIGHT_ENABLE diff --git a/common/backlight.c b/common/backlight.c index a0b2ce50..ee8169c6 100644 --- a/common/backlight.c +++ b/common/backlight.c @@ -16,6 +16,7 @@ along with this program. If not, see . */ #include "backlight.h" +#include "breathing_led.h" #include "eeconfig.h" #include "debug.h" @@ -33,7 +34,7 @@ void backlight_init(void) void backlight_increase(void) { -#ifdef BACKLIGHT_CUSTOM +#if defined(BACKLIGHT_CUSTOM) || defined(BREATHING_LED_ENABLE) if (backlight_config.enable) { if (backlight_config.level < BACKLIGHT_LEVELS) { backlight_config.level++; @@ -42,6 +43,9 @@ void backlight_increase(void) dprintf("backlight custom increase: %u\n", backlight_config.level); backlight_set(backlight_config.level); } +#ifdef BREATHING_LED_ENABLE + breathing_led_increase(); +#endif #else if(backlight_config.level < BACKLIGHT_LEVELS) { @@ -56,7 +60,7 @@ void backlight_increase(void) void backlight_decrease(void) { -#ifdef BACKLIGHT_CUSTOM +#if defined(BACKLIGHT_CUSTOM) || defined(BREATHING_LED_ENABLE) if (backlight_config.enable) { if(backlight_config.level > 1) { @@ -66,6 +70,9 @@ void backlight_decrease(void) dprintf("backlight custom decrease: %u\n", backlight_config.level); backlight_set(backlight_config.level); } +#ifdef BREATHING_LED_ENABLE + breathing_led_decrease(); +#endif #else if(backlight_config.level > 0) { @@ -80,16 +87,37 @@ void backlight_decrease(void) void backlight_toggle(void) { +#ifdef BREATHING_LED_ENABLE + if (breathing_led_is_enabled()) { + breathing_led_disable(); + backlight_disable(); + return; + } +#endif backlight_config.enable ^= 1; - if (backlight_config.enable) - { + if (backlight_config.enable) { +#if defined(BACKLIGHT_CUSTOM) || defined(BREATHING_LED_ENABLE) + backlight_enable(); +#endif if (backlight_config.level == 0) { backlight_config.level = 1; } } + else { +#ifndef BREATHING_LED_ENABLE +#ifdef BACKLIGHT_CUSTOM + backlight_disable(); +#endif +#endif + } eeconfig_write_backlight(backlight_config.raw); dprintf("backlight toggle: %u\n", backlight_config.enable); backlight_set(backlight_config.enable ? backlight_config.level : 0); +#ifdef BREATHING_LED_ENABLE + if (!backlight_config.enable) { + breathing_led_enable(); + } +#endif } void backlight_step(void) diff --git a/common/backlight.h b/common/backlight.h index 685c422a..a33c727a 100644 --- a/common/backlight.h +++ b/common/backlight.h @@ -36,6 +36,9 @@ void backlight_decrease(void); void backlight_toggle(void); void backlight_step(void); +void backlight_enable(void); +void backlight_disable(void); void backlight_set(uint8_t level); +void backlight_set_raw(uint8_t raw); #endif diff --git a/common/breathing_led.c b/common/breathing_led.c new file mode 100644 index 00000000..d71bf5b8 --- /dev/null +++ b/common/breathing_led.c @@ -0,0 +1,106 @@ +#include +#include +#include +#include "led.h" +#include "breathing_led.h" +#include "backlight.h" +#include "debug.h" + +#define BREATHING_LED_TIMER_TOP F_CPU/64 + +breathing_led_config_t breathing_led_config; + +void breathing_led_init(void) +{ + /* Timer3 setup */ + /* CTC mode */ + TCCR3B |= _BV(WGM12); + /* Clock selelct: clk/1 */ + TCCR3B |= _BV(CS10); + /* Set TOP value */ + uint8_t sreg = SREG; + cli(); + OCR3AH = (BREATHING_LED_TIMER_TOP>>8)&0xff; + OCR3AL = BREATHING_LED_TIMER_TOP&0xff; + SREG = sreg; +} + +bool breathing_led_is_enabled(void) +{ + return breathing_led_config.enable; +} + +void breathing_led_enable(void) +{ + /* Enable Compare Match Interrupt */ + TIMSK3 |= _BV(OCIE3A); + breathing_led_config.enable = true; + dprintf("breathing led on: %u\n", breathing_led_config.enable); + eeconfig_write_breathing_led(breathing_led_config.raw); +} + +void breathing_led_disable(void) +{ + /* Disable Compare Match Interrupt */ + TIMSK3 &= ~_BV(OCIE3A); + breathing_led_config.enable = false; + dprintf("breathing led off: %u\n", breathing_led_config.enable); + eeconfig_write_breathing_led(breathing_led_config.raw); +} + +void breathing_led_toggle(void) +{ + /* Disable Compare Match Interrupt */ + TIMSK3 ^= _BV(OCIE3A); + breathing_led_config.enable ^= 1; + dprintf("breathing led toggle: %u\n", breathing_led_config.enable); + eeconfig_write_breathing_led(breathing_led_config.raw); +} + +void breathing_led_increase(void) +{ + if (breathing_led_config.enable) { + if (breathing_led_config.level < BREATHING_LED_LEVELS) { + breathing_led_config.level++; + eeconfig_write_breathing_led(breathing_led_config.raw); + } + dprintf("breathing led speed increase: %u\n", breathing_led_config.level); + } +} + +void breathing_led_decrease(void) +{ + if (breathing_led_config.enable) { + if (breathing_led_config.level > 0) + { + breathing_led_config.level--; + eeconfig_write_breathing_led(breathing_led_config.raw); + } + dprintf("breathing led speed decrease: %u\n", breathing_led_config.level); + } +} + +/* Breathing LED brighness(PWM On period) table + * (64[steps] * 4[duration]) / 64[PWM periods/s] = 4 second breath cycle + * + * http://www.wolframalpha.com/input/?i=%28sin%28+x%2F64*pi%29**8+*+255%2C+x%3D0+to+63 + * (0..63).each {|x| p ((sin(x/64.0*PI)**8)*255).to_i } + */ +static const uint8_t breathing_table[64] PROGMEM = { +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 4, 6, 10, +15, 23, 32, 44, 58, 74, 93, 113, 135, 157, 179, 199, 218, 233, 245, 252, +255, 252, 245, 233, 218, 199, 179, 157, 135, 113, 93, 74, 58, 44, 32, 23, +15, 10, 6, 4, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 +}; + +ISR(TIMER3_COMPA_vect) +{ + uint8_t index = 0; + uint8_t step = 0; + step++; + if (step >= BREATHING_LED_LEVELS - breathing_led_config.level) { + step = 0; + index++; + backlight_set_raw(pgm_read_byte(&breathing_table[index])); + } +} diff --git a/common/breathing_led.h b/common/breathing_led.h new file mode 100644 index 00000000..fb31668f --- /dev/null +++ b/common/breathing_led.h @@ -0,0 +1,39 @@ +#ifndef BREATHING_LED_H +#define BREATHING_LED_H + + +#ifdef BREATHING_LED_ENABLE + +#include +#include + +#ifndef BREATHING_LED_LEVEL +#define BREATHING_LED_LEVEL 1 +#endif + +typedef union { + uint8_t raw; + struct { + bool enable:1; + uint8_t level:7; + }; +} breathing_led_config_t; + +void breathing_led_init(void); +bool breathing_led_is_enabled(void); +void breathing_led_enable(void); +void breathing_led_disable(void); +void breathing_led_toggle(void); +void breathing_led_increase(void); +void breathing_led_decrease(void); + +#else + +#define breathing_led_init() +#define breathing_led_enable() +#define breathing_led_disable() +#define breathing_led_toggle() + +#endif + +#endif diff --git a/common/eeconfig.c b/common/eeconfig.c index 5aadf1c5..ab9bae3c 100644 --- a/common/eeconfig.c +++ b/common/eeconfig.c @@ -14,6 +14,9 @@ void eeconfig_init(void) #ifdef BACKLIGHT_ENABLE eeprom_write_byte(EECONFIG_BACKLIGHT, 0); #endif +#ifdef BREATHING_LED_ENABLE + eeprom_write_byte(EECONFIG_BREATHING_LED, 0); +#endif #ifdef KEYMAP_EX_ENABLE keymap_ex_init(); #endif @@ -50,3 +53,8 @@ void eeconfig_write_keymap(uint8_t val) { eeprom_write_byte(EECONFIG_KEYMAP, val uint8_t eeconfig_read_backlight(void) { return eeprom_read_byte(EECONFIG_BACKLIGHT); } void eeconfig_write_backlight(uint8_t val) { eeprom_write_byte(EECONFIG_BACKLIGHT, val); } #endif + +#ifdef BREATHING_LED_ENABLE +uint8_t eeconfig_read_breathing_led(void) { return eeprom_read_byte(EECONFIG_BREATHING_LED); } +void eeconfig_write_breathing_led(uint8_t val) { eeprom_write_byte(EECONFIG_BREATHING_LED, val); } +#endif diff --git a/common/eeconfig.h b/common/eeconfig.h index e1b5ae28..36c18143 100644 --- a/common/eeconfig.h +++ b/common/eeconfig.h @@ -31,6 +31,7 @@ along with this program. If not, see . #define EECONFIG_KEYMAP (uint8_t *)4 #define EECONFIG_MOUSEKEY_ACCEL (uint8_t *)5 #define EECONFIG_BACKLIGHT (uint8_t *)6 +#define EECONFIG_BREATHING_LED (uint8_t *)7 /* debug bit */ @@ -71,4 +72,9 @@ uint8_t eeconfig_read_backlight(void); void eeconfig_write_backlight(uint8_t val); #endif +#ifdef BREATHING_LED_ENABLE +uint8_t eeconfig_read_breathing_led(void); +void eeconfig_write_breathing_led(uint8_t val); +#endif + #endif From f121a98ae39bc23a5d9cf5533cbcf83c2523a2a0 Mon Sep 17 00:00:00 2001 From: Kai Ryu Date: Wed, 16 Apr 2014 12:12:15 +0900 Subject: [PATCH 18/33] Bug fix and optimization of breathing led --- common/breathing_led.c | 25 +++++++++++-------------- common/keyboard.c | 4 ++++ 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/common/breathing_led.c b/common/breathing_led.c index d71bf5b8..80bb9d59 100644 --- a/common/breathing_led.c +++ b/common/breathing_led.c @@ -6,7 +6,7 @@ #include "backlight.h" #include "debug.h" -#define BREATHING_LED_TIMER_TOP F_CPU/64 +#define BREATHING_LED_TIMER_TOP F_CPU/256 breathing_led_config_t breathing_led_config; @@ -14,9 +14,9 @@ void breathing_led_init(void) { /* Timer3 setup */ /* CTC mode */ - TCCR3B |= _BV(WGM12); - /* Clock selelct: clk/1 */ - TCCR3B |= _BV(CS10); + TCCR3B |= _BV(WGM32); + /* Clock selelct: clk/8 */ + TCCR3B |= _BV(CS30); /* Set TOP value */ uint8_t sreg = SREG; cli(); @@ -81,22 +81,19 @@ void breathing_led_decrease(void) } /* Breathing LED brighness(PWM On period) table - * (64[steps] * 4[duration]) / 64[PWM periods/s] = 4 second breath cycle * - * http://www.wolframalpha.com/input/?i=%28sin%28+x%2F64*pi%29**8+*+255%2C+x%3D0+to+63 - * (0..63).each {|x| p ((sin(x/64.0*PI)**8)*255).to_i } + * http://www.wolframalpha.com/input/?i=Table%5Bfloor%28%28exp%28sin%28x%2F256*2*pi%2B3%2F2*pi%29%29-1%2Fe%29*%28256%2F%28e-1%2Fe%29%29%29%2C+%7Bx%2C0%2C255%2C1%7D%5D + * Table[floor((exp(sin(x/256*2*pi+3/2*pi))-1/e)*(256/(e-1/e))), {x,0,255,1}] + * (0..255).each {|x| print ((exp(sin(x/256.0*2*PI+3.0/2*PI))-1/E)*(256/(E-1/E))).to_i, ', ' } */ -static const uint8_t breathing_table[64] PROGMEM = { -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 4, 6, 10, -15, 23, 32, 44, 58, 74, 93, 113, 135, 157, 179, 199, 218, 233, 245, 252, -255, 252, 245, 233, 218, 199, 179, 157, 135, 113, 93, 74, 58, 44, 32, 23, -15, 10, 6, 4, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 +static const uint8_t breathing_table[256] PROGMEM = { +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 8, 8, 9, 10, 11, 11, 12, 13, 14, 15, 16, 17, 18, 19, 21, 22, 23, 25, 26, 27, 29, 30, 32, 34, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 56, 58, 61, 63, 66, 68, 71, 74, 77, 80, 83, 86, 89, 92, 95, 98, 102, 105, 108, 112, 116, 119, 123, 126, 130, 134, 138, 142, 145, 149, 153, 157, 161, 165, 169, 173, 176, 180, 184, 188, 192, 195, 199, 203, 206, 210, 213, 216, 219, 223, 226, 228, 231, 234, 236, 239, 241, 243, 245, 247, 248, 250, 251, 252, 253, 254, 255, 255, 255, 255, 255, 255, 255, 254, 253, 252, 251, 250, 248, 247, 245, 243, 241, 239, 236, 234, 231, 228, 226, 223, 219, 216, 213, 210, 206, 203, 199, 195, 192, 188, 184, 180, 176, 173, 169, 165, 161, 157, 153, 149, 145, 142, 138, 134, 130, 126, 123, 119, 116, 112, 108, 105, 102, 98, 95, 92, 89, 86, 83, 80, 77, 74, 71, 68, 66, 63, 61, 58, 56, 53, 51, 49, 47, 45, 43, 41, 39, 37, 35, 34, 32, 30, 29, 27, 26, 25, 23, 22, 21, 19, 18, 17, 16, 15, 14, 13, 12, 11, 11, 10, 9, 8, 8, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 2, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; ISR(TIMER3_COMPA_vect) { - uint8_t index = 0; - uint8_t step = 0; + static uint8_t index = 0; + static uint8_t step = 0; step++; if (step >= BREATHING_LED_LEVELS - breathing_led_config.level) { step = 0; diff --git a/common/keyboard.c b/common/keyboard.c index 933eb780..29155cfe 100644 --- a/common/keyboard.c +++ b/common/keyboard.c @@ -81,6 +81,10 @@ void keyboard_init(void) backlight_init(); #endif +#ifdef BREATHING_LED_ENABLE + breathing_led_init(); +#endif + #ifdef KEYMAP_EX_ENABLE keymap_ex_init(); #endif From 5cc4c69fae06888da6ccb92a3dce4b8cc31a9c32 Mon Sep 17 00:00:00 2001 From: Kai Ryu Date: Fri, 18 Apr 2014 12:12:59 +0900 Subject: [PATCH 19/33] Change software pwm method to fix blink issue --- common/breathing_led.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/breathing_led.c b/common/breathing_led.c index 80bb9d59..497f9a6d 100644 --- a/common/breathing_led.c +++ b/common/breathing_led.c @@ -97,7 +97,7 @@ ISR(TIMER3_COMPA_vect) step++; if (step >= BREATHING_LED_LEVELS - breathing_led_config.level) { step = 0; - index++; backlight_set_raw(pgm_read_byte(&breathing_table[index])); + index++; } } From 1b2685f37467045d9230db5b3adb09ed91705259 Mon Sep 17 00:00:00 2001 From: Kai Ryu Date: Fri, 18 Apr 2014 14:33:57 +0900 Subject: [PATCH 20/33] Simplifiy breathing led feature and code --- common/backlight.c | 36 +++---------------------- common/backlight.h | 3 --- common/breathing_led.c | 60 +++++++++++------------------------------- common/breathing_led.h | 22 +++------------- common/eeconfig.c | 8 ------ common/eeconfig.h | 6 ----- 6 files changed, 23 insertions(+), 112 deletions(-) diff --git a/common/backlight.c b/common/backlight.c index ee8169c6..a0b2ce50 100644 --- a/common/backlight.c +++ b/common/backlight.c @@ -16,7 +16,6 @@ along with this program. If not, see . */ #include "backlight.h" -#include "breathing_led.h" #include "eeconfig.h" #include "debug.h" @@ -34,7 +33,7 @@ void backlight_init(void) void backlight_increase(void) { -#if defined(BACKLIGHT_CUSTOM) || defined(BREATHING_LED_ENABLE) +#ifdef BACKLIGHT_CUSTOM if (backlight_config.enable) { if (backlight_config.level < BACKLIGHT_LEVELS) { backlight_config.level++; @@ -43,9 +42,6 @@ void backlight_increase(void) dprintf("backlight custom increase: %u\n", backlight_config.level); backlight_set(backlight_config.level); } -#ifdef BREATHING_LED_ENABLE - breathing_led_increase(); -#endif #else if(backlight_config.level < BACKLIGHT_LEVELS) { @@ -60,7 +56,7 @@ void backlight_increase(void) void backlight_decrease(void) { -#if defined(BACKLIGHT_CUSTOM) || defined(BREATHING_LED_ENABLE) +#ifdef BACKLIGHT_CUSTOM if (backlight_config.enable) { if(backlight_config.level > 1) { @@ -70,9 +66,6 @@ void backlight_decrease(void) dprintf("backlight custom decrease: %u\n", backlight_config.level); backlight_set(backlight_config.level); } -#ifdef BREATHING_LED_ENABLE - breathing_led_decrease(); -#endif #else if(backlight_config.level > 0) { @@ -87,37 +80,16 @@ void backlight_decrease(void) void backlight_toggle(void) { -#ifdef BREATHING_LED_ENABLE - if (breathing_led_is_enabled()) { - breathing_led_disable(); - backlight_disable(); - return; - } -#endif backlight_config.enable ^= 1; - if (backlight_config.enable) { -#if defined(BACKLIGHT_CUSTOM) || defined(BREATHING_LED_ENABLE) - backlight_enable(); -#endif + if (backlight_config.enable) + { if (backlight_config.level == 0) { backlight_config.level = 1; } } - else { -#ifndef BREATHING_LED_ENABLE -#ifdef BACKLIGHT_CUSTOM - backlight_disable(); -#endif -#endif - } eeconfig_write_backlight(backlight_config.raw); dprintf("backlight toggle: %u\n", backlight_config.enable); backlight_set(backlight_config.enable ? backlight_config.level : 0); -#ifdef BREATHING_LED_ENABLE - if (!backlight_config.enable) { - breathing_led_enable(); - } -#endif } void backlight_step(void) diff --git a/common/backlight.h b/common/backlight.h index a33c727a..685c422a 100644 --- a/common/backlight.h +++ b/common/backlight.h @@ -36,9 +36,6 @@ void backlight_decrease(void); void backlight_toggle(void); void backlight_step(void); -void backlight_enable(void); -void backlight_disable(void); void backlight_set(uint8_t level); -void backlight_set_raw(uint8_t raw); #endif diff --git a/common/breathing_led.c b/common/breathing_led.c index 497f9a6d..4e4822f8 100644 --- a/common/breathing_led.c +++ b/common/breathing_led.c @@ -1,22 +1,20 @@ #include #include -#include #include "led.h" #include "breathing_led.h" -#include "backlight.h" #include "debug.h" #define BREATHING_LED_TIMER_TOP F_CPU/256 -breathing_led_config_t breathing_led_config; +static uint8_t breathing_led_duration = 0; void breathing_led_init(void) { /* Timer3 setup */ /* CTC mode */ - TCCR3B |= _BV(WGM32); + TCCR3B |= (1< 0) - { - breathing_led_config.level--; - eeconfig_write_breathing_led(breathing_led_config.raw); - } - dprintf("breathing led speed decrease: %u\n", breathing_led_config.level); - } + breathing_led_duration = dur; + dprintf("breathing led set duration: %u\n", breathing_led_duration); } /* Breathing LED brighness(PWM On period) table @@ -87,7 +57,7 @@ void breathing_led_decrease(void) * (0..255).each {|x| print ((exp(sin(x/256.0*2*PI+3.0/2*PI))-1/E)*(256/(E-1/E))).to_i, ', ' } */ static const uint8_t breathing_table[256] PROGMEM = { -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 8, 8, 9, 10, 11, 11, 12, 13, 14, 15, 16, 17, 18, 19, 21, 22, 23, 25, 26, 27, 29, 30, 32, 34, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 56, 58, 61, 63, 66, 68, 71, 74, 77, 80, 83, 86, 89, 92, 95, 98, 102, 105, 108, 112, 116, 119, 123, 126, 130, 134, 138, 142, 145, 149, 153, 157, 161, 165, 169, 173, 176, 180, 184, 188, 192, 195, 199, 203, 206, 210, 213, 216, 219, 223, 226, 228, 231, 234, 236, 239, 241, 243, 245, 247, 248, 250, 251, 252, 253, 254, 255, 255, 255, 255, 255, 255, 255, 254, 253, 252, 251, 250, 248, 247, 245, 243, 241, 239, 236, 234, 231, 228, 226, 223, 219, 216, 213, 210, 206, 203, 199, 195, 192, 188, 184, 180, 176, 173, 169, 165, 161, 157, 153, 149, 145, 142, 138, 134, 130, 126, 123, 119, 116, 112, 108, 105, 102, 98, 95, 92, 89, 86, 83, 80, 77, 74, 71, 68, 66, 63, 61, 58, 56, 53, 51, 49, 47, 45, 43, 41, 39, 37, 35, 34, 32, 30, 29, 27, 26, 25, 23, 22, 21, 19, 18, 17, 16, 15, 14, 13, 12, 11, 11, 10, 9, 8, 8, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 2, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 8, 8, 9, 10, 11, 11, 12, 13, 14, 15, 16, 17, 18, 19, 21, 22, 23, 25, 26, 27, 29, 30, 32, 34, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 56, 58, 61, 63, 66, 68, 71, 74, 77, 80, 83, 86, 89, 92, 95, 98, 102, 105, 108, 112, 116, 119, 123, 126, 130, 134, 138, 142, 145, 149, 153, 157, 161, 165, 169, 173, 176, 180, 184, 188, 192, 195, 199, 203, 206, 210, 213, 216, 219, 223, 226, 228, 231, 234, 236, 239, 241, 243, 245, 247, 248, 250, 251, 252, 253, 254, 255, 255, 255, 255, 255, 255, 255, 254, 253, 252, 251, 250, 248, 247, 245, 243, 241, 239, 236, 234, 231, 228, 226, 223, 219, 216, 213, 210, 206, 203, 199, 195, 192, 188, 184, 180, 176, 173, 169, 165, 161, 157, 153, 149, 145, 142, 138, 134, 130, 126, 123, 119, 116, 112, 108, 105, 102, 98, 95, 92, 89, 86, 83, 80, 77, 74, 71, 68, 66, 63, 61, 58, 56, 53, 51, 49, 47, 45, 43, 41, 39, 37, 35, 34, 32, 30, 29, 27, 26, 25, 23, 22, 21, 19, 18, 17, 16, 15, 14, 13, 12, 11, 11, 10, 9, 8, 8, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 2, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; ISR(TIMER3_COMPA_vect) @@ -95,9 +65,9 @@ ISR(TIMER3_COMPA_vect) static uint8_t index = 0; static uint8_t step = 0; step++; - if (step >= BREATHING_LED_LEVELS - breathing_led_config.level) { + if (step > breathing_led_duration) { step = 0; - backlight_set_raw(pgm_read_byte(&breathing_table[index])); + breathing_led_set_raw(pgm_read_byte(&breathing_table[index])); index++; } } diff --git a/common/breathing_led.h b/common/breathing_led.h index fb31668f..b3a9e775 100644 --- a/common/breathing_led.h +++ b/common/breathing_led.h @@ -4,28 +4,12 @@ #ifdef BREATHING_LED_ENABLE -#include -#include - -#ifndef BREATHING_LED_LEVEL -#define BREATHING_LED_LEVEL 1 -#endif - -typedef union { - uint8_t raw; - struct { - bool enable:1; - uint8_t level:7; - }; -} breathing_led_config_t; - void breathing_led_init(void); -bool breathing_led_is_enabled(void); void breathing_led_enable(void); void breathing_led_disable(void); void breathing_led_toggle(void); -void breathing_led_increase(void); -void breathing_led_decrease(void); +void breathing_led_set_duration(uint8_t dur); +void breathing_led_set_raw(uint8_t raw); #else @@ -33,6 +17,8 @@ void breathing_led_decrease(void); #define breathing_led_enable() #define breathing_led_disable() #define breathing_led_toggle() +#define breathing_led_set_duration() +#define breathing_led_set_raw() #endif diff --git a/common/eeconfig.c b/common/eeconfig.c index ab9bae3c..5aadf1c5 100644 --- a/common/eeconfig.c +++ b/common/eeconfig.c @@ -14,9 +14,6 @@ void eeconfig_init(void) #ifdef BACKLIGHT_ENABLE eeprom_write_byte(EECONFIG_BACKLIGHT, 0); #endif -#ifdef BREATHING_LED_ENABLE - eeprom_write_byte(EECONFIG_BREATHING_LED, 0); -#endif #ifdef KEYMAP_EX_ENABLE keymap_ex_init(); #endif @@ -53,8 +50,3 @@ void eeconfig_write_keymap(uint8_t val) { eeprom_write_byte(EECONFIG_KEYMAP, val uint8_t eeconfig_read_backlight(void) { return eeprom_read_byte(EECONFIG_BACKLIGHT); } void eeconfig_write_backlight(uint8_t val) { eeprom_write_byte(EECONFIG_BACKLIGHT, val); } #endif - -#ifdef BREATHING_LED_ENABLE -uint8_t eeconfig_read_breathing_led(void) { return eeprom_read_byte(EECONFIG_BREATHING_LED); } -void eeconfig_write_breathing_led(uint8_t val) { eeprom_write_byte(EECONFIG_BREATHING_LED, val); } -#endif diff --git a/common/eeconfig.h b/common/eeconfig.h index 36c18143..e1b5ae28 100644 --- a/common/eeconfig.h +++ b/common/eeconfig.h @@ -31,7 +31,6 @@ along with this program. If not, see . #define EECONFIG_KEYMAP (uint8_t *)4 #define EECONFIG_MOUSEKEY_ACCEL (uint8_t *)5 #define EECONFIG_BACKLIGHT (uint8_t *)6 -#define EECONFIG_BREATHING_LED (uint8_t *)7 /* debug bit */ @@ -72,9 +71,4 @@ uint8_t eeconfig_read_backlight(void); void eeconfig_write_backlight(uint8_t val); #endif -#ifdef BREATHING_LED_ENABLE -uint8_t eeconfig_read_breathing_led(void); -void eeconfig_write_breathing_led(uint8_t val); -#endif - #endif From 9dcb2b3a7e0a57fa30ff6855c133719e3e21d0f7 Mon Sep 17 00:00:00 2001 From: tmk Date: Mon, 21 Apr 2014 12:18:12 +0900 Subject: [PATCH 21/33] Change PollingIntervalMS to 10ms(Fix #114) --- protocol/lufa/descriptor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protocol/lufa/descriptor.c b/protocol/lufa/descriptor.c index a46ba3ec..f9f6b953 100644 --- a/protocol/lufa/descriptor.c +++ b/protocol/lufa/descriptor.c @@ -306,7 +306,7 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = .EndpointAddress = (ENDPOINT_DIR_IN | KEYBOARD_IN_EPNUM), .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), .EndpointSize = KEYBOARD_EPSIZE, - .PollingIntervalMS = 0x01 + .PollingIntervalMS = 0x0A }, /* From 8b4822d40caad57e621bbbbffa9d1055e76cfdb0 Mon Sep 17 00:00:00 2001 From: tmk Date: Mon, 21 Apr 2014 22:17:42 +0900 Subject: [PATCH 22/33] Return when ready check loop is timeouted(Fix #115) --- protocol/lufa/descriptor.c | 4 ++-- protocol/lufa/lufa.c | 36 +++++++++++++++++++++++++----------- 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/protocol/lufa/descriptor.c b/protocol/lufa/descriptor.c index f9f6b953..d97f5d86 100644 --- a/protocol/lufa/descriptor.c +++ b/protocol/lufa/descriptor.c @@ -347,7 +347,7 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = .EndpointAddress = (ENDPOINT_DIR_IN | MOUSE_IN_EPNUM), .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), .EndpointSize = MOUSE_EPSIZE, - .PollingIntervalMS = 0x01 + .PollingIntervalMS = 0x0A }, #endif @@ -389,7 +389,7 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = .EndpointAddress = (ENDPOINT_DIR_IN | EXTRAKEY_IN_EPNUM), .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), .EndpointSize = EXTRAKEY_EPSIZE, - .PollingIntervalMS = 0x01 + .PollingIntervalMS = 0x0A }, #endif diff --git a/protocol/lufa/lufa.c b/protocol/lufa/lufa.c index eca51c87..68119d5e 100644 --- a/protocol/lufa/lufa.c +++ b/protocol/lufa/lufa.c @@ -351,7 +351,7 @@ static uint8_t keyboard_leds(void) static void send_keyboard(report_keyboard_t *report) { - uint8_t timeout = 0; + uint8_t timeout = 255; if (USB_DeviceState != DEVICE_STATE_Configured) return; @@ -360,15 +360,20 @@ static void send_keyboard(report_keyboard_t *report) #ifdef NKRO_ENABLE if (keyboard_nkro) { Endpoint_SelectEndpoint(NKRO_IN_EPNUM); + + /* Check if write ready for a polling interval around 1ms */ + while (timeout-- && !Endpoint_IsReadWriteAllowed()) _delay_us(4); + if (!Endpoint_IsReadWriteAllowed()) return; } else #endif { Endpoint_SelectEndpoint(KEYBOARD_IN_EPNUM); - } - /* Check if Keyboard Endpoint Ready for Read/Write */ - while (--timeout && !Endpoint_IsReadWriteAllowed()) ; + /* Check if write ready for a polling interval around 10ms */ + while (timeout-- && !Endpoint_IsReadWriteAllowed()) _delay_us(40); + if (!Endpoint_IsReadWriteAllowed()) return; + } /* Write Keyboard Report Data */ #ifdef NKRO_ENABLE @@ -391,7 +396,7 @@ static void send_keyboard(report_keyboard_t *report) static void send_mouse(report_mouse_t *report) { #ifdef MOUSE_ENABLE - uint8_t timeout = 0; + uint8_t timeout = 255; if (USB_DeviceState != DEVICE_STATE_Configured) return; @@ -399,8 +404,9 @@ static void send_mouse(report_mouse_t *report) /* Select the Mouse Report Endpoint */ Endpoint_SelectEndpoint(MOUSE_IN_EPNUM); - /* Check if Mouse Endpoint Ready for Read/Write */ - while (--timeout && !Endpoint_IsReadWriteAllowed()) ; + /* Check if write ready for a polling interval around 10ms */ + while (timeout-- && !Endpoint_IsReadWriteAllowed()) _delay_us(40); + if (!Endpoint_IsReadWriteAllowed()) return; /* Write Mouse Report Data */ Endpoint_Write_Stream_LE(report, sizeof(report_mouse_t), NULL); @@ -412,7 +418,7 @@ static void send_mouse(report_mouse_t *report) static void send_system(uint16_t data) { - uint8_t timeout = 0; + uint8_t timeout = 255; if (USB_DeviceState != DEVICE_STATE_Configured) return; @@ -422,14 +428,18 @@ static void send_system(uint16_t data) .usage = data }; Endpoint_SelectEndpoint(EXTRAKEY_IN_EPNUM); - while (--timeout && !Endpoint_IsReadWriteAllowed()) ; + + /* Check if write ready for a polling interval around 10ms */ + while (timeout-- && !Endpoint_IsReadWriteAllowed()) _delay_us(40); + if (!Endpoint_IsReadWriteAllowed()) return; + Endpoint_Write_Stream_LE(&r, sizeof(report_extra_t), NULL); Endpoint_ClearIN(); } static void send_consumer(uint16_t data) { - uint8_t timeout = 0; + uint8_t timeout = 255; if (USB_DeviceState != DEVICE_STATE_Configured) return; @@ -439,7 +449,11 @@ static void send_consumer(uint16_t data) .usage = data }; Endpoint_SelectEndpoint(EXTRAKEY_IN_EPNUM); - while (--timeout && !Endpoint_IsReadWriteAllowed()) ; + + /* Check if write ready for a polling interval around 10ms */ + while (timeout-- && !Endpoint_IsReadWriteAllowed()) _delay_us(40); + if (!Endpoint_IsReadWriteAllowed()) return; + Endpoint_Write_Stream_LE(&r, sizeof(report_extra_t), NULL); Endpoint_ClearIN(); } From 7707f6ab10b1b7836deef72682566874c5785d24 Mon Sep 17 00:00:00 2001 From: tmk Date: Thu, 24 Apr 2014 11:26:06 +0900 Subject: [PATCH 23/33] Change LUFA build options --- protocol/lufa.mk | 10 +++++++--- protocol/lufa/descriptor.c | 4 ++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/protocol/lufa.mk b/protocol/lufa.mk index 3489f19c..10a922f9 100644 --- a/protocol/lufa.mk +++ b/protocol/lufa.mk @@ -2,6 +2,7 @@ LUFA_DIR = protocol/lufa # Path to the LUFA library LUFA_PATH ?= protocol/lufa/LUFA-120730 +#LUFA_PATH ?= protocol/lufa/LUFA-130901 # Create the LUFA source path variables by including the LUFA makefile ifneq (, $(wildcard $(TOP_DIR)/$(LUFA_PATH)/LUFA/Build/lufa_sources.mk)) @@ -30,9 +31,12 @@ VPATH += $(TOP_DIR)/$(LUFA_PATH) #endif # LUFA library compile-time options and predefined tokens -LUFA_OPTS = -D USB_DEVICE_ONLY -LUFA_OPTS += -D USE_FLASH_DESCRIPTORS -LUFA_OPTS += -D USE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)" +LUFA_OPTS = -DUSB_DEVICE_ONLY +LUFA_OPTS += -DUSE_FLASH_DESCRIPTORS +LUFA_OPTS += -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)" +#LUFA_OPTS += -DINTERRUPT_CONTROL_ENDPOINT +LUFA_OPTS += -DFIXED_CONTROL_ENDPOINT_SIZE=8 +LUFA_OPTS += -DFIXED_NUM_CONFIGURATIONS=1 OPT_DEFS += -DF_USB=$(F_USB)UL OPT_DEFS += -DARCH=ARCH_$(ARCH) diff --git a/protocol/lufa/descriptor.c b/protocol/lufa/descriptor.c index d97f5d86..d88b5965 100644 --- a/protocol/lufa/descriptor.c +++ b/protocol/lufa/descriptor.c @@ -235,7 +235,7 @@ const USB_Descriptor_Device_t PROGMEM DeviceDescriptor = .SubClass = USB_CSCP_NoDeviceSubclass, .Protocol = USB_CSCP_NoDeviceProtocol, - .Endpoint0Size = 8, + .Endpoint0Size = FIXED_CONTROL_ENDPOINT_SIZE, /* specified in config.h */ .VendorID = VENDOR_ID, @@ -246,7 +246,7 @@ const USB_Descriptor_Device_t PROGMEM DeviceDescriptor = .ProductStrIndex = 0x02, .SerialNumStrIndex = NO_DESCRIPTOR, - .NumberOfConfigurations = 1 + .NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS }; /******************************************************************************* From 82415ef515ed06795a9d39b937432d9b3d757350 Mon Sep 17 00:00:00 2001 From: tmk Date: Fri, 25 Apr 2014 12:19:14 +0900 Subject: [PATCH 24/33] Move macro definitions from lufa.c to lufa.h --- protocol/lufa/lufa.c | 9 --------- protocol/lufa/lufa.h | 11 +++++++++++ 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/protocol/lufa/lufa.c b/protocol/lufa/lufa.c index 68119d5e..86e9f23d 100644 --- a/protocol/lufa/lufa.c +++ b/protocol/lufa/lufa.c @@ -184,15 +184,6 @@ void EVENT_USB_Device_StartOfFrame(void) /** Event handler for the USB_ConfigurationChanged event. * This is fired when the host sets the current configuration of the USB device after enumeration. */ -#if LUFA_VERSION_INTEGER < 0x120730 - /* old API 120219 */ - #define ENDPOINT_CONFIG(epnum, eptype, epdir, epsize, epbank) Endpoint_ConfigureEndpoint(epnum, eptype, epdir, epsize, epbank) -#else - /* new API >= 120730 */ - #define ENDPOINT_BANK_SINGLE 1 - #define ENDPOINT_BANK_DOUBLE 2 - #define ENDPOINT_CONFIG(epnum, eptype, epdir, epsize, epbank) Endpoint_ConfigureEndpoint((epdir) | (epnum) , eptype, epsize, epbank) -#endif void EVENT_USB_Device_ConfigurationChanged(void) { bool ConfigSuccess = true; diff --git a/protocol/lufa/lufa.h b/protocol/lufa/lufa.h index bcee060d..195123c0 100644 --- a/protocol/lufa/lufa.h +++ b/protocol/lufa/lufa.h @@ -66,4 +66,15 @@ typedef struct { uint16_t usage; } __attribute__ ((packed)) report_extra_t; + +#if LUFA_VERSION_INTEGER < 0x120730 + /* old API 120219 */ + #define ENDPOINT_CONFIG(epnum, eptype, epdir, epsize, epbank) Endpoint_ConfigureEndpoint(epnum, eptype, epdir, epsize, epbank) +#else + /* new API >= 120730 */ + #define ENDPOINT_BANK_SINGLE 1 + #define ENDPOINT_BANK_DOUBLE 2 + #define ENDPOINT_CONFIG(epnum, eptype, epdir, epsize, epbank) Endpoint_ConfigureEndpoint((epdir) | (epnum) , eptype, epsize, epbank) +#endif + #endif From 4975e79845321d8ef868bd8211542926cdc071ed Mon Sep 17 00:00:00 2001 From: tmk Date: Fri, 25 Apr 2014 12:52:47 +0900 Subject: [PATCH 25/33] Add LUFA git repository(release 140302) --- .gitmodules | 3 +++ protocol/lufa.mk | 8 ++++++-- protocol/lufa/LUFA-git | 1 + protocol/lufa/descriptor.c | 12 ++++++------ protocol/lufa/descriptor.h | 9 +++++++++ 5 files changed, 25 insertions(+), 8 deletions(-) create mode 160000 protocol/lufa/LUFA-git diff --git a/.gitmodules b/.gitmodules index 3e34a635..17a20dec 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "protocol/usb_hid/USB_Host_Shield_2.0"] path = protocol/usb_hid/USB_Host_Shield_2.0 url = git@github.com:tmk/USB_Host_Shield_2.0.git +[submodule "protocol/lufa/LUFA-git"] + path = protocol/lufa/LUFA-git + url = https://github.com/abcminiuser/lufa.git diff --git a/protocol/lufa.mk b/protocol/lufa.mk index 10a922f9..48ce9ae8 100644 --- a/protocol/lufa.mk +++ b/protocol/lufa.mk @@ -1,8 +1,12 @@ LUFA_DIR = protocol/lufa # Path to the LUFA library -LUFA_PATH ?= protocol/lufa/LUFA-120730 -#LUFA_PATH ?= protocol/lufa/LUFA-130901 +ifeq (, $(wildcard $(TOP_DIR)/$(LUFA_DIR)/LUFA-git)) + LUFA_PATH ?= $(LUFA_DIR)/LUFA-120730 +else + LUFA_PATH ?= $(LUFA_DIR)/LUFA-git +endif + # Create the LUFA source path variables by including the LUFA makefile ifneq (, $(wildcard $(TOP_DIR)/$(LUFA_PATH)/LUFA/Build/lufa_sources.mk)) diff --git a/protocol/lufa/LUFA-git b/protocol/lufa/LUFA-git new file mode 160000 index 00000000..b6c18b2a --- /dev/null +++ b/protocol/lufa/LUFA-git @@ -0,0 +1 @@ +Subproject commit b6c18b2a7c544653efbe12a1d4e8ba65e7d83c35 diff --git a/protocol/lufa/descriptor.c b/protocol/lufa/descriptor.c index d88b5965..c13a81bd 100644 --- a/protocol/lufa/descriptor.c +++ b/protocol/lufa/descriptor.c @@ -230,7 +230,7 @@ const USB_Descriptor_Device_t PROGMEM DeviceDescriptor = { .Header = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device}, - .USBSpecification = VERSION_BCD(01.10), + .USBSpecification = VERSION_BCD(1,1,0), .Class = USB_CSCP_NoDeviceClass, .SubClass = USB_CSCP_NoDeviceSubclass, .Protocol = USB_CSCP_NoDeviceProtocol, @@ -292,7 +292,7 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = { .Header = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID}, - .HIDSpec = VERSION_BCD(01.11), + .HIDSpec = VERSION_BCD(1,1,1), .CountryCode = 0x00, .TotalReportDescriptors = 1, .HIDReportType = HID_DTYPE_Report, @@ -333,7 +333,7 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = { .Header = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID}, - .HIDSpec = VERSION_BCD(01.11), + .HIDSpec = VERSION_BCD(1,1,1), .CountryCode = 0x00, .TotalReportDescriptors = 1, .HIDReportType = HID_DTYPE_Report, @@ -375,7 +375,7 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = { .Header = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID}, - .HIDSpec = VERSION_BCD(01.11), + .HIDSpec = VERSION_BCD(1,1,1), .CountryCode = 0x00, .TotalReportDescriptors = 1, .HIDReportType = HID_DTYPE_Report, @@ -417,7 +417,7 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = { .Header = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID}, - .HIDSpec = VERSION_BCD(01.11), + .HIDSpec = VERSION_BCD(1,1,1), .CountryCode = 0x00, .TotalReportDescriptors = 1, .HIDReportType = HID_DTYPE_Report, @@ -469,7 +469,7 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = { .Header = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID}, - .HIDSpec = VERSION_BCD(01.11), + .HIDSpec = VERSION_BCD(1,1,1), .CountryCode = 0x00, .TotalReportDescriptors = 1, .HIDReportType = HID_DTYPE_Report, diff --git a/protocol/lufa/descriptor.h b/protocol/lufa/descriptor.h index 9ee1c04d..e0acec80 100644 --- a/protocol/lufa/descriptor.h +++ b/protocol/lufa/descriptor.h @@ -159,4 +159,13 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, const void** const DescriptorAddress) ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3); + +/* new API */ +#if LUFA_VERSION_INTEGER < 0x140302 + #define VERSION_BCD(Major, Minor, Revision) \ + CPU_TO_LE16( ((Major & 0xFF) << 8) | \ + ((Minor & 0x0F) << 4) | \ + (Revision & 0x0F) ) +#endif + #endif From b0a91cd565f03c0c2a6f91606beedb68278f82bf Mon Sep 17 00:00:00 2001 From: tmk Date: Fri, 25 Apr 2014 15:32:21 +0900 Subject: [PATCH 26/33] Make NKRO deafult when it is available - NKRO is used only when keyboard_protocol = 1(report) --- common/action_util.c | 6 ++-- common/command.c | 4 +-- common/host.c | 2 +- common/host.h | 3 ++ protocol/lufa/lufa.c | 55 ++++++++++++++++++------------------ protocol/pjrc/usb.c | 18 ++++++------ protocol/pjrc/usb_keyboard.c | 11 +++----- protocol/pjrc/usb_keyboard.h | 2 -- 8 files changed, 51 insertions(+), 50 deletions(-) diff --git a/common/action_util.c b/common/action_util.c index 99a3adaa..ebe7150d 100644 --- a/common/action_util.c +++ b/common/action_util.c @@ -67,7 +67,7 @@ void send_keyboard_report(void) { void add_key(uint8_t key) { #ifdef NKRO_ENABLE - if (keyboard_nkro) { + if (keyboard_nkro && keyboard_protocol) { add_key_bit(key); return; } @@ -78,7 +78,7 @@ void add_key(uint8_t key) void del_key(uint8_t key) { #ifdef NKRO_ENABLE - if (keyboard_nkro) { + if (keyboard_nkro && keyboard_protocol) { del_key_bit(key); return; } @@ -151,7 +151,7 @@ uint8_t has_anymod(void) uint8_t get_first_key(void) { #ifdef NKRO_ENABLE - if (keyboard_nkro) { + if (keyboard_nkro && keyboard_protocol) { uint8_t i = 0; for (; i < REPORT_BITS && !keyboard_report->nkro.bits[i]; i++) ; diff --git a/common/command.c b/common/command.c index f6f27695..d2f8eb83 100644 --- a/common/command.c +++ b/common/command.c @@ -301,13 +301,13 @@ static bool command_common(uint8_t code) case KC_S: print("\n\n----- Status -----\n"); print_val_hex8(host_keyboard_leds()); + print_val_hex8(keyboard_protocol); + print_val_hex8(keyboard_idle); #ifdef PROTOCOL_PJRC print_val_hex8(UDCON); print_val_hex8(UDIEN); print_val_hex8(UDINT); print_val_hex8(usb_keyboard_leds); - print_val_hex8(usb_keyboard_protocol); - print_val_hex8(usb_keyboard_idle_config); print_val_hex8(usb_keyboard_idle_count); #endif diff --git a/common/host.c b/common/host.c index 1eafef75..2e56971b 100644 --- a/common/host.c +++ b/common/host.c @@ -24,7 +24,7 @@ along with this program. If not, see . #ifdef NKRO_ENABLE -bool keyboard_nkro = false; +bool keyboard_nkro = true; #endif static host_driver_t *driver; diff --git a/common/host.h b/common/host.h index 8ff26298..a56e6c3b 100644 --- a/common/host.h +++ b/common/host.h @@ -32,6 +32,9 @@ extern "C" { extern bool keyboard_nkro; #endif +uint8_t keyboard_idle; +uint8_t keyboard_protocol; + /* host driver */ void host_set_driver(host_driver_t *driver); diff --git a/protocol/lufa/lufa.c b/protocol/lufa/lufa.c index 86e9f23d..a43a552a 100644 --- a/protocol/lufa/lufa.c +++ b/protocol/lufa/lufa.c @@ -52,8 +52,8 @@ #include "descriptor.h" #include "lufa.h" -static uint8_t idle_duration = 0; -static uint8_t protocol_report = 1; +uint8_t keyboard_idle = 0; +uint8_t keyboard_protocol = 1; static uint8_t keyboard_led_stats = 0; static report_keyboard_t keyboard_report_sent; @@ -290,21 +290,26 @@ void EVENT_USB_Device_ControlRequest(void) case HID_REQ_GetProtocol: if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE)) { - Endpoint_ClearSETUP(); - while (!(Endpoint_IsINReady())); - Endpoint_Write_8(protocol_report); - Endpoint_ClearIN(); - Endpoint_ClearStatusStage(); + if (USB_ControlRequest.wIndex == KEYBOARD_INTERFACE) { + Endpoint_ClearSETUP(); + while (!(Endpoint_IsINReady())); + Endpoint_Write_8(keyboard_protocol); + Endpoint_ClearIN(); + Endpoint_ClearStatusStage(); + } } break; case HID_REQ_SetProtocol: if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE)) { - Endpoint_ClearSETUP(); - Endpoint_ClearStatusStage(); + if (USB_ControlRequest.wIndex == KEYBOARD_INTERFACE) { + Endpoint_ClearSETUP(); + Endpoint_ClearStatusStage(); - protocol_report = ((USB_ControlRequest.wValue & 0xFF) != 0x00); + keyboard_protocol = ((USB_ControlRequest.wValue & 0xFF) != 0x00); + clear_keyboard(); + } } break; @@ -314,7 +319,7 @@ void EVENT_USB_Device_ControlRequest(void) Endpoint_ClearSETUP(); Endpoint_ClearStatusStage(); - idle_duration = ((USB_ControlRequest.wValue & 0xFF00) >> 8); + keyboard_idle = ((USB_ControlRequest.wValue & 0xFF00) >> 8); } break; @@ -323,7 +328,7 @@ void EVENT_USB_Device_ControlRequest(void) { Endpoint_ClearSETUP(); while (!(Endpoint_IsINReady())); - Endpoint_Write_8(idle_duration); + Endpoint_Write_8(keyboard_idle); Endpoint_ClearIN(); Endpoint_ClearStatusStage(); } @@ -349,32 +354,28 @@ static void send_keyboard(report_keyboard_t *report) /* Select the Keyboard Report Endpoint */ #ifdef NKRO_ENABLE - if (keyboard_nkro) { + if (keyboard_nkro && keyboard_protocol) { + /* Report protocol - NKRO */ Endpoint_SelectEndpoint(NKRO_IN_EPNUM); /* Check if write ready for a polling interval around 1ms */ while (timeout-- && !Endpoint_IsReadWriteAllowed()) _delay_us(4); if (!Endpoint_IsReadWriteAllowed()) return; - } - else -#endif - { - Endpoint_SelectEndpoint(KEYBOARD_IN_EPNUM); - /* Check if write ready for a polling interval around 10ms */ - while (timeout-- && !Endpoint_IsReadWriteAllowed()) _delay_us(40); - if (!Endpoint_IsReadWriteAllowed()) return; - } - - /* Write Keyboard Report Data */ -#ifdef NKRO_ENABLE - if (keyboard_nkro) { + /* Write Keyboard Report Data */ Endpoint_Write_Stream_LE(report, NKRO_EPSIZE, NULL); } else #endif { - /* boot mode */ + /* Boot protocol */ + Endpoint_SelectEndpoint(KEYBOARD_IN_EPNUM); + + /* Check if write ready for a polling interval around 10ms */ + while (timeout-- && !Endpoint_IsReadWriteAllowed()) _delay_us(40); + if (!Endpoint_IsReadWriteAllowed()) return; + + /* Write Keyboard Report Data */ Endpoint_Write_Stream_LE(report, KEYBOARD_EPSIZE, NULL); } diff --git a/protocol/pjrc/usb.c b/protocol/pjrc/usb.c index 393b36f7..b09ad3f2 100644 --- a/protocol/pjrc/usb.c +++ b/protocol/pjrc/usb.c @@ -38,6 +38,7 @@ #include "sleep_led.h" #endif #include "suspend.h" +#include "action.h" #include "action_util.h" @@ -692,20 +693,20 @@ ISR(USB_GEN_vect) } /* TODO: should keep IDLE rate on each keyboard interface */ #ifdef NKRO_ENABLE - if (!keyboard_nkro && usb_keyboard_idle_config && (++div4 & 3) == 0) { + if (!keyboard_nkro && keyboard_idle && (++div4 & 3) == 0) { #else - if (usb_keyboard_idle_config && (++div4 & 3) == 0) { + if (keyboard_idle && (++div4 & 3) == 0) { #endif UENUM = KBD_ENDPOINT; if (UEINTX & (1<mods; UEDATX = 0; - uint8_t keys = usb_keyboard_protocol ? KBD_REPORT_KEYS : 6; + uint8_t keys = keyboard_protocol ? KBD_REPORT_KEYS : 6; for (uint8_t i=0; ikeys[i]; } @@ -901,13 +902,13 @@ ISR(USB_COM_vect) } if (bRequest == HID_GET_IDLE) { usb_wait_in_ready(); - UEDATX = usb_keyboard_idle_config; + UEDATX = keyboard_idle; usb_send_in(); return; } if (bRequest == HID_GET_PROTOCOL) { usb_wait_in_ready(); - UEDATX = usb_keyboard_protocol; + UEDATX = keyboard_protocol; usb_send_in(); return; } @@ -921,14 +922,15 @@ ISR(USB_COM_vect) return; } if (bRequest == HID_SET_IDLE) { - usb_keyboard_idle_config = (wValue >> 8); + keyboard_idle = (wValue >> 8); usb_keyboard_idle_count = 0; //usb_wait_in_ready(); usb_send_in(); return; } if (bRequest == HID_SET_PROTOCOL) { - usb_keyboard_protocol = wValue; + keyboard_protocol = wValue; + clear_keyboard(); //usb_wait_in_ready(); usb_send_in(); return; diff --git a/protocol/pjrc/usb_keyboard.c b/protocol/pjrc/usb_keyboard.c index de798fcc..c11995db 100644 --- a/protocol/pjrc/usb_keyboard.c +++ b/protocol/pjrc/usb_keyboard.c @@ -34,12 +34,12 @@ // protocol setting from the host. We use exactly the same report // either way, so this variable only stores the setting since we // are required to be able to report which setting is in use. -uint8_t usb_keyboard_protocol=1; +uint8_t keyboard_protocol=1; // the idle configuration, how often we send the report to the // host (ms * 4) even when it hasn't changed // Windows and Linux set 0 while OS X sets 6(24ms) by SET_IDLE request. -uint8_t usb_keyboard_idle_config=125; +uint8_t keyobard_idle=125; // count until idle timeout uint8_t usb_keyboard_idle_count=0; @@ -56,15 +56,12 @@ int8_t usb_keyboard_send_report(report_keyboard_t *report) int8_t result = 0; #ifdef NKRO_ENABLE - if (keyboard_nkro) + if (keyboard_nkro && keyboard_protocol) result = send_report(report, KBD2_ENDPOINT, 0, KBD2_SIZE); else #endif { - if (usb_keyboard_protocol) - result = send_report(report, KBD_ENDPOINT, 0, KBD_SIZE); - else - result = send_report(report, KBD_ENDPOINT, 0, 6); + result = send_report(report, KBD_ENDPOINT, 0, KBD_SIZE); } if (result) return result; diff --git a/protocol/pjrc/usb_keyboard.h b/protocol/pjrc/usb_keyboard.h index c362ca3b..9b798e9a 100644 --- a/protocol/pjrc/usb_keyboard.h +++ b/protocol/pjrc/usb_keyboard.h @@ -30,8 +30,6 @@ #include "host.h" -extern uint8_t usb_keyboard_protocol; -extern uint8_t usb_keyboard_idle_config; extern uint8_t usb_keyboard_idle_count; extern volatile uint8_t usb_keyboard_leds; From ca8de4f93d3174d1f02e201dcbb796dbfadfb175 Mon Sep 17 00:00:00 2001 From: tmk Date: Sun, 27 Apr 2014 05:07:27 +0900 Subject: [PATCH 27/33] NKRO is disable when SET_PROTOCOL(boot) - Command can force to enable NKRO even when boot mode - After boot keyboard may be in boot mode due to BIOS' request --- common/action_util.c | 6 +++--- protocol/lufa/lufa.c | 5 ++++- protocol/pjrc/usb.c | 3 +++ protocol/pjrc/usb_keyboard.c | 2 +- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/common/action_util.c b/common/action_util.c index ebe7150d..99a3adaa 100644 --- a/common/action_util.c +++ b/common/action_util.c @@ -67,7 +67,7 @@ void send_keyboard_report(void) { void add_key(uint8_t key) { #ifdef NKRO_ENABLE - if (keyboard_nkro && keyboard_protocol) { + if (keyboard_nkro) { add_key_bit(key); return; } @@ -78,7 +78,7 @@ void add_key(uint8_t key) void del_key(uint8_t key) { #ifdef NKRO_ENABLE - if (keyboard_nkro && keyboard_protocol) { + if (keyboard_nkro) { del_key_bit(key); return; } @@ -151,7 +151,7 @@ uint8_t has_anymod(void) uint8_t get_first_key(void) { #ifdef NKRO_ENABLE - if (keyboard_nkro && keyboard_protocol) { + if (keyboard_nkro) { uint8_t i = 0; for (; i < REPORT_BITS && !keyboard_report->nkro.bits[i]; i++) ; diff --git a/protocol/lufa/lufa.c b/protocol/lufa/lufa.c index a43a552a..db05702a 100644 --- a/protocol/lufa/lufa.c +++ b/protocol/lufa/lufa.c @@ -308,6 +308,9 @@ void EVENT_USB_Device_ControlRequest(void) Endpoint_ClearStatusStage(); keyboard_protocol = ((USB_ControlRequest.wValue & 0xFF) != 0x00); +#ifdef NKRO_ENABLE + keyboard_nkro = !!keyboard_protocol; +#endif clear_keyboard(); } } @@ -354,7 +357,7 @@ static void send_keyboard(report_keyboard_t *report) /* Select the Keyboard Report Endpoint */ #ifdef NKRO_ENABLE - if (keyboard_nkro && keyboard_protocol) { + if (keyboard_nkro) { /* Report protocol - NKRO */ Endpoint_SelectEndpoint(NKRO_IN_EPNUM); diff --git a/protocol/pjrc/usb.c b/protocol/pjrc/usb.c index b09ad3f2..2b267d48 100644 --- a/protocol/pjrc/usb.c +++ b/protocol/pjrc/usb.c @@ -930,6 +930,9 @@ ISR(USB_COM_vect) } if (bRequest == HID_SET_PROTOCOL) { keyboard_protocol = wValue; +#ifdef NKRO_ENABLE + keyboard_nkro = !!keyboard_protocol; +#endif clear_keyboard(); //usb_wait_in_ready(); usb_send_in(); diff --git a/protocol/pjrc/usb_keyboard.c b/protocol/pjrc/usb_keyboard.c index c11995db..d1683318 100644 --- a/protocol/pjrc/usb_keyboard.c +++ b/protocol/pjrc/usb_keyboard.c @@ -56,7 +56,7 @@ int8_t usb_keyboard_send_report(report_keyboard_t *report) int8_t result = 0; #ifdef NKRO_ENABLE - if (keyboard_nkro && keyboard_protocol) + if (keyboard_nkro) result = send_report(report, KBD2_ENDPOINT, 0, KBD2_SIZE); else #endif From efc983a07dcc4d2f6fffdbc9c085e62a14a34a55 Mon Sep 17 00:00:00 2001 From: tmk Date: Mon, 28 Apr 2014 08:55:07 +0900 Subject: [PATCH 28/33] Check if LUFA-git really exists(Fix #118) --- protocol/lufa.mk | 2 +- protocol/lufa/descriptor.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/protocol/lufa.mk b/protocol/lufa.mk index 48ce9ae8..ac70ac03 100644 --- a/protocol/lufa.mk +++ b/protocol/lufa.mk @@ -1,7 +1,7 @@ LUFA_DIR = protocol/lufa # Path to the LUFA library -ifeq (, $(wildcard $(TOP_DIR)/$(LUFA_DIR)/LUFA-git)) +ifeq (, $(wildcard $(TOP_DIR)/$(LUFA_DIR)/LUFA-git/LUFA/Version.h)) LUFA_PATH ?= $(LUFA_DIR)/LUFA-120730 else LUFA_PATH ?= $(LUFA_DIR)/LUFA-git diff --git a/protocol/lufa/descriptor.h b/protocol/lufa/descriptor.h index e0acec80..a2db4bfd 100644 --- a/protocol/lufa/descriptor.h +++ b/protocol/lufa/descriptor.h @@ -162,6 +162,7 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, /* new API */ #if LUFA_VERSION_INTEGER < 0x140302 + #undef VERSION_BCD #define VERSION_BCD(Major, Minor, Revision) \ CPU_TO_LE16( ((Major & 0xFF) << 8) | \ ((Minor & 0x0F) << 4) | \ From a1f49ff8c105bbe06b7f64ca8aa49e382b94bf82 Mon Sep 17 00:00:00 2001 From: tmk Date: Mon, 28 Apr 2014 15:21:42 +0900 Subject: [PATCH 29/33] Fix remotewakeup of PJRC stack(Fix #121) - without this fix wakeup often fails - keyboard can wakeup once or twice but fails after that --- protocol/pjrc/usb.c | 1 + 1 file changed, 1 insertion(+) diff --git a/protocol/pjrc/usb.c b/protocol/pjrc/usb.c index 2b267d48..1e6ba871 100644 --- a/protocol/pjrc/usb.c +++ b/protocol/pjrc/usb.c @@ -629,6 +629,7 @@ uint8_t usb_configured(void) void usb_remote_wakeup(void) { UDCON |= (1< Date: Tue, 29 Apr 2014 19:45:01 +0900 Subject: [PATCH 30/33] Unused endpoint of console OUT is commentout'd --- protocol/lufa/descriptor.h | 6 +++++- protocol/lufa/lufa.c | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/protocol/lufa/descriptor.h b/protocol/lufa/descriptor.h index a2db4bfd..42af0791 100644 --- a/protocol/lufa/descriptor.h +++ b/protocol/lufa/descriptor.h @@ -137,13 +137,17 @@ typedef struct #ifdef CONSOLE_ENABLE # define CONSOLE_IN_EPNUM (EXTRAKEY_IN_EPNUM + 1) -# define CONSOLE_OUT_EPNUM (EXTRAKEY_IN_EPNUM + 2) +# define CONSOLE_OUT_EPNUM (EXTRAKEY_IN_EPNUM + 1) +//# define CONSOLE_OUT_EPNUM (EXTRAKEY_IN_EPNUM + 2) #else # define CONSOLE_OUT_EPNUM EXTRAKEY_IN_EPNUM #endif #ifdef NKRO_ENABLE # define NKRO_IN_EPNUM (CONSOLE_OUT_EPNUM + 1) +# if defined(__AVR_ATmega32U2__) && NKRO_IN_EPNUM > 4 +# error "Endpoints are not available enough to support all functions. Remove some in Makefile.(MOUSEKEY, EXTRAKEY, CONSOLE, NKRO)" +# endif #endif diff --git a/protocol/lufa/lufa.c b/protocol/lufa/lufa.c index db05702a..9f8e50c4 100644 --- a/protocol/lufa/lufa.c +++ b/protocol/lufa/lufa.c @@ -208,9 +208,11 @@ void EVENT_USB_Device_ConfigurationChanged(void) /* Setup Console HID Report Endpoints */ ConfigSuccess &= ENDPOINT_CONFIG(CONSOLE_IN_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_IN, CONSOLE_EPSIZE, ENDPOINT_BANK_DOUBLE); +#if 0 ConfigSuccess &= ENDPOINT_CONFIG(CONSOLE_OUT_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_OUT, CONSOLE_EPSIZE, ENDPOINT_BANK_SINGLE); #endif +#endif #ifdef NKRO_ENABLE /* Setup NKRO HID Report Endpoints */ From 6f66f9955cdcdcfd13dd9a19861ff1d49ae8d511 Mon Sep 17 00:00:00 2001 From: tmk Date: Tue, 29 Apr 2014 19:46:37 +0900 Subject: [PATCH 31/33] Fix set LED for NKRO keyboard interface --- protocol/lufa/lufa.c | 1 + 1 file changed, 1 insertion(+) diff --git a/protocol/lufa/lufa.c b/protocol/lufa/lufa.c index 9f8e50c4..d60aecc3 100644 --- a/protocol/lufa/lufa.c +++ b/protocol/lufa/lufa.c @@ -272,6 +272,7 @@ void EVENT_USB_Device_ControlRequest(void) // Interface switch (USB_ControlRequest.wIndex) { case KEYBOARD_INTERFACE: + case NKRO_INTERFACE: Endpoint_ClearSETUP(); while (!(Endpoint_IsOUTReceived())) { From 74c4395454c46fa443ce097f3132a53987200cb0 Mon Sep 17 00:00:00 2001 From: Kai Ryu Date: Wed, 7 May 2014 11:39:07 +0900 Subject: [PATCH 32/33] Fix some definition and declaration --- common/keyboard.c | 1 + 1 file changed, 1 insertion(+) diff --git a/common/keyboard.c b/common/keyboard.c index 29155cfe..6b3f6427 100644 --- a/common/keyboard.c +++ b/common/keyboard.c @@ -31,6 +31,7 @@ along with this program. If not, see . #include "bootmagic.h" #include "eeconfig.h" #include "backlight.h" +#include "breathing_led.h" #include "keymap_ex.h" #ifdef MOUSEKEY_ENABLE # include "mousekey.h" From 9b73c1e4fc5b6474b9ba8c687a902510cffe8933 Mon Sep 17 00:00:00 2001 From: Kai Ryu Date: Mon, 26 May 2014 12:04:31 +0900 Subject: [PATCH 33/33] Remove keymap_ex changes --- common.mk | 7 +-- common/keyboard.c | 5 -- common/keymap_ex.c | 114 --------------------------------------------- common/keymap_ex.h | 68 --------------------------- 4 files changed, 1 insertion(+), 193 deletions(-) delete mode 100644 common/keymap_ex.c delete mode 100644 common/keymap_ex.h diff --git a/common.mk b/common.mk index 09561cba..f6e9f262 100644 --- a/common.mk +++ b/common.mk @@ -22,7 +22,7 @@ ifdef BOOTMAGIC_ENABLE OPT_DEFS += -DBOOTMAGIC_ENABLE endif -ifdef MOUSEKEY_ENABLE +ifdef $(or MOUSEKEY_ENABLE, PS2_MOUSE_ENABLE) SRC += $(COMMON_DIR)/mousekey.c OPT_DEFS += -DMOUSEKEY_ENABLE OPT_DEFS += -DMOUSE_ENABLE @@ -69,11 +69,6 @@ ifdef KEYMAP_SECTION_ENABLE EXTRALDFLAGS = -Wl,-L$(TOP_DIR),-Tldscript_keymap_avr5.x endif -ifdef KEYMAP_EX_ENABLE - SRC += $(COMMON_DIR)/keymap_ex.c - OPT_DEFS += -DKEYMAP_EX_ENABLE -endif - ifdef LED_MATRIX_ENABLE SRC += $(COMMON_DIR)/led_matrix.c OPT_DEFS += -DLED_MATRIX_ENABLE diff --git a/common/keyboard.c b/common/keyboard.c index 6b3f6427..7928741a 100644 --- a/common/keyboard.c +++ b/common/keyboard.c @@ -32,7 +32,6 @@ along with this program. If not, see . #include "eeconfig.h" #include "backlight.h" #include "breathing_led.h" -#include "keymap_ex.h" #ifdef MOUSEKEY_ENABLE # include "mousekey.h" #endif @@ -85,10 +84,6 @@ void keyboard_init(void) #ifdef BREATHING_LED_ENABLE breathing_led_init(); #endif - -#ifdef KEYMAP_EX_ENABLE - keymap_ex_init(); -#endif } /* diff --git a/common/keymap_ex.c b/common/keymap_ex.c deleted file mode 100644 index 99859c06..00000000 --- a/common/keymap_ex.c +++ /dev/null @@ -1,114 +0,0 @@ -/* -Copyright 2013 Kai Ryu - -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 . -*/ - -#include -#include -#include "eeconfig.h" -#include "keymap_ex.h" -#include "debug.h" - -#ifdef KEYMAP_EX_ENABLE - -void keymap_ex_init(void) { - if (!check_keymap_in_eeprom()) { - write_keymap_to_eeprom(); - } -} - -void keymap_ex_disable(void) { - eeprom_write_word((void*)EECONFIG_KEYMAP_CHECKSUM, eeprom_read_word((void*)EECONFIG_KEYMAP_CHECKSUM) + 1); -} - -bool check_keymap_in_eeprom(void) { - uint16_t checksum_in_eeprom = eeprom_read_word(&((keymap_ex_t*)EECONFIG_KEYMAP_EX)->checksum); - uint16_t checksum = EECONFIG_MAGIC_NUMBER; - for (uint16_t i = 0; i < KEYMAP_SIZE; i += 2) { - checksum += eeprom_read_word((void*)(EECONFIG_KEYMAP_FN_ACTIONS + i)); - } -#ifdef DEBUG - eeprom_write_word((void*)(EECONFIG_KEYMAP_DEBUG), checksum); -#endif - return (checksum_in_eeprom == checksum); -} - -void write_keymap_to_eeprom(void) { - uint16_t checksum = EECONFIG_MAGIC_NUMBER; - const uint16_t *fn_actions = fn_actions_pointer(); - const uint8_t *keymaps = keymaps_pointer(); - // write fn_actions - if (fn_actions != NULL) { - uint16_t fn_actions_count_in_flash = fn_actions_count(); - for (uint16_t i = 0; i < FN_ACTIONS_COUNT; i++) { - uint16_t fn_action = 0; - if (i < fn_actions_count_in_flash) { - fn_action = pgm_read_word(fn_actions + i); - } - eeconfig_write_keymap_fn_action(i, fn_action); - checksum += fn_action; - } - } - // write keymaps - if (keymaps != NULL) { - uint16_t keys_count_in_flash = keys_count(); - for (uint16_t i = 0; i < KEYS_COUNT; i++) { - uint8_t keymap = 0; - if (i < keys_count_in_flash) { - keymap = pgm_read_byte(keymaps + i); - } - eeconfig_write_keymap_key_by_index(i, keymap); - uint16_t keymap_word = keymap; - if (i & 1) { - keymap_word = keymap << 8; - } - checksum += keymap_word; - } - } - // write checksum - eeprom_write_word(&((keymap_ex_t*)EECONFIG_KEYMAP_EX)->checksum, checksum); -} - -uint8_t eeconfig_read_keymap_key(uint8_t layer, uint8_t row, uint8_t col) { - //return eeprom_read_byte(&((keymap_ex_t*)(EECONFIG_KEYMAP_EX))->keymaps[layer][row][col]); - return eeprom_read_byte((void*)(EECONFIG_KEYMAP_KEYMAPS + KEY_OFFSET(layer, row, col))); -} - -void eeconfig_write_keymap_key(uint8_t layer, uint8_t row, uint8_t col, uint8_t key) { - //return eeprom_write_byte(&((keymap_ex_t*)(EECONFIG_KEYMAP_EX))->keymaps[layer][row][col], key); - return eeprom_write_byte((void*)(EECONFIG_KEYMAP_KEYMAPS + KEY_OFFSET(layer, row, col)), key); -} - -uint8_t eeconfig_read_keymap_key_by_index(uint16_t index) { - //return eeprom_read_byte(((keymap_ex_t*)(EECONFIG_KEYMAP_EX)) + index); - return eeprom_read_byte((void*)(EECONFIG_KEYMAP_KEYMAPS + index)); -} - -void eeconfig_write_keymap_key_by_index(uint16_t index, uint8_t key) { - //return eeprom_write_byte(((keymap_ex_t*)(EECONFIG_KEYMAP_EX)) + index, key); - return eeprom_write_byte((void*)(EECONFIG_KEYMAP_KEYMAPS + index), key); -} - -uint16_t eeconfig_read_keymap_fn_action(uint8_t index) { - //return eeprom_read_word(&((keymap_ex_t*)(EECONFIG_KEYMAP_EX))->fn_actions[index]); - return eeprom_read_word((void*)(EECONFIG_KEYMAP_FN_ACTIONS + FN_ACTION_OFFSET(index))); -} - -void eeconfig_write_keymap_fn_action(uint8_t index, uint16_t fn_action) { - //return eeprom_write_word(&((keymap_ex_t*)(EECONFIG_KEYMAP_EX))->fn_actions[index], fn_action); - return eeprom_write_word((void*)(EECONFIG_KEYMAP_FN_ACTIONS + FN_ACTION_OFFSET(index)), fn_action); -} - -#endif diff --git a/common/keymap_ex.h b/common/keymap_ex.h deleted file mode 100644 index ee6ff8c6..00000000 --- a/common/keymap_ex.h +++ /dev/null @@ -1,68 +0,0 @@ -/* -Copyright 2013 Kai Ryu - -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 . -*/ - -#ifndef KEYMAP_EX_H -#define KEYMAP_EX_H - -#ifdef KEYMAP_EX_ENABLE - -#include -#include - -#define EECONFIG_KEYMAP_EX 0x10 -#ifndef FN_ACTIONS_COUNT -#define FN_ACTIONS_COUNT 32 -#endif -#ifndef KEYMAPS_COUNT -#define KEYMAPS_COUNT 8 -#endif - -typedef struct { - uint16_t checksum; - uint16_t fn_actions[FN_ACTIONS_COUNT]; - uint8_t keymaps[KEYMAPS_COUNT][MATRIX_ROWS][MATRIX_COLS]; -} keymap_ex_t; - -#define EECONFIG_KEYMAP_DEBUG (EECONFIG_KEYMAP_EX - sizeof(uint16_t)) -#define EECONFIG_KEYMAP_CHECKSUM (EECONFIG_KEYMAP_EX) -#define EECONFIG_KEYMAP_FN_ACTIONS (EECONFIG_KEYMAP_EX + sizeof(uint16_t)) -#define EECONFIG_KEYMAP_KEYMAPS (EECONFIG_KEYMAP_FN_ACTIONS + sizeof(uint16_t) * FN_ACTIONS_COUNT) - -#define KEYS_COUNT (KEYMAPS_COUNT * MATRIX_ROWS * MATRIX_COLS) -#define KEYMAP_SIZE (sizeof(uint16_t) * FN_ACTIONS_COUNT + sizeof(uint8_t) * KEYS_COUNT) -#define FN_ACTION_OFFSET(index) (sizeof(uint16_t) * index) -#define KEY_OFFSET(layer, row, col) (sizeof(uint8_t) * (layer * MATRIX_ROWS * MATRIX_COLS + row * MATRIX_COLS + col)) - -void keymap_ex_init(void); -void keymap_ex_disable(void); -bool check_keymap_in_eeprom(void); -void write_keymap_to_eeprom(void); -uint8_t eeconfig_read_keymap_key(uint8_t layer, uint8_t row, uint8_t col); -void eeconfig_write_keymap_key(uint8_t layer, uint8_t row, uint8_t col, uint8_t key); -uint8_t eeconfig_read_keymap_key_by_index(uint16_t index); -void eeconfig_write_keymap_key_by_index(uint16_t index, uint8_t key); -uint16_t eeconfig_read_keymap_fn_action(uint8_t index); -void eeconfig_write_keymap_fn_action(uint8_t index, uint16_t fn_action); - -const uint8_t* keymaps_pointer(void); -const uint16_t* fn_actions_pointer(void); -uint16_t keys_count(void); -uint16_t fn_actions_count(void); - -#endif - -#endif