useful_programs
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | |||
useful_programs [2024/03/19 09:25] – [Detection of change of state] emozolyak | useful_programs [2024/03/19 09:39] (current) – [Detection of change of state] emozolyak | ||
---|---|---|---|
Line 1540: | Line 1540: | ||
| | ||
onchange1(R(110), | onchange1(R(110), | ||
+ | ------- Detecting changes of a set of registers ---------------- | ||
+ | local regSet = {{110, function() | ||
+ | INFO(" | ||
+ | end }, | ||
+ | {1, function() | ||
+ | | ||
+ | end }, | ||
+ | {200, function() | ||
+ | INFO(" | ||
+ | end }, | ||
+ | |||
+ | } | ||
+ | | ||
+ | local handlers = {} | ||
+ | | ||
+ | -- registereing handlers | ||
+ | if (not handlers[regSet[1][1]]) then | ||
+ | for _, s in ipairs(regSet) do | ||
+ | handlers[s[1]] = OnChange() | ||
+ | end | ||
+ | end | ||
+ | |||
+ | -- using handlers | ||
+ | for _, s in ipairs(regSet) do | ||
+ | local reg, func = s[1], s[2] | ||
+ | handlers[reg](R(reg), | ||
+ | end | ||
end | end | ||
</ | </ |
useful_programs.txt · Last modified: 2024/03/19 09:39 by emozolyak