Show:

BO.io.BlinkM Class

Extends BO.I2CBase
Defined in: src/io/BlinkM.js:21

Creates an interface to a BlinkM RGB Led module. This object allows you to change the color of the led, fade between colors and run preprogrammed light scripts. See Breakout/examples/actuators/blinkM.html for an example application.

Constructor

BO.io.BlinkM

(
  • board
  • address
)

Defined in src/io/BlinkM.js:21

Parameters:

  • board IOBoard

    The IOBoard instance

  • address Number

    The i2c address of the BlinkM module

Methods

addEventListener

(
  • type
  • listener
)

Parameters:

  • type String

    The event type

  • listener Function

    The function to be called when the event is fired

dispatchEvent

(
  • type
  • optionalParams
)

Parameters:

  • type Event

    The Event object.

  • optionalParams Object

    Optional parameters passed as an object. return {boolean} True if dispatch is successful, false if not.

fadeToHSBColor

(
  • color
  • speed
)

Defined in src/io/BlinkM.js:97

Fades to the specified HSB color in the specified time duration. The fade speed range is from 1 to 255, where 1 is the slowest time and 255 is the fastest.

Parameters:

  • color Number

    An array containing the HSB values. color[0] = H, color[1] = S, color[2] = B

  • speed Number

    The fade speed. Default value is 15.

fadeToRandomHSBColor

(
  • colorRange
  • speed
)

Fade to a random HSB color. The fade speed range is from 1 to 255, where 1 is the slowest time and 255 is the fastest.

Parameters:

  • colorRange Number

    An array containing a range for each color value. colorRange[0] = range for Hue (0-255), colorRange[1] = range for Saturation, etc.

  • speed Number

    The fade speed. Default value is 15.

fadeToRandomRGBColor

(
  • colorRange
  • speed
)

Defined in src/io/BlinkM.js:78

Fade to a random RGB color. The fade speed range is from 1 to 255, where 1 is the slowest time and 255 is the fastest.

Parameters:

  • colorRange Number

    An array containing a range for each color value. colorRange[0] = range for Red (0-255), colorRange[1] = range for Green, etc.

  • speed Number

    The fade speed. Default value is 15.

fadeToRGBColor

(
  • color
  • speed
)

Defined in src/io/BlinkM.js:60

Fades to the specified RGB color in the specified time duration. The fade speed range is from 1 to 255, where 1 is the slowest time and 255 is the fastest.

Parameters:

  • color Number

    An array containing the RGB values. color[0] = R, color[1] = G, color[2] = B

  • speed Number

    The fade speed. Default value is 15.

goToRGBColorNow

(
  • }
)

Defined in src/io/BlinkM.js:49

Sets the BlinkM to the specified RGB color immediately.

Parameters:

  • } Number

    color An array containing the RGB values. color[0] = R, color[1] = G, color[2] = B

handleI2C

() private

Inherited from BO.I2CBase but overwritten in src/io/BlinkM.js:170

hasEventListener

(
  • type
)

Parameters:

  • type String

    The event type return {boolean} True is listener exists for this type, false if not.

playLightScript

(
  • scriptId
  • theNumberOfRepeats
  • lineNumber
)

Play a predefined light script. See the BlinkM datasheet page 20 for a list and description of the predefined scripts.

Parameters:

  • scriptId Number

    The id of the light script (from 0 to 18).

  • theNumberOfRepeats Number

    The number of times the script should repeat.

  • lineNumber Number

    The line number to begin the script from.

removeEventListener

(
  • type
  • listener
)

Parameters:

  • type String

    The event type

  • listener Function

    The function to be called when the event is fired

sendI2CRequest

(
  • command
  • data
)
protected

Send an i2c request command to the board

Parameters:

  • command Number
  • data Number

setFadeSpeed

(
  • speed
)

Set the rate at which color fading happens. The range is from 1 to 255, where 1 is the slowest and 255 is the fastest (immediate).

Parameters:

  • speed Number

stopScript

()

Stop the currently playing predefined light script.

update

() protected

To be implemented in subclass

Properties

address

Number

[read-only] The address of the i2c device.

I2CBase.I2C_REPLY

Unknown