zmk icon indicating copy to clipboard operation
zmk copied to clipboard

feat: add option to disable storing state to settings

Open xudongzheng opened this issue 2 years ago • 6 comments

Currently ZMK uses settings to periodically remember the latest state for &out, &ext_power, and others.

Some users may be prefer for such state to not persist. Not using settings means you are guaranteed a consistent state after each reset. The 60 second default debounce period can sometimes make it difficult to know what the initial state is.

One workaround is setting CONFIG_ZMK_SETTINGS_SAVE_DEBOUNCE to a really high value. However this is imperfect as setting that already exists on storage will persist indefinitely.

Ideally there would be a special value (such as CONFIG_ZMK_SETTINGS_SAVE_DEBOUNCE=-1) or a separate Kconfig value that disables state from being read from settings (and uses the default state). Instead of just IS_ENABLED(CONFIG_SETTINGS), it would check the proposed setting as well https://github.com/zmkfirmware/zmk/blob/main/app/src/ext_power_generic.c#L144.

xudongzheng avatar Dec 20 '22 04:12 xudongzheng

I'm not sure I understand this. How would this be different from disabling CONFIG_SETTINGS?

joelspadin avatar Dec 20 '22 06:12 joelspadin

I'm not sure I understand this. How would this be different from disabling CONFIG_SETTINGS?

Unfortunately, this would also break BT key storage... So we would need something more nuanced.

petejohanson avatar Dec 20 '22 13:12 petejohanson

Wouldn't it be enough to change this CONFIG_SETTINGS (line 44) to a new config value?

https://github.com/zmkfirmware/zmk/blob/e22bc7620cef763d9ad80e9b98182273de9973db/app/src/endpoints.c#L43-L49

If that's correct I'd also be happy to create a PR. (would be my first one though, so it might be a pretty bad one :) )

Timoyoungster avatar Apr 16 '24 06:04 Timoyoungster

Wouldn't it be enough to change this CONFIG_SETTINGS (line 44) to a new config value?

That would be part of it. The configuration that you change it to would have to be actually implemented as well. My initial comment https://github.com/zmkfirmware/zmk/issues/1599#issue-1503985403 describes some of what that includes.

xudongzheng avatar Apr 16 '24 12:04 xudongzheng

Ok, clear. But it won't break any other functionality this way right?

Because then I'd try to create 2 new settings (one for out and one for ext_power).

Timoyoungster avatar Apr 16 '24 13:04 Timoyoungster

If someone else is still waiting for this, I created a PR (#2308) and would be happy if also other people could test it. (I am only able to verify on one single keyboard)

Timoyoungster avatar May 30 '24 19:05 Timoyoungster