* Initial sp111 support * Align with templatepull/10461/head
@ -0,0 +1,83 @@ | |||
/* Copyright 2020 blindassassin111 | |||
* | |||
* 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 0x544B //TK | |||
#define PRODUCT_ID 0x5111 | |||
#define DEVICE_VER 0x0001 | |||
#define MANUFACTURER The Key Company | |||
#define PRODUCT SP111 | |||
/* key matrix size */ | |||
#define MATRIX_ROWS 6*2 | |||
#define MATRIX_COLS 11 | |||
/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */ | |||
#define DEBOUNCE 5 | |||
/* 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 |
@ -0,0 +1,19 @@ | |||
{ | |||
"keyboard_name": "SP-111", | |||
"url": "https://thekey.company/products/sp-111", | |||
"maintainer": "blindassassin111", | |||
"width": 22.5, | |||
"height": 6.75, | |||
"layouts": { | |||
"LAYOUT_all": { | |||
"layout": [ | |||
{"label":"F13", "x":0, "y":0}, {"label":"F14", "x":1, "y":0}, {"label":"F15", "x":2, "y":0}, {"label":"F16", "x":3, "y":0}, {"label":"Esc", "x":4.5, "y":0}, {"label":"F1", "x":5.75, "y":0}, {"label":"F2", "x":6.75, "y":0}, {"label":"F3", "x":7.75, "y":0}, {"label":"F4", "x":8.75, "y":0}, {"label":"F5", "x":10, "y":0}, {"label":"F6", "x":11, "y":0}, {"label":"F7", "x":12.75, "y":0}, {"label":"F8", "x":13.75, "y":0}, {"label":"F9", "x":15, "y":0}, {"label":"F10", "x":16, "y":0}, {"label":"F11", "x":17, "y":0}, {"label":"F12", "x":18, "y":0}, {"label":"Prt Scn", "x":19.25, "y":0}, {"label":"Scl Lck", "x":20.5, "y":0}, {"label":"Pause", "x":21.5, "y":0}, | |||
{"label":"Num Lock", "x":0, "y":1.5}, {"label":"/", "x":1, "y":1.5}, {"label":"*", "x":2, "y":1.5}, {"label":"-", "x":3, "y":1.5}, {"label":"~", "x":4.5, "y":1.5}, {"label":"!", "x":5.5, "y":1.5}, {"label":"@", "x":6.5, "y":1.5}, {"label":"#", "x":7.5, "y":1.5}, {"label":"$", "x":8.5, "y":1.5}, {"label":"%", "x":9.5, "y":1.5}, {"label":"^", "x":10.5, "y":1.5}, {"label":"&", "x":12.25, "y":1.5}, {"label":"*", "x":13.25, "y":1.5}, {"label":"(", "x":14.25, "y":1.5}, {"label":")", "x":15.25, "y":1.5}, {"label":"_", "x":16.25, "y":1.5}, {"label":"+", "x":17.25, "y":1.5}, {"label":"Backspace", "x":18.25, "y":1.5}, {"label":"Backspace2", "x":19.25, "y":1.5}, {"label":"Home", "x":20.5, "y":1.5}, {"label":"Insert", "x":21.5, "y":1.5}, | |||
{"label":"7", "x":0, "y":2.5}, {"label":"8", "x":1, "y":2.5}, {"label":"9", "x":2, "y":2.5}, {"label":"+", "x":3, "y":2.5}, {"label":"Tab", "x":4.5, "y":2.5, "w":1.5}, {"label":"Q", "x":6, "y":2.5}, {"label":"W", "x":7, "y":2.5}, {"label":"E", "x":8, "y":2.5}, {"label":"R", "x":9, "y":2.5}, {"label":"T", "x":10, "y":2.5}, {"label":"Y", "x":11.75, "y":2.5}, {"label":"U", "x":12.75, "y":2.5}, {"label":"I", "x":13.75, "y":2.5}, {"label":"O", "x":14.75, "y":2.5}, {"label":"P", "x":15.75, "y":2.5}, {"label":"{", "x":16.75, "y":2.5}, {"label":"}", "x":17.75, "y":2.5}, {"label":"|", "x":18.75, "y":2.5, "w":1.5}, {"label":"End", "x":20.5, "y":2.5}, {"label":"Delete", "x":21.5, "y":2.5}, | |||
{"label":"4", "x":0, "y":3.5}, {"label":"5", "x":1, "y":3.5}, {"label":"6", "x":2, "y":3.5}, {"label":"=", "x":3, "y":3.5}, {"label":"Caps Lock", "x":4.5, "y":3.5, "w":1.75}, {"label":"A", "x":6.25, "y":3.5}, {"label":"S", "x":7.25, "y":3.5}, {"label":"D", "x":8.25, "y":3.5}, {"label":"F", "x":9.25, "y":3.5}, {"label":"G", "x":10.25, "y":3.5}, {"label":"H", "x":12, "y":3.5}, {"label":"J", "x":13, "y":3.5}, {"label":"K", "x":14, "y":3.5}, {"label":"L", "x":15, "y":3.5}, {"label":":", "x":16, "y":3.5}, {"label":"\"", "x":17, "y":3.5}, {"label":"Enter", "x":18, "y":3.5, "w":2.25}, {"label":"PgUp", "x":20.5, "y":3.5}, {"label":"PgDn", "x":21.5, "y":3.5}, | |||
{"label":"1", "x":0, "y":4.5}, {"label":"2", "x":1, "y":4.5}, {"label":"3", "x":2, "y":4.5}, {"label":"Enter", "x":3, "y":4.5}, {"label":"Shift", "x":4.5, "y":4.5, "w":1.25}, {"label":"numbs", "x":5.75, "y":4.5, "w":1}, {"label":"Z", "x":6.75, "y":4.5}, {"label":"X", "x":7.75, "y":4.5}, {"label":"C", "x":8.75, "y":4.5}, {"label":"V", "x":9.75, "y":4.5}, {"label":"B", "x":10.75, "y":4.5}, {"label":"N", "x":12.5, "y":4.5}, {"label":"M", "x":13.5, "y":4.5}, {"label":"<", "x":14.5, "y":4.5}, {"label":">", "x":15.5, "y":4.5}, {"label":"?", "x":16.5, "y":4.5}, {"label":"Shift", "x":17.5, "y":4.5, "w":1.75}, {"label":"Fn", "x":19.25, "y":4.5}, {"label":"\u2191", "x":20.5, "y":4.75}, | |||
{"label":"0", "x":0, "y":5.5}, {"label":"00", "x":1, "y":5.5}, {"label":".", "x":2, "y":5.5}, {"label":"..", "x":3, "y":5.5}, {"label":"Ctrl", "x":4.5, "y":5.5, "w":1.25}, {"label":"Code", "x":5.75, "y":5.5, "w":1.25}, {"label":"Alt", "x":7, "y":5.5, "w":1.25}, {"label":"Fn", "x":8.25, "y":5.5, "w":1}, {"label":"", "x":9.25, "y":5.5, "w":2.25}, {"label":"", "x":12.25, "y":5.5, "w":2.25}, {"label":"", "x":14.5, "y":5.5, "w":1}, {"label":"Alt", "x":15.5, "y":5.5, "w":1.25}, {"label":"Code", "x":16.75, "y":5.5, "w":1.25}, {"label":"Ctrl", "x":18, "y":5.5, "w":1.25}, {"label":"\u2190", "x":19.5, "y":5.75}, {"label":"\u2193", "x":20.5, "y":5.75}, {"label":"\u2192", "x":21.5, "y":5.75} | |||
] | |||
} | |||
} | |||
} |
@ -0,0 +1,57 @@ | |||
/* Copyright 2020 blindassassin111 | |||
* | |||
* 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 | |||
// Defines names for use in layer keycodes and the keymap | |||
enum layer_names { | |||
_BASE, | |||
_FN | |||
}; | |||
// Defines the keycodes used by our macros in process_record_user | |||
enum custom_keycodes { | |||
KC_P00 = SAFE_RANGE | |||
}; | |||
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | |||
[_BASE] = LAYOUT_all( | |||
KC_MUTE, KC_MPRV, KC_MPLY, KC_MNXT, 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_NLCK, KC_PSLS, KC_PAST, KC_PMNS, 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_DEL, KC_HOME, KC_INS, | |||
KC_P7, KC_P8, KC_P9, KC_PPLS, 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_END, KC_DEL, | |||
KC_P4, KC_P5, KC_P6, KC_PEQL, KC_CAPS, 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_PGUP, KC_PGDN, | |||
KC_P1, KC_P2, KC_P3, KC_PENT, 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, MO(_FN), KC_UP, | |||
KC_P0, KC_P0, KC_P00, KC_PDOT, KC_LCTL, KC_LGUI, KC_LALT, KC_MUTE, KC_SPC, KC_SPC, KC_APP, KC_RALT, KC_RGUI, KC_RCTL, KC_LEFT, KC_DOWN, KC_RIGHT), | |||
[_FN] = LAYOUT_all( | |||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RESET, | |||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, | |||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, | |||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, | |||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, | |||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______), | |||
}; | |||
bool process_record_user(uint16_t keycode, keyrecord_t *record) { | |||
if (record->event.pressed) { | |||
switch (keycode) { | |||
case KC_P00: | |||
tap_code(KC_P0); | |||
tap_code(KC_P0); | |||
return false; | |||
} | |||
} | |||
return true; | |||
} |
@ -0,0 +1,18 @@ | |||
/* Copyright 2020 blindassassin111 | |||
* | |||
* 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 | |||
#define DYNAMIC_KEYMAP_LAYER_COUNT 3 |
@ -0,0 +1,42 @@ | |||
/* Copyright 2020 blindassassin111 | |||
* | |||
* 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_all( | |||
KC_MUTE, KC_MPRV, KC_MPLY, KC_MNXT, 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_NLCK, KC_PSLS, KC_PAST, KC_PMNS, 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_DEL, KC_HOME, KC_INS, | |||
KC_P7, KC_P8, KC_P9, KC_PPLS, 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_END, KC_DEL, | |||
KC_P4, KC_P5, KC_P6, KC_PEQL, KC_CAPS, 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_PGUP, KC_PGDN, | |||
KC_P1, KC_P2, KC_P3, KC_PENT, 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, MO(1), KC_UP, | |||
KC_P0, KC_P0, KC_P0, KC_PDOT, KC_LCTL, KC_LGUI, KC_LALT, KC_MUTE, KC_SPC, KC_SPC, KC_APP, KC_RALT, KC_RGUI, KC_RCTL, KC_LEFT, KC_DOWN, KC_RIGHT), | |||
[1] = LAYOUT_all( | |||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RESET, | |||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, | |||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, | |||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, | |||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, | |||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______), | |||
[2] = LAYOUT_all( | |||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, | |||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, | |||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, | |||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, | |||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, | |||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______), | |||
}; |
@ -0,0 +1 @@ | |||
VIA_ENABLE = yes |
@ -0,0 +1,178 @@ | |||
/* Copyright 2020 zvecr<git@zvecr.com> | |||
* | |||
* 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 "mcp23018.h" | |||
#include "quantum.h" | |||
// Optimize scanning code for speed as a slight mitigation for the port expander | |||
#pragma GCC push_options | |||
#pragma GCC optimize("-O3") | |||
#define I2C_ADDR 0x20 | |||
static uint16_t mcp23018_reset_loop = 0; | |||
static uint8_t mcp23018_errors = 0; | |||
static const pin_t row_pins[MATRIX_ROWS / 2] = {B1, D5, D4, D6, D7, B4}; | |||
static const pin_t col_pins[MATRIX_COLS] = {F5, F6, F7, C7, C6, B6, B5, D3, D2, B3, B2}; | |||
//_____REGULAR funcs____________________________________________________________ | |||
static void select_row(uint8_t row) { | |||
setPinOutput(row_pins[row]); | |||
writePinLow(row_pins[row]); | |||
} | |||
static void unselect_row(uint8_t row) { setPinInputHigh(row_pins[row]); } | |||
static void unselect_rows(void) { | |||
for (uint8_t x = 0; x < MATRIX_ROWS / 2; x++) { | |||
setPinInputHigh(row_pins[x]); | |||
} | |||
} | |||
static void init_pins(void) { | |||
unselect_rows(); | |||
for (uint8_t x = 0; x < MATRIX_COLS; x++) { | |||
setPinInputHigh(col_pins[x]); | |||
} | |||
} | |||
static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row) { | |||
// Store last value of row prior to reading | |||
matrix_row_t last_row_value = current_matrix[current_row]; | |||
// Clear data in matrix row | |||
matrix_row_t current_row_value = 0; | |||
// Select row and wait for row selection to stabilize | |||
select_row(current_row); | |||
wait_us(5); | |||
// For each col... | |||
for (uint8_t col_index = 0; col_index < MATRIX_COLS; col_index++) { | |||
// Select the col pin to read (active low) | |||
uint8_t pin_state = readPin(col_pins[col_index]); | |||
// Populate the matrix row with the state of the col pin | |||
current_row_value |= pin_state ? 0 : (MATRIX_ROW_SHIFTER << col_index); | |||
} | |||
// Unselect row | |||
unselect_row(current_row); | |||
if (last_row_value == current_row_value) { | |||
return false; | |||
} | |||
current_matrix[current_row] = current_row_value; | |||
return true; | |||
} | |||
//_____MCP23018 funcs___________________________________________________________ | |||
static void init_pins_MCP23018(void) { | |||
mcp23018_errors += !mcp23018_set_config(I2C_ADDR, mcp23018_PORTA, 0b11111111); | |||
mcp23018_errors += !mcp23018_set_config(I2C_ADDR, mcp23018_PORTB, 0b01100000); | |||
} | |||
static void select_row_MCP23018(uint8_t row) { | |||
uint8_t mask = 0; | |||
switch (row) { | |||
case 6: | |||
mask = 0b10000000; | |||
break; | |||
case 7: | |||
mask = 0b00000001; | |||
break; | |||
case 8: | |||
mask = 0b00000010; | |||
break; | |||
case 9: | |||
mask = 0b00000100; | |||
break; | |||
case 10: | |||
mask = 0b00001000; | |||
break; | |||
case 11: | |||
mask = 0b00010000; | |||
break; | |||
} | |||
mcp23018_errors += !mcp23018_set_output(I2C_ADDR, mcp23018_PORTB, ~mask); | |||
} | |||
static uint16_t read_cols_MCP23018(void) { | |||
uint16_t tmp = 0xFFFF; | |||
mcp23018_errors += !mcp23018_readPins_all(I2C_ADDR, &tmp); | |||
uint16_t state = ((tmp & 0b11111111) << 2) | ((tmp & 0b0110000000000000) >> 13); | |||
return (~state) & 0b1111111111; | |||
} | |||
static bool read_cols_on_row_MCP23018(matrix_row_t current_matrix[], uint8_t current_row) { | |||
// Store last value of row prior to reading | |||
matrix_row_t last_row_value = current_matrix[current_row]; | |||
// No need to Clear data in matrix row as we just replace in one go | |||
// Select row and wait for row selection to stabilize | |||
select_row_MCP23018(current_row); | |||
matrix_row_t current_row_value = read_cols_MCP23018(); | |||
// No need to Unselect row as the next `select_row` will blank everything | |||
if (last_row_value == current_row_value) { | |||
return false; | |||
} | |||
current_matrix[current_row] = current_row_value; | |||
return true; | |||
} | |||
//_____CUSTOM MATRIX IMPLEMENTATION____________________________________________________ | |||
void matrix_init_custom(void) { | |||
mcp23018_init(I2C_ADDR); | |||
init_pins(); | |||
init_pins_MCP23018(); | |||
} | |||
bool matrix_scan_custom(matrix_row_t current_matrix[]) { | |||
bool changed = false; | |||
for (uint8_t current_row = 0; current_row < MATRIX_ROWS / 2; current_row++) { | |||
changed |= read_cols_on_row(current_matrix, current_row); | |||
} | |||
if (mcp23018_errors) { | |||
if (++mcp23018_reset_loop > 0x7FFF) { | |||
// tuned to about 5s given the current scan rate | |||
print("trying to reset mcp23018\n"); | |||
mcp23018_reset_loop = 0; | |||
mcp23018_errors = 0; | |||
init_pins_MCP23018(); | |||
} | |||
return changed; | |||
} | |||
for (uint8_t current_row = MATRIX_ROWS / 2; current_row < MATRIX_ROWS; current_row++) { | |||
changed |= read_cols_on_row_MCP23018(current_matrix, current_row); | |||
} | |||
return changed; | |||
} | |||
#pragma GCC pop_options |
@ -0,0 +1,120 @@ | |||
/* Copyright 2020 zvecr<git@zvecr.com> | |||
* | |||
* 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 "mcp23018.h" | |||
#include "i2c_master.h" | |||
#include "wait.h" | |||
#include "debug.h" | |||
#define SLAVE_TO_ADDR(n) (n << 1) | |||
#define TIMEOUT 100 | |||
enum { | |||
CMD_IODIRA = 0x00, // i/o direction register | |||
CMD_IODIRB = 0x01, | |||
CMD_GPPUA = 0x0C, // GPIO pull-up resistor register | |||
CMD_GPPUB = 0x0D, | |||
CMD_GPIOA = 0x12, // general purpose i/o port register (write modifies OLAT) | |||
CMD_GPIOB = 0x13, | |||
}; | |||
void mcp23018_init(uint8_t addr) { | |||
static uint8_t s_init = 0; | |||
if (!s_init) { | |||
i2c_init(); | |||
wait_ms(1000); | |||
s_init = 1; | |||
} | |||
} | |||
bool mcp23018_set_config(uint8_t slave_addr, uint8_t port, uint8_t conf) { | |||
uint8_t addr = SLAVE_TO_ADDR(slave_addr); | |||
uint8_t cmdDirection = port ? CMD_IODIRB : CMD_IODIRA; | |||
uint8_t cmdPullup = port ? CMD_GPPUB : CMD_GPPUA; | |||
i2c_status_t ret = i2c_writeReg(addr, cmdDirection, &conf, sizeof(conf), TIMEOUT); | |||
if (ret != I2C_STATUS_SUCCESS) { | |||
dprintf("mcp23018_set_config::directionFAILED::%u\n", ret); | |||
return false; | |||
} | |||
ret = i2c_writeReg(addr, cmdPullup, &conf, sizeof(conf), TIMEOUT); | |||
if (ret != I2C_STATUS_SUCCESS) { | |||
dprintf("mcp23018_set_config::pullupFAILED::%u\n", ret); | |||
return false; | |||
} | |||
return true; | |||
} | |||
bool mcp23018_set_output(uint8_t slave_addr, uint8_t port, uint8_t conf) { | |||
uint8_t addr = SLAVE_TO_ADDR(slave_addr); | |||
uint8_t cmd = port ? CMD_GPIOB : CMD_GPIOA; | |||
i2c_status_t ret = i2c_writeReg(addr, cmd, &conf, sizeof(conf), TIMEOUT); | |||
if (ret != I2C_STATUS_SUCCESS) { | |||
dprintf("mcp23018_set_output::FAILED::%u\n", ret); | |||
return false; | |||
} | |||
return true; | |||
} | |||
bool mcp23018_set_output_all(uint8_t slave_addr, uint8_t confA, uint8_t confB) { | |||
uint8_t addr = SLAVE_TO_ADDR(slave_addr); | |||
uint8_t conf[2] = {confA, confB}; | |||
i2c_status_t ret = i2c_writeReg(addr, CMD_GPIOA, &conf[0], sizeof(conf), TIMEOUT); | |||
if (ret != I2C_STATUS_SUCCESS) { | |||
dprintf("mcp23018_set_output::FAILED::%u\n", ret); | |||
return false; | |||
} | |||
return true; | |||
} | |||
bool mcp23018_readPins(uint8_t slave_addr, uint8_t port, uint8_t* out) { | |||
uint8_t addr = SLAVE_TO_ADDR(slave_addr); | |||
uint8_t cmd = port ? CMD_GPIOB : CMD_GPIOA; | |||
i2c_status_t ret = i2c_readReg(addr, cmd, out, sizeof(uint8_t), TIMEOUT); | |||
if (ret != I2C_STATUS_SUCCESS) { | |||
dprintf("mcp23018_readPins::FAILED::%u\n", ret); | |||
return false; | |||
} | |||
return true; | |||
} | |||
bool mcp23018_readPins_all(uint8_t slave_addr, uint16_t* out) { | |||
uint8_t addr = SLAVE_TO_ADDR(slave_addr); | |||
typedef union { | |||
uint8_t u8[2]; | |||
uint16_t u16; | |||
} data16; | |||
data16 data = {.u16 = 0}; | |||
i2c_status_t ret = i2c_readReg(addr, CMD_GPIOA, &data.u8[0], sizeof(data), TIMEOUT); | |||
if (ret != I2C_STATUS_SUCCESS) { | |||
dprintf("mcp23018_readPins::FAILED::%u\n", ret); | |||
return false; | |||
} | |||
*out = data.u16; | |||
return true; | |||
} |
@ -0,0 +1,34 @@ | |||
/* Copyright 2020 zvecr<git@zvecr.com> | |||
* | |||
* 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 <stdint.h> | |||
#include <stdbool.h> | |||
#define mcp23018_PORTA 0 | |||
#define mcp23018_PORTB 1 | |||
#define ALL_OUTPUT 0 | |||
#define ALL_INPUT 0xFF | |||
#define ALL_LOW 0 | |||
#define ALL_HIGH 0xFF | |||
void mcp23018_init(uint8_t addr); | |||
bool mcp23018_set_config(uint8_t slave_addr, uint8_t port, uint8_t conf); | |||
bool mcp23018_set_output(uint8_t slave_addr, uint8_t port, uint8_t conf); | |||
bool mcp23018_set_output_all(uint8_t slave_addr, uint8_t confA, uint8_t confB); | |||
bool mcp23018_readPins(uint8_t slave_addraddr, uint8_t port, uint8_t* ret); | |||
bool mcp23018_readPins_all(uint8_t slave_addr, uint16_t* ret); |
@ -0,0 +1,21 @@ | |||
# SP-111 | |||
![SP-111](https://i.imgur.com/RPFv9KKl.jpg) | |||
Southpaw (left sided numpad) allows you to use the numpad and mouse at the same time. | |||
Split allows placement in a comfortable manner for long sessions. | |||
Right side layout to maintain the functionality of a full size board in a much more compact manner. | |||
* Keyboard Maintainer: [zvecr](https://github.com/zvecr), blindassassin111 | |||
* Hardware Supported: SP-111 | |||
* Hardware Availability: <https://thekey.company/products/sp-111> | |||
Make example for this keyboard (after setting up your build environment): | |||
make sp111:default | |||
Flashing example for this keyboard: | |||
make sp111: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). |
@ -0,0 +1,30 @@ | |||
# MCU name | |||
MCU = atmega32u4 | |||
# Bootloader selection | |||
BOOTLOADER = atmel-dfu | |||
# 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 = no # 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 = yes # 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 | |||
LTO_ENABLE = yes # Smaller (and slightly faster) firmware | |||
# custom matrix setup | |||
CUSTOM_MATRIX = lite | |||
SRC += mcp23018.c matrix.c | |||
QUANTUM_LIB_SRC += i2c_master.c |
@ -0,0 +1,42 @@ | |||
/* Copyright 2020 blindassassin111 | |||
* | |||
* 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 "sp111.h" | |||
void keyboard_pre_init_kb(void) { | |||
// enable built in pullups to avoid timeouts when right hand not connected | |||
setPinInputHigh(D0); | |||
setPinInputHigh(D1); | |||
keyboard_pre_init_user(); | |||
} | |||
void matrix_init_kb(void) { | |||
setPinOutput(F0); | |||
setPinOutput(F1); | |||
setPinOutput(F4); | |||
matrix_init_user(); | |||
} | |||
bool led_update_kb(led_t led_state) { | |||
bool res = led_update_user(led_state); | |||
if (res) { | |||
writePin(F0, led_state.num_lock); | |||
writePin(F1, led_state.caps_lock); | |||
writePin(F4, led_state.scroll_lock); | |||
} | |||
return res; | |||
} |
@ -0,0 +1,41 @@ | |||
/* Copyright 2020 blindassassin111 | |||
* | |||
* 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" | |||
#define ___ KC_NO | |||
#define LAYOUT_all( \ | |||
L00, L01, L02, L03, L04, L05, L06, L07, L08, L09, L0A, R01, R02, R03, R04, R05, R06, R07, R08, R09, \ | |||
L10, L11, L12, L13, L14, L15, L16, L17, L18, L19, L0B, R10, R11, R12, R13, R14, R15, R16, R17, R18, R19, \ | |||
L20, L21, L22, L23, L24, L25, L26, L27, L28, L29, R20, R21, R22, R23, R24, R25, R26, R27, R28, R29, \ | |||
L30, L31, L32, L33, L34, L35, L36, L37, L38, L39, R30, R31, R32, R33, R34, R35, R36, R37, R38, R39, \ | |||
L40, L41, L42, L43, L44, L45, L46, L47, L48, L49, R41, R42, R43, R44, R45, R46, R47, R48, \ | |||
L50, L51, L52, L53, L54, L55, L56, L57, L58, R52, R53, R54, R55, R56, R57, R49, R59 \ | |||
) { \ | |||
{ L00, L01, L02, L03, L04, L05, L06, L07, L08, L09, L0A }, \ | |||
{ L10, L11, L12, L13, L14, L15, L16, L17, L18, L19, L0B }, \ | |||
{ L20, L21, L22, L23, L24, L25, L26, L27, L28, L29, ___ }, \ | |||
{ L30, L31, L32, L33, L34, L35, L36, L37, L38, L39, ___ }, \ | |||
{ L40, L41, L42, L43, L44, L45, L46, L47, L48, L49, ___ }, \ | |||
{ L50, L51, L52, L53, L54, L55, L56, L57, L58, ___, ___ }, \ | |||
{ ___, R01, R02, R03, R04, R05, R06, R07, R08, R09, ___ }, \ | |||
{ R10, R11, R12, R13, R14, R15, R16, R17, R18, R19, ___ }, \ | |||
{ R20, R21, R22, R23, R24, R25, R26, R27, R28, R29, ___ }, \ | |||
{ R30, R31, R32, R33, R34, R35, R36, R37, R38, R39, ___ }, \ | |||
{ ___, R41, R42, R43, R44, R45, R46, R47, R48, ___, ___ }, \ | |||
{ ___, ___, R52, R53, R54, R55, R56, R57, R49, R59, ___ } \ | |||
} |