Add =null syntax to remove entries
This commit is contained in:
parent
b31f82edf6
commit
0d0317634c
2 changed files with 17 additions and 1 deletions
7
cf2.md
7
cf2.md
|
|
@ -94,6 +94,9 @@ PIN_DISPLAY_MOSI = PIN_MOSI
|
|||
# custom configuration keys
|
||||
_679732427 = 123
|
||||
_815320287 = 0x80192
|
||||
|
||||
# remove an existing config entry
|
||||
PIN_BTN_MENU2 = null
|
||||
```
|
||||
|
||||
The keys are either key names, or underscore followed by a decimal number.
|
||||
|
|
@ -109,6 +112,10 @@ The way pin numbers are parsed depends on the `PINS_PORT_SIZE`:
|
|||
Certain keys (like `PINS_PORT_SIZE`) have a number of pre-defined values,
|
||||
which can be used instead of integers.
|
||||
|
||||
Because you're usually use this syntax to patch an existing configuration,
|
||||
you sometimes may want to remove an entry that's already there.
|
||||
To do that, use `null` as the value of the key.
|
||||
|
||||
For list of keys and predefined values, see `configkeys.h` which can be downloaded
|
||||
from the patcher website.
|
||||
|
||||
|
|
|
|||
|
|
@ -654,6 +654,16 @@ function patchConfig(buf, cfg) {
|
|||
}
|
||||
})
|
||||
|
||||
let changes = ""
|
||||
forAll((kn, k, v) => {
|
||||
v = v.toUpperCase()
|
||||
if (v == "NULL" || v == "UNDEFINED") {
|
||||
let old = lookupCfg(cfgdata, k)
|
||||
changes += "remove " + showKV(k, old, portSize0) + "\n"
|
||||
delete cfgMap[k]
|
||||
}
|
||||
})
|
||||
|
||||
forAll((kn, k, v) => {
|
||||
if (isNaN(parseInt(v)))
|
||||
err("Value not understood: " + v)
|
||||
|
|
@ -667,7 +677,6 @@ function patchConfig(buf, cfg) {
|
|||
patch.push(parseInt(cfgMap[k]))
|
||||
}
|
||||
|
||||
let changes = ""
|
||||
for (let i = 0; i < patch.length; i += 2) {
|
||||
let k = patch[i]
|
||||
let v = patch[i + 1]
|
||||
|
|
|
|||
Loading…
Reference in a new issue