Skip to content

Commit

Permalink
refactor(split): move and rename Kconfig options
Browse files Browse the repository at this point in the history
  • Loading branch information
xudongzheng committed Dec 24, 2023
1 parent d89ec53 commit dee1124
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 34 deletions.
24 changes: 24 additions & 0 deletions app/src/split/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,30 @@ if ZMK_SPLIT
config ZMK_SPLIT_ROLE_CENTRAL
bool "Split central device"

if ZMK_SPLIT_ROLE_CENTRAL

config ZMK_SPLIT_CENTRAL_POSITION_QUEUE_SIZE
int "Max number of key position state events to queue when received from peripherals"
default 5

endif # ZMK_SPLIT_ROLE_CENTRAL

if !ZMK_SPLIT_ROLE_CENTRAL

config ZMK_SPLIT_PERIPHERAL_STACK_SIZE
int "Split peripheral notify thread stack size"
default 650

config ZMK_SPLIT_PERIPHERAL_PRIORITY
int "Split peripheral notify thread priority"
default 5

config ZMK_SPLIT_PERIPHERAL_POSITION_QUEUE_SIZE
int "Max number of key position state events to queue to send to the central"
default 10

endif #!ZMK_SPLIT_ROLE_CENTRAL

choice ZMK_SPLIT_TRANSPORT
prompt "Split transport"

Expand Down
16 changes: 0 additions & 16 deletions app/src/split/bluetooth/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ config ZMK_SPLIT_BLE_CENTRAL_PERIPHERALS
int "Number of peripherals that will connect to the central."
default 1

config ZMK_SPLIT_BLE_CENTRAL_POSITION_QUEUE_SIZE
int "Max number of key position state events to queue when received from peripherals"
default 5

config ZMK_SPLIT_BLE_CENTRAL_SPLIT_RUN_STACK_SIZE
int "BLE split central write thread stack size"
default 512
Expand All @@ -50,18 +46,6 @@ endif # ZMK_SPLIT_ROLE_CENTRAL

if !ZMK_SPLIT_ROLE_CENTRAL

config ZMK_SPLIT_BLE_PERIPHERAL_STACK_SIZE
int "BLE split peripheral notify thread stack size"
default 650

config ZMK_SPLIT_BLE_PERIPHERAL_PRIORITY
int "BLE split peripheral notify thread priority"
default 5

config ZMK_SPLIT_BLE_PERIPHERAL_POSITION_QUEUE_SIZE
int "Max number of key position state events to queue to send to the central"
default 10

config BT_MAX_PAIRED
default 1

Expand Down
4 changes: 2 additions & 2 deletions app/src/split/central.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);

K_MSGQ_DEFINE(peripheral_event_msgq, sizeof(struct zmk_position_state_changed),
CONFIG_ZMK_SPLIT_BLE_CENTRAL_POSITION_QUEUE_SIZE, 4);
CONFIG_ZMK_SPLIT_CENTRAL_POSITION_QUEUE_SIZE, 4);

void peripheral_event_work_callback(struct k_work *work) {
struct zmk_position_state_changed ev;
Expand All @@ -34,7 +34,7 @@ void zmk_position_state_change_handle(struct zmk_position_state_changed *ev) {

#if ZMK_KEYMAP_HAS_SENSORS
K_MSGQ_DEFINE(peripheral_sensor_event_msgq, sizeof(struct zmk_sensor_event),
CONFIG_ZMK_SPLIT_BLE_CENTRAL_POSITION_QUEUE_SIZE, 4);
CONFIG_ZMK_SPLIT_CENTRAL_POSITION_QUEUE_SIZE, 4);

void peripheral_sensor_event_work_callback(struct k_work *work) {
struct zmk_sensor_event ev;
Expand Down
8 changes: 4 additions & 4 deletions app/src/split/service.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ static uint8_t position_state[ZMK_SPLIT_POS_STATE_LEN];
static struct sensor_event last_sensor_event;
#endif

K_THREAD_STACK_DEFINE(service_q_stack, CONFIG_ZMK_SPLIT_BLE_PERIPHERAL_STACK_SIZE);
K_THREAD_STACK_DEFINE(service_q_stack, CONFIG_ZMK_SPLIT_PERIPHERAL_STACK_SIZE);

struct k_work_q service_work_q;

K_MSGQ_DEFINE(position_state_msgq, sizeof(char[ZMK_SPLIT_POS_STATE_LEN]),
CONFIG_ZMK_SPLIT_BLE_PERIPHERAL_POSITION_QUEUE_SIZE, 4);
CONFIG_ZMK_SPLIT_PERIPHERAL_POSITION_QUEUE_SIZE, 4);

void send_position_state_callback(struct k_work *work) {
uint8_t state[ZMK_SPLIT_POS_STATE_LEN];
Expand Down Expand Up @@ -70,7 +70,7 @@ int zmk_split_position_released(uint8_t position) {

#if ZMK_KEYMAP_HAS_SENSORS
K_MSGQ_DEFINE(sensor_state_msgq, sizeof(struct sensor_event),
CONFIG_ZMK_SPLIT_BLE_PERIPHERAL_POSITION_QUEUE_SIZE, 4);
CONFIG_ZMK_SPLIT_PERIPHERAL_POSITION_QUEUE_SIZE, 4);

void send_sensor_state_callback(struct k_work *work) {
while (k_msgq_get(&sensor_state_msgq, &last_sensor_event, K_NO_WAIT) == 0) {
Expand Down Expand Up @@ -120,7 +120,7 @@ int service_init(const struct device *_arg) {
static const struct k_work_queue_config queue_config = {
.name = "Split Peripheral Notification Queue"};
k_work_queue_start(&service_work_q, service_q_stack, K_THREAD_STACK_SIZEOF(service_q_stack),
CONFIG_ZMK_SPLIT_BLE_PERIPHERAL_PRIORITY, &queue_config);
CONFIG_ZMK_SPLIT_PERIPHERAL_PRIORITY, &queue_config);

return 0;
}
Expand Down
24 changes: 12 additions & 12 deletions docs/docs/config/system.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,15 @@ Note that `CONFIG_BT_MAX_CONN` and `CONFIG_BT_MAX_PAIRED` should be set to the s

Following split keyboard settings are defined in [zmk/app/src/split/Kconfig](https://github.com/zmkfirmware/zmk/blob/main/app/src/split/Kconfig) (generic) and [zmk/app/src/split/Kconfig](https://github.com/zmkfirmware/zmk/blob/main/app/src/split/bluetooth/Kconfig) (bluetooth).

| Config | Type | Description | Default |
| ----------------------------------------------------- | ---- | ------------------------------------------------------------------------ | ------- |
| `CONFIG_ZMK_SPLIT` | bool | Enable split keyboard support | n |
| `CONFIG_ZMK_SPLIT_PERIPHERAL_HID_INDICATORS` | bool | Enable split keyboard support for passing indicator state to peripherals | n |
| `CONFIG_ZMK_SPLIT_BLE` | bool | Use BLE to communicate between split keyboard halves | y |
| `CONFIG_ZMK_SPLIT_ROLE_CENTRAL` | bool | `y` for central device, `n` for peripheral | |
| `CONFIG_ZMK_SPLIT_BLE_CENTRAL_POSITION_QUEUE_SIZE` | int | Max number of key state events to queue when received from peripherals | 5 |
| `CONFIG_ZMK_SPLIT_BLE_CENTRAL_SPLIT_RUN_STACK_SIZE` | int | Stack size of the BLE split central write thread | 512 |
| `CONFIG_ZMK_SPLIT_BLE_CENTRAL_SPLIT_RUN_QUEUE_SIZE` | int | Max number of behavior run events to queue to send to the peripheral(s) | 5 |
| `CONFIG_ZMK_SPLIT_BLE_PERIPHERAL_STACK_SIZE` | int | Stack size of the BLE split peripheral notify thread | 650 |
| `CONFIG_ZMK_SPLIT_BLE_PERIPHERAL_PRIORITY` | int | Priority of the BLE split peripheral notify thread | 5 |
| `CONFIG_ZMK_SPLIT_BLE_PERIPHERAL_POSITION_QUEUE_SIZE` | int | Max number of key state events to queue to send to the central | 10 |
| Config | Type | Description | Default |
| ---------------------------------------------------- | ---- | ------------------------------------------------------------------------ | ------- |
| `CONFIG_ZMK_SPLIT` | bool | Enable split keyboard support | n |
| `CONFIG_ZMK_SPLIT_PERIPHERAL_HID_INDICATORS` | bool | Enable split keyboard support for passing indicator state to peripherals | n |
| `CONFIG_ZMK_SPLIT_BLE` | bool | Use BLE to communicate between split keyboard halves | y |
| `CONFIG_ZMK_SPLIT_ROLE_CENTRAL` | bool | `y` for central device, `n` for peripheral | |
| `CONFIG_ZMK_SPLIT_CENTRAL_POSITION_QUEUE_SIZE` | int | Max number of key state events to queue when received from peripherals | 5 |
| `CONFIG_ZMK_SPLIT_BLE_CENTRAL_SPLIT_RUN_STACK_SIZE` | int | Stack size of the BLE split central write thread | 512 |
| `CONFIG_ZMK_SPLIT_BLE_CENTRAL_SPLIT_RUN_QUEUE_SIZE` | int | Max number of behavior run events to queue to send to the peripheral(s) | 5 |
| `CONFIG_ZMK_SPLIT_PERIPHERAL_STACK_SIZE` | int | Stack size of the split peripheral notify thread | 650 |
| `CONFIG_ZMK_SPLIT_PERIPHERAL_PRIORITY` | int | Priority of the split peripheral notify thread | 5 |
| `CONFIG_ZMK_SPLIT_PERIPHERAL_POSITION_QUEUE_SIZE` | int | Max number of key state events to queue to send to the central | 10 |

0 comments on commit dee1124

Please sign in to comment.