Skip to content

Commit

Permalink
Fix broken CI builds on Zephyr 3.2 (#6)
Browse files Browse the repository at this point in the history
* fix(backlight/tests): Restore original behaviour to fix backlight tests

* fix(build): Remove feature-specific code when SPLIT_BLE, RGB_UNDERGLOW or BACKLIGHT isn't enabled

* refactor(bluetooth): Add battery reporting config.

* Add dedicated battery reporting Kconfig that is `imply`d by
  enabling ZMK_BLE.

* fix(rgb_underglow): Use correct condition in service.c

* Revert "refactor(bluetooth): Add battery reporting config."

This reverts commit 881da25.

---------

Co-authored-by: Peter Johanson <[email protected]>
  • Loading branch information
DerDreschner and petejohanson authored Jul 31, 2023
1 parent 4b5ecbc commit 93bf512
Show file tree
Hide file tree
Showing 11 changed files with 55 additions and 2 deletions.
7 changes: 6 additions & 1 deletion app/include/zmk/split/bluetooth/central.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,10 @@
int zmk_split_bt_invoke_behavior(uint8_t source, struct zmk_behavior_binding *binding,
struct zmk_behavior_binding_event event, bool state);

#if IS_ENABLED(CONFIG_ZMK_RGB_UNDERGLOW)
int zmk_split_bt_update_led(struct zmk_periph_led *periph);
int zmk_split_bt_update_bl(struct backlight_state *periph);
#endif

#if IS_ENABLED(CONFIG_ZMK_BACKLIGHT)
int zmk_split_bt_update_bl(struct backlight_state *periph);
#endif
6 changes: 5 additions & 1 deletion app/include/zmk/split/bluetooth/service.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,19 @@ struct zmk_split_run_behavior_payload {
char behavior_dev[ZMK_SPLIT_RUN_BEHAVIOR_DEV_LEN];
} __packed;

#if IS_ENABLED(CONFIG_ZMK_RGB_UNDERGLOW)
struct zmk_split_update_led_data {
uint8_t layer;
uint8_t indicators;
} __packed;
#endif

#if IS_ENABLED(CONFIG_ZMK_BACKLIGHT)
struct zmk_split_update_bl_data {
uint8_t brightness;
bool on;
} __packed;
#endif

int zmk_split_bt_position_pressed(uint8_t position);
int zmk_split_bt_position_released(uint8_t position);
int zmk_split_bt_position_released(uint8_t position);
6 changes: 6 additions & 0 deletions app/src/rgb_underglow.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ static struct rgb_underglow_state state;

static struct zmk_periph_led led_data;

#if IS_ENABLED(CONFIG_ZMK_SPLIT_BLE)
static bool last_ble_state[2];
#endif

static bool triggered;

Expand Down Expand Up @@ -328,6 +330,7 @@ static void zmk_rgb_underglow_effect_kinesis() {
zmk_rgb_underglow_central_send();
}
#else
#if IS_ENABLED(CONFIG_ZMK_SPLIT_BLE)
// leds for peripheral(right) side
/* if (zmk_ble_active_profile_is_open()) {
pixels[0].r = CONFIG_ZMK_RGB_UNDERGLOW_BRT_SCALE * last_ble_state[0];
Expand Down Expand Up @@ -361,6 +364,7 @@ static void zmk_rgb_underglow_effect_kinesis() {
}
state.animation_step++;
} else {
#endif
// set first led as LED_NUMLOCK
pixels[2].r =
(led_data.indicators & ZMK_LED_NUMLOCK_BIT) * CONFIG_ZMK_RGB_UNDERGLOW_BRT_SCALE;
Expand Down Expand Up @@ -423,8 +427,10 @@ static void zmk_rgb_underglow_effect_kinesis() {
pixels[0].b = 0;
break;
}
#if IS_ENABLED(CONFIG_ZMK_SPLIT_BLE)
}
#endif
#endif
}

static void zmk_rgb_underglow_effect_test() {
Expand Down
11 changes: 11 additions & 0 deletions app/src/split/bluetooth/central.c
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,7 @@ int zmk_split_bt_invoke_behavior(uint8_t source, struct zmk_behavior_binding *bi
return split_bt_invoke_behavior_payload(wrapper);
}

#if IS_ENABLED(CONFIG_ZMK_RGB_UNDERGLOW)
K_THREAD_STACK_DEFINE(split_central_split_led_q_stack,
CONFIG_ZMK_SPLIT_BLE_CENTRAL_SPLIT_LED_STACK_SIZE);

Expand Down Expand Up @@ -686,7 +687,9 @@ int zmk_split_bt_update_led(struct zmk_periph_led *periph) {

return split_bt_update_led_payload(payload);
}
#endif

#if IS_ENABLED(CONFIG_ZMK_BACKLIGHT)
K_THREAD_STACK_DEFINE(split_central_split_bl_q_stack,
CONFIG_ZMK_SPLIT_BLE_CENTRAL_SPLIT_BL_STACK_SIZE);

Expand Down Expand Up @@ -744,17 +747,25 @@ int zmk_split_bt_update_bl(struct backlight_state *periph) {

return split_bt_update_bl_payload(payload);
}
#endif

int zmk_split_bt_central_init(const struct device *_arg) {
k_work_queue_start(&split_central_split_run_q, split_central_split_run_q_stack,
K_THREAD_STACK_SIZEOF(split_central_split_run_q_stack),
CONFIG_ZMK_BLE_THREAD_PRIORITY, NULL);

#if IS_ENABLED(CONFIG_ZMK_RGB_UNDERGLOW)
k_work_queue_start(&split_central_split_led_q, split_central_split_led_q_stack,
K_THREAD_STACK_SIZEOF(split_central_split_led_q_stack),
CONFIG_ZMK_BLE_THREAD_PRIORITY, NULL);
#endif

#if IS_ENABLED(CONFIG_ZMK_BACKLIGHT)
k_work_queue_start(&split_central_split_bl_q, split_central_split_bl_q_stack,
K_THREAD_STACK_SIZEOF(split_central_split_bl_q_stack),
CONFIG_ZMK_BLE_THREAD_PRIORITY, NULL);
#endif

bt_conn_cb_register(&conn_callbacks);

return start_scan();
Expand Down
17 changes: 17 additions & 0 deletions app/src/split/bluetooth/service.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,14 @@ static uint8_t num_of_positions = ZMK_KEYMAP_LEN;
static uint8_t position_state[POS_STATE_LEN];

static struct zmk_split_run_behavior_payload behavior_run_payload;

#if IS_ENABLED(CONFIG_ZMK_RGB_UNDERGLOW)
static struct zmk_split_update_led_data update_led_data;
#endif

#if IS_ENABLED(CONFIG_ZMK_BACKLIGHT)
static struct zmk_split_update_bl_data update_bl_data;
#endif

static ssize_t split_svc_pos_state(struct bt_conn *conn, const struct bt_gatt_attr *attrs,
void *buf, uint16_t len, uint16_t offset) {
Expand Down Expand Up @@ -83,6 +89,7 @@ static ssize_t split_svc_run_behavior(struct bt_conn *conn, const struct bt_gatt
return len;
}

#if IS_ENABLED(CONFIG_ZMK_RGB_UNDERGLOW)
static ssize_t split_svc_update_led(struct bt_conn *conn, const struct bt_gatt_attr *attrs,
const void *buf, uint16_t len, uint16_t offset, uint8_t flags) {
struct zmk_split_update_led_data *payload = attrs->user_data;
Expand All @@ -103,7 +110,9 @@ static ssize_t split_svc_update_led(struct bt_conn *conn, const struct bt_gatt_a

return len;
}
#endif

#if IS_ENABLED(CONFIG_ZMK_BACKLIGHT)
static ssize_t split_svc_update_bl(struct bt_conn *conn, const struct bt_gatt_attr *attrs,
const void *buf, uint16_t len, uint16_t offset, uint8_t flags) {
struct zmk_split_update_bl_data *payload = attrs->user_data;
Expand All @@ -124,6 +133,7 @@ static ssize_t split_svc_update_bl(struct bt_conn *conn, const struct bt_gatt_at

return len;
}
#endif

static ssize_t split_svc_num_of_positions(struct bt_conn *conn, const struct bt_gatt_attr *attrs,
void *buf, uint16_t len, uint16_t offset) {
Expand All @@ -143,12 +153,19 @@ BT_GATT_SERVICE_DEFINE(
BT_GATT_CHARACTERISTIC(BT_UUID_DECLARE_128(ZMK_SPLIT_BT_CHAR_RUN_BEHAVIOR_UUID),
BT_GATT_CHRC_WRITE_WITHOUT_RESP, BT_GATT_PERM_WRITE_ENCRYPT, NULL,
split_svc_run_behavior, &behavior_run_payload),

#if IS_ENABLED(CONFIG_ZMK_RGB_UNDERGLOW)
BT_GATT_CHARACTERISTIC(BT_UUID_DECLARE_128(ZMK_SPLIT_BT_CHAR_UPDATE_LED_UUID),
BT_GATT_CHRC_WRITE_WITHOUT_RESP, BT_GATT_PERM_WRITE_ENCRYPT, NULL,
split_svc_update_led, &update_led_data),
#endif

#if IS_ENABLED(CONFIG_ZMK_BACKLIGHT)
BT_GATT_CHARACTERISTIC(BT_UUID_DECLARE_128(ZMK_SPLIT_BT_CHAR_UPDATE_BL_UUID),
BT_GATT_CHRC_WRITE_WITHOUT_RESP, BT_GATT_PERM_WRITE_ENCRYPT, NULL,
split_svc_update_bl, &update_bl_data),
#endif

BT_GATT_DESCRIPTOR(BT_UUID_NUM_OF_DIGITALS, BT_GATT_PERM_READ, split_svc_num_of_positions, NULL,
&num_of_positions), );

Expand Down
2 changes: 2 additions & 0 deletions app/tests/backlight/basic/native_posix_64.conf
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ CONFIG_SYS_CLOCK_TICKS_PER_SEC=1000

CONFIG_LED_GPIO=y
CONFIG_ZMK_BACKLIGHT=y
CONFIG_ZMK_BACKLIGHT_BRT_START=40
CONFIG_ZMK_BACKLIGHT_BRT_SCALE=100
1 change: 1 addition & 0 deletions app/tests/backlight/config-brt/native_posix_64.conf
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ CONFIG_SYS_CLOCK_TICKS_PER_SEC=1000
CONFIG_LED_GPIO=y
CONFIG_ZMK_BACKLIGHT=y
CONFIG_ZMK_BACKLIGHT_BRT_START=60
CONFIG_ZMK_BACKLIGHT_BRT_SCALE=100
2 changes: 2 additions & 0 deletions app/tests/backlight/config-on/native_posix_64.conf
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ CONFIG_SYS_CLOCK_TICKS_PER_SEC=1000
CONFIG_LED_GPIO=y
CONFIG_ZMK_BACKLIGHT=y
CONFIG_ZMK_BACKLIGHT_ON_START=n
CONFIG_ZMK_BACKLIGHT_BRT_START=40
CONFIG_ZMK_BACKLIGHT_BRT_SCALE=100
1 change: 1 addition & 0 deletions app/tests/backlight/config-step/native_posix_64.conf
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ CONFIG_LED_GPIO=y
CONFIG_ZMK_BACKLIGHT=y
CONFIG_ZMK_BACKLIGHT_BRT_START=60
CONFIG_ZMK_BACKLIGHT_BRT_STEP=30
CONFIG_ZMK_BACKLIGHT_BRT_SCALE=100
2 changes: 2 additions & 0 deletions app/tests/backlight/cycle/native_posix_64.conf
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ CONFIG_SYS_CLOCK_TICKS_PER_SEC=1000

CONFIG_LED_GPIO=y
CONFIG_ZMK_BACKLIGHT=y
CONFIG_ZMK_BACKLIGHT_BRT_START=40
CONFIG_ZMK_BACKLIGHT_BRT_SCALE=100
2 changes: 2 additions & 0 deletions app/tests/backlight/low-brightness/native_posix_64.conf
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ CONFIG_SYS_CLOCK_TICKS_PER_SEC=1000

CONFIG_LED_GPIO=y
CONFIG_ZMK_BACKLIGHT=y
CONFIG_ZMK_BACKLIGHT_BRT_START=40
CONFIG_ZMK_BACKLIGHT_BRT_SCALE=100

0 comments on commit 93bf512

Please sign in to comment.