Skip to content

Commit

Permalink
Merge pull request #116 from decaday/feat/direct_pin_matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
HaoboGu authored Oct 29, 2024
2 parents a7b2fe2 + 0305aaa commit 2b103eb
Show file tree
Hide file tree
Showing 47 changed files with 98,204 additions and 29 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ on:
push:
branches:
- main
# testing..
- docs/i18n

permissions:
contents: read
Expand Down
31 changes: 31 additions & 0 deletions docs/src/keyboard_configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,23 @@ output_pins = ["PD7", "PD8", "PD9"]
# row2col = true
```

If your keys are directly connected to the microcontroller pins, set `matrix_type` to `direct_pin`. (The default value for `matrix_type` is `normal`)

`direct_pins` is a two-dimensional array that represents the physical layout of your keys.

If your pin requires a pull-up resistor and the button press pulls the pin low, set `direct_pin_low_active` to true. Conversely, set it to false if your pin requires a pull-down resistor and the button press pulls the pin high.

Here is an example for rp2040.
```toml
matrix_type = "direct_pin"
direct_pins = [
["PIN_0", "PIN_1", "PIN_2"],
["PIN_3", "_", "PIN_5"]
]
# `direct_pin_low_active` is optional. Default is `true`.
direct_pin_low_active = true
```

### `[layout]`

`[layout]` section contains the layout and the default keymap for the keyboard:
Expand Down Expand Up @@ -228,11 +245,25 @@ usb_enable = true

# Set matrix IO for the board. This section is for non-split keyboard and is conflict with [split] section
[matrix]
# `matrix_type` is optional. Default is "normal"
matrix_type = "normal"
# Input and output pins
input_pins = ["PIN_6", "PIN_7", "PIN_8", "PIN_9"]
output_pins = ["PIN_19", "PIN_20", "PIN_21"]
# WARNING: Currently row2col/col2row is set in RMK's feature gate, configs here do nothing actually

# Direct Pin Matrix is a Matrix of buttons connected directly to pins. It conflicts with the above.
matrix_type = "direct_pin"
direct_pins = [
["PIN_0", "PIN_1", "PIN_2"],
["PIN_3", "_", "PIN_5"]
]

# `direct_pin_low_active` is optional. Default is `true`.
# If your pin needs to be pulled up and the pin is pulled down when the button is turned on, please set it to true
# WARNING: If you use a normal matrix, it will be ineffective
direct_pin_low_active = true

# Layout info for the keyboard, this section is mandatory
[layout]
# Number of rows. For split keyboard, this is the total rows contains all splits
Expand Down
11 changes: 11 additions & 0 deletions docs/src/user_guide/3-2_config_rmk_project_rust.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,15 @@ let (input_pins, output_pins) = config_matrix_pins_rp!(

`input` and `output` are lists of used pins, change them accordingly.

If your keys are directly connected to the microcontroller pins, you can define your pins like this:
```rust
let direct_pins = config_matrix_pins_rp! {
peripherals: p,
direct_pins: [
[PIN_0, PIN_1, PIN_2],
[PIN_3, _, PIN_5],
]
};
```

So far so good, you've done all necessary modifications of your firmware project. You can also check TODOs listed in the generated `README.md` file.
2 changes: 2 additions & 0 deletions examples/use_config/rp2040/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions examples/use_config/rp2040_direct_pin/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[target.'cfg(all(target_arch = "arm", target_os = "none"))']
# runner = "probe-rs run --chip RP2040"
runner = "probe-rs run --probe 0d28:0204:000100011A5A5CC60000000000051D66A5A5A5A597969908 --chip rp2040"
# runner = "elf2uf2-rs -d"

[build]
target = "thumbv6m-none-eabi" # Cortex-M0 and Cortex-M0+

[env]
DEFMT_LOG = "debug"
Loading

0 comments on commit 2b103eb

Please sign in to comment.