minivan port (#306)

This commit is contained in:
Dong Zhou 2022-12-19 18:53:06 -05:00 committed by GitHub
parent c1af16563e
commit f163b89dbe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 477 additions and 0 deletions

View File

@ -0,0 +1,15 @@
#include "MiniVan20221213055608.h"
void matrix_init_kb(void) {
matrix_init_user();
}
void matrix_scan_kb(void) {
matrix_scan_user();
}
bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
return process_record_user(keycode, record);
}
void led_set_kb(uint8_t usb_led) {
led_set_user(usb_led);
}

View File

@ -0,0 +1,11 @@
#ifndef MINIVAN20221213055608_H
#define MINIVAN20221213055608_H
#include "quantum.h"
#define LAYOUT(K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K30, K31, K32, K34, K33, K37, K38, K39, K3A, K3B) { \
{ K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B }, \
{ K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B }, \
{ K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B }, \
{ K30, K31, K32, K33, K34, KC_NO, KC_NO, K37, K38, K39, K3A, K3B } \
}
#endif

View File

@ -0,0 +1,48 @@
#pragma once
#define VENDOR_ID 0xFEAE
#undef PRODUCT_ID
#define PRODUCT_ID 0x8847
#undef DEVICE_VER
#define DEVICE_VER 0x0001
/* #define DESCRIPTION Hotswap MiniVan 40% */
#define MATRIX_ROWS 4
#define MATRIX_COLS 12
#define MATRIX_ROW_PINS { D7, B5, F7, D4 }
#define MATRIX_COL_PINS { D2, D3, D5, D6, B4, B6, F6, F5, F4, F1, F0, B3 }
#define DIODE_DIRECTION COL2ROW
#define BACKLIGHT_LEVELS 1
#define BACKLIGHT_PIN B7
#define DEBOUNCE 5
#define TAPPING_TERM 170
#define USB_MAX_POWER_CONSUMPTION 100
#define PERMISSIVE_HOLD
#define RGB_DI_PIN D0
#define RGBLED_NUM 3
#define RGBLIGHT_ANIMATIONS
#define RGBLIGHT_SLEEP
#define IS_COMMAND() ( keyboard_report->mods == (MOD_BIT(KC_LSFT) | MOD_BIT(KC_RSFT)) )
#define AUTO_SHIFT_TIMEOUT 150
#define NO_AUTO_SHIFT_ALPHA
/* #define COMBO_COUNT 5 */
#undef RGBLIGHT_EFFECT_STATIC_GRADIENT
#undef RGBLIGHT_EFFECT_RAINBOW_SWIRL
#define VIAL_KEYBOARD_UID {0x12, 0x9F, 0x38, 0xE9, 0x3E, 0x6E, 0x1C, 0x7E}
#define NO_ACTION_MACRO
#define NO_ACTION_FUNCTION
#define VIAL_UNLOCK_COMBO_ROWS { 0, 0 }
#define VIAL_UNLOCK_COMBO_COLS { 0, 11 }

View File

@ -0,0 +1,95 @@
#include "MiniVan20221213055608.h"
enum custom_keycodes {
M_IME = SAFE_RANGE,
};
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
if (record->event.pressed) {
switch(keycode) {
case M_IME:
SEND_STRING(SS_DOWN(X_LSFT)SS_DOWN(X_LALT));
return false;
}
}
else {
switch(keycode) {
case M_IME:
SEND_STRING(SS_UP(X_LSFT)SS_UP(X_LALT));
return false;
}
}
return true;
};
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[0] = LAYOUT(KC_TAB, KC_Q, KC_W, KC_F, KC_P, KC_B, KC_J, KC_L, KC_U, KC_Y, KC_SCLN, KC_BSPC,
LCTL_T(KC_ESC), KC_A, KC_R, KC_S, KC_T, KC_G, KC_K, KC_N, KC_E, KC_I, KC_O, RSFT_T(KC_ENT),
OSM(MOD_LSFT), KC_X, KC_C, KC_D, KC_V, KC_Z, KC_M, KC_H, KC_COMM, KC_DOT, KC_SLSH, KC_QUOT,
LT(2, KC_LEFT), TG(1), KC_LGUI, KC_NO, LT(3, KC_ENT), LT(1, KC_SPC), RALT_T(KC_DOWN), RGUI_T(KC_UP), KC_NO, RCTL_T(KC_RIGHT)),
[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_TRNS,
KC_TAB, KC_LPRN, KC_RPRN, KC_LBRC, KC_RBRC, KC_TRNS, KC_PLUS, KC_1, KC_2, KC_3, KC_ASTR, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_NO, KC_TRNS, KC_TRNS, KC_MINS, KC_EQL, KC_TRNS, KC_TRNS, KC_TRNS, KC_WH_U, KC_TRNS,
KC_TRNS, KC_TRNS, KC_NO, KC_0, KC_SPC, KC_WH_L, KC_WH_D, KC_NO, KC_WH_R),
[2] = LAYOUT(KC_BTN2, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_PGUP, KC_HOME, KC_UP, KC_END, KC_COLN, RALT(KC_BSPC),
KC_TRNS, KC_NO, KC_NO, KC_NO, KC_BSPC, KC_NO, KC_PGDN, KC_LEFT, KC_DOWN, KC_RIGHT, KC_ENT, RALT(KC_D),
KC_TRNS, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_BTN1, RALT(KC_LEFT), RALT(KC_RIGHT), KC_MS_U, RALT(KC_B), RALT(KC_F),
KC_TRNS, KC_TRNS, KC_TRNS, KC_NO, LALT(KC_DEL), KC_DEL, KC_MS_L, KC_MS_D, KC_NO, KC_MS_R),
[3] = LAYOUT(KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_NO, KC_NO, KC_TRNS, KC_TRNS,
KC_CAPS, KC_LCBR, KC_RCBR, KC_LPRN, KC_RPRN, KC_NO, KC_PLUS, KC_DLR, KC_PIPE, KC_BSLS, KC_DQT,
KC_TRNS, KC_NO, KC_SLCT, KC_PAUS, KC_VOLD, KC_VOLU, KC_MUTE, KC_MINS, KC_EQL, KC_LT, KC_GT, KC_QUES,
KC_TRNS, KC_TRNS, QK_BOOT, KC_NO, KC_NO, KC_NO, KC_UNDS, KC_TRNS, KC_TRNS, KC_NO, KC_TRNS)
};
void process_indicator_update(layer_state_t state, uint8_t usb_led) {
for (int i = 0; i < 3; i++) {
setrgb(0, 0, 0, (LED_TYPE *)&led[i]);
}
if (usb_led & (1<<USB_LED_CAPS_LOCK)) {
setrgb(255, 0, 0, (LED_TYPE *)&led[0]);
}
if (state & (1<<1)) {
setrgb(255, 0, 255, (LED_TYPE *)&led[0]);
}
if (state & (1<<2)) {
setrgb(0, 0, 255, (LED_TYPE *)&led[1]);
}
if (state & (1<<3)) {
setrgb(255, 255, 0, (LED_TYPE *)&led[1]);
}
if (state & (1<<1)) {
setrgb(10, 255, 125, (LED_TYPE *)&led[2]);
}
rgblight_set();
};
void keyboard_post_init_user(void) {
process_indicator_update(layer_state, host_keyboard_leds());
};
void led_set_user(uint8_t usb_led) {
process_indicator_update(layer_state, host_keyboard_leds());
};
layer_state_t layer_state_set_user(layer_state_t state) {
process_indicator_update(state, host_keyboard_leds());
return state;
};
/* const uint16_t PROGMEM test_combo1[] = {KC_D, KC_V, COMBO_END}; */
/* const uint16_t PROGMEM test_combo2[] = {KC_C, KC_D, COMBO_END}; */
/* const uint16_t PROGMEM test_combo3[] = {KC_C, KC_X, COMBO_END}; */
/* const uint16_t PROGMEM test_combo4[] = {KC_COMM, KC_H, COMBO_END}; */
/* combo_t key_combos[COMBO_COUNT] = { */
/* COMBO(test_combo1, LGUI(KC_V)), */
/* COMBO(test_combo2, LGUI(KC_C)), */
/* COMBO(test_combo3, LGUI(KC_X)), */
/* COMBO(test_combo4, KC_MINS), */
/* }; */

View File

@ -0,0 +1,244 @@
#include <stdint.h>
#include <stdbool.h>
#include "util.h"
#include "matrix.h"
#include "debounce.h"
#include "quantum.h"
#ifdef DIRECT_PINS
static pin_t direct_pins[MATRIX_ROWS][MATRIX_COLS] = DIRECT_PINS;
#elif ((DIODE_DIRECTION == ROW2COL) || (DIODE_DIRECTION == COL2ROW)) && !defined(MULTIPLEX_PINS)
static const pin_t row_pins[MATRIX_ROWS] = MATRIX_ROW_PINS;
static const pin_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS;
#endif
#ifdef MULTIPLEX_PINS
static const uint8_t select_pins[MULTIPLEX] = MULTIPLEX_PINS;
#if (DIODE_DIRECTION == ROW2COL)
static const pin_t row_pins[MATRIX_ROWS] = MATRIX_ROW_PINS;
static const uint8_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS;
#else
static const uint8_t row_pins[MATRIX_ROWS] = MATRIX_ROW_PINS;
static const pin_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS;
#endif
#endif
// matrix code
#ifdef DIRECT_PINS
static void init_pins(void) {
for (int row = 0; row < MATRIX_ROWS; row++) {
for (int col = 0; col < MATRIX_COLS; col++) {
pin_t pin = direct_pins[row][col];
if (pin != NO_PIN) {
setPinInputHigh(pin);
}
}
}
}
static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row) {
// Start with a clear matrix row
matrix_row_t current_row_value = 0;
for (uint8_t col_index = 0; col_index < MATRIX_COLS; col_index++) {
pin_t pin = direct_pins[current_row][col_index];
if (pin != NO_PIN) {
current_row_value |= readPin(pin) ? 0 : (MATRIX_ROW_SHIFTER << col_index);
}
}
// If the row has changed, store the row and return the changed flag.
if (current_matrix[current_row] != current_row_value) {
current_matrix[current_row] = current_row_value;
return true;
}
return false;
}
#elif defined(DIODE_DIRECTION)
# if (DIODE_DIRECTION == COL2ROW)
# if defined(MULTIPLEX_PINS)
static void select_row(uint8_t row) {
for (uint8_t select = 0; select < MULTIPLEX; select++) {
writePin(select_pins[select], (row_pins[row] & (1 << select)));
}
}
static void init_pins(void) {
for (uint8_t select = 0; select < MULTIPLEX; select++) {
setPinOutput(select_pins[select]);
}
for (uint8_t x = 0; x < MATRIX_COLS; x++) {
setPinInputHigh(col_pins[x]);
}
}
# else
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; 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]);
}
}
# endif
static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row) {
// Select row and wait for row selecton to stabilize
select_row(current_row);
matrix_io_delay();
# if defined(PORTSCAN)
uint8_t port_state = ~PINx_ADDRESS(PORTSCAN) & PORTSCAN_PINS;
# ifndef MULTIPLEX_PINS
unselect_row(current_row);
# endif
if (current_matrix[current_row] != port_state) {
current_matrix[current_row] = port_state;
return true;
}
return false;
# else
matrix_row_t current_row_value = 0;
// 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);
}
# ifndef MULTIPLEX_PINS
// Unselect row
unselect_row(current_row);
# endif
// If the row has changed, store the row and return the changed flag.
if (current_matrix[current_row] != current_row_value) {
current_matrix[current_row] = current_row_value;
return true;
}
return false;
# endif
}
# elif (DIODE_DIRECTION == ROW2COL)
# if defined(MULTIPLEX_PINS)
static void select_col(uint8_t col) {
for (uint8_t select = 0; select < MULTIPLEX; select++) {
writePin(select_pins[select], col_pins[col] & (1 << select));
}
matrix_io_delay();
}
static void init_pins(void) {
for (uint8_t sel_index = 0; sel_index < MULTIPLEX; sel_index++) {
setPinOutput(select_pins[sel_index]);
}
for (uint8_t x = 0; x < MATRIX_ROWS; x++) {
setPinInputHigh(row_pins[x]);
}
}
# else
static void select_col(uint8_t col) {
setPinOutput(col_pins[col]);
writePinLow(col_pins[col]);
}
static void unselect_col(uint8_t col) { setPinInputHigh(col_pins[col]); }
static void unselect_cols(void) {
for (uint8_t x = 0; x < MATRIX_COLS; x++) {
setPinInputHigh(col_pins[x]);
}
}
static void init_pins(void) {
unselect_cols();
for (uint8_t x = 0; x < MATRIX_ROWS; x++) {
setPinInputHigh(row_pins[x]);
}
}
# endif
static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col) {
bool matrix_changed = false;
// Select col and wait for col selecton to stabilize
select_col(current_col);
matrix_io_delay();
// For each row...
for (uint8_t row_index = 0; row_index < MATRIX_ROWS; row_index++) {
// Store last value of row prior to reading
matrix_row_t last_row_value = current_matrix[row_index];
matrix_row_t current_row_value = last_row_value;
// Check row pin state
if (readPin(row_pins[row_index]) == 0) {
// Pin LO, set col bit
current_row_value |= (MATRIX_ROW_SHIFTER << current_col);
} else {
// Pin HI, clear col bit
current_row_value &= ~(MATRIX_ROW_SHIFTER << current_col);
}
// Determine if the matrix changed state
if ((last_row_value != current_row_value)) {
matrix_changed |= true;
current_matrix[row_index] = current_row_value;
}
}
// Unselect col
# ifndef MULTIPLEX_PINS
unselect_col(current_col);
# endif
return matrix_changed;
}
# else
# error DIODE_DIRECTION must be one of COL2ROW or ROW2COL!
# endif
#else
# error DIODE_DIRECTION is not defined!
#endif
void matrix_init_custom(void) {
// initialize key pins
init_pins();
}
uint8_t matrix_scan_custom(matrix_row_t current_matrix[]) {
bool changed = false;
#if defined(DIRECT_PINS) || (DIODE_DIRECTION == COL2ROW)
// Set row, read cols
for (uint8_t current_row = 0; current_row < MATRIX_ROWS; current_row++) {
changed |= read_cols_on_row(current_matrix, current_row);
}
#elif (DIODE_DIRECTION == ROW2COL)
// Set col, read rows
for (uint8_t current_col = 0; current_col < MATRIX_COLS; current_col++) {
changed |= read_rows_on_col(current_matrix, current_col);
}
#endif
return changed;
}

View File

@ -0,0 +1,3 @@
Ported from https://qmk.trashman.club/?keyboard=minivan_hs_rev1
Supports indicator lights for 3 layers

View File

@ -0,0 +1,37 @@
MCU = atmega32u4
F_CPU = 16000000
ARCH = AVR8
F_USB = 16000000
OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT
OPT_DEFS += -DBOOTLOADER_SIZE=4096
NO_USB_STARTUP_CHECK = yes
MOUSEKEY_ENABLE = yes
EXTRAKEY_ENABLE = yes
AUTO_SHIFT_ENABLE = yes
COMBO_ENABLE = yes
NKRO_ENABLE = yes
RGBLIGHT_ENABLE = yes
CUSTOM_MATRIX = lite
MIDI_ENABLE = no
AUDIO_ENABLE = no
BLUETOOTH_ENABLE = no
SRC += matrix.c
EXTRAFLAGS+=-flto
CONSOLE_ENABLE = no
COMMAND_ENABLE = no
VIA_ENABLE = yes
VIAL_ENABLE = yes
QMK_SETTINGS = yes
TAP_DANCE_ENABLE = no
KEY_OVERRIDE_ENABLE = no

View File

@ -0,0 +1,24 @@
{
"name": "Minivan",
"vendorId": "0xFEAE",
"productId": "0x8844",
"lighting": "qmk_rgblight",
"matrix": {
"rows": 4,
"cols": 12
},
"layouts": {
"keymap": [
[{"c":"#777777"},"0,0",{"c":"#cccccc"},"0,1","0,2","0,3","0,4","0,5","0,6","0,7","0,8","0,9","0,10",{"c":"#aaaaaa","w":1.75},"0,11"],
[{"w":1.25},"1,0",{"c":"#cccccc"},"1,1","1,2","1,3","1,4","1,5","1,6","1,7","1,8","1,9","1,10",{"c":"#aaaaaa","w":1.5},"1,11"],
[{"w":1.75},"2,0",{"c":"#cccccc"},"2,1","2,2","2,3","2,4","2,5","2,6","2,7","2,8","2,9","2,10\n\n\n0,0",{"c":"#aaaaaa"},"2,11"],
[{"w":1.25},"3,0\n\n\n1,0",{"w":1.5},"3,1\n\n\n1,0",{"w":1.25},"3,2\n\n\n1,0",{"c":"#777777","w":2.25},"3,3",{"c":"#aaaaaa","w":2},"3,7",{"w":1.25},"3,8\n\n\n0,0",{"w":1.5},"3,9\n\n\n0,0",{"w":1.75},"3,11\n\n\n0,0"],
[{"y":0.25,"x":10.75,"c":"#777777"},"2,10\n\n\n0,1"],
[{"c":"#aaaaaa"},"3,0\n\n\n1,1","3,1\n\n\n1,1","3,2\n\n\n1,1","3,4\n\n\n1,1",{"x":4.25,"w":1.5},"3,8\n\n\n0,1",{"c":"#777777"},"3,9\n\n\n0,1","3,10\n\n\n0,1","3,11\n\n\n0,1"]
],
"labels": [
"Arrows",
"Mac"
]
}
}