Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tobykurien/rpi_lcars
Star Trek LCARS interface for Raspberry Pi using Pygame
https://github.com/tobykurien/rpi_lcars
Last synced: 2 months ago
JSON representation
Star Trek LCARS interface for Raspberry Pi using Pygame
- Host: GitHub
- URL: https://github.com/tobykurien/rpi_lcars
- Owner: tobykurien
- License: mit
- Created: 2016-01-20T11:48:50.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2021-10-17T07:08:56.000Z (over 3 years ago)
- Last Synced: 2024-08-02T01:16:52.016Z (6 months ago)
- Language: Python
- Size: 2.69 MB
- Stars: 650
- Watchers: 103
- Forks: 146
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-rainmana - tobykurien/rpi_lcars - Star Trek LCARS interface for Raspberry Pi using Pygame (Python)
README
# RaspberryPi LCARS Interface
Star Trek [LCARS](https://en.wikipedia.org/wiki/LCARS) interface for [Raspberry Pi](https://raspberrypi.org/) using [Pygame](http://www.pygame.org).
The code is an example of implementing a custom MovieOS-style interface for your RaspberryPi projects that include the RaspberryPi touch screen (e.g. home automation control panel). The LCARS assets can be replaced with assets from any other style of user interface (e.g. from games, cartoons, or TV series).
[![screenshot 1](screenshot.png)](https://youtu.be/HCEL9O3ie40)
(Click screenshot for a video)
# Global Config
- [UI_PLACEMENT_MODE](https://github.com/tobykurien/rpi_lcars/blob/master/app/config.py#L2) - if set to ```True```, allows you to long-press any widget (except background items) and then drag them to any location. When you release the widget, it's new top and left co-ordinates are printed in the console, which you can use in your code to place the widget there.
- [DEV_MODE](https://github.com/tobykurien/rpi_lcars/blob/master/app/config.py#L6) - if set to ```True```, will show the mouse cursor and a close button, for example. The mouse cursor is useful during development (on a non-touch screen).
- [SOUND](https://github.com/tobykurien/rpi_lcars/blob/master/app/config.py#L7) - if set to ```False```, will disable all sounds and prevent errors if a sound device isn't present
- [PIN](https://github.com/tobykurien/rpi_lcars/blob/master/app/config.py#L8) - Set authorization code. For now only numbers are supported.# Usage
- The starting point for modifying this interface to your needs is [the initial Screen that is loaded](https://github.com/tobykurien/rpi_lcars/blob/master/app/lcars.py#L6), which is ```ScreenAuthorize```. The Screens are defined in the ```screens``` folder.
- Screens extend the [```LcarsScreen```](https://github.com/tobykurien/rpi_lcars/blob/master/app/ui/widgets/screen.py) class and define a ```setup()``` method, and optionally the ```handleEvents()``` and ```update()``` methods.
- The ```setup()``` method initializes the widgets to display. See [lcars_widgets.py](https://github.com/tobykurien/rpi_lcars/blob/master/app/ui/widgets/lcars_widgets.py) for some of the implemented widgets.
- The ```handleEvents()``` method is used to respond to clicks. If this method returns ```True```, the event is "consumed", otherwise other widgets get a chance to act on the event.
- The ```update()``` method is called once per frame, allowing the Screen to update how it is drawn. Code in here needs to be highly optimized. This method is called *after* the widgets are drawn, but there is a ```pre_update()``` method you can override to draw before the widgets get drawn.
- The method ```loadScreen()``` can be called to open a new Screen. There is no backstack, so you will have to manage the Screen flows manually.
- To use the [```SOUND```](https://github.com/tobykurien/rpi_lcars/blob/master/app/config.py#L7) config, you need to use [```ui.utils.sound.Sound```](https://github.com/tobykurien/rpi_lcars/blob/master/app/ui/utils/sound.py#L8) instead of the normal ```pygame.mixer.Sound```.# Installation
- Download or Git clone this repository into a local folder
- Run the ```setup.sh``` script to install the needed dependencies, OR if you have pip, run ```pip install -r requirements.txt```# Launching
- You can launch the interface from inside an X desktop session by opening a terminal and running ```python lcars.py``` from inside the ```app``` folder.
- To launch the interface from the command line, run the ```run.sh``` script in the project root. Note that you will need to have ```xinit``` installed (```sudo apt-get install xinit```). While you can run it without X, the touch points will be mis-aligned, and so is not feasible.
- You can launch the interface on bootup by adding the following to the ```/etc/rc.local``` file:```
cd /home/pi/rpi_lcars/app
sudo -u pi xinit /usr/bin/python3 lcars.py
```
The above assumes you want to run the interface from the ```/home/pi/rpi_lcars``` folder as the ```pi``` user. To run as root, simply omit the ```sudo -u pi``` bit.# Notes
- Although not implemented in the demo, an interpolator is provided to allow for animations. To see how this can be used, see the [LcarsMoveToMouse](https://github.com/tobykurien/rpi_lcars/blob/master/app/ui/widgets/sprite.py#L79-L101) widget, which smoothly follows screen touches/mouse clicks.
- The [applyColour()](https://github.com/tobykurien/rpi_lcars/blob/master/app/ui/widgets/sprite.py#L71-L77) method is used to take an image asset of a uniform colour (e.g. white) and change its colour to any other colour. This is how buttons of various colours are created from one asset. However, currently this is a very simple implementation which results in aliasing artifacts, which is why the buttons look aliased. The advantage of this method is that it is trivial to use it to add highlighting of touches on buttons and keep the number of assets required to a minimum.
- If you are using the [Waveshare 5" or 7" touch screen](https://www.adafruit.com/products/2407) (or similar), then you can use the sample ```boot/config.txt``` to get the screen running at the correct resolution, and install a user-space touch driver, like [this one](https://github.com/derekhe/waveshare-7inch-touchscreen-driver)# Credits
- LCARS graphical user interface is copyright [CBS Studios Inc.](http://www.cbs.com/) and is subject to [the fair use statute](https://en.wikipedia.org/wiki/LCARS#Legal)
- LCARS images and audio assets from (what used to be) lcarscom.net and audio assets from [trekcore.com/audio/](http://trekcore.com/audio/)
- Sample weather image from the [SABC](http://www.sabc.co.za)