Skip to content

Commit

Permalink
keyboards/ryanskidmore: add rskeys100 keyboard (#15506)
Browse files Browse the repository at this point in the history
* keyboards/ryanskidmore/rskeys100: add rskeys100 draft firmware

* keyboards/ryanskidmore/rskeys100: fix firmware

* ryanskidmore/rskeys100: fix remaining bugs

* keyboards/ryanskidmore/rskeys100: finishing touches on firmware

* keyboards/ryanskidmore/rskeys100: migrate from full replacement matrix scanning to lite, move rgb matrix enable call to keymap

* keyboards/ryanskidmore/rskeys100: remove undefines, clarify comments

* ryanskidmore/rskeys100: remove unused imports

* keyboards/ryanskidmore/rskeys100: pr feedback
  • Loading branch information
ryanskidmore authored May 2, 2022
1 parent 8b668a2 commit 66fc18c
Show file tree
Hide file tree
Showing 9 changed files with 479 additions and 0 deletions.
85 changes: 85 additions & 0 deletions keyboards/ryanskidmore/rskeys100/config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
// Copyright 2021 Ryan Skidmore (@ryanskidmore, [email protected])
// SPDX-License-Identifier: GPL-2.0-or-later

#pragma once

#include "config_common.h"

/* USB Device descriptor parameter */
#define VENDOR_ID 0x7273 // rs
#define PRODUCT_ID 0x0064 // 100
#define DEVICE_VER 0x0001 // rev 1
#define MANUFACTURER ryanskidmore
#define PRODUCT rsKeys100

/* Key Matrix Sizes */
#define MATRIX_ROWS 6
#define MATRIX_COLS 24

/* Rows */
#define ROW_A D4
#define ROW_B C6
#define ROW_C D7
#define ROW_D E6
#define ROW_E B4
#define ROW_F B5

/* Columns 0 - 20 (24 with dummy columns for shift registers) */
#define SHR_LATCH B2
#define SHR_CLOCK B3
#define SHR_DATA B1
#define SHR_COLS { 0x000001, 0x000002, 0x000004, 0x000008, 0x000010, 0x000020, 0x000040, 0x000080, 0x000100, 0x000200, 0x000400, 0x000800, 0x001000, 0x002000, 0x004000, 0x008000, 0x010000, 0x020000, 0x040000, 0x080000, 0x100000, 0x200000, 0x400000, 0x800000 }

/* The shift registers on the matrix PCB output a signal on each column, which passes through the
* switch and a diode towards the row. The row is then connected to the AVR as an input. This means
* the diode direction is COL(umn) to ROW */
#define DIODE_DIRECTION COL2ROW

/* RGB Data Pin */
#define RGB_DI_PIN C7
/* The number of RGB LEDs connected */
#define DRIVER_LED_TOTAL 105
/* Set the maximum brightness to 110 to avoid going over 500 mA.
* At full brightness with all three indicator LEDs on, the power draw is about 450 mA. */
#define RGB_MATRIX_MAXIMUM_BRIGHTNESS 110
/* Enable framebuffer effects */
#define RGB_MATRIX_FRAMEBUFFER_EFFECTS
/* Enable the cycle left right animation and set it as the startup mode */
#define ENABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT
#define RGB_MATRIX_STARTUP_MODE RGB_MATRIX_CYCLE_LEFT_RIGHT

/* 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

/* Set the max power consumption for the keyboard, which is 500 mA. */
#define USB_MAX_POWER_CONSUMPTION 500

/*
* 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

/* disable these deprecated features by default */
#define NO_ACTION_MACRO
#define NO_ACTION_FUNCTION
121 changes: 121 additions & 0 deletions keyboards/ryanskidmore/rskeys100/info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
{
"keyboard_name": "rskeys100",
"url": "",
"maintainer": "ryanskidmore",
"layouts": {
"LAYOUT_fullsize_iso": {
"layout": [
{"x":0, "y":0},
{"x":2, "y":0},
{"x":3, "y":0},
{"x":4, "y":0},
{"x":5, "y":0},
{"x":6.5, "y":0},
{"x":7.5, "y":0},
{"x":8.5, "y":0},
{"x":9.5, "y":0},
{"x":11, "y":0},
{"x":12, "y":0},
{"x":13, "y":0},
{"x":14, "y":0},
{"x":15.25, "y":0},
{"x":16.25, "y":0},
{"x":17.25, "y":0},

{"x":0, "y":1.25},
{"x":1, "y":1.25},
{"x":2, "y":1.25},
{"x":3, "y":1.25},
{"x":4, "y":1.25},
{"x":5, "y":1.25},
{"x":6, "y":1.25},
{"x":7, "y":1.25},
{"x":8, "y":1.25},
{"x":9, "y":1.25},
{"x":10, "y":1.25},
{"x":11, "y":1.25},
{"x":12, "y":1.25},
{"x":13, "y":1.25, "w":2},
{"x":15.25, "y":1.25},
{"x":16.25, "y":1.25},
{"x":17.25, "y":1.25},
{"x":18.5, "y":1.25},
{"x":19.5, "y":1.25},
{"x":20.5, "y":1.25},
{"x":21.5, "y":1.25},

{"x":0, "y":2.25, "w":1.5},
{"x":1.5, "y":2.25},
{"x":2.5, "y":2.25},
{"x":3.5, "y":2.25},
{"x":4.5, "y":2.25},
{"x":5.5, "y":2.25},
{"x":6.5, "y":2.25},
{"x":7.5, "y":2.25},
{"x":8.5, "y":2.25},
{"x":9.5, "y":2.25},
{"x":10.5, "y":2.25},
{"x":11.5, "y":2.25},
{"x":12.5, "y":2.25},
{"x":15.25, "y":2.25},
{"x":16.25, "y":2.25},
{"x":17.25, "y":2.25},
{"x":18.5, "y":2.25},
{"x":19.5, "y":2.25},
{"x":20.5, "y":2.25},
{"x":21.5, "y":2.25, "h": 2},

{"x":0, "y":3.25, "w":1.75},
{"x":1.75, "y":3.25},
{"x":2.75, "y":3.25},
{"x":3.75, "y":3.25},
{"x":4.75, "y":3.25},
{"x":5.75, "y":3.25},
{"x":6.75, "y":3.25},
{"x":7.75, "y":3.25},
{"x":8.75, "y":3.25},
{"x":9.75, "y":3.25},
{"x":10.75, "y":3.25},
{"x":11.75, "y":3.25},
{"x":12.75, "y":3.25},
{"x":13.75, "y":2.25, "w":1.25, "h":2},
{"x":18.5, "y":3.25},
{"x":19.5, "y":3.25},
{"x":20.5, "y":3.25},

{"x":0, "y":4.25, "w":1.25},
{"x":1.25, "y":4.25},
{"x":2.25, "y":4.25},
{"x":3.25, "y":4.25},
{"x":4.25, "y":4.25},
{"x":5.25, "y":4.25},
{"x":6.25, "y":4.25},
{"x":7.25, "y":4.25},
{"x":8.25, "y":4.25},
{"x":9.25, "y":4.25},
{"x":10.25, "y":4.25},
{"x":11.25, "y":4.25},
{"x":12.25, "y":4.25, "w":2.75},
{"x":16.25, "y":4.25},
{"x":18.5, "y":4.25},
{"x":19.5, "y":4.25},
{"x":20.5, "y":4.25},
{"x":21.5, "y":4.25, "h":2},

{"x":0, "y":5.25, "w":1.25},
{"x":1.25, "y":5.25, "w":1.25},
{"x":2.5, "y":5.25, "w":1.25},
{"x":3.75, "y":5.25, "w":6.25},
{"x":10, "y":5.25, "w":1.25},
{"x":11.25, "y":5.25, "w":1.25},
{"x":12.5, "y":5.25, "w":1.25},
{"x":13.75, "y":5.25, "w":1.25},
{"x":15.25, "y":5.25},
{"x":16.25, "y":5.25},
{"x":17.25, "y":5.25},
{"x":18.5, "y":5.25, "w":2},
{"x":20.5, "y":5.25}
]
}
}
}
65 changes: 65 additions & 0 deletions keyboards/ryanskidmore/rskeys100/keymaps/default/keymap.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// Copyright 2021 Ryan Skidmore (@ryanskidmore, [email protected])
// SPDX-License-Identifier: GPL-2.0-or-later

#include QMK_KEYBOARD_H

const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
/*
* ┌───┐ ┌───┬───┬───┬───┐ ┌───┬───┬───┬───┐ ┌───┬───┬───┬───┐ ┌───┬───┬───┐
* │Esc│ │F1 │F2 │F3 │F4 │ │F5 │F6 │F7 │F8 │ │F9 │F10│F11│F12│ │PSc│Scr│Pse│
* └───┘ └───┴───┴───┴───┘ └───┴───┴───┴───┘ └───┴───┴───┴───┘ └───┴───┴───┘
* ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐ ┌───┬───┬───┐ ┌───┬───┬───┬───┐
* │ ` │ 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 │ [ │ ] │ │ │Del│End│PgD│ │ 7 │ 8 │ 9 │ │
* ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┐ Ent│ └───┴───┴───┘ ├───┼───┼───┤ + │
* │ Caps │ A │ S │ D │ F │ G │ H │ J │ K │ L │ ; │ ' │ # │ │ │ 4 │ 5 │ 6 │ │
* ├────┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴───┴────┤ ┌───┐ ├───┼───┼───┼───┤
* │Shft│ \ │ Z │ X │ C │ V │ B │ N │ M │ , │ . │ / │ Shift │ │ ↑ │ │ 1 │ 2 │ 3 │ │
* ├────┼───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴───┼───┴┬────┬────┤ ┌───┼───┼───┐ ├───┴───┼───┤Ent│
* │Ctrl│GUI │Alt │ │ Alt│ GUI│Menu│Ctrl│ │ ← │ ↓ │ → │ │ 0 │ . │ │
* └────┴────┴────┴────────────────────────┴────┴────┴────┴────┘ └───┴───┴───┘ └───────┴───┴───┘
*/
/* Default Layer */
[0] = LAYOUT_fullsize_iso(
KC_ESC, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, LT(1, 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_ENT, KC_DEL, KC_END, KC_PGDN, KC_P7, KC_P8, KC_P9, KC_PPLS,
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_NUHS, 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, KC_APP, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT, KC_P0, KC_PDOT
),
/* RGB Control Layer */
[1] = LAYOUT_fullsize_iso(
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,

_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RGB_VAI, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, RGB_VAD, _______, _______, _______
),
};

void keyboard_post_init_user(void) {
rgb_matrix_enable_noeeprom();
}

void rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) {
/* We use RGB for the indicator RGB colours since we don't need to adjust the brightness.
* If any of the indicators are enabled, set the key to white. This overrides the active RGB
* matrix animation. */

if (host_keyboard_led_state().caps_lock) {
RGB_MATRIX_INDICATOR_SET_COLOR(73, 255, 255, 255);
}

if (host_keyboard_led_state().num_lock) {
RGB_MATRIX_INDICATOR_SET_COLOR(19, 255, 255, 255);
}

if (host_keyboard_led_state().scroll_lock) {
RGB_MATRIX_INDICATOR_SET_COLOR(14, 255, 255, 255);
}
}
1 change: 1 addition & 0 deletions keyboards/ryanskidmore/rskeys100/keymaps/default/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This is the default keymap (UK, ISO) for the rskeys100. The RGB control layer can be activated by holding the F12 key.
110 changes: 110 additions & 0 deletions keyboards/ryanskidmore/rskeys100/matrix.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
/*
Copyright 2014 Ralf Schmitt <[email protected]>
Modified by Ryan Skidmore <[email protected]> (@ryanskidmore)
to support the rskeys100.
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 <stdbool.h>
#include "matrix.h"
#include <util/delay.h>
#include "quantum.h"

static const uint32_t col_values[24] = SHR_COLS;

static uint8_t read_rows(void);
static void select_col(uint8_t col);

static void shift_pulse(void);
static void shift_out_single(uint8_t value);
static void shift_out(uint32_t value);

void matrix_init_custom(void) {
setPinInput(ROW_A);
setPinInput(ROW_B);
setPinInput(ROW_C);
setPinInput(ROW_D);
setPinInput(ROW_E);
setPinInput(ROW_F);

setPinOutput(SHR_DATA);
setPinOutput(SHR_LATCH);
setPinOutput(SHR_CLOCK);
}

bool matrix_scan_custom(matrix_row_t current_matrix[]) {
bool changed = false;

for (uint8_t col = 0; col < MATRIX_COLS; col++) {
select_col(col);
_delay_us(1);
uint8_t rows = read_rows();
for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
bool prev_bit = ((uint32_t)(current_matrix[row]) & (matrix_row_t)(1UL << col)) ? 1 : 0;
bool curr_bit = ((uint32_t)rows & (uint32_t)(1UL << row)) ? 1 : 0;
if (prev_bit != curr_bit) {
current_matrix[row] = (uint32_t)(current_matrix[row]) ^ (uint32_t)(1UL << col);
changed = true;
}
}
}

return changed;
}

static uint8_t read_rows(void) {
return (readPin(ROW_F) << 5)
| (readPin(ROW_E) << 4)
| (readPin(ROW_D) << 3)
| (readPin(ROW_C) << 2)
| (readPin(ROW_B) << 1)
| (readPin(ROW_A) );
}

static void select_col(uint8_t col) {
shift_out(col_values[col]);
}

static void shift_out(uint32_t value) {
writePinLow(SHR_LATCH);
uint8_t first_byte = (value >> 16) & 0xFF;
uint8_t second_byte = (value >> 8) & 0xFF;
uint8_t third_byte = (uint8_t)(value & 0xFF);

shift_out_single(first_byte);
shift_out_single(second_byte);
shift_out_single(third_byte);
writePinHigh(SHR_LATCH);
/* We delay here to prevent multiple consecutive keys being triggered with a single switch press */
_delay_us(10);
}

static void shift_out_single(uint8_t value) {
for (uint8_t i = 0; i < 8; i++) {
if (value & 0b10000000) {
writePinHigh(SHR_DATA);
} else {
writePinLow(SHR_DATA);
}

shift_pulse();
value = value << 1;
}
}

static inline void shift_pulse(void) {
writePinHigh(SHR_CLOCK);
writePinLow(SHR_CLOCK);
}
Loading

0 comments on commit 66fc18c

Please sign in to comment.