useful_programs
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
useful_programs [2020/03/20 10:06] – [3-point control for a valve or servo] emozolyak | useful_programs [2020/06/03 12:00] – [Other handy functions] emozolyak | ||
---|---|---|---|
Line 228: | Line 228: | ||
end | end | ||
+ | </ | ||
+ | |||
+ | For complex tables print, you can use the following function: | ||
+ | <code lua> | ||
+ | function tprint(t, indent) | ||
+ | if not indent then indent = 0 end | ||
+ | for k, v in pairs(t) do | ||
+ | local formatting = string.rep(' | ||
+ | if type(v) == " | ||
+ | ERROR(formatting) | ||
+ | tprint(v, indent + 1) -- recursive call | ||
+ | else | ||
+ | if type(v) == " | ||
+ | v = v and " | ||
+ | end | ||
+ | ERROR(formatting .. v) | ||
+ | end | ||
+ | end -- for | ||
+ | end -- tprint | ||
</ | </ | ||
Line 633: | Line 652: | ||
quant = 0 | quant = 0 | ||
end -- if motion | end -- if motion | ||
- | UpdReg(v .. " | + | UpdReg(v .. " |
return quant | return quant | ||
end -- motionTmr | end -- motionTmr | ||
Line 750: | Line 769: | ||
return false -- nothing happened | return false -- nothing happened | ||
end -- P_TRIG | end -- P_TRIG | ||
+ | |||
+ | function MulGetReg(...) -- multiple ids or aliases read, returns table, have to be unpack() 'ed | ||
+ | local results = {} | ||
+ | for i = 1, #arg do | ||
+ | local param = arg[i] | ||
+ | -- INFO(" | ||
+ | results[i] = GetReg(param) | ||
+ | | ||
+ | if (#results == 1) then | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | end | ||
</ | </ | ||
useful_programs.txt · Last modified: 2024/05/27 13:23 by emozolyak