Headless renderer for Kivy framework
Project description
Kivy Headless Renderer
This project uses the Kivy framework to create a headless renderer for a Raspberry Pi. The renderer is specifically designed for and tested with the ST7789 SPI display, but it should work with other SPI displays as well. The code utilizes the Adafruit RGB Display library to communicate with the display. The renderer is optimized to not update the LCD if nothing has changed in the frame.
📋 Requirements
- Raspberry Pi 4 or 5
- SPI Display (tested with ST7789 module)
📦 Installation
pip install headless-kivy
To work on a non-RPi environment, run this:
# pip:
pip install headless-kivy[dev]
# poetry:
poetry --group dev headless-kivy
🛠 Usage
-
Call setup_headless() before inheriting the
HeadlessWidget
class for the root widget of your application, and provide the optional parameters as needed. For example (these are all default values, you only need to provide the ones you want to change):setup_headless( min_fps=1, max_fps=30, width=240, height=240, baudrate=60000000, is_debug_mode=False, display_class=ST7789, double_buffering=True, automatic_fps=True, clear_at_exit=True, )
-
Inherit the
HeadlessWidget
class for the root widget of your Kivy application. For example:class FboFloatLayout(FloatLayout, HeadlessWidget): pass
-
Run the Kivy app as you normally would.
Checkout Ubo App to see a sample implementation.
⚙️ Parameters
These parameters can be set to control the behavior of headless kivy pi:
min_fps
Minimum frames per second for when the Kivy application is idle.
max_fps
Maximum frames per second for the Kivy application.
width
The width of the display in pixels.
height
The height of the display in pixels.
is_debug_mode
If set to True, the application will print debug information, including FPS.
double_buffering
Is set to True
, it will let Kivy generate the next frame while sending the last
frame to the display.
automatic_fps
If set to True
, it will monitor the hash of the screen data, if this hash changes,
it will increase the fps to the maximum and if the hash doesn't change for a while,
it will drop the fps to the minimum.
rotation
The rotation of the display. It will be multiplied by 90 degrees.
flip_horizontal
If set to True
, it will flip the display horizontally.
flip_vertical
If set to True
, it will flip the display vertically.
🤝 Contributing
You need to have Poetry installed on your machine.
After having poetry, to install the required dependencies, run the following command in the root directory of the project:
poetry install
⚠️ Important Note
This project has only been tested with the ST7789 SPI display module. Other display modules might not be compatible or may require changing the parameters or even modifications to the code.
🔒 License
This project is released under the Apache-2.0 License. See the LICENSE file for more details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for headless_kivy-0.9.0a1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b9db842315ea565a5a29b585bbfbd06b7fba27074637b3332484b5291195f71e |
|
MD5 | 7ae8cf41f980878cbf4fc79c551d8b37 |
|
BLAKE2b-256 | 6b46e5fd45d4c58f82018525936011f6c7c999b3b7b3f0eb547ad8ff89f4c1e9 |