This extension provides a firefly-like protocol to synchronize devices together.
Use the firefly.onSync
event that is raised
on each clock cycle.
firefly.onSync(function () {
console.log('sync')
})
Use the firefly.onTick
event to run on each tick
firefly.onTick(function () {
console.log('tick')
})
Use the firefly.onCorrection
event to run
when a tick correction was applied
firefly.onCorrection(function () {
console.log('correction')
})
You can change the interval of the sync event using this block.
firefly.setInterval(1000)
Indicates if any signal was received from neighboring devices during the clock cycle.
firefly.onSync(function () {
if (firefly.hasNeighbors()) {
console.log('sync')
}
})
- for PXT/microbit