kareltucek / firmware

This is fork of UHK's firmware featuring extended macro engine.
Other
82 stars 9 forks source link

Add on-exit hook #80

Closed soraxas closed 2 years ago

soraxas commented 2 years ago

Adds an onExit hook. Usage

ifKeyActive 85 tapKey 1
ifKeyActive 85 onExit final setLedTxt 5000 YES
ifNotKeyActive 85 tapKey 2
ifNotKeyActive 85 onExit final setLedTxt 5000 NO

delayUntil 2000  // do work

Registered hook will be executed after the macro is exiting. Unlike label, this hook respect runtime encounter. The example will display YES for L-shift+MacroKey. MacroKey without L-shift will display NO. In both scenario, the display happens after the whole macro had finished (after the long delay in the end)

kareltucek commented 2 years ago

Please do elaborate a bit more on motivation. (E.g., real-life usecases and problems or why not simply branch using jump in the above example - you only save like one or two lines of code.)

Like this, it looks like a very arbitrary feature proposal to me. I am not at all convinced that it is justified and actually makes sense.

soraxas commented 2 years ago

Hi @kareltucek thanks for your response!

I do agree that what this feature proposal provides can already be achieved with branching jumps. What this feature tackle is to have an easy way to define common ending point (e.g. clean up actions, setting led text to something when macro starts, and using onExit hook to reset things when done, etc.). This feature only avoids having to specify jumps on all possible exit points (esp. when final is given to command and it's not possible to chain command in a single line yet).

I'm perfectly fine if you want to close this PR

soraxas commented 2 years ago

Closing, as this PR increases memory layout