From 1f2c09aaaefd3fbc06222030ddc300d35e6b524c Mon Sep 17 00:00:00 2001 From: fenuks Date: Sun, 26 Sep 2021 01:06:40 +0200 Subject: [PATCH 1/3] Draft: adapt downsteam Ghost Squid support to lastest QMK --- keyboards/bpiphany/ghost_squid/config.h | 42 +++++ keyboards/bpiphany/ghost_squid/ghost_squid.c | 80 +++++++++ keyboards/bpiphany/ghost_squid/ghost_squid.h | 54 ++++++ .../ghost_squid/keymaps/default/config.h | 3 + .../ghost_squid/keymaps/default/keymap.c | 58 ++++++ .../ghost_squid/keymaps/default/readme.md | 1 + .../ghost_squid/keymaps/default/rules.mk | 17 ++ keyboards/bpiphany/ghost_squid/matrix.c | 167 ++++++++++++++++++ keyboards/bpiphany/ghost_squid/readme.md | 34 ++++ keyboards/bpiphany/ghost_squid/rules.mk | 66 +++++++ 10 files changed, 522 insertions(+) create mode 100644 keyboards/bpiphany/ghost_squid/config.h create mode 100644 keyboards/bpiphany/ghost_squid/ghost_squid.c create mode 100644 keyboards/bpiphany/ghost_squid/ghost_squid.h create mode 100644 keyboards/bpiphany/ghost_squid/keymaps/default/config.h create mode 100644 keyboards/bpiphany/ghost_squid/keymaps/default/keymap.c create mode 100644 keyboards/bpiphany/ghost_squid/keymaps/default/readme.md create mode 100644 keyboards/bpiphany/ghost_squid/keymaps/default/rules.mk create mode 100644 keyboards/bpiphany/ghost_squid/matrix.c create mode 100644 keyboards/bpiphany/ghost_squid/readme.md create mode 100644 keyboards/bpiphany/ghost_squid/rules.mk diff --git a/keyboards/bpiphany/ghost_squid/config.h b/keyboards/bpiphany/ghost_squid/config.h new file mode 100644 index 000000000000..3918ee98626b --- /dev/null +++ b/keyboards/bpiphany/ghost_squid/config.h @@ -0,0 +1,42 @@ +/* +Copyright 2016 Daniel Svensson + +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 . +*/ + +#pragma once + +#include "config_common.h" + +/* USB Device descriptor parameter */ +#define VENDOR_ID 0xFEED +#define PRODUCT_ID 0x6050 +#define DEVICE_VER 0x0104 +#define MANUFACTURER Bathroom Epiphanies +#define PRODUCT ghost_squid + +/* key matrix size */ +#define MATRIX_ROWS 8 +#define MATRIX_COLS 18 + +/* COL2ROW or ROW2COL */ +#define DIODE_DIRECTION COL2ROW + +/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */ +#define DEBOUNCE 5 + +/* key combination for magic key command */ +#define IS_COMMAND() ( \ + keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \ +) diff --git a/keyboards/bpiphany/ghost_squid/ghost_squid.c b/keyboards/bpiphany/ghost_squid/ghost_squid.c new file mode 100644 index 000000000000..85d1665fe45b --- /dev/null +++ b/keyboards/bpiphany/ghost_squid/ghost_squid.c @@ -0,0 +1,80 @@ +/* +Copyright 2016 Daniel Svensson + +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 "ghost_squid.h" + +__attribute__ ((weak)) +void matrix_init_user(void) { +}; + +__attribute__ ((weak)) +void matrix_scan_user(void) { +} + +__attribute__ ((weak)) +bool process_action_user(keyrecord_t *record) { + return true; +} + +/* __attribute__ ((weak)) */ +/* void led_set_user(uint8_t usb_led) { */ +/* } */ + +void matrix_init_kb(void) { + matrix_init_user(); +} + +void matrix_scan_kb(void) { + matrix_scan_user(); +} + +bool process_action_kb(keyrecord_t *record) { + return process_action_user(record); +} + +void led_set_kb(uint8_t usb_led) { + led_set_user(usb_led); +} + +void led_set_user(uint8_t usb_led) { + if (usb_led & (1 << USB_LED_NUM_LOCK)) { + num_led_on(); + } else { + num_led_off(); + } + + if (usb_led & (1 << USB_LED_CAPS_LOCK)) { + caps_led_on(); + } else { + caps_led_off(); + } + + if (usb_led & (1 << USB_LED_SCROLL_LOCK)) { + scroll_led_on(); + } else { + scroll_led_off(); + } +} + +extern inline void num_led_on(void); +extern inline void num_led_off(void); +extern inline void caps_led_on(void); +extern inline void caps_led_off(void); +extern inline void scroll_led_on(void); +extern inline void scroll_led_off(void); +extern inline void fn_led_on(void); +extern inline void fn_led_off(void); diff --git a/keyboards/bpiphany/ghost_squid/ghost_squid.h b/keyboards/bpiphany/ghost_squid/ghost_squid.h new file mode 100644 index 000000000000..8cf2c687eb04 --- /dev/null +++ b/keyboards/bpiphany/ghost_squid/ghost_squid.h @@ -0,0 +1,54 @@ +/* +Copyright 2016 Daniel Svensson + +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 . +*/ + +#pragma once + +#include "matrix.h" +#include "quantum.h" + +inline void num_led_on(void) { DDRC |= (1<<5); PORTC &= ~(1<<5); } +inline void num_led_off(void) { DDRC &= ~(1<<5); PORTC &= ~(1<<5); } + +inline void caps_led_on(void) { DDRC |= (1<<6); PORTC &= ~(1<<6); } +inline void caps_led_off(void) { DDRC &= ~(1<<6); PORTC &= ~(1<<6); } + +inline void scroll_led_on(void) { DDRB |= (1<<7); PORTB &= ~(1<<7); } +inline void scroll_led_off(void) { DDRB &= ~(1<<7); PORTB &= ~(1<<7); } + +inline void fn_led_on(void) { DDRD |= (1<<0); PORTD &= ~(1<<0); } +inline void fn_led_off(void) { DDRD &= ~(1<<0); PORTD &= ~(1<<0); } + +#define ___ KC_NO + +#define LAYOUT( \ + KJ6, KI4, KH4, KH2, KH6, KA7, KE6, KD2, KD4, KB4, KB7, KB6, KB0, KC7, KC5, KA5, \ + KJ4, KJ7, KI7, KH7, KG7, KG4, KF4, KF7, KE7, KD7, KR7, KR4, KE4, KB2, KL4, KO4, KQ4, KK1, KL1, KQ1, KQ0, \ + KJ2, KJ5, KI5, KH5, KG5, KG2, KF2, KF5, KE5, KD5, KR5, KR2, KE2, KB3, KK4, KO7, KQ7, KK5, KL5, KQ5, KO5, \ + KI2, KJ3, KI3, KH3, KG3, KG6, KF6, KF3, KE3, KD3, KR3, KR6, KB1, KK2, KL2, KQ2, \ + KN2, KI6, KJ1, KI1, KH1, KG1, KG0, KF0, KF1, KE1, KD1, KR0, KN3, KO6, KK3, KL3, KQ3, KO3, \ + KA4, KP2, KC6, KK6, KC0, KM3, KD0, KA1, KO0, KK0, KL0, KL6, KQ6 \ + ) { /* 00-A 01-B 02-C 03-D 04-E 05-F 06-G 07-H 08-I 09-J 10-K 11-L 12-M 13-N 14-O 15-P 16-Q 17-R */ \ + /* 0 */ { ___ , KB0 , KC0 , KD0 , ___ , KF0 , KG0 , ___ , ___ , ___ , KK0 , KL0 , ___ , ___ , KO0 , ___ , KQ0 , KR0 }, \ + /* 1 */ { KA1 , KB1 , ___ , KD1 , KE1 , KF1 , KG1 , KH1 , KI1 , KJ1 , KK1 , KL1 , ___ , ___ , ___ , ___ , KQ1 , ___ }, \ + /* 2 */ { ___ , KB2 , ___ , KD2 , KE2 , KF2 , KG2 , KH2 , KI2 , KJ2 , KK2 , KL2 , ___ , KN2 , ___ , KP2 , KQ2 , KR2 }, \ + /* 3 */ { ___ , KB3 , ___ , KD3 , KE3 , KF3 , KG3 , KH3 , KI3 , KJ3 , KK3 , KL3 , KM3 , KN3 , KO3 , ___ , KQ3 , KR3 }, \ + /* 4 */ { KA4 , KB4 , ___ , KD4 , KE4 , KF4 , KG4 , KH4 , KI4 , KJ4 , KK4 , KL4 , ___ , ___ , KO4 , ___ , KQ4 , KR4 }, \ + /* 5 */ { KA5 , ___ , KC5 , KD5 , KE5 , KF5 , KG5 , KH5 , KI5 , KJ5 , KK5 , KL5 , ___ , ___ , KO5 , ___ , KQ5 , KR5 }, \ + /* 6 */ { ___ , KB6 , KC6 , ___ , KE6 , KF6 , KG6 , KH6 , KI6 , KJ6 , KK6 , KL6 , ___ , ___ , KO6 , ___ , KQ6 , KR6 }, \ + /* 7 */ { KA7 , KB7 , KC7 , KD7 , KE7 , KF7 , KG7 , KH7 , KI7 , KJ7 , ___ , ___ , ___ , ___ , KO7 , ___ , KQ7 , KR7 } \ + } + diff --git a/keyboards/bpiphany/ghost_squid/keymaps/default/config.h b/keyboards/bpiphany/ghost_squid/keymaps/default/config.h new file mode 100644 index 000000000000..271f48d0011b --- /dev/null +++ b/keyboards/bpiphany/ghost_squid/keymaps/default/config.h @@ -0,0 +1,3 @@ +#pragma once + +// place overrides here diff --git a/keyboards/bpiphany/ghost_squid/keymaps/default/keymap.c b/keyboards/bpiphany/ghost_squid/keymaps/default/keymap.c new file mode 100644 index 000000000000..3760142276be --- /dev/null +++ b/keyboards/bpiphany/ghost_squid/keymaps/default/keymap.c @@ -0,0 +1,58 @@ +/* +Copyright 2016 Daniel Svensson + +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 QMK_KEYBOARD_H + +/* Default qwerty layout +* ┌───┐ ┌───┬───┬───┬───┐ ┌───┬───┬───┬───┐ ┌───┬───┬───┬───┐ ┌───┬───┬───┐ ┌───────────┐ +* │ESC│ │F1 │F2 │F3 │F4 │ │F5 │F6 │F7 │F8 │ │F9 │F10│F11│F12│ │PRT│SCR│PAU│ │Ghost Squid│ +* └───┘ └───┴───┴───┴───┘ └───┴───┴───┴───┘ └───┴───┴───┴───┘ └───┴───┴───┘ └───────────┘ +* ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐ ┌───┬───┬───┐ ┌───┬───┬───┬───┐ +* │ ` │ 1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │ 8 │ 9 │ 0 │ - │ = │ Backsp│ │INS│HOM│PgU│ │NUM│ / │ * │ - │ +* ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤ ├───┼───┼───┤ ├───┼───┼───┼───┤ +* │ Tab │ Q │ W │ E │ R │ T │ Y │ U │ I │ O │ P │ [ │ ] │ENTER│ │DEL│END│PgD│ │ 7 │ 8 │ 9 │ │ +* ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┐ │ └───┴───┴───┘ ├───┼───┼───┤ + │ +* │ Caps │ A │ S │ D │ F │ G │ H │ J │ K │ L │ ; │ ' │ \ │ │ │ 7 │ 8 │ 9 │ │ +* ├────┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴───┴────┤ ┌───┐ ├───┼───┼───┼───┤ +* │Shif│ # │ Z │ X │ C │ V │ B │ N │ M │ , │ . │ / │ Shift │ │HOM│ │ 1 │ 2 │ 3 │ E │ +* ├────┼───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴───┼───┴┬────┬────┤ ┌───┼───┼───┐ ├───┴───┼───┤ N │ +* │Ctrl│GUI │Alt │ │ Alt│ GUI│Fn │Ctrl│ │DEL│END│PgD│ │ 0 │ , │ T │ +* └────┴────┴────┴────────────────────────┴────┴────┴────┴────┘ └───┴───┴───┘ └───────┴───┴───┘ +*/ + +#define KM_QWERTY 0 +#define KM_MEDIA 1 + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + /* Layer 0: Standard ISO layer */ + [KM_QWERTY] = LAYOUT( +KC_ESC, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_PSCR,KC_SLCK,KC_PAUS, \ +KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS,KC_EQL, KC_BSPC, KC_INS, KC_HOME,KC_PGUP, KC_NLCK,KC_PSLS,KC_PAST,KC_PMNS, \ +KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC,KC_RBRC,KC_BSLS, KC_DEL, KC_END, KC_PGDN, KC_P7, KC_P8, KC_P9, KC_PPLS, \ +KC_CLCK, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN,KC_QUOT, KC_ENT, KC_P4, KC_P5, KC_P6, \ +KC_LSFT, KC_NUBS,KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM,KC_DOT, KC_SLSH, KC_RSFT, KC_UP, KC_P1, KC_P2, KC_P3, KC_PENT, \ +KC_LCTL, KC_LGUI,KC_LALT, KC_SPC, KC_RALT,KC_RGUI,MO(KM_MEDIA),KC_RCTL, KC_LEFT,KC_DOWN,KC_RGHT, KC_P0, KC_PDOT), + /* Layer 1: Function layer */ + [KM_MEDIA] = LAYOUT( +_______, _______, _______, _______, _______, KC_MEDIA_PLAY_PAUSE, KC_MEDIA_STOP, KC_MEDIA_PREV_TRACK, KC_MEDIA_NEXT_TRACK, _______,KC_MUTE, KC_VOLD, KC_VOLU, _______,_______, RESET, \ +_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______, _______,_______,_______,_______, \ + _______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______, _______,_______,_______, _______, _______, _______, _______, \ + _______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______, _______, _______, _______, _______, \ + _______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______, _______, _______, _______, _______, _______, _______, \ + _______,_______,_______, _______, _______,_______,_______ ,_______, _______,_______,_______, _______, _______) +}; + diff --git a/keyboards/bpiphany/ghost_squid/keymaps/default/readme.md b/keyboards/bpiphany/ghost_squid/keymaps/default/readme.md new file mode 100644 index 000000000000..3c27324d1c57 --- /dev/null +++ b/keyboards/bpiphany/ghost_squid/keymaps/default/readme.md @@ -0,0 +1 @@ +# Default layout desc TODO diff --git a/keyboards/bpiphany/ghost_squid/keymaps/default/rules.mk b/keyboards/bpiphany/ghost_squid/keymaps/default/rules.mk new file mode 100644 index 000000000000..08d26a4c3c79 --- /dev/null +++ b/keyboards/bpiphany/ghost_squid/keymaps/default/rules.mk @@ -0,0 +1,17 @@ +# Build Options +# change to "no" to disable the options, or define them in the Makefile in +# the appropriate keymap folder that will get included automatically +# +BOOTMAGIC_ENABLE ?= yes # Virtual DIP switch configuration(+1000) +MOUSEKEY_ENABLE ?= yes # Mouse keys(+4700) +EXTRAKEY_ENABLE ?= yes # Audio control and System control(+450) +CONSOLE_ENABLE ?= yes # Console for debug(+400) +COMMAND_ENABLE ?= yes # Commands for debug and configuration +CUSTOM_MATRIX ?= yes # Custom matrix file for the Pegasus Hoof due to the 2x74HC42 +NKRO_ENABLE ?= no # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work +BACKLIGHT_ENABLE ?= no # Enable keyboard backlight functionality +MIDI_ENABLE ?= no # MIDI controls +AUDIO_ENABLE ?= no # Audio output on port C6 +UNICODE_ENABLE ?= no # Unicode +BLUETOOTH_ENABLE ?= no # Enable Bluetooth with the Adafruit EZ-Key HID +RGBLIGHT_ENABLE ?= no # Enable WS2812 RGB underlight. Do not enable this with audio at the same time. diff --git a/keyboards/bpiphany/ghost_squid/matrix.c b/keyboards/bpiphany/ghost_squid/matrix.c new file mode 100644 index 000000000000..c4a13a246fa0 --- /dev/null +++ b/keyboards/bpiphany/ghost_squid/matrix.c @@ -0,0 +1,167 @@ +/* + Copyright 2014 Ralf Schmitt + Copyright 2016 Daniel Svensson + + 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 +#include "wait.h" +#include "print.h" +#include "debug.h" +#include "util.h" +#include "matrix.h" + +static uint8_t debouncing = DEBOUNCE; +static matrix_row_t matrix[MATRIX_ROWS]; +static matrix_row_t matrix_debouncing[MATRIX_ROWS]; + +static matrix_row_t read_cols(void); +static void select_row(uint8_t col); + +inline uint8_t matrix_rows(void) +{ + return MATRIX_ROWS; +} + +inline uint8_t matrix_cols(void) +{ + return MATRIX_COLS; +} + +void matrix_init(void) +{ + /* Column output pins */ + DDRD |= 0b01111110; + /* Row input pins */ + DDRC &= ~0b00000100; + DDRB &= ~0b01111111; + PORTC |= 0b00000100; + PORTB |= 0b01111111; + + for (uint8_t i=0; i < MATRIX_ROWS; i++) { + matrix[i] = 0; + matrix_debouncing[i] = 0; + } + + matrix_init_quantum(); +} + +uint8_t matrix_scan(void) +{ + for (uint8_t col = 0; col < MATRIX_COLS; col++) { + select_row(col); + wait_us(30); + matrix_row_t rows = read_cols(); + for (uint8_t row = 0; row < MATRIX_ROWS; row++) { + bool prev_bit = matrix_debouncing[row] & ((matrix_row_t)1< Date: Tue, 28 Sep 2021 13:29:02 +0200 Subject: [PATCH 2/3] Apply most of the suggestions from code review --- keyboards/bpiphany/ghost_squid/config.h | 10 +-- keyboards/bpiphany/ghost_squid/ghost_squid.c | 66 +++--------------- keyboards/bpiphany/ghost_squid/ghost_squid.h | 14 +--- .../ghost_squid/keymaps/default/keymap.c | 35 +++++++--- .../ghost_squid/keymaps/default/rules.mk | 17 ----- keyboards/bpiphany/ghost_squid/rules.mk | 69 +++---------------- 6 files changed, 52 insertions(+), 159 deletions(-) delete mode 100644 keyboards/bpiphany/ghost_squid/keymaps/default/rules.mk diff --git a/keyboards/bpiphany/ghost_squid/config.h b/keyboards/bpiphany/ghost_squid/config.h index 3918ee98626b..bb8535b17769 100644 --- a/keyboards/bpiphany/ghost_squid/config.h +++ b/keyboards/bpiphany/ghost_squid/config.h @@ -33,10 +33,10 @@ along with this program. If not, see . /* COL2ROW or ROW2COL */ #define DIODE_DIRECTION COL2ROW +#define LED_PIN_ON_STATE 0 +#define LED_NUM_LOCK_PIN C5 +#define LED_CAPS_LOCK_PIN C6 +#define LED_SCROLL_LOCK_PIN B7 + /* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */ #define DEBOUNCE 5 - -/* key combination for magic key command */ -#define IS_COMMAND() ( \ - keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \ -) diff --git a/keyboards/bpiphany/ghost_squid/ghost_squid.c b/keyboards/bpiphany/ghost_squid/ghost_squid.c index 85d1665fe45b..05a36314c329 100644 --- a/keyboards/bpiphany/ghost_squid/ghost_squid.c +++ b/keyboards/bpiphany/ghost_squid/ghost_squid.c @@ -17,64 +17,14 @@ along with this program. If not, see . #include "ghost_squid.h" -__attribute__ ((weak)) -void matrix_init_user(void) { -}; +void matrix_init_kb(void) {} -__attribute__ ((weak)) -void matrix_scan_user(void) { -} - -__attribute__ ((weak)) -bool process_action_user(keyrecord_t *record) { - return true; -} - -/* __attribute__ ((weak)) */ -/* void led_set_user(uint8_t usb_led) { */ -/* } */ - -void matrix_init_kb(void) { - matrix_init_user(); -} - -void matrix_scan_kb(void) { - matrix_scan_user(); -} +void matrix_scan_kb(void) {} -bool process_action_kb(keyrecord_t *record) { - return process_action_user(record); +void keyboard_pre_init_kb(void) { + setPinOutput(D0); + writePinLow(D0); + fn_led_off(); + + keyboard_pre_init_user(); } - -void led_set_kb(uint8_t usb_led) { - led_set_user(usb_led); -} - -void led_set_user(uint8_t usb_led) { - if (usb_led & (1 << USB_LED_NUM_LOCK)) { - num_led_on(); - } else { - num_led_off(); - } - - if (usb_led & (1 << USB_LED_CAPS_LOCK)) { - caps_led_on(); - } else { - caps_led_off(); - } - - if (usb_led & (1 << USB_LED_SCROLL_LOCK)) { - scroll_led_on(); - } else { - scroll_led_off(); - } -} - -extern inline void num_led_on(void); -extern inline void num_led_off(void); -extern inline void caps_led_on(void); -extern inline void caps_led_off(void); -extern inline void scroll_led_on(void); -extern inline void scroll_led_off(void); -extern inline void fn_led_on(void); -extern inline void fn_led_off(void); diff --git a/keyboards/bpiphany/ghost_squid/ghost_squid.h b/keyboards/bpiphany/ghost_squid/ghost_squid.h index 8cf2c687eb04..839c9fc123f9 100644 --- a/keyboards/bpiphany/ghost_squid/ghost_squid.h +++ b/keyboards/bpiphany/ghost_squid/ghost_squid.h @@ -17,20 +17,10 @@ along with this program. If not, see . #pragma once -#include "matrix.h" #include "quantum.h" -inline void num_led_on(void) { DDRC |= (1<<5); PORTC &= ~(1<<5); } -inline void num_led_off(void) { DDRC &= ~(1<<5); PORTC &= ~(1<<5); } - -inline void caps_led_on(void) { DDRC |= (1<<6); PORTC &= ~(1<<6); } -inline void caps_led_off(void) { DDRC &= ~(1<<6); PORTC &= ~(1<<6); } - -inline void scroll_led_on(void) { DDRB |= (1<<7); PORTB &= ~(1<<7); } -inline void scroll_led_off(void) { DDRB &= ~(1<<7); PORTB &= ~(1<<7); } - -inline void fn_led_on(void) { DDRD |= (1<<0); PORTD &= ~(1<<0); } -inline void fn_led_off(void) { DDRD &= ~(1<<0); PORTD &= ~(1<<0); } +#define fn_led_on() writePinLow(D0) +#define fn_led_off() writePinHigh(D0) #define ___ KC_NO diff --git a/keyboards/bpiphany/ghost_squid/keymaps/default/keymap.c b/keyboards/bpiphany/ghost_squid/keymaps/default/keymap.c index 3760142276be..7d4d0831d7ac 100644 --- a/keyboards/bpiphany/ghost_squid/keymaps/default/keymap.c +++ b/keyboards/bpiphany/ghost_squid/keymaps/default/keymap.c @@ -24,18 +24,19 @@ along with this program. If not, see . * ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐ ┌───┬───┬───┐ ┌───┬───┬───┬───┐ * │ ` │ 1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │ 8 │ 9 │ 0 │ - │ = │ Backsp│ │INS│HOM│PgU│ │NUM│ / │ * │ - │ * ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤ ├───┼───┼───┤ ├───┼───┼───┼───┤ -* │ Tab │ Q │ W │ E │ R │ T │ Y │ U │ I │ O │ P │ [ │ ] │ENTER│ │DEL│END│PgD│ │ 7 │ 8 │ 9 │ │ -* ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┐ │ └───┴───┴───┘ ├───┼───┼───┤ + │ +* │ Tab │ Q │ W │ E │ R │ T │ Y │ U │ I │ O │ P │ [ │ ] │ │ │DEL│END│PgD│ │ 7 │ 8 │ 9 │ │ +* ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┐ ↲ │ └───┴───┴───┘ ├───┼───┼───┤ + │ * │ Caps │ A │ S │ D │ F │ G │ H │ J │ K │ L │ ; │ ' │ \ │ │ │ 7 │ 8 │ 9 │ │ * ├────┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴───┴────┤ ┌───┐ ├───┼───┼───┼───┤ -* │Shif│ # │ Z │ X │ C │ V │ B │ N │ M │ , │ . │ / │ Shift │ │HOM│ │ 1 │ 2 │ 3 │ E │ -* ├────┼───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴───┼───┴┬────┬────┤ ┌───┼───┼───┐ ├───┴───┼───┤ N │ -* │Ctrl│GUI │Alt │ │ Alt│ GUI│Fn │Ctrl│ │DEL│END│PgD│ │ 0 │ , │ T │ +* │Shif│ # │ Z │ X │ C │ V │ B │ N │ M │ , │ . │ / │ Shift │ │ ↑ │ │ 1 │ 2 │ 3 │ │ +* ├────┼───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴───┼───┴┬────┬────┤ ┌───┼───┼───┐ ├───┴───┼───┤ ↲ │ +* │Ctrl│GUI │Alt │ │ Alt│ GUI│Fn │Ctrl│ │ ← │ ↓ │ → │ │ 0 │ , │ │ * └────┴────┴────┴────────────────────────┴────┴────┴────┴────┘ └───┴───┴───┘ └───────┴───┴───┘ */ -#define KM_QWERTY 0 -#define KM_MEDIA 1 +#define KM_QWERTY 0 +#define KM_MEDIA 1 +#define KM_GUI_LOCK 2 const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { /* Layer 0: Standard ISO layer */ @@ -48,11 +49,27 @@ KC_LSFT, KC_NUBS,KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM KC_LCTL, KC_LGUI,KC_LALT, KC_SPC, KC_RALT,KC_RGUI,MO(KM_MEDIA),KC_RCTL, KC_LEFT,KC_DOWN,KC_RGHT, KC_P0, KC_PDOT), /* Layer 1: Function layer */ [KM_MEDIA] = LAYOUT( -_______, _______, _______, _______, _______, KC_MEDIA_PLAY_PAUSE, KC_MEDIA_STOP, KC_MEDIA_PREV_TRACK, KC_MEDIA_NEXT_TRACK, _______,KC_MUTE, KC_VOLD, KC_VOLU, _______,_______, RESET, \ +_______, _______, _______, _______, _______, KC_MEDIA_PLAY_PAUSE, KC_MEDIA_STOP, KC_MEDIA_PREV_TRACK, KC_MEDIA_NEXT_TRACK, TG(KM_GUI_LOCK),KC_MUTE, KC_VOLD, KC_VOLU, _______,_______, RESET, \ _______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______, _______,_______,_______,_______, \ _______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______, _______,_______,_______, _______, _______, _______, _______, \ _______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______, _______, _______, _______, _______, \ _______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______, _______, _______, _______, _______, _______, _______, \ - _______,_______,_______, _______, _______,_______,_______ ,_______, _______,_______,_______, _______, _______) + _______,_______,_______, _______, _______,_______,_______ ,_______, _______,_______,_______, _______, _______), + [KM_GUI_LOCK] = LAYOUT( +_______, _______, _______, _______, _______, _______, _______, _______, _______, _______,_______, _______, _______, _______,_______, _______, \ +_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______, _______,_______,_______,_______, \ + _______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______, _______,_______,_______, _______, _______, _______, _______, \ + _______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______, _______, _______, _______, _______, \ + _______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______, _______, _______, _______, _______, _______, _______, \ + _______,KC_NO,_______, _______, _______,KC_NO,_______ ,_______, _______,_______,_______, _______, _______) }; + +layer_state_t layer_state_set_user(layer_state_t state) { + if (IS_LAYER_ON_STATE(state, KM_GUI_LOCK)) { + fn_led_on(); + } else { + fn_led_off(); + } + return state; +} diff --git a/keyboards/bpiphany/ghost_squid/keymaps/default/rules.mk b/keyboards/bpiphany/ghost_squid/keymaps/default/rules.mk deleted file mode 100644 index 08d26a4c3c79..000000000000 --- a/keyboards/bpiphany/ghost_squid/keymaps/default/rules.mk +++ /dev/null @@ -1,17 +0,0 @@ -# Build Options -# change to "no" to disable the options, or define them in the Makefile in -# the appropriate keymap folder that will get included automatically -# -BOOTMAGIC_ENABLE ?= yes # Virtual DIP switch configuration(+1000) -MOUSEKEY_ENABLE ?= yes # Mouse keys(+4700) -EXTRAKEY_ENABLE ?= yes # Audio control and System control(+450) -CONSOLE_ENABLE ?= yes # Console for debug(+400) -COMMAND_ENABLE ?= yes # Commands for debug and configuration -CUSTOM_MATRIX ?= yes # Custom matrix file for the Pegasus Hoof due to the 2x74HC42 -NKRO_ENABLE ?= no # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work -BACKLIGHT_ENABLE ?= no # Enable keyboard backlight functionality -MIDI_ENABLE ?= no # MIDI controls -AUDIO_ENABLE ?= no # Audio output on port C6 -UNICODE_ENABLE ?= no # Unicode -BLUETOOTH_ENABLE ?= no # Enable Bluetooth with the Adafruit EZ-Key HID -RGBLIGHT_ENABLE ?= no # Enable WS2812 RGB underlight. Do not enable this with audio at the same time. diff --git a/keyboards/bpiphany/ghost_squid/rules.mk b/keyboards/bpiphany/ghost_squid/rules.mk index 9572442cc76e..699c1e70e216 100644 --- a/keyboards/bpiphany/ghost_squid/rules.mk +++ b/keyboards/bpiphany/ghost_squid/rules.mk @@ -1,66 +1,19 @@ # MCU name MCU = atmega32u2 -# Processor frequency. -# This will define a symbol, F_CPU, in all source code files equal to the -# processor frequency in Hz. You can then use this symbol in your source code to -# calculate timings. Do NOT tack on a 'UL' at the end, this will be done -# automatically to create a 32-bit value in your source code. -# -# This will be an integer division of F_USB below, as it is sourced by -# F_USB after it has run through any CPU prescalers. Note that this value -# does not *change* the processor frequency - it should merely be updated to -# reflect the processor speed set externally so that the code can use accurate -# software delays. -F_CPU = 16000000 - -# -# LUFA specific -# -# Target architecture (see library "Board Types" documentation). -ARCH = AVR8 - -# Input clock frequency. -# This will define a symbol, F_USB, in all source code files equal to the -# input clock frequency (before any prescaling is performed) in Hz. This value may -# differ from F_CPU if prescaling is used on the latter, and is required as the -# raw input clock is fed directly to the PLL sections of the AVR for high speed -# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL' -# at the end, this will be done automatically to create a 32-bit value in your -# source code. -# -# If no clock division is performed on the input clock inside the AVR (via the -# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU. -F_USB = $(F_CPU) - -# Interrupt driven control endpoint task(+60) -OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT - - -# Boot Section Size in *bytes* -# Teensy halfKay 512 -# Teensy++ halfKay 1024 -# Atmel DFU loader 4096 -# LUFA bootloader 4096 -# USBaspLoader 2048 -OPT_DEFS += -DBOOTLOADER_SIZE=4096 - +BOOTLOADER = atmel-dfu # Build Options # change yes to no to disable # -BOOTMAGIC_ENABLE ?= yes # Virtual DIP switch configuration(+1000) -MOUSEKEY_ENABLE ?= yes # Mouse keys(+4700) -EXTRAKEY_ENABLE ?= yes # Audio control and System control(+450) -CONSOLE_ENABLE ?= yes # Console for debug(+400) -COMMAND_ENABLE ?= yes # Commands for debug and configuration -NKRO_ENABLE ?= no # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work -BACKLIGHT_ENABLE ?= no # Enable keyboard backlight functionality -AUDIO_ENABLE ?= no # Audio output on port C6 -UNICODE_ENABLE ?= no # Unicode -BLUETOOTH_ENABLE ?= no # Enable Bluetooth with the Adafruit EZ-Key HID -RGBLIGHT_ENABLE ?= no # Enable WS2812 RGB underlight. Do not enable this with audio at the same time. - - -CUSTOM_MATRIX ?= yes +BOOTMAGIC_ENABLE = yes # Enable Bootmagic Lite +MOUSEKEY_ENABLE = yes # Mouse keys +EXTRAKEY_ENABLE = yes # Audio control and System control +CONSOLE_ENABLE = no # Console for debug +COMMAND_ENABLE = no # Commands for debug and configuration +NKRO_ENABLE = no # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work +BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality +AUDIO_ENABLE = no # Audio output +RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight. Do not enable this with audio at the same time. +CUSTOM_MATRIX = yes SRC += matrix.c From ccb6c23dd448d4a4f1adb44f584c89097530acd5 Mon Sep 17 00:00:00 2001 From: fenuks Date: Tue, 28 Sep 2021 19:11:26 +0200 Subject: [PATCH 3/3] Apply suggestions from @fauxpark --- keyboards/bpiphany/ghost_squid/ghost_squid.c | 4 - .../ghost_squid/keymaps/default/config.h | 3 - .../ghost_squid/keymaps/default/keymap.c | 42 ++-- keyboards/bpiphany/ghost_squid/matrix.c | 202 ++++++------------ keyboards/bpiphany/ghost_squid/readme.md | 31 ++- keyboards/bpiphany/ghost_squid/rules.mk | 10 +- 6 files changed, 107 insertions(+), 185 deletions(-) delete mode 100644 keyboards/bpiphany/ghost_squid/keymaps/default/config.h diff --git a/keyboards/bpiphany/ghost_squid/ghost_squid.c b/keyboards/bpiphany/ghost_squid/ghost_squid.c index 05a36314c329..3ecac66f7a7c 100644 --- a/keyboards/bpiphany/ghost_squid/ghost_squid.c +++ b/keyboards/bpiphany/ghost_squid/ghost_squid.c @@ -17,10 +17,6 @@ along with this program. If not, see . #include "ghost_squid.h" -void matrix_init_kb(void) {} - -void matrix_scan_kb(void) {} - void keyboard_pre_init_kb(void) { setPinOutput(D0); writePinLow(D0); diff --git a/keyboards/bpiphany/ghost_squid/keymaps/default/config.h b/keyboards/bpiphany/ghost_squid/keymaps/default/config.h deleted file mode 100644 index 271f48d0011b..000000000000 --- a/keyboards/bpiphany/ghost_squid/keymaps/default/config.h +++ /dev/null @@ -1,3 +0,0 @@ -#pragma once - -// place overrides here diff --git a/keyboards/bpiphany/ghost_squid/keymaps/default/keymap.c b/keyboards/bpiphany/ghost_squid/keymaps/default/keymap.c index 7d4d0831d7ac..09523ebbb91b 100644 --- a/keyboards/bpiphany/ghost_squid/keymaps/default/keymap.c +++ b/keyboards/bpiphany/ghost_squid/keymaps/default/keymap.c @@ -34,34 +34,36 @@ along with this program. If not, see . * └────┴────┴────┴────────────────────────┴────┴────┴────┴────┘ └───┴───┴───┘ └───────┴───┴───┘ */ -#define KM_QWERTY 0 -#define KM_MEDIA 1 -#define KM_GUI_LOCK 2 +enum layer_names { + KM_QWERTY, + KM_MEDIA, + KM_GUI_LOCK +}; const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { /* Layer 0: Standard ISO layer */ [KM_QWERTY] = LAYOUT( -KC_ESC, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_PSCR,KC_SLCK,KC_PAUS, \ -KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS,KC_EQL, KC_BSPC, KC_INS, KC_HOME,KC_PGUP, KC_NLCK,KC_PSLS,KC_PAST,KC_PMNS, \ -KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC,KC_RBRC,KC_BSLS, KC_DEL, KC_END, KC_PGDN, KC_P7, KC_P8, KC_P9, KC_PPLS, \ -KC_CLCK, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN,KC_QUOT, KC_ENT, KC_P4, KC_P5, KC_P6, \ -KC_LSFT, KC_NUBS,KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM,KC_DOT, KC_SLSH, KC_RSFT, KC_UP, KC_P1, KC_P2, KC_P3, KC_PENT, \ +KC_ESC, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_PSCR,KC_SLCK,KC_PAUS, +KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS,KC_EQL, KC_BSPC, KC_INS, KC_HOME,KC_PGUP, KC_NLCK,KC_PSLS,KC_PAST,KC_PMNS, +KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC,KC_RBRC,KC_BSLS, KC_DEL, KC_END, KC_PGDN, KC_P7, KC_P8, KC_P9, KC_PPLS, +KC_CLCK, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN,KC_QUOT, KC_ENT, KC_P4, KC_P5, KC_P6, +KC_LSFT, KC_NUBS,KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM,KC_DOT, KC_SLSH, KC_RSFT, KC_UP, KC_P1, KC_P2, KC_P3, KC_PENT, KC_LCTL, KC_LGUI,KC_LALT, KC_SPC, KC_RALT,KC_RGUI,MO(KM_MEDIA),KC_RCTL, KC_LEFT,KC_DOWN,KC_RGHT, KC_P0, KC_PDOT), /* Layer 1: Function layer */ [KM_MEDIA] = LAYOUT( -_______, _______, _______, _______, _______, KC_MEDIA_PLAY_PAUSE, KC_MEDIA_STOP, KC_MEDIA_PREV_TRACK, KC_MEDIA_NEXT_TRACK, TG(KM_GUI_LOCK),KC_MUTE, KC_VOLD, KC_VOLU, _______,_______, RESET, \ -_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______, _______,_______,_______,_______, \ - _______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______, _______,_______,_______, _______, _______, _______, _______, \ - _______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______, _______, _______, _______, _______, \ - _______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______, _______, _______, _______, _______, _______, _______, \ - _______,_______,_______, _______, _______,_______,_______ ,_______, _______,_______,_______, _______, _______), +_______,_______,_______,_______,_______, KC_MEDIA_PLAY_PAUSE, KC_MEDIA_STOP, KC_MEDIA_PREV_TRACK, KC_MEDIA_NEXT_TRACK, TG(KM_GUI_LOCK),KC_MUTE, KC_VOLD, KC_VOLU,_______,_______, RESET, +_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______, +_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______, +_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______, +_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______, _______,_______, +_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______), [KM_GUI_LOCK] = LAYOUT( -_______, _______, _______, _______, _______, _______, _______, _______, _______, _______,_______, _______, _______, _______,_______, _______, \ -_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______, _______,_______,_______,_______, \ - _______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______, _______,_______,_______, _______, _______, _______, _______, \ - _______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______, _______, _______, _______, _______, \ - _______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______, _______, _______, _______, _______, _______, _______, \ - _______,KC_NO,_______, _______, _______,KC_NO,_______ ,_______, _______,_______,_______, _______, _______) +_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______, _______, +_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______, +_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______, +_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______, +_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______, +_______,KC_NO,_______,_______,_______,KC_NO,_______,_______,_______,_______,_______,_______,_______) }; diff --git a/keyboards/bpiphany/ghost_squid/matrix.c b/keyboards/bpiphany/ghost_squid/matrix.c index c4a13a246fa0..b0ad6075554a 100644 --- a/keyboards/bpiphany/ghost_squid/matrix.c +++ b/keyboards/bpiphany/ghost_squid/matrix.c @@ -16,152 +16,82 @@ along with this program. If not, see . */ -#include -#include -#include -#include "wait.h" -#include "print.h" -#include "debug.h" -#include "util.h" #include "matrix.h" - -static uint8_t debouncing = DEBOUNCE; -static matrix_row_t matrix[MATRIX_ROWS]; -static matrix_row_t matrix_debouncing[MATRIX_ROWS]; - -static matrix_row_t read_cols(void); -static void select_row(uint8_t col); - -inline uint8_t matrix_rows(void) -{ - return MATRIX_ROWS; -} - -inline uint8_t matrix_cols(void) -{ - return MATRIX_COLS; +#include "quantum.h" + +matrix_row_t read_rows(void) { + return + (PINB & (1 << 1) ? 0 : ((matrix_row_t)1 << 0)) | + (PINC & (1 << 2) ? 0 : ((matrix_row_t)1 << 1)) | + (PINB & (1 << 6) ? 0 : ((matrix_row_t)1 << 2)) | + (PINB & (1 << 4) ? 0 : ((matrix_row_t)1 << 3)) | + (PINB & (1 << 3) ? 0 : ((matrix_row_t)1 << 4)) | + (PINB & (1 << 2) ? 0 : ((matrix_row_t)1 << 5)) | + (PINB & (1 << 0) ? 0 : ((matrix_row_t)1 << 6)) | + (PINB & (1 << 5) ? 0 : ((matrix_row_t)1 << 7)); } -void matrix_init(void) -{ - /* Column output pins */ - DDRD |= 0b01111110; - /* Row input pins */ - DDRC &= ~0b00000100; - DDRB &= ~0b01111111; - PORTC |= 0b00000100; - PORTB |= 0b01111111; - - for (uint8_t i=0; i < MATRIX_ROWS; i++) { - matrix[i] = 0; - matrix_debouncing[i] = 0; - } - - matrix_init_quantum(); -} - -uint8_t matrix_scan(void) -{ - for (uint8_t col = 0; col < MATRIX_COLS; col++) { - select_row(col); - wait_us(30); - matrix_row_t rows = read_cols(); - for (uint8_t row = 0; row < MATRIX_ROWS; row++) { - bool prev_bit = matrix_debouncing[row] & ((matrix_row_t)1<