API Reference

qwiic_serlcd

Python module for the SparkFun SerLCD QWIIC products:

[SparkFun 16x2 SerLCD - RGB Backlight (Qwiic)](https://www.sparkfun.com/products/16396) [SparkFun 16x2 SerLCD - RGB Text (Qwiic)](https://www.sparkfun.com/products/16397) [SparkFun 20x4 SerLCD - RGB Backlight (Qwiic)](https://www.sparkfun.com/products/16398)

This python package enables the user to control the SerLCDs via I2C. It is intended to be used by simply plugging in a qwiic cable for power and I2C communicaiton.

This package can be used in conjunction with the overall [SparkFun qwiic Python Package](https://github.com/sparkfun/Qwiic_Py)

New to qwiic? Take a look at the entire [SparkFun qwiic ecosystem](https://www.sparkfun.com/qwiic).

class qwiic_serlcd.QwiicSerlcd(address=None, i2c_driver=None)[source]
Parameters:
  • address – The I2C address to use for the device. If not provided, the default address is used.
  • i2c_driver – An existing i2c driver object. If not provided a driver object is created.
Returns:

The QwiicSerlcd device object.

Return type:

Object

autoscroll()[source]

Turn autoscrolling on. This will right-justify text from the cursor.

Returns:Returns true if the I2C write was successful, otherwise False.
Return type:bool
begin()[source]

Initialize the operation of the SerLCD module

Returns:Returns true of the initializtion was successful, otherwise False.
Return type:bool

Turn the blink cursor on.

Returns:Returns true if the I2C write was successful, otherwise False.
Return type:bool
clearScreen()[source]

Sends the command to clear the screen

Returns:Returns true if the I2C write was successful, otherwise False.
Return type:bool
command(command)[source]

Send one setting command to the display. Used by other functions.

Parameters:command – Command to send (a single byte)
Returns:Returns true if the I2C write was successful, otherwise False.
Return type:bool
connected

Determine if a device is conntected to the system..

Returns:True if the device is connected, otherwise False.
Return type:bool
createChar(location, charmap)[source]

Create a customer character :param location: character number 0 to 7 :param charmap: byte array for character

Returns:Returns true if the I2C write was successful, otherwise False.
Return type:bool
cursor()[source]

Turn the underline cursor on.

Returns:Returns true if the I2C write was successful, otherwise False.
Return type:bool
disableSplash()[source]

Disable splash screen at power on

Returns:Returns true if the I2C write was successful, otherwise False.
Return type:bool
disableSystemMessages()[source]

Disable system messages

Returns:Returns true if the I2C write was successful, otherwise False.
Return type:bool
display()[source]

Turn the display on quickly.

Returns:Returns true if the I2C write was successful, otherwise False.
Return type:bool
enableSplash()[source]

Enable splash screen at power on

Returns:Returns true if the I2C write was successful, otherwise False.
Return type:bool
enableSystemMessages()[source]

Enable system messages

Returns:Returns true if the I2C write was successful, otherwise False.
Return type:bool
home()[source]

Send the home command to the display. This returns the cursor to return to the beginning of the display, without clearing the display.

Returns:Returns true if the I2C write was successful, otherwise False.
Return type:bool
is_connected()[source]

Determine if a device is conntected to the system..

Returns:True if the device is connected, otherwise False.
Return type:bool
leftToRight()[source]

Set the text to flow from left to right.

Returns:Returns true if the I2C write was successful, otherwise False.
Return type:bool
moveCursorLeft(count=1)[source]

Move the cursor one or more characters to the left.

Parameters:count – Number of character spaces you’d like to move
Returns:Returns true if the I2C write was successful, otherwise False.
Return type:bool
moveCursorRight(count=1)[source]

Move the cursor one or more characters to the right.

Parameters:count – Number of character spaces you’d like to move
Returns:Returns true if the I2C write was successful, otherwise False.
Return type:bool
noAutoscroll()[source]

Turn autoscrolling off.

Returns:Returns true if the I2C write was successful, otherwise False.
Return type:bool

Turn the blink cursor off.

Returns:Returns true if the I2C write was successful, otherwise False.
Return type:bool
noCursor()[source]

Turn the underline cursor off.

Returns:Returns true if the I2C write was successful, otherwise False.
Return type:bool
noDisplay()[source]

Turn the display off quickly.

Returns:Returns true if the I2C write was successful, otherwise False.
Return type:bool
print(string)[source]

Print a string of characters to the LCD

Parameters:string – The string you would like to print. Aka ASCII characters. example: “Hello”
Returns:Returns true if the I2C writes were successful, otherwise False.
Return type:bool
rightToLeft()[source]

Set the text to flow from right to left

Returns:Returns true if the I2C write was successful, otherwise False.
Return type:bool
saveSplash()[source]

Save the current display as the splash Saves whatever is currently being displayed into EEPROM This will be displayed at next power on as the splash screen

Returns:Returns true if the I2C write was successful, otherwise False.
Return type:bool
scrollDisplayLeft(count=1)[source]

Scroll the display one or multiple characters to the left, without changing the text.

Parameters:count – Number of character spaces you’d like to scroll
Returns:Returns true if the I2C write was successful, otherwise False.
Return type:bool
scrollDisplayRight(count=1)[source]

Scroll the display one or multiple characters to the right, without changing the text.

Parameters:count – Number of character spaces you’d like to scroll
Returns:Returns true if the I2C write was successful, otherwise False.
Return type:bool
setAddress(new_addr)[source]

Change the I2C Address. 0x72 is the default. Note that this change is persistent. If anything goes wrong you may need to do a hardware reset to unbrick the display. :param new_addr: new i2c address

Returns:Returns true if the I2C write was successful, otherwise False.
Return type:bool
setBacklight(r, g, b)[source]

Set the brightness of each backlight (red, green, blue)

Parameters:
  • red – The new red brightness value (0-255)
  • green – The new green brightness value (0-255)
  • blue – The new blue brightness value (0-255)
Returns:

Returns true if the I2C write was successful, otherwise False.

Return type:

bool

setContrast(contrast)[source]

Set the contrast of the LCD screen (0-255)

Parameters:contrast – The new contrast value (0-255)
Returns:Returns true if the I2C write was successful, otherwise False.
Return type:bool
setCursor(col, row)[source]

Set the cursor position to a particular column and row.

Parameters:
  • col – The column postion (0-19)
  • row – The row postion (0-3)
Returns:

Returns true if the I2C write was successful, otherwise False.

Return type:

bool

setFastBacklight(r, g, b)[source]

Set backlight with no LCD messages or delays :param r: red backlight value 0-255 :param g: green backlight value 0-255 :param b: blue backlight value 0-255

Returns:Returns true if the I2C write was successful, otherwise False.
Return type:bool
specialCommand(command, count=1)[source]

Send one (or multiple) special commands to the display. Used by other functions.

Parameters:
  • command – Command to send (a single byte)
  • count – Number of times to send the command (if ommited, then default is once)
Returns:

Returns true if the I2C write was successful, otherwise False.

Return type:

bool

writeChar(location)[source]

Write a customer character to the display :param location: character number 0 to 7

Returns:Returns true if the I2C write was successful, otherwise False.
Return type:bool
qwiic_serlcd.map(x, in_min, in_max, out_min, out_max)[source]

Map a value from one range to another

param in_min:minimum of input range
param in_max:maximum of input range
param out_min:minimum of output range
param out_max:maximum of output range
return:The value scaled to the new range
rtype:int