summaryrefslogtreecommitdiffstats
path: root/keyboards/keychron/k7_pro/k7_pro.c
diff options
context:
space:
mode:
authorlalalademaxiya1 <2831039915@qq.com>2023-10-20 09:48:07 +0800
committerlalalademaxiya1 <2831039915@qq.com>2023-10-20 09:48:07 +0800
commit9b56d621ca2e0769a720d4ae3e00064e6c0d111f (patch)
tree32030457a5ffd929ac6cf043210070ef2f475231 /keyboards/keychron/k7_pro/k7_pro.c
parent00af20f690b66b11c3c00826b5193a306b611ec4 (diff)
Add k7 pro iso version
Diffstat (limited to 'keyboards/keychron/k7_pro/k7_pro.c')
-rw-r--r--keyboards/keychron/k7_pro/k7_pro.c39
1 files changed, 29 insertions, 10 deletions
diff --git a/keyboards/keychron/k7_pro/k7_pro.c b/keyboards/keychron/k7_pro/k7_pro.c
index 24a83dc984..f62e5a69ed 100644
--- a/keyboards/keychron/k7_pro/k7_pro.c
+++ b/keyboards/keychron/k7_pro/k7_pro.c
@@ -29,16 +29,19 @@
# include "factory_test.h"
#endif
-#define POWER_ON_LED_DURATION 3000
+#ifdef BAT_LOW_LED_PIN
+static uint32_t power_on_indicator_timer_buffer;
+# define POWER_ON_LED_DURATION 3000
+#endif
typedef struct PACKED {
uint8_t len;
uint8_t keycode[3];
} key_combination_t;
-static uint32_t power_on_indicator_timer_buffer;
-static uint32_t siri_timer_buffer = 0;
-static uint8_t mac_keycode[4] = {KC_LOPT, KC_ROPT, KC_LCMD, KC_RCMD};
+static uint32_t factory_timer_buffer = 0;
+static uint32_t siri_timer_buffer = 0;
+static uint8_t mac_keycode[4] = {KC_LOPT, KC_ROPT, KC_LCMD, KC_RCMD};
key_combination_t key_comb_list[4] = {
{2, {KC_LWIN, KC_TAB}}, // Task (win)
@@ -48,7 +51,7 @@ key_combination_t key_comb_list[4] = {
};
#ifdef KC_BLUETOOTH_ENABLE
-bool firstDisconnect = true;
+bool firstDisconnect = true;
bool bt_factory_reset = false;
static virtual_timer_t pairing_key_timer;
extern uint8_t g_pwm_buffer[DRIVER_COUNT][192];
@@ -60,7 +63,11 @@ static void pairing_key_timer_cb(void *arg) {
bool dip_switch_update_kb(uint8_t index, bool active) {
if (index == 0) {
+#ifdef INVERT_OS_SWITCH_STATTE
+ default_layer_set(1UL << (!active ? 0 : 1));
+#else
default_layer_set(1UL << (active ? 0 : 1));
+#endif
}
dip_switch_update_user(index, active);
@@ -137,7 +144,8 @@ void keyboard_post_init_kb(void) {
#ifdef KC_BLUETOOTH_ENABLE
/* Currently we don't use this reset pin */
- palSetLineMode(CKBT51_RESET_PIN, PAL_MODE_UNCONNECTED);
+ palSetLineMode(CKBT51_RESET_PIN, PAL_MODE_OUTPUT_PUSHPULL);
+ palWriteLine(CKBT51_RESET_PIN, PAL_HIGH);
/* IMPORTANT: DO NOT enable internal pull-up resistor
* as there is an external pull-down resistor.
@@ -146,7 +154,7 @@ void keyboard_post_init_kb(void) {
ckbt51_init(false);
bluetooth_init();
-# endif
+#endif
power_on_indicator_timer_buffer = sync_timer_read32() | 1;
writePin(BAT_LOW_LED_PIN, BAT_LOW_LED_PIN_ON_STATE);
@@ -154,6 +162,16 @@ void keyboard_post_init_kb(void) {
}
void matrix_scan_kb(void) {
+ if (factory_timer_buffer && timer_elapsed32(factory_timer_buffer) > 2000) {
+ factory_timer_buffer = 0;
+ if (bt_factory_reset) {
+ bt_factory_reset = false;
+ palWriteLine(CKBT51_RESET_PIN, PAL_LOW);
+ wait_ms(5);
+ palWriteLine(CKBT51_RESET_PIN, PAL_HIGH);
+ }
+ }
+
if (power_on_indicator_timer_buffer) {
if (sync_timer_elapsed32(power_on_indicator_timer_buffer) > POWER_ON_LED_DURATION) {
power_on_indicator_timer_buffer = 0;
@@ -171,15 +189,15 @@ void matrix_scan_kb(void) {
#ifdef FACTORY_RESET_TASK
FACTORY_RESET_TASK();
-# endif
+#endif
matrix_scan_user();
}
#ifdef KC_BLUETOOTH_ENABLE
static void ckbt51_param_init(void) {
/* Set bluetooth device name */
- // ckbt51_set_local_name(STR(PRODUCT));
ckbt51_set_local_name(PRODUCT);
+ wait_ms(10);
/* Set bluetooth parameters */
module_param_t param = {.event_mode = 0x02,
.connected_idle_timeout = 7200,
@@ -191,12 +209,13 @@ static void ckbt51_param_init(void) {
.verndor_id = 0, // Must be 0x3434
.product_id = PRODUCT_ID};
ckbt51_set_param(&param);
+ wait_ms(10);
}
void bluetooth_enter_disconnected_kb(uint8_t host_idx) {
if (bt_factory_reset) {
- bt_factory_reset = false;
ckbt51_param_init();
+ factory_timer_buffer = timer_read32();
}
/* CKBT51 bluetooth module boot time is slower, it enters disconnected after boot,
so we place initialization here. */