Skip to content

Commit

Permalink
Merge pull request vial-kb#494 from adophoxia/keychron-q11-fixup-merge
Browse files Browse the repository at this point in the history
Fix merge issue for Keychron Q11
  • Loading branch information
xyzz authored Jul 16, 2023
2 parents 1d91042 + e0a9458 commit 3f731f1
Show file tree
Hide file tree
Showing 28 changed files with 878 additions and 207 deletions.
116 changes: 0 additions & 116 deletions keyboards/keychron/q11/ansi_encoder/ansi_encoder.c
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@
#include "quantum.h"

#ifdef RGB_MATRIX_ENABLE

// clang-format off

const ckled2001_led PROGMEM g_ckled2001_leds[RGB_MATRIX_LED_COUNT] = {
/* Refer to IS31 manual for these locations
* driver
Expand Down Expand Up @@ -128,117 +125,4 @@ const ckled2001_led PROGMEM g_ckled2001_leds[RGB_MATRIX_LED_COUNT] = {
{0, G_1, I_1, H_1}, // Down
{0, G_7, I_7, H_7}, // Right
};

#define __ NO_LED

led_config_t g_led_config = {
{
// Key Matrix to LED Index
{ __, 0, 1, 2, 3, 4, 5, 6, __ },
{ 7, 8, 9, 10, 11, 12, 13, 14, __ },
{ 15, 16, 17, 18, 19, __, 20, 21, __ },
{ 22, 23, 24, 25, 26, 27, 28, __, __ },
{ 29, __, 30, 31, 32, 33, 34, 35, __ },
{ 36, 37, 38, 39, 40, __, 41, __, __ },
{ 42, 43, 44, 45, 46, 47, 48, 49, __ },
{ 50, 51, 52, 53, 54, 55, 56, __, 57 },
{ 58, 59, 60, 61, 62, 63, 64, 65, 66 },
{ 67, 68, 69, 70, 71, 72, __, 73, 74 },
{ 75, 76, 77, 78, 79, 80, __, 81, __ },
{ __, 82, 83, 84, 85, __, 86, 87, 88 },
},
{
// LED Index to Physical Position
{17,0}, {31,0}, {45,0}, {59,0}, {72,0}, {86,0}, {100,0},
{0,15}, {17,15}, {31,15}, {45,15}, {59,15}, {72,15}, {86,15}, {100,15},
{0,27}, {21,27}, {38,27}, {52,27}, {66,27}, {79,27}, {93,27},
{0,40}, {22,40}, {41,40}, {55,40}, {69,40}, {83,40}, {97,40},
{0,52}, {26,52}, {48,52}, {61,52}, {76,52}, {90,52}, {102,52},
{0,64}, {19,64}, {36,64}, {53,64}, {70,64}, {94,64},
{110,0}, {124,0}, {138,0}, {152,0}, {165,0}, {179,0}, {193,0}, {207,0},
{110,15}, {124,15}, {138,15}, {152,15}, {165,15}, {179,15}, {200,15}, {224,15},
{104,27}, {117,27}, {131,27}, {145,27}, {158,27}, {172,27}, {186,27}, {203,27}, {224,27},
{107,40}, {121,40}, {134,40}, {148,40}, {162,40}, {176,40}, {198,40}, {224,40},
{114,52}, {127,52}, {141,52}, {155,52}, {169,52}, {188,52}, {210,52},
{126,64}, {152,64}, {166,64}, {180,64}, {196,64}, {210,64}, {224,64},
},
{
// RGB LED Index to Flag
1, 1, 1, 1, 1, 1, 1,
1, 1, 4, 4, 4, 4, 4, 4,
1, 1, 4, 4, 4, 4, 4,
1, 8, 4, 4, 4, 4, 4,
1, 1, 4, 4, 4, 4, 4,
1, 1, 1, 1, 1, 4,
1, 1, 1, 1, 1, 1, 1, 1,
4, 4, 4, 4, 4, 4, 1, 1,
4, 4, 4, 4, 4, 4, 4, 4, 1,
4, 4, 4, 4, 4, 4, 1, 1,
4, 4, 4, 4, 4, 1, 1,
4, 1, 1, 1, 1, 1, 1,
}
};

// clang-format on

#endif

#define ADC_BUFFER_DEPTH 1
#define ADC_NUM_CHANNELS 1
#define ADC_SAMPLING_RATE ADC_SMPR_SMP_12P5
#define ADC_RESOLUTION ADC_CFGR_RES_10BITS

static int16_t analogReadPin_my(pin_t pin) {
ADCConfig adcCfg = {};
adcsample_t sampleBuffer[ADC_NUM_CHANNELS*ADC_BUFFER_DEPTH];
ADCDriver* targetDriver = &ADCD1;
ADCConversionGroup adcConversionGroup = {
.circular = FALSE,
.num_channels = (uint16_t)(ADC_NUM_CHANNELS),
.cfgr = ADC_RESOLUTION,
};

palSetLineMode(pin, PAL_MODE_INPUT_ANALOG);
switch (pin) {
case B0:
adcConversionGroup.smpr[2] = ADC_SMPR2_SMP_AN15(ADC_SAMPLING_RATE);
adcConversionGroup.sqr[0] = ADC_SQR1_SQ1_N(ADC_CHANNEL_IN15);
sampleBuffer[0] = 0;
break;
case B1:
adcConversionGroup.smpr[2] = ADC_SMPR2_SMP_AN16(ADC_SAMPLING_RATE);
adcConversionGroup.sqr[0] = ADC_SQR1_SQ1_N(ADC_CHANNEL_IN16);
sampleBuffer[0] = 0;
break;
default:
return 0;
}
adcStart(targetDriver, &adcCfg);
if (adcConvert(targetDriver, &adcConversionGroup, &sampleBuffer[0], ADC_BUFFER_DEPTH) != MSG_OK) {
return 0;
}

return *sampleBuffer;
}

void keyboard_post_init_kb(void) {
// 1. The pin A5/B5 of the USB C interface in the left hand is connected to the pin A0 of MCU,
// A0 will be set to output and write high when keyboard initial.
// 2. The same pin in the right hand is connected to the pin B0 and B1 of MCU respectively,
// and the ADC function of B0 and B1 will be enabled when keyboard initial.
// 3. because the serial usart RXD and TXD is multiplexed on USB's D+ and D- in the right hand.
// So detect the voltage on the pin A5/B5 of the USB C interface by ADC,
// and disable USB connectivity when the ADC value exceeds 1000,
// to avoid affecting the serial usart communication between the left hand and the right hand.
if (is_keyboard_left()) {
setPinOutput(A0);
writePinHigh(A0);
} else {
if ((analogReadPin_my(B0) > 1000) || (analogReadPin_my(B1) > 1000)) {
setPinInput(A11);
setPinInput(A12);
}
}

keyboard_post_init_user();
}
3 changes: 3 additions & 0 deletions keyboards/keychron/q11/ansi_encoder/config.h
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,8 @@

#pragma once

/* RGB Matrix Configuration */
#define RGB_MATRIX_LED_COUNT 89

/* Enable caps-lock LED */
#define CAPS_LOCK_LED_INDEX 23
Empty file modified keyboards/keychron/q11/ansi_encoder/info.json
100755 → 100644
Empty file.
12 changes: 5 additions & 7 deletions keyboards/keychron/q11/ansi_encoder/keymaps/default/keymap.c
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -15,44 +15,42 @@
*/
#include QMK_KEYBOARD_H

// clang-format off

enum layers{
MAC_BASE,
MAC_FN,
WIN_BASE,
WIN_FN
WIN_FN,
};

#define KC_TASK LGUI(KC_TAB)
#define KC_FLXP LGUI(KC_E)

const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[MAC_BASE] = LAYOUT_ansi_91(
[MAC_BASE] = LAYOUT_91_ansi(
KC_MUTE, KC_ESC, KC_BRID, KC_BRIU, KC_MCTL, KC_LPAD, RGB_VAD, RGB_VAI, KC_MPRV, KC_MPLY, KC_MNXT, KC_MUTE, KC_VOLD, KC_VOLU, KC_INS, KC_DEL, KC_MUTE,
_______, 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_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_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_HOME,
_______, 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_LOPT, KC_LCMD, MO(MAC_FN), KC_SPC, KC_SPC, KC_RCMD, MO(MAC_FN), KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT),

[MAC_FN] = LAYOUT_ansi_91(
[MAC_FN] = LAYOUT_91_ansi(
RGB_TOG, _______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, _______, _______, RGB_TOG,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, RGB_TOG, RGB_MOD, RGB_VAI, RGB_HUI, RGB_SAI, RGB_SPI, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, RGB_RMOD, RGB_VAD, RGB_HUD, RGB_SAD, RGB_SPD, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, NK_TOGG, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______),

[WIN_BASE] = LAYOUT_ansi_91(
[WIN_BASE] = LAYOUT_91_ansi(
KC_MUTE, 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_INS, KC_DEL, KC_MUTE,
_______, 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_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_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_HOME,
_______, 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_LWIN, KC_LALT, MO(WIN_FN), KC_SPC, KC_SPC, KC_RALT, MO(WIN_FN), KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT),

[WIN_FN] = LAYOUT_ansi_91(
[WIN_FN] = LAYOUT_91_ansi(
RGB_TOG, _______, KC_BRID, KC_BRIU, KC_TASK, KC_FLXP, RGB_VAD, RGB_VAI, KC_MPRV, KC_MPLY, KC_MNXT, KC_MUTE, KC_VOLD, KC_VOLU, _______, _______, RGB_TOG,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, RGB_TOG, RGB_MOD, RGB_VAI, RGB_HUI, RGB_SAI, RGB_SPI, _______, _______, _______, _______, _______, _______, _______, _______, _______,
Expand Down
Empty file modified keyboards/keychron/q11/ansi_encoder/keymaps/default/rules.mk
100755 → 100644
Empty file.
12 changes: 5 additions & 7 deletions keyboards/keychron/q11/ansi_encoder/keymaps/keychron/keymap.c
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -17,41 +17,39 @@
#include QMK_KEYBOARD_H
#include "keychron_common.h"

// clang-format off

enum layers{
MAC_BASE,
MAC_FN,
WIN_BASE,
WIN_FN
WIN_FN,
};

const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[MAC_BASE] = LAYOUT_ansi_91(
[MAC_BASE] = LAYOUT_91_ansi(
KC_MUTE, KC_ESC, KC_BRID, KC_BRIU, KC_MCTL, KC_LPAD, RGB_VAD, RGB_VAI, KC_MPRV, KC_MPLY, KC_MNXT, KC_MUTE, KC_VOLD, KC_VOLU, KC_INS, KC_DEL, KC_MUTE,
MC_1, 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_PGUP,
MC_2, 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_PGDN,
MC_3, 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_HOME,
MC_4, 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,
MC_5, KC_LCTL, KC_LOPTN, KC_LCMMD, MO(MAC_FN), KC_SPC, KC_SPC, KC_RCMMD, MO(MAC_FN), KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT),

[MAC_FN] = LAYOUT_ansi_91(
[MAC_FN] = LAYOUT_91_ansi(
RGB_TOG, _______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, _______, _______, RGB_TOG,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, RGB_TOG, RGB_MOD, RGB_VAI, RGB_HUI, RGB_SAI, RGB_SPI, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, RGB_RMOD, RGB_VAD, RGB_HUD, RGB_SAD, RGB_SPD, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, NK_TOGG, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______),

[WIN_BASE] = LAYOUT_ansi_91(
[WIN_BASE] = LAYOUT_91_ansi(
KC_MUTE, 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_INS, KC_DEL, KC_MUTE,
MC_1, 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_PGUP,
MC_2, 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_PGDN,
MC_3, 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_HOME,
MC_4, 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,
MC_5, KC_LCTL, KC_LWIN, KC_LALT, MO(WIN_FN), KC_SPC, KC_SPC, KC_RALT, MO(WIN_FN), KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT),

[WIN_FN] = LAYOUT_ansi_91(
[WIN_FN] = LAYOUT_91_ansi(
RGB_TOG, _______, KC_BRID, KC_BRIU, KC_TASK, KC_FLXP, RGB_VAD, RGB_VAI, KC_MPRV, KC_MPLY, KC_MNXT, KC_MUTE, KC_VOLD, KC_VOLU, _______, _______, RGB_TOG,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, RGB_TOG, RGB_MOD, RGB_VAI, RGB_HUI, RGB_SAI, RGB_SPI, _______, _______, _______, _______, _______, _______, _______, _______, _______,
Expand Down
Empty file modified keyboards/keychron/q11/ansi_encoder/keymaps/keychron/rules.mk
100755 → 100644
Empty file.
10 changes: 4 additions & 6 deletions keyboards/keychron/q11/ansi_encoder/keymaps/via/keymap.c
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

#include QMK_KEYBOARD_H

// clang-format off

enum layers{
MAC_BASE,
MAC_FN,
Expand All @@ -29,31 +27,31 @@ enum layers{
#define KC_FLXP LGUI(KC_E)

const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[MAC_BASE] = LAYOUT_ansi_91(
[MAC_BASE] = LAYOUT_91_ansi(
KC_MUTE, KC_ESC, KC_BRID, KC_BRIU, KC_MCTL, KC_LPAD, RGB_VAD, RGB_VAI, KC_MPRV, KC_MPLY, KC_MNXT, KC_MUTE, KC_VOLD, KC_VOLU, KC_INS, KC_DEL, KC_MUTE,
MC_1, 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_PGUP,
MC_2, 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_PGDN,
MC_3, 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_HOME,
MC_4, 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,
MC_5, KC_LCTL, KC_LOPT, KC_LCMD, MO(MAC_FN), KC_SPC, KC_SPC, KC_RCMD, MO(MAC_FN), KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT),

[MAC_FN] = LAYOUT_ansi_91(
[MAC_FN] = LAYOUT_91_ansi(
RGB_TOG, _______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, _______, _______, RGB_TOG,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, RGB_TOG, RGB_MOD, RGB_VAI, RGB_HUI, RGB_SAI, RGB_SPI, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, RGB_RMOD, RGB_VAD, RGB_HUD, RGB_SAD, RGB_SPD, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, NK_TOGG, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______),

[WIN_BASE] = LAYOUT_ansi_91(
[WIN_BASE] = LAYOUT_91_ansi(
KC_MUTE, 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_INS, KC_DEL, KC_MUTE,
MC_1, 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_PGUP,
MC_2, 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_PGDN,
MC_3, 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_HOME,
MC_4, 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,
MC_5, KC_LCTL, KC_LWIN, KC_LALT, MO(WIN_FN), KC_SPC, KC_SPC, KC_RALT, MO(WIN_FN), KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT),

[WIN_FN] = LAYOUT_ansi_91(
[WIN_FN] = LAYOUT_91_ansi(
RGB_TOG, _______, KC_BRID, KC_BRIU, KC_TASK, KC_FLXP, RGB_VAD, RGB_VAI, KC_MPRV, KC_MPLY, KC_MNXT, KC_MUTE, KC_VOLD, KC_VOLU, _______, _______, RGB_TOG,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, RGB_TOG, RGB_MOD, RGB_VAI, RGB_HUI, RGB_SAI, RGB_SPI, _______, _______, _______, _______, _______, _______, _______, _______, _______,
Expand Down
Empty file modified keyboards/keychron/q11/ansi_encoder/keymaps/via/rules.mk
100755 → 100644
Empty file.
2 changes: 1 addition & 1 deletion keyboards/keychron/q11/ansi_encoder/keymaps/vial/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#pragma once

#define VIAL_KEYBOARD_UID {0x63, 0x39, 0x38, 0xEA, 0x3A, 0x46, 0x3E, 0x9F}
#define VIAL_KEYBOARD_UID {0x5C, 0x2B, 0xB4, 0x2A, 0x60, 0xB3, 0x8B, 0x46}

#define VIAL_UNLOCK_COMBO_ROWS { 0, 9 }
#define VIAL_UNLOCK_COMBO_COLS { 1, 7 }
Loading

0 comments on commit 3f731f1

Please sign in to comment.