Code Monkey home page Code Monkey logo

unicorn-remote's Introduction

Unicorn Remote Logo

Code Climate

Unicorn Remote is a web based remote control for the Unicorn HAT LED matrix. It allows you to control light grid programs from a desktop or mobile browser and a web API.

Supports both the new Unicorn HAT HD 16x16 and original Unicorn HAT 8x8. It comes with a built-in set of programs for both, and allows you add your own.

The Unicorn HAT and HAT HD are available from Pimoroni.

If this software has been useful to you, please star the repository to show your interest.

Web UI screenshot Demo animation

Setup

  1. Follow first time setup for Unicorn HAT or Unicorn HAT HD

  2. Clone or download the repository:

git clone https://github.com/njbbaer/unicorn-remote.git
cd unicorn-remote
  1. Create a virtual environment (recommended)
virtualenv venv
  1. Either enter the virtual environment with source venv/bin/activate or prefix commands with venv/bin/.

  2. Install dependencies

pip install -r requirements.txt
  1. Start Unicorn Remote
python run.py

Optional Arguments

-o --original use original 8x8 unicorn hat
-d --debug enable Flask debugging mode
-p --port <port> set port number (default 5000)

Web Interface

Visit the web interface by directing a browser to the server's address.

http://localhost:5000
  • Choose a program from the dropdown list.
  • Select the desired brightness and display rotation.
  • Press Run to start the program, and Stop to end it.

Custom Programs

To add your own custom program, simply copy it into one of the follow directories:

app/programs/hd for 32x32 programs
OR app/programs/original for original 16x16 programs

No additional configuration required!

REST API

Start a program by placing a PUT request:

PUT /api/program/<program_name>
  • All programs also accept optional query parameters for brightness and rotation.

Stop the currently running program:

PUT /api/stop

Testing

Run the test suite. Enjoy the light show.

python -m unittest

Contribute

  • Star the repository to show your interest in this project.
  • Give feedback, report bugs, and request features as GitHub issues.
  • Improve the repository and submit a pull request.

unicorn-remote's People

Contributors

njbbaer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

unicorn-remote's Issues

Unicorn Remote can't find pillow module

When I run a program to display an image, it errors because it can't find the pillow module which is required to display images.

 #!/usr/bin/env python

import time
from sys import exit

try:
    from PIL import Image
except ImportError:
    exit('This script requires the pillow module\nInstall with: sudo pip install pillow')

import unicornhathd as unicorn

def run(params):
	width, height = unicorn.get_shape()

	img = Image.open('doom.png')

	try:
		while True:
			for o_x in range(int(img.size[0] / width)):
				for o_y in range(int(img.size[1] / height)):

					valid = False
					for x in range(width):
						for y in range(height):
							pixel = img.getpixel(((o_x * width) + y, (o_y * height) + x))
							r, g, b = int(pixel[0]), int(pixel[1]), int(pixel[2])
							if r or g or b:
								valid = True
							unicorn.set_pixel(x, y, r, g, b)

					if valid:
						unicorn.show()
						time.sleep(0.5)

	except KeyboardInterrupt:
		unicorn.off()

That produces a "This script requirtes the pillow module | Install with: sudo pip install pillow" message. Thing is though, pillow is installed.

Running this .py by itself, without Unicorn Remote, works just fine:

#!/usr/bin/env python

import time
from sys import exit

try:
    from PIL import Image
except ImportError:
    exit('This script requires the pillow module\nInstall with: sudo pip install pillow')

import unicornhathd

unicornhathd.rotation(0)
unicornhathd.brightness(0.3)

width, height = unicornhathd.get_shape()

img = Image.open('doom.png')

try:
    while True:
        for o_x in range(int(img.size[0] / width)):
            for o_y in range(int(img.size[1] / height)):

                valid = False
                for x in range(width):
                    for y in range(height):
                        pixel = img.getpixel(((o_x * width) + y, (o_y * height) + x))
                        r, g, b = int(pixel[0]), int(pixel[1]), int(pixel[2])
                        if r or g or b:
                            valid = True
                        unicornhathd.set_pixel(x, y, r, g, b)

                if valid:
                    unicornhathd.show()
                    time.sleep(0.5)

except KeyboardInterrupt:
    unicornhathd.off()

Any ideas?

start unicorn-remote at boot

Can you advise on the best approach to starting unicorn-remote in the background on boot?
My use case is a headless pi set up as an access point.
Thanks

Errno 2 No such file or directory

Hi. Can you help with this error on an original unicornhat (8x8). Thanks

pi@Pi3-UniHat:~/unicorn-remote $ sudo python3 run.py -o
Traceback (most recent call last):
File "run.py", line 4, in
from app import create_app
File "/home/pi/unicorn-remote/app/init.py", line 5, in
from app.state import state
File "/home/pi/unicorn-remote/app/state.py", line 2, in
import unicornhathd as unicornhat
File "/usr/local/lib/python3.4/dist-packages/unicornhathd/init.py", line 20, in
_spi.open(0, 0)
FileNotFoundError: [Errno 2] No such file or directory

Unicorn Remote Problems

I followed your instructions for your unicorn-remote and when running the command to start the program, i get the following error. I did try doing what it suggested with "sudo pip install numpy" but it says it was already installed. Any ideas? Thank you!

sudo pipenv run python run.py
Traceback (most recent call last):
File "/root/.local/share/virtualenvs/unicorn-remote-QVlOwlcP/lib/python3.5/site-packages/numpy/core/init.py", line 16, in
from . import multiarray
ImportError: libf77blas.so.3: cannot open shared object file: No such file or directory

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/root/.local/share/virtualenvs/unicorn-remote-QVlOwlcP/lib/python3.5/site-packages/unicornhathd/init.py", line 13, in
import numpy
File "/root/.local/share/virtualenvs/unicorn-remote-QVlOwlcP/lib/python3.5/site-packages/numpy/init.py", line 142, in
from . import add_newdocs
File "/root/.local/share/virtualenvs/unicorn-remote-QVlOwlcP/lib/python3.5/site-packages/numpy/add_newdocs.py", line 13, in
from numpy.lib import add_newdoc
File "/root/.local/share/virtualenvs/unicorn-remote-QVlOwlcP/lib/python3.5/site-packages/numpy/lib/init.py", line 8, in
from .type_check import *
File "/root/.local/share/virtualenvs/unicorn-remote-QVlOwlcP/lib/python3.5/site-packages/numpy/lib/type_check.py", line 11, in
import numpy.core.numeric as _nx
File "/root/.local/share/virtualenvs/unicorn-remote-QVlOwlcP/lib/python3.5/site-packages/numpy/core/init.py", line 26, in
raise ImportError(msg)
ImportError:
Importing the multiarray numpy extension module failed. Most
likely you are trying to import a failed build of numpy.
If you're working with a numpy git repo, try git clean -xdf (removes all
files not under version control). Otherwise reinstall numpy.

Original error was: libf77blas.so.3: cannot open shared object file: No such file or directory

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "run.py", line 4, in
from app import create_app
File "/home/pi/Pimoroni/unicornhathd/examples/unicorn-remote/app/init.py", line 5, in
from app.state import state
File "/home/pi/Pimoroni/unicornhathd/examples/unicorn-remote/app/state.py", line 73, in
state = State()
File "/home/pi/Pimoroni/unicornhathd/examples/unicorn-remote/app/state.py", line 12, in init
self.set_model(is_hd)
File "/home/pi/Pimoroni/unicornhathd/examples/unicorn-remote/app/state.py", line 18, in set_model
import unicornhathd
File "/root/.local/share/virtualenvs/unicorn-remote-QVlOwlcP/lib/python3.5/site-packages/unicornhathd/init.py", line 15, in
raise ImportError("This library requires the numpy module\nInstall with: sudo pip install numpy")
ImportError: This library requires the numpy module
Install with: sudo pip install numpy

[Feature request] Program to autostart when Unicorn Remote is started

Title.

It would be awesome if we could set a program to automatically be started after Unicorn Remote is started.
CPU Utilization, for example. You boot up Unicorn Remote and CPU Utilization is started automatically. Maybe have a folder called "autostart" in which you copy/paste the program you want to start after the remote has been started.

Thank you for your time.
Cheers,
Griefed

Adding programs

Me again :)
Looking to add more programs to the list.
I've put my .py file in /app/programs/original/
I tried to add it to the the list as per structure in /app/programs/__init__.py but I guess there might be more to it than that?
Sorry for basic question..I'm a tinkerer not a coder, but learning..Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.