Package: headless-kivy-pi
Kivy Headless Renderer for Raspberry PiThis 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.📋 RequirementsRaspberry Pi 4 or 5SPI Display (tested with ST7789 module)📦 InstallationYou can install it using this handle: headless-kivy-pi@git+https://github.com/ubopod/headless-kivy-pi.gitpipinstallheadless-kivy-piTo work on a non-RPi environment, run this:# pip:pipinstallheadless-kivy-pi[dev]# poetry:poetry--groupdevheadless-kivy-pi🛠 UsageCall setup_headless() before inheriting theHeadlessWidgetclass 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,synchronous_clock=True,automatic_fps=True,clear_at_exit=True,)Inherit theHeadlessWidgetclass for the root widget of your Kivy application.
For example:classFboFloatLayout(FloatLayout,HeadlessWidget):passRun the Kivy app as you normally would.CheckoutUbo Appto see a sample implementation.⚙️ ParametersThese parameters can be set to control the behavior of headless kivy pi:min_fpsMinimum frames per second for when the Kivy application is idle.max_fpsMaximum frames per second for the Kivy application.widthThe width of the display in pixels.heightThe height of the display in pixels.baudrateThe baud rate for the display connection.is_debug_modeIf set to True, the application will print debug information, including FPS.display_classThe display class to use (default is ST7789).double_bufferingIs set toTrue, it will let Kivy generate the next frame while sending the last
frame to the display.synchronous_clockIf set toTrue, Kivy will wait for the LCD before rendering next frames. This will
cause Headless to skip frames if they are rendered before the LCD has finished displaying
the previous frames. If set to False, frames will be rendered asynchronously, letting
Kivy render frames regardless of display being able to catch up or not at the expense
of possible frame skipping.automatic_fpsIf set toTrue, 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.clear_at_exitIf set toTrue, it will clear the screen before exiting.🤝 ContributingYou need to havePoetryinstalled on your machine.After having poetry, to install the required dependencies, run the following command
in the root directory of the project:poetryinstall⚠️ Important NoteThis 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.🔒 LicenseThis project is released under the Apache-2.0 License. See theLICENSEfile for more details.