ILI9486 (ili9486_elixir v0.1.4)
View SourceILI9486 Elixir driver
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 mode
Set frame rate
Set display pixel format
Set touch panel callback function
Get screen size
Functions
Returns a specification to start this module under a supervisor.
Closes all SPI and GPIO resources on shutdown.
API
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)
- cmd_data: cmd data to be sent.
Default value:
return: self
Write a byte or array of bytes to the display as display data.
- self:
%ILI9486{}
- data: display data
return: self
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 providedimage_data
.
return: self
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
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
. Only0
,90
,180
and270
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
: focs0b01
: focs/20b10
: focs/40b11
: 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 from0b10000
(16 clocks) to0b11111
(31 clocks), i.e., clocks increases by 1 asrtna
increasing by 1.is_high_speed: Is the high speed variant?
Default value:
false
. Settrue
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.spi_lcd: pre-opened SPI handle for the LCD bus.
Default value:
nil
. If provided, overrides:port
and:lcd_cs
.spi_touch: pre-opened SPI handle for the touch panel bus.
Default value:
nil
. If provided, overrides:port
and:touch_cs
.gpio_dc: pre-opened GPIO pin for the D/C line.
Default value:
nil
. If provided, overrides:dc
.gpio_rst: pre-opened GPIO pin for the reset line.
Default value:
nil
. If provided, overrides:rst
.
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
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 toself
when is_list(bytes)
,bytes
will be casting to bitstring and then sent toself
is_data:
true
:bytes
will be sent as datafalse
:bytes
will be sent as commands
return: self
Turn on/off display
- self:
%ILI9486{}
- status: either
:on
or:off
return: self
Set display mode
- self:
%ILI9486{}
- display_mode: Valid values:
:normal
,:partial
,:idle
return: self
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}
Set display pixel format
- self:
%ILI9486{}
- pix_fmt: one of
:bgr565
,:rgb565
, :bgr666,
:rgb666**return**:
self`
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}
Constants
Functions
Returns a specification to start this module under a supervisor.
See Supervisor
.
Closes all SPI and GPIO resources on shutdown.