ST7789 (st7789_elixir v0.1.0) View Source

ST7789 Elixir driver

Link to this section Summary

API

Write a byte to the display as command data.

Write a byte or array of bytes to the display as display data.

Write the provided 24bit RGB888 image to the hardware.

Write the provided 16bit RGB565 image to the hardware.

New connection to an ST7789

Reset the display, if reset pin is connected.

Link to this section API

Write a byte to the display as command data.

  • self: %ST7789{}
  • cmd: command data

return: self

Write a byte or array of bytes to the display as display data.

  • self: %ST7789{}
  • data: display data

return: self

Link to this function

display(self, image_data)

View Source

Write the provided 24bit RGB888 image to the hardware.

  • self: %ST7789{}
  • image_data: Should be 24bit RGB888 format and the same dimensions (width x height x 3) as the display hardware.

return: self

Link to this function

display_565(self, image_data)

View Source

Write the provided 16bit RGB565 image to the hardware.

  • self: %ST7789{}
  • image_data: Should be 16bit RGB565 format and the same dimensions (width x height x 3) as the display hardware.

return: self

New connection to an ST7789

  • port: SPI port number

  • cs: SPI chip-select number (0 or 1 for BCM).

    Default value: kBG_SPI_CS_FRONT.

  • backlight: Pin for controlling backlight

    Default value: nil.

  • rst: Reset pin for ST7789

    Default value: nil.

  • width: Width of display connected to ST7789

    Default value: 240.

  • height: Height of display connected to ST7789

    Default value: 240.

  • offset_top: Offset to top row

    Default value: 0.

  • offset_left: Offset to left column

    Default value: 0.

  • invert: Invert display

    Default value: true.

  • speed_hz: SPI speed (in Hz)

    Default value: 400_0000.

return: %ST7789{}

Example

port = 0
dc = 9
backlight = 19
speed_hz = 80 * 1000 * 1000
disp = ST7789.new(port, dc: dc, backlight: backlight, speed_hz: speed_hz)

Reset the display, if reset pin is connected.

  • self: %ST7789{}

return: self

Link to this function

send(self, bytes, is_data, chunk_size \\ 4096)

View Source

Send bytes to the ST7789

  • self: %ST7789{}

  • bytes: The bytes to be sent to self

    • when is_integer(bytes), sent will take the 8 least-significant bits [band(bytes, 0xFF)] and send it to self
    • when is_list(bytes), bytes will be casting to bitstring and then sent to self
  • is_data:

    • true: bytes will be sent as data
    • false: bytes will be sent as commands
  • chunk_size: Indicates how many bytes will be send in a single write call

return: self

Link to this section Constants