|
|
Since we added sensors to the system it is also great to have some output to show their data. That's why we added a LCD to show what is currently meassured.
|
|
|
|
|
|
## Setup
|
|
|
|
|
|
You can find the code for the LCD in [scripts/lcd](https://gitlab.hrz.tu-chemnitz.de/vws-demo/vws-spielwiese/-/tree/followup/demonstrator_config/scripts/lcd). The necessary Python packages can be installed for the user or in a virtual environment. After that a system service can be created to start the script on boot.
|
|
|
|
|
|
### Find the correct pins
|
|
|
|
|
|
Before running the script it's important you check the pins that are initialized in the first few lines of the script! Change them to the correct pins if necessary.
|
|
|
|
|
|
### Install packages for the user
|
|
|
|
|
|
Use the following command:
|
|
|
|
|
|
```console
|
|
|
$ pip3 install -r requirements.txt
|
|
|
```
|
|
|
|
|
|
### Install in a virtual environment
|
|
|
|
|
|
To create virtual Python environments (in short venv) you first need to install `python3-venv`:
|
|
|
|
|
|
```console
|
|
|
$ sudo apt install python3-venv
|
|
|
```
|
|
|
|
|
|
After that you can create a new virtual environment by using:
|
|
|
|
|
|
```
|
|
|
$ python3 -m venv <directory name>
|
|
|
```
|
|
|
|
|
|
where `directory name` is the name of the directory where the venv is stored in.
|
|
|
|
|
|
To activate it use:
|
|
|
|
|
|
```console
|
|
|
$ source <directory name>/bin/activate
|
|
|
```
|
|
|
|
|
|
After that you can just install the packages normally:
|
|
|
|
|
|
```console
|
|
|
$ pip3 install -r requirements.txt
|
|
|
```
|
|
|
|
|
|
### Create a system service
|
|
|
|
|
|
If you already created the system service in [the initial Raspberry setup](/setup/Setting-up-a-Raspberry-Pi-for-the-demo) you can overwrite this service or create a new one. In the following steps we will reuse it.
|
|
|
|
|
|
#### Creating a `start.sh`
|
|
|
|
|
|
Copy the following lines in a file called `start.sh` in the lcd directory:
|
|
|
|
|
|
```bash
|
|
|
#!/bin/bash
|
|
|
cd /home/pi/vws-spielwiese/scripts/lcd
|
|
|
|
|
|
# Uncomment and change the following line if you used an virtual environment!
|
|
|
# source venv/bin/activate
|
|
|
|
|
|
python3 display.py
|
|
|
```
|
|
|
|
|
|
To make that file executable run `chmod +x ./start.sh`.
|
|
|
|
|
|
#### Updating the system service
|
|
|
|
|
|
To access the system service definition run
|
|
|
|
|
|
```console
|
|
|
$ sudo systemctl edit --force --full i4.0-demo.service
|
|
|
```
|
|
|
|
|
|
Look for a line starting with `ExecStart` and replace it with the following line:
|
|
|
|
|
|
```ini
|
|
|
ExecStart=/home/pi/vws-spielwiese/scripts/lcd/start.sh
|
|
|
```
|
|
|
|
|
|
Save and quit the editor. |
|
|
\ No newline at end of file |