Skip to content

Commit

Permalink
Make bootcfg sense optional (#1051)
Browse files Browse the repository at this point in the history
* Make bootcfg sense optional

In case we're only interested in non-lockout-prone options, like NKRO
  • Loading branch information
regicidalplutophage authored Dec 9, 2024
1 parent f634693 commit dd58ed5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
9 changes: 5 additions & 4 deletions docs/en/boot.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ configuration.
from kmk.bootcfg import bootcfg

bootcfg(
# required:
sense: [microcontroller.Pin, digitalio.DigitalInOut],
# optional:
sense: Optional[microcontroller.Pin, digitalio.DigitalInOut] = None,
source: Optional[microcontroller.Pin, digitalio.DigitalInOut] = None,
autoreload: bool = True,
boot_device: int = 0,
Expand All @@ -45,8 +44,8 @@ they may differ from board specific defaults.
#### `sense`
`sense` accepts either uninitialized `Pin`s or `DigitalInOut` instances for
maximum flexibility.
The boot configuration is only applied if `sense` reads `True` or "high", and
skipped if it reads `False` or "low".
The lockout-prone subset of boot configuration is only applied if `sense` reads `True` or "high", and
skipped if it reads `False` or "low". The latter is also true if `sense` is not provided.
If `sense` is an uninitialized `Pin`, it'll be configured as pulled-up input; it
wont be further configured if it is a `DigitalInOut`.

Expand Down Expand Up @@ -81,6 +80,7 @@ for details.

#### `cdc_console`
This will enable or disable the USB endpoint for the serial console with REPL.
**Caution**: If erroneous `sense` parameter is provided, changing this might make recovery problematic.


#### `cdc_data`
Expand Down Expand Up @@ -122,6 +122,7 @@ hid endpoint.
#### `storage`
Disable storage if you don't want your computer to go "there's a new thumb drive
I have to mount!" every time you plug in your keyboard.
**Caution**: If erroneous `sense` parameter is provided, changing this might make recovery problematic.


#### `usb_id`
Expand Down
8 changes: 4 additions & 4 deletions kmk/bootcfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@


def bootcfg(
sense: [microcontroller.Pin, digitalio.DigitalInOut],
sense: Optional[microcontroller.Pin, digitalio.DigitalInOut] = None,
source: Optional[microcontroller.Pin, digitalio.DigitalInOut] = None,
autoreload: bool = True,
boot_device: int = 0,
Expand Down Expand Up @@ -86,9 +86,9 @@ def bootcfg(

usb_cdc.enable(data=True)

# sense pulled low -> Skip boot configuration that may disable debug or
# rescue facilities.
if not sense.value:
# sense not provided or pulled low -> Skip boot configuration that may
# disable debug or rescue facilities.
if sense is None or not sense.value:
return False

# Entries for serial console (REPL) and storage are intentionally evaluated
Expand Down

0 comments on commit dd58ed5

Please sign in to comment.