the-via / app

GNU General Public License v3.0
765 stars 173 forks source link

Add timeout for custom menu commits #164

Open mini-ninja-64 opened 1 year ago

mini-ninja-64 commented 1 year ago

Hello while implementing a custom menu for my device I found what appears to be a disagreement between the documentation and behaviour of VIA.

The VIA docs currently state the following:

The id_custom_save command is sent after one or more id_custom_set_value commands have been sent, and after a small delay. It is used to allow the firmware to defer writing to EEPROM and respond to set value commands quickly.

However the current VIA codebase will push a custom menu save command for every custom menu set it does, this is not ideal for the EEPROM as such it would be best in my opinion to defer writing to the EEPROM until we are sure that the user has settled on a value.

To fix this I have offloaded the sending of a custom menu save command to a function that is executed only once 250ms has passed without any custom menu updates.

I am very happy to update and change the solution chosen as there are of course multiple ways to proceed with this problem, including moving the tackling of EEPROM save timing to firmware.

I was also unsure whether or not I should open an associated issue to link to this PR, let me know if that would be useful.