io animation is registering a sequence of io changes for device. It runs regardless program. This is useful when driving dynamic-lightning or stepper motors.
Unlimited Animation
io.animation() will register animation. Supply animation name and animations. It runs immidiately without timeout. obniz.io.animation("animation-1", "pause")
will pause obniz.io.animation("animation-1", "resume")
resume from pause.
An animation state indicate one io states. One state consist of duration time(msec) and io state. Below is a example of io0 and io1 ON-OFF 10msec interval.
// Javascript Example
obniz.io.animation("animation-1", "loop", [
{
duration: 10,
state: function(index){ // index = 0
obniz.io0.output(false)
obniz.io1.output(true)
}
},{
duration: 10,
state: function(index){ // index = 1
obniz.io0.output(true)
obniz.io1.output(false)
}
}
])
Limited numbered animation
This is used for generating correct and fast io changes. Can be used for rotating stepper motor. animations registered from repeat.wait() has a run count limitaiton. repeat.wait() will wait for until done.
Below example results
1. io0 ON for 1000msec
2. io0 OFF for 1000msec
3. io0 ON for 1000msec
4. io0 OFF for 1000msec
// Javascript Example
await obniz.io.repeatWait([
{
duration: 1000,
state: function(index){
obniz.io0.output(true)
}
},{
duration: 1000,
state: function(index){
obniz.io0.output(false)
}
}
], 4)