Skip to content

Commit 6fa491e

Browse files
committedApr 11, 2024
Clarify bound on number of Bluetooth profile colors
1 parent 8855e0b commit 6fa491e

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed
 

‎app/src/rgb_underglow.c

+6-3
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,10 @@ static void zmk_rgb_underglow_central_send() {
227227
}
228228
}
229229

230-
static const struct led_rgb BT_COLORS[8] = {LED_RGB(0xFFFFFF), LED_RGB(0x0000FF), LED_RGB(0xFF0000),
231-
LED_RGB(0x00FF00), LED_RGB(0x000000)};
230+
#define NUM_BT_COLORS 4
231+
232+
static const struct led_rgb BT_COLORS[NUM_BT_COLORS] = {LED_RGB(0xFFFFFF), LED_RGB(0x0000FF),
233+
LED_RGB(0xFF0000), LED_RGB(0x00FF00)};
232234
#endif
233235

234236
static const struct led_rgb LAYER_COLORS[8] = {
@@ -290,12 +292,13 @@ static void zmk_rgb_underglow_effect_kinesis() {
290292

291293
// set second led to bluetooth state, blinking quickly if bluetooth not paired,
292294
// and slowly if not connected
295+
int bt_idx = zmk_ble_active_profile_index();
293296
if (zmk_ble_active_profile_is_open()) {
294297
bt_blinking = zmk_kinesis_blink_step(0, 2);
295298
} else if (!zmk_ble_active_profile_is_connected()) {
296299
bt_blinking = zmk_kinesis_blink_step(1, 13);
297300
}
298-
pixels[1] = bt_blinking ? LED_RGB(0x000000) : BT_COLORS[zmk_ble_active_profile_index()];
301+
pixels[1] = (bt_idx < NUM_BT_COLORS && !bt_blinking) ? BT_COLORS[bt_idx] : LED_RGB(0x000000);
299302

300303
// set third led to layer state
301304
pixels[2] = LAYER_COLORS[layer_color_left];

0 commit comments

Comments
 (0)