Code Monkey home page Code Monkey logo

pixlez's Introduction

PixLeZ - Documentation

alt text alt text GitHub license GitHub version

GitHub version GitHub version GitHub version

alt text alt text

Introduction

PixLeZ is a Software-Bundle for controlling the WS2801 Pixels with a Raspberry Pi.
The Bundle contains a server application, running on the Raspberry Pi and different clients to control the server.

Content

  • Raspberry Pi Setup (Hardware and Software)
  • PixLeZ-Server running on the Raspberry Pi
    • API calls via local network and the browser
    • Effects and Modes
    • Own Effects and Modes
    • Example: Use the API
  • PixLeZ-Application, a cross platform app, developed with flutter
  • About
  • Links

Setup the Raspberry Pi

Hardware

For the Hardware part, follow the descriptions bellow.

Software

For the software part you have to install some python libraries with the following commands.

sudo apt-get update
sudo apt-get install python3
sudo apt-get install python3-pip -y

Navigate inside your PixLeZ_Server directory using cd. Then install the needed requirements:

pip install -r requirements.txt

PixLeZ-Server

Path: ./PixLeZ_Server

The base of the application is a simple flask server running with python, controlling your WS2801 Pixels. After the configuration of your Raspberry Pi with the packages in the Software part, you need to move the ./PixLeZ_Server directory to your Raspberry Pi. After that, you can simply run the server inside the directory using the following command.

python app.py

The PixLeZ-Server is now accessible via the local network. For configuration changes modify the statement below in the file app.py and restart the application app.py after.

app.run(port=8080, host="0.0.0.0")

API calls

After installing, the PixLeZ-Server provides the following API. The API is used by the applications described in the next few sections, but can also be used via a webbrowser or an other application.
The term changeable during runtime is used to describe that the attributes can be changed during the execution of an effect or mode. The change of attributes with non changeable during runtime will be changed after selecting a new effect or mode, or after doing an /stop and /start. Each time you select an effect, the mode attribute will turn to -1 and backwards. Furthermore after selecting an effect or mode, the program will automatically do an /stop and /start.

# starts the process -> only call in the beginning or after a stop
@app.route('/start')

# stops the process
@app.route('/stop')

# String color in HEX -> Example /set/color/FF00FF
# changable during runtime
@app.route('/set/color/<string:color>')

# time as floating number
# changable during runtime
@app.route('/set/time/<float:post_id>')

# timer as floating number
# non changable during runtime
@app.route('/set/timer/<float:post_id>')

# number as integer
# changable during runtime
@app.route('/set/number/<int:post_id>')

# mode as integer -> the mode will automatically change and the effect is set to 0
# changable during runtime
@app.route('/select/mode/<int:post_id>')

# effect as integer -> the effect will automatically change and the mode is set to 0
# changable during runtime
@app.route('/select/effect/<int:post_id>')

# returns the status of the attributes
@app.route('/status')

# Set a custom Color Theme
# Body: List of hex-colors
# changable during runtime
@app.route('/set/pixels', methods=['POST'])

Effects and Modes

The following tables describes the different effects and modes which can be used. In the last column there are some shortcuts used to give the opportunity for manipulating the effects or modes.

  • c := Color in Hex
  • t := time in sec
  • tr := timer in sec
  • n := number in x

Effects

Index Name Decription Config
-1 Init No Effect active
0 Shine Switching all Pixels on c
1 Walking Pixels Pixels walking to one side c, t
2 Walking Pixels reverse Pixels walking to the other side c, t
3 Fill it Insort the selected number of Pixels c, n
4 Get empty And the Pixels are going away c, tr
5 Final countdown Countdown with red Pixels tr
6 Pulsing Pixels Pulsating Pixels everywhere c, t
7 Dim Off Dim the Pixels off c, tr
8 Rainbow Mode The Pixels change in the Spectrum of the Rainbow t
9 Rainbow Walk Pixels walking in the Spectrum of the Rainbow t
10 Rainbow Puls Pixels pulsing in the Spectrum of the Rainbow t
11 Cyclon Pixels Pixels making a huge Cyclon c, t, n
12 Twinkle It Pixels can twinkle c, t
13 Twinkle It Colorful Pixels can twinkle in different colors t
14 The Sparkle Pixels What a sparkle Pixel c, t
15 Snow Sparkling Feeling like snowin c, t
16 Pixel Runner They are running very fast c, t
17 Theater Chase Pixels Maybe Pixels visited a Theater c, t
18 Bouncing Pixels And they bounce to center and back c, t, n
19 tbd

Modes

Index Name Decription Config
-1 Initial No Mode active
0 Shine It Normal light Pixel mode c
1 Chill Mode Chillin with the Pixels
2 Color Theme Use your custom color Pixel theme c
2 No Effect Nope, not today
3 tbd

Add your own Effects and Modes

You are able to add your own effects and modes to the PixLeZ-Package. Feel free to share your code with me and I will extend the PixLeZ-Package with your features or simply create a Pull Request.

Add your code in Blink.py under the last effect or mode, depending on your purpose. Just add an further if-condition with an unique index.

if self.effect == [unique effect Number]:
  # insert your code here
if self.mode == [unique mode Numer]:
  # insert your code here

Implement the logic of the effect in Effects.py. Use the adafruit-ws2801 API to expand the code.

After adding, you are able to call the effects and modes with an simple flask API call or an application.

You are not able to select your added effects and modes with the PixLeZ-Application. You'll have to add it to the App by hand. We are aware of this issue and will think of a better solution in an upcoming iteration.

Example: Use the API

How to start an effect and manipulate it. If you use an application do the same steps but without the API calls.

  1. Select a color or color theme with /set/color/<string:color> or /set/pixels
  2. Select your effect with /select/effect/1
  3. Use /start to start the application
  4. You can manipulate the effect with setting different attributes during runtime. As example /set/color/AA0011 or /set/time/0.001
  5. Select an other effect during runtime with /select/effect/16

PixLeZ-Application

Path: ./PixLeZ_Application

The PixLeZ-Application is the main part of the project. The application provides a lot of possibilities for configuration the Pixels.

The PixLeZ-Application is made with flutter. Flutters advantage is in running code on every platform. For more information check the Flutter webpage.

You have two options to run the PixLeZ-Application

  1. Set up a Flutter environment and compile it on your specific platform (Web, Android, IOS, Mac, Win,...)
  2. Download the predefined installation packages and install it on the specific platform

About

PixLeZ was originally created by Tobias Schreiweis in 2020.
Later, Timo joined as a maintainer and contributor.

It started as a private project with the main focus to improve their python skills with the Raspberry Pi and learning new programing languages like dart with the framework flutter. After some requests from other people getting the application Tobias decided to publish it on GitHub.

You are welcome to extend the PixLeZ-Bundle or send us your ideas and we will be glad to add your code and ideas to this repository.

If we can be of assistance, please do not hesitate to contact us.

We first released this repo to public in mid 2022.

alt text alt text

Links

pixlez's People

Contributors

excyto avatar therisenphoenix avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

pixlez's Issues

Save configuration

The configurations in the controller are reset when the server has been restarted. We should save them locally on the client.

Additionally, it would be great if users could bookmark colors that they found to be pleasing for the lights.

Download available effects from server

The effects should not be hardcoded in the app, but the app should download a list of currently supported effects (with name, icon, description and id) and display them.

Exception when opening "custom effect"

════════ Exception caught by foundation library ════════════════════════════════════════════════════
setState() or markNeedsBuild() called during build.
════════════════════════════════════════════════════════════════════════════════════════════════════

════════ Exception caught by rendering library ═════════════════════════════════════════════════════
colors list must have at least two colors
'package:flutter/src/painting/gradient.dart':
Failed assertion: line 189 pos 12: 'colors.length >= 2'
The relevant error-causing widget was:
Container file:///[...]/PixLeZ/PixLeZ_Application/lib/color_theme_config.dart:401:54

Wake Up effect

All lights start very dark, then slowly get brighter by time.
Colors are yellow/orange/red, like a sunrise.
Same, but other way round could be used to simulate sunset

Button to shut down raspi

There should be a button in the app to shutdown the raspi, to avoid dataloss when just switching it off
Or can we do this another way?

Add alpha to color

The colorsetter should get a 4th value indicating the alpha - the brightness of the color

Add Timetriggers

A functionality, to the schedule an effect for a certain time, maybe also for a certain time range (like show for 5 minutes at 6AM each day). Rules to schedule more individual would be nice (like only on workdays, only on weekends etc)

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.