ILI9486 (ili9486_elixir v0.1.1) View Source

ILI9486 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 BGR888/RGB888 image to the hardware.

Write the provided 16bit BGR565/RGB565 image to the hardware.

Write the provided 18bit BGR666/RGB666 image to the hardware.

New connection to an ILI9486

Get display pixel format

Reset the display, if reset pin is connected.

Send bytes to the ILI9486

Turn on/off display

Set display pixel format

Set touch panel callback function

Get screen size

Functions

Returns a specification to start this module under a supervisor.

Link to this section API

Link to this function

command(self_pid, cmd, opts \\ [])

View Source

Write a byte to the display as command data.

  • self: %ILI9486{}
  • cmd: command data
  • opts:
    • cmd_data: cmd data to be sent. Default value: []. (no data will be sent)
    • delay: wait delay ms after the cmd data is sent Default value: 0. (no wait)

return: self

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

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

return: self

Link to this function

display(self_pid, image_data, source_color)

View Source

Write the provided 24bit BGR888/RGB888 image to the hardware.

  • self: %ILI9486{}
  • image_data: Should be 24bit format and the same dimensions (width x height x 3) as the display hardware.
  • pix_fmt: Either :rgb888 or :bgr888. Indicates the channel order of the provided image_data.

return: self

Link to this function

display_565(self_pid, image_data)

View Source

Write the provided 16bit BGR565/RGB565 image to the hardware.

  • self: %ILI9486{}
  • image_data: Should be 16bit BGR565/RGB565 format (same channel order as in self) and the same dimensions (width x height x 3) as the display hardware.

return: self

Link to this function

display_666(self_pid, image_data)

View Source

Write the provided 18bit BGR666/RGB666 image to the hardware.

  • self: %ILI9486{}
  • image_data: Should be 18bit BGR666/RGB666 format (same channel order as in self) and the same dimensions (width x height x 3) as the display hardware.

return: self

New connection to an ILI9486

  • port: SPI port number

    Default value: 0

  • lcd_cs: LCD chip-selection number

    Default value: 0.

  • touch_cs: (Optional) Touch panel chip-selection number

    Default value: nil.

  • touch_irq: (Optional) Touch panel interrupt. Low level while the Touch Panel detects touching

    Default value: nil.

  • touch_speed_hz: SPI Speed for the touch panel

    Default value: 50000.

  • dc: Command/data register selection

    Default value: 24.

  • rst: Reset pin for ILI9486

    Default value: nil.

  • width: Width of display connected to ILI9486

    Default value: 480.

  • height: Height of display connected to ILI9486

    Default value: 320.

  • offset_top: Offset to top row

    Default value: 0.

  • offset_left: Offset to left column

    Default value: 0.

  • speed_hz: SPI speed (in Hz)

    Default value: 16_000_000.

  • pix_fmt: either :bgr565, :rgb565, :bgr666 or :rgb666

    Default value: :bgr565.

  • rotation: Screen rotation.

    Default value: 90. Only 0, 90, 180 and 270 are valid.

  • mad_mode: MAD mode.

    Default value: :right_down. Valid values: :right_down, :right_up and :rgb_mode

  • display_mode: Display mode.

    Default value: :normal. Enters normal display mode after initialization.

  • frame_rate: Frame rate.

    Default value: 70. Valid frame rate should be one of the following:

    • 28
    • 30
    • 32
    • 34
    • 36
    • 39
    • 42
    • 46
    • 50
    • 56
    • 62
    • 70
    • 81
    • 96
    • 117
  • diva: Division ratio for internal clocks.

    Default value: 0b00.

    • 0b00: focs
    • 0b01: focs/2
    • 0b10: focs/4
    • 0b11: focs/8
  • rtna: RTNA[4:0] is used to set 1H (line) period of Normal mode at CPU interface.

    Default value: 0b10001. Valid value starts from 0b10000 (16 clocks) to 0b11111 (31 clocks), i.e., clocks increases by 1 as rtna increasing by 1.

  • is_high_speed: Is the high speed variant?

    Default value: false. Set true to make it compatible with the high speed variant. (125MHz SPI).

  • chunk_size: batch transfer size.

    Default value: 4096 for the lo-speed variant. 0x8000 for the hi-speed variant.

return: %ILI9486{}

Example

# default
# assuming LCD device at /dev/spidev0.0
# DC connects to PIN 24
# RST not connected
# SPI speed: 16MHz
# Pixel Format: BGR565
{:ok, disp} = ILI9486.new()
# default with touch panel
# DC connects to PIN 24
# RST connects to PIN 25
# SPI speed: 16MHz
# Pixel Format: RGB666 (for demo only, not necessary)
# Touch panel device at /dev/spidev0.1
# Touch panel IRQ PIN 17
{:ok, disp} = ILI9486.new(,
  speed_hz: 16_000_000,
  pix_fmt: :bgr666,
  rst: 25,
  touch_cs: 1,
  touch_irq: 17
)

high-speed variant (125MHz SPI)

# assuming LCD device at /dev/spidev0.0
# DC connects to PIN 24
# RST connects to PIN 25 (for demo only, not necessary)
# SPI speed: 125MHz
# Pixel Format: BGR666 (for demo only, not necessary)
{:ok, disp} = ILI9486.new(,
  is_high_speed: true,
  speed_hz: 125_000_000,
  pix_fmt: :bgr666,
  rst: 25
)

high-speed variant (125MHz SPI) with touch panel

# assuming LCD device at /dev/spidev0.0
# DC connects to PIN 24
# RST connects to PIN 25 (for demo only, not necessary)
# SPI speed: 125MHz
# Pixel Format: BGR666 (for demo only, not necessary)
# Touch panel device at /dev/spidev0.1
# Touch panel IRQ PIN 17
{:ok, disp} = ILI9486.new(,
  is_high_speed: true,
  speed_hz: 125_000_000,
  pix_fmt: :bgr666,
  rst: 25,
  touch_cs: 1,
  touch_irq: 17
)

Get display pixel format

  • self: %ILI9486{}

return: one of :bgr565, :rgb565, :bgr666, :rgb666

Reset the display, if reset pin is connected.

  • self: %ILI9486{}

return: self

Link to this function

send(self_pid, bytes, is_data)

View Source

Send bytes to the ILI9486

  • self: %ILI9486{}

  • 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

return: self

Link to this function

set_display(self_pid, status)

View Source

Turn on/off display

  • self: %ILI9486{}
  • status: either :on or :off

return: self

Link to this function

set_display_mode(self_pid, display_mode)

View Source

Set display mode

  • self: %ILI9486{}
  • display_mode: Valid values: :normal, :partial, :idle

return: self

Link to this function

set_frame_rate(self_pid, frame_rate)

View Source

Set frame rate

  • self: %ILI9486{}
  • frame_rate: Valid value should be one of the following
    • 28
    • 30
    • 32
    • 34
    • 36
    • 39
    • 42
    • 46
    • 50
    • 56
    • 62
    • 70
    • 81
    • 96
    • 117

return: :ok | {:error, reason}

Link to this function

set_pix_fmt(self_pid, pix_fmt)

View Source

Set display pixel format

  • self: %ILI9486{}
  • pix_fmt: one of :bgr565, :rgb565, :bgr666,:rgb666**return**:self`
Link to this function

set_touch_callback(self_pid, callback)

View Source

Set touch panel callback function

  • self: %ILI9486{}
  • callback: callback function. 3 arguments: pin, timestamp, status

Get screen size

  • self: %ILI9486{}

return: %{height: height, width: width}

Link to this section Constants

Link to this section Functions

Returns a specification to start this module under a supervisor.

See Supervisor.