ColorMatrix

The color matrix is an external device that is connected to the hub through a port. The color matrix is a 3x3 matrix of lights where the color and brightness of each pixel can be changed to display things.

GetPort()

Returns

integer
Returns the currently assigned port for this color matrix

Parameters

None

Example

1 2 3 use Libraries.Robots.Spike.ColorMatrix ColorMatrix cm integer port = cm:GetPort()

SetPort(integer port)

Returns

None

Parameters

  1. 1.integerport

    The port that this color matrix object will be set to

Example

1 2 3 4 5 use Libraries.Robots.Spike.ColorMatrix use Libraries.Robots.Spike.Port ColorMatrix cm Port port cm:SetPort(port:A)

Clear()

Returns

None
Clears all pixels on the color matrix

Parameters

None

Example

1 2 3 4 5 6 use Libraries.Robots.Spike.ColorMatrix use Libraries.Robots.Spike.Port ColorMatrix cm Port port cm:SetPort(port:A) cm:Clear()

GetPixelColor(integer x, integer y)

Returns

Array<integer>
Returns an array of size 2 with the color and intensity of the pixel at the provided x and y location

Parameters

  1. 1.integerx

    The x location of the pixel, 0 to 2

  2. 2.integery

    The y location of the pixel, 0 to 2

Example

1 2 3 4 5 6 7 use Libraries.Robots.Spike.ColorMatrix use Libraries.Robots.Spike.Port use Libraries.Containers.Array ColorMatrix cm Port port cm:SetPort(port:A) Array<integer> colorIntensity = cm:GetPixelColor(0, 0)

SetPixelColor(integer x, integer y, integer color, integer intensity)

Returns

None
Sets the color and intensity of the pixel at the provided x and y location

Parameters

  1. 1.integerx

    The x location of the pixel, 0 to 2

  2. 2.integery

    The y location of the pixel, 0 to 2

  3. 3.integercolor

    The color constant to set the pixel to (see Color)

  4. 4.integerintensity

    The intensity (brightness) to set the pixel to

Example

1 2 3 4 5 6 7 8 use Libraries.Robots.Spike.ColorMatrix use Libraries.Robots.Spike.Color use Libraries.Robots.Spike.Port ColorMatrix cm Color color Port port cm:SetPort(port:A) cm:SetPixelColor(0, 0, color:RED, 100)

ShowColors(Array<integer> colorValues, Array<integer> intensityValues)

Returns

None
Changes the color and intensity (brightness) of all pixels from the provided color and intensity arrays

Parameters

  1. 1.Array<integer>colorValues

    An integer array of size 9 containing the color for each pixel

  2. 2.Array<integer>intensityValues

    An integer array of size 9 containing the intensity for each pixel

Example

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 use Libraries.Robots.Spike.ColorMatrix use Libraries.Robots.Spike.Color use Libraries.Robots.Spike.Port use Libraries.Containers.Array ColorMatrix cm Color color Port port Array<integer> colors Array<integer> intensities repeat 9 times colors:Add(color:RED) intensities:Add(100) end cm:SetPort(port:A) cm:ShowColors(colors, intensities)