Skip to content

Commit b0c91d3

Browse files
authoredApr 15, 2024
Clarify bound on number of Bluetooth profile colors (#20)
1 parent b2ea092 commit b0c91d3

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] = {
@@ -295,12 +297,13 @@ static void zmk_rgb_underglow_effect_kinesis() {
295297

296298
// set second led to bluetooth state, blinking quickly if bluetooth not paired,
297299
// and slowly if not connected
300+
int bt_idx = zmk_ble_active_profile_index();
298301
if (zmk_ble_active_profile_is_open()) {
299302
bt_blinking = zmk_kinesis_blink_step(0, 2);
300303
} else if (!zmk_ble_active_profile_is_connected()) {
301304
bt_blinking = zmk_kinesis_blink_step(1, 13);
302305
}
303-
pixels[1] = bt_blinking ? LED_RGB(0x000000) : BT_COLORS[zmk_ble_active_profile_index()];
306+
pixels[1] = (bt_idx < NUM_BT_COLORS && !bt_blinking) ? BT_COLORS[bt_idx] : LED_RGB(0x000000);
304307

305308
// set third led to layer state
306309
pixels[2] = LAYER_COLORS[layer_color_left];

0 commit comments

Comments
 (0)