Package blinkstick :: Module blinkstick :: Class BlinkStickProMatrix
[frames] | no frames]

Class BlinkStickProMatrix

source code

   object --+    
            |    
BlinkStickPro --+
                |
               BlinkStickProMatrix

BlinkStickProMatrix class is specifically designed to control the individually addressable LEDs connected to the device and arranged in a matrix. The tutorials section contains all the details on how to connect them to BlinkStick Pro with matrices.

http://www.blinkstick.com/help/tutorials/blinkstick-pro-adafruit-neopixel-matrices

Code example on how you can use this class are available here:

https://github.com/arvydas/blinkstick-python/wiki#code-examples-for-blinkstick-pro

Matrix is driven by using BlinkStickProMatrix.set_color with [x,y] coordinates and class automatically divides data into subsets and sends it to the matrices.

For example, if you have 2 8x8 matrices connected to BlinkStickPro and you initialize the class with

>>> matrix = BlinkStickProMatrix(r_columns=8, r_rows=8, g_columns=8, g_rows=8)

Then you can set the internal framebuffer by using {set_color} command:

>>> matrix.set_color(x=10, y=5, r=255, g=0, b=0)
>>> matrix.set_color(x=6, y=3, r=0, g=255, b=0)

And send data to both matrices in one go:

>>> matrix.send_data_all()
Instance Methods
 
__init__(self, r_columns=0, r_rows=0, g_columns=0, g_rows=0, b_columns=0, b_rows=0, delay=0.002, max_rgb_value=255)
Initialize BlinkStickProMatrix class.
source code
 
set_color(self, x, y, r, g, b, remap_values=True)
Set the color of a single pixel in the internal framebuffer.
source code
(int, int, int)
get_color(self, x, y)
Get the current color of a single pixel.
source code
 
shift_left(self, remove=False)
Shift all LED values in the matrix to the left
source code
 
shift_right(self, remove=False)
Shift all LED values in the matrix to the right
source code
 
shift_down(self, remove=False)
Shift all LED values in the matrix down
source code
 
shift_up(self, remove=False)
Shift all LED values in the matrix up
source code
 
number(self, x, y, n, r, g, b)
Render a 3x5 number n at location x,y and r,g,b color
source code
 
rectangle(self, x1, y1, x2, y2, r, g, b)
Draw a rectangle with it's corners at x1:y1 and x2:y2
source code
 
line(self, x1, y1, x2, y2, r, g, b)
Draw a line from x1:y1 and x2:y2
source code
 
clear(self)
Set all pixels to black in the cached matrix
source code
 
send_data(self, channel)
Send data stored in the internal buffer to the channel.
source code

Inherited from BlinkStickPro: connect, off, send_data_all

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties

Inherited from object: __class__

Method Details

__init__(self, r_columns=0, r_rows=0, g_columns=0, g_rows=0, b_columns=0, b_rows=0, delay=0.002, max_rgb_value=255)
(Constructor)

source code 

Initialize BlinkStickProMatrix class.

Parameters:
  • r_columns (int) - number of matric columns for R channel
  • g_columns (int) - number of matric columns for R channel
  • b_columns (int) - number of matric columns for R channel
  • delay (int) - default transmission delay between frames
  • max_rgb_value (int) - maximum color value for RGB channels
Overrides: object.__init__

set_color(self, x, y, r, g, b, remap_values=True)

source code 

Set the color of a single pixel in the internal framebuffer.

Parameters:
  • x (int) - the x location in the matrix
  • y (int) - the y location in the matrix
  • r (int) - red color byte
  • g (int) - green color byte
  • b (int) - blue color byte
  • remap_values (bool) - Automatically remap values based on the {max_rgb_value} supplied in the constructor
Overrides: BlinkStickPro.set_color

get_color(self, x, y)

source code 

Get the current color of a single pixel.

Parameters:
  • x (int) - x coordinate of the internal framebuffer
  • y (int) - y coordinate of the internal framebuffer
Returns: (int, int, int)
3-tuple for R, G and B values
Overrides: BlinkStickPro.get_color

shift_left(self, remove=False)

source code 

Shift all LED values in the matrix to the left

Parameters:
  • remove (bool) - whether to remove the pixels on the last column or move the to the first column

shift_right(self, remove=False)

source code 

Shift all LED values in the matrix to the right

Parameters:
  • remove (bool) - whether to remove the pixels on the last column or move the to the first column

shift_down(self, remove=False)

source code 

Shift all LED values in the matrix down

Parameters:
  • remove (bool) - whether to remove the pixels on the last column or move the to the first column

shift_up(self, remove=False)

source code 

Shift all LED values in the matrix up

Parameters:
  • remove (bool) - whether to remove the pixels on the last column or move the to the first column

number(self, x, y, n, r, g, b)

source code 

Render a 3x5 number n at location x,y and r,g,b color

Parameters:
  • x (int) - the x location in the matrix (left of the number)
  • y (int) - the y location in the matrix (top of the number)
  • n (int) - number digit to render 0..9
  • r (int) - red color byte
  • g (int) - green color byte
  • b (int) - blue color byte

rectangle(self, x1, y1, x2, y2, r, g, b)

source code 

Draw a rectangle with it's corners at x1:y1 and x2:y2

Parameters:
  • x1 (int) - the x1 location in the matrix for first corner of the rectangle
  • y1 (int) - the y1 location in the matrix for first corner of the rectangle
  • x2 (int) - the x2 location in the matrix for second corner of the rectangle
  • y2 (int) - the y2 location in the matrix for second corner of the rectangle
  • r (int) - red color byte
  • g (int) - green color byte
  • b (int) - blue color byte

line(self, x1, y1, x2, y2, r, g, b)

source code 

Draw a line from x1:y1 and x2:y2

Parameters:
  • x1 (int) - the x1 location in the matrix for the start of the line
  • y1 (int) - the y1 location in the matrix for the start of the line
  • x2 (int) - the x2 location in the matrix for the end of the line
  • y2 (int) - the y2 location in the matrix for the end of the line
  • r (int) - red color byte
  • g (int) - green color byte
  • b (int) - blue color byte

clear(self)

source code 

Set all pixels to black in the cached matrix

Overrides: BlinkStickPro.clear

send_data(self, channel)

source code 

Send data stored in the internal buffer to the channel.

Parameters:
  • channel -
    • 0 - R pin on BlinkStick Pro board
    • 1 - G pin on BlinkStick Pro board
    • 2 - B pin on BlinkStick Pro board
Overrides: BlinkStickPro.send_data