sparkfun_serlcd
¶
CircuitPython driver library for the Sparkfun Serial LCD displays
Author(s): Gaston Williams
Based on the Arduino library for the Sparkfun SerLCD displays Written by Gaston Williams, August 22, 2018
Based on sample code provided with the SparkFun Serial OpenLCD display. The original LiquidCrystal library was written by David A. Mellis and modified by Limor Fried @ Adafruit and the OpenLCD code was written by Nathan Seidle @ SparkFun.
Implementation Notes¶
Hardware:
This is library is for the SparkFun Serial LCD displays
SparkFun sells these at its website: www.sparkfun.com
Do you like this library? Help support SparkFun. Buy a board!
16x2 SerLCD Black on RGB https://www.sparkfun.com/products/14072
16x2 SerLCD RGB on Black https://www.sparkfun.com/products/14073
20x4 SerLCD Black on RGB https://www.sparkfun.com/products/14074
Software and Dependencies:
Adafruit CircuitPython firmware for the supported boards: https://github.com/adafruit/circuitpython/releases
Adafruit’s Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
- sparkfun_serlcd.DEFAULT_I2C_ADDR = 114¶
Default I2C address for SerLCD
- class sparkfun_serlcd.Sparkfun_SerLCD¶
Abstract base class for Sparkfun AVR-Based Serial LCD display. Use the appropriate driver communcation subclass Sparkfun_SerLCD_I2C() for I2C, Sparkfun_SerLCD_SPI() for SPI or Sparkfun_SerLCD_UART for UART.
- autoscroll(enable)¶
Turn autoscrolling on and off.
- blink(value)¶
Turn the blink cursor on and off.
- clear()¶
Clear the display
- command(command)¶
Send a command to the display.
Command cheat sheet:
ASCII / DEC / HEX
‘|’ / 124 / 0x7C - Put into setting mode
Ctrl+c / 3 / 0x03 - Change width to 20
Ctrl+d / 4 / 0x04 - Change width to 16
Ctrl+e / 5 / 0x05 - Change lines to 4
Ctrl+f / 6 / 0x06 - Change lines to 2
Ctrl+g / 7 / 0x07 - Change lines to 1
Ctrl+h / 8 / 0x08 - Software reset of the system
Ctrl+i / 9 / 0x09 - Enable/disable splash screen
Ctrl+j / 10 / 0x0A - Save currently displayed text as splash
Ctrl+k / 11 / 0x0B - Change baud to 2400bps
Ctrl+l / 12 / 0x0C - Change baud to 4800bps
Ctrl+m / 13 / 0x0D - Change baud to 9600bps
Ctrl+n / 14 / 0x0E - Change baud to 14400bps
Ctrl+o / 15 / 0x0F - Change baud to 19200bps
Ctrl+p / 16 / 0x10 - Change baud to 38400bps
Ctrl+q / 17 / 0x11 - Change baud to 57600bps
Ctrl+r / 18 / 0x12 - Change baud to 115200bps
Ctrl+s / 19 / 0x13 - Change baud to 230400bps
Ctrl+t / 20 / 0x14 - Change baud to 460800bps
Ctrl+u / 21 / 0x15 - Change baud to 921600bps
Ctrl+v / 22 / 0x16 - Change baud to 1000000bps
Ctrl+w / 23 / 0x17 - Change baud to 1200bps
Ctrl+x / 24 / 0x18 - Change the contrast. Follow Ctrl+x with number 0 to 255. 120 is default.
Ctrl+y / 25 / 0x19 - Change the TWI address. Follow Ctrl+x with number 0 to 255. 114 (0x72) is default.
Ctrl+z / 26 / 0x1A - Enable/disable ignore RX pin on startup (ignore emergency reset)
‘+’ / 43 / 0x2B - Set RGB backlight with three following bytes, 0-255
‘,’ / 44 / 0x2C - Display current firmware version
‘-’ / 45 / 0x2D - Clear display. Move cursor to home position.
‘.’ / 46 / 0x2E - Enable system messages (ie, display ‘Contrast: 5’ when changed)
‘/’ / 47 / 0x2F - Disable system messages (ie, don’t display ‘Contrast: 5’ when changed)
‘0’ / 48 / 0x30 - Enable splash screen
‘1’ / 49 / 0x31 - Disable splash screen
/ 128-157 / 0x80-0x9D - Set the primary backlight brightness. 128 = Off, 157 = 100%.
/ 158-187 / 0x9E-0xBB - Set the green backlight brightness. 158 = Off, 187 = 100%.
/ 188-217 / 0xBC-0xD9 - Set the blue backlight brightness. 188 = Off, 217 = 100%.
For example, to change the baud rate to 115200 send 124 followed by 18.
- create_character(location, charmap)¶
Create a customer character location - character number 0 to 7 charmap - bytes for character as 8 x 5 bit map
- cursor(value)¶
Turn the underline cursor on and off.
- default_splash_screen()¶
Result to the default splash screen
- display(value)¶
Turn the display on and off quickly.
- home()¶
Send the cursor home
- left_to_right()¶
Set the text to flow from left to right. This is the direction that is common to most Western languages.
- move_cursor_left(count=1)¶
Move the cursor to the left
- move_cursor_right(count=1)¶
Scroll the display to the right
- reset()¶
Perform a software reset on the dislay.
- right_to_left()¶
Set the text to flow from right to left.
- save_splash_screen()¶
Save the current display as the splash screem.
- scroll_display_left(count=1)¶
Scroll the display to the left
- scroll_display_right(count=1)¶
Scroll the display to the right
- set_backlight(rgb)¶
Set the backlight with 24-bit RGB value.
- set_backlight_rgb(red, green, blue)¶
Set the backlight with byte values for r, g, b
- set_contrast(value)¶
Set the display contrast.
- set_cursor(col, row)¶
Set the cursor position.
- set_fast_backlight(rgb)¶
Set the backlight color by a 24-bit value in one pass.
- set_fast_backlight_rgb(red, green, blue)¶
Set the backlight color in one pass.
- set_i2c_address(new_address)¶
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.
byte new_addr - new i2c address
- show_version()¶
Show the firmware version on the display.
- splash_screen(enable)¶
Enable or disable the splash screem.
- system_messages(enable)¶
Enable or disable the printint of messages like ‘UART: 57600’ or ‘Contrast: 5’
- write(message)¶
Write a character string to the display.
- write_character(location)¶
Write a customer character to the display location - character number 0 to 7
- class sparkfun_serlcd.Sparkfun_SerLCD_I2C(i2c, address=114)¶
Driver subclass for Sparkfun Serial Displays over I2C communication
- class sparkfun_serlcd.Sparkfun_SerLCD_SPI(spi, cs)¶
Driver subclass for Sparkfun Serial LCD display over SPI communication
- class sparkfun_serlcd.Sparkfun_SerLCD_UART(uart)¶
Driver subclass for Sparkfun Serial LCD display over Serial communication