Project logo

Display library

Universal graphics library for TFT/ePaper/OLED display with enhanced functionality


Display Library

Display-Library is universal graphics library for microcontrolers providing a common set of graphics primitives, correction of display resolution and management of multiple displays in your project.

Graphics primitives you can work with:

  • vector graphics (circle, line, triangle)
  • pictures (1 bpp bitmap, 16 bpp bitmap, xbm)
  • text (using various fonts)

UML structure of library:

UML diagram

Single display examples:

Example of initialization:

/* Initialize pins. */
DigitalPin TFT_MISO(12, INPUT);     // master in slave out
DigitalPin TFT_MOSI(13, OUTPUT);    // master out slave in
DigitalPin TFT_SCLK(14, OUTPUT);    // serial clocks
DigitalPin TFT_CS(15, OUTPUT);      // chip select  
DigitalPin TFT_DC(32, OUTPUT);      // data command 
DigitalPin TFT_RST(4, OUTPUT);      // reset   

/* Create framework-based interface (Arduino SPI). */
SPIClass ArduinoSPI;

/* Create specified display interface. */
SPI_4W DisplaySPI(&ArduinoSPI, SPISettings(40000000, MSBFIRST, SPI_MODE0), TFT_CS, TFT_RST, TFT_DC);

/* Create concrete display class. */
ILI9341 Display(&DisplaySPI, 240, 320);

void setup()
{
    /* Initialize framework-based interface (Arduino SPI). */
    ArduinoSPI.begin(TFT_SCLK.getPinID(), TFT_MISO.getPinID(), TFT_MOSI.getPinID());

    /* Initialize specified display interface. */
    DisplaySPI.init_protocol();

    /* Initialize concrete display class. */
    Display.init_display();
}

void loop() 
{

}

Module DisplayCorrector example:

/* Create concrete display class */
ILI9327 Display(&Protocol, 240, 320);

// Create corrector class */
DisplayCorrector Corrector(&Display, 240, 280);

...

// Draw circle (corrected)
Corrector.fill_circle(150, 150, 100);

Module DisplayCorrector example:

/* Create concrete display class */
ILI9327 Display(&Protocol, 240, 320);

// Create corrector class */
DisplayCorrector Corrector(&Display, 240, 280);

...

// Draw circle (corrected)
Corrector.fill_circle(150, 150, 100);

Module DisplayContainer example:

Initialization of container:

/* Create display container class */
MatrixDisplayContainer Container;

/* Add displays to container */
Container.add_display(&Display0);
Container.add_display(&Display1);
. . . 
Container.add_display(&Display5);

Single display mode:

/* Select first display */
Container.select_display(0);

/* Fill circle on first display */
Container.fill_circle(150, 150, 100);

/* Select second display */
Container.select_display(1);

/* Fill rectangle on second display */
Container.fill_rectangle(150, 150, 200, 200);

Mirror display mode:

/* Set mirroring mode */
Container.select_display(MIRROR);

/* Plot rectangle on all displays */
Container.fill_rectangle(150, 150, 200, 200);

Extend display mode:

/* Set extended mode */
Container.select_display(EXTEND);

/* Plot line on extended display */
Container.draw_line(150, 50, 50, 350);

MIT License

Copyright (c) 2021 Matúš Nečas - Display Library Copyright (c) 2021 Volodymyr Sadivskyy - UniGraphic core

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Contributors 2

Matúš Nečas 89.47%

Juraj Ďuďák 10.53%


Links

Languages

  • C 51.5%
  • C++ 48.5%

  • Library
    Last update

    2022-05-10 16:00:53

    Created at

    20.12.2021