mirror of
https://github.com/Keychron/qmk_firmware.git
synced 2024-11-22 00:16:41 +06:00
Update v8 knob include ansi and iso version
This commit is contained in:
parent
cc22ddb962
commit
9e06f87017
|
@ -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
|
||||
|
|
|
@ -22,8 +22,8 @@
|
|||
#define RGB_MATRIX_LED_COUNT (DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL)
|
||||
|
||||
/* Encoder Configuration */
|
||||
#define ENCODERS_PAD_A { A10 }
|
||||
#define ENCODERS_PAD_B { B5 }
|
||||
#define ENCODERS_PAD_A { B5 }
|
||||
#define ENCODERS_PAD_B { A10 }
|
||||
#define ENCODER_RESOLUTION 4
|
||||
#define ENCODER_DEFAULT_POS 0x3
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
"usb": {
|
||||
"vid": "0x3434",
|
||||
"pid": "0x0381",
|
||||
"device_version": "1.0.1"
|
||||
"device_version": "1.0.2"
|
||||
},
|
||||
"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
|
||||
|
|
|
@ -139,7 +139,7 @@ led_config_t g_led_config = {
|
|||
void encoder0_pad_cb(void *param) {
|
||||
(void)param;
|
||||
|
||||
encoder_insert_state();
|
||||
encoder_insert_state(0);
|
||||
}
|
||||
|
||||
void keyboard_post_init_kb(void) {
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
"usb": {
|
||||
"vid": "0x3434",
|
||||
"pid": "0x0383",
|
||||
"device_version": "1.0.1"
|
||||
"device_version": "1.0.2"
|
||||
},
|
||||
"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
|
||||
|
|
|
@ -139,7 +139,7 @@ led_config_t g_led_config = {
|
|||
void encoder0_pad_cb(void *param) {
|
||||
(void)param;
|
||||
|
||||
encoder_insert_state();
|
||||
encoder_insert_state(0);
|
||||
}
|
||||
|
||||
void keyboard_post_init_kb(void) {
|
||||
|
|
|
@ -56,6 +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};
|
||||
|
||||
// encoder counts
|
||||
static uint8_t thisCount;
|
||||
|
@ -221,10 +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) {
|
||||
if ((encoder_state[i] & 0x3) != new_status || encoder_external_update[i]) {
|
||||
encoder_state[i] <<= 2;
|
||||
encoder_state[i] |= new_status;
|
||||
changed |= encoder_update(i, encoder_state[i]);
|
||||
encoder_external_update[i] = false;
|
||||
}
|
||||
}
|
||||
return changed;
|
||||
|
@ -268,3 +270,10 @@ void encoder_update_raw(uint8_t *slave_state) {
|
|||
if (changed) last_encoder_activity_trigger();
|
||||
}
|
||||
#endif
|
||||
|
||||
void encoder_insert_state(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;
|
||||
}
|
||||
|
|
|
@ -25,6 +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);
|
||||
|
||||
#ifdef SPLIT_KEYBOARD
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user