LightMatrix

The light matrix controls a 5x5 set of pixels on the Spikeā„¢ robot. The first pixel in the top left is 0,0 and the bottom right pixel is 4,4. You can get and set the pixels manually, clear the display, or write words to it.

Constants

  1. UP=0
  2. RIGHT=1
  3. DOWN=2
  4. LEFT=3
  5. HEART=1
  6. HEART_SMALL=2
  7. HAPPY=3
  8. SMILE=4
  9. SAD=5
  10. CONFUSED=6

Write(text value)

Returns

None

Parameters

  1. 1.textvalue

    Text that will be written to the display.

Example

1 2 3 use Libraries.Robots.Spike.LightMatrix LightMatrix lights lights:Write("Hi!")

GetPixel(integer x, integer y)

Returns

integer
Returns the intensity, between 0 and 100, of a particular pixel on the display.

Parameters

  1. 1.integerx

    The x coordinate, from 0 to 4, of the pixel

  2. 2.integery

    The y coordinate, from 0 to 4, of the pixel

Example

1 2 3 use Libraries.Robots.Spike.LightMatrix LightMatrix lights output lights:GetPixel(0,0)

SetPixel(integer x, integer y, integer intensity)

Returns

None

Parameters

  1. 1.integerx

    The x coordinate, from 0 to 4, of the pixel

  2. 2.integery

    The y coordinate, from 0 to 4, of the pixel

  3. 3.integery

    The intensity, from 0 to 100, that the pixel will be set to

Example

1 2 3 4 use Libraries.Robots.Spike.LightMatrix LightMatrix lights lights:SetPixel(0,0,100) lights:SetPixel(4,4,100)

Show(Array<integer> pixels)

Returns

None

Parameters

  1. 1.Array<integer>pixels

    An integer array of pixels to display, where each index represents the intensity from 0 to 100 of the corresponding pixel. The order is left to right, top to bottom on a 5x5 grid.

Example

1 2 3 4 5 6 7 8 9 10 11 use Libraries.Robots.Spike.LightMatrix use Libraries.Containers.Array Array pixels LightMatrix lights integer i = 0 repeat 25 times pixels:Add(i) i = i + 4 end lights:Show(pixels)

ShowImage(integer image)

Returns

None

Parameters

  1. 1.integerimage

    Built in image to display; should be one of the constant values of LightMatrix

Example

1 2 3 use Libraries.Robots.Spike.LightMatrix LightMatrix lights lights:ShowImage(1)

Clear()

Returns

None
Sets the intensity of all pixels to 0

Parameters

None

Example

1 2 3 use Libraries.Robots.Spike.LightMatrix LightMatrix lights lights:Clear()

GetOrientation()

Returns

integer
Returns the orientation of the light matrix, which is a value from 0 to 3 (UP, RIGHT, DOWN, LEFT)

Parameters

None

Example

1 2 3 use Libraries.Robots.Spike.LightMatrix LighMatrix lights integer orientation = lights:GetOrientation()

SetOrientation(integer orientation)

Returns

integer
Returns the orientation of the light matrix, which is a value from 0 to 3 (UP, RIGHT, DOWN, LEFT)

Parameters

  1. 1.integerorientation

    The direction to orient the light matrix, defined as a value from 0 to 3 (UP, RIGHT, DOWN, LEFT).

Example

1 2 3 use Lsibraries.Robots.Spike.LightMatrix LightMatrix lights lights:SetOrientation(lights:UP)