diff --git a/README.md b/README.md index 9bf5eda..04a8e26 100644 --- a/README.md +++ b/README.md @@ -1,41 +1,133 @@ -# RPi_WS2812b_LED +# tickerPi -#Raspberry Pi Project -#WS2812b - LED -#Python3 +tickerPi is a Python Program to handle WS281X LED interactions on a Raspberry Pi +* WS2812b has only been tested at this time + +## Authors -Objective: +* **Justin Healy** +* **Vin Presciutti** -Be able to pass through data (text, designs, colors, patterns, etc) through GPIO on a Raspberry Pi, through to WS2812b LEDs. +## Requirements -Initial Challenges: +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 -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) +## Installation -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 +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 - 0 | 15 | 16 | 31 | 32 | 47 | 48 | 63 | - 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 | +## Contributing +TBD - vs +## License + * [MIT](https://choosealicense.com/licenses/mit/) + > A copy of this can be found in the root directory of this project under "LICENSE" - 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 - 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. - -4 - Figure out how to use Neopixel pass offs. (already solved and confirmed working) \ No newline at end of file diff --git a/Scroll_Pi_Text.py.save b/Scroll_Pi_Text.py.save new file mode 100644 index 0000000..f1110ca --- /dev/null +++ b/Scroll_Pi_Text.py.save @@ -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() + + + +