Skip to content

Commit

Permalink
Continued development - not quite there yet!
Browse files Browse the repository at this point in the history
  • Loading branch information
GeekyTim authored and GeekyTim committed Aug 19, 2020
1 parent 48a9598 commit 453f5f8
Show file tree
Hide file tree
Showing 16 changed files with 387 additions and 415 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ ipython_config.py
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
# PEP 582; used by e.green. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
Expand Down
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def setup(app):
#
# html_use_opensearch = ''

# This is the file name suffix for HTML files (e.g. ".xhtml").
# This is the file name suffix for HTML files (e.green. ".xhtml").
# html_file_suffix = None

# Language to be used for generating the HTML full-text search index.
Expand Down
6 changes: 5 additions & 1 deletion docs/source/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ Uncomment or add the following to in the optional hardware interfaces::

dtparam=spi=on

Add the following line to the end of the file to set memory frequency::

core_freq=250

Disable Sound in the Kernel
===========================

Expand All @@ -54,7 +58,7 @@ boot commandline file::

sudo nano /boot/cmdline.txt

Add the following to the end of the only line to increase the SPI buffer size:
Add the following to the end of the only line to increase the SPI buffer size::

spidev.bufsiz=32768

Expand Down
25 changes: 15 additions & 10 deletions docs/source/library.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,34 @@ If you have not already installed the library, see :ref:`Installing the Python L

Creating a Strip Object
-----------------------
.. module:: pixelpi

.. autoclass:: pixelpi.Strip
:members: getLength, getWidth, getHeight, getStripType, getStripNumber, getUpdateStatus, getStripPattern

Setting LED Colours
-------------------
.. automethod:: pixelpi.Strip.showStrip
.. autoclass:: pixelpi.Strip
:members: getLength, getWidth, getHeight, getStripType, getStripNumber, updateStatus

Setting LED Colours and Brightness
----------------------------------
.. automethod:: pixelpi.Strip.setLED

.. automethod:: pixelpi.Strip.clearStrip
.. automethod:: pixelpi.Strip.getLED

.. automethod:: pixelpi.Strip.setBrightness

.. automethod:: pixelpi.Strip.setUpdateStatus
.. automethod:: pixelpi.Strip.setImage

.. automethod:: pixelpi.Strip.getLED
.. automethod:: pixelpi.Strip.setPattern

.. automethod:: pixelpi.Strip.setImage
.. automethod:: pixelpi.Strip.clearStrip

.. automethod:: pixelpi.Strip.setStripPattern

Manipulating LED Colours
------------------------
.. automethod:: pixelpi.Strip.rotateStrip

.. automethod:: pixelpi.Strip.reflectStrip

Controlling Strip Updates
-------------------------
.. automethod:: pixelpi.Strip.showStrip

38 changes: 9 additions & 29 deletions examples/clear.py
Original file line number Diff line number Diff line change
@@ -1,33 +1,13 @@
#!/usr/bin/env python3

import colorsys
import time
from pixelpi import PixelPi
from pixelpi import Strip

"""
Available strip types (note, setting the white element of LEDs is currently not supported):
strip1 = Strip(1, 300, brightness=40)
strip2 = Strip(2, 300, brightness=40)
strip3 = Strip(3, 300, brightness=40)
strip4 = Strip(4, 300, brightness=40)

* `WS2812`
* `SK6812`
* `SK6812W`
* `SK6812_RGBW`
* `SK6812_RBGW`
* `SK6812_GRBW`
* `SK6812_GBRW`
* `SK6812_BRGW`
* `SK6812_BGRW`
* `WS2811_RGB`
* `WS2811_RBG`
* `WS2811_GRB`
* `WS2811_GBR`
* `WS2811_BRG`
* `WS2811_BGR`
"""

strip = PixelPi(1, 300, striptype='WS2811_GRB', brightness=40)
strip = PixelPi(2, 300, striptype='WS2811_GRB', brightness=40)
strip = PixelPi(3, 300, striptype='WS2811_GRB', brightness=40)
strip = PixelPi(4, 300, striptype='WS2811_GRB', brightness=40)

strip.clearStrip()
strip.showStrip()
for strip in [strip1, strip2, strip3, strip4]:
strip.clearStrip()
strip.showStrip()
del strip
53 changes: 23 additions & 30 deletions examples/image.py
Original file line number Diff line number Diff line change
@@ -1,37 +1,30 @@
from time import sleep

from PIL import Image
from pixelpi import PixelPi
from pixelpi import Strip

im = Image.open("image.png").convert(mode='RGB', colors=256)

# strip1 = Strip(2, (8, 8), striptype='SK6812_GRBW', stripshape="matrix", brightness=0.2)
strip2 = PixelPi(2, (8, 32), striptype='WS2812', stripshape="zmatrix", brightness=0.2)
# strip1 = Strip(2, (8, 8), ledtype='SK6812_GRBW', shape="matrix", brightness=0.2)
strip = Strip(terminal=2, size=(8, 32), ledtype='WS2812', shape="zmatrix", brightness=30)

i = 0
while True:
i = i + 1
if i >= 32:
i = 0
im = im.transpose(Image.ROTATE_90)
# strip1.set_image(im)
strip2.setImage(im, (0, i))
strip2.showStrip()
sleep(0.5)
im = im.transpose(Image.ROTATE_90)
# strip1.set_image(im)
strip2.setImage(im, (0, i))
strip2.showStrip()
sleep(0.5)
im = im.transpose(Image.ROTATE_90)
# strip1.set_image(im)
strip2.setImage(im, (0, i))
strip2.showStrip()
sleep(0.5)
im = im.transpose(Image.ROTATE_90)
# strip1.set_image(im)
strip2.setImage(im, (0, i))
strip2.showStrip()
sleep(0.5)
strip2.clearStrip()
strip2.showStrip()
try:
i = 0
while True:
i = i + 1
if i >= 32:
i = 0

for r in range(4):
im = im.transpose(Image.ROTATE_90)
strip.setLED(led=(0, i), image=im)
strip.showStrip()
sleep(0.5)

strip.clearStrip()
strip.showStrip()

except KeyboardInterrupt:
strip.clearStrip()
strip.showStrip()
del strip
48 changes: 27 additions & 21 deletions examples/rainbow.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,37 @@
#!/usr/bin/env python3

import colorsys
import time

import colorsys
from pixelpi import Strip

strip1 = Strip(2, 300, stripshape='straight', striptype='WS2811_GRB', brightness=50)
# strip2 = Strip(2, 10, striptype='SK6812_GRBW', brightness=50)
# strip3 = Strip(3, 10, striptype='WS2811_RGB', brightness=50)
# strip4 = Strip(4, 10, striptype='WS2811_RGB', brightness=50)
# Change the terminal type to the type you have
strip1 = Strip(1, 256, ledtype='WS2811_GRB', brightness=30)
strip2 = Strip(2, 256, ledtype='WS2811_GRB', brightness=30)
strip3 = Strip(3, 256, ledtype='WS2811_GRB', brightness=30)
strip4 = Strip(4, 256, ledtype='WS2811_GRB', brightness=30)

spacing = 360.0 / 16.0
hue = 0

while True:
hue = int(time.time() * 100) % 360
for x in range(256):
offset = x * spacing
h = ((hue + offset) % 360) / 360.0
r, g, b = [int(c * 255) for c in colorsys.hsv_to_rgb(h, 1.0, 1.0)]
strip1.setLED(r, g, b, LED=x)
# strip2.setLED(x, r, g, b)
# strip3.setLED(x, r, g, b)
# strip4.setLED(x, r, g, b)

strip1.showStrip()
# strip2.showStrip()
# strip3.showStrip()
# strip4.showStrip()
time.sleep(0.001)
try:
while True:
hue = int(time.time() * 100) % 360
for x in range(256):
offset = x * spacing
h = ((hue + offset) % 360) / 360.0
r, g, b = [int(c * 255) for c in colorsys.hsv_to_rgb(h, 1.0, 1.0)]

for strip in [strip1, strip2, strip3, strip4]:
strip.setLED(rgb=(r, g, b), led=x)

for strip in [strip1, strip2, strip3, strip4]:
strip.showStrip()

time.sleep(0.001)

except KeyboardInterrupt:
for strip in [strip1, strip2, strip3, strip4]:
strip.clearStrip()
strip.showStrip()
del strip
20 changes: 8 additions & 12 deletions examples/sequence.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
#!/usr/bin/env python3
import colorsys
import numpy
import time
from pixelpi import PixelPi
from typing import Any

strip2 = PixelPi(2, 256, striptype='WS2812', brightness=40)
from pixelpi import Strip

strip2.clearStrip()
colourarray = strip2.getStrip
strip = Strip(2, 256, striptype='WS2812', brightness=40)

strip.clearStrip()
colourarray = strip.getLED()

print(colourarray)

for pixel in range(len(colourarray)):
colourarray[pixel] = [pixel, 0, 255 - pixel, 51]

while True:
strip2.sequence_set(colourarray)
# strip2.sequence_reflect(colourarray)
strip2.showStrip()
strip.setLED(pattern=colourarray)
strip.showStrip()
# time.sleep(0.2)
colourarray = strip2.sequence_rotate(colourarray, 1)
colourarray = strip.rotateStrip(colourarray, 1)
96 changes: 54 additions & 42 deletions examples/testmatrix.py
Original file line number Diff line number Diff line change
@@ -1,55 +1,67 @@
#!/usr/bin/env python3

import time
from pixelpi import PixelPi

from pixelpi import Strip

"""
Available strip types (note, setting the white element of LEDs is currently not supported):
* `WS2812`
* `SK6812`
* `SK6812W`
* `SK6812_RGBW`
* `SK6812_RBGW`
* `SK6812_GRBW`
* `SK6812_GBRW`
* `SK6812_BRGW`
* `SK6812_BGRW`
* `WS2811_RGB`
* `WS2811_RBG`
* `WS2811_GRB`
* `WS2811_GBR`
* `WS2811_BRG`
* `WS2811_BGR`
Change the parameters below until you see the colours indicated on the screen:
terminal = The screw terminal your LEDs are connected to
size = The number of LEDs in your terminal (can be (x, y) for a matrix)
shape = The 'shape' of the terminal.
* `matrix` - a normal matrix where the led order goes left to right. i.e:
1 2 3 4
5 6 7 8
9 . . .
* `zmatrix` - A matrix where the pixels in the first row go left to right, the next one
right to left. i.e:
1 2 3 4
8 7 6 5
9 . . .
ledtype = One of the supported terminal types:
WS2812, SK6812, SK6812W, SK6812_RGBW, SK6812_RBGW, SK6812_GRBW, SK6812_GBRW, SK6812_BRGW,
SK6812_BGRW, WS2811_RGB, WS2811_RBG, WS2811_GRB, WS2811_GBR, WS2811_BRG, WS2811_BGR
brightness = The default brightness for all LEDs (0-255).
"""

strip = PixelPi(1, (8, 32), striptype='WS2812', stripshape="zmatrix", brightness=0.2)
print(strip.getStripType)
strip = Strip(4, (8, 32), shape="zmatrix", ledtype='WS2812', brightness=30)

while True:
print("Red")
strip.set_all(255, 0, 0)
strip.showStrip()
time.sleep(1)
try:
while True:
print("Red")
strip.setLED(rgb=(255, 0, 0))
strip.showStrip()
time.sleep(1)

print("Green")
strip.set_all(0, 255, 0)
strip.showStrip()
time.sleep(1)
print("Green")
strip.setLED(rgb=(0, 255, 0))
strip.showStrip()
time.sleep(1)

print("Blue")
strip.set_all(0, 0, 255)
strip.showStrip()
time.sleep(1)
print("Blue")
strip.setLED(rgb=(0, 0, 255))
strip.showStrip()
time.sleep(1)

strip.clearStrip()
strip.showStrip()

for y in range(strip.getHeight):
for x in range(strip.getWidth):
led = (x, y)
print("White: ", led)
strip.setLED(rgb=(255, 255, 255), led=led)
strip.showStrip()
time.sleep(0.25)
strip.setLED(rgb=(0, 0, 0), led=led)
strip.showStrip()

except KeyboardInterrupt:
strip.clearStrip()
strip.showStrip()

for y in range(strip.getHeight):
for x in range(strip.getWidth):
pixel = (x, y)
strip.set_pixel(pixel, 255, 255, 255)
strip.showStrip()
time.sleep(0.25)
strip.set_pixel(pixel, 0, 0, 0)
strip.showStrip()
del strip
Loading

0 comments on commit 453f5f8

Please sign in to comment.