lcd.gpio#

Description#

Plugin to write to an LCD display connected via GPIO.

Configuration#

lcd.gpio:
  # [Required]
  # Pin for register select (RS).
  pin_rs:   # type=int

  # [Required]
  # Pin to start data read or write (E).
  pin_e:   # type=int

  # [Required]
  # List of data bus pins in 8 bit mode (DB0-DB7) or in 4
  # bit mode (DB4-DB7) in ascending order.
  pins_data:   # type=List[int]

  # [Optional]
  # Pin for selecting read or write mode (R/W). Default:
  # ``None``, read only mode.
  # pin_rw:   # type=Optional[int]

  # [Optional]
  # Which scheme to use for numbering of the GPIO pins,
  # either ``BOARD`` or ``BCM``. Default: ``BOARD``.
  # pin_mode: BOARD  # type=str

  # [Optional]
  # Pin for controlling backlight on/off. Set this to
  # ``None`` for no backlight control. Default: ``None``.
  # pin_backlight:   # type=Optional[int]

  # [Optional]
  # Number of columns per row (usually 16 or 20). Default: ``16``.
  # cols: 16  # type=int

  # [Optional]
  # Number of display rows (usually 1, 2 or 4). Default: ``2``.
  # rows: 2  # type=int

  # [Optional]
  # Whether the backlight is enabled initially.
  # Default: ``True``. Has no effect if pin_backlight is ``None``
  # backlight_enabled: True  # type=bool

  # [Optional]
  # Set this to either ``active_high`` or ``active_low``
  # to configure the operating control for the backlight. Has no effect if
  # pin_backlight is ``None``
  # backlight_mode: active_low  # type=str

  # [Optional]
  # Some 1 line displays allow a font height of 10px.
  # Allowed: ``8`` or ``10``. Default: ``8``.
  # dotsize: 8  # type=int

  # [Optional]
  # The character map used. Depends on your LCD. This must
  # be either ``A00`` or ``A02`` or ``ST0B``. Default: ``A02``.
  # charmap: A02  # type=str

  # [Optional]
  # Whether or not to automatically insert line
  # breaks. Default: ``True``.
  # auto_linebreaks: True  # type=bool

  # [Optional]
  # Whether to run additional checks to support older LCDs
  # that may not run at the reference clock (or keep up with it).
  # Default: ``False``.
  # compat_mode: False  # type=bool

Dependencies#

pip

pip install RPi.GPIO RPLCD

Actions#

Module reference#

class platypush.plugins.lcd.gpio.LcdGpioPlugin(pin_rs: int, pin_e: int, pins_data: List[int], pin_rw: int | None = None, pin_mode: str = 'BOARD', pin_backlight: int | None = None, cols: int = 16, rows: int = 2, backlight_enabled: bool = True, backlight_mode: str = 'active_low', dotsize: int = 8, charmap: str = 'A02', auto_linebreaks: bool = True, compat_mode: bool = False, **kwargs)[source]#

Bases: LcdPlugin

Plugin to write to an LCD display connected via GPIO.

__init__(pin_rs: int, pin_e: int, pins_data: List[int], pin_rw: int | None = None, pin_mode: str = 'BOARD', pin_backlight: int | None = None, cols: int = 16, rows: int = 2, backlight_enabled: bool = True, backlight_mode: str = 'active_low', dotsize: int = 8, charmap: str = 'A02', auto_linebreaks: bool = True, compat_mode: bool = False, **kwargs)[source]#
Parameters:
  • pin_rs – Pin for register select (RS).

  • pin_e – Pin to start data read or write (E).

  • pins_data – List of data bus pins in 8 bit mode (DB0-DB7) or in 4 bit mode (DB4-DB7) in ascending order.

  • pin_mode – Which scheme to use for numbering of the GPIO pins, either BOARD or BCM. Default: BOARD.

  • pin_rw – Pin for selecting read or write mode (R/W). Default: None, read only mode.

  • pin_backlight – Pin for controlling backlight on/off. Set this to None for no backlight control. Default: None.

  • cols – Number of columns per row (usually 16 or 20). Default: 16.

  • rows – Number of display rows (usually 1, 2 or 4). Default: 2.

  • backlight_enabled – Whether the backlight is enabled initially. Default: True. Has no effect if pin_backlight is None

  • backlight_mode – Set this to either active_high or active_low to configure the operating control for the backlight. Has no effect if pin_backlight is None

  • dotsize – Some 1 line displays allow a font height of 10px. Allowed: 8 or 10. Default: 8.

  • charmap – The character map used. Depends on your LCD. This must be either A00 or A02 or ST0B. Default: A02.

  • auto_linebreaks – Whether or not to automatically insert line breaks. Default: True.

  • compat_mode – Whether to run additional checks to support older LCDs that may not run at the reference clock (or keep up with it). Default: False.

clear()#

Clear the LCD display.

close(clear: bool = False)#

Close the handler to the LCD display and release the GPIO resources.

Parameters:

clear – Clear the display as well on close (default: False).

command(value: int)#

Send a raw command to the LCD.

Parameters:

value – Command to be sent.

cr()#

Write a carriage return (\r) character to the LCD.

create_char(location: int, bitmap: List[int])#

Create a new character. The HD44780 supports up to 8 custom characters (location 0-7).

Parameters:
  • location – The place in memory where the character is stored. Values need to be integers between 0 and 7.

  • bitmap – The bitmap containing the character. This should be a list of 8 numbers, each representing a 5 pixel row.

Example for the smiley character:

[
    0,   # 0b00000
    10,  # 0b01010
    10,  # 0b01010
    0,   # 0b00000
    17,  # 0b10001
    17,  # 0b10001
    14,  # 0b01110
    0    # 0b00000
]
crlf()#

Write a carriage return + line feed (\r\n) sequence to the LCD.

disable_backlight()#

Disable the display backlight.

disable_display()#

Turn off the display.

enable_backlight()#

Enable the display backlight.

enable_display()#

Turn on the display.

home()#

Set cursor to initial position and reset any shifting.

lf()#

Write a line feed (\n) character to the LCD.

set_cursor_pos(position: List[int])#

Change the position of the cursor on the display.

Parameters:

position – New cursor position, as a list of two elements.

set_text_align(mode: str)#

Change the text align mode.

Parameters:

mode – Supported values: left, right.

shift_display(amount: int)#

Set cursor to initial position and reset any shifting.

toggle_backlight()#

Toggle the display backlight on/off.

toggle_display()#

Toggle the display state.

write(value: int)#

Write a raw byte to the LCD.

Parameters:

value – Byte to be sent.

write_string(value: str, position: List[int] | None = None)#

Write a string to the display.

Parameters:
  • value – String to be displayed.

  • position – String position on the display as a 2-int list.