Re: SIOC and Encoders (ROTATE function, etc)
Righto, so ROTATE, LIMIT etc functions do the "magic" bit. That's fine just as long as I know what happens.
Thanks for clearing that up man!
Quote:
Originally Posted by
pdpo
nope,
if you do not want that then you have to condition the encoder value to be +1 if >=0 and -1 if <= -1.
Yep that's exactly what I ended up doing yesterday, just following my nose and looking at what actually happens.
Re: SIOC and Encoders (ROTATE function, etc)
Glad you got it "sorted". SIOC is powerful, but sometimes challenging, particularly the principle that the code attached to a variable is only executed when the variable changes value - caught me out many times :)
Re: SIOC and Encoders (ROTATE function, etc)
Quote:
Originally Posted by
fordgt40
Glad you got it "sorted". SIOC is powerful, but sometimes challenging, particularly the principle that the code attached to a variable is only executed when the variable changes value - caught me out many times :)
Yep me too... I was going nuts with the way it defied "standard practices" and that there was no clear documentation as to what exactly happens. Or I might have missed it when fiddling about yesterday.
Must admit that code attached to variables is very natural to me. They are called event handlers in JavaScript or a Window Procedure in Windows API. Then there're processor interrupts that function in a similar way with interrupt handler only executed when hw requests it(say encoder changes value :D ) Anyway that's off topic.
Thanks a lot guys, I appreciate your help!
PS. MCP is now coming along nicely :)
Re: SIOC and Encoders (ROTATE function, etc)
Hi guys,
SIOC's statement:
Code:
v2 = ROTATE 0 359 L0
has indeed the behaviour that Peter described; the ROTATE function takes the actual value of v2 before incrementing/decrementing, 'range wraparounding' and finally 'assigning'.
In C/C++ one would write:
Code:
v2 = Rotate(0, 359, L0, v2);
best regards,
Nico Kaan
Re: SIOC and Encoders (ROTATE function, etc)
Quote:
Originally Posted by
aVaTar
Must admit that code attached to variables is very natural to me. They are called event handlers in JavaScript or a Window Procedure in Windows API.
Indeed. SIOC is an 'event driven scripting language', not a normal procedural programming language.
Read more about SIOC and 'the golden rule' here.
regards,
Nico