|
DUDS
|
Distributed Update of Data from Something
|
A fairly generic interface to a character based display that lacks color. More...
#include <TextDisplay.hpp>
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... | |
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.
Definition at line 31 of file TextDisplay.hpp.
|
protected |
Initializes the object with an invalid display size and cursor position.
Definition at line 16 of file TextDisplay.cpp.
|
protected |
Initializes the object with the given display size and an invalid cursor position.
| c | The number of columns on the display. |
| r | The number of rows on the display. |
Definition at line 19 of file TextDisplay.cpp.
|
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.
|
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().
|
pure virtual |
Removes all text from the display and moves the cursor to the upper left corner.
Implemented in duds::hardware::devices::displays::HD44780.
| 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.
| c | The end column. |
| r | The end row. |
| DisplayBoundsError | The 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().
|
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().
|
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().
| void duds::hardware::display::TextDisplay::move | ( | unsigned int | c, |
| unsigned int | r | ||
| ) |
Moves the cursor to the given location.
| c | The destination column. |
| r | The destination row. |
| DisplayBoundsError | The requested position is beyond the display's boundries. |
Definition at line 36 of file TextDisplay.cpp.
Referenced by writeImpl().
|
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.
|
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().
|
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.
| void duds::hardware::display::TextDisplay::write | ( | int | c | ) |
Writes a single character onto the display at the current cursor location and advances the cursor.
| c | The character to write. |
Definition at line 53 of file TextDisplay.cpp.
Referenced by clearTo(), and writeImpl().
| 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.
| text | The string to write. |
Definition at line 69 of file TextDisplay.cpp.
| 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.
| text | The string to write. |
| c | The starting column. |
| r | The starting row. |
| DisplayBoundsError | The requested position is beyond the display's boundries. |
Definition at line 87 of file TextDisplay.cpp.
|
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().
|
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.
|
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.
|
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().
|
protected |
Cursor column position.
Definition at line 44 of file TextDisplay.hpp.
Referenced by advance(), duds::hardware::devices::displays::HD44780::clear(), clearTo(), columnPos(), duds::hardware::devices::displays::HD44780::initialize(), move(), duds::hardware::devices::displays::HD44780::setGlyph(), write(), and duds::hardware::devices::displays::HD44780::writeImpl().
|
protected |
Number of rows on the display.
Definition at line 40 of file TextDisplay.hpp.
Referenced by advance(), clearTo(), duds::hardware::devices::displays::HD44780::configure(), duds::hardware::devices::displays::HD44780::initialize(), move(), rows(), and write().
|
protected |
Cursor row position.
Definition at line 48 of file TextDisplay.hpp.
Referenced by advance(), duds::hardware::devices::displays::HD44780::clear(), clearTo(), duds::hardware::devices::displays::HD44780::initialize(), move(), rowPos(), duds::hardware::devices::displays::HD44780::setGlyph(), write(), and duds::hardware::devices::displays::HD44780::writeImpl().