FastArduino v1.10
C++ library to build fast but small Arduino/AVR projects
Loading...
Searching...
No Matches
devices::display::Display< DISPLAY_DEVICE > Class Template Reference

Class handling drawing primitives on any display device. More...

#include <fastarduino/devices/display.h>

Inheritance diagram for devices::display::Display< DISPLAY_DEVICE >:
Collaboration diagram for devices::display::Display< DISPLAY_DEVICE >:

Public Types

using COLOR = typename DISPLAY_TRAITS::COLOR
 The type of one pixel color. More...
 
using FONT = Font< DISPLAY_TRAITS::VERTICAL_FONT >
 The type of Fonts for this display device. More...
 
using DRAW_MODE = DrawMode< COLOR >
 The type of DrawMode for this display device. More...
 
using XCOORD = typename DISPLAY_TRAITS::XCOORD
 Integral type of X coordinate. More...
 
using YCOORD = typename DISPLAY_TRAITS::YCOORD
 Integral type of Y coordinate. More...
 
using POINT = Point< XCOORD, YCOORD >
 Coordinates of a point in the display. More...
 
using SCALAR = typename DISPLAY_TRAITS::SCALAR
 Integral type used in various calculations based on coordinates. More...
 

Public Member Functions

 Display ()=default
 Comstruct a display instance.
 
void set_draw_mode (const DRAW_MODE &mode)
 Set draw mode (color, pixel op) to use for next calls to drawing primitives. More...
 
void set_fill_mode (const DRAW_MODE &mode)
 Set fill mode (color, pixel op) to use for next calls to drawing primitives (for closed surfaces only). More...
 
void set_font (const FONT &font)
 Set the new font to use for next calls to text drawing perimitives. More...
 
Error last_error () const
 Error code of latest called drawing primitive. More...
 
void erase ()
 Erase complete display. More...
 
void draw_char (POINT point, char value)
 Draw one character at the given display location. More...
 
void draw_string (POINT point, const char *content)
 Draw a string of characters at the given display location. More...
 
void draw_string (POINT point, const flash::FlashStorage *content)
 Draw a string of characters at the given display location. More...
 
void draw_point (POINT point)
 Draw a pixel at given coordinate. More...
 
void draw_line (POINT point1, POINT point2)
 Draw a line between 2 points, at given coordinates. More...
 
void draw_rectangle (POINT point1, POINT point2)
 Draw a rectangle defined by 2 corner points, at given coordinates. More...
 
void draw_rounded_rectangle (POINT point1, POINT point2, SCALAR radius)
 Draw a rounded rectangle defined by 2 corner points, at given coordinates, and the radius of circle arcs drawn at each corner. More...
 
void draw_circle (POINT center, SCALAR radius)
 Draw a circle defined by its center, at given coordinates, and its radius. More...
 
void draw_polyline (std::initializer_list< POINT > points)
 Draw lines between consecutive points in the provided list. More...
 
void draw_polygon (std::initializer_list< POINT > points)
 Draw a polygon (closed surface) with lines between consecutive points in the provided list. More...
 
template<typename F >
void draw_bitmap (POINT origin, POINT size, F input_streamer)
 Draw a bitmap onto the display device. More...
 
void update ()
 For display devices having a raster buffer, this method copies invalid (modified) parts of the raster buffer to the device. More...
 
void force_update ()
 For display devices having a raster buffer, this method copies the whole raster buffer to the device. More...
 

Static Public Attributes

static constexpr XCOORD WIDTH = DISPLAY_TRAITS::WIDTH
 Display width. More...
 
static constexpr YCOORD HEIGHT = DISPLAY_TRAITS::HEIGHT
 Display height. More...
 

Protected Types

using SIGNED_SCALAR = typename DISPLAY_TRAITS::SIGNED_SCALAR
 Integral signed type used in calculations of some drawing primitives. More...
 

Detailed Description

template<typename DISPLAY_DEVICE>
class devices::display::Display< DISPLAY_DEVICE >

Class handling drawing primitives on any display device.

Tha driver for the actual display device is provided by the template argument DISPLAY_DEVICE. Display supports devices with or without a raster buffer.

Warning
if DISPLAY_DEVICE uses a raster buffer, then drawing primitives never display anything until you call update().

Drawing primitives calls may generate various errors and possibly have no impact on display. Errors may be checked after each drawing primitive call, through last_error() call.

Template Parameters
DISPLAY_DEVICEreal display device class, must subclass AbstractDisplay

Definition at line 434 of file display.h.

Member Typedef Documentation

◆ COLOR

template<typename DISPLAY_DEVICE >
using devices::display::Display< DISPLAY_DEVICE >::COLOR = typename DISPLAY_TRAITS::COLOR

The type of one pixel color.

Definition at line 444 of file display.h.

◆ FONT

template<typename DISPLAY_DEVICE >
using devices::display::Display< DISPLAY_DEVICE >::FONT = Font<DISPLAY_TRAITS::VERTICAL_FONT>

The type of Fonts for this display device.

Definition at line 446 of file display.h.

◆ DRAW_MODE

template<typename DISPLAY_DEVICE >
using devices::display::Display< DISPLAY_DEVICE >::DRAW_MODE = DrawMode<COLOR>

The type of DrawMode for this display device.

Definition at line 448 of file display.h.

◆ XCOORD

template<typename DISPLAY_DEVICE >
using devices::display::Display< DISPLAY_DEVICE >::XCOORD = typename DISPLAY_TRAITS::XCOORD

Integral type of X coordinate.

Definition at line 450 of file display.h.

◆ YCOORD

template<typename DISPLAY_DEVICE >
using devices::display::Display< DISPLAY_DEVICE >::YCOORD = typename DISPLAY_TRAITS::YCOORD

Integral type of Y coordinate.

Definition at line 452 of file display.h.

◆ POINT

template<typename DISPLAY_DEVICE >
using devices::display::Display< DISPLAY_DEVICE >::POINT = Point<XCOORD, YCOORD>

Coordinates of a point in the display.

Definition at line 455 of file display.h.

◆ SCALAR

template<typename DISPLAY_DEVICE >
using devices::display::Display< DISPLAY_DEVICE >::SCALAR = typename DISPLAY_TRAITS::SCALAR

Integral type used in various calculations based on coordinates.

Typically the smallest of XCOORD and YCOORD.

Definition at line 461 of file display.h.

◆ SIGNED_SCALAR

template<typename DISPLAY_DEVICE >
using devices::display::Display< DISPLAY_DEVICE >::SIGNED_SCALAR = typename DISPLAY_TRAITS::SIGNED_SCALAR
protected

Integral signed type used in calculations of some drawing primitives.

This must be larger or equal to XCOORD and YCOORD. It mst be large enough to store -4 * min(WIDTH, HEIGHT).

Definition at line 474 of file display.h.

Member Function Documentation

◆ set_draw_mode()

template<typename DISPLAY_DEVICE >
void devices::display::Display< DISPLAY_DEVICE >::set_draw_mode ( const DRAW_MODE mode)
inline

Set draw mode (color, pixel op) to use for next calls to drawing primitives.

Parameters
modethe new DRAW_MODE to use from now

Definition at line 485 of file display.h.

◆ set_fill_mode()

template<typename DISPLAY_DEVICE >
void devices::display::Display< DISPLAY_DEVICE >::set_fill_mode ( const DRAW_MODE mode)
inline

Set fill mode (color, pixel op) to use for next calls to drawing primitives (for closed surfaces only).

Parameters
modethe new DRAW_MODE to use from now for filling areas

Definition at line 496 of file display.h.

◆ set_font()

template<typename DISPLAY_DEVICE >
void devices::display::Display< DISPLAY_DEVICE >::set_font ( const FONT font)
inline

Set the new font to use for next calls to text drawing perimitives.

Parameters
fontthe new font to use from now
See also
Font

Definition at line 507 of file display.h.

◆ last_error()

template<typename DISPLAY_DEVICE >
Error devices::display::Display< DISPLAY_DEVICE >::last_error ( ) const
inline

Error code of latest called drawing primitive.

Automatically erased (set to Error::NO_ERROR) by a successful call to a drawing primitive. If the latest drawing primitive set an error, this means nothing was drawn at all.

Returns
Error Error::NO_ERROR if last drawing primitive ran successfully.

Definition at line 521 of file display.h.

◆ erase()

template<typename DISPLAY_DEVICE >
void devices::display::Display< DISPLAY_DEVICE >::erase ( )
inline

Erase complete display.

Definition at line 529 of file display.h.

◆ draw_char()

template<typename DISPLAY_DEVICE >
void devices::display::Display< DISPLAY_DEVICE >::draw_char ( POINT  point,
char  value 
)
inline

Draw one character at the given display location.

Parameters
pointcoordinates of top left character pixel
valuecode of character to write; this must be available in the current loaded Font.
See also
AbstractDisplayDevice::set_font()

Definition at line 544 of file display.h.

◆ draw_string() [1/2]

template<typename DISPLAY_DEVICE >
void devices::display::Display< DISPLAY_DEVICE >::draw_string ( POINT  point,
const char *  content 
)
inline

Draw a string of characters at the given display location.

Parameters
pointcoordinates of 1st top left character pixel
contentC-string of characters to write; all charcaters must be available in the current loaded Font.
See also
AbstractDisplayDevice::set_font()

Definition at line 570 of file display.h.

◆ draw_string() [2/2]

template<typename DISPLAY_DEVICE >
void devices::display::Display< DISPLAY_DEVICE >::draw_string ( POINT  point,
const flash::FlashStorage *  content 
)
inline

Draw a string of characters at the given display location.

Parameters
pointcoordinates of 1st top left character pixel
contentC-string of characters, stored in MCU Flash, to write; all charcaters must be available in the current loaded Font.
See also
AbstractDisplayDevice::set_font()

Definition at line 609 of file display.h.

◆ draw_point()

template<typename DISPLAY_DEVICE >
void devices::display::Display< DISPLAY_DEVICE >::draw_point ( POINT  point)
inline

Draw a pixel at given coordinate.

Parameters
pointcoordinates of pixel to draw

Definition at line 647 of file display.h.

◆ draw_line()

template<typename DISPLAY_DEVICE >
void devices::display::Display< DISPLAY_DEVICE >::draw_line ( POINT  point1,
POINT  point2 
)
inline

Draw a line between 2 points, at given coordinates.

Parameters
point1coordinates of line 1st point
point2coordinates of line 2nd point

Definition at line 665 of file display.h.

◆ draw_rectangle()

template<typename DISPLAY_DEVICE >
void devices::display::Display< DISPLAY_DEVICE >::draw_rectangle ( POINT  point1,
POINT  point2 
)
inline

Draw a rectangle defined by 2 corner points, at given coordinates.

Parameters
point1coordinates of rectangle 1st corner
point2coordinates of rectangle 2nd corner

Definition at line 711 of file display.h.

◆ draw_rounded_rectangle()

template<typename DISPLAY_DEVICE >
void devices::display::Display< DISPLAY_DEVICE >::draw_rounded_rectangle ( POINT  point1,
POINT  point2,
SCALAR  radius 
)
inline

Draw a rounded rectangle defined by 2 corner points, at given coordinates, and the radius of circle arcs drawn at each corner.

Parameters
point1coordinates of rectangle 1st corner
point2coordinates of rectangle 2nd corner
radiusradius of circle arcs to draw at corners

Definition at line 724 of file display.h.

◆ draw_circle()

template<typename DISPLAY_DEVICE >
void devices::display::Display< DISPLAY_DEVICE >::draw_circle ( POINT  center,
SCALAR  radius 
)
inline

Draw a circle defined by its center, at given coordinates, and its radius.

Parameters
centercoordinates of circle center
radiuscircle radius

Definition at line 787 of file display.h.

◆ draw_polyline()

template<typename DISPLAY_DEVICE >
void devices::display::Display< DISPLAY_DEVICE >::draw_polyline ( std::initializer_list< POINT points)
inline

Draw lines between consecutive points in the provided list.

Parameters
pointslist of coordinates of consecutive points to join with lines

Definition at line 813 of file display.h.

◆ draw_polygon()

template<typename DISPLAY_DEVICE >
void devices::display::Display< DISPLAY_DEVICE >::draw_polygon ( std::initializer_list< POINT points)
inline

Draw a polygon (closed surface) with lines between consecutive points in the provided list.

A line is added to connect the last point of the list to the first point.

Parameters
pointslist of coordinates of consecutive points to join with lines

Definition at line 825 of file display.h.

◆ draw_bitmap()

template<typename DISPLAY_DEVICE >
template<typename F >
void devices::display::Display< DISPLAY_DEVICE >::draw_bitmap ( POINT  origin,
POINT  size,
F  input_streamer 
)
inline

Draw a bitmap onto the display device.

No clipping is performed, bitmap must be fully displayable at origin, otherwise an error willl occur and nothing wil be drawn.

Bitmap content is made of a sequence of bytes, each byte representing 8 horizontal pixels:

  • each 1 pixel will be drawn with current outline mode, as set with set_draw_mode()
  • each 0 pixel will be drawn with current filling mode, as set with set_fill_mode()
Template Parameters
FFunctor class which instance input_streamer will be used to read bitmap byte after byte; class should be able to read bitmap bytes wherever they are (Flash memore, SD card...)
Parameters
originthe point at which the top left corner of the bitmap shall be displayed
sizethe size of the bitmap to diaply
input_streamera functor instance that will be called repeatedly for each bitmap byte, from the first to the last
See also
flash::FlashReader

Definition at line 854 of file display.h.

◆ update()

template<typename DISPLAY_DEVICE >
void devices::display::Display< DISPLAY_DEVICE >::update ( )
inline

For display devices having a raster buffer, this method copies invalid (modified) parts of the raster buffer to the device.

For such devices, nothing will get actually drawn until update() is called.

This is useless for devices with direct draw to device (no raster buffer).

Definition at line 906 of file display.h.

◆ force_update()

template<typename DISPLAY_DEVICE >
void devices::display::Display< DISPLAY_DEVICE >::force_update ( )
inline

For display devices having a raster buffer, this method copies the whole raster buffer to the device.

This is useless for devices with direct draw to device (no raster buffer).

Definition at line 921 of file display.h.

Member Data Documentation

◆ WIDTH

template<typename DISPLAY_DEVICE >
constexpr XCOORD devices::display::Display< DISPLAY_DEVICE >::WIDTH = DISPLAY_TRAITS::WIDTH
staticconstexpr

Display width.

Maximum X coordinate on display is WIDTH - 1.

Definition at line 464 of file display.h.

◆ HEIGHT

template<typename DISPLAY_DEVICE >
constexpr YCOORD devices::display::Display< DISPLAY_DEVICE >::HEIGHT = DISPLAY_TRAITS::HEIGHT
staticconstexpr

Display height.

Maximum Y coordinate on display is HEIGHT - 1.

Definition at line 466 of file display.h.


The documentation for this class was generated from the following file: