Skip to content

Commit

Permalink
Merge pull request #19 from Excyto/refactoring/cleanup-upgrade
Browse files Browse the repository at this point in the history
Upgrades and improved design
  • Loading branch information
Excyto authored Apr 24, 2022
2 parents 1473d8a + 99f8dbd commit cce0738
Show file tree
Hide file tree
Showing 22 changed files with 209 additions and 366 deletions.
6 changes: 3 additions & 3 deletions PixLeZ_Application/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ if (localPropertiesFile.exists()) {

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
throw new FileNotFoundException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
Expand All @@ -26,7 +26,7 @@ apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion 28
compileSdkVersion 31

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
Expand All @@ -40,7 +40,7 @@ android {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.pixlez_application"
minSdkVersion 16
targetSdkVersion 28
targetSdkVersion 31
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
Expand Down
5 changes: 3 additions & 2 deletions PixLeZ_Application/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here. -->
<application
android:name="io.flutter.app.FlutterApplication"
android:name="${applicationName}"
android:label="PixLeZ"
android:icon="@mipmap/ic_launcher">
<activity
Expand All @@ -18,7 +18,8 @@
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
android:windowSoftInputMode="adjustResize"
android:exported="true">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
Expand Down
4 changes: 2 additions & 2 deletions PixLeZ_Application/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
buildscript {
ext.kotlin_version = '1.5.31'
ext.kotlin_version = '1.6.20'
repositories {
google()
jcenter()
}

dependencies {
classpath 'com.android.tools.build:gradle:4.1.3'
classpath 'com.android.tools.build:gradle:7.1.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Expand Down
8 changes: 5 additions & 3 deletions PixLeZ_Application/lib/about.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ class _AboutStarterState extends State<AboutStarter>
title: Text('PixLeZ - About'),
flexibleSpace: Container(
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [Colors.black, Colors.orange],
),
gradient: LinearGradient(
begin: Alignment.bottomLeft,
end: Alignment.topRight,
colors: [Colors.redAccent, Colors.lightGreenAccent, Colors.lightBlueAccent]
)
),
),
),
Expand Down
11 changes: 6 additions & 5 deletions PixLeZ_Application/lib/app_theme/app_drawer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'package:PixLeZ/color_theme_config.dart';
import 'package:PixLeZ/about.dart';
import 'package:PixLeZ/help.dart';
import 'package:PixLeZ/page_license.dart';
import 'package:rainbow_gradient/rainbow_gradient.dart';

class AppDrawer extends StatelessWidget {
@override
Expand All @@ -20,11 +21,11 @@ class AppDrawer extends StatelessWidget {
margin: EdgeInsets.zero,
padding: EdgeInsets.zero,
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [Colors.orange, Colors.black],
),
gradient: LinearGradient(
begin: Alignment.bottomLeft,
end: Alignment.topRight,
colors: [Colors.redAccent, Colors.lightGreenAccent, Colors.lightBlueAccent]
)
),
child: Stack(
children: <Widget>[
Expand Down
11 changes: 5 additions & 6 deletions PixLeZ_Application/lib/assets/about_page.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# PixLeZ - About

PixLeZ is created by Tobias Schreiweis in 2020.
PixLeZ was originally created by [Tobias Schreiweis](https://github.com/Excyto) in 2020.
Later, [Timo](https://github.com/TheRisenPhoenix) joined as a maintainer and contributor.

It started as a private project with the main focus to improve my python skills with the Raspberry Pi and learning new programing languages like dart with the framework flutter. After some request from other peoples getting the application I decided to publish it on GitHub.
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 me your ideas and I would be glad about adding your code and ideas to this repository.
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 I can be of assistance, please do not hesitate to contact me.

[![alt text](https://img.shields.io/github/followers/Excyto?label=Github&style=social)](https://github.com/Excyto)
If we can be of assistance, please do not hesitate to contact us.
256 changes: 20 additions & 236 deletions PixLeZ_Application/lib/assets/help_overview.md
Original file line number Diff line number Diff line change
@@ -1,243 +1,27 @@
# PixLeZ - Documentation
## Quick Start
Once you set up the server using your Raspberry Pi (please refer to the readme on the server for this) and have it running (using `python app.py`), you need to first head over to the settings-section to specify the connection.
Enter the IP address of your raspi and the number of LEDs on your light strip. You only need to do this once.
After that, head over to `Controller`, start the server and assign a color of your choice. Finally, you can open `effects` and select an effect of your choice by long-pressing the button.

[![alt text](https://img.shields.io/github/followers/Excyto?label=Github&style=social)](https://github.com/Excyto)
[![alt text](https://img.shields.io/github/v/release/Excyto/PixLeZ?color=g)](https://github.com/Excyto/PixLeZ)
[![GitHub license](https://img.shields.io/badge/license-MIT-brightgreen)](https://github.com/Excyto/PixLeZ/blob/master/LICENSE)
[![GitHub version](https://img.shields.io/badge/Open-Source-brightgreen)](https://github.com/Excyto/PixLeZ)
## Controller
The controller allows you to specify various parameters for your effects. For example, many effects (besides, e.g. Rainbow) need you to specify a color. In order to avoid seeing no effects, set a color other than black using the sliders.
The first three sliders red, green and blue allow you to compose your color, whereas the fourth slider controls the intensity of the color. Set it to a high level in order to make the effects darker.
The number-parameter specifies how many pixles are shown, this is not used for all effects (but for example for walking pixles).

[![GitHub version](https://img.shields.io/badge/Hardware-Raspberry%20Pi-brightgreen)](hhttps://github.com/Excyto/PixLeZ)
[![GitHub version](https://img.shields.io/badge/Server-Python-brightgreen)](https://github.com/Excyto/PixLeZ)
[![GitHub version](https://img.shields.io/badge/Client-C%23%20%7C%20Flutter-brightgreen)](https://github.com/Excyto/PixLeZ)
## Custom Themes
This section allows you to create your own themes and effects.
tbd

## Introduction
## Effects
In this tab you can start various effects. Try them out to see what they look like! :)
In order to select an effect, hold the button until a small icon appears. By this, you should be prevented from accidentally switching effects.

PixLeZ is a Software-Bundle for controlling the [WS2801 Pixels](https://github.com/adafruit/Adafruit_Python_WS2801/blob/master/Adafruit_WS2801/WS2801.py) with a Raspberry Pi.
The Bundle contains a server application, running on the Raspberry Pi and different clients for control the server.
## Modes
This is similar to effects, but more ambient-oriented. Here, you can also switch off the lights.

## Content
## Settings
In this section, you specify the IP-Address of your server and the number of LEDs your light-strip is equipped with.

- 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-Desktop application for Windows, developed with `C#`
- PixLeZ-Application, a cross platform app, developed with `flutter`
- PixLeZ-Simulator, developed with `Python`
- About
- Links

## Setup the Raspberry Pi

### Hardware

For the Hardware part, follow the descriptions bellow.

- [Raspberry Pi Tutorial Setup (ger)](https://tutorials-raspberrypi.de/raspberry-pi-ws2801-rgb-led-streifen-anschliessen-steuern/)
- [Raspberry Pi Tutorial Setup (en)](https://tutorials-raspberrypi.com/how-to-control-a-raspberry-pi-ws2801-rgb-led-strip/)

There is a picture of my personal setup.

- TODO: Bild hier einfuegen

### Software

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

```sh
sudo apt-get update
sudo apt-get install python[Version]
sudo apt-get install python-pip -y
sudo pip install RPi.GPIO
sudo pip install Adafruit-GPIO
sudo pip install adafruit-ws2801
sudo pip install flask
```

## PixLeZ-Server

> Path: `./PixLeZ_Server`
The base of the application is a simple flask server running with python, controlling your [WS2801 Pixels](https://github.com/adafruit/Adafruit_Python_WS2801/blob/master/Adafruit_WS2801/WS2801.py). 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.

```sh
python app.py
```

The PixLeZ-Server is now accessible via the local network. For [configuration](https://flask.palletsprojects.com/en/1.1.x/api/?highlight=run#flask.Flask.run) changes modify the statement below in the file `app.py` and restart the application `app.py` after.

```python
app.run(debug=True, 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`.

```python
# 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, n|
|2 |Walking Pixels reverse |Pixels walking to the other side|c, t, n|
|3 |Fill it |Insort the selected number of Pixels|c, n|
|4 |Get empty |And the Pixels are going away|c, tr, n|
|5 |Final countdown |Countdown with red Pixels|c, 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.

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`.
Use the [adafruit-ws2801 API](https://github.com/adafruit/Adafruit_Python_WS2801/blob/master/Adafruit_WS2801/WS2801.py) to expand the code.

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

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. For this purpose expand the further code by your own or send me your effects and modes and i will expand it.

### Example: Use the API

How to start an effect and manipulate it. If u 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`
1. Select your effect with `/select/effect/1`
1. Use `/start` to start the application
1. You can manipulate the effect with setting different attributes during runtime. As example `/set/color/AA0011` or `/set/time/0.001`
1. Select an other effect during runtime with `/select/effect/16`

## PixLeZ-Desktop

> Path: `./PixLeZ_Desktop`
PixLeZ-Desktop is developed for easy controlling the pixels via windows desktop. It is developed in `C#` with Visual Studio. The main use of this programm is to debug and test the application.

Use PixLeZ-Application developed with `flutter` instead of PixLeZ_Desktop for a better user experience.

## 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](https://flutter.dev/) webpage.

You have two options to run the PixLeZ-Application

1. Set up a [Flutter environment](https://flutter.dev/docs/get-started/install) 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

## PixLeZ-Simulator

> Path: `./PixLeZ_Simulator`
The PixLeZ-Simulator is developed for simulating, debuging and testing your program without using hardware. It is using the same [API](https://github.com/adafruit/Adafruit_Python_WS2801/blob/master/Adafruit_WS2801/WS2801.py) for manipulating the pixels, so it is possible to copy and paste the code between the simulator and the hardware without changing too much.

For more Information please check the Simulator `Readme.md` in `./PixLeZ_Simulator/Readme.md`.

## About

PixLeZ is created by Tobias Schreiweis in 2020.

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

You are welcome to extend the PixLeZ-Bundle or send me your ideas and I would be glad about adding your code and ideas to this repository.

If I can be of assistance, please do not hesitate to contact me.

[![alt text](https://img.shields.io/github/followers/Excyto?label=Github&style=social)](https://github.com/Excyto)

## Links

- [Raspberry Pi Tutorial Setup (ger)](https://tutorials-raspberrypi.de/raspberry-pi-ws2801-rgb-led-streifen-anschliessen-steuern/)
- [Raspberry Pi Tutorial Setup (en)](https://tutorials-raspberrypi.com/how-to-control-a-raspberry-pi-ws2801-rgb-led-strip/)
- [Adafruit_WS2801 Library GitHub](https://github.com/adafruit/Adafruit_Python_WS2801/blob/master/Adafruit_WS2801/WS2801.py)
- [Inspiration of some Arduino LED effects](https://www.tweaking4all.com/hardware/arduino/adruino-led-strip-effects/)
- [Flask Framework](https://flask.palletsprojects.com/en/1.1.x/)
- [Tkinter Framework](https://realpython.com/python-gui-tkinter/)
- [Flutter](https://flutter.dev/)
## Additional help
If you have any questions or need additional help, feel free to create an [issue](https://github.com/Excyto/PixLeZ/issues) or contact one of the contributors. We will be happy to help you!
8 changes: 5 additions & 3 deletions PixLeZ_Application/lib/color_theme_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,11 @@ class _MyWidgetState extends State<ColorTheme>
title: Text('PixLeZ - Custom Themes'),
flexibleSpace: Container(
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [Colors.black, Colors.orange],
),
gradient: LinearGradient(
begin: Alignment.bottomLeft,
end: Alignment.topRight,
colors: [Colors.redAccent, Colors.lightGreenAccent, Colors.lightBlueAccent]
)
),
),
),
Expand Down
Loading

0 comments on commit cce0738

Please sign in to comment.