This repository modifies the Pervasive Displays API (basic edition, CC-BY-SA) to include several new features:
- Use with Raspberry Pi 3B single board computer
- Display to standard video output using Simple DirectMedia Layer 2, for immediate visualisation of the expected display.
- Format text using Freetype, allowing use of any font.
- Additional quality of life functions.
For compilation for standard computer (without eInk display), use:
g++ -o Demo *.cpp -lSDL2 -I/usr/include/freetype2 -lfreetype
.
For compilation on Raspberry Pi (with eInk display), the additional define RPI
must be set:
g++ -o Demo *.cpp -DRPI -lSDL2 -lspidev-lib++ -lwiringPi -I/usr/include/freetype2 -lfreetype
All compilation requires the libsdl2 (eg. : sudo apt install libsdl2-dev
).
Running on Raspberry Pi requires in addition the wiringPi library and the spidev-lib library.
The software has only been tested on a Raspberry Pi 3B with a 4.37" E-ink display Three colours. Any other screen requires modification of the code to work, as the screen size is hardcoded. Any other computer than RPI3B likely requires adjustments of the pinout and spi setup to work properly.
- Enable the SPI communication in the
raspi-config
utility and reboot. - The pins are (wire colours corresponds to the ones when using the EXT3 kit:
- 3.3V: pin 1. BLACK
- MOSI: pin 19. BLUE
- MISO: pin 21. GREEN
- SCLK: pin 23. BROWN
- Busy: GPIO5, pin 29. RED
- D/C: GPIO6, pin 31. ORANGE
- RST: GPIO13, pin 33. YELLOW
- Flash CS: GPIO26, pin 37. PURPLE
- Panel CS: GPIO19, pin 35. GRAY
- GND: pin 6. WHITE
NB: the pins defined in the c++ code are NEITHER the GPIO number NOR the pin numbers. wiringPi
uses different numbers (not sure where they come from), which can be found there if you want to change the pins. The SPI connection use is /dev/spidev0.0
.
3. Compile with the -DRPI
flag and the other required libraries (cf. above).
4. If you are connected to a headless RPI, you probably need an display connection of SDL may have issues. In ssh, you can use ssh -X ...
. Check how to set up a X display through ssh to see how that can be achieved.
5. The compiled program needs to be run as root to have access to SPI communication and GPIO: sudo ./Demo
. There are probably ways to give the appropriate rights to avoid running as root...
Sierpinski
Paragraph_freetype (int fontsize, int x0, int y0, int line_end_x, int ymax, String s, uint16_t colour, uint16_t bgcolor=myColours.white)
: display text in a given bounding box (4 ints in the middle), width a given fontsize and colour. Supports newlines (\n
), italic and bold using markdown syntax (*word*
or_word_
,**word**
or__word__
). The fonts can be changed in theFunctions.cpp
file.