API
LCD
I2C LCD Display driver for 1602 and 2004 displays controlled via I2C
LCD data sheet: https://www.sparkfun.com/datasheets/LCD/HD44780.pdf
Ported to MicroPython from https://github.com/fdebrabander/Arduino-LiquidCrystal-I2C-library
- class lcd_i2c.lcd_i2c.LCD(addr: int, cols: int, rows: int, charsize: int = 0, i2c: None = None)[source]
Bases:
object
Driver for the Liquid Crystal LCD displays that use the I2C bus
- _command(value: int, mode: int = 0) None [source]
Send 8 bits command to I2C device
- Parameters
value (int) – The value
- _expander_write(value: int) None [source]
Write data to I2C device (port expander)
- Parameters
value (int) – The value to send
- _pulse_enable(value: int) None [source]
Pulse Enable (EN) pin
- Parameters
value (int) – The value to send
- _write_4_bits(value: int) None [source]
Write 4 bits to I2C device
- Parameters
value (int) – The value to send
- begin() None [source]
Set the LCD display in the correct begin state
Must be called before anything else is done
- clear() None [source]
Remove all the characters currently shown
Next print/write operation will start from the first position on LCD display.
- property cols: int
Get the number of columns of the LCD
- Returns
Number of columns of the LCD
- Return type
- create_char(location: int, charmap: None) None [source]
Fill the first 8 CGRAM locations with custom characters
- cursor() None [source]
Turn the underline cursor on
Cursor can blink or not blink. Use the methods @see blink and @see no_blink for changing the cursor blink status.
- display() None [source]
Turn the display on
Show the characters on the LCD display, this is the normal behaviour. This method should only be used after no_display() has been used.
@see no_display
- home() None [source]
Set cursor to home position (0, 0)
Next print/write operation will start from the first position on the LCD display.
- no_display() None [source]
Turn the display off
Do not show any characters on the LCD display. Backlight state will remain unchanged. Also all characters written on the display will return, when the display in enabled again.
@see display
HD44780 Constants
- lcd_i2c.const.EN = <Mock name='mock.const()' id='139917829882160'>
Enable bit
- lcd_i2c.const.LCD_1LINE = <Mock name='mock.const()' id='139917829882160'>
1 line command
- lcd_i2c.const.LCD_2LINE = <Mock name='mock.const()' id='139917829882160'>
2 line command
- lcd_i2c.const.LCD_4BITMODE = <Mock name='mock.const()' id='139917829882160'>
4 bit mode command
- lcd_i2c.const.LCD_5x10DOTS = <Mock name='mock.const()' id='139917829882160'>
5x10 dots display command
- lcd_i2c.const.LCD_5x8DOTS = <Mock name='mock.const()' id='139917829882160'>
5x8 dots display command
- lcd_i2c.const.LCD_8BITMODE = <Mock name='mock.const()' id='139917829882160'>
8 bit mode command
- lcd_i2c.const.LCD_BACKLIGHT = <Mock name='mock.const()' id='139917829882160'>
Activate backlight command
- lcd_i2c.const.LCD_BLINKOFF = <Mock name='mock.const()' id='139917829882160'>
Set curor no blink command
- lcd_i2c.const.LCD_BLINKON = <Mock name='mock.const()' id='139917829882160'>
Set curor blink command
- lcd_i2c.const.LCD_CLEARDISPLAY = <Mock name='mock.const()' id='139917829882160'>
Clear display command
- lcd_i2c.const.LCD_CURSORMOVE = <Mock name='mock.const()' id='139917829882160'>
Move cursor command
- lcd_i2c.const.LCD_CURSOROFF = <Mock name='mock.const()' id='139917829882160'>
Turn cursor off command
- lcd_i2c.const.LCD_CURSORON = <Mock name='mock.const()' id='139917829882160'>
Turn cursor on command
- lcd_i2c.const.LCD_CURSORSHIFT = <Mock name='mock.const()' id='139917829882160'>
Shift cursor command
- lcd_i2c.const.LCD_DISPLAYCONTROL = <Mock name='mock.const()' id='139917829882160'>
Control display command
- lcd_i2c.const.LCD_DISPLAYMOVE = <Mock name='mock.const()' id='139917829882160'>
Display move command
- lcd_i2c.const.LCD_DISPLAYOFF = <Mock name='mock.const()' id='139917829882160'>
Turn display off command
- lcd_i2c.const.LCD_DISPLAYON = <Mock name='mock.const()' id='139917829882160'>
Turn display on command
- lcd_i2c.const.LCD_ENTRYLEFT = <Mock name='mock.const()' id='139917829882160'>
Set display entry mode as left command
- lcd_i2c.const.LCD_ENTRYMODESET = <Mock name='mock.const()' id='139917829882160'>
Set entry mode command
- lcd_i2c.const.LCD_ENTRYRIGHT = <Mock name='mock.const()' id='139917829882160'>
Set display entry mode as right command
- lcd_i2c.const.LCD_ENTRYSHIFTDECREMENT = <Mock name='mock.const()' id='139917829882160'>
Set display entry mode as shift decrement command
- lcd_i2c.const.LCD_ENTRYSHIFTINCREMENT = <Mock name='mock.const()' id='139917829882160'>
Set display entry mode as shift increment command
- lcd_i2c.const.LCD_FUNCTIONSET = <Mock name='mock.const()' id='139917829882160'>
Set function command
- lcd_i2c.const.LCD_MOVELEFT = <Mock name='mock.const()' id='139917829882160'>
Move display shift left command
- lcd_i2c.const.LCD_MOVERIGHT = <Mock name='mock.const()' id='139917829882160'>
Move display shift right command
- lcd_i2c.const.LCD_NOBACKLIGHT = <Mock name='mock.const()' id='139917829882160'>
Deactivate backlight command
- lcd_i2c.const.LCD_RETURNHOME = <Mock name='mock.const()' id='139917829882160'>
Return to home position command
- lcd_i2c.const.LCD_SETCGRAMADDR = <Mock name='mock.const()' id='139917829882160'>
Set CGRAM address command
- lcd_i2c.const.LCD_SETDDRAMADDR = <Mock name='mock.const()' id='139917829882160'>
Set DDRAM address command
- lcd_i2c.const.RS = <Mock name='mock.const()' id='139917829882160'>
Register select bit
- lcd_i2c.const.RW = <Mock name='mock.const()' id='139917829882160'>
Read/Write bit