aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--keyboards/chidori/board.c2
-rw-r--r--keyboards/chidori/chidori.c2
-rw-r--r--keyboards/chidori/chidori.h68
-rw-r--r--keyboards/chidori/keymaps/default/keymap.c16
-rw-r--r--keyboards/chidori/keymaps/extended/keymap.c22
-rw-r--r--keyboards/chidori/matrix.c89
-rw-r--r--keyboards/chidori/rules.mk6
-rw-r--r--keyboards/chidori/usbconfig.h23
8 files changed, 59 insertions, 169 deletions
diff --git a/keyboards/chidori/board.c b/keyboards/chidori/board.c
index ff5b76a3a..e00156eb9 100644
--- a/keyboards/chidori/board.c
+++ b/keyboards/chidori/board.c
@@ -141,8 +141,6 @@ inline bool board_is_master(board_info_t* board) {
141 return false; 141 return false;
142} 142}
143 143
144inline uint8_t matrix_rows(void) { return MATRIX_ROWS; }
145
146inline uint8_t matrix2board(uint8_t row) { return row % NUM_ROWS; } 144inline uint8_t matrix2board(uint8_t row) { return row % NUM_ROWS; }
147 145
148inline uint8_t board_index(uint8_t row) { return row / NUM_ROWS; } 146inline uint8_t board_index(uint8_t row) { return row / NUM_ROWS; }
diff --git a/keyboards/chidori/chidori.c b/keyboards/chidori/chidori.c
index a3b6f2c04..229982724 100644
--- a/keyboards/chidori/chidori.c
+++ b/keyboards/chidori/chidori.c
@@ -13,3 +13,5 @@
13 * You should have received a copy of the GNU General Public License 13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>. 14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */ 15 */
16
17#include "chidori.h"
diff --git a/keyboards/chidori/chidori.h b/keyboards/chidori/chidori.h
index efaff7194..d82b9217f 100644
--- a/keyboards/chidori/chidori.h
+++ b/keyboards/chidori/chidori.h
@@ -13,47 +13,45 @@
13 * You should have received a copy of the GNU General Public License 13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>. 14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */ 15 */
16
16#pragma once 17#pragma once
17 18
18#include "quantum.h" 19#include "quantum.h"
19 20
20// clang-format off 21// clang-format off
21#define LAYOUT( \ 22#define LAYOUT( \
22 L01, L02, L03, L04, L05, L06, R01, R02, R03, R04, R05, R06, \ 23 L01, L02, L03, L04, L05, L06, R01, R02, R03, R04, R05, R06, \
23 L07, L08, L09, L10, L11, L12, R07, R08, R09, R10, R11, R12, \ 24 L07, L08, L09, L10, L11, L12, R07, R08, R09, R10, R11, R12, \
24 L13, L14, L15, L16, L17, L18, R13, R14, R15, R16, R17, R18, \ 25 L13, L14, L15, L16, L17, L18, R13, R14, R15, R16, R17, R18, \
25 L19, L20, L21, L22, L23, L24, R19, R20, R21, R22, R23, R24 \ 26 L19, L20, L21, L22, L23, L24, R19, R20, R21, R22, R23, R24 \
26 ) \ 27) { \
27 { \ 28 { L01, L02, L03, L04, L05, L06 }, \
28 { L01, L02, L03, L04, L05, L06 }, \ 29 { L07, L08, L09, L10, L11, L12 }, \
29 { L07, L08, L09, L10, L11, L12 }, \ 30 { L13, L14, L15, L16, L17, L18 }, \
30 { L13, L14, L15, L16, L17, L18 }, \ 31 { L19, L20, L21, L22, L23, L24 }, \
31 { L19, L20, L21, L22, L23, L24 }, \ 32 { R01, R02, R03, R04, R05, R06 }, \
32 { R01, R02, R03, R04, R05, R06 }, \ 33 { R07, R08, R09, R10, R11, R12 }, \
33 { R07, R08, R09, R10, R11, R12 }, \ 34 { R13, R14, R15, R16, R17, R18 }, \
34 { R13, R14, R15, R16, R17, R18 }, \ 35 { R19, R20, R21, R22, R23, R24 } \
35 { R19, R20, R21, R22, R23, R24 } \ 36}
36 }
37 37
38#define LAYOUT_extended( \ 38#define LAYOUT_extended( \
39 L01, L02, L03, L04, L05, L06, M01, M02, M03, M04, M05, M06, R01, R02, R03, R04, R05, R06, \ 39 L01, L02, L03, L04, L05, L06, M01, M02, M03, M04, M05, M06, R01, R02, R03, R04, R05, R06, \
40 L07, L08, L09, L10, L11, L12, M07, M08, M09, M10, M11, M12, R07, R08, R09, R10, R11, R12, \ 40 L07, L08, L09, L10, L11, L12, M07, M08, M09, M10, M11, M12, R07, R08, R09, R10, R11, R12, \
41 L13, L14, L15, L16, L17, L18, M13, M14, M15, M16, M17, M18, R13, R14, R15, R16, R17, R18, \ 41 L13, L14, L15, L16, L17, L18, M13, M14, M15, M16, M17, M18, R13, R14, R15, R16, R17, R18, \
42 L19, L20, L21, L22, L23, L24, M19, M20, M21, M22, M23, M24, R19, R20, R21, R22, R23, R24 \ 42 L19, L20, L21, L22, L23, L24, M19, M20, M21, M22, M23, M24, R19, R20, R21, R22, R23, R24 \
43 ) \ 43) { \
44 { \ 44 { L01, L02, L03, L04, L05, L06 }, \
45 { L01, L02, L03, L04, L05, L06 }, \ 45 { L07, L08, L09, L10, L11, L12 }, \
46 { L07, L08, L09, L10, L11, L12 }, \ 46 { L13, L14, L15, L16, L17, L18 }, \
47 { L13, L14, L15, L16, L17, L18 }, \ 47 { L19, L20, L21, L22, L23, L24 }, \
48 { L19, L20, L21, L22, L23, L24 }, \ 48 { M01, M02, M03, M04, M05, M06 }, \
49 { M01, M02, M03, M04, M05, M06 }, \ 49 { M07, M08, M09, M10, M11, M12 }, \
50 { M07, M08, M09, M10, M11, M12 }, \ 50 { M13, M14, M15, M16, M17, M18 }, \
51 { M13, M14, M15, M16, M17, M18 }, \ 51 { M19, M20, M21, M22, M23, M24 }, \
52 { M19, M20, M21, M22, M23, M24 }, \ 52 { R01, R02, R03, R04, R05, R06 }, \
53 { R01, R02, R03, R04, R05, R06 }, \ 53 { R07, R08, R09, R10, R11, R12 }, \
54 { R07, R08, R09, R10, R11, R12 }, \ 54 { R13, R14, R15, R16, R17, R18 }, \
55 { R13, R14, R15, R16, R17, R18 }, \ 55 { R19, R20, R21, R22, R23, R24 } \
56 { R19, R20, R21, R22, R23, R24 } \ 56}
57 }
58
59// clang-format on 57// clang-format on
diff --git a/keyboards/chidori/keymaps/default/keymap.c b/keyboards/chidori/keymaps/default/keymap.c
index 4aacdfb74..373b5ec83 100644
--- a/keyboards/chidori/keymaps/default/keymap.c
+++ b/keyboards/chidori/keymaps/default/keymap.c
@@ -162,15 +162,9 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
162 return true; 162 return true;
163} 163}
164 164
165void led_set_user(uint8_t usb_led) { 165bool led_update_user(led_t led_state) {
166 if (IS_LED_ON(usb_led, USB_LED_CAPS_LOCK)) { 166 board_set_led_by_index(0, LED_YELLOW, led_state.caps_lock);
167 board_set_led_by_index(0, LED_YELLOW, true); 167 board_set_led_by_index(1, LED_YELLOW, led_state.scroll_lock);
168 } else { 168
169 board_set_led_by_index(0, LED_YELLOW, false); 169 return false;
170 }
171 if (IS_LED_ON(usb_led, USB_LED_SCROLL_LOCK)) {
172 board_set_led_by_index(1, LED_YELLOW, true);
173 } else {
174 board_set_led_by_index(1, LED_YELLOW, false);
175 }
176} 170}
diff --git a/keyboards/chidori/keymaps/extended/keymap.c b/keyboards/chidori/keymaps/extended/keymap.c
index a5c9769f0..174e9ff2e 100644
--- a/keyboards/chidori/keymaps/extended/keymap.c
+++ b/keyboards/chidori/keymaps/extended/keymap.c
@@ -162,20 +162,10 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
162 return true; 162 return true;
163} 163}
164 164
165void led_set_user(uint8_t usb_led) { 165bool led_update_user(led_t led_state) {
166 if (IS_LED_ON(usb_led, USB_LED_CAPS_LOCK)) { 166 board_set_led_by_index(0, LED_YELLOW, led_state.caps_lock);
167 board_set_led_by_index(0, LED_YELLOW, true); 167 board_set_led_by_index(1, LED_YELLOW, led_state.scroll_lock);
168 } else { 168 board_set_led_by_index(2, LED_YELLOW, led_state.num_lock);
169 board_set_led_by_index(0, LED_YELLOW, false); 169
170 } 170 return false;
171 if (IS_LED_ON(usb_led, USB_LED_SCROLL_LOCK)) {
172 board_set_led_by_index(1, LED_YELLOW, true);
173 } else {
174 board_set_led_by_index(1, LED_YELLOW, false);
175 }
176 if (IS_LED_ON(usb_led, USB_LED_NUM_LOCK)) {
177 board_set_led_by_index(2, LED_YELLOW, true);
178 } else {
179 board_set_led_by_index(2, LED_YELLOW, false);
180 }
181} 171}
diff --git a/keyboards/chidori/matrix.c b/keyboards/chidori/matrix.c
index 204f236a6..6228125d9 100644
--- a/keyboards/chidori/matrix.c
+++ b/keyboards/chidori/matrix.c
@@ -14,100 +14,23 @@ GNU General Public License for more details.
14You should have received a copy of the GNU General Public License 14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>. 15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/ 16*/
17#include <stdint.h> 17
18#include <stdbool.h>
19#include "wait.h"
20#include "print.h"
21#include "debug.h"
22#include "util.h"
23#include "matrix.h"
24#include "debounce.h"
25#include "quantum.h" 18#include "quantum.h"
19#include "matrix.h"
26#include "board.h" 20#include "board.h"
27 21
28#if (MATRIX_COLS <= 8) 22void matrix_init_custom(void) {
29# define print_matrix_header() print("\nr/c 01234567\n")
30# define print_matrix_row(row) print_bin_reverse8(matrix_get_row(row))
31# define matrix_bitpop(i) bitpop(matrix[i])
32# define ROW_SHIFTER ((uint8_t)1)
33#elif (MATRIX_COLS <= 16)
34# define print_matrix_header() print("\nr/c 0123456789ABCDEF\n")
35# define print_matrix_row(row) print_bin_reverse16(matrix_get_row(row))
36# define matrix_bitpop(i) bitpop16(matrix[i])
37# define ROW_SHIFTER ((uint16_t)1)
38#elif (MATRIX_COLS <= 32)
39# define print_matrix_header() print("\nr/c 0123456789ABCDEF0123456789ABCDEF\n")
40# define print_matrix_row(row) print_bin_reverse32(matrix_get_row(row))
41# define matrix_bitpop(i) bitpop32(matrix[i])
42# define ROW_SHIFTER ((uint32_t)1)
43#endif
44
45#ifdef MATRIX_MASKED
46extern const matrix_row_t matrix_mask[];
47#endif
48
49/* matrix state(1:on, 0:off) */
50static matrix_row_t raw_matrix[MATRIX_ROWS]; // raw values
51static matrix_row_t matrix[MATRIX_ROWS]; // debounced values
52
53__attribute__((weak)) void matrix_init_quantum(void) { matrix_init_kb(); }
54
55__attribute__((weak)) void matrix_scan_quantum(void) { matrix_scan_kb(); }
56
57__attribute__((weak)) void matrix_init_kb(void) { matrix_init_user(); }
58
59__attribute__((weak)) void matrix_scan_kb(void) { matrix_scan_user(); }
60
61__attribute__((weak)) void matrix_init_user(void) {}
62
63__attribute__((weak)) void matrix_scan_user(void) {}
64
65inline matrix_row_t matrix_get_row(uint8_t row) {
66 // Matrix mask lets you disable switches in the returned matrix data. For example, if you have a
67 // switch blocker installed and the switch is always pressed.
68#ifdef MATRIX_MASKED
69 return matrix[row] & matrix_mask[row];
70#else
71 return matrix[row];
72#endif
73}
74
75void matrix_print(void) {
76 print_matrix_header();
77
78 for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
79 phex(row);
80 print(": ");
81 print_matrix_row(row);
82 print("\n");
83 }
84}
85
86void matrix_init(void) {
87 // initialize key pins 23 // initialize key pins
88 board_init(); 24 board_init();
89
90 // initialize matrix state: all keys off
91 for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
92 raw_matrix[i] = 0;
93 matrix[i] = 0;
94 }
95
96 debounce_init(MATRIX_ROWS);
97
98 matrix_init_quantum();
99} 25}
100 26
101uint8_t matrix_scan(void) { 27bool matrix_scan_custom(matrix_row_t current_matrix[]) {
102 bool changed = false; 28 bool changed = false;
103 29
104 // Set row, read cols 30 // Set row, read cols
105 for (uint8_t current_row = 0; current_row < MATRIX_ROWS; current_row++) { 31 for (uint8_t current_row = 0; current_row < MATRIX_ROWS; current_row++) {
106 changed |= board_read_cols_on_row(raw_matrix, current_row); 32 changed |= board_read_cols_on_row(current_matrix, current_row);
107 } 33 }
108 34
109 debounce(raw_matrix, matrix, MATRIX_ROWS, changed); 35 return changed;
110
111 matrix_scan_quantum();
112 return 1;
113} 36}
diff --git a/keyboards/chidori/rules.mk b/keyboards/chidori/rules.mk
index 2e88146ba..7902c41db 100644
--- a/keyboards/chidori/rules.mk
+++ b/keyboards/chidori/rules.mk
@@ -1,9 +1,5 @@
1# MCU name 1# MCU name
2MCU = atmega328p 2MCU = atmega328p
3ARCH = AVR8
4F_USB = $(F_CPU)
5
6OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT
7 3
8# Bootloader selection 4# Bootloader selection
9# Teensy halfkay 5# Teensy halfkay
@@ -36,7 +32,7 @@ AUDIO_ENABLE = no # Audio output on port C6
36FAUXCLICKY_ENABLE = no # Use buzzer to emulate clicky switches 32FAUXCLICKY_ENABLE = no # Use buzzer to emulate clicky switches
37HD44780_ENABLE = no # Enable support for HD44780 based LCDs 33HD44780_ENABLE = no # Enable support for HD44780 based LCDs
38 34
39CUSTOM_MATRIX = yes 35CUSTOM_MATRIX = lite
40 36
41# project specific files 37# project specific files
42SRC += matrix.c 38SRC += matrix.c
diff --git a/keyboards/chidori/usbconfig.h b/keyboards/chidori/usbconfig.h
index 361868d28..48b72de93 100644
--- a/keyboards/chidori/usbconfig.h
+++ b/keyboards/chidori/usbconfig.h
@@ -109,21 +109,10 @@ section at the end of this file).
109 * (e.g. HID), but never want to send any data. This option saves a couple 109 * (e.g. HID), but never want to send any data. This option saves a couple
110 * of bytes in flash memory and the transmit buffers in RAM. 110 * of bytes in flash memory and the transmit buffers in RAM.
111 */ 111 */
112#define USB_CFG_INTR_POLL_INTERVAL 1
113/* If you compile a version with endpoint 1 (interrupt-in), this is the poll
114 * interval. The value is in milliseconds and must not be less than 10 ms for
115 * low speed devices.
116 */
117#define USB_CFG_IS_SELF_POWERED 0 112#define USB_CFG_IS_SELF_POWERED 0
118/* Define this to 1 if the device has its own power supply. Set it to 0 if the 113/* Define this to 1 if the device has its own power supply. Set it to 0 if the
119 * device is powered from the USB bus. 114 * device is powered from the USB bus.
120 */ 115 */
121// max power draw with maxed white underglow measured at 120 mA (peaks)
122#define USB_CFG_MAX_BUS_POWER 100
123/* Set this variable to the maximum USB bus power consumption of your device.
124 * The value is in milliamperes. [It will be divided by two since USB
125 * communicates power requirements in units of 2 mA.]
126 */
127#define USB_CFG_IMPLEMENT_FN_WRITE 1 116#define USB_CFG_IMPLEMENT_FN_WRITE 1
128/* Set this to 1 if you want usbFunctionWrite() to be called for control-out 117/* Set this to 1 if you want usbFunctionWrite() to be called for control-out
129 * transfers. Set it to 0 if you don't need it and want to save a couple of 118 * transfers. Set it to 0 if you don't need it and want to save a couple of
@@ -219,7 +208,7 @@ section at the end of this file).
219 208
220/* -------------------------- Device Description --------------------------- */ 209/* -------------------------- Device Description --------------------------- */
221 210
222#define USB_CFG_VENDOR_ID (VENDOR_ID & 0xED), ((VENDOR_ID >> 8) & 0xFE) 211#define USB_CFG_VENDOR_ID (VENDOR_ID & 0xFF), ((VENDOR_ID >> 8) & 0xFF)
223/* USB vendor ID for the device, low byte first. If you have registered your 212/* USB vendor ID for the device, low byte first. If you have registered your
224 * own Vendor ID, define it here. Otherwise you may use one of obdev's free 213 * own Vendor ID, define it here. Otherwise you may use one of obdev's free
225 * shared VID/PID pairs. Be sure to read USB-IDs-for-free.txt for rules! 214 * shared VID/PID pairs. Be sure to read USB-IDs-for-free.txt for rules!
@@ -228,7 +217,7 @@ section at the end of this file).
228 * with libusb: 0x16c0/0x5dc. Use this VID/PID pair ONLY if you understand 217 * with libusb: 0x16c0/0x5dc. Use this VID/PID pair ONLY if you understand
229 * the implications! 218 * the implications!
230 */ 219 */
231#define USB_CFG_DEVICE_ID (PRODUCT_ID & 0x00), ((PRODUCT_ID >> 8) & 0x00) 220#define USB_CFG_DEVICE_ID (PRODUCT_ID & 0xFF), ((PRODUCT_ID >> 8) & 0xFF)
232/* This is the ID of the product, low byte first. It is interpreted in the 221/* This is the ID of the product, low byte first. It is interpreted in the
233 * scope of the vendor ID. If you have registered your own VID with usb.org 222 * scope of the vendor ID. If you have registered your own VID with usb.org
234 * or if you have licensed a PID from somebody else, define it here. Otherwise 223 * or if you have licensed a PID from somebody else, define it here. Otherwise
@@ -239,10 +228,10 @@ section at the end of this file).
239 * with libusb: 0x16c0/0x5dc. Use this VID/PID pair ONLY if you understand 228 * with libusb: 0x16c0/0x5dc. Use this VID/PID pair ONLY if you understand
240 * the implications! 229 * the implications!
241 */ 230 */
242#define USB_CFG_DEVICE_VERSION 0x00, 0x01 231#define USB_CFG_DEVICE_VERSION (DEVICE_VER & 0xFF), ((DEVICE_VER >> 8) & 0xFF)
243/* Version number of the device: Minor number first, then major number. 232/* Version number of the device: Minor number first, then major number.
244 */ 233 */
245#define USB_CFG_VENDOR_NAME 'k','a','g','i','z','a','r','a','y','a' 234#define USB_CFG_VENDOR_NAME 'K','a','g','i','z','a','r','a','y','a'
246#define USB_CFG_VENDOR_NAME_LEN 10 235#define USB_CFG_VENDOR_NAME_LEN 10
247/* These two values define the vendor name returned by the USB device. The name 236/* These two values define the vendor name returned by the USB device. The name
248 * must be given as a list of characters under single quotes. The characters 237 * must be given as a list of characters under single quotes. The characters
@@ -258,8 +247,8 @@ section at the end of this file).
258 * the macros. See the file USB-IDs-for-free.txt before you assign a name if 247 * the macros. See the file USB-IDs-for-free.txt before you assign a name if
259 * you use a shared VID/PID. 248 * you use a shared VID/PID.
260 */ 249 */
261//#define USB_CFG_SERIAL_NUMBER 'd','m','9','r','e','c','o','r','d','s','.','c','o','m',':','p','1' 250/*#define USB_CFG_SERIAL_NUMBER 'N', 'o', 'n', 'e' */
262//#define USB_CFG_SERIAL_NUMBER_LEN 17 251/*#define USB_CFG_SERIAL_NUMBER_LEN 0 */
263/* Same as above for the serial number. If you don't want a serial number, 252/* Same as above for the serial number. If you don't want a serial number,
264 * undefine the macros. 253 * undefine the macros.
265 * It may be useful to provide the serial number through other means than at 254 * It may be useful to provide the serial number through other means than at