[Keyboard] Misc tidyups for Chidori (#8091)
8 files changed, 59 insertions(+), 169 deletions(-) M keyboards/chidori/board.c M keyboards/chidori/chidori.c M keyboards/chidori/chidori.h M keyboards/chidori/keymaps/default/keymap.c M keyboards/chidori/keymaps/extended/keymap.c M keyboards/chidori/matrix.c M keyboards/chidori/rules.mk M keyboards/chidori/usbconfig.h
M keyboards/chidori/board.c => keyboards/chidori/board.c +0 -2
@@ 141,8 141,6 @@ inline bool board_is_master(board_info_t* board) { return false; } inline uint8_t matrix_rows(void) { return MATRIX_ROWS; } inline uint8_t matrix2board(uint8_t row) { return row % NUM_ROWS; } inline uint8_t board_index(uint8_t row) { return row / NUM_ROWS; }
M keyboards/chidori/chidori.c => keyboards/chidori/chidori.c +2 -0
@@ 13,3 13,5 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "chidori.h"
M keyboards/chidori/chidori.h => keyboards/chidori/chidori.h +33 -35
@@ 13,47 13,45 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include "quantum.h" // clang-format off #define LAYOUT( \ L01, L02, L03, L04, L05, L06, R01, R02, R03, R04, R05, R06, \ L07, L08, L09, L10, L11, L12, R07, R08, R09, R10, R11, R12, \ L13, L14, L15, L16, L17, L18, R13, R14, R15, R16, R17, R18, \ L19, L20, L21, L22, L23, L24, R19, R20, R21, R22, R23, R24 \ ) \ { \ { L01, L02, L03, L04, L05, L06 }, \ { L07, L08, L09, L10, L11, L12 }, \ { L13, L14, L15, L16, L17, L18 }, \ { L19, L20, L21, L22, L23, L24 }, \ { R01, R02, R03, R04, R05, R06 }, \ { R07, R08, R09, R10, R11, R12 }, \ { R13, R14, R15, R16, R17, R18 }, \ { R19, R20, R21, R22, R23, R24 } \ } L01, L02, L03, L04, L05, L06, R01, R02, R03, R04, R05, R06, \ L07, L08, L09, L10, L11, L12, R07, R08, R09, R10, R11, R12, \ L13, L14, L15, L16, L17, L18, R13, R14, R15, R16, R17, R18, \ L19, L20, L21, L22, L23, L24, R19, R20, R21, R22, R23, R24 \ ) { \ { L01, L02, L03, L04, L05, L06 }, \ { L07, L08, L09, L10, L11, L12 }, \ { L13, L14, L15, L16, L17, L18 }, \ { L19, L20, L21, L22, L23, L24 }, \ { R01, R02, R03, R04, R05, R06 }, \ { R07, R08, R09, R10, R11, R12 }, \ { R13, R14, R15, R16, R17, R18 }, \ { R19, R20, R21, R22, R23, R24 } \ } #define LAYOUT_extended( \ L01, L02, L03, L04, L05, L06, M01, M02, M03, M04, M05, M06, R01, R02, R03, R04, R05, R06, \ L07, L08, L09, L10, L11, L12, M07, M08, M09, M10, M11, M12, R07, R08, R09, R10, R11, R12, \ L13, L14, L15, L16, L17, L18, M13, M14, M15, M16, M17, M18, R13, R14, R15, R16, R17, R18, \ L19, L20, L21, L22, L23, L24, M19, M20, M21, M22, M23, M24, R19, R20, R21, R22, R23, R24 \ ) \ { \ { L01, L02, L03, L04, L05, L06 }, \ { L07, L08, L09, L10, L11, L12 }, \ { L13, L14, L15, L16, L17, L18 }, \ { L19, L20, L21, L22, L23, L24 }, \ { M01, M02, M03, M04, M05, M06 }, \ { M07, M08, M09, M10, M11, M12 }, \ { M13, M14, M15, M16, M17, M18 }, \ { M19, M20, M21, M22, M23, M24 }, \ { R01, R02, R03, R04, R05, R06 }, \ { R07, R08, R09, R10, R11, R12 }, \ { R13, R14, R15, R16, R17, R18 }, \ { R19, R20, R21, R22, R23, R24 } \ } L01, L02, L03, L04, L05, L06, M01, M02, M03, M04, M05, M06, R01, R02, R03, R04, R05, R06, \ L07, L08, L09, L10, L11, L12, M07, M08, M09, M10, M11, M12, R07, R08, R09, R10, R11, R12, \ L13, L14, L15, L16, L17, L18, M13, M14, M15, M16, M17, M18, R13, R14, R15, R16, R17, R18, \ L19, L20, L21, L22, L23, L24, M19, M20, M21, M22, M23, M24, R19, R20, R21, R22, R23, R24 \ ) { \ { L01, L02, L03, L04, L05, L06 }, \ { L07, L08, L09, L10, L11, L12 }, \ { L13, L14, L15, L16, L17, L18 }, \ { L19, L20, L21, L22, L23, L24 }, \ { M01, M02, M03, M04, M05, M06 }, \ { M07, M08, M09, M10, M11, M12 }, \ { M13, M14, M15, M16, M17, M18 }, \ { M19, M20, M21, M22, M23, M24 }, \ { R01, R02, R03, R04, R05, R06 }, \ { R07, R08, R09, R10, R11, R12 }, \ { R13, R14, R15, R16, R17, R18 }, \ { R19, R20, R21, R22, R23, R24 } \ } // clang-format on
M keyboards/chidori/keymaps/default/keymap.c => keyboards/chidori/keymaps/default/keymap.c +5 -11
@@ 162,15 162,9 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { return true; } void led_set_user(uint8_t usb_led) { if (IS_LED_ON(usb_led, USB_LED_CAPS_LOCK)) { board_set_led_by_index(0, LED_YELLOW, true); } else { board_set_led_by_index(0, LED_YELLOW, false); } if (IS_LED_ON(usb_led, USB_LED_SCROLL_LOCK)) { board_set_led_by_index(1, LED_YELLOW, true); } else { board_set_led_by_index(1, LED_YELLOW, false); } bool led_update_user(led_t led_state) { board_set_led_by_index(0, LED_YELLOW, led_state.caps_lock); board_set_led_by_index(1, LED_YELLOW, led_state.scroll_lock); return false; }
M keyboards/chidori/keymaps/extended/keymap.c => keyboards/chidori/keymaps/extended/keymap.c +6 -16
@@ 162,20 162,10 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { return true; } void led_set_user(uint8_t usb_led) { if (IS_LED_ON(usb_led, USB_LED_CAPS_LOCK)) { board_set_led_by_index(0, LED_YELLOW, true); } else { board_set_led_by_index(0, LED_YELLOW, false); } if (IS_LED_ON(usb_led, USB_LED_SCROLL_LOCK)) { board_set_led_by_index(1, LED_YELLOW, true); } else { board_set_led_by_index(1, LED_YELLOW, false); } if (IS_LED_ON(usb_led, USB_LED_NUM_LOCK)) { board_set_led_by_index(2, LED_YELLOW, true); } else { board_set_led_by_index(2, LED_YELLOW, false); } bool led_update_user(led_t led_state) { board_set_led_by_index(0, LED_YELLOW, led_state.caps_lock); board_set_led_by_index(1, LED_YELLOW, led_state.scroll_lock); board_set_led_by_index(2, LED_YELLOW, led_state.num_lock); return false; }
M keyboards/chidori/matrix.c => keyboards/chidori/matrix.c +6 -83
@@ 14,100 14,23 @@ 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 <http://www.gnu.org/licenses/>. */ #include <stdint.h> #include <stdbool.h> #include "wait.h" #include "print.h" #include "debug.h" #include "util.h" #include "matrix.h" #include "debounce.h" #include "quantum.h" #include "matrix.h" #include "board.h" #if (MATRIX_COLS <= 8) # define print_matrix_header() print("\nr/c 01234567\n") # define print_matrix_row(row) print_bin_reverse8(matrix_get_row(row)) # define matrix_bitpop(i) bitpop(matrix[i]) # define ROW_SHIFTER ((uint8_t)1) #elif (MATRIX_COLS <= 16) # define print_matrix_header() print("\nr/c 0123456789ABCDEF\n") # define print_matrix_row(row) print_bin_reverse16(matrix_get_row(row)) # define matrix_bitpop(i) bitpop16(matrix[i]) # define ROW_SHIFTER ((uint16_t)1) #elif (MATRIX_COLS <= 32) # define print_matrix_header() print("\nr/c 0123456789ABCDEF0123456789ABCDEF\n") # define print_matrix_row(row) print_bin_reverse32(matrix_get_row(row)) # define matrix_bitpop(i) bitpop32(matrix[i]) # define ROW_SHIFTER ((uint32_t)1) #endif #ifdef MATRIX_MASKED extern const matrix_row_t matrix_mask[]; #endif /* matrix state(1:on, 0:off) */ static matrix_row_t raw_matrix[MATRIX_ROWS]; // raw values static matrix_row_t matrix[MATRIX_ROWS]; // debounced values __attribute__((weak)) void matrix_init_quantum(void) { matrix_init_kb(); } __attribute__((weak)) void matrix_scan_quantum(void) { matrix_scan_kb(); } __attribute__((weak)) void matrix_init_kb(void) { matrix_init_user(); } __attribute__((weak)) void matrix_scan_kb(void) { matrix_scan_user(); } __attribute__((weak)) void matrix_init_user(void) {} __attribute__((weak)) void matrix_scan_user(void) {} inline matrix_row_t matrix_get_row(uint8_t row) { // Matrix mask lets you disable switches in the returned matrix data. For example, if you have a // switch blocker installed and the switch is always pressed. #ifdef MATRIX_MASKED return matrix[row] & matrix_mask[row]; #else return matrix[row]; #endif } void matrix_print(void) { print_matrix_header(); for (uint8_t row = 0; row < MATRIX_ROWS; row++) { phex(row); print(": "); print_matrix_row(row); print("\n"); } } void matrix_init(void) { void matrix_init_custom(void) { // initialize key pins board_init(); // initialize matrix state: all keys off for (uint8_t i = 0; i < MATRIX_ROWS; i++) { raw_matrix[i] = 0; matrix[i] = 0; } debounce_init(MATRIX_ROWS); matrix_init_quantum(); } uint8_t matrix_scan(void) { bool matrix_scan_custom(matrix_row_t current_matrix[]) { bool changed = false; // Set row, read cols for (uint8_t current_row = 0; current_row < MATRIX_ROWS; current_row++) { changed |= board_read_cols_on_row(raw_matrix, current_row); changed |= board_read_cols_on_row(current_matrix, current_row); } debounce(raw_matrix, matrix, MATRIX_ROWS, changed); matrix_scan_quantum(); return 1; return changed; }
M keyboards/chidori/rules.mk => keyboards/chidori/rules.mk +1 -5
@@ 1,9 1,5 @@ # MCU name MCU = atmega328p ARCH = AVR8 F_USB = $(F_CPU) OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT # Bootloader selection @@ # Teensy halfkay 36,7 32,7 @@ AUDIO_ENABLE = no # Audio output on port C6 FAUXCLICKY_ENABLE = no # Use buzzer to emulate clicky switches HD44780_ENABLE = no # Enable support for HD44780 based LCDs CUSTOM_MATRIX = yes CUSTOM_MATRIX = lite # project specific files SRC += matrix.c
M keyboards/chidori/usbconfig.h => keyboards/chidori/usbconfig.h +6 -17
@@ 109,21 109,10 @@ section at the end of this file). * (e.g. HID), but never want to send any data. This option saves a couple * of bytes in flash memory and the transmit buffers in RAM. */ #define USB_CFG_INTR_POLL_INTERVAL 1 /* If you compile a version with endpoint 1 (interrupt-in), this is the poll * interval. The value is in milliseconds and must not be less than 10 ms for * low speed devices. */ #define USB_CFG_IS_SELF_POWERED 0 /* Define this to 1 if the device has its own power supply. Set it to 0 if the * device is powered from the USB bus. */ // max power draw with maxed white underglow measured at 120 mA (peaks) #define USB_CFG_MAX_BUS_POWER 100 /* Set this variable to the maximum USB bus power consumption of your device. * The value is in milliamperes. [It will be divided by two since USB * communicates power requirements in units of 2 mA.] */ #define USB_CFG_IMPLEMENT_FN_WRITE 1 /* Set this to 1 if you want usbFunctionWrite() to be called for control-out @@ * 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). /* -------------------------- Device Description --------------------------- */ #define USB_CFG_VENDOR_ID (VENDOR_ID & 0xED), ((VENDOR_ID >> 8) & 0xFE) #define USB_CFG_VENDOR_ID (VENDOR_ID & 0xFF), ((VENDOR_ID >> 8) & 0xFF) /* USB vendor ID for the device, low byte first. If you have registered your * own Vendor ID, define it here. Otherwise you may use one of obdev's free @@ * 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). * with libusb: 0x16c0/0x5dc. Use this VID/PID pair ONLY if you understand * the implications! */ #define USB_CFG_DEVICE_ID (PRODUCT_ID & 0x00), ((PRODUCT_ID >> 8) & 0x00) #define USB_CFG_DEVICE_ID (PRODUCT_ID & 0xFF), ((PRODUCT_ID >> 8) & 0xFF) /* This is the ID of the product, low byte first. It is interpreted in the * scope of the vendor ID. If you have registered your own VID with usb.org @@ * 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). * with libusb: 0x16c0/0x5dc. Use this VID/PID pair ONLY if you understand * the implications! */ #define USB_CFG_DEVICE_VERSION 0x00, 0x01 #define USB_CFG_DEVICE_VERSION (DEVICE_VER & 0xFF), ((DEVICE_VER >> 8) & 0xFF) /* Version number of the device: Minor number first, then major number. */ #define USB_CFG_VENDOR_NAME 'k','a','g','i','z','a','r','a','y','a' #define USB_CFG_VENDOR_NAME 'K','a','g','i','z','a','r','a','y','a' #define USB_CFG_VENDOR_NAME_LEN 10 /* These two values define the vendor name returned by the USB device. The name @@ * must be given as a list of characters under single quotes. The characters 258,8 247,8 @@ section at the end of this file). * the macros. See the file USB-IDs-for-free.txt before you assign a name if * you use a shared VID/PID. */ //#define USB_CFG_SERIAL_NUMBER 'd','m','9','r','e','c','o','r','d','s','.','c','o','m',':','p','1' //#define USB_CFG_SERIAL_NUMBER_LEN 17 /*#define USB_CFG_SERIAL_NUMBER 'N', 'o', 'n', 'e' */ /*#define USB_CFG_SERIAL_NUMBER_LEN 0 */ /* Same as above for the serial number. If you don't want a serial number, * undefine the macros. * It may be useful to provide the serial number through other means than at