summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlokher <lokher@gmail.com>2022-08-10 15:19:01 +0800
committerlokher <lokher@gmail.com>2022-08-12 15:30:02 +0800
commit5c61a8b0bcd153b7c393e887794747a5e7821a78 (patch)
tree72637eaa1799cd15594c7829012b23a9e3f1596b
parentc3f7cee76404e15b90bb399f3eebb34ec2a47354 (diff)
Fix indicating bug
-rw-r--r--keyboards/keychron/bluetooth/bat_level_animation.c14
-rw-r--r--keyboards/keychron/bluetooth/bluetooth.c11
-rw-r--r--keyboards/keychron/bluetooth/factory_test.c28
-rw-r--r--keyboards/keychron/bluetooth/indicator.c4
-rw-r--r--keyboards/keychron/bluetooth/transport.c2
5 files changed, 31 insertions, 28 deletions
diff --git a/keyboards/keychron/bluetooth/bat_level_animation.c b/keyboards/keychron/bluetooth/bat_level_animation.c
index 94a21f11e1..83a4f91cae 100644
--- a/keyboards/keychron/bluetooth/bat_level_animation.c
+++ b/keyboards/keychron/bluetooth/bat_level_animation.c
@@ -24,11 +24,10 @@ enum {
BAT_LVL_ANI_BLINK_ON,
};
-static uint8_t animation_state;
-static uint32_t bat_lvl_ani_timer_buffer;
+static uint8_t animation_state = 0;
+static uint32_t bat_lvl_ani_timer_buffer = 0;
static uint8_t bat_percentage;
static uint8_t cur_percentage;
-static uint8_t bat_lvl_led_list[10] = BAT_LEVEL_LED_LIST;
static uint32_t time_interval;
#ifdef RGB_MATRIX_ENABLE
static uint8_t r, g, b;
@@ -61,6 +60,8 @@ bool bat_level_animiation_actived(void) {
void bat_level_animiation_indicate(void) {
#ifdef LED_MATRIX_ENABLE
+ uint8_t bat_lvl_led_list[10] = BAT_LEVEL_LED_LIST;
+
for (uint8_t i = 0; i <= DRIVER_LED_TOTAL; i++) {
led_matrix_set_value(i, 0);
}
@@ -71,14 +72,17 @@ void bat_level_animiation_indicate(void) {
#endif
#ifdef RGB_MATRIX_ENABLE
+ uint8_t bat_lvl_led_list[10] = BAT_LEVEL_LED_LIST;
+
for (uint8_t i = 0; i <= DRIVER_LED_TOTAL; i++) {
rgb_matrix_set_color(i, 0, 0, 0);
}
- if (animation_state == BAT_LVL_ANI_GROWING || animation_state == BAT_LVL_ANI_BLINK_ON)
+ if (animation_state == BAT_LVL_ANI_GROWING || animation_state == BAT_LVL_ANI_BLINK_ON) {
for (uint8_t i = 0; i < cur_percentage / 10; i++) {
rgb_matrix_set_color(bat_lvl_led_list[i], r, g, b);
}
+ }
#endif
}
@@ -109,7 +113,7 @@ void bat_level_animiation_update(void) {
case BAT_LVL_ANI_BLINK_ON:
animation_state = BAT_LVL_ANI_NONE;
- if (indicator_config.value == 0 && indicator_is_backlit_enabled_eeprom()) {
+ if (indicator_config.value == 0 && !indicator_is_backlit_enabled_eeprom()) {
indicator_disable();
}
break;
diff --git a/keyboards/keychron/bluetooth/bluetooth.c b/keyboards/keychron/bluetooth/bluetooth.c
index ba71b2b05a..10c79257a9 100644
--- a/keyboards/keychron/bluetooth/bluetooth.c
+++ b/keyboards/keychron/bluetooth/bluetooth.c
@@ -28,6 +28,15 @@ extern report_buffer_t kb_rpt;
extern uint32_t retry_time_buffer;
extern uint8_t retry;
+#ifdef NKRO_ENABLE
+typedef struct {
+ bool usb : 1;
+ bool bluetooth : 1;
+} nkro_t;
+
+extern nkro_t nkro;
+#endif
+
static uint8_t host_index = 0;
static uint8_t led_state = 0;
@@ -198,7 +207,7 @@ static void bluetooth_enter_connected(uint8_t host_idx) {
/* Enable NKRO since it may be disabled in pin code entry */
#if defined(NKRO_ENABLE) && defined(BLUETOOTH_NKRO_ENABLE)
- keymap_config.nkro = true;
+ keymap_config.nkro = nkro.bluetooth;
#else
keymap_config.nkro = false;
#endif
diff --git a/keyboards/keychron/bluetooth/factory_test.c b/keyboards/keychron/bluetooth/factory_test.c
index 10fdf24d17..10286c52df 100644
--- a/keyboards/keychron/bluetooth/factory_test.c
+++ b/keyboards/keychron/bluetooth/factory_test.c
@@ -179,42 +179,30 @@ void process_record_factory_reset(uint16_t keycode, keyrecord_t *record) {
}
#ifdef LED_MATRIX_ENABLE
-void led_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) {
+void led_matrix_indicators_user(void) {
if (factory_reset_ind_state) {
- for (uint8_t i = led_min; i <= led_max; i++) {
- led_matrix_set_value(i, factory_reset_ind_state % 2 ? 0 : 255);
- }
+ led_matrix_set_value_all(factory_reset_ind_state % 2 ? 0 : 255)
}
}
#endif
#ifdef RGB_MATRIX_ENABLE
-void rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) {
+void rgb_matrix_indicators_user(void) {
if (factory_reset_ind_state) {
- for (uint8_t i = led_min; i <= led_max; i++) {
- rgb_matrix_set_color(i, factory_reset_ind_state % 2 ? 0 : 255, 0, 0);
- }
+ rgb_matrix_set_color_all(factory_reset_ind_state % 2 ? 0 : 255, 0, 0);
} else if (backlight_test_mode) {
switch (backlight_test_mode) {
case BACKLIGHT_TEST_WHITE:
- for (uint8_t i = led_min; i <= led_max; i++) {
- rgb_matrix_set_color(i, 255, 255, 255);
- }
+ rgb_matrix_set_color_all(255, 255, 255);
break;
case BACKLIGHT_TEST_RED:
- for (uint8_t i = led_min; i <= led_max; i++) {
- rgb_matrix_set_color(i, 255, 0, 0);
- }
+ rgb_matrix_set_color_all(255, 0, 0);
break;
case BACKLIGHT_TEST_GREEN:
- for (uint8_t i = led_min; i <= led_max; i++) {
- rgb_matrix_set_color(i, 0, 255, 0);
- }
+ rgb_matrix_set_color_all(0, 255, 0);
break;
case BACKLIGHT_TEST_BLUE:
- for (uint8_t i = led_min; i <= led_max; i++) {
- rgb_matrix_set_color(i, 0, 0, 255);
- }
+ rgb_matrix_set_color_all(0, 0, 255);
break;
}
}
diff --git a/keyboards/keychron/bluetooth/indicator.c b/keyboards/keychron/bluetooth/indicator.c
index 0936f4ea97..bfe0f5cb17 100644
--- a/keyboards/keychron/bluetooth/indicator.c
+++ b/keyboards/keychron/bluetooth/indicator.c
@@ -65,7 +65,7 @@ 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;
+static uint32_t indicator_timer_buffer = 0;
static uint32_t battery_low_indicator = 0;
#if defined(LED_MATRIX_ENABLE) || defined(RGB_MATRIX_ENABLE)
@@ -79,6 +79,8 @@ static pin_t host_led_pin_list[HOST_DEVICES_COUNT] = HOST_LED_PIN_LIST;
#endif
void indicator_init(void) {
+ memset(&indicator_config, 0, sizeof(indicator_config));
+
#ifdef HOST_LED_PIN_LIST
for (uint8_t i = 0; i < HOST_DEVICES_COUNT; i++) {
setPinOutput(host_led_pin_list[i]);
diff --git a/keyboards/keychron/bluetooth/transport.c b/keyboards/keychron/bluetooth/transport.c
index d011fb558f..09fe99cf88 100644
--- a/keyboards/keychron/bluetooth/transport.c
+++ b/keyboards/keychron/bluetooth/transport.c
@@ -28,7 +28,7 @@ extern keymap_config_t keymap_config;
static transport_t transport = TRANSPORT_USB;
#ifdef NKRO_ENABLE
-static nkro_t nkro = {false, false};
+nkro_t nkro = {false, false};
#endif
static void transport_changed(transport_t new_transport);