[Keyboard] Update K type (#15405)

Co-authored-by: Ryan <fauxpark@gmail.com>
master
Andrew-Fahmy 2021-12-06 22:58:02 -06:00 committed by GitHub
parent c0dcfcedf9
commit 23554726c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 160 additions and 109 deletions

View File

@ -105,3 +105,82 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
/* Bootmagic Lite key configuration */
//#define BOOTMAGIC_LITE_ROW 0
//#define BOOTMAGIC_LITE_COLUMN 0
#ifdef RGB_MATRIX_ENABLE
//#include "gpio.h"
// RGB Matrix Animation modes. Explicitly enabled
// For full list of effects, see:
// https://docs.qmk.fm/#/feature_rgb_matrix?id=rgb-matrix-effects
# define ENABLE_RGB_MATRIX_ALPHAS_MODS
# define ENABLE_RGB_MATRIX_GRADIENT_UP_DOWN
# define ENABLE_RGB_MATRIX_GRADIENT_LEFT_RIGHT
# define ENABLE_RGB_MATRIX_BREATHING
# define ENABLE_RGB_MATRIX_BAND_SAT
# define ENABLE_RGB_MATRIX_BAND_VAL
# define ENABLE_RGB_MATRIX_BAND_PINWHEEL_SAT
# define ENABLE_RGB_MATRIX_BAND_PINWHEEL_VAL
# define ENABLE_RGB_MATRIX_BAND_SPIRAL_SAT
# define ENABLE_RGB_MATRIX_BAND_SPIRAL_VAL
# define ENABLE_RGB_MATRIX_CYCLE_ALL
# define ENABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT
# define ENABLE_RGB_MATRIX_CYCLE_UP_DOWN
# define ENABLE_RGB_MATRIX_RAINBOW_MOVING_CHEVRON
# define ENABLE_RGB_MATRIX_CYCLE_OUT_IN
# define ENABLE_RGB_MATRIX_CYCLE_OUT_IN_DUAL
# define ENABLE_RGB_MATRIX_CYCLE_PINWHEEL
# define ENABLE_RGB_MATRIX_CYCLE_SPIRAL
# define ENABLE_RGB_MATRIX_DUAL_BEACON
# define ENABLE_RGB_MATRIX_RAINBOW_BEACON
# define ENABLE_RGB_MATRIX_RAINBOW_PINWHEELS
# define ENABLE_RGB_MATRIX_RAINDROPS
# define ENABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS
# define ENABLE_RGB_MATRIX_HUE_BREATHING
# define ENABLE_RGB_MATRIX_HUE_PENDULUM
# define ENABLE_RGB_MATRIX_HUE_WAVE
# define ENABLE_RGB_MATRIX_PIXEL_RAIN
# define ENABLE_RGB_MATRIX_PIXEL_FLOW
# define ENABLE_RGB_MATRIX_PIXEL_FRACTAL
// enabled only if RGB_MATRIX_FRAMEBUFFER_EFFECTS is defined
# define ENABLE_RGB_MATRIX_TYPING_HEATMAP
# define ENABLE_RGB_MATRIX_DIGITAL_RAIN
// enabled only if RGB_MATRIX_KEYPRESSES or RGB_MATRIX_KEYRELEASES is defined
# define ENABLE_RGB_MATRIX_SOLID_REACTIVE_SIMPLE
# define ENABLE_RGB_MATRIX_SOLID_REACTIVE
# define ENABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE
# define ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE
# define ENABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS
# define ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS
# define ENABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS
# define ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS
# define ENABLE_RGB_MATRIX_SPLASH
# define ENABLE_RGB_MATRIX_MULTISPLASH
# define ENABLE_RGB_MATRIX_SOLID_SPLASH
# define ENABLE_RGB_MATRIX_SOLID_MULTISPLASH
# define RGB_MATRIX_KEYPRESSES
# define RGB_MATRIX_FRAMEBUFFER_EFFECTS
// i2c_master defines
# define I2C_COUNT 2
# define I2C1_CLOCK_SPEED 400000
# define I2C1_SCL_PIN B0 // A2 on pinout = B0
# define I2C1_SDA_PIN B1 // A2 on pinout = B1
# define I2C1_SCL_PAL_MODE PAL_MODE_ALTERNATIVE_2
# define I2C1_SDA_PAL_MODE PAL_MODE_ALTERNATIVE_2
# define USE_I2C2
# define I2C2_SCL_PIN C10 // A2 on pinout = C10
# define I2C2_SDA_PIN C11 // A2 on pinout = C11
# define I2C2_SCL_PAL_MODE PAL_MODE_ALTERNATIVE_2
# define I2C2_SDA_PAL_MODE PAL_MODE_ALTERNATIVE_2
# define DRIVER_ADDR_1 0b1010000
# define DRIVER_ADDR_2 0b1010000
# define DRIVER_COUNT 2
# define DRIVER_1_LED_TOTAL 64
# define DRIVER_2_LED_TOTAL 55
# define DRIVER_LED_TOTAL (DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL)
#endif

View File

@ -63,22 +63,22 @@ static i2c_status_t chibios_to_qmk(const msg_t* status) {
}
}
__attribute__((weak)) void i2c_init(I2CDriver *driver, ioportid_t scl_port, ioportid_t sda_port, iopadid_t scl_pad, iopadid_t sda_pad) {
__attribute__((weak)) void i2c_init(I2CDriver *driver, ioline_t scl_pin, ioline_t sda_pin) {
static uint8_t index = 0;
if (index < I2C_COUNT) {
// Try releasing special pins for a short time
palSetPadMode(scl_port, scl_pad, PAL_MODE_INPUT);
palSetPadMode(sda_port, sda_pad, PAL_MODE_INPUT);
palSetLineMode(scl_pin, PAL_MODE_INPUT);
palSetLineMode(sda_pin, PAL_MODE_INPUT);
chThdSleepMilliseconds(10);
#if defined(USE_GPIOV1)
palSetPadMode(scl_port, scl_pad, I2C1_SCL_PAL_MODE);
palSetPadMode(sda_port, sda_pad, I2C1_SDA_PAL_MODE);
palSetLineMode(scl_pin, I2C1_SCL_PAL_MODE);
palSetLineMode(sda_pin, I2C1_SDA_PAL_MODE);
#else
palSetPadMode(scl_port, scl_pad, PAL_MODE_ALTERNATE(I2C1_SCL_PAL_MODE) | PAL_STM32_OTYPE_OPENDRAIN);
palSetPadMode(sda_port, sda_pad, PAL_MODE_ALTERNATE(I2C1_SDA_PAL_MODE) | PAL_STM32_OTYPE_OPENDRAIN);
palSetLineMode(scl_pin, PAL_MODE_ALTERNATE(I2C1_SCL_PAL_MODE) | PAL_OUTPUT_TYPE_OPENDRAIN);
palSetLineMode(sda_pin, PAL_MODE_ALTERNATE(I2C1_SDA_PAL_MODE) | PAL_OUTPUT_TYPE_OPENDRAIN);
#endif
drivers[index++] = driver;

View File

@ -58,11 +58,11 @@
# endif
#endif
#ifndef I2C1_SCL
# define I2C1_SCL 6
#ifndef I2C1_SCL_PIN
# define I2C1_SCL_PIN 6
#endif
#ifndef I2C1_SDA
# define I2C1_SDA 7
#ifndef I2C1_SDA_PIN
# define I2C1_SDA_PIN 7
#endif
#ifdef USE_I2CV1
@ -118,7 +118,7 @@ typedef int16_t i2c_status_t;
#define I2C_STATUS_ERROR (-1)
#define I2C_STATUS_TIMEOUT (-2)
void i2c_init(I2CDriver *driver, ioportid_t scl_port, ioportid_t sda_port, iopadid_t scl_pad, iopadid_t sda_pad);
void i2c_init(I2CDriver *driver, ioline_t scl_pin, ioline_t sda_pin);
i2c_status_t i2c_start(uint8_t index, uint8_t address);
i2c_status_t i2c_transmit(uint8_t index, uint8_t address, const uint8_t* data, uint16_t length, uint16_t timeout);
i2c_status_t i2c_receive(uint8_t index, uint8_t address, uint8_t* data, uint16_t length, uint16_t timeout);

View File

@ -51,7 +51,7 @@
#define ISSI_REG_CSPULLUP 0x10 // PG3
#ifndef ISSI_TIMEOUT
# define ISSI_TIMEOUT 100
# define ISSI_TIMEOUT 5000
#endif
#ifndef ISSI_PERSISTENCE
@ -80,12 +80,12 @@ bool IS31FL3733_write_register(uint8_t index, uint8_t addr, uint8_t reg, uint8_t
#if ISSI_PERSISTENCE > 0
for (uint8_t i = 0; i < ISSI_PERSISTENCE; i++) {
if (i2c_transmit(index, addr << 1, g_twi_transfer_buffer, 2, ISSI_TIMEOUT) != 0) {
if (i2c_transmit(index, addr << 1, g_twi_transfer_buffer, 2, TIME_US2I(ISSI_TIMEOUT)) != 0) {
return false;
}
}
#else
if (i2c_transmit(index, addr << 1, g_twi_transfer_buffer, 2, ISSI_TIMEOUT) != 0) {
if (i2c_transmit(index, addr << 1, g_twi_transfer_buffer, 2, TIME_US2I(ISSI_TIMEOUT)) != 0) {
return false;
}
#endif
@ -110,12 +110,12 @@ bool IS31FL3733_write_pwm_buffer(uint8_t index, uint8_t addr, uint8_t *pwm_buffe
#if ISSI_PERSISTENCE > 0
for (uint8_t i = 0; i < ISSI_PERSISTENCE; i++) {
if (i2c_transmit(index, addr << 1, g_twi_transfer_buffer, 17, ISSI_TIMEOUT) != 0) {
if (i2c_transmit(index, addr << 1, g_twi_transfer_buffer, 17, TIME_US2I(ISSI_TIMEOUT)) != 0) {
return false;
}
}
#else
if (i2c_transmit(index, addr << 1, g_twi_transfer_buffer, 17, ISSI_TIMEOUT) != 0) {
if (i2c_transmit(index, addr << 1, g_twi_transfer_buffer, 17, TIME_US2I(ISSI_TIMEOUT)) != 0) {
return false;
}
#endif

View File

@ -20,6 +20,7 @@
#include <stdint.h>
#include <stdbool.h>
#include "progmem.h"
typedef struct is31_led {
uint8_t driver : 2;

View File

@ -23,10 +23,10 @@
static void init(void) {
i2c_init(&I2CD1, I2C1_SCL_BANK, I2C1_SDA_BANK, I2C1_SCL, I2C1_SDA);
i2c_init(&I2CD1, I2C1_SCL_PIN, I2C1_SDA_PIN);
IS31FL3733_init(0, DRIVER_ADDR_1, 0);
# ifdef USE_I2C2
i2c_init(&I2CD2, I2C2_SCL_BANK, I2C2_SDA_BANK, I2C2_SCL, I2C2_SDA);
i2c_init(&I2CD2, I2C2_SCL_PIN, I2C2_SDA_PIN);
IS31FL3733_init(1, DRIVER_ADDR_2, 0);
# endif
for (int index = 0; index < DRIVER_LED_TOTAL; index++) {

View File

@ -92,7 +92,7 @@ const is31_led PROGMEM g_is31_leds[DRIVER_LED_TOTAL] = {
{ 0, K_15, J_15, L_15 },
{ 0, K_16, J_16, L_16 },
// Driver 2 is on I2C2 - currently not usable with i2c_master
// Driver 2 is on I2C2
{ 1, B_1, A_1, C_1 },
{ 1, B_2, A_2, C_2 },
{ 1, B_3, A_3, C_3 },
@ -204,3 +204,32 @@ led_config_t g_led_config = {
}
};
#endif
void keyboard_pre_init_kb(void) {
#ifdef RGB_MATRIX_ENABLE
// Turn on LED controller
setPinOutput(B16);
writePinHigh(B16);
#endif
keyboard_pre_init_user();
}
void matrix_init_kb(void) {
// put your keyboard start-up code here
// runs once when the firmware starts up
#ifdef RGB_MATRIX_ENABLE
/*
* Since K20x is stuck with a 32 byte EEPROM (see tmk_core/common/chibios/eeprom_teensy.c),
* and neither led_matrix_eeconfig.speed or .flags fit in this boundary, just force their values to default on boot.
*/
# if !defined(RGB_MATRIX_STARTUP_SPD)
# define RGB_MATRIX_STARTUP_SPD UINT8_MAX / 2
# endif
rgb_matrix_set_speed(RGB_MATRIX_STARTUP_SPD),
rgb_matrix_set_flags(LED_FLAG_ALL);
#endif
matrix_init_user();
}

View File

@ -8,6 +8,15 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
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_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_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_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, KC_RGUI, KC_APP , KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT
KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, MO(1), KC_APP, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT
),
[1] = LAYOUT_tkl_ansi(
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RGB_TOG, RGB_MOD, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RGB_SPD, RGB_SPI, _______, RGB_HUI, RGB_SAI, RGB_VAI,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RGB_HUD, RGB_SAD, RGB_VAD,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______
)
};

View File

@ -1,32 +0,0 @@
#pragma once
#ifdef RGB_MATRIX_ENABLE
# define RGB_MATRIX_KEYPRESSES
# define RGB_MATRIX_STARTUP_MODE RGB_MATRIX_SOLID_COLOR
# define RGB_MATRIX_LED_FLUSH_LIMIT 100
// i2c_master defines
# define I2C_COUNT 2
# define I2C1_BANK GPIOB
# define I2C1_SCL 0 // A2 on pinout = B0
# define I2C1_SDA 1 // A2 on pinout = B1
# define I2C1_SCL_PAL_MODE PAL_MODE_ALTERNATIVE_2
# define I2C1_SDA_PAL_MODE PAL_MODE_ALTERNATIVE_2
# define USE_I2C2
# define I2C2_BANK GPIOC
# define I2C2_SCL 10 // A2 on pinout = C10
# define I2C2_SDA 11 // A2 on pinout = C11
# define I2C2_SCL_PAL_MODE PAL_MODE_ALTERNATIVE_2
# define I2C2_SDA_PAL_MODE PAL_MODE_ALTERNATIVE_2
# define DRIVER_ADDR_1 0b1010000
# define DRIVER_ADDR_2 0b1010000
# define DRIVER_COUNT 2
# define DRIVER_1_LED_TOTAL 64
# define DRIVER_2_LED_TOTAL 55
# define DRIVER_LED_TOTAL (DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL)
#endif

View File

@ -1,30 +0,0 @@
#include QMK_KEYBOARD_H
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[0] = LAYOUT_tkl_ansi(
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_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_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_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_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, MO(1), KC_APP, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT
),
[1] = LAYOUT_tkl_ansi(
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RGB_TOG, RGB_MOD, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RGB_SPD, RGB_SPI, _______, RGB_HUI, RGB_SAI, RGB_VAI,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RGB_HUD, RGB_SAD, RGB_VAD,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______
)
};
#ifdef RGB_MATRIX_ENABLE
// Turn off SDB
void keyboard_pre_init_user() {
palSetPadMode(GPIOB, 16, PAL_MODE_OUTPUT_PUSHPULL);
palSetPad(GPIOB, 16);
}
#endif

View File

@ -1,7 +0,0 @@
# K-Type RGB Matrix Keymap
This is an experimental keymap adding support for RGB Matrix on the K-Type.
The keyboard should now support full RGB lightings. The lighting animations are running at 10 fps for performance reasons.
You can configure this by changing the `RGB_MATRIX_LED_FLUSH_LIMIT` inside the `config.h` file to a lower value.
For example `RGB_MATRIX_LED_FLUSH_LIMIT 16` would mean that the animations run every 16 ms or at 60 fps.

View File

@ -52,6 +52,6 @@
#define KINETIS_I2C_I2C0_PRIORITY 4
#define KINETIS_I2C_USE_I2C1 TRUE
#define KINETIS_I2C_I2C0_PRIORITY 4
#define KINETIS_I2C_I2C1_PRIORITY 4
#endif /* _MCUCONF_H_ */

View File

@ -15,20 +15,22 @@ BOARD = IC_TEENSY_3_1
# change yes to no to disable
#
BOOTMAGIC_ENABLE = no # Enable Bootmagic Lite
MOUSEKEY_ENABLE = yes # Mouse keys
EXTRAKEY_ENABLE = yes # Audio control and System control
CONSOLE_ENABLE = yes # Console for debug
COMMAND_ENABLE = yes # Commands for debug and configuration
MOUSEKEY_ENABLE = no # Mouse keys
EXTRAKEY_ENABLE = no # Audio control and System control
CONSOLE_ENABLE = no # Console for debug
COMMAND_ENABLE = no # Commands for debug and configuration
# 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
AUDIO_ENABLE = no # Audio output
# RGB options
RGB_MATRIX_ENABLE = no
RGB_MATRIX_DRIVER = custom
# Additional files for RGB lighting
SRC += k_type-rgbdriver.c
QUANTUM_LIB_SRC += i2c_master.c is31fl3733-dual.c
LAYOUTS = tkl_ansi