yodaRT. light

The LightScript is the script framework which provides you to control any hardware interactive part includes the LEDs and sound effects. Every script just looks like a JavaScript function:

module.exports = function (lightCtx, params, done) {
  lightCtx.requestAnimationFrame(() => {
    lightCtx.fill(255, 255, 255)

In the main function, LightScript provides the 3 params for script developer:

  • lightCtx yodaRT.light.LightRenderingContext the LightScript API that you could use.
  • params the object which the caller pass.
  • done the function the developer should call when the light is done.

The LightScript files should be installed on /opt/light or your ./light directory under your own application, therefore you could use it by yodaRT.activity.Activity.LightClient.

module.exports = function (activity) {
  activity.on('create', () => {
    activity.light.play('system://hello.js', { num: 10 }, {
      zIndex: 20,
      shouldResume: true

The above example application would play the first LightScript after it gets create lifetime.



Type Definitions


Name Type Description
r number

the RED color.

g number

the GREEN color.

b number

the BLUE color.

a number

the ALPHA value.