Skip to content

Class daisy::OneBitGraphicsDisplayImpl

template <class ChildType>

ClassList > daisy > OneBitGraphicsDisplayImpl

More...

  • #include <display.h>

Inherits the following classes: daisy::OneBitGraphicsDisplay

Inherited by the following classes: daisy::OledDisplay

Public Functions

Type Name
virtual void DrawArc (uint_fast8_t x, uint_fast8_t y, uint_fast8_t radius, int_fast16_t start_angle, int_fast16_t sweep, bool on) override
virtual void DrawLine (uint_fast8_t x1, uint_fast8_t y1, uint_fast8_t x2, uint_fast8_t y2, bool on) override
virtual void DrawRect (uint_fast8_t x1, uint_fast8_t y1, uint_fast8_t x2, uint_fast8_t y2, bool on, bool fill=false) override
OneBitGraphicsDisplayImpl ()
virtual char WriteChar (char ch, FontDef font, bool on) override
virtual char WriteString (const char * str, FontDef font, bool on) override
virtual Rectangle WriteStringAligned (const char * str, const FontDef & font, Rectangle boundingBox, Alignment alignment, bool on) override
virtual ~OneBitGraphicsDisplayImpl ()

Public Functions inherited from daisy::OneBitGraphicsDisplay

See daisy::OneBitGraphicsDisplay

Type Name
size_t CurrentX ()
size_t CurrentY ()
virtual void DrawArc (uint_fast8_t x, uint_fast8_t y, uint_fast8_t radius, int_fast16_t start_angle, int_fast16_t sweep, bool on) = 0
void DrawCircle (uint_fast8_t x, uint_fast8_t y, uint_fast8_t radius, bool on)
virtual void DrawLine (uint_fast8_t x1, uint_fast8_t y1, uint_fast8_t x2, uint_fast8_t y2, bool on) = 0
virtual void DrawPixel (uint_fast8_t x, uint_fast8_t y, bool on) = 0
virtual void DrawRect (uint_fast8_t x1, uint_fast8_t y1, uint_fast8_t x2, uint_fast8_t y2, bool on, bool fill=false) = 0
void DrawRect (const Rectangle & rect, bool on, bool fill=false)
virtual void Fill (bool on) = 0
Rectangle GetBounds () const
virtual uint16_t Height () const = 0
OneBitGraphicsDisplay ()
void SetCursor (uint16_t x, uint16_t y)
virtual void Update () = 0
virtual bool UpdateFinished () = 0
virtual uint16_t Width () const = 0
virtual char WriteChar (char ch, FontDef font, bool on) = 0
virtual char WriteString (const char * str, FontDef font, bool on) = 0
virtual Rectangle WriteStringAligned (const char * str, const FontDef & font, Rectangle boundingBox, Alignment alignment, bool on) = 0
virtual ~OneBitGraphicsDisplay ()

Protected Attributes inherited from daisy::OneBitGraphicsDisplay

See daisy::OneBitGraphicsDisplay

Type Name
uint16_t currentX_
uint16_t currentY_

Detailed Description

This class is intended as a intermediary class for your actual implementation of the OneBitGraphicsDisplay interface. It uses the CRTP design pattern where the template argument is the child class. It provides implementations for most of the functions, except DrawPixel(), Update() and Fill(), which you'll have to provide in your child class. The main goal of this class is to provide common drawing functions without relying on massive amounts of virtual function calls that would result in a performance loss. To achieve this, any drawing function that is implemented here and internally calls other drawing functions (e.g. DrawRect() which internally calls DrawPixel() and DrawLine()) makes these calls via the qualified name of these functions to explicitly suppress the virtual dispatch mechanism like this: To create a custom OneBitGraphicsDisplay implementation, you can A) inherit from OneBitGraphicsDisplay directly and provide all the drawing functions yourself B) Inherit from OneBitGraphicsDisplayImpl and only provide DrawPixel(), Fill() and Update() like this:

class MyDisplayClass : public OneBitGraphicsDisplayImpl<MyDisplayClass> { public: void Fill() override { ... }; void DrawPixel(uint_fast8_t x, uint_fast8_t y, bool on) override { ... }; void Update() override { ... } };

Public Functions Documentation

function DrawArc

inline virtual void daisy::OneBitGraphicsDisplayImpl::DrawArc (
    uint_fast8_t x,
    uint_fast8_t y,
    uint_fast8_t radius,
    int_fast16_t start_angle,
    int_fast16_t sweep,
    bool on
) override

Draws an arc around the specified coordinate

Parameters:

  • x x Coordinate of the center of the arc
  • y y Coordinate of the center of the arc
  • radius radius of the arc
  • start_angle angle where to start the arc
  • sweep total angle of the arc
  • on on or off

Implements daisy::OneBitGraphicsDisplay::DrawArc


function DrawLine

inline virtual void daisy::OneBitGraphicsDisplayImpl::DrawLine (
    uint_fast8_t x1,
    uint_fast8_t y1,
    uint_fast8_t x2,
    uint_fast8_t y2,
    bool on
) override

Draws a line from (x1, y1) to (y1, y2)

Parameters:

  • x1 x Coordinate of the starting point
  • y1 y Coordinate of the starting point
  • x2 x Coordinate of the ending point
  • y2 y Coordinate of the ending point
  • on on or off

Implements daisy::OneBitGraphicsDisplay::DrawLine


function DrawRect

inline virtual void daisy::OneBitGraphicsDisplayImpl::DrawRect (
    uint_fast8_t x1,
    uint_fast8_t y1,
    uint_fast8_t x2,
    uint_fast8_t y2,
    bool on,
    bool fill=false
) override

Draws a rectangle based on two coordinates.

Parameters:

  • x1 x Coordinate of the first point
  • y1 y Coordinate of the first point
  • x2 x Coordinate of the second point
  • y2 y Coordinate of the second point
  • on on or off
  • fill fill the rectangle or draw only the outline

Implements daisy::OneBitGraphicsDisplay::DrawRect


function OneBitGraphicsDisplayImpl

inline daisy::OneBitGraphicsDisplayImpl::OneBitGraphicsDisplayImpl () 

function WriteChar

inline virtual char daisy::OneBitGraphicsDisplayImpl::WriteChar (
    char ch,
    FontDef font,
    bool on
) override

Writes the character with the specific FontDef to the display buffer at the current Cursor position.

Parameters:

  • ch character to be written
  • font font to be written in
  • on on or off

Returns:

&

Implements daisy::OneBitGraphicsDisplay::WriteChar


function WriteString

inline virtual char daisy::OneBitGraphicsDisplayImpl::WriteString (
    const  char * str,
    FontDef font,
    bool on
) override

Similar to WriteChar, except it will handle an entire String. Wrapping does not happen automatically, so the width of the string must be kept within the dimensions of the screen.

Parameters:

  • str string to be written
  • font font to use
  • on on or off

Returns:

&

Implements daisy::OneBitGraphicsDisplay::WriteString


function WriteStringAligned

inline virtual Rectangle daisy::OneBitGraphicsDisplayImpl::WriteStringAligned (
    const  char * str,
    const  FontDef & font,
    Rectangle boundingBox,
    Alignment alignment,
    bool on
) override

Similar to WriteString but justified within a bounding box.

Parameters:

  • str string to be written
  • font font to use
  • boundingBox the bounding box to draw the text in
  • alignment the alignment to use
  • on on or off

Returns:

The rectangle that was drawn to

Implements daisy::OneBitGraphicsDisplay::WriteStringAligned


function ~OneBitGraphicsDisplayImpl

inline virtual daisy::OneBitGraphicsDisplayImpl::~OneBitGraphicsDisplayImpl () 


The documentation for this class was generated from the following file external-docs/libDaisy/src/hid/disp/display.h