DUDS
Distributed Update of Data from Something
duds::hardware::display::TextDisplay Class Referenceabstract

A fairly generic interface to a character based display that lacks color. More...

#include <TextDisplay.hpp>

Inheritance diagram for duds::hardware::display::TextDisplay:
Collaboration diagram for duds::hardware::display::TextDisplay:

Public Member Functions

virtual ~TextDisplay ()=0
 Allows destruction of a pointer of this base class to properly destruct the derived object. More...
 
virtual void clear ()=0
 Removes all text from the display and moves the cursor to the upper left corner. More...
 
void clearTo (unsigned int c, unsigned int r)
 Clear text from the current cursor position to the given position, inclusive. More...
 
unsigned int columnPos () const
 The current column position of the cursor. More...
 
unsigned int columns () const
 Returns the number of columns on the display. More...
 
void move (unsigned int c, unsigned int r)
 Moves the cursor to the given location. More...
 
unsigned int rowPos () const
 The current row position of the cursor. More...
 
unsigned int rows () const
 Returns the number of rows on the display. More...
 
void write (int c)
 Writes a single character onto the display at the current cursor location and advances the cursor. More...
 
void write (const std::string &text)
 Writes a string onto the display starting from the current cursor location. More...
 
void write (const std::string &text, unsigned int c, unsigned int r)
 Writes a string onto the display starting from the given location. More...
 

Protected Member Functions

 TextDisplay ()
 Initializes the object with an invalid display size and cursor position. More...
 
 TextDisplay (unsigned int c, unsigned int r)
 Initializes the object with the given display size and an invalid cursor position. More...
 
virtual bool advance ()
 Advances the column position, and if it goes off the visible portion of the display, updates the row position. More...
 
virtual void moveImpl (unsigned int c, unsigned int r)=0
 Moves the display's cursor to the indicated position. More...
 
virtual void writeImpl (int c)=0
 Writes a single character onto the display at the current cursor location. More...
 
virtual void writeImpl (const std::string &text)
 Writes a string to the display. More...
 
virtual void writeImpl (const std::string &text, unsigned int c, unsigned int r)
 Writes a string to the display starting at the indicated location. More...
 

Protected Attributes

std::uint8_t columnsize
 Number of columns on the display. More...
 
std::uint8_t cpos
 Cursor column position. More...
 
std::uint8_t rowsize
 Number of rows on the display. More...
 
std::uint8_t rpos
 Cursor row position. More...
 

Detailed Description

A fairly generic interface to a character based display that lacks color.

This class is not thread-safe because using a text display directly from multiple threads makes little sense.

Author
Jeff Jackowski

Definition at line 31 of file TextDisplay.hpp.

Constructor & Destructor Documentation

◆ TextDisplay() [1/2]

duds::hardware::display::TextDisplay::TextDisplay ( )
protected

Initializes the object with an invalid display size and cursor position.

Definition at line 16 of file TextDisplay.cpp.

◆ TextDisplay() [2/2]

duds::hardware::display::TextDisplay::TextDisplay ( unsigned int  c,
unsigned int  r 
)
protected

Initializes the object with the given display size and an invalid cursor position.

Parameters
cThe number of columns on the display.
rThe number of rows on the display.

Definition at line 19 of file TextDisplay.cpp.

◆ ~TextDisplay()

duds::hardware::display::TextDisplay::~TextDisplay ( )
pure virtual

Allows destruction of a pointer of this base class to properly destruct the derived object.

Definition at line 22 of file TextDisplay.cpp.

Member Function Documentation

◆ advance()

bool duds::hardware::display::TextDisplay::advance ( )
protectedvirtual

Advances the column position, and if it goes off the visible portion of the display, updates the row position.

Returns true if moveImpl() or similar function must be called to reposition the cursor onto a visible spot. The default implementation is for displays that do not keep the cursor on the visible part of the display when moving past the end of a row.

Definition at line 24 of file TextDisplay.cpp.

Referenced by write(), and duds::hardware::devices::displays::HD44780::writeImpl().

◆ clear()

virtual void duds::hardware::display::TextDisplay::clear ( )
pure virtual

Removes all text from the display and moves the cursor to the upper left corner.

Precondition
initialize() has been successfully called.

Implemented in duds::hardware::devices::displays::HD44780.

◆ clearTo()

void duds::hardware::display::TextDisplay::clearTo ( unsigned int  c,
unsigned int  r 
)

Clear text from the current cursor position to the given position, inclusive.

The cursor will be moved to the spot immediately after the given position. The implementation writes spaces while the cursor is not at the position, then writes one more.

Parameters
cThe end column.
rThe end row.
Exceptions
DisplayBoundsErrorThe requested position is beyond the display's boundries.

Definition at line 106 of file TextDisplay.cpp.

Referenced by duds::hardware::display::TextDisplayBasicStreambuf< Char, Traits >::startLine().

◆ columnPos()

unsigned int duds::hardware::display::TextDisplay::columnPos ( ) const
inline

The current column position of the cursor.

Definition at line 179 of file TextDisplay.hpp.

Referenced by duds::hardware::display::TextDisplayBasicStreambuf< Char, Traits >::startLine().

◆ columns()

unsigned int duds::hardware::display::TextDisplay::columns ( ) const
inline

Returns the number of columns on the display.

This value is supplied to the object by the using program rather than by the display.

Definition at line 166 of file TextDisplay.hpp.

Referenced by duds::hardware::display::TextDisplayBasicStreambuf< Char, Traits >::startLine().

◆ move()

void duds::hardware::display::TextDisplay::move ( unsigned int  c,
unsigned int  r 
)

Moves the cursor to the given location.

Parameters
cThe destination column.
rThe destination row.
Exceptions
DisplayBoundsErrorThe requested position is beyond the display's boundries.

Definition at line 36 of file TextDisplay.cpp.

Referenced by writeImpl().

◆ moveImpl()

virtual void duds::hardware::display::TextDisplay::moveImpl ( unsigned int  c,
unsigned int  r 
)
protectedpure virtual

Moves the display's cursor to the indicated position.

The position has already passed a range check. The new position will be recorded by the caller, move(unsigned int, unsigned int), so there is no need for this function to record the new position.

Implemented in duds::hardware::devices::displays::HD44780.

Referenced by move(), and write().

◆ rowPos()

unsigned int duds::hardware::display::TextDisplay::rowPos ( ) const
inline

The current row position of the cursor.

Definition at line 185 of file TextDisplay.hpp.

Referenced by duds::hardware::display::TextDisplayBasicStreambuf< Char, Traits >::startLine().

◆ rows()

unsigned int duds::hardware::display::TextDisplay::rows ( ) const
inline

Returns the number of rows on the display.

This value is supplied to the object by the using program rather than by the display.

Definition at line 173 of file TextDisplay.hpp.

◆ write() [1/3]

void duds::hardware::display::TextDisplay::write ( int  c)

Writes a single character onto the display at the current cursor location and advances the cursor.

Precondition
initialize() has been successfully called.
Parameters
cThe character to write.

Definition at line 53 of file TextDisplay.cpp.

Referenced by clearTo(), and writeImpl().

◆ write() [2/3]

void duds::hardware::display::TextDisplay::write ( const std::string &  text)

Writes a string onto the display starting from the current cursor location.

If the cursor moves off the visible portion of the display, it will be moved to a visible spot. The spot will be the start of the next row down, or if no such row exixts, the start of the first row.

Precondition
initialize() has been successfully called.
Parameters
textThe string to write.

Definition at line 69 of file TextDisplay.cpp.

◆ write() [3/3]

void duds::hardware::display::TextDisplay::write ( const std::string &  text,
unsigned int  c,
unsigned int  r 
)

Writes a string onto the display starting from the given location.

If the cursor moves off the visible portion of the display, it will be moved to a visible spot. The spot will be the start of the next row down, or if no such row exixts, the start of the first row.

Precondition
initialize() has been successfully called.
Parameters
textThe string to write.
cThe starting column.
rThe starting row.
Exceptions
DisplayBoundsErrorThe requested position is beyond the display's boundries.

Definition at line 87 of file TextDisplay.cpp.

◆ writeImpl() [1/3]

virtual void duds::hardware::display::TextDisplay::writeImpl ( int  c)
protectedpure virtual

Writes a single character onto the display at the current cursor location.

The cursor location is already set prior to the call. After the call, advance() is called to move the cursor.

Implemented in duds::hardware::devices::displays::HD44780.

Referenced by write().

◆ writeImpl() [2/3]

void duds::hardware::display::TextDisplay::writeImpl ( const std::string &  text)
protectedvirtual

Writes a string to the display.

This function must handle advancing the cursor, and must reposition the cursor when repos is true. The default implementation calls writeImpl(int), advance(), and moveImpl() in a loop.

Reimplemented in duds::hardware::devices::displays::HD44780.

Definition at line 61 of file TextDisplay.cpp.

◆ writeImpl() [3/3]

void duds::hardware::display::TextDisplay::writeImpl ( const std::string &  text,
unsigned int  c,
unsigned int  r 
)
protectedvirtual

Writes a string to the display starting at the indicated location.

This function must handle moving and advancing the cursor. The default implementation calls move(), then write(const std::string &).

Reimplemented in duds::hardware::devices::displays::HD44780.

Definition at line 77 of file TextDisplay.cpp.

Member Data Documentation

◆ columnsize

std::uint8_t duds::hardware::display::TextDisplay::columnsize
protected

Number of columns on the display.

Definition at line 36 of file TextDisplay.hpp.

Referenced by advance(), clearTo(), columns(), duds::hardware::devices::displays::HD44780::configure(), move(), and write().

◆ cpos

◆ rowsize

std::uint8_t duds::hardware::display::TextDisplay::rowsize
protected

◆ rpos


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