diff --git a/cf2.md b/cf2.md index e8b7e8e..a71a0b8 100644 --- a/cf2.md +++ b/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. diff --git a/patcher/patcher.js b/patcher/patcher.js index 1c12ee0..041a6fc 100644 --- a/patcher/patcher.js +++ b/patcher/patcher.js @@ -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]