17 Commits

Author SHA1 Message Date
jhealy
acb4ea8f56 Formatting changes on README.md v15 2021-01-10 12:31:35 -05:00
jhealy
9a7bb116bf Formatting changes on README.md v14 2021-01-10 12:29:00 -05:00
jhealy
42a0bc722d Formatting changes on README.md v13 2021-01-10 12:26:14 -05:00
jhealy
eb728f3ddb Formatting changes on README.md v12 2021-01-10 12:25:03 -05:00
jhealy
62b91f103e Formatting changes on README.md v11 2021-01-10 12:22:11 -05:00
jhealy
6dc51746ea Formatting changes on README.md v10 2021-01-10 12:19:29 -05:00
jhealy
91dc76caa4 Formatting changes on README.md v9 2021-01-10 12:14:56 -05:00
jhealy
3915a5f317 Formatting changes on README.md v8 2021-01-10 12:11:50 -05:00
jhealy
aed3274bdf Formatting changes on README.md v7 2021-01-10 12:09:19 -05:00
jhealy
36ffcb5d77 Formatting changes on README.md v6 2021-01-10 12:05:04 -05:00
jhealy
4e78ca7d24 Formatting changes on README.md v5 2021-01-10 12:02:15 -05:00
jhealy
7733a922b6 Formatting changes on README.md v4 2021-01-10 11:58:29 -05:00
jhealy
b96dde47ef Formatting changes on README.md v3 2021-01-10 11:52:42 -05:00
jhealy
a71079c86f Formatting changes on README.md v2 2021-01-10 11:43:51 -05:00
jhealy
b421b016b5 Formatting changes on README.md 2021-01-10 11:39:07 -05:00
jhealy
3a83768c0c Update on README.md 2021-01-09 12:19:03 -05:00
jhealy
0b2e28795a Update on BP Structure Template 2021-01-09 10:21:11 -05:00
13 changed files with 207 additions and 203 deletions

21
LICENSE Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2021 Bramble-Hands-Software (BraHaSoft)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

156
README.md
View File

@@ -1,41 +1,127 @@
# RPi_WS2812b_LED
#Raspberry Pi Project
#WS2812b - LED
#Python3
Objective:
Be able to pass through data (text, designs, colors, patterns, etc) through GPIO on a Raspberry Pi, through to WS2812b LEDs.
Initial Challenges:
1 - Rasberry Pi doesn't have 1:1 libraries for Neopixel, so need to write programs to pass off to the Adafruit libraries (already installed)
2 - Current LEDs are in a "zigzag" configuration (because we can not use the 1:1 Neopixel Matrix Module), we have to take on the overhead to configure/define our LED matrix, then convert our data to that matrix
Example: LED Matrix numbered by: 8x8
0 | 15 | 16 | 31 | 32 | 47 | 48 | 63 | # tickerPi
1 | 14 | 17 | 30 | 33 | 46 | 49 | 62 |
2 | 13 | 18 | 29 | 34 | 45 | 50 | 61 |
3 | 12 | 19 | 28 | 35 | 44 | 51 | 60 |
4 | 11 | 20 | 27 | 36 | 43 | 52 | 59 |
5 | 10 | 21 | 26 | 37 | 42 | 53 | 58 |
6 | 9 | 22 | 25 | 38 | 41 | 54 | 57 |
7 | 8 | 23 | 24 | 39 | 40 | 55 | 56 |
vs tickerPi is a Python Program to handle WS281X LED interactions on a Raspberry Pi
* WS2812b has only been tested at this time
0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 ## Authors
15 | 14 | 13 | 12 | 11 | 10 | 9 | 8
16 | 17 | 18 | 19 | 20 | 21 | 22 | 23
31 | 30 | 29 | 28 | 27 | 26 | 25 | 24
32 | 33 | 34 | 35 | 36 | 37 | 38 | 39
47 | 46 | 45 | 44 | 43 | 42 | 41 | 40
48 | 49 | 50 | 51 | 52 | 53 | 54 | 55
63 | 62 | 61 | 60 | 59 | 58 | 57 | 56
3 - Read from a file > take the contents > convert to string > turn string into ASCII imagery > turn ASCII imagery into pixel grid matrix > convert matrix into zigzag matrix to send to Neopixel and throw it to the LED matrix. (piltest.py) already has this PoC up to the Matrix to zigzag. * **Justin Healy**
* **Vin Presciutti**
## Requirements
1. Python 3 - As Python 2 support is no longer available
2. Python 3 PIP
3. Python SMBus
4. RPI.GPIO
5. Adafruit Blinka
6. Adafruit Neopixel
7. RPI WS281X Libraries
8. Adafruit PixelFramebuffer
## Installation
1. Standard Updates for Raspberry Pi:
```
sudo apt-get update
sudo apt-get upgrade
sudo pip3 install --upgrade setuptools
```
* If this fails, try this and repeat step 1
```
sudo apt-get install python3-pip
```
* Recommended, but may not be required, setting your Python install to default with Python 3. There are multiple ways to do this, here's an example:
```
sudo apt-get install -y python3 git python3-pip
sudo update-alternatives --install /usr/bin/python python $(which python2) 1
sudo update-alternatives --install /usr/bin/python python $(which python3) 2
sudo update-alternatives --config python
```
2. Enabling I2C and SPI, which is only required to be done **once** for **each** Raspberry Pi:\
**Only Required if you are using multiple devices on your Raspberry Pi, if not, move to step 3**\
**Important:**
> If you are using a GPIO wiring setup for the LEDs that does not support I2C, you will not see anything show up for the LEDS.\
> Again, this is only for if you have **OTHER** devices you plan on hooking up to make sure they still show up under I2C
* Enabling I2C:
* From Command Line:
```
sudo apt-get install -y python-smbus
sudo apt-get install -y i2c-tools
sudo raspi-config
```
* Interfacing Options > I2C > Enable > Yes
> If you did not hit "finish" you can repeat these steps but change out the I2C for the SPI
* Enabling SPI:
* From Command Line:
```
sudo raspi-config
```
* Interfacing Options > SPI > Enable > Yes
* Click "Finish"
* Reboot your Raspberry Pi
```
sudo reboot
```
* Testing I2C and SPI after reboot:
* I2C Testing:
```
sudo i2cdetect -y 1
```
* If you do not get anything back from the above command, try seeing which I2C is being used under Dev:
```
ls /dev/i2c*
```
> Whichever number is after the "-" in "/dev/i2c-(X) is what you should replace the number in the command with
>> Example: /dev/i2c-3 = "sudo i2cdetect -y 3"
* SPI Testing:
```
ls -l /dev/spidev*
```
> This should return a device for each SPI bus (two)
3. Installing Python Support Libraries:
* GPIO - If not already installed:
```
sudo pip3 install RPI.GPIO
```
* Adafruit Blinka:
```
sudo pip3 install adafruit-blinka
```
* RPi WS281X and Neopixel:
```
sudo pip3 install rpi_ws281x adafruit-circuitpython-neopixel
sudo python3 -m pip install --force-reinstall adafruit-blinka
```
* PixelFramebuffer:
```
sudo pip3 install adafruit-circuitpython-pixel-framebuf
```
4. Changing Conflicting HDMI Settings:\
**Important:** Only do this if you are having issues with the LEDs, this is not always needed!\
```
sudo nano /boot/config.txt
```
* If it doesn't already exist, add:
```
hdmi_force_hotplug=1
hdmi_force_edid_audio=1
```
* Save and exit the file (ctrl + x > y)
* Reboot Raspberry Pi
```
sudo reboot
```
## Usage
TBD
## Contributing
TBD
## License
* [MIT](https://choosealicense.com/licenses/mit/)
> A copy of this can be found in the root directory of this project under "LICENSE"
4 - Figure out how to use Neopixel pass offs. (already solved and confirmed working)

65
Scroll_Pi_Text.py.save Normal file
View File

@@ -0,0 +1,65 @@
#Created By: Justin Healy and Vin Presciutti || 2021
#Based off of work done by 2020 Melissa LeBlanc-Williams, written for Adafruit Industries, MIT
#!/usr/bin/python3
import board
import neopixel
from PIL import Image
from adafruit_pixel_framebuf import PixelFramebuffer
import time
import argparse
gpio_pin = board.D18
pixel_width = 8
scroll_width = pixel_width + 1
pixel_height = 16
scroll_height = pixel_height + 1
pixel_max = pixel_width * pixel_height - 1
led_message = "Jaki"
# Main program logic follows:
if __name__ == '__main__':
# Process arguments
parser = argparse.ArgumentParser()
parser.add_argument('-c', '--clear', action='store_true', help='clear the display on exit')
args = parser.parse_args()
# Create NeoPixel object with appropriate configuration.
neo_pixel = neopixel.NeoPixel(gpio_pin, pixel_width * pixel_height, brightness=0.1, auto_write=False)
#Create PixelFramebuffer object with appropriate configuration.
pixel_framebuf = PixelFramebuffer(neo_pixel, pixel_width, pixel_height, reverse_x=True,alternating=True)
print ('Press Ctrl-C to quit.')
if not args.clear:
print('Use "-c" argument to clear LEDs on exit')
try:
while True:
led_message_len = len(led_message)
led_message_scroll_height = led_message_len * 16
for led_scroll in range(0, led_message_scroll_height , 1):
led_char_counter = 1
pixel_framebuf.fill(0x000000)
pixel_framebuf.display()
for led_char in led_message:
led_char_spacing = 8 * led_char_counter
led_char_pos = pixel_height - led_scroll + led_char_spacing
pixel_framebuf.text(led_char, 0, led_char_pos , 0x00FF00)
pixel_framebuf.display()
time.sleep
led_char_counter += 1
except KeyboardInterrupt:
if args.clear:
neo_pixel.deinit()

Binary file not shown.

View File

@@ -1,67 +0,0 @@
# Library containing the class interface to create a new LED light display.
import board
import neopixel
from PIL import Image
from adafruit_pixel_framebuf import PixelFramebuffer
import time
import argparse
class LightDisplay:
def __init__(self, x=8, y=8, orientation="vertical", color="red", speed=1):
self.x = x
self.y = y
self.orientation = orientation
self.color = color
self.speed = speed
def display(self, message="Hello World"):
# Init variables
gpio_pin = board.D18
pixel_width = self.x
scroll_width = pixel_width + 1
pixel_height = self.y
scroll_height = pixel_height + 1
pixel_max = pixel_width * pixel_height - 1
led_message = self.message
# Process arguments
parser = argparse.ArgumentParser()
parser.add_argument('-c', '--clear', action='store_true', help='clear the display on exit')
args = parser.parse_args()
# Create NeoPixel object with appropriate configuration.
neo_pixel = neopixel.NeoPixel(gpio_pin, pixel_width * pixel_height, brightness=0.1, auto_write=False)
#Create PixelFramebuffer object with appropriate configuration.
pixel_framebuf = PixelFramebuffer(neo_pixel, pixel_width, pixel_height, reverse_x=True,alternating=True)
print ('Press Ctrl-C to quit.')
if not args.clear:
print('Use "-c" argument to clear LEDs on exit')
try:
while True:
led_message_len = len(led_message)
led_message_scroll_height = led_message_len * 16
for led_scroll in range(0, led_message_scroll_height , 1):
led_char_counter = 1
pixel_framebuf.fill(0x000000)
# pixel_framebuf.display()
for led_char in led_message:
led_char_spacing = 8 * led_char_counter
led_char_pos = pixel_height - led_scroll + led_char_spacing
pixel_framebuf.text(led_char, 0, led_char_pos , 0x00FF00)
led_char_counter += 1
pixel_framebuf.display()
time.sleep(25/500)
except KeyboardInterrupt:
if args.clear:
neo_pixel.deinit()

View File

@@ -1,34 +0,0 @@
# SPDX-FileCopyrightText: 2020 Melissa LeBlanc-Williams, written for Adafruit Industries
# SPDX-License-Identifier: MIT
#!/usr/bin/python3
"""
Be sure to check the learn guides for more usage information.
This example is for use on (Linux) computers that are using CPython with
Adafruit Blinka to support CircuitPython libraries. CircuitPython does
not support PIL/pillow (python imaging library)!
Author(s): Melissa LeBlanc-Williams for Adafruit Industries
"""
import board
import neopixel
from PIL import Image
from adafruit_pixel_framebuf import PixelFramebuffer
pixel_pin = board.D18
pixel_width = 8
pixel_height = 16
pixels = neopixel.NeoPixel(
pixel_pin, pixel_width * pixel_height, brightness=0.1, auto_write=False,
)
pixel_framebuf = PixelFramebuffer(pixels, pixel_width, pixel_height, reverse_x=True,alternating=True)
pixel_framebuf.fill(0x000000)
pixel_framebuf.display()
pixel_framebuf.text("H", 0, 0, 0x00FF00)
pixel_framebuf.display()
pixel_framebuf.text("i", 0, 8, 0x00FF00)
pixel_framebuf.display()

View File

@@ -1 +0,0 @@
Jaki is the best.

View File

@@ -1,52 +0,0 @@
#Created by Justin Healy
#Based on logic from jsheperd from https://stackoverflow.com/a/27753869/190597
from __future__ import print_function
import string
from PIL import Image
from PIL import ImageFont
from PIL import ImageDraw
import numpy as np
def char_to_pixels(text, path, fontsize):
font = ImageFont.truetype(path, fontsize)
w, h = font.getsize(text)
image = Image.new('L', (w, h), 1)
draw = ImageDraw.Draw(image)
draw.text((0, 0), text, font=font)
arr = np.asarray(image)
arr = np.where(arr, 0, 1)
arr = arr[(arr != 0).any(axis=1)]
return arr
def display(arr):
result = np.where(arr, '1', '0')
print("This gives an Array of Arrays, where reach contained Array is a row")
print(result)
print()
print('\n'.join([''.join(row) for row in result]))
#I have used static coding successfully, now to set this as more reusable declarations rather than hard coding.
#Single Source to change for everything
#Read from file?
fileName = "pilReadTest"
pullFile = open(fileName,"r")
someString = pullFile.read()
#Font Path?
fontPath = "fonts/FreeMonoBold.ttf"
#font Size?
fontSize = 12
#print("This was what was found in the File: "+str(someString))
#print()
#print("Now putting each letter of the found string through the PIL Image Module")
#print()
for c in someString:
arr = char_to_pixels(c,fontPath,fontSize)
print()
#This is the grid size results (w,h)
print(arr.shape)
print()
#print("This is the converted values of the AofAs, for each ROW in Result, the end product")
display(arr)
print()

View File

@@ -1,14 +0,0 @@
#!/usr/bin/python3
from led_display import LightDisplay
def main():
led_test = LightDisplay(8, 16, "blue", 2)
print(led_test.color)
print(led_test.x)
print(led_test.y)
print(led_test.speed + '\n\n\n')
led_test.display("Print this message")
if __name__ == "__main__":
main()