Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add keychron k17 pro #184

Closed
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
641e435
Added K17_Pro
galican Sep 13, 2023
0eea17b
Updated k17_pro.
galican Sep 13, 2023
96deaf0
Added q10 pro
galican Sep 13, 2023
d5f9d52
Added q13 pro
galican Sep 14, 2023
0b99a7c
Update readme.md of q13 pro
galican Sep 14, 2023
74f18fc
Update info.json of q13 pro
galican Sep 14, 2023
0901e90
Update q13 pro
galican Sep 14, 2023
84f270f
delete common folder
galican Oct 16, 2023
681b85b
Update ansi_encoder version of k17 pro
galican Oct 20, 2023
2c37a31
Add iso version of k17 pro
galican Oct 23, 2023
657df4d
Update k17_pro
galican Oct 23, 2023
90d024d
Add iso version of k17 pro
galican Oct 24, 2023
0ac8ec0
Update keyboards/keychron/bluetooth/bluetooth.c
KeychronMacro Oct 26, 2023
ae55b49
Update keyboards/keychron/k17_pro/k17_pro.h
KeychronMacro Oct 26, 2023
b420836
Update keyboards/keychron/q10_pro/ansi_encoder/ansi_encoder.c
KeychronMacro Oct 26, 2023
ac83aeb
Update keyboards/keychron/q10_pro/ansi_encoder/config.h
KeychronMacro Oct 26, 2023
8fe9104
Update keyboards/keychron/q10_pro/config.h
KeychronMacro Oct 26, 2023
8150888
Update keyboards/keychron/q10_pro/iso_encoder/config.h
KeychronMacro Oct 26, 2023
acfaadd
Update keyboards/keychron/q10_pro/iso_encoder/iso_encoder.c
KeychronMacro Oct 26, 2023
ed09f71
Update keyboards/keychron/q13_pro/ansi_encoder/ansi_encoder.c
KeychronMacro Oct 26, 2023
1ad2c02
Update keyboards/keychron/q13_pro/iso_encoder/iso_encoder.c
KeychronMacro Oct 26, 2023
875f081
k17_pro_iso_encoder_rgb: Cancel the separate LED indication of caps a…
KeychronMacro Nov 10, 2023
cb377f0
k17_pro_iso_encoder_white: Caps lock individual indicator LED changed…
KeychronMacro Nov 13, 2023
411b064
k17_pro_iso_encoder_rgb: 1:Caps lock individual indicator LED changed…
KeychronMacro Nov 14, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions keyboards/keychron/bluetooth/bluetooth.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include <string.h>
#include "action.h"
#include "quantum.h"
#include "bluetooth.h"
Expand Down Expand Up @@ -291,7 +292,16 @@ uint8_t bluetooth_keyboard_leds(void) {
extern keymap_config_t keymap_config;

void bluetooth_send_keyboard(report_keyboard_t *report) {
if (bt_state == BLUETOOTH_PARING && !pincodeEntry) return;
/* Prevent keys from not bouncing back after shutdown due to low power */
KeychronMacro marked this conversation as resolved.
Show resolved Hide resolved
if (battery_is_critical_low()) {
report_keyboard_t empty_report;
memset(&empty_report, 0, sizeof(empty_report));
if (memcmp(keyboard_report, &empty_report, sizeof(report_keyboard_t)) != 0) {
return;
}
}

if ((bt_state == BLUETOOTH_PARING && !pincodeEntry)) return;

if (bt_state == BLUETOOTH_CONNECTED || (bt_state == BLUETOOTH_PARING && pincodeEntry)) {
#if defined(NKRO_ENABLE)
Expand Down Expand Up @@ -388,14 +398,17 @@ void bluetooth_send_extra(report_extra_t *report) {
}

void bluetooth_low_battery_shutdown(void) {
// static report_keyboard_t *report;

#if defined(BAT_LOW_LED_PIN) || defined(BAT_LOW_LED_PIN_STATE)
indicator_battery_low_enable(false);
#endif
#if defined(LOW_BAT_IND_INDEX)
indicator_battery_low_backlit_enable(false);
#endif

clear_keyboard();
send_keyboard_report();
wait_ms(50);

bluetooth_disconnect();
}
Expand Down
47 changes: 28 additions & 19 deletions keyboards/keychron/bluetooth/indicator.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
#include "config.h"
#include "rtc_timer.h"

#include "usb_main.h"

#if defined(LED_MATRIX_ENABLE) || defined(RGB_MATRIX_ENABLE)
# ifdef LED_MATRIX_ENABLE
# include "led_matrix.h"
Expand Down Expand Up @@ -55,11 +57,11 @@ static indicator_config_t pairing_config = INDICATOR_CONFIG_PARING;
static indicator_config_t connected_config = INDICATOR_CONFIG_CONNECTD;
static indicator_config_t reconnecting_config = INDICATOR_CONFIG_RECONNECTING;
static indicator_config_t disconnected_config = INDICATOR_CONFIG_DISCONNECTED;
indicator_config_t indicator_config;
static bluetooth_state_t indicator_state;
static uint16_t next_period;
static indicator_type_t type;
static uint32_t indicator_timer_buffer = 0;
indicator_config_t indicator_config;
static bluetooth_state_t indicator_state;
static uint16_t next_period;
static indicator_type_t type;
static uint32_t indicator_timer_buffer = 0;

#if defined(BAT_LOW_LED_PIN) || defined(BAT_LOW_LED_PIN_STATE)
static uint32_t bat_low_pin_indicator = 0;
Expand Down Expand Up @@ -96,10 +98,10 @@ static pin_t host_led_pin_list[HOST_DEVICES_COUNT] = HOST_LED_PIN_LIST;
# define SET_LED_BT(idx) led_matrix_set_value(idx, 255)
# define SET_LED_LOW_BAT(idx) led_matrix_set_value(idx, 255)
# define LED_DRIVER_IS_ENABLED led_matrix_is_enabled
# define LED_DRIVER_EECONFIG_RELOAD() \
# define LED_DRIVER_EECONFIG_RELOAD() \
eeprom_read_block(&led_matrix_eeconfig, EECONFIG_LED_MATRIX, sizeof(led_matrix_eeconfig)); \
if (!led_matrix_eeconfig.mode) { \
eeconfig_update_led_matrix_default(); \
if (!led_matrix_eeconfig.mode) { \
eeconfig_update_led_matrix_default(); \
}
# define LED_DRIVER_ALLOW_SHUTDOWN led_matrix_driver_allow_shutdown
# define LED_DRIVER_ENABLE_NOEEPROM led_matrix_enable_noeeprom
Expand All @@ -119,10 +121,10 @@ static pin_t host_led_pin_list[HOST_DEVICES_COUNT] = HOST_LED_PIN_LIST;
# define SET_LED_BT(idx) rgb_matrix_set_color(idx, 0, 0, 255)
# define SET_LED_LOW_BAT(idx) rgb_matrix_set_color(idx, 255, 0, 0)
# define LED_DRIVER_IS_ENABLED rgb_matrix_is_enabled
# define LED_DRIVER_EECONFIG_RELOAD() \
# define LED_DRIVER_EECONFIG_RELOAD() \
eeprom_read_block(&rgb_matrix_config, EECONFIG_RGB_MATRIX, sizeof(rgb_matrix_config)); \
if (!rgb_matrix_config.mode) { \
eeconfig_update_rgb_matrix_default(); \
if (!rgb_matrix_config.mode) { \
eeconfig_update_rgb_matrix_default(); \
}
# define LED_DRIVER_ALLOW_SHUTDOWN rgb_matrix_driver_allow_shutdown
# define LED_DRIVER_ENABLE_NOEEPROM rgb_matrix_enable_noeeprom
Expand Down Expand Up @@ -259,9 +261,9 @@ static void indicator_timer_cb(void *arg) {

if (idx < HOST_DEVICES_COUNT) {
if ((indicator_config.value & 0x80) && !time_up) {
writePin(host_led_pin_list[idx], HOST_LED_PIN_ON_STATE);
writePin(host_led_pin_list[idx], HOST_LED_PIN_ON_STATE);
} else {
writePin(host_led_pin_list[idx], !HOST_LED_PIN_ON_STATE);
writePin(host_led_pin_list[idx], !HOST_LED_PIN_ON_STATE);
}
}
}
Expand Down Expand Up @@ -517,7 +519,7 @@ bool LED_INDICATORS_KB(void) {
/* Prevent backlight flash caused by key activities */
if (battery_is_critical_low()) {
SET_ALL_LED_OFF();
return false;
return false;
}

# if (defined(LED_MATRIX_ENABLE) || defined(RGB_MATRIX_ENABLE)) && defined(LOW_BAT_IND_INDEX)
Expand Down Expand Up @@ -555,7 +557,7 @@ bool LED_INDICATORS_KB(void) {
} else
os_state_indicate();

return false;
return false;
}

bool led_update_kb(led_t led_state) {
Expand All @@ -564,22 +566,29 @@ bool led_update_kb(led_t led_state) {
led_update_ports(led_state);

if (!LED_DRIVER_IS_ENABLED()) {
# if defined(LED_MATRIX_DRIVER_SHUTDOWN_ENABLE) || defined(RGB_MATRIX_DRIVER_SHUTDOWN_ENABLE)
# if defined(LED_MATRIX_DRIVER_SHUTDOWN_ENABLE) || defined(RGB_MATRIX_DRIVER_SHUTDOWN_ENABLE)
LED_DRIVER.exit_shutdown();
# endif
# endif
SET_ALL_LED_OFF();
os_state_indicate();
LED_DRIVER.flush();
# if defined(LED_MATRIX_DRIVER_SHUTDOWN_ENABLE) || defined(RGB_MATRIX_DRIVER_SHUTDOWN_ENABLE)
# if defined(LED_MATRIX_DRIVER_SHUTDOWN_ENABLE) || defined(RGB_MATRIX_DRIVER_SHUTDOWN_ENABLE)
if (LED_DRIVER_ALLOW_SHUTDOWN()) LED_DRIVER.shutdown();
# endif
# endif
}
}

return res;
}

void LED_NONE_INDICATORS_KB(void) {
if (get_transport() == TRANSPORT_USB) {
# if defined(RGB_DISABLE_WHEN_USB_SUSPENDED) || defined(LED_DISABLE_WHEN_USB_SUSPENDED)
if (USB_DRIVER.state == USB_SUSPENDED) {
return;
}
# endif
}
os_state_indicate();
}

Expand Down
55 changes: 55 additions & 0 deletions keyboards/keychron/k17_pro/ansi_encoder/rgb/config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/* Copyright 2023 @ Keychron (https://www.keychron.com)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#pragma once

#ifdef RGB_MATRIX_ENABLE
/* RGB Matrix Driver Configuration */
# define DRIVER_COUNT 2
# define DRIVER_ADDR_1 0b1110111
# define DRIVER_ADDR_2 0b1110100

/* RGB Matrix Configuration */
# define DRIVER_1_LED_TOTAL 54
# define DRIVER_2_LED_TOTAL 49
# define RGB_MATRIX_LED_COUNT (DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL)

/* Set to infinit, which is use in USB mode by default */
# define RGB_MATRIX_TIMEOUT RGB_MATRIX_TIMEOUT_INFINITE

/* Allow to shutdown driver to save power */
# define RGB_MATRIX_DRIVER_SHUTDOWN_ENABLE

/* Turn off backllit if brightness value is low */
# define RGB_MATRIX_BRIGHTNESS_TURN_OFF_VAL 48

/* Indication led index */
# define NUM_LOCK_INDEX 34
# define CAPS_LOCK_INDEX 57
# define DIM_CAPS_LOCK
# define LOW_BAT_IND_INDEX 94

/* RGB Matrix Animation modes. Explicitly enabled
* For full list of effects, see:
* https://docs.qmk.fm/#/feature_rgb_matrix?id=rgb-matrix-effects
*/
# define RGB_MATRIX_FRAMEBUFFER_EFFECTS
# define RGB_MATRIX_KEYPRESSES

/* Set LED driver current */
# define CKLED2001_CURRENT_TUNE \
{ 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18 }
#endif
145 changes: 145 additions & 0 deletions keyboards/keychron/k17_pro/ansi_encoder/rgb/info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
{
"usb": {
"pid": "0x0206",
"device_version": "1.0.1"
},
"features": {
"rgb_matrix": true
},
"rgb_matrix": {
"driver": "CKLED2001",
"animations": {
"breathing": true,
"band_spiral_val": true,
"cycle_all": true,
"cycle_left_right": true,
"cycle_up_down": true,
"rainbow_moving_chevron": true,
"cycle_out_in": true,
"cycle_out_in_dual": true,
"cycle_pinwheel": true,
"cycle_spiral": true,
"dual_beacon": true,
"rainbow_beacon": true,
"jellybean_raindrops": true,
"pixel_rain": true,
"typing_heatmap": true,
"digital_rain": true,
"solid_reactive_simple": true,
"solid_reactive_multiwide": true,
"solid_reactive_multinexus": true,
"splash": true,
"solid_splash": true
},
"layout": [
{"matrix":[0, 0], "flags":1, "x":0, "y":0},
{"matrix":[0, 1], "flags":1, "x":12, "y":0},
{"matrix":[0, 2], "flags":1, "x":23, "y":0},
{"matrix":[0, 3], "flags":1, "x":35, "y":0},
{"matrix":[0, 4], "flags":1, "x":47, "y":0},
{"matrix":[0, 5], "flags":1, "x":58, "y":0},
{"matrix":[0, 6], "flags":1, "x":70, "y":0},
{"matrix":[0, 7], "flags":1, "x":82, "y":0},
{"matrix":[0, 8], "flags":1, "x":93, "y":0},
{"matrix":[0, 9], "flags":1, "x":105, "y":0},
{"matrix":[0, 10], "flags":1, "x":117, "y":0},
{"matrix":[0, 11], "flags":1, "x":128, "y":0},
{"matrix":[0, 12], "flags":1, "x":140, "y":0},
{"matrix":[0, 13], "flags":1, "x":152, "y":0},
{"matrix":[0, 14], "flags":1, "x":163, "y":0},
{"matrix":[0, 15], "flags":1, "x":176, "y":0},
{"matrix":[0, 16], "flags":1, "x":189, "y":0},
{"matrix":[0, 17], "flags":1, "x":201, "y":0},
{"matrix":[0, 18], "flags":1, "x":212, "y":0},

{"matrix":[1, 0], "flags":1, "x":0, "y":14},
{"matrix":[1, 1], "flags":8, "x":12, "y":14},
{"matrix":[1, 2], "flags":8, "x":23, "y":14},
{"matrix":[1, 3], "flags":8, "x":35, "y":14},
{"matrix":[1, 4], "flags":4, "x":47, "y":14},
{"matrix":[1, 5], "flags":4, "x":58, "y":14},
{"matrix":[1, 6], "flags":4, "x":70, "y":14},
{"matrix":[1, 7], "flags":4, "x":82, "y":14},
{"matrix":[1, 8], "flags":4, "x":93, "y":14},
{"matrix":[1, 9], "flags":4, "x":105, "y":14},
{"matrix":[1, 10], "flags":4, "x":117, "y":14},
{"matrix":[1, 11], "flags":4, "x":128, "y":14},
{"matrix":[1, 12], "flags":4, "x":140, "y":14},
{"matrix":[1, 14], "flags":1, "x":157, "y":14},
{"matrix":[1, 15], "flags":1, "x":176, "y":14},
{"matrix":[1, 16], "flags":8, "x":189, "y":14},
{"matrix":[1, 17], "flags":4, "x":201, "y":14},
{"matrix":[1, 18], "flags":4, "x":212, "y":14},
{"matrix":[1, 19], "flags":4, "x":224, "y":14},

{"matrix":[2, 0], "flags":1, "x":3, "y":26},
{"matrix":[2, 1], "flags":4, "x":17, "y":26},
{"matrix":[2, 2], "flags":4, "x":29, "y":26},
{"matrix":[2, 3], "flags":4, "x":41, "y":26},
{"matrix":[2, 4], "flags":4, "x":52, "y":26},
{"matrix":[2, 5], "flags":4, "x":64, "y":26},
{"matrix":[2, 6], "flags":4, "x":76, "y":26},
{"matrix":[2, 7], "flags":4, "x":87, "y":26},
{"matrix":[2, 8], "flags":4, "x":99, "y":26},
{"matrix":[2, 9], "flags":4, "x":111, "y":26},
{"matrix":[2, 10], "flags":4, "x":122, "y":26},
{"matrix":[2, 11], "flags":4, "x":134, "y":26},
{"matrix":[2, 12], "flags":4, "x":146, "y":26},
{"matrix":[2, 14], "flags":1, "x":160, "y":26},
{"matrix":[2, 15], "flags":1, "x":176, "y":26},
{"matrix":[2, 16], "flags":4, "x":189, "y":26},
{"matrix":[2, 17], "flags":4, "x":201, "y":26},
{"matrix":[2, 18], "flags":4, "x":212, "y":26},
{"matrix":[2, 19], "flags":4, "x":224, "y":33},

{"matrix":[3, 0], "flags":8, "x":4, "y":39},
{"matrix":[3, 1], "flags":4, "x":20, "y":39},
{"matrix":[3, 2], "flags":4, "x":32, "y":39},
{"matrix":[3, 3], "flags":4, "x":43, "y":39},
{"matrix":[3, 4], "flags":4, "x":55, "y":39},
{"matrix":[3, 5], "flags":4, "x":67, "y":39},
{"matrix":[3, 6], "flags":4, "x":79, "y":39},
{"matrix":[3, 7], "flags":4, "x":90, "y":39},
{"matrix":[3, 8], "flags":4, "x":102, "y":39},
{"matrix":[3, 9], "flags":4, "x":114, "y":39},
{"matrix":[3, 10], "flags":4, "x":125, "y":39},
{"matrix":[3, 11], "flags":4, "x":137, "y":39},
{"matrix":[3, 13], "flags":1, "x":156, "y":39},
{"matrix":[3, 15], "flags":1, "x":176, "y":39},
{"matrix":[3, 16], "flags":4, "x":189, "y":39},
{"matrix":[3, 17], "flags":4, "x":201, "y":39},
{"matrix":[3, 18], "flags":4, "x":212, "y":39},

{"matrix":[4, 0], "flags":1, "x":7, "y":51},
{"matrix":[4, 2], "flags":4, "x":26, "y":51},
{"matrix":[4, 3], "flags":4, "x":38, "y":51},
{"matrix":[4, 4], "flags":4, "x":50, "y":51},
{"matrix":[4, 5], "flags":4, "x":61, "y":51},
{"matrix":[4, 6], "flags":4, "x":73, "y":51},
{"matrix":[4, 7], "flags":4, "x":85, "y":51},
{"matrix":[4, 8], "flags":4, "x":96, "y":51},
{"matrix":[4, 9], "flags":4, "x":108, "y":51},
{"matrix":[4, 10], "flags":4, "x":120, "y":51},
{"matrix":[4, 11], "flags":4, "x":131, "y":51},
{"matrix":[4, 12], "flags":1, "x":147, "y":51},
{"matrix":[4, 14], "flags":1, "x":164, "y":51},
{"matrix":[4, 16], "flags":4, "x":189, "y":51},
{"matrix":[4, 17], "flags":4, "x":201, "y":51},
{"matrix":[4, 18], "flags":4, "x":212, "y":51},
{"matrix":[4, 19], "flags":4, "x":224, "y":58},

{"matrix":[5, 0], "flags":1, "x":1, "y":64},
{"matrix":[5, 1], "flags":1, "x":16, "y":64},
{"matrix":[5, 2], "flags":1, "x":31, "y":64},
{"matrix":[5, 6], "flags":4, "x":74, "y":64},
{"matrix":[5, 10], "flags":1, "x":117, "y":64},
{"matrix":[5, 11], "flags":1, "x":128, "y":64},
{"matrix":[5, 12], "flags":1, "x":140, "y":64},
{"matrix":[5, 13], "flags":1, "x":153, "y":64},
{"matrix":[5, 14], "flags":1, "x":164, "y":64},
{"matrix":[5, 15], "flags":1, "x":176, "y":64},
{"matrix":[5, 16], "flags":4, "x":195, "y":64},
{"matrix":[5, 18], "flags":4, "x":212, "y":64}
]
}
}
Loading
Loading