GlowBit.py
Classes | Public Member Functions | Public Attributes | List of all members
glowbit.stick Class Reference
Inheritance diagram for glowbit.stick:
Inheritance graph
[legend]
Collaboration diagram for glowbit.stick:
Collaboration graph
[legend]

Classes

class  graph1D
 One dimensional graph ofject for drawing a graph bar on a GlowBit Stick display. More...
 
class  pulse
 A class for animating "pulses" which move down a GlowBit stick. More...
 

Public Member Functions

def __init__ (self, numLEDs=8, pin=18, brightness=20, rateLimitFPS=30, sm=0)
 Initialisation routine for GlowBit stick modules and tiled arrays thereof. More...
 
def addPulse (self, speed=100, colour=[0xFFFFFF], index=0, colourMap=None)
 Add a pulse to the list of pulses. More...
 
def updatePulses (self)
 Update the position of all pulses in self.pulses[] and draw them to the internal buffer. More...
 
def newGraph1D (self, minIndex=0, maxIndex=7, minValue=0, maxValue=255, colour=0xFFFFFF, colourMap="Solid", update=False)
 Wrapper function to create graph1D objects. More...
 
def updateGraph1D (self, graph, value)
 Updates a graph1D object, drawing it to the display. More...
 
def fillSlice (self, i=0, j=-1, colour=0xFFFFFF)
 Fill a "slice" of the GlowBit stick's pixels with a solid colour. More...
 
def pulseDemo (self, iters=100)
 A demonstration of the use of "pulse" objects. More...
 
def graphDemo (self, iters=3)
 A demonstration of the use of "graph1D" objects. More...
 
def sliceDemo (self)
 A Demonstration of the use of the "fillSlice" method. More...
 
def rainbowDemo (self, iters=5)
 Uses the colourMapRainbow() colour map to display a colourful animation.
 
def demo (self)
 Runs several demo patterns.
 
- 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
 
 numLEDs
 
 strip
 
 lastFrame_ms
 
 ar
 
 dimmer_ar
 
 rateLimit
 
 brightness
 
 pulses
 
- 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
 

Constructor & Destructor Documentation

◆ __init__()

def glowbit.stick.__init__ (   self,
  numLEDs = 8,
  pin = 18,
  brightness = 20,
  rateLimitFPS = 30,
  sm = 0 
)

Initialisation routine for GlowBit stick modules and tiled arrays thereof.

Parameters
numLEDsThe total number of LEDs. Should be set to 8 * (the number of tiled 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].
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

◆ addPulse()

def glowbit.stick.addPulse (   self,
  speed = 100,
  colour = [0xFFFFFF],
  index = 0,
  colourMap = None 
)

Add a pulse to the list of pulses.

Parameters
speedThe speed of the pulse in units of (pixels moved per frame) * 100. A value of 100 means the pulse will move 1 pixels per frame. A speed of 1 will move a pulse 1 pixel every 100 frames. Speed can be positive or negative to allow pulses to move in either direction.
colourA list of 32-bit GlowBit colours for the pulse. The pulse will have a width equal to the number of elements in this list. A list entry of -1 will have the colour set by a colour map function.
indexThe initial index of the pulse. Generally recommended to set to 0 if speed > 0 and numLEDs if speed < 0.
colourMapEither the string "Solid" or "Rainbow" or a custom function pointer. Custom functions must take the positional arguments: colourMapFunction(self, index, minIndex, maxIndex). When calling colour map functions updatePulses() sets minIndex to 0 and maxIndex to numLEDs.

◆ fillSlice()

def glowbit.stick.fillSlice (   self,
  i = 0,
  j = -1,
  colour = 0xFFFFFF 
)

Fill a "slice" of the GlowBit stick's pixels with a solid colour.

By default it will fill the entire display with a solid colour.

Parameters
iThe minimum index to fill
jThe maximum index to fill
colourA 32-bit GlowBit colour value

◆ graphDemo()

def glowbit.stick.graphDemo (   self,
  iters = 3 
)

A demonstration of the use of "graph1D" objects.

This demonstration alternates between drawing two graphs with different colour maps; one with the "Rainbow" map, covering the full colour wheel, and another of solid white.

Parameters
itersThe number of times both graphs are drawn.

◆ newGraph1D()

def glowbit.stick.newGraph1D (   self,
  minIndex = 0,
  maxIndex = 7,
  minValue = 0,
  maxValue = 255,
  colour = 0xFFFFFF,
  colourMap = "Solid",
  update = False 
)

Wrapper function to create graph1D objects.

Returns a new stick.graph1D() object.

See also stick.graph1D()

Parameters
minIndexThe pixel index for the start of the graph
maxIndexThe pixel index for the end of the graph
minValueThe numerical value of the start of the graph
maxValueThe numerical value of the end of the graph
colourThe graph's colour if using the Solid colourmap
colourMapEither the string "Solid" or "Rainbow" or a function pointer to a custom colour map. Custom colour maps must take the parameters colourMap(Self, index, minIndex, maxIndex).
updateIf this is set to True then a call to updateGraph1D() will automatically call pixelsShow() to update the physical display.

◆ pulseDemo()

def glowbit.stick.pulseDemo (   self,
  iters = 100 
)

A demonstration of the use of "pulse" objects.

The pulse traveling "up" the stick is drawn with default arguments: a single white pixel

The pulse returning "down" the stick is drawn with a 3-pixel list of colours. The first and last are coloured with the "Rainbow" colour map, changing colour with pixel index, while the middle is white.

Parameters
itersThe number of frames which are drawn before returning.

◆ sliceDemo()

def glowbit.stick.sliceDemo (   self)

A Demonstration of the use of the "fillSlice" method.

Animates a red, green, and blue slice "moving" down the GlowBit Stick display.

The number of iterations is fixed due to the bit shift operation being used to change colour.

◆ updateGraph1D()

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

Updates a graph1D object, drawing it to the display.

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 stick.graph1D
valueThe numerical value to plot on the graph

◆ updatePulses()

def glowbit.stick.updatePulses (   self)

Update the position of all pulses in self.pulses[] and draw them to the internal buffer.

A call to pixelsShow() must be done manually to update the physical LEDs.


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