The proposed architecture isolates the low level layers (already provided by waveshare), calling it from a C++ wrapper, solving some logic problems and allowing to add features without touching (or at least, reducing refactors) that low level code.
There are two parts of the wrapper:
- The image generator (Gui):
- Added support for width-variable fonts: before it was only compatible with monospaced fonts.
- Added a cursor when drawing characters, so, the program could know the position where the object ends, making easy to work with width-variable fonts.
- Auto memory allocation for the image: now there is no need to operate with width and height and create manually an array.
- Grouping interfaces in namespaces to keep clean code.
- The Display control (DisplayApi):
- Storing the status of the display like initialization mode, avoiding problems when using non-compatible functions with the operation mode.
- Reducing the number of interfaces, calling the appropiate low-level function from a single upper-level method.
Also, the project is built using CMake.
-
scripts/font-generator.py.
Script for generating width-variable fonts. Requires Pillow module. Place a .ttf font inside scripts/fonts and run the script:cd scripts python font-generator.py -fs=<font_size> -fn="<font_name.ttf>"Example:
cd scripts # fonts/arial.ttf python font-generator.py -fs=44 -fn="arial.ttf"It will create the output directory and place the <font_name><font_size>.c file. This file must be placed manually in src/clib/Fonts/
Including the font in the project requires adding the new file to src/CMakeLists.txt and the extern reference in inc/clib/Fonts/fonts.h
The project is code-documented, and docs are auto-generated using Doxygen. The site link: https://ailr16.github.io/epd4in2v2-cpp/
