mirror of
https://github.com/Keychron/qmk_firmware.git
synced 2024-11-22 00:16:41 +06:00
Update v2
This commit is contained in:
parent
9e06f87017
commit
77e6996b5c
|
@ -16,13 +16,6 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
/* COL2ROW or ROW2COL */
|
||||
#define DIODE_DIRECTION ROW2COL
|
||||
|
||||
/* key matrix pins */
|
||||
#define MATRIX_ROW_PINS { B4, B3, A15, A14, A13 }
|
||||
#define MATRIX_COL_PINS { C14, C15, A0, A1, A2, A3, A4, A5, A6, A7, B0, B1, A8, A9, H3 }
|
||||
|
||||
/* If uses PH3 with a stronger pull resistor then the following definition should be included */
|
||||
// #define MATRIX_UNSELECT_DRIVE_HIGH
|
||||
|
||||
|
@ -87,6 +80,10 @@
|
|||
#define ENABLE_RGB_MATRIX_PIXEL_RAIN
|
||||
// #define ENABLE_RGB_MATRIX_PIXEL_FLOW
|
||||
// #define ENABLE_RGB_MATRIX_PIXEL_FRACTAL
|
||||
|
||||
#define RGB_MATRIX_FRAMEBUFFER_EFFECTS
|
||||
#define RGB_MATRIX_KEYPRESSES
|
||||
|
||||
// enabled only if RGB_MATRIX_FRAMEBUFFER_EFFECTS is defined
|
||||
#define ENABLE_RGB_MATRIX_TYPING_HEATMAP
|
||||
#define ENABLE_RGB_MATRIX_DIGITAL_RAIN
|
||||
|
@ -103,11 +100,3 @@
|
|||
// #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
|
||||
|
||||
/* Enable receive custom command from host */
|
||||
#define RAW_HID_CMD 0xAB
|
||||
|
||||
#define HOLD_ON_OTHER_KEY_PRESS
|
||||
|
|
|
@ -35,80 +35,3 @@ bool dip_switch_update_kb(uint8_t index, bool active) {
|
|||
}
|
||||
|
||||
#endif // DIP_SWITCH_ENABLE
|
||||
|
||||
#if defined(RGB_MATRIX_ENABLE) && defined(CAPS_LOCK_LED_INDEX)
|
||||
|
||||
# define CAPS_LOCK_MAX_BRIGHTNESS 0xFF
|
||||
# ifdef RGB_MATRIX_MAXIMUM_BRIGHTNESS
|
||||
# undef CAPS_LOCK_MAX_BRIGHTNESS
|
||||
# define CAPS_LOCK_MAX_BRIGHTNESS RGB_MATRIX_MAXIMUM_BRIGHTNESS
|
||||
# endif
|
||||
|
||||
# define CAPS_LOCK_VAL_STEP 8
|
||||
# ifdef RGB_MATRIX_VAL_STEP
|
||||
# undef CAPS_LOCK_VAL_STEP
|
||||
# define CAPS_LOCK_VAL_STEP RGB_MATRIX_VAL_STEP
|
||||
# endif
|
||||
|
||||
extern void rgb_matrix_update_pwm_buffers(void);
|
||||
|
||||
static uint8_t light_brightness_get(void) {
|
||||
uint8_t value = rgb_matrix_get_val();
|
||||
if (value < CAPS_LOCK_VAL_STEP) {
|
||||
value = CAPS_LOCK_VAL_STEP;
|
||||
} else if (value < (CAPS_LOCK_MAX_BRIGHTNESS - CAPS_LOCK_VAL_STEP)) {
|
||||
value += CAPS_LOCK_VAL_STEP; // one step more than current brightness
|
||||
} else {
|
||||
value = CAPS_LOCK_MAX_BRIGHTNESS;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
bool rgb_matrix_indicators_kb(void) {
|
||||
if (!rgb_matrix_indicators_user()) {
|
||||
return false;
|
||||
}
|
||||
if (host_keyboard_led_state().caps_lock) {
|
||||
uint8_t v = light_brightness_get();
|
||||
rgb_matrix_set_color(CAPS_LOCK_LED_INDEX, v, v, v); // white, with the adjusted brightness
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void rgb_matrix_indicators_none_kb(void) {
|
||||
rgb_matrix_indicators_kb();
|
||||
rgb_matrix_update_pwm_buffers();
|
||||
}
|
||||
|
||||
bool led_update_kb(led_t led_state) {
|
||||
bool res = led_update_user(led_state);
|
||||
|
||||
if (rgb_matrix_is_enabled()
|
||||
# if defined(ENABLE_RGB_MATRIX_RAINDROPS)
|
||||
&& (rgb_matrix_get_mode() != RGB_MATRIX_RAINDROPS)
|
||||
# endif
|
||||
# if defined(ENABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS)
|
||||
&& (rgb_matrix_get_mode() != RGB_MATRIX_JELLYBEAN_RAINDROPS)
|
||||
# endif
|
||||
# if defined(ENABLE_RGB_MATRIX_PIXEL_RAIN)
|
||||
&& (rgb_matrix_get_mode() != RGB_MATRIX_PIXEL_RAIN)
|
||||
# endif
|
||||
) {
|
||||
return res;
|
||||
}
|
||||
|
||||
if (res) {
|
||||
if (led_state.caps_lock) {
|
||||
uint8_t v = light_brightness_get();
|
||||
rgb_matrix_set_color(CAPS_LOCK_LED_INDEX, v, v, v);
|
||||
} else {
|
||||
rgb_matrix_set_color(CAPS_LOCK_LED_INDEX, 0, 0, 0);
|
||||
}
|
||||
rgb_matrix_update_pwm_buffers();
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
#endif // CAPS_LOCK_LED_INDEX
|
||||
|
|
|
@ -24,9 +24,6 @@
|
|||
#define CKLED2001_CURRENT_TUNE { 0xCA, 0xCA, 0x60, 0xCA, 0xCA, 0x60, 0xCA, 0xCA, 0x60, 0xCA, 0xCA, 0x60 }
|
||||
|
||||
/* Encoder Configuration */
|
||||
#define ENCODERS_PAD_A { A10 }
|
||||
#define ENCODERS_PAD_B { B5 }
|
||||
#define ENCODER_RESOLUTION 4
|
||||
#define ENCODER_DEFAULT_POS 0x3
|
||||
|
||||
/* Enable caps-lock LED */
|
||||
|
|
|
@ -6,7 +6,17 @@
|
|||
"usb": {
|
||||
"vid": "0x3434",
|
||||
"pid": "0x0321",
|
||||
"device_version": "1.0.3"
|
||||
"device_version": "1.0.4"
|
||||
},
|
||||
"matrix_pins": {
|
||||
"cols": ["C14", "C15", "A0", "A1", "A2", "A3", "A4", "A5", "A6", "A7", "B0", "B1", "A8", "A9", "H3"],
|
||||
"rows": ["B4", "B3", "A15", "A14", "A13"]
|
||||
},
|
||||
"diode_direction": "ROW2COL",
|
||||
"encoder": {
|
||||
"rotary": [
|
||||
{"pin_a": "A10", "pin_b": "B5"}
|
||||
]
|
||||
},
|
||||
"processor": "STM32L432",
|
||||
"bootloader": "stm32-dfu",
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
#include QMK_KEYBOARD_H
|
||||
#include "keychron_common.h"
|
||||
#include "keychron_ft_common.h"
|
||||
|
||||
// clang-format off
|
||||
|
||||
|
@ -84,21 +85,10 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
|||
if (!process_record_keychron(keycode, record)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool dip_switch_update_user(uint8_t index, bool active) {
|
||||
if (!dip_switch_update_keychron(index, active)) {
|
||||
if (!process_record_keychron_ft(keycode, record)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef RGB_MATRIX_ENABLE
|
||||
bool rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) {
|
||||
if(!rgb_matrix_indicators_advanced_keychron(led_min, led_max)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
#endif // RGB_MATRIX_ENABLE
|
||||
|
|
|
@ -2,5 +2,4 @@ VIA_ENABLE = yes
|
|||
ENCODER_MAP_ENABLE = yes
|
||||
|
||||
VPATH += keyboards/keychron/common
|
||||
SRC += keychron_common.c
|
||||
SRC += keychron_factory_test_common.c
|
||||
SRC += keychron_common.c keychron_ft_common.c
|
||||
|
|
|
@ -7,8 +7,6 @@ EXTRAKEY_ENABLE = yes # Audio control and System control
|
|||
CONSOLE_ENABLE = no # Console for debug
|
||||
COMMAND_ENABLE = no # Commands for debug and configuration
|
||||
NKRO_ENABLE = yes # Enable USB N-key Rollover
|
||||
BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
|
||||
RGBLIGHT_ENABLE = no # Enable keyboard RGB underglow
|
||||
AUDIO_ENABLE = no # Audio output
|
||||
ENCODER_ENABLE = yes # Enable Encoder
|
||||
ENCODER_MAP_ENABLE = no
|
||||
|
|
|
@ -125,7 +125,7 @@ led_config_t g_led_config = {
|
|||
1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1,
|
||||
8, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, 1,
|
||||
1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, 1,
|
||||
1, 1, 1, 4, 1, 1, 1, 1, 1, 1
|
||||
1, 1, 1, 4, 1, 4, 1, 1, 1, 1
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -136,18 +136,36 @@ led_config_t g_led_config = {
|
|||
void encoder0_pad_cb(void *param) {
|
||||
(void)param;
|
||||
|
||||
encoder_insert_state();
|
||||
encoder_inerrupt_read(0);
|
||||
}
|
||||
|
||||
void keyboard_post_init_kb(void) {
|
||||
void encoder1_pad_cb(void *param) {
|
||||
(void)param;
|
||||
|
||||
encoder_inerrupt_read(1);
|
||||
}
|
||||
|
||||
void encoder_interrupt_init(void) {
|
||||
pin_t encoders_pad_a[NUM_ENCODERS] = ENCODERS_PAD_A;
|
||||
pin_t encoders_pad_b[NUM_ENCODERS] = ENCODERS_PAD_B;
|
||||
for (uint8_t i = 0; i < NUM_ENCODERS; i++) {
|
||||
palEnableLineEvent(encoders_pad_a[i], PAL_EVENT_MODE_BOTH_EDGES);
|
||||
palEnableLineEvent(encoders_pad_b[i], PAL_EVENT_MODE_BOTH_EDGES);
|
||||
palSetLineCallback(encoders_pad_a[i], encoder0_pad_cb, NULL);
|
||||
palSetLineCallback(encoders_pad_b[i], encoder0_pad_cb, NULL);
|
||||
}
|
||||
if (NUM_ENCODERS > 0) {
|
||||
palSetLineCallback(encoders_pad_a[0], encoder0_pad_cb, NULL);
|
||||
palSetLineCallback(encoders_pad_b[0], encoder0_pad_cb, NULL);
|
||||
}
|
||||
if (NUM_ENCODERS > 1) {
|
||||
palSetLineCallback(encoders_pad_a[1], encoder1_pad_cb, NULL);
|
||||
palSetLineCallback(encoders_pad_b[1], encoder1_pad_cb, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void keyboard_post_init_kb(void) {
|
||||
#if defined(ENCODER_ENABLE) && defined(PAL_USE_CALLBACKS)
|
||||
encoder_interrupt_init();
|
||||
#endif
|
||||
|
||||
// allow user keymaps to do custom post_init
|
||||
keyboard_post_init_user();
|
||||
|
|
|
@ -56,7 +56,7 @@ static int8_t encoder_LUT[] = {0, -1, 1, 0, 1, 0, 0, -1, -1, 0, 0, 1, 0, 1, -1,
|
|||
|
||||
static uint8_t encoder_state[NUM_ENCODERS] = {0};
|
||||
static int8_t encoder_pulses[NUM_ENCODERS] = {0};
|
||||
static bool encoder_external_update[NUM_ENCODERS] = {false};
|
||||
static bool encoder_interrupt_update[NUM_ENCODERS] = {false};
|
||||
|
||||
// encoder counts
|
||||
static uint8_t thisCount;
|
||||
|
@ -222,11 +222,11 @@ bool encoder_read(void) {
|
|||
bool changed = false;
|
||||
for (uint8_t i = 0; i < thisCount; i++) {
|
||||
uint8_t new_status = (readPin(encoders_pad_a[i]) << 0) | (readPin(encoders_pad_b[i]) << 1);
|
||||
if ((encoder_state[i] & 0x3) != new_status || encoder_external_update[i]) {
|
||||
if ((encoder_state[i] & 0x3) != new_status || encoder_interrupt_update[i]) {
|
||||
encoder_state[i] <<= 2;
|
||||
encoder_state[i] |= new_status;
|
||||
changed |= encoder_update(i, encoder_state[i]);
|
||||
encoder_external_update[i] = false;
|
||||
encoder_interrupt_update[i] = false;
|
||||
}
|
||||
}
|
||||
return changed;
|
||||
|
@ -271,9 +271,9 @@ void encoder_update_raw(uint8_t *slave_state) {
|
|||
}
|
||||
#endif
|
||||
|
||||
void encoder_insert_state(uint8_t index) {
|
||||
void encoder_inerrupt_read(uint8_t index) {
|
||||
encoder_state[index] <<= 2;
|
||||
encoder_state[index] |= (readPin(encoders_pad_a[index]) << 0) | (readPin(encoders_pad_b[index]) << 1);
|
||||
encoder_pulses[index] += encoder_LUT[encoder_state[index] & 0xF];
|
||||
encoder_external_update[index] = true;
|
||||
encoder_interrupt_update[index] = true;
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ bool encoder_read(void);
|
|||
|
||||
bool encoder_update_kb(uint8_t index, bool clockwise);
|
||||
bool encoder_update_user(uint8_t index, bool clockwise);
|
||||
void encoder_insert_state(uint8_t index);
|
||||
void encoder_inerrupt_read(uint8_t index);
|
||||
|
||||
#ifdef SPLIT_KEYBOARD
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user