GlowBit.py
Classes | Public Member Functions | List of all members
glowbit.glowbitMatrix Class Reference

Methods specific to 2D matrix displays and tiled arrangements thereof. More...

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

Classes

class  graph1D
 One dimensional graph object for graph bars on GlowBit Matrix displays. More...
 
class  graph2D
 Object for drawing 2 dimensional time series graphs on GlowBit Matrix displays. More...
 
class  raindrop
 A class used by the rain() demonstration. More...
 

Public Member Functions

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...
 

Additional Inherited Members

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

Detailed Description

Methods specific to 2D matrix displays and tiled arrangements thereof.

This class should not be used directly; its methods are inherited by the glowbit.matrix8x8 and glowbit.matrix4x4 classes.

Member Function Documentation

◆ circularRainbow()

def glowbit.glowbitMatrix.circularRainbow (   self)

Demonstration of a rainbow effect is pseudo-polar coordinates.

This function intentionally uses integer arithmetic for performance reasons. As such, it is drawn half a pixel off center.

The function animates 255 frames then returns.

◆ drawCircle()

def glowbit.glowbitMatrix.drawCircle (   self,
  x0,
  y0,
  r,
  colour 
)

Draws a circle with center (x0,y0) and radius r.

The circle's outline is drawn in the specified colour. Pixels inside the circle are not modified.

Parameters
x0The x coordinate of the circle's center
y0The y coordinate of the circle's center
colourA packed 32-bit GlowBit colour value

◆ drawLine()

def glowbit.glowbitMatrix.drawLine (   self,
  x0,
  y0,
  x1,
  y1,
  colour 
)

Draws a straight line between (x0,y0) and (x1,y1) in the specified 32-bit GlowBit colour.

If pixel is drawn off the screen a "clipping" effect will be inherited from the behaviour of pixelSetXYClip(). ie: Pixels landing off the screen will not be drawn.

Parameters
x0The line's starting x coordinate
y0The line's starting y coordinate
x1The line's ending x coordinate
y1The line's ending y coordinate
colourA packed 32-bit GlowBit colour value

◆ drawRectangle()

def glowbit.glowbitMatrix.drawRectangle (   self,
  x0,
  y0,
  x1,
  y1,
  colour 
)

Draws a rectangle with upper-left corner (x0,y0) and lower right corner (x1, y1).

All edge lines are drawn with the specified colour.

Pixels inside the rectangle are left unmodified.

If pixel is drawn off the screen a "clipping" effect will be inherited from the behaviour of pixelSetXYClip(). ie: Pixels landing off the screen will not be drawn.

Parameters
x0The x coordinate of the upper left corner
y0The y coordinate of the upper left corner
x1The x coordinate of the lower right corner
y1The y coordinate of the lower right corner
colourA packed 32-bit GlowBit colour value

◆ drawRectangleFill()

def glowbit.glowbitMatrix.drawRectangleFill (   self,
  x0,
  y0,
  x1,
  y1,
  colour 
)

Draws a rectangle with upper-left corner (x0,y0) and lower right corner (x1, y1).

The rectangle is then filled to form a solid block of the specified colour.

This method overwrites pixel data with the colour value.

If pixel is drawn off the screen a "clipping" effect will be inherited from the behaviour of pixelSetXYClip(). ie: Pixels landing off the screen will not be drawn.

Parameters
x0The x coordinate of the upper left corner
y0The y coordinate of the upper left corner
x1The x coordinate of the lower right corner
y1The y coordinate of the lower right corner
colourA packed 32-bit GlowBit colour value

◆ drawRectangleFillAdd()

def glowbit.glowbitMatrix.drawRectangleFillAdd (   self,
  x0,
  y0,
  x1,
  y1,
  colour 
)

Draws a rectangle with upper-left corner (x0,y0) and lower right corner (x1, y1).

The rectangle is then filled to form a solid block of the specified colour.

This method adds a colour to every pixel, allowing a rectangle to be drawn over the top of other pixel data.

If pixel is drawn off the screen a "clipping" effect will be inherited from the behaviour of pixelSetXYClip(). ie: Pixels landing off the screen will not be drawn.

Parameters
x0The x coordinate of the upper left corner
y0The y coordinate of the upper left corner
x1The x coordinate of the lower right corner
y1The y coordinate of the lower right corner
colourA packed 32-bit GlowBit colour value

◆ drawTriangle()

def glowbit.glowbitMatrix.drawTriangle (   self,
  x0,
  y0,
  x1,
  y1,
  x2,
  y2,
  colour 
)

Draws a triangle with vertices (corners) at (x0,y0), (x1, y1), and (x2,y2).

All lines are drawn with the specified colour.

If pixel is drawn off the screen a "clipping" effect will be inherited from the behaviour of pixelSetXYClip(). ie: Pixels landing off the screen will not be drawn.

Parameters
x0The x coordinate of the first vertex
y0The y coordinate of the first vertex
x1The x coordinate of the second vertex
y1The y coordinate of the second vertex
x2The x coordinate of the third vertex
y2The y coordinate of the third vertex
colourA packed 32-bit GlowBit colour value

◆ fireworks()

def glowbit.glowbitMatrix.fireworks (   self,
  iters = 10 
)

Demonstrate drawing randomly placed, randomly coloured, expanding circles.

Note that pixelsFill(0) is only called after drawing an expanding circle, simulating a mostly filled circle. Gaps are an artefact of the circle drawing algorithm, not a bug.

◆ getPixelXY()

def glowbit.glowbitMatrix.getPixelXY (   self,
  x,
  y 
)

Returns the 32-bit GlowBit colour value of the LED at a given (x,y) coordinate.

If the (x,y) coordinate falls outside of the display's boundary an IndexError exception may be thrown or the GlowBit colour value of an undefined pixel may be returned.

Parameters
iThe index of the LED
Returns
The 32-bit GlowBit colour value of the i'th LED

◆ newGraph1D()

def glowbit.glowbitMatrix.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.

Calling matrix.graph1D() directly is recommended - this is only here so that it appears more clearly in the Doxygen.

◆ pixelAddXY()

def glowbit.glowbitMatrix.pixelAddXY (   self,
  x,
  y,
  colour 
)

Adds the colour value to the GlowBit LED at a given (x,y) coordinate.

The coordinate assumes an origin in the upper left of the display with x increasing to the right and y increasing downwards.

If the x-y coordinate falls outside the display's boundary this function will "wrap-around". For example, A dot placed just off the right edge will appear along the left edge.

Data colour corruption will occur if the sum result of any RGB value exceeds 255. Care must be taken to avoid this manually. eg: if the blue channel's resulting intensity value is 256 it will be set to zero and the red channel incremented by 1. See the colourFunctions class documentation for the 32-bit GlowBit colour specification.

Parameters
xThe x coordinate of the GlowBit LED. x must be an integer.
yThe y coordinate of the GlowBit LED. y must be an integer.
colourA packed 32-bit GlowBit colour value

◆ pixelAddXYClip()

def glowbit.glowbitMatrix.pixelAddXYClip (   self,
  x,
  y,
  colour 
)

Adds the colour value to the GlowBit LED at a given (x,y) coordinate.

The coordinate assumes an origin in the upper left of the display with x increasing to the right and y increasing downwards.

If the x-y coordinate falls outside the display's boundary the display's internal buffer will not be modified.

Data colour corruption will occur if the sum result of any RGB value exceeds 255. Care must be taken to avoid this manually. eg: if the blue channel's resulting intensity value is 256 it will be set to zero and the red channel incremented by 1. See the colourFunctions class documentation for the 32-bit GlowBit colour specification.

Parameters
xThe x coordinate of the GlowBit LED. x must be an integer.
yThe y coordinate of the GlowBit LED. y must be an integer.
colourA packed 32-bit GlowBit colour value

◆ pixelSetXY()

def glowbit.glowbitMatrix.pixelSetXY (   self,
  x,
  y,
  colour 
)

Sets the colour value of the GlowBit LED at a given x-y coordinate.

The coordinate assumes an origin in the upper left of the display with x increasing to the right and y increasing downwards.

If the x-y coordinate falls outside the display's boundary this function will "wrap-around". For example, A dot placed just off the right edge will appear along the left edge in the same row.

Advanced: If seeking maximum speed consider modifying the ar[] array directly

Parameters
xThe x coordinate of the GlowBit LED. x must be an integer.
yThe y coordinate of the GlowBit LED. y must be an integer.
colourA packed 32-bit GlowBit colour value

◆ pixelSetXYClip()

def glowbit.glowbitMatrix.pixelSetXYClip (   self,
  x,
  y,
  colour 
)

Sets the colour value of the GlowBit LED at a given x-y coordinate.

The coordinate assumes an origin in the upper left of the display with x increasing to the right and y increasing downwards.

If the x-y coordinate falls outside the display's boundary the display's internal buffer will not be modified.

Parameters
xThe x coordinate of the GlowBit LED. x must be an integer.
yThe y coordinate of the GlowBit LED. y must be an integer.
colourA packed 32-bit GlowBit colour value

◆ pixelSetXYNow()

def glowbit.glowbitMatrix.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.

The coordinate assumes an origin in the upper left of the display with x increasing to the right and y increasing downwards.

If the x-y coordinate falls outside the display's boundary this function will "wrap-around". For example, A dot placed just off the right edge will appear along the left edge.

Advanced: If seeking maximum speed consider modifying the ar[] array directly

Parameters
xThe x coordinate of the GlowBit LED. x must be an integer.
yThe y coordinate of the GlowBit LED. y must be an integer.
colourA packed 32-bit GlowBit colour value

◆ rain()

def glowbit.glowbitMatrix.rain (   self,
  iters = 200,
  density = 1 
)

A "digital rain" demonstration.

Parameters
itersThe number of frames on which raindrops can be drawn
densityThe density of raindrops in units of "drops per 4x4 square". The number of drops on the screen will be kept at (number of pixels)*(density)/16

◆ textDemo()

def glowbit.glowbitMatrix.textDemo (   self,
  text = "Scrolling Text Demo" 
)

Demonstrates creation of non-blocking scrolling text.

Only compatible with the GlowBit Matrix 8x8 and tiled arrangements thereof.

Parameters
textA string of text which is scrolled across the top row of the display.

◆ updateGraph1D()

def glowbit.glowbitMatrix.updateGraph1D (   self,
  graph,
  value 
)

Updates a graph1D object, draws it to the display buffer.

If the graph1D object was created with "update = True" this function will call pixelsShow() to update the physical display before returning.

Parameters
graphA graph1D object as returned by glowbitMatrix.graph1D()
valueThe value to draw to the graph. It will be mapped to the graph bet

◆ updateGraph2D()

def glowbit.glowbitMatrix.updateGraph2D (   self,
  graph,
  value 
)

Updates a 2D graph with a new value.

Parameters
graphA graph2D object created graph2D
valueA new value to draw to the graph. This value will be drawn on the right edge and the oldest value will be deleted.

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