- Enable SPI on the Raspberry is required. Here a follow up on one method to do it.
- You must load the fbtft kernel module before to use this library. This module allows to use the Linux framebuffer and draw to a connected display through the Serial Peripheral Interface. For default the Raspberry framebuffer is set to 16 bits-per-pixel. For more info see this GitHub repo and the wiki you can find here https://github.com/notro/fbtft/wiki.
Download/clone this repo, cd into the RaspiGFX folder and compile:
cd RaspiGFX g++ -std=c++11 RaspiGFX.cpp RGB565.cpp Framebuffer.cpp your_cpp_source.cpp -o rgfxor
g++ -std=c++11 RaspiGFX.cpp RGB565.cpp Framebuffer.cpp graphicTest.cpp -o rgfx
if you want to use the
graphicTest.cpp program.Anyway it is suggested to examine the example program source to get an idea on how to use the RaspiGFX class.
Since version 3.15 the Linux Kernel comes with included FBTFT drivers. You need to load it the first time after boot before to use this library. This is accomplished issuing the fallowing command:
sudo modprobe fbtft_device name=adafruit22a rotate=90
where:
nameis the device name required for the model of display you are using. (ili9340 in this case, here is the full list of supported displays and the corresponding name to be used).rotateis the screen orientation.
You can also make it load automatically when the Rpi boots.
If required you can unload the module issuing:
sudo modprobe -r fbtft_device
Execute with the fallowing command:
sudo ./rfgx
Note that the test program comes with the fbtft module parameters suitable for a ili9340 display. You need to change
the device name according to the display you are using.
RaspiGFX comes with a built-in font and some custom fonts you can find within the
BitmapFonts folder. You
can build your own custom font starting from .ttf files converting them with the fontconvert easy-to-use tool provided by Adafruit. For more info and a guide on how to use such tool you can follow the learn center on the Adafruit site here.
This C++ library is written by the owner of this repo, wiredolphin. You can freely use, modify or redistribuite it without any warranty. It only requires
to include credit or mention of the contributors. Read the license header in each source file for more
info.
Note that this code contains some algorithms taken from the Adafruit_GFX library for drawing some primitives and for drawing and use the custom bitmap fonts, so you must also agree their license terms. For more info look at the Adafruit Industries GitHub repo.
