CharLCDPlate Class

The CharLCDPlate Class is designed to work with the Adafruit Character LCD Plate. This page documents the public API of the GPS Class.

Note: the CharLCDPlate Class is dependent on the MCP23017 Class.

Adafruit RGB Positive 16x2 LCD+Keypad Kit for Raspberry Pi

PRODUCT ID: 1109
This new Adafruit Pi Plate makes it easy to use an RGB 16x2 Character LCD. We really like the RGB Character LCDs we stock in the shop. (For RGB we have
$24.95
IN STOCK

Adafruit RGB Negative 16x2 LCD+Keypad Kit for Raspberry Pi

PRODUCT ID: 1110
This new Adafruit Pi Plate makes it easy to use an RGB 16x2 Character LCD. We really like the RGB Character LCDs we stock in the shop. (For RGB we have
$24.95
IN STOCK

Constructor

The class has a single constructor, CharLCDPlate(), which takes no arguments.

The constructor creates an instance of the MCP23017 class.

Download: file
public CharLCDPlate()

Methods

BeginAsync

This is an asynchronous method that initializes the MCP23017 and the Character LCD.

The method takes three integer arguments (the third argument is optional): cols, which specifies the number of columns on the LCD, lines, which specifies the number of lines on the LCD, and the optional argument dotsize, which specifies the dor matrix size of each character. Default is 5x8.

Constant values for the third argument are defined:

  • public const byte LCD_5x10DOTS = 0x04;
  • public const byte LCD_5x8DOTS = 0x00;

 

Download: file
public async Task BeginAsync(int cols, int lines, int dotsize = LCD_5x8DOTS)

clear

This method takes no arguments and clears the LCD display

Download: file
public void clear()

home

This method takes no arguments and moves the cursor to the 0,0 (home) position

Download: file
public void home()

setCursor

This methof positions the cursor at the specified column and line. It takes two integer arguments, col and line. 

Download: file
public void setCursor(byte col, byte line)

createChar

The createChar method allows the host program to define a custom character. Up to 8 custom characters can be defined.

The method takes as arguments a location and an array of bytes. The location is the number of the custom character (0 through 7). The array is a set of bfitmapped bytes representing the dots of the character. For more information on defining custom characters, please see this page

Download: file
public void createChar(byte location, byte[] charmap)

readButtons

This method reads the state of the 5 buttons on the plate. It retutns a byte containing a bitmap of the button states (1=pressed/0=unpressed).

The class contains bitmask definitions for the 5 buttons:

  • public const byte BUTTON_UP = 0x08;
  • public const byte BUTTON_DOWN = 0x04;
  • public const byte BUTTON_LEFT = 0x10;
  • public const byte BUTTON_RIGHT = 0x02;
  • public const byte BUTTON_SELECT = 0x01;
Download: file
public byte readButtons()

setBacklight

This method controls the color of the RGB backlight on LCDs with a color backlight. It takes a single integer argument, color, which is a bitmap of the three colors.

  • Red : 0x04
  • Green : 0x02
  • Blue : 0x01

Backlights are either on or off. There is no shading.

Download: file
public void setBacklight(int color)

print

There are three overloads of the print method. The first overload takes a string as an argument, the second overload takes an integer as an argument, and the third overload takes a double as an argument.

All three overloads write characters to the display beginning at the current cursor location.

Download: file
public void print(string str)
public void print(int number)
public void print(double number)

Additional methods

The following methods are also available:

  • noDisplay : turn display off
  • display : turn display on
  • noCursor : turn underline cursor off
  • cursor : turn underline cursor on
  • noBlink : turn cursor blink off
  • blink : turn cursor blink on
  • scrollDisplayLeft : scroll display left
  • scrollDisplayRight : scroll display right
  • leftToRight : sets text to flow from left to right
  • rightToLeft : sets text to flow from right to left
  • autoscroll : when printing, characters fill from right (right justify)
  • noAutoscroll: when printing, characters fill from left (left justify)
Download: file
        public void noDisplay()
        public void display()
        public void noCursor()
        public void cursor()
        public void noBlink()
        public void blink()
        public void scrollDisplayLeft()
        public void scrollDisplayRight()
        public void leftToRight()
        public void rightToLeft()
        public void autoscroll()
        public void noAutoscroll()
This guide was first published on Nov 22, 2016. It was last updated on Nov 22, 2016. This page (CharLCDPlate Class) was last updated on Jul 30, 2019.