Menu

HowTo

Benedict Jäggi

HowTo

Back to [Home]

You can run this framework on any machine you like.
If you want/have some other machine/OS than a Raspberry Pi (e.g. a Windows Laptop), just download the code and set the framework home path like described below.

NOTE: I could not bring the Music Player to run on Windows because of missing depencies.

Get the following:

You can skip this if you run the framework on another machine or OS.

Raspberry Pi Zero 2 W: https://www.pi-shop.ch/raspberry-pi-zero-2-w-starter-kit
Touch Display for it: https://www.pi-shop.ch/7-touch-display-kit-for-raspberry-pi-zero
And some power: https://www.pi-shop.ch/27w-usb-c-pd-power-supply-eu-plug-white

The parts can be simply sticked together, No soldering needed.

You have a computer for under 100 CHF then.

Flash Raspbian 32bit Desktop onto the SD Card

You can skip this if you run the framework on another machine or OS.

I first used 64bit but it was freaking slow. Maybe because I fiddled with the display settings and set the GPU RAM to 256MB?
I now use 32bit version and did not change anything on the display settings anymore. It just works fine.

You need a version with Desktop environment. It is needed for the pygame library to open a window.

You can use the Raspbi Imager and simply select the appropriate OS in a drop-down-menu.
https://www.raspberrypi.com/software/

Download the code

From the git repository here.
See Code section for further information.

Short: git clone https://git.code.sf.net/p/pirobot/code robot

This will clone the framework into the robot directory.

Maybe you need to install git before.

(How to install GIT)

Debian Linux:

sudo apt install git

Alpine Linux:

apk add git as root user.

Windows:

Head to the git website, download the installer and install it on your machine.

MacOS:

Not used till now, look for yourself.

Set PiRobot Home Path

Open MAIN.py or APP_BASE.pywith a text editor. (MAIN.py overwrites the path in APP_BASE.py)

You need to set the full path to the scripts in APP_BASE.py (or MAIN.py):
APP_BASE.HOME_PATH="/full/path/to/this/scripts/"

On Windows it's:
APP_BASE.HOME_PATH="C:\\full/path/to/this/scripts/", with the drive at the beginning.

You need to add a slash at the end!
This is for proper file loading and saving into the userdata and appdata directories so that this scripts can be started from somewhere other than their home dir. That is the case with the desktop file below. I have set Path in the desktop file but it did not work. So I added the HOME_PATH-variable to APP_BASE.

Usage

Run it on autostart with the desktop file below or with python3 MAIN.py in the directory of this scripts.

It shows you a face.
The face app is the "underlying application", or the "system root" or whatever you may call that. You can change it of course.

Press/touch a mouse button on the upper part of the screen to show the time. (Mouse is hidden because it's a touch screen.)
Left eye is hours, right eye is minutes.
If you release it on the lower part of the screen, it will show you a menu.
This menu is customizable. Here you can switch between the "installed" Apps.
Several games are programmed into it and you may add new menu items or change the old ones easily.

Have Fun with the games and maybe draw something with your fingers.
You can save and load images from the drawing App and game states in the chess App right now.

Add autostart (Raspbian Linux)

You can skip this if you run it on another machine/OS than Raspberry Pi with Raspbian.

User is pi and MAIN.py is in /home/pi/robot here, you may have other name and directory:

cd /home/pi/.config
mkdir autostart (if it does not exist)
cd autostart

You should now be in the /home/pi/.config/autostart directory.
Create a new file with nano here:

nano robot.desktop

and add those lines, with the right directory directing to your MAIN.py:

[Desktop Entry]
Type=Application
Name=Robot
Exec=/usr/bin/python3 /home/pi/robot/MAIN.py

Ctrl-O, Enter, Ctrl-X, Enter

The application should now autostart after it boots into desktop.

Everything was preinstalled on my Raspbian, even the pygame library.
If not, try pip install pygame - maybe you need to install pip, too. Should not happen nowadays.

Further information

Look into the files for further information. Everything is well commented.
Begin with MAIN.py, this is the startup file.

When you are ready,
use a copy of APP_TEMPLATE.py to create a new Application.
and add it to a menu in MAIN.py

Look into APP_BASE.py which contains the Base Application Class and all System Functions -
and into UITools.py for heavily used global variables and functions.


Next is [MAIN]

Or go back [Home]


Related

Wiki: Home
Wiki: MAIN

MongoDB Logo MongoDB