The JSON config for the physical UI allows you to set-up initial transition defaults e.g.
Below you can see the "power" RGBLED has default transition
options set. This means all transitions will happen over 750ms.
initialTransition
is used to set-up the RGBLED when it's initialised and before any messages to change it's state are received. In this case, the LED will be transitions to the colour [200, 200, 200]
over 5 seconds backwards and forwards repeatedly (yoyo
).
...
"RGBLEDs": [
{
"id": "power",
"pins": [6,10,11],
"colour": [200, 200, 200],
"transitions": {
"duration": 750
},
"initialTransition": {
"duration": 5000,
"yoyo": true
}
}
...
This is roughly mapped to:
var rgb = RGB.create(config.pins, anyOtherOpts);
rgb.transitions(config.transitions);
rgb.colour(config.colour, config.initialTransition);
content = {
colour: [255, 0, 128], // RGB colour
transition: {
duration: 1000, // in ms
yoyo: true, // boolean
easing: 'easingFuncName' // from this list http://easings.net/
}
}
This is mapped to rgb.colour(content.colour, content.transition)
.
content = {
queue: [
{
colour: [0, 0, 255],
transition: {
duration: 1000
}
},
{
colour: [255, 0, 0],
}
]
}
This allows a queuing of changes in a single message. The queue above will change RGBLED to blue over 1second, then change to red using default transitions (or instantly if no default transitions).
This maps to:
rgb.colour([0,0,255], { chain: true, duration: 1000}); rgb.colour([255, 0, 0]);
This queries the current colour of the RGBLED and returns over the message bus.
https://github.com/radiodan/physical-ui/blob/master/lib/bootstrap.js#L189-L193