Onion Omega2 ILI9225 Library
This library enables the Omega2(+) to control a ILI9225 based display via SPI. It contains many graphics-drawing and display-drawing functions. Due to the current state of the OnionIoT provided bit-banged SPI driver (which has multiple issues), drawing is extremely slow (1-2 FPS). Thus, this library is rather suited for displaying simple user interfaces, simple graphics or static pictures.
You will need:
- an Onion Omega2 or Omega2+, preferably with the extension dock
- an ILI9225 display (e.g., on ebay)
- breadboard and wires
You can connect the wires (MOSI, SCLK, CS, RST, RS, LED) to any free GPIO pin you have. This library uses the spio-gpio-driver from OmegaIoT, which is able to bit-bang SPI on any given pin. The other signals RST (reset), RS (also called register select, data/command or D/C) and LED (backlight control) can also be connected to any GPIO. The library takes an initialization object in which you can define which pins to use.
Your first call should be to
ILI9225_Init() with a pin configuration object (see example code). You can then use any of the functions to draw text, shapes or pixels into the framebuffer. At last, you have to transfer the local framebuffer to the display by calling
The following library functions are available:
- drawing text with different fonts, sizes and colors
- drawing shapes (lines, circles, triangles) either filled or outlined with a color
- changing the orientation of the display (portrait / landscape)
- turning the display on and off (either by LED GPIO pin or SPI commands)
- modfying the internal framebuffer directly, or drawing from an external frame buffer
- executing a graphics demo
This project was designed for cross-compliation. Compile your toolchain according to https://docs.onion.io/omega2-docs/cross-compiling.html, change the paths in the
TOOLCHAIN_ROOT_DIR) and do a
make all. Optionally,
make upload will attempt to use
scp to transfer the compiled binary to your Omega Onion2 system. Simply change the IP address and the password if you whish to use this feature.
For a successful compilation, you need the
omega_libs folder somewhere on your computer. You can download them here). This folder basically includes the
libugpio library and include files. Change the path in the
make all, the library file
libili9225.so and a executable file
displayTest will be created. If you wish to to use the dynamic library in your own project, you have to:
- set the include path to where the
- set the library path to where the
libili9225.soand the dependency
- set the linker flags to link your executable against the prementioned dependencies (
-lili9225 -lonionspi -loniondebug -lugpio)
See the Makefile of this project to see how a userspace program may be compiled and linked against this library.
Testing the compiled binaries
- Install the SPI library by typing
opkg update && opkg install libonionspi. If you already have that library, skip this step.
- Transfer the
libili9225.sofile from this repository to the
/usr/lib/folder on your Omega2, e.g. by using
- Make sure the wiring is that which is described in the
- Transfer the
displayTestfile (ELF) to some directory on your Omega2, e.g.
/root/and run it!
- Maximilian Gerhardt, library porter
- Nkawu, ported library to AVR Arduino
- 4D Systems, original library