Sming Graphics Library

An asynchronous graphics management library intended for SPI-based displays. See the Basic_Graphics sample application for demonstration of how to use it.

For a discussion about multitasking and how Sming works, see Multitasking.

Getting started

On first use several required python modules must be installed. Try building a sample application:

cd $SMING_HOME
make fetch Graphics
cd Libraries/Graphics/samples/Basic_Graphics
make python-requirements
make

Virtual Screen

This is a display device for use by the Host Emulator. The ‘display’ is a python application which communicates with the Sming Graphics::Display::Virtual display driver using a TCP socket. Graphics processing is handled using SDL2.

To start the virtual screen server type make virtual-screen from your project directory. The default TCP port is 7780. If you need to change this, use:

make virtual-screen VSPORT=7780

The screen server’s IP address is shown in the caption bar. Build and run your project in host mode as follows:

make SMING_ARCH=Host
make run VSADDR=192.1.2.3

Some definitions

Graphics::Object

Defines a specific graphical item, such as a line, circle or image.

Graphics::SceneObject

List of objects describing the components of a displayed image (line, rectangle, circle, image, text, etc.) Also contains a list of assets which allows objects to be re-used within a scene.

Applications use methods such as drawCircle to construct a scene.

Graphics::TextBuilder

Helper object to simplify text layout, handling wrapping, alignment etc.

Graphics::Surface

Rectangular array of pixels representing a display or offscreen bitmap

Graphics::Device

A display device. This provides a single Surface for access to the screen.

Graphics::Renderer

Class which performs background rendering tasks such as drawing a sequence of lines, filling a circle, etc. Each renderer performs a single, specific-task. The renderers are created by the Surface which allows display devices to provide customised implementations.

Graphics::PixelFormat

Describes the format of pixel data required by a Surface.

For example, the ILI9341 display uses RGB565 colours (2 bytes) with the MSB first. It can use other pixel formats (RGB 6:6:6), but this is how the driver sets the display up during initialisation.

Applications do not need to be aware of this, however, and simply express colours in a 32-bit Graphics::Color type. This includes an alpha channel, where 255 is fully opaque and 0 is fully transparent. Conversion is handled in a single step (via Graphics::pack()) so further manipulation (even byte-swapping) is not required by the display driver.

Note that the ILI9341 display has another quirk in that display data is always read back in 24-bit format (18 significant bits). This detail is managed by the display driver which does the conversion during read operations. See :cpp:method:`Graphics::Surface::readDataBuffer`.

Graphics::Blend

This is a virtual base class used to implement custom colour blending operations. Currently only supported for memory images using Graphics::ImageSurface.

Resources

Projects describe which fonts and image resources they require in a JSON resource script.

This is compiled to produce two files:
$(OUT_BASE)/resource.h

A header file describing the resources and containing indices and other lookup tables. Include this ONCE from a source file.

$(OUT_BASE)/resource.bin

Contains image data and font glyph bitmaps. This file can be linked into the application or stored in a file. A better approach is to store it in a dedicated partition as this avoids any filing system overhead. The library accesses this as a stream - applications must call Graphics::Resource::init().

The goal is to enable an optimal set of resources to be produced for the target display from original high-quality assets.

Usage

  1. Create a directory to contain project resources, e.g. resource.

  2. Place any custom images, fonts, etc. into this directory

  3. Create a resource script file, e.g. resource/graphics.rc. See below for details on editing this file.

  1. Add an entry to the project component.mk file::

    RESOURCE_SCRIPT := resource/graphics.rc

The general structure of a resource script is:

{
    "resources": {
        "<type>": {
            "<name>": {
                ...
            }
        }
    }
}

Fonts

A Graphics::Font contains up to four typefaces which correspond to the selected style (normal, italic, bold or bold+italic).

The default font is Graphics::LcdFont, a simple Arduino fixed Adafruit GFX font. Only the ‘normal’ typeface is defined. This is linked into the program image.

All other fonts are loaded from resources. These are parsed from their original format and converted to an efficient internal format based on the Arduino GFX font library.

Resource script entries look like this:

Styles are optional but a font must have at least one typeface.

By default, all ASCII characters from 0x20 (space) to 0x7e (~). The codepoints parameter is a comma-separated list of ranges:

a-z,A-Z,0-9,0x4000-0x4050

This overrides the default and includes only characters and digits, plus unicode characters in the given range. The chars parameter is a simple list of characters, e.g. “Include these chars”. Both lists are combined, de-duplicated and sorted in ascending order.

The following font classes are currently supported:

GFX

Adafruit GFX library font files. These are identified using a “gfx/” prefix for the font files. See resource/fonts/GFX.

Linux

Linux console bitmap fonts. These are in .c format, identified by “linux/” path prefix. See resource/fonts/Linux.

PFI

The “.pfi” file extension is a Portable Font Index. Font glyph bitmap information is contained in an associated .pbm file. See resource/fonts/PFI.

VLW

Smoothed fonts produced by the https://processing.org/ library with a “.vlw” file extension. These are from the TFT_eSPI library. Note that TTF/OTF scalable vector fonts are supported directly by this library so is the preferred format for new fonts.

freetype
Font type is identified from the file extension:
.ttf

TrueType

.otf

OpenType

.pcf, .pcf.gz

X11 bitmap font

The library supports other types so if required these are easily added.

These fonts have some additional parameters:
“mono”: <True/False>

Whether to produce monochrome (1-bit) or grayscale (8-bit alpha) glyphs. If not specified, defaults to grayscale.

“size”: <Point size of font>

e.g. 16, 14.5

Images

Resource script entries look like this:

The Python pillow library is used to read and process images.

The format parameter is intended to produce a raw, un-compressed image compatible with the target display device. Alternatively, specify “BMP” to output a standared .bmp file or omit to store the original image contents un-processed.

Scene construction

Instead of writing directly to the display, applications create a Graphics::SceneObject which will contain a description of the scene to be drawn.

The scene can then be constructed using methods such as drawLine, drawRect, etc. These create an object describing the operation and adds it to the scene.

When the scene is fully described, the application calls the display device’s render method and the rendering begins in the background. A callback function may be provided which will be invoked when the scene has been drawn. The application is free to start creating further scenes, etc.

Note: Scenes are never modified during rendering so can be drawn multiple times if required.

Rendering

This is the process of converting the scene objects into pixels which are then drawn into a Surface.

Computation and primitive rendering is done in small, manageable chunks via the task queue. Data is sent to the screen using the appropriate display driver. The ILI9341 driver uses interrupts and hardware (SPI) transfers to do its work.

If the primitive object is simple (e.g. block fill, horizontal/vertical line) then it can be written to the display buffer immediately.

More complex shapes (images, text, diagonal lines, rectangles, triangles, circles, etc.) create a specific Graphics::Renderer instance to do the work.

Transparency (alpha-blending) involves a read-modify-write cycle. The ILI9341 driver can also handle small transparent rectangles (including indivudual pixels) to assist with line drawing. Larger areas are handled by the appropriate renderer.

Shapes such as rectangles, triangles, circles, etc. are described as a set of connected lines and points which is then iterated through and rendered using fill operations.

The standard Surface implementation uses a standard set of renderers to do this work, however these can be overridden by display devices to make use of available hardware features.

Transparency

With sufficient RAM this is a trivial exercise as we just render everything to a memory surface then copy it to the display. For updating small areas of the screen this may be the best approach. However, even a small 240x320 pixel display would require 150kBytes with RGB565.

The more general approach adopted by this library is to read a small block of pixels from the display, combine them with new data as required then write the block back to the display. The Graphics::TextRenderer does this by default. The algorithm also ensures that text can be rendered correctly with filled backgrounds (solid, transparent or custom brushes).

Display driver

The ILI9341 display driver buffers requests into a set of hardware-specific commands with associated data. When the request buffer is full, it is sent it to the hardware using the HardwareSPI library. This particular display is typically configured in 4-wire SPI mode which requires an additional GPIO to select between command and data transfers. The driver manages this within its interrupt service routines.

Two request buffers are used so that when one buffer has completed transfer the next can begin immediately. This switch is handled within the interrupt service routine, which also schedules a task callback to the renderer so it may re-fill the first request buffer.

Configuration variables

VSADDR

e.g. 192.168.1.105:7780

TCP address of the virtual screen server application, as shown in the title bar.

VSPORT

default: 7780

Port number to use for virtual screen.

ENABLE_GRAPHICS_DEBUG

default 0 (off)

Set to ‘1’ to enable additional debug output from renderers

ENABLE_GRAPHICS_RAM_TRACKING

default 0 (off)

Set to ‘1’ to enable additional diagnistics to assist with tracking RAM usage

Further work

The list of possible updates to the library is endless. Some thoughts:

Text wrapping

Currently wraps at common punctuation characters. Add options to specify how to break text (character boundaries, word boundaries, break characters, etc.)

Rich Text

Add support for HTML, markdown and other suitable formats. This could be handled by the resource compiler by converting to Graphics::Drawing resources.

Transparent bitmaps

Simple transparency can be handled using Blend Images with per-pixel alpha are not currently implemented. The resource compiler would be extended to support creation of images in ARGB format, with appropriate renderer updates.

Text glyph alignment

Text is drawn using the upper-left corner as reference. It may be desirable to change this, using the baseline or bottom corner instead. This can be added as an option.

Metafiles

Rather than describing scenes in code, we should be able to draw them using other tools and export the layouts as metafiles. Similarly, we might like to export our scenes as metafiles for later re-use.

An example use case is for a ‘scribble’ application, recording pen strokes a touch-enabled screen.

The Drawing API is intended for this use, providing a simple Graphics Description Language (GDL). The provided GDRAW_xxx macros allow embedding of these scripts within programs. This feature is restricted so appropriate only for very simple constructions.

Drawings could be described in textual resource files and compiled during build.

A simple utility program can be written to convert between text and binary GDL formats. Other conversion programs then only need to generate the text equivalent. This will allow the binary format to change as required.

It would be highly desirable to give subroutines textual identifiers. These would be resolved into numeric identifiers for the binary format.

Interactive objects

Drawing buttons, for example, might be done by defining the basic button in GDL.

The button routine could use the following:

pen #0: Inactive surround
pen #1: Active surround
brush #0: Inactive fill
brush #1: Active fill

These slots can be set depending on the desired state by program code. It would be more efficient if GDL can do this based on other parameters, or perhaps by registering callbacks or control objects to make these decisions.

For example, a ButtonObject could use GDL to draw itself and provide callbacks to handle state control, etc. This would also be required for control purposes.

To support use of touch screens we need the ability to query scenes and identify objects at a specific position. Those objects may then be adjusted and redrawn to reflect ‘push’ operations, etc.

For example, we might create a button control by defining a scene describing how the button looks, then create an InteractiveObject containing a reference to that scene plus some kind of user identifier and location of the control ‘hot spot’.

Brushes, Gradient fills, etc.

Rectangular gradient fills can be done by creating a custom ImageObject and drawing it. The object just generates the pixel data as requested according to configured parameters.

This is the basis for Brush objects which would be used to render circles, rounded rectangles and glyphs. That would allow for all sorts of useful effects, including clipping images to other shapes.

Tiling an image can be done by filling a rectangle with an ImageBrush, which deals with co-ordinate wrapping and returns the corresponding region from a source ImageObject.

Cursors, sprites and priority drawing

Response to user input should be prioritised. For example, if a cursor or mouse pointer is present on the screen then waiting for a complex screen update is going to affect useability.

Cursors are drawn over everything else. Although some hardware may support cursors directly, for now we’ll assume not. Similarly text carets (e.g. ‘_’, ‘>’ prompts) can be drawn with priority so that changes in their position are updated ahead of other items.

A read-xor-write pattern is simple enough to implement within a Command List, so that the XOR operation is done in interrupt context. This should provide sufficient priority.

Sprites can be managed using a Surface filter layer which tracks Address Window operations. If data is written to an area occupied by a sprite, then that data can be modified (using XOR) before passing through to provide flicker-free drawing.

Repeat fills make this a little tricky though. An alternative is to identify when a sprite will be affected and, if so, remove it before drawing the new information then re-draw it afterwards. This could be implemented using Regions so that only the affect portion is updated.

Each sprite must store both its own contents (foreground), plus the original display contents (background) excluding any other sprites. Multiple overlapping are combined at point of rendering.

References

File formats
Fonts
Graphics libraries
Metafiles
Papers

API

namespace Graphics

AbstractDisplay.h

Copyright 2021 mikee47 mike@sillyhouse.net

This file is part of the Sming-Graphics Library

This library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3 or later.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this library. If not, see https://www.gnu.org/licenses/.

AddressWindow.h

Copyright 2021 mikee47 mike@sillyhouse.net

This file is part of the Sming-Graphics Library

This library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3 or later.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this library. If not, see https://www.gnu.org/licenses/.

Asset.h

Author

: May 2021 - mikee47 mike@sillyhouse.net

Copyright 2021 mikee47 mike@sillyhouse.net

This file is part of the Sming-Graphics Library

This library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3 or later.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this library. If not, see https://www.gnu.org/licenses/.

Blend.h

Author

: May 2021 - mikee47 mike@sillyhouse.net

Copyright 2021 mikee47 mike@sillyhouse.net

This file is part of the Sming-Graphics Library

This library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3 or later.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this library. If not, see https://www.gnu.org/licenses/.

Object.h

Author

: May 2021 - mikee47 mike@sillyhouse.net

Copyright 2021 mikee47 mike@sillyhouse.net

This file is part of the Sming-Graphics Library

This library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3 or later.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this library. If not, see https://www.gnu.org/licenses/.

Debug.h

Author

: May 2021 - mikee47 mike@sillyhouse.net

Copyright 2021 mikee47 mike@sillyhouse.net

This file is part of the Sming-Graphics Library

This library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3 or later.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this library. If not, see https://www.gnu.org/licenses/.

Device.h

Author

: May 2021 - mikee47 mike@sillyhouse.net

Copyright 2021 mikee47 mike@sillyhouse.net

This file is part of the Sming-Graphics Library

This library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3 or later.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this library. If not, see https://www.gnu.org/licenses/.

ILI9341.h

Author

: May 2021 - mikee47 mike@sillyhouse.net

Copyright 2021 mikee47 mike@sillyhouse.net

This file is part of the Sming-Graphics Library

This library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3 or later.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this library. If not, see https://www.gnu.org/licenses/.

Null.h

Author

: May 2021 - mikee47 mike@sillyhouse.net

Copyright 2021 mikee47 mike@sillyhouse.net

This file is part of the Sming-Graphics Library

This library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3 or later.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this library. If not, see https://www.gnu.org/licenses/.

ST7789V.h

Author

: May 2021 - mikee47 mike@sillyhouse.net

This file is part of the Sming-Graphics Library

This library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3 or later.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this library. If not, see https://www.gnu.org/licenses/.

Command.h

Author

: October 2021 - Slavey Karadzhov slav@attachix.com

Copyright 2021 mikee47 mike@sillyhouse.net

This file is part of the Sming-Graphics Library

This library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3 or later.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this library. If not, see https://www.gnu.org/licenses/.

Header.h

Author

: May 2021 - mikee47 mike@sillyhouse.net

Copyright 2021 mikee47 mike@sillyhouse.net

This file is part of the Sming-Graphics Library

This library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3 or later.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this library. If not, see https://www.gnu.org/licenses/.

Drawing.h

Author

: May 2021 - mikee47 mike@sillyhouse.net

Copyright 2021 mikee47 mike@sillyhouse.net

This file is part of the Sming-Graphics Library

This library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3 or later.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this library. If not, see https://www.gnu.org/licenses/.

Registers.h

Author

: May 2021 - mikee47 mike@sillyhouse.net

Copyright 2021 mikee47 mike@sillyhouse.net

This file is part of the Sming-Graphics Library

This library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3 or later.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this library. If not, see https://www.gnu.org/licenses/.

Renderer.h

Author

: May 2021 - mikee47 mike@sillyhouse.net

Copyright 2021 mikee47 mike@sillyhouse.net

This file is part of the Sming-Graphics Library

This library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3 or later.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this library. If not, see https://www.gnu.org/licenses/.

Surface.h

Author

: May 2021 - mikee47 mike@sillyhouse.net

Copyright 2021 mikee47 mike@sillyhouse.net

This file is part of the Sming-Graphics Library

This library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3 or later.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this library. If not, see https://www.gnu.org/licenses/.

glcdfont.cpp

Author

: May 2021 - mikee47 mike@sillyhouse.net

This is the ‘classic’ fixed-space bitmap font for Adafruit_GFX since 1.0.

See https://github.com/adafruit/Adafruit-GFX-Library

Meta.h

Copyright 2021 mikee47 mike@sillyhouse.net

This file is part of the Sming-Graphics Library

This library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3 or later.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this library. If not, see https://www.gnu.org/licenses/.

Mipi.h

Author

: May 2021 - mikee47 mike@sillyhouse.net

This file is part of the Sming-Graphics Library

This library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3 or later.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this library. If not, see https://www.gnu.org/licenses/.

RenderQueue.h

Copyright 2021 mikee47 mike@sillyhouse.net

This file is part of the Sming-Graphics Library

This library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3 or later.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this library. If not, see https://www.gnu.org/licenses/.

Scene.h

Author

: May 2021 - mikee47 mike@sillyhouse.net

Copyright 2021 mikee47 mike@sillyhouse.net

This file is part of the Sming-Graphics Library

This library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3 or later.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this library. If not, see https://www.gnu.org/licenses/.

SpiDisplay.h

Author

: May 2021 - mikee47 mike@sillyhouse.net

Copyright 2021 mikee47 mike@sillyhouse.net

This file is part of the Sming-Graphics Library

This library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3 or later.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this library. If not, see https://www.gnu.org/licenses/.

SpiDisplayList.h

Author

: May 2021 - mikee47 mike@sillyhouse.net

Copyright 2021 mikee47 mike@sillyhouse.net

This file is part of the Sming-Graphics Library

This library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3 or later.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this library. If not, see https://www.gnu.org/licenses/.

Stream.h

Author

: May 2021 - mikee47 mike@sillyhouse.net

Copyright 2021 mikee47 mike@sillyhouse.net

This file is part of the Sming-Graphics Library

This library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3 or later.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this library. If not, see https://www.gnu.org/licenses/.

TextBuilder.h

Author

: May 2021 - mikee47 mike@sillyhouse.net

Copyright 2021 mikee47 mike@sillyhouse.net

This file is part of the Sming-Graphics Library

This library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3 or later.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this library. If not, see https://www.gnu.org/licenses/.

Types.h

Author

: May 2021 - mikee47 mike@sillyhouse.net

Copyright 2021 mikee47 mike@sillyhouse.net

This file is part of the Sming-Graphics Library

This library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3 or later.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this library. If not, see https://www.gnu.org/licenses/.

Author

: May 2021 - mikee47 mike@sillyhouse.net

Typedefs

using AssetType = Asset::Type
using GlyphOptions = TextOptions
using BlendMode = Blend::Mode
using DrawingTarget = Drawing::Target
using CustomObject = ObjectTemplate<Object::Kind::Custom>

Base class for a custom object.

using AssetID = uint16_t

Numeric identifiers for re-useable objects.

using Point = TPoint<int16_t>
using IntPoint = TPoint<int>
using PointF = TPoint<float>
using Range = TRange<uint16_t>
using FontStyles = BitSet<uint16_t, FontStyle, 10>

Enums

enum BrushStyle

Values:

enumerator FullScreen
enumerator SourceLocal
enum Color

Standard colour definitions.

Values:

enumerator None
enumerator XX
enumerator XX
enum ColorOrder

Order refers to colour order within bitstream.

Values:

enumerator orderRGB
enumerator orderBGR
enum PixelFormat

Values:

enumerator None
enumerator XX
enum Orientation

Defines orientation of display.

Values:

enumerator normal
enumerator deg0
enumerator deg90
enumerator deg180
enumerator deg270
enum Align

Values:

enumerator Near
enumerator Centre
enumerator Far
enumerator Left
enumerator Top
enumerator Center
enumerator Right
enumerator Bottom
enum Origin

Points on a compass.

These are ordered by angles in increments of 45 degrees.

Values:

enumerator E
enumerator NE
enumerator N
enumerator NW
enumerator W
enumerator SW
enumerator S
enumerator SE
enumerator Centre
enumerator TopLeft
enumerator Top
enumerator TopRight
enumerator Left
enumerator Center
enumerator Right
enumerator BottomLeft
enumerator Bottom
enumerator BottomRight
enum FontStyle

Values:

enumerator XX

Functions

inline constexpr uint32_t getColorValue(uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255)

Obtain 24-bit colour value from red, green and blue components.

inline constexpr Color makeColor(uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255)

Function to create a custom colour.

inline constexpr Color makeColor(uint32_t color, uint8_t alpha = 255)
inline constexpr Color makeColor(Color color, uint8_t alpha)
inline constexpr uint8_t getAlpha(Color color)
inline constexpr uint8_t getRed(Color color)
inline constexpr uint8_t getGreen(Color color)
inline constexpr uint8_t getBlue(Color color)
bool fromString(const char *s, Color &color)
inline bool fromString(const String &s, Color &color)
inline uint8_t getBytesPerPixel(PixelFormat format)

Get number of bytes required to store a pixel in the given format.

union __attribute__ ((packed)) PixelBuffer

Structure used to perform pixel format conversions.

PixelBuffer pack(PixelBuffer src, PixelFormat format)

Convert RGB colour into packed format.

Parameters
  • color – The RGB colour to convert

  • format – The desired pixel format

Returns

PackedColor

inline PackedColor pack(Color color, PixelFormat format)
PixelBuffer unpack(PixelBuffer src, PixelFormat format)

Convert packed colour into RGB.

Parameters
  • src – PixelBuffer loaded with packed colour

  • format – The exact format of the source colour

Returns

Color – The corresponding RGB colour

inline Color unpack(PackedColor packed, PixelFormat format)
inline Color unpack(uint32_t packed, PixelFormat format)
size_t writeColor(void *buffer, PackedColor color, PixelFormat format)

Store a packed colour value into memory.

Parameters
  • buffer – Where to write the colour value

  • color – The value to write

Returns

size_t – The number of bytes written

inline size_t writeColor(void *buffer, Color color, PixelFormat format)
size_t writeColor(void *buffer, PackedColor color, PixelFormat format, size_t count)

Store a block of packed colours into memory.

Parameters
  • buffer – Where to write the colour value

  • color – The value to write

  • count – The number of times to repeat the colour

Returns

size_t – The number of bytes written

inline size_t writeColor(void *buffer, Color color, PixelFormat format, size_t count)
size_t convert(const void *srcData, PixelFormat srcFormat, void *dstBuffer, PixelFormat dstFormat, size_t numPixels)

Convert block of data from one pixel format to another.

void highlightText(SceneObject &scene)

Highlight text segments and print details.

void highlightText(TextObject &object)
inline Origin opposite(Origin o)

Get the origin for the opposite side of the rectangle.

e.g. E -> W, NE -> SW

inline constexpr Size rotate(Size size, Orientation orientation)
template<typename T, typename Q>
constexpr TPoint<T> operator+(TPoint<T> pt, const Q &other)
template<typename T, typename Q>
constexpr TPoint<T> operator-(TPoint<T> pt, const Q &other)
template<typename T, typename Q>
constexpr TPoint<T> operator*(TPoint<T> pt, const Q &other)
template<typename T>
constexpr TPoint<T> operator*(TPoint<T> pt, const Size &other)
template<typename T, typename Q>
constexpr TPoint<T> operator/(TPoint<T> pt, const Q &other)
template<typename T>
constexpr TPoint<T> operator/(TPoint<T> pt, const Size &other)
template<typename T, typename Q>
constexpr TPoint<T> operator%(TPoint<T> pt, const Q &other)
template<typename T>
Rect operator+(const Rect &rect, const T &other)
inline Rect operator-(const Rect &rect, const Point &offset)
inline Rect intersect(Rect r1, const Rect &r2)
inline Region operator-(const Region &rgn, const Rect &r)
inline uint16_t originToDegrees(Origin origin)

Get corresponding angle for given origin.

Origin degreesToOrigin(uint16_t angle)

Get origin closest to given angle (expressed in degrees)

uint16_t normaliseAngle(int angle)

Make 0 <= angle < 360.

Variables

LcdFont lcdFont
static constexpr uint8_t PIN_NONE = {255}

Undefined I/O pin value.

class AbstractDisplay : public Graphics::Device, public Graphics::RenderTarget
#include <AbstractDisplay.h>

Use this class as a base for all types of display drivers.

Subclassed by Graphics::Display::Virtual, Graphics::SpiDisplay

struct AddressWindow
#include <AddressWindow.h>

Manages a rectangular area of display memory with position information.

Accesses to display memory is controlled by first setting an active Address Window. This is a rectangular area into which following writes (or reads) will store data.

Although the display hardware usually manages this some operations require tracking the position within the driver.

class ArcObject : public Graphics::ObjectTemplate<Object::Kind::Arc>
#include <Object.h>

An arc outline.

class ArcRectList : public Graphics::RectList
#include <Renderer.h>
class ArcRenderer : public Graphics::EllipseRenderer
#include <Renderer.h>

Render arc outline with adjustable line width.

class Asset : public LinkedObjectTemplate<Asset>, public Graphics::Meta
#include <Asset.h>

An asset is used to render an Object, but is not itself drawable.

Subclassed by Graphics::AssetTemplate< AssetType::Blend >, Graphics::AssetTemplate< AssetType::Font >, Graphics::AssetTemplate< AssetType::Object >, Graphics::AssetTemplate< AssetType::Pen >, Graphics::AssetTemplate< AssetType::SolidBrush >, Graphics::AssetTemplate< AssetType::Surface >, Graphics::AssetTemplate< AssetType::Text >, Graphics::AssetTemplate< AssetType::TextureBrush >, Graphics::AssetTemplate< AssetType::Typeface >, Graphics::AssetTemplate< asset_type >

class AssetList : public OwnedLinkedObjectListTemplate<Asset>
#include <Asset.h>
template<Asset::Type asset_type>
class AssetTemplate : public Graphics::Asset
#include <Asset.h>
class BitmapObject : public Graphics::StreamImageObject
#include <Object.h>

A BMP format image.

Code based on https://github.com/adafruit/Adafruit-GFX-Library

class Blend : public Graphics::AssetTemplate<AssetType::Blend>
#include <Blend.h>

Blend operations.

See MemoryImageSurface::write

Subclassed by Graphics::BlendTemplate< BlendMode::Alpha >, Graphics::BlendTemplate< BlendMode::Transparent >, Graphics::BlendTemplate< BlendMode::Write >, Graphics::BlendTemplate< BlendMode::XNor >, Graphics::BlendTemplate< BlendMode::Xor >, Graphics::BlendTemplate< blendMode >

class BlendAlpha : public Graphics::BlendTemplate<BlendMode::Alpha>
#include <Blend.h>
class BlendRenderer : public Graphics::Renderer
#include <Renderer.h>

Perform blending with draw.

template<BlendMode blendMode>
class BlendTemplate : public Graphics::Blend
#include <Blend.h>
class BlendTransparent : public Graphics::BlendTemplate<BlendMode::Transparent>
#include <Blend.h>
class BlendWrite : public Graphics::BlendTemplate<BlendMode::Write>
#include <Blend.h>
class BlendXNor : public Graphics::BlendTemplate<BlendMode::XNor>
#include <Blend.h>
class BlendXor : public Graphics::BlendTemplate<BlendMode::Xor>
#include <Blend.h>
class Brush : public Graphics::Meta
#include <Asset.h>

The source of colour for drawing.

Subclassed by Graphics::Pen

class CircleObject : public Graphics::ObjectTemplate<Object::Kind::Circle>
#include <Object.h>

A circle outline.

class CircleRenderer : public Graphics::Renderer
#include <Renderer.h>

Draws a circle outline.

Code based on https://github.com/adafruit/Adafruit-GFX-Library

class ColorRange
#include <Types.h>
class CopyObject : public Graphics::ObjectTemplate<Object::Kind::Copy>
#include <Object.h>

Describes a copy operation within the same surface.

class CopyRenderer : public Graphics::Renderer
#include <Renderer.h>

Copy an area within the same surface.

Subclassed by Graphics::ImageCopyRenderer

class Device
#include <Device.h>

A physical display device.

Subclassed by Graphics::AbstractDisplay, Graphics::Display::NullDevice

class DisplayList
#include <DisplayList.h>

Stores list of low-level display commands.

Used by hardware surfaces to efficiently buffer commands which are then executed in interrupt context.

The ILI9341 4-wire SPI mode is awkard to use so to allow more efficient access the command and data information is buffered as various types of ‘chunk’ using this class. A single HSPI request packet is used for all requests and is re-filled in interrupt context from this list.

Count values (data length) are stored as either 1 or 2 bytes. Values less than 0x80 bytes are stored in 1 byte, values from 0x0080 to 0x7fff are stored MSB first with the top bit set, followed by the LSB. For example, 0x1234 would be stored as 0x92 0x34.

Commands are stored in 1 byte. To allow use of this class with other displays may require adjusting this, perhaps converting this into a class template to accommodate these differences more efficiently.

  • Standard chunk. Contains a display-specific command byte followed by optional data.

    • command (1 byte)

    • data length (1 or 2 bytes)

    • data (variable length)

  • Data chunk (no command).

    • COMMAND_DATA (1 byte)

    • data length (1 or 2 bytes)

    • data (variable length)

  • Repeated data chunk (no command). Used to perform colour fills.

    • COMMAND_DATA_REPEAT (1 byte)

    • data length (1 or 2 bytes)

    • repeat count (1 or 2 bytes)

    • data (varible length)

  • Read command. Defines a single read command packet. Reading is particularly awkward on the ILI9341 as it ‘forgets’ the read position after each read packet. Reading a block of display memory therefore requires the address window to be set immediately before the RAMRD instruction. The final block in the sequence is a CALLBACK command.

    • COMMAND_READ (1 byte)

    • data length (1 or 2 bytes)

    • command (1 byte) The display-specific command to issue

    • buffer address (4 bytes)

  • Callback. Invokes a callback function (see Callback type). Note that the single parameter points to a copy of the original data which is stored in the list.

    • COMMAND_CALLBACK (1 byte)

    • parameter data length (1 or 2 bytes)

    • callback function pointer (4 bytes)

    • callback parameters (variable)

Subclassed by Graphics::SpiDisplayList

class DrawingObject : public Graphics::ObjectTemplate<Object::Kind::Drawing>
#include <Object.h>

A collection of line and curve drawing operations.

Stored in a compact format which can be streamed.

struct Ellipse
#include <Renderer.h>

State information for tracing an ellipse outline.

class EllipseObject : public Graphics::ObjectTemplate<Object::Kind::Ellipse>
#include <Object.h>

An ellipse outline.

class EllipseRenderer : public Graphics::Renderer
#include <Renderer.h>

Draws an ellipse outline.

Uses McIlroy’s Ellipse Algorithm

See http://enchantia.com/graphapp/doc/tech/ellipses.html

Subclassed by Graphics::ArcRenderer

class FileImageObject : public Graphics::RawImageObject, public Graphics::RenderTarget
#include <Object.h>
class FileImageSurface : public Graphics::ImageSurface
#include <ImageSurface.h>

Image surface using filing system as backing store.

Slower than RAM but size is unrestricted. Use for constructing complex scenes for faster drawing.

class FilledArcObject : public Graphics::ObjectTemplate<Object::Kind::FilledArc>
#include <Object.h>

A filled arc.

class FilledArcRenderer : public Graphics::FilledEllipseRenderer
#include <Renderer.h>

Render arc outline with adjustable line width.

class FilledCircleObject : public Graphics::ObjectTemplate<Object::Kind::FilledCircle>
#include <Object.h>

A filled circle.

class FilledCircleRenderer : public Graphics::Renderer
#include <Renderer.h>

Draws a filled circle.

Code based on https://github.com/adafruit/Adafruit-GFX-Library

class FilledEllipseObject : public Graphics::ObjectTemplate<Object::Kind::FilledEllipse>
#include <Object.h>

A filled ellipse.

class FilledEllipseRenderer : public Graphics::Renderer
#include <Renderer.h>

Draws a filled ellipse.

See http://enchantia.com/graphapp/doc/tech/ellipses.html

Subclassed by Graphics::FilledArcRenderer

class FilledRectObject : public Graphics::ObjectTemplate<Object::Kind::FilledRect>
#include <Object.h>

A filled rectangle.

class FilledRectRenderer : public Graphics::Renderer
#include <Renderer.h>

Draws a filled rectangle.

To accommodate transparency, etc.

class FilledRoundedRectRenderer : public Graphics::Renderer
#include <Renderer.h>

Draws a filled rectangle with rounded corners.

Code based on https://github.com/adafruit/Adafruit-GFX-Library

struct FillInfo
#include <DisplayList.h>

Supports DisplayList blend operations.

See

See DisplayList::fill

class Font : public Graphics::AssetTemplate<AssetType::Font>
#include <Asset.h>

Base class for a loaded font.

As there are various formats for defining fonts we need a consistent interface for accessing and rendering them, which this class defines.

Fonts are specified by family and size, and can be registered with various typefaces.

Subclassed by Graphics::LcdFont, Graphics::ResourceFont

class GfxLineRenderer : public Graphics::Renderer
#include <Renderer.h>

Draws 1-pixel lines.

Code based on https://github.com/adafruit/Adafruit-GFX-Library

struct GlyphMetrics
#include <Types.h>

Glyph metrics.

class GlyphObject : public Graphics::ImageObject
#include <Object.h>

A character glyph image.

Characters are accessed like regular images but there are some specialisations which may be necessary which this class exposes:

  • To support devices with custom renderers we require access to the raw monochrome bits

  • Images currently don’t support transparency, although this could be enabled using a flag bits in the PackedColor format. The display driver or renderer would then need to interpret this flag and render accordingly. An alternative method is to nominate a transparent colour.

Subclassed by Graphics::LcdGlyph

class GradientBrush : public Graphics::TextureBrush
#include <Asset.h>
class ImageBrush : public Graphics::TextureBrush
#include <Asset.h>

Brush using pixels from image.

class ImageCopyRenderer : public Graphics::CopyRenderer
#include <Renderer.h>
class ImageObject : public Graphics::ObjectTemplate<Object::Kind::Image>
#include <Object.h>

Virtual base class for an image.

Subclassed by Graphics::GlyphObject, Graphics::StreamImageObject

class ImageRenderer : public Graphics::Renderer
#include <Renderer.h>

Render an image object.

class ImageSurface : public Graphics::Surface
#include <ImageSurface.h>

Virtual class to access an image as a Surface.

Use to create off-screen bitmaps by drawing or copying areas from display memory.

Subclassed by Graphics::FileImageSurface, Graphics::MemoryImageSurface

template<typename T>
class ItemList
#include <Renderer.h>

Fixed list of types.

Rendering algorithms create small sets of points, lines or rectangles. Buffering these in a small list simplifies logic considerably.

class LcdFont : public Graphics::Font
#include <LcdFont.h>
class LcdGlyph : public Graphics::GlyphObject
#include <LcdFont.h>
class LcdTypeFace : public Graphics::TypeFace
#include <LcdFont.h>
class LineObject : public Graphics::ObjectTemplate<Object::Kind::Line>
#include <Object.h>

A drawn line.

class LineRenderer : public Graphics::Renderer
#include <Renderer.h>

Draws lines.

See http://enchantia.com/graphapp/

struct Location
#include <Types.h>

Identifies position within bounding rectangle.

class MemoryImageObject : public Graphics::RawImageObject, public Graphics::RenderTarget
#include <Object.h>
class MemoryImageSurface : public Graphics::ImageSurface
#include <ImageSurface.h>

Image surface using RAM as backing store.

Useful for sprites, etc.

class Meta
#include <Meta.h>

Empty base class to support object enumeration Non-virtual to avoid bloat.

Subclassed by Graphics::Asset, Graphics::Brush, Graphics::Object, Graphics::TextObject::Element, Graphics::TextOptions

class MetaWriter
#include <Meta.h>

Writes object content in readable format for debugging.

class MipiDisplay : public Graphics::SpiDisplay
#include <MipiDisplay.h>

Subclassed by Graphics::Display::ILI9341, Graphics::Display::ST7789V

class MipiSurface : public Graphics::Surface
#include <MipiDisplay.h>
class MultiRenderer : public Graphics::Renderer
#include <Renderer.h>

Base class to render multiple objects.

Subclassed by Graphics::Drawing::Renderer, Graphics::RenderQueue, Graphics::SceneRenderer

class Object : public LinkedObjectTemplate<Object>, public Graphics::Meta
#include <Object.h>

A drawable object inherits from this virtual base class.

Subclassed by Graphics::ObjectTemplate< object_kind >, Graphics::SceneObject, Graphics::ObjectTemplate< Object::Kind::Arc >, Graphics::ObjectTemplate< Object::Kind::Circle >, Graphics::ObjectTemplate< Object::Kind::Copy >, Graphics::ObjectTemplate< Object::Kind::Drawing >, Graphics::ObjectTemplate< Object::Kind::Ellipse >, Graphics::ObjectTemplate< Object::Kind::FilledArc >, Graphics::ObjectTemplate< Object::Kind::FilledCircle >, Graphics::ObjectTemplate< Object::Kind::FilledEllipse >, Graphics::ObjectTemplate< Object::Kind::FilledRect >, Graphics::ObjectTemplate< Object::Kind::Image >, Graphics::ObjectTemplate< Object::Kind::Line >, Graphics::ObjectTemplate< Object::Kind::Point >, Graphics::ObjectTemplate< Object::Kind::Polyline >, Graphics::ObjectTemplate< Object::Kind::Rect >, Graphics::ObjectTemplate< Object::Kind::Reference >, Graphics::ObjectTemplate< Object::Kind::Scroll >, Graphics::ObjectTemplate< Object::Kind::Surface >, Graphics::ObjectTemplate< Object::Kind::Text >

class ObjectAsset : public Graphics::AssetTemplate<AssetType::Object>
#include <Asset.h>
template<Object::Kind object_kind>
class ObjectTemplate : public Graphics::Object
#include <Object.h>
struct PackedColor
#include <Colors.h>

Colour in device pixel format.

class Pen : public Graphics::Brush
#include <Asset.h>

Subclassed by Graphics::PenAsset

class PenAsset : public Graphics::AssetTemplate<AssetType::Pen>, public Graphics::Pen
#include <Asset.h>
union PixelFormatStruct
#include <Colors.h>

Public Functions

inline uint8_t byteCount() const
inline uint8_t bitsPerPixel() const
inline ColorOrder colorOrder() const

Public Members

PixelFormat format
uint8_t mByteCount
uint8_t mBitsPerPixel
uint8_t mColorOrder
struct Graphics::PixelFormatStruct::[anonymous] [anonymous]
class PointList : public Graphics::ItemList<Point>
#include <Renderer.h>

Small list of points for drawing.

Algorithms generate multiple points within a loop so buffering them in a list simplifies logic considerably.

class PointObject : public Graphics::ObjectTemplate<Object::Kind::Point>
#include <Object.h>

A single pixel == 1x1 rectangle.

class PolylineObject : public Graphics::ObjectTemplate<Object::Kind::Polyline>
#include <Object.h>

A sequence of lines.

By default, lines are connected. This is used to draw rectangles, triangles or any other type of polygon. A line is drawn between points 0-1, 1-2, 2-3, etc.

Setting the connected property to false allows the lines to be discontinuous, so a line is drawn between points 0-1, 2-3, 3-4, etc.

class PolylineRenderer : public Graphics::Renderer
#include <Renderer.h>

Draws series of lines defined by a PolylineObject

class RawImageObject : public Graphics::StreamImageObject
#include <Object.h>

Image stored as raw pixels in a specific format.

Use images stored in native display format for best performance as no conversion is required.

Subclassed by Graphics::FileImageObject, Graphics::MemoryImageObject

struct ReadBuffer
#include <Buffer.h>

Buffer used for reading pixel data from device.

Subclassed by Graphics::ReadStatusBuffer

struct ReadStatus
#include <Buffer.h>

Stores result of read operation.

struct ReadStatusBuffer : public Graphics::ReadBuffer
#include <Buffer.h>

Composite ReadBuffer with status.

class ReadStream
#include <Stream.h>
struct Rect
#include <Types.h>

Location and size of rectangular area (x, y, w, h)

class RectList : public Graphics::ItemList<Rect>
#include <Renderer.h>

Small list of rectangles, similar to PointList.

Subclassed by Graphics::ArcRectList

class RectObject : public Graphics::ObjectTemplate<Object::Kind::Rect>
#include <Object.h>

A rectangular outline.

class RectRenderer : public Graphics::Renderer
#include <Renderer.h>

Draws a rectangle as a polyline.

class ReferenceObject : public Graphics::ObjectTemplate<Object::Kind::Reference>
#include <Object.h>

Reference to another object.

Objects are owned by a Scene, so this allows objects to be re-used in multiple scenes, or to other classes which expose an Object interface.

class Region
#include <Types.h>

Represents the intersection of two rectangles.

This produces up to 4 separate, non-overlapping rectangles.

class Renderer : public LinkedObjectTemplate<Renderer>
#include <Object.h>

Virtual base class to manage rendering of various types of information to a surface.

Subclassed by Graphics::BlendRenderer, Graphics::CircleRenderer, Graphics::CopyRenderer, Graphics::EllipseRenderer, Graphics::FilledCircleRenderer, Graphics::FilledEllipseRenderer, Graphics::FilledRectRenderer, Graphics::FilledRoundedRectRenderer, Graphics::GfxLineRenderer, Graphics::ImageRenderer, Graphics::LineRenderer, Graphics::MultiRenderer, Graphics::PolylineRenderer, Graphics::RectRenderer, Graphics::RoundedRectRenderer, Graphics::ScrollRenderer, Graphics::SurfaceRenderer, Graphics::TextRenderer

class RenderQueue : private Graphics::MultiRenderer
#include <RenderQueue.h>

Top-level manager to queue objects for rendering to a specific target.

Use this to render single objects, typically Scenes or Drawings

class RenderTarget
#include <Object.h>

Interface for objects which support writing via surfaces.

Subclassed by Graphics::AbstractDisplay, Graphics::Display::NullDevice, Graphics::FileImageObject, Graphics::MemoryImageObject

class ResourceFont : public Graphics::Font
#include <Asset.h>
class ResourceTypeface : public Graphics::TypeFace
#include <Asset.h>
class RoundedRectRenderer : public Graphics::Renderer
#include <Renderer.h>

Draws a rectangle outline with rounded corners.

Code based on https://github.com/adafruit/Adafruit-GFX-Library

class Scale
#include <Types.h>
class SceneObject : public Graphics::Object
#include <Scene.h>

A Scene containing multiple objects.

class SceneRenderer : public Graphics::MultiRenderer
#include <Renderer.h>

A scene is a list of other objects, so we just iterate through the list and draw each in turn.

Rendering is performed by calling Surface::render(). Surfaces are provided by devices so may be able to provide optimised renderers for their hardware.

class ScrollObject : public Graphics::ObjectTemplate<Object::Kind::Scroll>
#include <Object.h>

Describes a scrolling operation.

class ScrollRenderer : public Graphics::Renderer
#include <Renderer.h>

Scroll an area.

class SharedBuffer
#include <Buffer.h>

Shared heap-allocated data buffer.

Used for write operations with data outside Command List.

struct Size
#include <Types.h>

Size of rectangular area (width x height)

class SolidBrush : public Graphics::AssetTemplate<AssetType::SolidBrush>
#include <Asset.h>
class SpiDisplay : protected HSPI::Device, public Graphics::AbstractDisplay
#include <SpiDisplay.h>

Subclassed by Graphics::MipiDisplay

class SpiDisplayList : public Graphics::DisplayList
#include <SpiDisplayList.h>

Display list for hardware SPI devices.

A single HSPI request packet is used for all requests and is re-filled in interrupt context from this list.

class StreamImageObject : public Graphics::ImageObject
#include <Object.h>

Image whose contents are stored in a stream, typically in a file or flash memory.

Subclassed by Graphics::BitmapObject, Graphics::RawImageObject

class SubStream : public IDataSourceStream
#include <Stream.h>
class Surface : public Graphics::AssetTemplate<AssetType::Surface>
#include <Surface.h>

Interface for a drawing surface.

Represents a rectangular area of pixels which can be read or written.

A display device has at least one of these, representing the primary display area. More complex devices with large amounts of display memory may allow additional surfaces to be used to perform screen updates by ‘flipping’ (switching active surface) or fast copies using display hardware.

Subclassed by Graphics::ImageSurface, Graphics::MipiSurface

Render an object

Surfaces may override this method to implement alternative rendering using specific hardware features of the display device.

param object

What to render

param location

Placement information

param renderer

If operation cannot be completed in hardware, create a renderer instance to manage the process

returns Return

true on success, false to retry later

Software renderers should be run by calling surface::execute.

class SurfaceObject : public Graphics::ObjectTemplate<Object::Kind::Surface>
#include <Object.h>

Describes a target surface and corresponding source location.

Used in surface copy operations to read display memory contents.

class SurfaceRenderer : public Graphics::Renderer
#include <Renderer.h>

Copy an area to another surface.

Typically used to copy display memory into RAM

class TextAsset : public Graphics::AssetTemplate<AssetType::Text>
#include <Asset.h>
class TextBuilder : public Graphics::TextParser, public Print
#include <TextBuilder.h>

Simplifies construction of TextObject instances.

class TextObject : public Graphics::ObjectTemplate<Object::Kind::Text>
#include <Object.h>

A block of text consisting of zero or more segments.

A segment is a straight run of text using a specific typeface and style.

class TextOptions : public Graphics::Meta
#include <Asset.h>
class TextParser
#include <TextBuilder.h>

Simplifies construction of TextObject instances.

Subclassed by Graphics::TextBuilder

class TextRenderer : public Graphics::Renderer
#include <Renderer.h>

Draw a line of text.

If foreground and background colours are the same then the text is renderered transparently.

class TextureBrush : public Graphics::AssetTemplate<AssetType::TextureBrush>
#include <Asset.h>

Subclassed by Graphics::GradientBrush, Graphics::ImageBrush

class Touch
#include <Touch.h>

Subclassed by Graphics::XPT2046

template<typename T>
struct TPoint
#include <Types.h>

An (x, y) display co-ordinate.

class TypeFace : public Graphics::AssetTemplate<AssetType::Typeface>
#include <Asset.h>

Base class for a loaded typeface, e.g. Sans 16pt bold.

Subclassed by Graphics::LcdTypeFace, Graphics::ResourceTypeface

class WriteStream
#include <Stream.h>
class XPT2046 : private HSPI::Device, public Graphics::Touch
#include <XPT2046.h>
namespace Display
class ILI9341 : public Graphics::MipiDisplay
#include <ILI9341.h>
class NullDevice : public Graphics::Device, public Graphics::RenderTarget
#include <Null.h>

Null display device, discards data.

Used for testing performance and algorithms.

class ST7789V : public Graphics::MipiDisplay
#include <ST7789V.h>
class Virtual : public Graphics::AbstractDisplay
#include <Virtual.h>

Virtual display device for Host.

Talks to python virtual screen application via TCP

namespace Drawing

Enums

enum Command

Values:

enumerator XX
enum OpCode

Values:

enumerator store
enumerator add
enumerator sub
enumerator execute

Functions

String toString(OpCode opcode)
union Header
#include <Header.h>

Command header structure.

Public Types

enum Type

Values:

enumerator uint8
enumerator uint16
enumerator uint32
enumerator resource
enum DataType

Values:

enumerator charArray
enum ResourceKind

Values:

enumerator text
enumerator image
enum LengthSize

Values:

enumerator uint8
enumerator uint16

Public Members

uint8_t index

Register index.

Type type
OpCode opcode

Operation to perform.

= OpCode::store

uint32_t param
struct Graphics::Drawing::Header::[anonymous] [anonymous]

Size of resource length field.

ResourceKind kind
LengthSize lengthSize
DataType dataType
struct Graphics::Drawing::Header::[anonymous] resource
Command cmd
class Reader
#include <Reader.h>
struct Registers
#include <Registers.h>
class Renderer : public Graphics::MultiRenderer
#include <Renderer.h>

A drawing contains a compact list of drawing commands, like a virtual plotter.

class Target
#include <Target.h>
class Writer
#include <Writer.h>
namespace Mipi

Enums

enum SerialInterfaceCommand

Values:

enumerator DSI_V_SYNC_START
enumerator DSI_V_SYNC_END
enumerator DSI_H_SYNC_START
enumerator DSI_H_SYNC_END
enumerator DSI_COMPRESSION_MODE
enumerator DSI_END_OF_TRANSMISSION
enumerator DSI_COLOR_MODE_OFF
enumerator DSI_COLOR_MODE_ON
enumerator DSI_SHUTDOWN_PERIPHERAL
enumerator DSI_TURN_ON_PERIPHERAL
enumerator DSI_GENERIC_SHORT_WRITE_0_PARAM
enumerator DSI_GENERIC_SHORT_WRITE_1_PARAM
enumerator DSI_GENERIC_SHORT_WRITE_2_PARAM
enumerator DSI_GENERIC_READ_REQUEST_0_PARAM
enumerator DSI_GENERIC_READ_REQUEST_1_PARAM
enumerator DSI_GENERIC_READ_REQUEST_2_PARAM
enumerator DSI_DCS_SHORT_WRITE
enumerator DSI_DCS_SHORT_WRITE_PARAM
enumerator DSI_DCS_READ
enumerator DSI_EXECUTE_QUEUE
enumerator DSI_SET_MAXIMUM_RETURN_PACKET_SIZE
enumerator DSI_NULL_PACKET
enumerator DSI_BLANKING_PACKET
enumerator DSI_GENERIC_LONG_WRITE
enumerator DSI_DCS_LONG_WRITE
enumerator DSI_PICTURE_PARAMETER_SET
enumerator DSI_COMPRESSED_PIXEL_STREAM
enumerator DSI_LOOSELY_PACKED_PIXEL_STREAM_YCBCR20
enumerator DSI_PACKED_PIXEL_STREAM_YCBCR24
enumerator DSI_PACKED_PIXEL_STREAM_YCBCR16
enumerator DSI_PACKED_PIXEL_STREAM_30
enumerator DSI_PACKED_PIXEL_STREAM_36
enumerator DSI_PACKED_PIXEL_STREAM_YCBCR12
enumerator DSI_PACKED_PIXEL_STREAM_16
enumerator DSI_PACKED_PIXEL_STREAM_18
enumerator DSI_PIXEL_STREAM_3BYTE_18
enumerator DSI_PACKED_PIXEL_STREAM_24
enum SerialTransactionType

Values:

enumerator DSI_RX_ACKNOWLEDGE_AND_ERROR_REPORT
enumerator DSI_RX_END_OF_TRANSMISSION
enumerator DSI_RX_GENERIC_SHORT_READ_RESPONSE_1BYTE
enumerator DSI_RX_GENERIC_SHORT_READ_RESPONSE_2BYTE
enumerator DSI_RX_GENERIC_LONG_READ_RESPONSE
enumerator DSI_RX_DCS_LONG_READ_RESPONSE
enumerator DSI_RX_DCS_SHORT_READ_RESPONSE_1BYTE
enumerator DSI_RX_DCS_SHORT_READ_RESPONSE_2BYTE
enum DisplayCommandSet

Values:

enumerator DCS_NOP
enumerator DCS_SOFT_RESET
enumerator DCS_GET_COMPRESSION_MODE
enumerator DCS_GET_DISPLAY_ID
enumerator DCS_GET_ERROR_COUNT_ON_DSI
enumerator DCS_GET_RED_CHANNEL
enumerator DCS_GET_GREEN_CHANNEL
enumerator DCS_GET_BLUE_CHANNEL
enumerator DCS_GET_DISPLAY_STATUS
enumerator DCS_GET_POWER_MODE
enumerator DCS_GET_ADDRESS_MODE
enumerator DCS_GET_PIXEL_FORMAT
enumerator DCS_GET_DISPLAY_MODE
enumerator DCS_GET_SIGNAL_MODE
enumerator DCS_GET_DIAGNOSTIC_RESULT
enumerator DCS_ENTER_SLEEP_MODE
enumerator DCS_EXIT_SLEEP_MODE
enumerator DCS_ENTER_PARTIAL_MODE
enumerator DCS_ENTER_NORMAL_MODE
enumerator DCS_GET_IMAGE_CHECKSUM_RGB
enumerator DCS_GET_IMAGE_CHECKSUM_CT
enumerator DCS_EXIT_INVERT_MODE
enumerator DCS_ENTER_INVERT_MODE
enumerator DCS_SET_GAMMA_CURVE
enumerator DCS_SET_DISPLAY_OFF
enumerator DCS_SET_DISPLAY_ON
enumerator DCS_SET_COLUMN_ADDRESS
enumerator DCS_SET_PAGE_ADDRESS
enumerator DCS_WRITE_MEMORY_START
enumerator DCS_WRITE_LUT
enumerator DCS_READ_MEMORY_START
enumerator DCS_SET_PARTIAL_ROWS
enumerator DCS_SET_PARTIAL_COLUMNS
enumerator DCS_SET_SCROLL_AREA
enumerator DCS_SET_TEAR_OFF
enumerator DCS_SET_TEAR_ON
enumerator DCS_SET_ADDRESS_MODE
enumerator DCS_SET_SCROLL_START
enumerator DCS_EXIT_IDLE_MODE
enumerator DCS_ENTER_IDLE_MODE
enumerator DCS_SET_PIXEL_FORMAT
enumerator DCS_WRITE_MEMORY_CONTINUE
enumerator DCS_SET_3D_CONTROL
enumerator DCS_READ_MEMORY_CONTINUE
enumerator DCS_GET_3D_CONTROL
enumerator DCS_SET_VSYNC_TIMING
enumerator DCS_SET_TEAR_SCANLINE
enumerator DCS_GET_SCANLINE
enumerator DCS_SET_DISPLAY_BRIGHTNESS
enumerator DCS_GET_DISPLAY_BRIGHTNESS
enumerator DCS_WRITE_CONTROL_DISPLAY
enumerator DCS_GET_CONTROL_DISPLAY
enumerator DCS_WRITE_POWER_SAVE
enumerator DCS_GET_POWER_SAVE
enumerator DCS_SET_CABC_MIN_BRIGHTNESS
enumerator DCS_GET_CABC_MIN_BRIGHTNESS
enumerator DCS_READ_DDB_START
enumerator DCS_READ_PPS_START
enumerator DCS_READ_DDB_CONTINUE
enumerator DCS_READ_PPS_CONTINUE
enum DcsAddressMode

Values:

enumerator DCS_ADDRESS_MODE_MIRROR_Y
enumerator DCS_ADDRESS_MODE_MIRROR_X
enumerator DCS_ADDRESS_MODE_SWAP_XY
enumerator DCS_ADDRESS_MODE_REFRESH_BT
enumerator DCS_ADDRESS_MODE_BGR
enumerator DCS_ADDRESS_MODE_RGB
enumerator DCS_ADDRESS_MODE_LATCH_RL
enumerator DCS_ADDRESS_MODE_FLIP_X
enumerator DCS_ADDRESS_MODE_FLIP_Y
enum DcsPixelFormat

Values:

enumerator DCS_PIXEL_FMT_24BIT
enumerator DCS_PIXEL_FMT_18BIT
enumerator DCS_PIXEL_FMT_16BIT
enumerator DCS_PIXEL_FMT_12BIT
enumerator DCS_PIXEL_FMT_8BIT
enumerator DCS_PIXEL_FMT_3BIT
namespace Resource

Functions

void init(IDataSourceStream *stream)
IDataSourceStream *createSubStream(uint32_t offset, size_t size)
struct FontResource
#include <resource.h>
struct GlyphBlock
#include <resource.h>

Identifies a run of unicode characters.

struct GlyphResource
#include <resource.h>

Describes glyph bitmap and position.

struct ImageResource
#include <resource.h>
struct TypefaceResource
#include <resource.h>

References

Used by

Environment Variables