Skip to content

Commit

Permalink
Implement data driven dip switches
Browse files Browse the repository at this point in the history
  • Loading branch information
zvecr committed Sep 14, 2023
1 parent f9ed1e3 commit ef4df06
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 1 deletion.
4 changes: 4 additions & 0 deletions data/mappings/info_config.hjson
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@
// Combos
"COMBO_TERM": {"info_key": "combo.term", "value_type": "int"},

"DIP_SWITCH_MATRIX_GRID": {"info_key": "dip_switch.matrix_grid", "value_type": "array.array.int", "to_json": false},
"DIP_SWITCH_PINS": {"info_key": "dip_switch.pins", "value_type": "array"},
"DIP_SWITCH_PINS_RIGHT": {"info_key": "split.dip_switch.right.pins", "value_type": "array"},

// Dynamic Keymap
"DYNAMIC_KEYMAP_EEPROM_MAX_ADDR": {"info_key": "dynamic_keymap.eeprom_max_addr", "value_type": "int"},
"DYNAMIC_KEYMAP_LAYER_COUNT": {"info_key": "dynamic_keymap.layer_count", "value_type": "int"},
Expand Down
1 change: 1 addition & 0 deletions data/mappings/info_rules.hjson
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"BOOTLOADER": {"info_key": "bootloader", "warn_duplicate": false},
"BOOTMAGIC_ENABLE": {"info_key": "bootmagic.enabled", "value_type": "bool"},
"CAPS_WORD_ENABLE": {"info_key": "caps_word.enabled", "value_type": "bool"},
"DIP_SWITCH_ENABLE": {"info_key": "dip_switch.enabled", "value_type": "bool"},
"DEBOUNCE_TYPE": {"info_key": "build.debounce_type"},
"EEPROM_DRIVER": {"info_key": "eeprom.driver"},
"ENCODER_ENABLE": {"info_key": "encoder.enabled", "value_type": "bool"},
Expand Down
38 changes: 37 additions & 1 deletion data/schemas/keyboard.jsonschema
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,15 @@
}
}
}
}
},
"dip_switch_config": {
"type": "object",
"properties": {
"pins": {
"$ref": "qmk.definitions.v1#/mcu_pin_array"
}
}
},
},
"type": "object",
"not": { "required": [ "vendorId", "productId" ] }, // reject via keys...
Expand Down Expand Up @@ -245,6 +253,25 @@
"type": "array",
"items": {"$ref": "qmk.definitions.v1#/filename"}
},
"dip_switch": {
"$ref": "#/definitions/dip_switch_config",
"properties": {
"enabled": {"type": "boolean"},
"matrix_grid": {
"type": "array",
"minItems": 1,
"items": {
"type": "array",
"minItems": 2,
"maxItems": 2,
"items": {
"type": "integer",
"minimum": 0
}
}
}
}
},
"eeprom": {
"properties": {
"driver": {"type": "string"},
Expand Down Expand Up @@ -621,6 +648,15 @@
}
}
},
"dip_switch": {
"type": "object",
"additionalProperties": false,
"properties": {
"right": {
"$ref": "#/definitions/dip_switch_config"
}
}
},
"encoder": {
"type": "object",
"additionalProperties": false,
Expand Down
18 changes: 18 additions & 0 deletions docs/reference_info_json.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,20 @@ Configures the [Combo](feature_combo.md) feature.
* The amount of time to recognize a combo in milliseconds.
* Default: `50` (50 ms)

## DIP Switches :id=dip-switch

Configures the [DIP Switches](feature_dip_switch.md) feature.

* `dip_switch`
* `enabled`
* Enable the DIP Switches feature.
* Default: `false`
* `pins`
* A list of GPIO pins connected to the MCU.
* `matrix_grid`
* A list of matrix locations in the key matrix.
* Example: `[ [0,6], [1,6], [2,6] ]`

## EEPROM :id=eeprom

Configures the [EEPROM](eeprom_driver.md) driver.
Expand Down Expand Up @@ -591,6 +605,10 @@ Configures the [Split Keyboard](feature_split_keyboard.md) feature.
* `bootmagic`
* `matrix`
* See [Bootmagic](#bootmagic) config.
* `dip_switch`
* `right`
* `pins`
* See [DIP Switches](#dip-switch) config.
* `enabled`
* Enable the Split Keyboard feature.
* Default: `false`
Expand Down

0 comments on commit ef4df06

Please sign in to comment.