From a2d2f163e52e49b376f6fac9d5d8121c02c050a8 Mon Sep 17 00:00:00 2001 From: David Dreschner <34408442+DerDreschner@users.noreply.github.com> Date: Mon, 31 Jul 2023 11:37:10 +0200 Subject: [PATCH] Fix broken CI builds on Zephyr 3.2 (#6) * 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." Co-Authored-By: Peter Johanson --- app/include/zmk/split/bluetooth/central.h | 7 ++++++- app/include/zmk/split/bluetooth/service.h | 6 +++++- app/src/rgb_underglow.c | 6 ++++++ app/src/split/bluetooth/central.c | 11 +++++++++++ app/src/split/bluetooth/service.c | 17 +++++++++++++++++ app/tests/backlight/basic/native_posix_64.conf | 2 ++ .../backlight/config-brt/native_posix_64.conf | 1 + .../backlight/config-on/native_posix_64.conf | 2 ++ .../backlight/config-step/native_posix_64.conf | 1 + app/tests/backlight/cycle/native_posix_64.conf | 2 ++ .../low-brightness/native_posix_64.conf | 2 ++ 11 files changed, 55 insertions(+), 2 deletions(-) diff --git a/app/include/zmk/split/bluetooth/central.h b/app/include/zmk/split/bluetooth/central.h index 0ca42116f6c..228c531e690 100644 --- a/app/include/zmk/split/bluetooth/central.h +++ b/app/include/zmk/split/bluetooth/central.h @@ -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); \ No newline at end of file +#endif + +#if IS_ENABLED(CONFIG_ZMK_BACKLIGHT) +int zmk_split_bt_update_bl(struct backlight_state *periph); +#endif diff --git a/app/include/zmk/split/bluetooth/service.h b/app/include/zmk/split/bluetooth/service.h index d8b2ab1bfdf..59e11968d0e 100644 --- a/app/include/zmk/split/bluetooth/service.h +++ b/app/include/zmk/split/bluetooth/service.h @@ -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); \ No newline at end of file +int zmk_split_bt_position_released(uint8_t position); diff --git a/app/src/rgb_underglow.c b/app/src/rgb_underglow.c index bf4e1d98b93..f3df1897a2c 100644 --- a/app/src/rgb_underglow.c +++ b/app/src/rgb_underglow.c @@ -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; @@ -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]; @@ -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; @@ -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() { diff --git a/app/src/split/bluetooth/central.c b/app/src/split/bluetooth/central.c index 576c7f34ce6..c630c00f5da 100644 --- a/app/src/split/bluetooth/central.c +++ b/app/src/split/bluetooth/central.c @@ -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); @@ -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); @@ -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(); diff --git a/app/src/split/bluetooth/service.c b/app/src/split/bluetooth/service.c index d27744af851..5f4c02efed4 100644 --- a/app/src/split/bluetooth/service.c +++ b/app/src/split/bluetooth/service.c @@ -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) { @@ -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; @@ -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; @@ -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) { @@ -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), ); diff --git a/app/tests/backlight/basic/native_posix_64.conf b/app/tests/backlight/basic/native_posix_64.conf index bd29a072c9c..e06889e62c1 100644 --- a/app/tests/backlight/basic/native_posix_64.conf +++ b/app/tests/backlight/basic/native_posix_64.conf @@ -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 diff --git a/app/tests/backlight/config-brt/native_posix_64.conf b/app/tests/backlight/config-brt/native_posix_64.conf index 65cdd3263d9..71a0122430b 100644 --- a/app/tests/backlight/config-brt/native_posix_64.conf +++ b/app/tests/backlight/config-brt/native_posix_64.conf @@ -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 diff --git a/app/tests/backlight/config-on/native_posix_64.conf b/app/tests/backlight/config-on/native_posix_64.conf index eb9e7c8a1b2..af1222f321b 100644 --- a/app/tests/backlight/config-on/native_posix_64.conf +++ b/app/tests/backlight/config-on/native_posix_64.conf @@ -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 diff --git a/app/tests/backlight/config-step/native_posix_64.conf b/app/tests/backlight/config-step/native_posix_64.conf index c03eb7b01a6..3d14669f38e 100644 --- a/app/tests/backlight/config-step/native_posix_64.conf +++ b/app/tests/backlight/config-step/native_posix_64.conf @@ -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 diff --git a/app/tests/backlight/cycle/native_posix_64.conf b/app/tests/backlight/cycle/native_posix_64.conf index bd29a072c9c..e06889e62c1 100644 --- a/app/tests/backlight/cycle/native_posix_64.conf +++ b/app/tests/backlight/cycle/native_posix_64.conf @@ -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 diff --git a/app/tests/backlight/low-brightness/native_posix_64.conf b/app/tests/backlight/low-brightness/native_posix_64.conf index bd29a072c9c..e06889e62c1 100644 --- a/app/tests/backlight/low-brightness/native_posix_64.conf +++ b/app/tests/backlight/low-brightness/native_posix_64.conf @@ -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