[Keyboard] Add keyboard GRS-70EC (#11296)

This commit is contained in:
sekigon-gonnoc 2021-07-21 02:24:22 +09:00 committed by GitHub
parent 8f6867ce95
commit c6698cfce3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 716 additions and 0 deletions

View File

@ -0,0 +1,154 @@
/*
Copyright 2020 sekigon-gonnoc
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 <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "config_common.h"
/* USB Device descriptor parameter */
#define VENDOR_ID 0xFEED
#define PRODUCT_ID 0x70EC
#define DEVICE_VER 0x0001
#define MANUFACTURER sekigon-gonnoc
#define PRODUCT GRS-70EC
/* key matrix size */
#define MATRIX_ROWS 10
#define MATRIX_COLS 8
/* EC switch threshold with hysteresis */
#define HIGH_THRESHOLD 300
#define LOW_THRESHOLD 200
/*
* Keyboard Matrix Assignments
*
* Change this to how you wired your keyboard
* COLS: AVR pins used for columns, left to right
* ROWS: AVR pins used for rows, top to bottom
* DIODE_DIRECTION: COL2ROW = COL = Anode (+), ROW = Cathode (-, marked on diode)
* ROW2COL = ROW = Anode (+), COL = Cathode (-, marked on diode)
*
*/
#define MATRIX_ROW_PINS { C6, D7, E6, B4, B5 }
#define MATRIX_COL_PINS { S2, S1, S0, S3, S5, S7, S6, S4 }
#define UNUSED_PINS
#define DISCHARGE_PIN B1
#define ANALOG_PORT F6
#define MUX_SEL_PINS { D1, D0, D4 }
/* COL2ROW, ROW2COL */
#define DIODE_DIRECTION COL2ROW
/*
* Split Keyboard specific options, make sure you have 'SPLIT_KEYBOARD = yes' in your rules.mk, and define SOFT_SERIAL_PIN.
*/
#define SOFT_SERIAL_PIN D3 // or D1, D2, D3, E6
#define EE_HANDS
//#define BACKLIGHT_PIN B7
//#define BACKLIGHT_LEVELS 3
//#define BACKLIGHT_BREATHING
//#define RGB_DI_PIN E2
//#ifdef RGB_DI_PIN
//# define RGBLED_NUM 16
//# define RGBLIGHT_HUE_STEP 8
//# define RGBLIGHT_SAT_STEP 8
//# define RGBLIGHT_VAL_STEP 8
//# define RGBLIGHT_LIMIT_VAL 255 /* The maximum brightness level */
//# define RGBLIGHT_SLEEP /* If defined, the RGB lighting will be switched off when the host goes to sleep */
/*== all animations enable ==*/
//# define RGBLIGHT_ANIMATIONS
/*== or choose animations ==*/
//# define RGBLIGHT_EFFECT_BREATHING
//# define RGBLIGHT_EFFECT_RAINBOW_MOOD
//# define RGBLIGHT_EFFECT_RAINBOW_SWIRL
//# define RGBLIGHT_EFFECT_SNAKE
//# define RGBLIGHT_EFFECT_KNIGHT
//# define RGBLIGHT_EFFECT_CHRISTMAS
//# define RGBLIGHT_EFFECT_STATIC_GRADIENT
//# define RGBLIGHT_EFFECT_RGB_TEST
//# define RGBLIGHT_EFFECT_ALTERNATING
/*== customize breathing effect ==*/
/*==== (DEFAULT) use fixed table instead of exp() and sin() ====*/
//# define RGBLIGHT_BREATHE_TABLE_SIZE 256 // 256(default) or 128 or 64
/*==== use exp() and sin() ====*/
//# define RGBLIGHT_EFFECT_BREATHE_CENTER 1.85 // 1 to 2.7
//# define RGBLIGHT_EFFECT_BREATHE_MAX 255 // 0 to 255
//#endif
/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */
#define DEBOUNCE 5
/* define if matrix has ghost (lacks anti-ghosting diodes) */
//#define MATRIX_HAS_GHOST
/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */
#define LOCKING_SUPPORT_ENABLE
/* Locking resynchronize hack */
#define LOCKING_RESYNC_ENABLE
/* If defined, GRAVE_ESC will always act as ESC when CTRL is held.
* This is useful for the Windows task manager shortcut (ctrl+shift+esc).
*/
//#define GRAVE_ESC_CTRL_OVERRIDE
/*
* Force NKRO
*
* Force NKRO (nKey Rollover) to be enabled by default, regardless of the saved
* state in the bootmagic EEPROM settings. (Note that NKRO must be enabled in the
* makefile for this to work.)
*
* If forced on, NKRO can be disabled via magic key (default = LShift+RShift+N)
* until the next keyboard reset.
*
* NKRO may prevent your keystrokes from being detected in the BIOS, but it is
* fully operational during normal computer usage.
*
* For a less heavy-handed approach, enable NKRO via magic key (LShift+RShift+N)
* or via bootmagic (hold SPACE+N while plugging in the keyboard). Once set by
* bootmagic, NKRO mode will always be enabled until it is toggled again during a
* power-up.
*
*/
//#define FORCE_NKRO
/*
* Feature disable options
* These options are also useful to firmware size reduction.
*/
/* disable debug print */
//#define NO_DEBUG
/* disable print */
//#define NO_PRINT
/* disable action features */
//#define NO_ACTION_LAYER
//#define NO_ACTION_TAPPING
//#define NO_ACTION_ONESHOT
/* disable these deprecated features by default */
#define NO_ACTION_MACRO
#define NO_ACTION_FUNCTION
/* Bootmagic Lite key configuration */
//#define BOOTMAGIC_LITE_ROW 0
//#define BOOTMAGIC_LITE_COLUMN 0

View File

@ -0,0 +1,161 @@
/* Copyright 2020 sekigon-gonnoc
*
* 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 <http://www.gnu.org/licenses/>.
*/
#include "ec_switch_matrix.h"
#include "quantum.h"
#include "analog.h"
#include "print.h"
// sensing channel definitions
#define S0 0
#define S1 1
#define S2 2
#define S3 3
#define S4 4
#define S5 5
#define S6 6
#define S7 7
// pin connections
const uint8_t row_pins[] = MATRIX_ROW_PINS;
const uint8_t col_channels[] = MATRIX_COL_PINS;
const uint8_t mux_sel_pins[] = MUX_SEL_PINS;
_Static_assert(sizeof(mux_sel_pins) == 3, "invalid MUX_SEL_PINS");
static ecsm_config_t config;
static uint16_t ecsm_sw_value[MATRIX_ROWS][MATRIX_COLS];
static inline void discharge_capacitor(void) { setPinOutput(DISCHARGE_PIN); }
static inline void charge_capacitor(uint8_t row) {
setPinInput(DISCHARGE_PIN);
writePinHigh(row_pins[row]);
}
static inline void clear_all_row_pins(void) {
for (int row = 0; row < sizeof(row_pins); row++) {
writePinLow(row_pins[row]);
}
}
static inline void init_mux_sel(void) {
for (int idx = 0; idx < sizeof(mux_sel_pins); idx++) {
setPinOutput(mux_sel_pins[idx]);
}
}
static inline void select_mux(uint8_t col) {
uint8_t ch = col_channels[col];
writePin(mux_sel_pins[0], ch & 1);
writePin(mux_sel_pins[1], ch & 2);
writePin(mux_sel_pins[2], ch & 4);
}
static inline void init_row(void) {
for (int idx = 0; idx < sizeof(row_pins); idx++) {
setPinOutput(row_pins[idx]);
writePinLow(row_pins[idx]);
}
}
// Initialize pins
int ecsm_init(ecsm_config_t const* const ecsm_config) {
// save config
config = *ecsm_config;
// initialize discharge pin as discharge mode
writePinLow(DISCHARGE_PIN);
setPinOutput(DISCHARGE_PIN);
// set analog reference
analogReference(ADC_REF_POWER);
// initialize drive lines
init_row();
// initialize multiplexer select pin
init_mux_sel();
// set discharge pin to charge mode
setPinInput(DISCHARGE_PIN);
return 0;
}
// Read key value of key (row, col)
uint16_t ecsm_readkey_raw(uint8_t row, uint8_t col) {
uint16_t sw_value = 0;
discharge_capacitor();
select_mux(col);
clear_all_row_pins();
cli();
charge_capacitor(row);
sw_value = analogReadPin(ANALOG_PORT);
sei();
return sw_value;
}
// Update press/release state of key at (row, col)
bool ecsm_update_key(matrix_row_t* current_row, uint8_t col, uint16_t sw_value) {
bool current_state = (*current_row >> col) & 1;
// press to release
if (current_state && sw_value < config.low_threshold) {
*current_row &= ~(1 << col);
return true;
}
// release to press
if ((!current_state) && sw_value > config.high_threshold) {
*current_row |= (1 << col);
return true;
}
return false;
}
// Scan key values and update matrix state
bool ecsm_matrix_scan(matrix_row_t current_matrix[]) {
bool updated = false;
for (int col = 0; col < sizeof(col_channels); col++) {
for (int row = 0; row < sizeof(row_pins); row++) {
ecsm_sw_value[row][col] = ecsm_readkey_raw(row, col);
updated |= ecsm_update_key(&current_matrix[row], col, ecsm_sw_value[row][col]);
}
}
return updated;
}
// Print key values
void ecsm_print_matrix(void) {
for (int row = 0; row < sizeof(row_pins); row++) {
for (int col = 0; col < sizeof(col_channels); col++) {
xprintf("%4d", ecsm_sw_value[row][col]);
}
xprintf("\n");
}
}

View File

@ -0,0 +1,38 @@
/* Copyright 2020 sekigon-gonnoc
*
* 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 <http://www.gnu.org/licenses/>.
*/
//
// Scan EC switch matrix using 74HC7051
// Define MUX_SEL_PINS, DISCHARGE_PIN, and ANALOG_PORT to compile
//
#pragma once
#include <stdint.h>
#include <stdbool.h>
#include "matrix.h"
typedef struct {
uint16_t low_threshold; // threshold for key release
uint16_t high_threshold; // threshold for key press
} ecsm_config_t;
int ecsm_init(ecsm_config_t const* const ecsm_config);
bool ecsm_matrix_scan(matrix_row_t current_matrix[]);
void ecsm_print_matrix(void);
uint16_t ecsm_readkey_raw(uint8_t row, uint8_t col);
bool ecsm_update_key(matrix_row_t* current_row, uint8_t col, uint16_t sw_value);

View File

@ -0,0 +1,38 @@
/* Copyright 2020 sekigon-gonnoc
*
* 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 <http://www.gnu.org/licenses/>.
*/
#include "grs_70ec.h"
void led_on(void) {
setPinOutput(D2);
writePinHigh(D2);
}
void led_off(void) { writePinLow(D2); }
void keyboard_post_init_kb() {
led_on();
keyboard_post_init_user();
}
void keyboard_pre_init_kb(void) {
// Turn on extern circuit
setPinOutput(F7);
writePinHigh(F7);
keyboard_pre_init_user();
}

View File

@ -0,0 +1,49 @@
/* Copyright 2020 sekigon-gonnoc
*
* 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 <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "quantum.h"
void led_on(void);
void led_off(void);
/* This is a shortcut to help you visually see your layout.
*
* The first section contains all of the arguments representing the physical
* layout of the board and position of the keys.
*
* The second converts the arguments into a two-dimensional array which
* represents the switch matrix.
*/
#define LAYOUT( \
L00, L01, L02, L03, L04, L05, L06, R00, R01, R02, R03, R04, R05, R06, R07, \
L11, L12, L13, L14, L15, L16, R10, R11, R12, R13, R14, R15, R16, R17, \
L21, L22, L23, L24, L25, L26, R20, R21, R22, R23, R24, R25, R26, R27, \
L30, L31, L32, L33, L34, L35, L36, R30, R31, R32, R33, R34, R35, R36, R37, \
L40, L42, L43, L45, L46, R40, R41, R42, R43, R45, R46, R47 \
) { \
{ L00, L01, L02, L03, L04, L05, L06, KC_NO }, \
{ KC_NO, L11, L12, L13, L14, L15, L16, KC_NO }, \
{ KC_NO, L21, L22, L23, L24, L25, L26, KC_NO }, \
{ L30, L31, L32, L33, L34, L35, L36, KC_NO }, \
{ L40, KC_NO, L42, L43, KC_NO, L45, L46, KC_NO }, \
{ R00, R01, R02, R03, R04, R05, R06, R07 }, \
{ R10, R11, R12, R13, R14, R15, R16, R17 }, \
{ R20, R21, R22, R23, R24, R25, R26, R27 }, \
{ R30, R31, R32, R33, R34, R35, R36, R37 }, \
{ R40, R41, R42, R43, KC_NO, R45, R46, R47 } \
}

View File

@ -0,0 +1,83 @@
{
"keyboard_name": "grs_70ec",
"url": "https://github.com/sekigon-gonnoc/GRS-70EC-doc/",
"maintainer": "sekigon-gonnoc",
"width": 15.75,
"height": 5,
"layouts": {
"LAYOUT": {
"layout": [
{ "label": "k00", "x": 0, "y": 0 },
{ "label": "k01", "x": 1, "y": 0 },
{ "label": "k02", "x": 2, "y": 0 },
{ "label": "k03", "x": 3, "y": 0 },
{ "label": "k04", "x": 4, "y": 0 },
{ "label": "k05", "x": 5, "y": 0 },
{ "label": "k06", "x": 6, "y": 0 },
{ "label": "k50", "x": 7.75, "y": 0 },
{ "label": "k51", "x": 8.75, "y": 0 },
{ "label": "k52", "x": 9.75, "y": 0 },
{ "label": "k53", "x": 10.75, "y": 0 },
{ "label": "k54", "x": 11.75, "y": 0 },
{ "label": "k55", "x": 12.75, "y": 0 },
{ "label": "k56", "x": 13.75, "y": 0 },
{ "label": "k57", "x": 14.75, "y": 0 },
{ "label": "k11", "x": 0, "y": 1, "w": 1.5 },
{ "label": "k12", "x": 1.5, "y": 1 },
{ "label": "k13", "x": 2.5, "y": 1 },
{ "label": "k14", "x": 3.5, "y": 1 },
{ "label": "k15", "x": 4.5, "y": 1 },
{ "label": "k16", "x": 5.5, "y": 1 },
{ "label": "k60", "x": 7.25, "y": 1 },
{ "label": "k61", "x": 8.25, "y": 1 },
{ "label": "k62", "x": 9.25, "y": 1 },
{ "label": "k63", "x": 10.25, "y": 1 },
{ "label": "k64", "x": 11.25, "y": 1 },
{ "label": "k65", "x": 12.25, "y": 1 },
{ "label": "k66", "x": 13.25, "y": 1 },
{ "label": "k67", "x": 14.25, "y": 1, "w": 1.5 },
{ "label": "k21", "x": 0, "y": 2, "w": 1.75 },
{ "label": "k22", "x": 1.75, "y": 2 },
{ "label": "k23", "x": 2.75, "y": 2 },
{ "label": "k24", "x": 3.75, "y": 2 },
{ "label": "k25", "x": 4.75, "y": 2 },
{ "label": "k26", "x": 5.75, "y": 2 },
{ "label": "k70", "x": 7.5, "y": 2 },
{ "label": "k71", "x": 8.5, "y": 2 },
{ "label": "k72", "x": 9.5, "y": 2 },
{ "label": "k73", "x": 10.5, "y": 2 },
{ "label": "k74", "x": 11.5, "y": 2 },
{ "label": "k75", "x": 12.5, "y": 2 },
{ "label": "k76", "x": 13.5, "y": 2 },
{ "label": "k77", "x": 14.5, "y": 2 },
{ "label": "k30", "x": 0, "y": 3 },
{ "label": "k31", "x": 1, "y": 3 },
{ "label": "k32", "x": 2, "y": 3 },
{ "label": "k33", "x": 3, "y": 3 },
{ "label": "k34", "x": 4, "y": 3 },
{ "label": "k35", "x": 5, "y": 3 },
{ "label": "k36", "x": 6, "y": 3 },
{ "label": "k80", "x": 7.75, "y": 3 },
{ "label": "k81", "x": 8.75, "y": 3 },
{ "label": "k82", "x": 9.75, "y": 3 },
{ "label": "k83", "x": 10.75, "y": 3 },
{ "label": "k84", "x": 11.75, "y": 3 },
{ "label": "k85", "x": 12.75, "y": 3 },
{ "label": "k86", "x": 13.75, "y": 3 },
{ "label": "k87", "x": 14.75, "y": 3 },
{ "label": "k40", "x": 0, "y": 4, "w": 1.25 },
{ "label": "k42", "x": 2, "y": 4 },
{ "label": "k43", "x": 3, "y": 4, "w": 1.25 },
{ "label": "k45", "x": 4.25, "y": 4, "w": 1.25 },
{ "label": "k46", "x": 5.5, "y": 4, "w": 1.25 },
{ "label": "k90", "x": 7.5, "y": 4, "w": 1.25 },
{ "label": "k91", "x": 8.75, "y": 4, "w": 1.25 },
{ "label": "k92", "x": 10, "y": 4, "w": 1.25 },
{ "label": "k93", "x": 11.25, "y": 4 },
{ "label": "k95", "x": 12.75, "y": 4 },
{ "label": "k96", "x": 13.75, "y": 4 },
{ "label": "k97", "x": 14.75, "y": 4 }
]
}
}
}

View File

@ -0,0 +1,41 @@
/* Copyright 2020 sekigon-gonnoc
*
* 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 <http://www.gnu.org/licenses/>.
*/
#include QMK_KEYBOARD_H
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[0] = LAYOUT(
KC_ESC, 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_BSPC,
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_LCTL, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, LALT(KC_GRV),
KC_LSFT, KC_LSFT, 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_RSFT,
KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, LT(1,KC_SPC), LT(2,KC_ENT), KC_ENT, KC_RGUI, KC_RALT, KC_LEFT, KC_DOWN, KC_RGHT
),
[1] = LAYOUT(
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_DEL, KC_DEL,
KC_TAB, S(KC_1), S(KC_2), S(KC_3), S(KC_4), S(KC_5), S(KC_6), S(KC_7), S(KC_8), S(KC_9),S(KC_0), KC_LBRC, KC_RBRC, KC_PIPE,
KC_LCTL, KC_1, KC_2, KC_3, KC_4, KC_5, KC_LCBR, KC_MINS, KC_EQL, KC_RCBR,KC_COLN, KC_DQT, KC_ENT, KC_ENT,
KC_LSFT, KC_LSFT, KC_6, KC_7, KC_8, KC_9, KC_0, KC_UNDS, KC_PLUS, KC_LBRC, KC_RBRC,KC_BSLS, KC_RSFT, KC_UP, KC_NO,
KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_TRNS, KC_ENT, KC_ENT, KC_RGUI, KC_RALT, KC_LEFT, KC_DOWN, KC_RGHT
),
[2] = LAYOUT(
KC_TILD, 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_INS, KC_INS,
KC_TAB, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_HOME, KC_PGDN, KC_PGUP, KC_END, KC_P, KC_LBRC, KC_RBRC, KC_BSLS,
KC_LCTL, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT,KC_SCLN, KC_QUOT, KC_ENT, LALT(KC_GRV),
KC_LSFT, KC_LSFT, KC_F11, KC_F12, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_UP, KC_RSFT,
KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_SPC, KC_TRNS, KC_ENT, KC_RGUI, KC_RALT, KC_LEFT, KC_DOWN, KC_RGHT
)
};

View File

@ -0,0 +1,107 @@
/* Copyright 2020 sekigon-gonnoc
*
* 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 <http://www.gnu.org/licenses/>.
*/
#include "grs_70ec.h"
#include "ec_switch_matrix.h"
#include "matrix.h"
#include "debug.h"
#include "split_util.h"
#include "transport.h"
#include "debounce.h"
#ifndef LOW_THRESHOLD
# define LOW_THRESHOLD 200
#endif
#ifndef HIGH_THRESHOLD
# define HIGH_THRESHOLD 300
#endif
#define ERROR_DISCONNECT_COUNT 20
#define ROWS_PER_HAND (MATRIX_ROWS / 2)
/* matrix state(1:on, 0:off) */
extern matrix_row_t raw_matrix[MATRIX_ROWS]; // raw values
extern matrix_row_t matrix[MATRIX_ROWS]; // debounced values
// row offsets for each hand
uint8_t thisHand, thatHand;
// user-defined overridable functions
__attribute__((weak)) void matrix_slave_scan_user(void) {}
void matrix_init_custom(void) {
split_pre_init();
ecsm_config_t ecsm_config = {.low_threshold = LOW_THRESHOLD, .high_threshold = HIGH_THRESHOLD};
ecsm_init(&ecsm_config);
thisHand = isLeftHand ? 0 : (ROWS_PER_HAND);
thatHand = ROWS_PER_HAND - thisHand;
split_post_init();
}
bool matrix_scan_custom(matrix_row_t current_matrix[]) {
bool updated = ecsm_matrix_scan(current_matrix);
static int cnt = 0;
if (cnt++ == 300) {
cnt = 0;
ecsm_print_matrix();
print("\n");
}
return updated;
}
void matrix_post_scan(void) {
if (is_keyboard_master()) {
static uint8_t error_count;
if (!transport_master(matrix + thatHand)) {
error_count++;
if (error_count > ERROR_DISCONNECT_COUNT) {
// reset other half if disconnected
dprintf("Error: disconnect split half\n");
for (int i = 0; i < ROWS_PER_HAND; ++i) {
matrix[thatHand + i] = 0;
}
}
} else {
error_count = 0;
}
matrix_scan_quantum();
} else {
transport_slave(matrix + thisHand);
matrix_slave_scan_user();
}
}
uint8_t matrix_scan(void) {
bool changed = matrix_scan_custom(raw_matrix);
debounce(raw_matrix, matrix + thisHand, ROWS_PER_HAND, changed);
matrix_post_scan();
return changed;
}

View File

@ -0,0 +1,19 @@
# GRS-70EC
![grs_70ec](https://raw.githubusercontent.com/sekigon-gonnoc/GRS-70EC-doc/master/img/GRS-70EC.JPG)
A split keyboard using electrostatic capacitive switch
* Keyboard Maintainer: [sekigon](https://github.com/sekigon-gonnoc)
* Hardware Supported: GRS-70EC PCB, Pro Micro
* Hardware Availability: [BOOTH Shop](https://nogikes.booth.pm/items/2626903)
Make example for this keyboard (after setting up your build environment):
make sekigon/grs_70ec:default
Flashing example for this keyboard:
make sekigon/grs_70ec:default:flash
See the [build environment setup](https://docs.qmk.fm/#/getting_started_build_tools) and the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) for more information. Brand new to QMK? Start with our [Complete Newbs Guide](https://docs.qmk.fm/#/newbs).

View File

@ -0,0 +1,26 @@
# MCU name
MCU = atmega32u4
# Bootloader selection
BOOTLOADER = caterina
# Build Options
# change yes to no to disable
#
BOOTMAGIC_ENABLE = lite # Virtual DIP switch configuration
MOUSEKEY_ENABLE = yes # Mouse keys
EXTRAKEY_ENABLE = yes # Audio control and System control
CONSOLE_ENABLE = yes # Console for debug
COMMAND_ENABLE = no # Commands for debug and configuration
# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
# if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
NKRO_ENABLE = no # USB Nkey Rollover
BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
RGBLIGHT_ENABLE = no # Enable keyboard RGB underglow
BLUETOOTH_ENABLE = no # Enable Bluetooth
AUDIO_ENABLE = no # Audio output
CUSTOM_MATRIX = lite
SPLIT_KEYBOARD = yes
SRC += analog.c ec_switch_matrix.c matrix.c