GlowBit.py
Public Member Functions | Public Attributes | List of all members
glowbit.matrix4x4 Class Reference

Class for driving GlowBit Matrix 4x4 modules and horizontally tiled arrangements thereof. More...

Inheritance diagram for glowbit.matrix4x4:
Inheritance graph
[legend]
Collaboration diagram for glowbit.matrix4x4:
Collaboration graph
[legend]

Public Member Functions

def __init__ (self, tiles=1, pin=18, brightness=20, mapFunction=None, rateLimitFPS=30, sm=0)
 Initialisation routine for GlowBit stick modules and tiled arrays thereof. More...
 
def remap4x4 (self, x, y)
 Maps an (x,y) coordinate on a 4 row, Nx4 column, tiled GlowBit Matrix 4x4 array to an array index for the internal buffer. More...
 
- Public Member Functions inherited from glowbit.glowbitMatrix
def pixelSetXY (self, x, y, colour)
 Sets the colour value of the GlowBit LED at a given x-y coordinate. More...
 
def pixelSetXYNow (self, x, y, colour)
 Sets the colour value of the GlowBit LED at a given x-y coordinate and immediately calls pixelsShow() to update the physical LEDs. More...
 
def pixelSetXYClip (self, x, y, colour)
 Sets the colour value of the GlowBit LED at a given x-y coordinate. More...
 
def pixelAddXY (self, x, y, colour)
 Adds the colour value to the GlowBit LED at a given (x,y) coordinate. More...
 
def pixelAddXYClip (self, x, y, colour)
 Adds the colour value to the GlowBit LED at a given (x,y) coordinate. More...
 
def getPixelXY (self, x, y)
 Returns the 32-bit GlowBit colour value of the LED at a given (x,y) coordinate. More...
 
def drawLine (self, x0, y0, x1, y1, colour)
 Draws a straight line between (x0,y0) and (x1,y1) in the specified 32-bit GlowBit colour. More...
 
def drawTriangle (self, x0, y0, x1, y1, x2, y2, colour)
 Draws a triangle with vertices (corners) at (x0,y0), (x1, y1), and (x2,y2). More...
 
def drawRectangle (self, x0, y0, x1, y1, colour)
 Draws a rectangle with upper-left corner (x0,y0) and lower right corner (x1, y1). More...
 
def drawRectangleFill (self, x0, y0, x1, y1, colour)
 Draws a rectangle with upper-left corner (x0,y0) and lower right corner (x1, y1). More...
 
def drawRectangleFillAdd (self, x0, y0, x1, y1, colour)
 Draws a rectangle with upper-left corner (x0,y0) and lower right corner (x1, y1). More...
 
def drawCircle (self, x0, y0, r, colour)
 Draws a circle with center (x0,y0) and radius r. More...
 
def newGraph1D (self, originX=0, originY=7, length=8, direction="Up", minValue=0, maxValue=255, colour=0xFFFFFF, colourMap="Solid", update=False)
 Wrapper method to create a graph1D object. More...
 
def updateGraph1D (self, graph, value)
 Updates a graph1D object, draws it to the display buffer. More...
 
def updateGraph2D (self, graph, value)
 Updates a 2D graph with a new value. More...
 
def lineDemo (self, iters=10)
 Demonstrate drawing an animated line.
 
def fireworks (self, iters=10)
 Demonstrate drawing randomly placed, randomly coloured, expanding circles. More...
 
def circularRainbow (self)
 Demonstration of a rainbow effect is pseudo-polar coordinates. More...
 
def rain (self, iters=200, density=1)
 A "digital rain" demonstration. More...
 
def textDemo (self, text="Scrolling Text Demo")
 Demonstrates creation of non-blocking scrolling text. More...
 
def bounce (self, iters=500)
 Draws a single pixel at a random coordinate and "bounces" it around the display.
 
def demo (self)
 Runs several demo functions.
 
- Public Member Functions inherited from glowbit.glowbit
def pixelsShow (self)
 Pushes the internal pixel data buffer to the physical GlowBit LEDs. More...
 
def pixelSet (self, i, colour)
 Sets the i'th GlowBit LED to a 32-bit GlowBit colour value. More...
 
def pixelSetNow (self, i, colour)
 Sets the i'th GlowBit LED to a 32-bit GlowBit colour value and updates the physical LEDs. More...
 
def pixelAdd (self, i, colour)
 Adds a 32-bit GlowBit colour value to the i'th LED in the internal buffer only. More...
 
def pixelSaturatingAdd (self, i, colour)
 Adds a 32-bit GlowBit colour value to the i'th LED in the internal buffer. More...
 
def pixelsFill (self, colour)
 Fills all pixels with a solid colour value. More...
 
def pixelsFillNow (self, colour)
 Fills all pixels with a solid colour value and updates the physical LEDs. More...
 
def blankDisplay (self)
 Blanks the entire GlowBit display. More...
 
def getPixel (self, N)
 Returns the 32-bit GlowBit colour value of the i'th LED. More...
 
def updateRateLimitFPS (self, rateLimitFPS)
 Sets a new value for the GlowBit display's frames per second (FPS) limiter. More...
 
def power (self)
 Calculates an estimate for the total power draw given the current display data. More...
 
def chaos (self, iters=100)
 Sets random colour values on every LED on the attached GlowBit display. More...
 
- Public Member Functions inherited from glowbit.colourFunctions
def wheel (self, pos)
 Converts an integer "colour wheel position" to a packed 32-bit RGB GlowBit colour value. More...
 
def rgbColour (self, r, g, b)
 Converts the r, g, and b integer arguments to a packed 32-bit RGB GlowBit colour value. More...
 
def glowbitColour2RGB (self, colour)
 Converts a 32-bit GlowBit colour value to an (R,G,B) tuple. More...
 
def red (self)
 Returns the GlowBit colour value for pure red.
 
def green (self)
 Returns the GlowBit colour value for pure green.
 
def blue (self)
 Returns the GlowBit colour value for pure blue.
 
def yellow (self)
 Returns the GlowBit colour value for yellow.
 
def purple (self)
 Returns the GlowBit colour value for purple.
 
def cyan (self)
 Returns the GlowBit colour value for cyan.
 
def white (self)
 Returns the GlowBit colour value for white.
 
def black (self)
 Returns the GlowBit colour value for black.
 
- Public Member Functions inherited from glowbit.colourMaps
def colourMapSolid (self, index, minIndex, maxIndex)
 Trivial colourmap method which always returns the colour in the parent object. More...
 
def colourMapRainbow (self, index, minIndex, maxIndex)
 Maps the pure hue colour wheel between minIndex and maxIndex. More...
 

Public Attributes

 sm
 
 pixelsShow
 
 ticks_ms
 
 tiles
 
 numLEDs
 
 numLEDsX
 
 numLEDsY
 
 numCols
 
 numRows
 
 strip
 
 ar
 
 dimmer_ar
 
 lastFrame_ms
 
 scrollingText
 
 brightness
 
 remap
 
 rateLimit
 
- Public Attributes inherited from glowbit.glowbit
 lastFrame_ms
 
 rateLimit
 

Additional Inherited Members

- Static Public Attributes inherited from glowbit.glowbit
 sideset_init
 
 OUT_LOW
 
 out_shiftdir
 
 SHIFT_LEFT
 
 autopull
 
 True
 
 pull_thresh
 

Detailed Description

Class for driving GlowBit Matrix 4x4 modules and horizontally tiled arrangements thereof.

NB: The 4x4 matrix is designed to only tile horizontally, making an Nx4 pixel display.

If manually tiling horizontally and vertically a custom remapping function will need to be written.

The custom mapping function has the form mapFunction(self, x: int, y: int) -> int and returns a "one dimensional" pixel index given an (x,y) coordinate.

No checking is performed before calling the mapping function. An exception will be raised if the positional arguments are incorrect.

Constructor & Destructor Documentation

◆ __init__()

def glowbit.matrix4x4.__init__ (   self,
  tiles = 1,
  pin = 18,
  brightness = 20,
  mapFunction = None,
  rateLimitFPS = 30,
  sm = 0 
)

Initialisation routine for GlowBit stick modules and tiled arrays thereof.

Parameters
tilesThe number of tiled GlowBit Matrix 4x4 modules.
pinThe GPIO pin connected to the GlowBit stick module. Defaults to 18 as that pin is compatible with the Raspberry Pi and Raspberry Pi Pico. Any pin can be used on the Raspberry Pi Pico, only pins 18 and 12 are valid on the Raspberry Pi.
brightnessThe relative brightness of the LEDs. Colours drawn to the internal buffer should be in the range [0,255] and the brightness parameter scales this value before drawing to the physical display. If brightness is an integer it should be in the range [0,255]. If brightness is floating point it is assumed to be in the range [0,1.0].
mapFunctionA function pointer to a custom pixel mapping function. Only required if mapping pixels to non-standard tiling arrangements.
rateLimitFPSThe maximum frame rate of the display in frames per second. The pixelsShow() function blocks to enforce this limit.
sm(Raspberry Pi Pico only) The PIO state machine to generate the GlowBit data stream. Each connected GlowBit display chain requires a unique state machine. Valid values are in the range [0,7].

Member Function Documentation

◆ remap4x4()

def glowbit.matrix4x4.remap4x4 (   self,
  x,
  y 
)

Maps an (x,y) coordinate on a 4 row, Nx4 column, tiled GlowBit Matrix 4x4 array to an array index for the internal buffer.

It is recommended to use pixelSetXY() (and variants) instead of this function.

The return value can be passed to pixelSet(i, colour) (and its variants pixelSetNow() etc) in place of the paramter "i".

The (x,y) coordinates assume (0,0) in the upper left corner of the display with x increasing to the right and y increasing down

This function does not do boundary checking and may return a value which is outside the array, causing an IndexError exception to be raised.

Parameters
xThe x coordinate of the pixel to index
yThe y coordinate of the pixel to index

The documentation for this class was generated from the following file: