FastArduino v1.10
C++ library to build fast but small Arduino/AVR projects
Loading...
Searching...
No Matches
devices::display Namespace Reference

Defines generic API for all display devices. More...

Classes

class  DefaultVerticalFont7x5
 
class  Display
 Class handling drawing primitives on any display device. More...
 
struct  DisplayDeviceTrait
 Traits for display devices. More...
 
struct  DisplayDeviceTrait_impl
 Default base class for all DisplayDeviceTrait. More...
 
class  DrawContext
 Drawing Context passed to display devices low-level primitives set_pixel() and write_char(). More...
 
class  DrawMode
 Drawing Mode to use for Display drawing primitives. More...
 
class  Font
 Generic font support class. More...
 
class  LCD5110
 SPI device driver for Nokia 5110 display chip. More...
 

Enumerations

enum class  Mode : uint8_t {
  COPY = 0 ,
  XOR ,
  AND ,
  OR ,
  NO_CHANGE = 0xFF
}
 Mode used when drawing pixels. More...
 
enum class  Error : uint8_t {
  NO_ERROR = 0 ,
  NO_FONT_SET ,
  NO_GLYPH_FOUND ,
  OUT_OF_DISPLAY ,
  COORDS_INVALID ,
  INVALID_GEOMETRY
}
 Types of errors that can occur on Display instances. More...
 
enum class  TemperatureCoefficient : uint8_t {
  TC0_1mV_K = 0x04 ,
  TC1_9mV_K = 0x05 ,
  TC2_17mV_K = 0x06 ,
  TC3_24mV_K = 0x07
}
 Possible temperature coeeficient that can be set on Nokia5110 display. More...
 

Detailed Description

Defines generic API for all display devices.

Any actual device class must:

  • derive from AbstractDisplayDevice template class
  • define XCOORD, YCOORD, SCALAR, SIGNED_SCALAR integral types
  • define HAS_RASTER bool constant indicating if the device uses a raster buffer
  • define WIDTH and HEIGHT constants
  • define a protected default constructor
  • implement 4 protected drawing primitives
    • erase()
    • set_pixel(x, y)
    • is_valid_char_xy(x, y)
    • write_char(x, y, glyph_ref)
  • implement protected update(x1, y1, x2, y2) method
  • implement any device-specific public API

A display device class becomes actually usable be defining a type as the Display template class instantiation for the display device class itself. The type such defined:

  • inherits the display device class and thus provides all its specific public API
  • provides additional 2D drawing primitives as public API

You can see a concrete example for LCD5110 device:

LCD5110 is a usual SPIDevice subclass, since this device is based on SPI.

Then, actual use of LCD5110 is performed through Display<LCD5110<...>>.

Display devices are:

  • either based on a SRAM raster buffer they have to handle themselves (this is applicable only to small resolution devices such as Nokia5110, as SRAM is a scarce resource on AVR MCU); this device needs to provide an implementation of update() method that sends invalidated raster pixels to the device.
  • or they directly draw evey pixel directly to the device because they cannot possibly hold a raster buffer in SRAM (too large resolution, like ILI9340); this device must implement an empty update() method.

Enumeration Type Documentation

◆ Mode

enum class devices::display::Mode : uint8_t
strong

Mode used when drawing pixels.

This determines how the destination pixel color is affected by the source color.

Note
Not all display devices can support all modes, as most modes (except Mode::COPY) require access to a raster buffer (either in SRAM or on the display chip itself).
Enumerator
COPY 

Source color simply replaces destination pixel.

XOR 

Destination pixel is xor'ed with source color (inversion mode).

AND 

Destination pixel is and'ed with source color (clear mode).

OR 

Destination pixel is or'ed with source color (set mode).

NO_CHANGE 

In this mode, the destination pixel never changes, whatever the source color.

Definition at line 101 of file display.h.

◆ Error

enum class devices::display::Error : uint8_t
strong

Types of errors that can occur on Display instances.

See also
Display.last_error()
Enumerator
NO_ERROR 

No error occurred.

NO_FONT_SET 

A text drawing primitive has been called but no font has been set yet.

NO_GLYPH_FOUND 

A text drawing primitive has been called with a character value which has no glyph in current font.

OUT_OF_DISPLAY 

A drawing primitive would draw its shape outside the display estate, which is forbidden.

This may be due to out of range (x,y) coordinates, or extra arguments (e.g. too large circle radius).

COORDS_INVALID 

A drawing primitive has been called with invalid (x,y) coordinates; this is different to COORDS_OUT_OF_RANGE in the sens that actual display devices may impose specific constraint on x or y coordinates (e.g.

being a multiple of 8).

INVALID_GEOMETRY 

A drawing primitive would lead to incorrect geometry due to invalid arguments.

This may be due to various factors such as:

  • trying to draw a line between A and B where A == B
  • trying to draw a flat rectangle
  • trying to draw a circle with a 0 radius

Definition at line 291 of file display.h.

◆ TemperatureCoefficient

enum class devices::display::TemperatureCoefficient : uint8_t
strong

Possible temperature coeeficient that can be set on Nokia5110 display.

Enumerator
TC0_1mV_K 

TC0 Temperature coefficient 1mV/K

TC1_9mV_K 

TC0 Temperature coefficient 9mV/K

TC2_17mV_K 

TC0 Temperature coefficient 17mV/K

TC3_24mV_K 

TC0 Temperature coefficient 24mV/K

Definition at line 57 of file lcd5110.h.