16 namespace duds {
namespace hardware {
namespace devices {
namespace displays {
25 std::chrono::nanoseconds delay
45 std::chrono::nanoseconds delay
48 if ((c > 20) || (c < 1) || (r > 4) || (r < 1)) {
55 if (!outPins.havePins() || !enablePin) {
59 if (outPins.size() != 5) {
63 std::vector<duds::hardware::interface::DigitalPinCap> caps =
64 outPins.capabilities();
66 std::vector<duds::hardware::interface::DigitalPinCap>::const_iterator iter =
69 for (; iter != caps.cend(); ++pos, ++iter) {
71 if (!iter->canOutput()) {
79 iter->firstOutputDriveConfigFlags()
92 auto remain =
soonestSend - std::chrono::high_resolution_clock::now();
93 if (remain.count() > 0) {
138 soonestSend = std::chrono::high_resolution_clock::now();
148 static const std::uint8_t initdata[] {
162 std::this_thread::sleep_for(std::chrono::milliseconds(4));
164 int loop =
sizeof(initdata) - 1;
165 for (; loop >=
sizeof(initdata) - 4; --loop) {
167 std::this_thread::sleep_for(std::chrono::milliseconds(2));
173 std::this_thread::sleep_for(std::chrono::milliseconds(2));
175 for (; loop >= 0; --loop) {
177 std::this_thread::sleep_for(std::chrono::milliseconds(2));
206 sendByte(acc, 0x80 | (rowStartAddr[r] + c));
211 std::string::const_iterator iter = text.begin();
223 }
while (++iter != text.end());
240 const std::string &text,
247 sendByte(acc, 0x80 | (rowStartAddr[r] + c));
267 if ((idx < 0) || (idx > 7)) {
273 if ((glyph->width() > 5) || (glyph->height() > 8)) {
284 for (; y < glyph->height(); ++y) {
286 std::uint8_t row = *(glyph->bufferLine(y));
boost::error_info< struct Info_ImageDimensions, ImageDimensions > ImageErrorDimensions
Image dimensions relevant to the error.
std::chrono::high_resolution_clock::time_point soonestSend
The soonest time a new command can be sent to the display.
An attempt was made to use an uninitialized display object.
void YieldingWait(Duration duration)
Waits for a minumum period of time by calling std::this_thread::yield() in a loop.
void initialize()
Initializes the display for use.
The image given for a definable glyph was an unsupported size.
void write(Int val, int bits) const
Writes out a number in binary to the pins.
Defines the configuration for a digital general purpose I/O pin.
static std::uint8_t rowStartAddr[4]
The address used by the display for the start of each row.
void wait() const
Waits until the time in soonestSend has passed.
The operation has too few or much data to work on the pins, which can alternately be stated as having...
HD44780()
Initializes the object with an invalid display size and no pins to use.
move_impl move(unsigned int c, unsigned int r)
Display stream manipulator that moves the display cursor to the given location.
duds::hardware::interface::ChipSelect enable
Used to represent the enable line of the LCD.
A pin required for the operation does not exist or is unavailable to the process. ...
DigitalPinConfig modifyConfig(unsigned int pos, const DigitalPinConfig &conf) const
Modifies the configuration of a pin.
boost::error_info< struct Info_PinId, unsigned int > PinErrorId
The pin global ID involved in the error.
An object to wrap together a ChipSelectManager and chip ID to simplify code that needs to repeatedly ...
boost::error_info< struct Info_DisplayGlyph, int > DisplayGlyphIndex
Index used for a definable glyph.
The specified display size is unsupported, or there is a display size mismatch.
std::shared_ptr< BppImage > BppImageSptr
std::uint8_t cpos
Cursor column position.
Stores column and row data for display errors.
duds::hardware::interface::DigitalPinSetAccess output
The set used for the 4 data pins and the text flag, more commonly referred to as "RS".
Represents a set of pins on a single DigitalPort.
std::uint8_t columnsize
Number of columns on the display.
std::unique_ptr< DigitalPinSetAccess > access() const
Obtains an access object for all the pins in this set.
Flag to send only a nibble rather than a whole byte; used in display initalization.
bool havePins() const
Returns true if this object has been given any pins to represent.
std::uint8_t rowsize
Number of rows on the display.
std::uint8_t rpos
Cursor row position.
Stores access objects together.
void off()
Commands the display to turn off.
void deselect()
Deselects the chip.
std::unique_ptr< ChipAccess > access()
Obtains a ChipAccess object.
void output(unsigned int pos, bool state) const
Changes the output state of a pin.
virtual void clear()
Removes all text from the display and moves the cursor to the upper left corner.
void on()
Commands the display to turn on.
Indicates that a request to configure a pin to output was made of a pin that cannot output...
std::vector< duds::hardware::interface::DigitalPinConfig > outcfg
The best output configuration for the display bus given the port in use.
void setGlyph(const std::shared_ptr< duds::ui::graphics::BppImage > &glyph, int idx)
Loads a glyph into the display's CGRAM (Character Generator Random Access Memory).
virtual ~HD44780()
Calls off().
TextDisplay()
Initializes the object with an invalid display size and cursor position.
duds::hardware::interface::DigitalPinSet outputs
Represents the 5 output lines, other than enable, that are needed to communicate with the LCD...
void preparePins(Access &acc)
Obtains access to the pins and configures them for output.
duds::hardware::interface::ChipAccess enable
Used to assert the enable line of the LCD.
void sendByte(Access &acc, int val)
Sends a byte to the display a nibble at a time.
The index given for a definable glyph was outside the allowable range.
std::chrono::nanoseconds nibblePeriod
The amount of time to allow the display to read data.
void configure(duds::hardware::interface::DigitalPinSet &&outPins, duds::hardware::interface::ChipSelect &&enablePin, unsigned int c, unsigned int r, std::chrono::nanoseconds delay=std::chrono::nanoseconds(8000))
Sets the pins to use for communicating with the display.
virtual void writeImpl(int c)
Writes a single character to the display.
Flag for sending text to the display rather than a command.
Integer ReverseBits(Integer i)
Reverses the bits in a given value.
void select()
Selects the chip.
#define DUDS_THROW_EXCEPTION(x)
Works like BOOST_THROW_EXCEPTION, but includes a stack trace if DUDS_ERRORS_VERBOSE is defined...
virtual void moveImpl(unsigned int c, unsigned int r)
Moves the display's cursor to the indicated position.
virtual bool advance()
Advances the column position, and if it goes off the visible portion of the display, updates the row position.
boost::error_info< struct Info_DisplaySize, Info_DisplayColRow > TextDisplaySizeInfo
Column and row size of a display as part of an error.