Zumo32U4 library
Public Member Functions | List of all members
PololuHD44780 Class Reference

Main class for interfacing with the HD44780 LCDs. More...

#include <PololuHD44780.h>

Inheritance diagram for PololuHD44780:
PololuHD44780Base

Public Member Functions

 PololuHD44780 (uint8_t rs, uint8_t e, uint8_t db4, uint8_t db5, uint8_t db6, uint8_t db7)
 
virtual void initPins ()
 
virtual void send (uint8_t data, bool rsValue, bool only4bits)
 
void init ()
 
void reinitialize ()
 
void clear ()
 
void loadCustomCharacter (const uint8_t *picture, uint8_t number)
 
void loadCustomCharacter (const char *picture, uint8_t number)
 
void loadCustomCharacterFromRam (const uint8_t *picture, uint8_t number)
 
void createChar (uint8_t number, uint8_t picture[])
 
void gotoXY (uint8_t x, uint8_t y)
 
void setCursor (uint8_t col, uint8_t row)
 
void noDisplay ()
 
void display ()
 
void noCursor ()
 
void cursor ()
 
void noBlink ()
 
void blink ()
 
void cursorSolid ()
 
void cursorBlinking ()
 
void hideCursor ()
 
void scrollDisplayLeft ()
 
void scrollDisplayRight ()
 
void home ()
 
void leftToRight ()
 
void rightToLeft ()
 
void autoscroll ()
 
void noAutoscroll ()
 
void command (uint8_t cmd)
 
virtual size_t write (uint8_t c)
 
virtual size_t write (const uint8_t *buffer, size_t size)
 

Detailed Description

Main class for interfacing with the HD44780 LCDs.

This class is suitable for controlling an HD44780 LCD assuming that the LCD's RS, E, DB4, DB5, DB6, and DB7 pins are each connected to a pin on the microcontroller, each of those six microcontroller pins is supported by the Arduino's pinMode and digitalWrite functions, and those pins are not being used for any other purpose that conflicts with the LCD.

This class sets the E pin to be an output driving low the first time you use the LCD, and it assumes that no other code will change that pin. You cannot use E for any other purposes because if the LCD sees a pulse on the E pin then it might consider that to be a command or data, and the LCD state will become corrupted.

For the other pins (RS, DB4, DB5, and DB6), this library reconfigures them each time they are used, so it is OK if you have other code that uses those pins for other purposes. Before writing to the LCD, you just need to disable any peripherals (such as UARTs) that override the output values of those pins.

If you cannot meet these conditions, you might be able to control your LCD using a custom subclass of PololuHD44780Base. You can use this class as a reference for how to do that.

Definition at line 360 of file PololuHD44780.h.

Constructor & Destructor Documentation

◆ PololuHD44780()

PololuHD44780::PololuHD44780 ( uint8_t  rs,
uint8_t  e,
uint8_t  db4,
uint8_t  db5,
uint8_t  db6,
uint8_t  db7 
)
inline

Creates a new instance of PololuHD44780.

Parameters
rsThe pin number for the microcontroller pin that is connected to the RS pin of the LCD.
eThe pin number for the microcontroller pin that is connected to the E pin of the LCD.
db4The pin number for the microcontroller pin that is connected to the DB4 pin of the LCD.
db5The pin number for the microcontroller pin that is connected to the DB5 pin of the LCD.
db6The pin number for the microcontroller pin that is connected to the DB6 pin of the LCD.
db7The pin number for the microcontroller pin that is connected to the DB7 pin of the LCD.

Definition at line 378 of file PololuHD44780.h.

Member Function Documentation

◆ autoscroll()

void PololuHD44780Base::autoscroll ( )
inherited

Turns on auto-scrolling.

When auto-scrolling is enabled, every time a character is written, the screen will automatically scroll by one column in the appropriate direction.

Definition at line 214 of file PololuHD44780.cpp.

◆ blink()

void PololuHD44780Base::blink ( )
inherited

Shows the blinking cursor.

This function sets the LCD's "B" configuration bit without changing the other bits.

The cursor will normally be a blinking rectangle, but there could also be a row of solid black pixels at the bottom if previous commands have enabled the solid cursor. For this reason, it is usually better to call cursorSolid() or cursorBlinking() instead. This function is only provided for compatibilty with the LiquidCrystal library.

Definition at line 177 of file PololuHD44780.cpp.

◆ clear()

void PololuHD44780Base::clear ( )
inherited

Clear the contents of the LCDs, resets the cursor position to the upper left, and resets the scroll position.

Definition at line 78 of file PololuHD44780.cpp.

◆ command()

void PololuHD44780Base::command ( uint8_t  cmd)
inlineinherited

Send an arbitrary command to the LCD. This is here for compatibility with the LiquidCrystal library.

Definition at line 294 of file PololuHD44780.h.

◆ createChar()

void PololuHD44780Base::createChar ( uint8_t  number,
uint8_t  picture[] 
)
inlineinherited

Defines a custom character. This is provided for compatibility with the LiquidCrystal library.

Definition at line 152 of file PololuHD44780.h.

◆ cursor()

void PololuHD44780Base::cursor ( )
inherited

Shows the solid cursor.

This function sets the LCD's "C" configuration bit without changing the other bits.

The cursor will normally be a solid line in the bottom row, but there could be a blinking rectangle superimposed on it if previous commands have enabled the blinking cursor. For this reason, it is usually better to call cursorSolid() or cursorBlinking() instead. This function is only provided for compatibility with the LiquidCrystal library.

Definition at line 167 of file PololuHD44780.cpp.

◆ cursorBlinking()

void PololuHD44780Base::cursorBlinking ( )
inherited

Enables a cursor that appears as a blinking black rectangle.

This sets the LCD's "C" and "B" configuration bits.

Note that the cursor will not be shown if the display is currently off (due to a call to noDisplay()), or if the cursor position is not within the bounds of the screen.

Definition at line 142 of file PololuHD44780.cpp.

◆ cursorSolid()

void PololuHD44780Base::cursorSolid ( )
inherited

Enables a cursor that appears as a solid line in the bottom row.

This sets the LCD's "C" configuration bit and clears its "B" bit.

Note that the cursor will not be shown if the display is currently off (due to a call to noDisplay()), or if the cursor position is not within the bounds of the screen.

Definition at line 137 of file PololuHD44780.cpp.

◆ display()

void PololuHD44780Base::display ( )
inherited

Turns the display on. This should only be needed if noDisplay() was previously called.

Definition at line 157 of file PololuHD44780.cpp.

◆ gotoXY()

void PololuHD44780Base::gotoXY ( uint8_t  x,
uint8_t  y 
)
inherited

Change the location of the cursor. The cursor (whether visible or invisible), is the place where the next character written to the LCD will be displayed.

Note that the scrolling features of the LCD change the correspondence between the x parameter and the physical column that the data is displayed on. See the "LCD scrolling" section above for more information.

Parameters
xThe number of the column to go to, with 0 being the leftmost column.
yThe number of the row to go to, with 0 being the top row.

Definition at line 88 of file PololuHD44780.cpp.

◆ hideCursor()

void PololuHD44780Base::hideCursor ( )
inherited

Hides the solid and blinking cursors.

This clears the LCD's "C" and "B" configuration bits.

Definition at line 147 of file PololuHD44780.cpp.

◆ home()

void PololuHD44780Base::home ( )
inherited

Resets the screen scrolling position back to the default and moves the cursor to the upper left corner of the screen.

This command takes about 1600 microseconds, so it would be faster to instead call scrollDisplayLeft() or scrollDisplayRight() the appropriate number of times and then call gotoXY(0, 0).

Definition at line 192 of file PololuHD44780.cpp.

◆ init()

void PololuHD44780Base::init ( )
inlineinherited

Initialize the LCD if it has not already been initialized.

Definition at line 67 of file PololuHD44780.h.

◆ initPins()

virtual void PololuHD44780::initPins ( )
inlinevirtual

Initializes the pins so that the send() function can be called successfully. This is the first step of initializing the LCD.

Implements PololuHD44780Base.

Definition at line 389 of file PololuHD44780.h.

◆ leftToRight()

void PololuHD44780Base::leftToRight ( )
inherited

Puts the LCD into left-to-right mode: the cursor will shift to the right after any character is written. This is the default behavior.

Definition at line 204 of file PololuHD44780.cpp.

◆ loadCustomCharacter() [1/2]

void PololuHD44780Base::loadCustomCharacter ( const char *  picture,
uint8_t  number 
)
inlineinherited

This overload of loadCustomCharacter is only provided for compatibility with OrangutanLCD; a lot of Orangutan code defines an array of chars for custom character pictures.

Definition at line 145 of file PololuHD44780.h.

◆ loadCustomCharacter() [2/2]

void PololuHD44780Base::loadCustomCharacter ( const uint8_t *  picture,
uint8_t  number 
)
inherited

Defines a custom character.

Parameters
pictureA pointer to the character dot pattern, in program space.
numberA number between 0 and 7.

Definition at line 103 of file PololuHD44780.cpp.

◆ loadCustomCharacterFromRam()

void PololuHD44780Base::loadCustomCharacterFromRam ( const uint8_t *  picture,
uint8_t  number 
)
inherited

Defines a custom character from RAM.

Parameters
pictureA pointer to the character dot pattern, in RAM.
numberA number between 0 and 7.

Definition at line 117 of file PololuHD44780.cpp.

◆ noAutoscroll()

void PololuHD44780Base::noAutoscroll ( )
inherited

Turns off auto-scrolling. Auto-scrolling is off by default.

Definition at line 219 of file PololuHD44780.cpp.

◆ noBlink()

void PololuHD44780Base::noBlink ( )
inherited

Hides the blinking cursor.

This functions clears the LCD's "B" configuration bit without changing the other bits.

Calling this function does not enable or disable the solid cursor (a solid line in the bottom row) so it is usually better to call hideCursor() or cursorSolid() instead. This function is only provided for compatibilty with the LiquidCrystal library.

Definition at line 172 of file PololuHD44780.cpp.

◆ noCursor()

void PololuHD44780Base::noCursor ( )
inherited

Hides the solid cursor.

This function clears the LCD's "C" configuration bit without changing the other bits.

If the "B" bit is set to 1, a blinking cursor will still be displayed even after calling this function. For that reason, it is usually better to call hideCursor() instead. This function is only provided for compatibility with the LiquidCrystal library.

Definition at line 162 of file PololuHD44780.cpp.

◆ noDisplay()

void PololuHD44780Base::noDisplay ( )
inherited

Turns off the display while preserving its state.

You can turn the display on again by calling display().

Definition at line 152 of file PololuHD44780.cpp.

◆ reinitialize()

void PololuHD44780Base::reinitialize ( )
inlineinherited

Reinitialize the LCD. This performs the same initialization that is done automatically the first time any function is called that writes to the LCD. This is useful if you want to get it back to a totally clean state.

Definition at line 80 of file PololuHD44780.h.

◆ rightToLeft()

void PololuHD44780Base::rightToLeft ( )
inherited

Puts the LCD into right-to-left mode: the cursor will shift to the left after any character is written.

Definition at line 209 of file PololuHD44780.cpp.

◆ scrollDisplayLeft()

void PololuHD44780Base::scrollDisplayLeft ( )
inherited

Scrolls everything on the screen one position to the left.

This command takes about 37 microseconds.

Definition at line 182 of file PololuHD44780.cpp.

◆ scrollDisplayRight()

void PololuHD44780Base::scrollDisplayRight ( )
inherited

Scrolls everything on the screen one position to the right.

This command takes about 37 microseconds.

Definition at line 187 of file PololuHD44780.cpp.

◆ send()

virtual void PololuHD44780::send ( uint8_t  data,
bool  rsValue,
bool  only4bits 
)
inlinevirtual

Sends data or commands to the LCD.

The initPins() function will always be called before the first time this function is called. This function does not need to worry about the delays necessary to make sure the previous command has finished; that is taken care of by PololuHD44780Base.

This function, along with initPins(), comprise the hardware abstraction layer for the LCD, and must be defined in a subclass of PololuHD44780Base. All other functions use these two functions to communicate with the LCD.

Parameters
dataThe data to send to the LCD.
rsValueTrue to drive the RS pin high, false to drive it low.
only4bitsIf true, and the LCD is using a 4-bit interface, only sends the lower 4 bits of the data.

Implements PololuHD44780Base.

Definition at line 395 of file PololuHD44780.h.

◆ setCursor()

void PololuHD44780Base::setCursor ( uint8_t  col,
uint8_t  row 
)
inlineinherited

Changes the location of the cursor. This is just a wrapper around gotoXY provided for compaitibility with the LiquidCrystal library.

Definition at line 170 of file PololuHD44780.h.

◆ write() [1/2]

size_t PololuHD44780Base::write ( const uint8_t *  buffer,
size_t  size 
)
virtualinherited

Writes multiple characters to the LCD.

Parameters
bufferPointer to a string of characters in RAM, not necessarily null-terminated.
sizeThe number of characters to write to the LCD, excluding any null termination character.

Definition at line 68 of file PololuHD44780.cpp.

◆ write() [2/2]

size_t PololuHD44780Base::write ( uint8_t  c)
virtualinherited

Writes a single character to the LCD.

Definition at line 62 of file PololuHD44780.cpp.


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