diff options
author | lokher <lokher@gmail.com> | 2023-10-25 15:10:57 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-25 15:10:57 +0800 |
commit | 10ffaf7417c41e52649bd85471986e7ec2273213 (patch) | |
tree | d4cca4586904087c1440500815207aea1b153f16 /keyboards/keychron/k8_pro/k8_pro.c | |
parent | d72ae351eabcf2baec05436b1e479182863bfda2 (diff) | |
parent | 891e47ce2c98139ec50352e67894761df35d384a (diff) |
Merge pull request #187 from KeychronMacro/keychron_k8_pro
Keychron k8 pro jis version
Diffstat (limited to 'keyboards/keychron/k8_pro/k8_pro.c')
-rw-r--r-- | keyboards/keychron/k8_pro/k8_pro.c | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/keyboards/keychron/k8_pro/k8_pro.c b/keyboards/keychron/k8_pro/k8_pro.c index 5fb63f9c6b..ba0cd7e819 100644 --- a/keyboards/keychron/k8_pro/k8_pro.c +++ b/keyboards/keychron/k8_pro/k8_pro.c @@ -36,9 +36,10 @@ typedef struct PACKED { 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 power_on_indicator_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) @@ -60,7 +61,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_STATE + default_layer_set(1UL << (!active ? 2 : 0)); +#else default_layer_set(1UL << (active ? 2 : 0)); +#endif } dip_switch_update_user(index, active); @@ -137,7 +142,9 @@ 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_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. @@ -159,6 +166,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; @@ -190,6 +207,7 @@ 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, @@ -201,12 +219,13 @@ static void ckbt51_param_init(void) { .verndor_id = 0, // Must be 0x3434 .product_id = PRODUCT_ID}; ckbt51_set_param(¶m); + 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. */ |