Microchip® Advanced Software Framework

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Display - ILI9488 Controller

Low-level driver for the ILI9488 LCD controller.

This driver provides access to the main features of the ILI9488 controller.

Modules

 

Macros

#define LCD_DATA_CACHE_SIZE   ILI9488_LCD_WIDTH
 

Functions

static void ili9488_check_box_coordinates (uint32_t *p_ul_x1, uint32_t *p_ul_y1, uint32_t *p_ul_x2, uint32_t *p_ul_y2)
 Check box coordinates. More...
 
void ili9488_copy_pixels_from_screen (uint16_t *pixels, uint32_t count)
 Copy pixels from the screen to a pixel buffer. More...
 
void ili9488_copy_pixels_to_screen (const uint16_t *pixels, uint32_t count)
 Copy pixels from SRAM to the screen. More...
 
void ili9488_delay (uint32_t ul_ms)
 Delay function. More...
 
void ili9488_display_off (void)
 Turn off the LCD. More...
 
void ili9488_display_on (void)
 Turn on the LCD. More...
 
static void ili9488_draw_char (uint32_t ul_x, uint32_t ul_y, uint8_t uc_c)
 Draw an ASCII character on LCD. More...
 
uint32_t ili9488_draw_circle (uint32_t ul_x, uint32_t ul_y, uint32_t ul_r)
 Draw a circle on LCD. More...
 
uint32_t ili9488_draw_filled_circle (uint32_t ul_x, uint32_t ul_y, uint32_t ul_r)
 Draw a filled circle on LCD. More...
 
void ili9488_draw_filled_rectangle (uint32_t ul_x1, uint32_t ul_y1, uint32_t ul_x2, uint32_t ul_y2)
 Draw a filled rectangle on LCD. More...
 
void ili9488_draw_line (uint32_t ul_x1, uint32_t ul_y1, uint32_t ul_x2, uint32_t ul_y2)
 Draw a line on LCD. More...
 
static void ili9488_draw_line_bresenham (uint32_t ul_x1, uint32_t ul_y1, uint32_t ul_x2, uint32_t ul_y2)
 Draw a line on LCD, which is not horizontal or vertical. More...
 
uint32_t ili9488_draw_pixel (uint32_t ul_x, uint32_t ul_y)
 Draw a pixel on LCD. More...
 
void ili9488_draw_pixmap (uint32_t ul_x, uint32_t ul_y, uint32_t ul_width, uint32_t ul_height, const ili9488_color_t *p_ul_pixmap)
 Draw a pixmap on LCD. More...
 
void ili9488_draw_prepare (uint32_t ul_x, uint32_t ul_y, uint32_t ul_width, uint32_t ul_height)
 Prepare LCD to draw. More...
 
void ili9488_draw_rectangle (uint32_t ul_x1, uint32_t ul_y1, uint32_t ul_x2, uint32_t ul_y2)
 Draw a rectangle on LCD. More...
 
void ili9488_draw_string (uint32_t ul_x, uint32_t ul_y, const uint8_t *p_str)
 Draw a string on LCD. More...
 
void ili9488_duplicate_pixel (const uint16_t color, uint32_t count)
 Set a given number of pixels to the same color. More...
 
void ili9488_fill (ili9488_color_t ul_color)
 Fill the LCD buffer with the specified color. More...
 
ili9488_color_t ili9488_get_pixel (uint32_t ul_x, uint32_t ul_y)
 Get a pixel from LCD. More...
 
uint32_t ili9488_init (struct ili9488_opt_t *p_opt)
 Initialize the ILI9488 lcd driver. More...
 
static uint32_t ili9488_read_chipid (void)
 Read chipid. More...
 
uint16_t ili9488_read_gram (void)
 Read a single color from the graphical memory. More...
 
static uint32_t ili9488_read_ram (void)
 Read data to LCD GRAM. More...
 
void ili9488_scroll (uint16_t ul_tfa, uint16_t ul_vsa, uint16_t ul_bfa)
 Scroll up/down for the number of specified lines. More...
 
void ili9488_set_bottom_right_limit (ili9488_coord_t x, ili9488_coord_t y)
 Set the display bottom right drawing limit. More...
 
void ili9488_set_cursor_position (uint16_t x, uint16_t y)
 Set cursor of LCD screen. More...
 
void ili9488_set_display_direction (enum ili9488_display_direction direction)
 ILI9488 configure landscape. More...
 
void ili9488_set_foreground_color (uint32_t ul_color)
 Set foreground color. More...
 
void ili9488_set_limits (ili9488_coord_t start_x, ili9488_coord_t start_y, ili9488_coord_t end_x, ili9488_coord_t end_y)
 Set the full display drawing limits. More...
 
void ili9488_set_orientation (uint8_t flags)
 Sets the orientation of the display data. More...
 
void ili9488_set_scroll_address (uint16_t ul_vsp)
 Enable the scrolling feature. More...
 
void ili9488_set_top_left_limit (ili9488_coord_t x, ili9488_coord_t y)
 Set the display top left drawing limit. More...
 
void ili9488_set_window (uint16_t x, uint16_t y, uint16_t width, uint16_t height)
 ILI9488 configure window. More...
 
void ili9488_write_brightness (uint16_t us_value)
 Set display brightness. More...
 
void ili9488_write_gram (uint16_t color)
 Write the graphical memory with a single color pixel. More...
 
static void ili9488_write_ram (ili9488_color_t ul_color)
 Write data to LCD GRAM. More...
 
static void ili9488_write_ram_buffer (const ili9488_color_t *p_ul_buf, uint32_t ul_size)
 Write multiple data in buffer to LCD controller. More...
 
static void ili9488_write_ram_prepare (void)
 Prepare to write GRAM data. More...
 
static void ili9488_write_register (uint8_t uc_reg, const ili9488_color_t *us_data, uint32_t size)
 Write data to LCD Register. More...
 

Variables

static ili9488_color_t g_ul_pixel_cache [LCD_DATA_CACHE_SIZE *LCD_DATA_COLOR_UNIT]
 
struct ili9488_font gfont = {10, 14}
 
static ili9488_coord_t limit_end_x
 
static ili9488_coord_t limit_end_y
 
static ili9488_coord_t limit_start_x
 
static ili9488_coord_t limit_start_y
 
const uint8_t p_uc_charset10x14 []
 Character set table for font 10x14 Coding format: Char height is 14 bits, which is coded using 2 bytes per column (2 unused bits). More...
 

#define LCD_DATA_CACHE_SIZE   ILI9488_LCD_WIDTH

static void ili9488_check_box_coordinates ( uint32_t *  p_ul_x1,
uint32_t *  p_ul_y1,
uint32_t *  p_ul_x2,
uint32_t *  p_ul_y2 
)
static

Check box coordinates.

Parameters
p_ul_x1X coordinate of upper-left corner on LCD.
p_ul_y1Y coordinate of upper-left corner on LCD.
p_ul_x2X coordinate of lower-right corner on LCD.
p_ul_y2Y coordinate of lower-right corner on LCD.

References ILI9488_LCD_HEIGHT, and ILI9488_LCD_WIDTH.

Referenced by ili9488_draw_filled_rectangle(), ili9488_draw_pixmap(), and ili9488_draw_rectangle().

void ili9488_copy_pixels_from_screen ( uint16_t *  pixels,
uint32_t  count 
)

Copy pixels from the screen to a pixel buffer.

Use this function to copy pixels from the display to an internal SRAM buffer.

Limits have to be set prior to calling this function, e.g.:

Parameters
pixelsPointer to the pixel buffer to read to
countNumber of pixels to read

References ILI9488_CMD_MEMORY_READ, ILI9488_COLOR, ili9488_set_window(), ili9488_write_register(), pio_set(), pio_set_pin_high(), and spi_read_packet().

void ili9488_copy_pixels_to_screen ( const uint16_t *  pixels,
uint32_t  count 
)

Copy pixels from SRAM to the screen.

Used to copy a large quantitative of data to the screen in one go.

Limits have to be set prior to calling this function, e.g.:

Parameters
pixelsPointer to the pixel data
countNumber of pixels to copy to the screen

References ILI9488_CMD_MEMORY_WRITE, ili9488_set_window(), ili9488_write_ram(), ili9488_write_ram_prepare(), ili9488_write_register(), LCD_DATA_COLOR_UNIT, and RGB_16_TO_18BIT.

void ili9488_delay ( uint32_t  ul_ms)

Delay function.

Referenced by ili9488_init().

void ili9488_display_off ( void  )

Turn off the LCD.

References ILI9488_CMD_DISPLAY_OFF, and ili9488_write_register().

void ili9488_display_on ( void  )

Turn on the LCD.

References ILI9488_CMD_DISPLAY_ON, and ili9488_write_register().

Referenced by gfx_ili9488_init(), and ili9488_init().

static void ili9488_draw_char ( uint32_t  ul_x,
uint32_t  ul_y,
uint8_t  uc_c 
)
static

Draw an ASCII character on LCD.

Parameters
ul_xX coordinate of character upper-left corner.
ul_yY coordinate of character upper-left corner.
uc_ccharacter to print.

References ili9488_draw_pixel().

Referenced by ili9488_draw_string().

uint32_t ili9488_draw_circle ( uint32_t  ul_x,
uint32_t  ul_y,
uint32_t  ul_r 
)

Draw a circle on LCD.

Parameters
ul_xX coordinate of circle center.
ul_yY coordinate of circle center.
ul_rcircle radius.
Returns
0 if succeeds, otherwise fails.

References ili9488_draw_pixel().

Referenced by main().

uint32_t ili9488_draw_filled_circle ( uint32_t  ul_x,
uint32_t  ul_y,
uint32_t  ul_r 
)

Draw a filled circle on LCD.

Parameters
ul_xX coordinate of circle center.
ul_yY coordinate of circle center.
ul_rcircle radius.
Returns
0 if succeeds, otherwise fails.

References ili9488_draw_filled_rectangle().

void ili9488_draw_filled_rectangle ( uint32_t  ul_x1,
uint32_t  ul_y1,
uint32_t  ul_x2,
uint32_t  ul_y2 
)

Draw a filled rectangle on LCD.

Parameters
ul_x1X coordinate of upper-left corner on LCD.
ul_y1Y coordinate of upper-left corner on LCD.
ul_x2X coordinate of lower-right corner on LCD.
ul_y2Y coordinate of lower-right corner on LCD.

References ili9488_check_box_coordinates(), ILI9488_LCD_HEIGHT, ILI9488_LCD_WIDTH, ili9488_set_window(), ili9488_write_ram_buffer(), ili9488_write_ram_prepare(), LCD_DATA_CACHE_SIZE, and LCD_DATA_COLOR_UNIT.

Referenced by ili9488_draw_filled_circle(), ili9488_draw_line(), ili9488_draw_rectangle(), main(), and refresh_display().

void ili9488_draw_line ( uint32_t  ul_x1,
uint32_t  ul_y1,
uint32_t  ul_x2,
uint32_t  ul_y2 
)

Draw a line on LCD.

Parameters
ul_x1X coordinate of line start.
ul_y1Y coordinate of line start.
ul_x2X coordinate of line end.
ul_y2Y coordinate of line end.

References ili9488_draw_filled_rectangle(), and ili9488_draw_line_bresenham().

Referenced by main().

static void ili9488_draw_line_bresenham ( uint32_t  ul_x1,
uint32_t  ul_y1,
uint32_t  ul_x2,
uint32_t  ul_y2 
)
static

Draw a line on LCD, which is not horizontal or vertical.

Parameters
ul_x1X coordinate of line start.
ul_y1Y coordinate of line start.
ul_x2X coordinate of line end.
ul_y2Y coordinate of line endl.

References ili9488_draw_pixel().

Referenced by ili9488_draw_line().

uint32_t ili9488_draw_pixel ( uint32_t  ul_x,
uint32_t  ul_y 
)

Draw a pixel on LCD.

Parameters
ul_xX coordinate of pixel.
ul_yY coordinate of pixel.
Returns
0 if succeeds, otherwise fails.

References ILI9488_LCD_HEIGHT, ILI9488_LCD_WIDTH, ili9488_set_cursor_position(), ili9488_write_ram_buffer(), ili9488_write_ram_prepare(), and LCD_DATA_COLOR_UNIT.

Referenced by ili9488_draw_char(), ili9488_draw_circle(), ili9488_draw_line_bresenham(), and ili9488_draw_number().

void ili9488_draw_pixmap ( uint32_t  ul_x,
uint32_t  ul_y,
uint32_t  ul_width,
uint32_t  ul_height,
const ili9488_color_t p_ul_pixmap 
)

Draw a pixmap on LCD.

Parameters
ul_xX coordinate of upper-left corner on LCD.
ul_yY coordinate of upper-left corner on LCD.
ul_widthwidth of the picture.
ul_heightheight of the picture.
p_ul_pixmappixmap of the image.

References ili9488_check_box_coordinates(), ILI9488_CMD_MEMORY_WRITE, ILI9488_LCD_HEIGHT, ILI9488_LCD_WIDTH, ili9488_set_window(), ili9488_write_register(), and LCD_DATA_COLOR_UNIT.

Referenced by main(), and refresh_display().

void ili9488_draw_prepare ( uint32_t  ul_x,
uint32_t  ul_y,
uint32_t  ul_width,
uint32_t  ul_height 
)

Prepare LCD to draw.

Parameters
ul_xHorizontal address start position
ul_yVertical address start position
ul_widthThe width of the window.
ul_heightThe height of the window.

References ili9488_set_cursor_position(), ili9488_set_window(), and ili9488_write_ram_prepare().

void ili9488_draw_rectangle ( uint32_t  ul_x1,
uint32_t  ul_y1,
uint32_t  ul_x2,
uint32_t  ul_y2 
)

Draw a rectangle on LCD.

Parameters
ul_x1X coordinate of upper-left corner on LCD.
ul_y1Y coordinate of upper-left corner on LCD.
ul_x2X coordinate of lower-right corner on LCD.
ul_y2Y coordinate of lower-right corner on LCD.

References ili9488_check_box_coordinates(), and ili9488_draw_filled_rectangle().

void ili9488_draw_string ( uint32_t  ul_x,
uint32_t  ul_y,
const uint8_t *  p_str 
)

Draw a string on LCD.

Parameters
ul_xX coordinate of string top-left corner.
ul_yY coordinate of string top-left corner.
p_strString to display.

References ili9488_font::height, ili9488_draw_char(), and ili9488_font::width.

Referenced by main(), refresh_display(), and wifi_connect().

void ili9488_duplicate_pixel ( const uint16_t  color,
uint32_t  count 
)

Set a given number of pixels to the same color.

Use this function to write a certain number of pixels to the same color within a set limit.

Limits have to be set prior to calling this function, e.g.:

Parameters
colorThe color to write to the display
countThe number of pixels to write with this color

References ili9488_set_window(), ili9488_write_ram(), ili9488_write_ram_prepare(), and RGB_16_TO_18BIT.

void ili9488_fill ( ili9488_color_t  ul_color)

Fill the LCD buffer with the specified color.

Parameters
ul_colorfill color.

References ILI9488_LCD_HEIGHT, ILI9488_LCD_WIDTH, ili9488_set_cursor_position(), ili9488_write_ram(), and ili9488_write_ram_prepare().

ili9488_color_t ili9488_get_pixel ( uint32_t  ul_x,
uint32_t  ul_y 
)

Get a pixel from LCD.

Parameters
ul_xX coordinate of pixel.
ul_yY coordinate of pixel.
Returns
the pixel color.

References Assert, ILI9488_LCD_HEIGHT, ILI9488_LCD_WIDTH, ili9488_read_ram(), and ili9488_set_cursor_position().

uint32_t ili9488_init ( struct ili9488_opt_t p_opt)
static uint32_t ili9488_read_chipid ( void  )
static
uint16_t ili9488_read_gram ( void  )

Read a single color from the graphical memory.

Use this function to read a color from the graphical memory of the controller.

Limits have to be set prior to calling this function, e.g.:

Return values
ili9488_color_tThe read color pixel

References ili9488_read_ram(), and ili9488_set_cursor_position().

Referenced by gfx_ili9488_get_pixel().

static uint32_t ili9488_read_ram ( void  )
static

Read data to LCD GRAM.

Note
Because pixel data LCD GRAM is 18-bits, so convertion to RGB565 16-bits will cause low color bit lose.
Returns
color 16-bits RGB color.

References ILI9488_CMD_MEMORY_READ, ILI9488_COLOR, ili9488_write_register(), pio_set_pin_high(), and spi_read_packet().

Referenced by ili9488_get_pixel(), and ili9488_read_gram().

void ili9488_scroll ( uint16_t  ul_tfa,
uint16_t  ul_vsa,
uint16_t  ul_bfa 
)

Scroll up/down for the number of specified lines.

Parameters
ul_tfaTop Fixed Area in number of lines from the top of the frame memory.
ul_linesnumber of lines to scroll.
ul_bfabottom Fixed Area in number of lines from the bottom of the frame memory.

References get_0b_to_8b, get_8b_to_16b, ILI9488_CMD_VERT_SCROLL_DEFINITION, and ili9488_write_register().

void ili9488_set_bottom_right_limit ( ili9488_coord_t  x,
ili9488_coord_t  y 
)

Set the display bottom right drawing limit.

Use this function to set the bottom right corner of the drawing limit box.

Parameters
xThe x coordinate of the bottom right corner
yThe y coordinate of the bottom right corner
void ili9488_set_cursor_position ( uint16_t  x,
uint16_t  y 
)

Set cursor of LCD screen.

Parameters
xX coordinate of upper-left corner on LCD.
yY coordinate of upper-left corner on LCD.

References get_0b_to_8b, get_8b_to_16b, ILI9488_CMD_COLUMN_ADDRESS_SET, ILI9488_CMD_NOP, ILI9488_CMD_PAGE_ADDRESS_SET, and ili9488_write_register().

Referenced by ili9488_draw_pixel(), ili9488_draw_prepare(), ili9488_fill(), ili9488_get_pixel(), ili9488_init(), ili9488_read_gram(), and ili9488_write_gram().

void ili9488_set_display_direction ( enum ili9488_display_direction  direction)

ILI9488 configure landscape.

LandscaprMode Landscape Mode.

References ILI9488_CMD_MEMORY_ACCESS_CONTROL, and ili9488_write_register().

Referenced by ili9488_init().

void ili9488_set_foreground_color ( uint32_t  ul_color)

Set foreground color.

Parameters
ul_colorforeground color.

References LCD_DATA_CACHE_SIZE, and LCD_DATA_COLOR_UNIT.

Referenced by ili9488_init(), main(), refresh_display(), and wifi_connect().

void ili9488_set_limits ( ili9488_coord_t  start_x,
ili9488_coord_t  start_y,
ili9488_coord_t  end_x,
ili9488_coord_t  end_y 
)

Set the full display drawing limits.

Use this function to set the full drawing limit box.

Parameters
start_xThe x coordinate of the top left corner
start_yThe y coordinate of the top left corner
end_xThe x coordinate of the bottom right corner
end_yThe y coordinate of the bottom right corner
void ili9488_set_orientation ( uint8_t  flags)

Sets the orientation of the display data.

Configures the display for a given orientation, including mirroring and/or screen rotation.

Parameters
flagsOrientation flags to use, see ILI9488_FLIP_X, ILI9488_FLIP_Y and ILI9488_SWITCH_XY.

References ILI9488_CMD_MEMORY_ACCESS_CONTROL, ILI9488_FLIP_X, ILI9488_FLIP_Y, ILI9488_SWITCH_XY, and ili9488_write_register().

Referenced by gfx_ili9488_set_orientation().

void ili9488_set_scroll_address ( uint16_t  ul_vsp)

Enable the scrolling feature.

Parameters
ul_vspVertical Scrolling Start Address

References get_0b_to_8b, get_8b_to_16b, ILI9488_CMD_VERT_SCROLL_START_ADDRESS, and ili9488_write_register().

void ili9488_set_top_left_limit ( ili9488_coord_t  x,
ili9488_coord_t  y 
)

Set the display top left drawing limit.

Use this function to set the top left limit of the drawing limit box.

Parameters
xThe x coordinate of the top left corner
yThe y coordinate of the top left corner
void ili9488_set_window ( uint16_t  x,
uint16_t  y,
uint16_t  width,
uint16_t  height 
)
void ili9488_write_brightness ( uint16_t  us_value)

Set display brightness.

Configures the display for a given brightness value

Parameters
us_valuebrightness value need to written.

References ILI9488_CMD_WRITE_DISPLAY_BRIGHTNESS, and ili9488_write_register().

void ili9488_write_gram ( uint16_t  color)

Write the graphical memory with a single color pixel.

Use this function to write a single color pixel to the controller memory.

Limits have to be set prior to calling this function, e.g.:

Parameters
colorThe color pixel to write to the screen

References ili9488_set_cursor_position(), ili9488_write_ram(), ili9488_write_ram_prepare(), and RGB_16_TO_18BIT.

Referenced by gfx_ili9488_draw_line_pixel(), and gfx_ili9488_draw_pixel().

static void ili9488_write_ram ( ili9488_color_t  ul_color)
static

Write data to LCD GRAM.

Parameters
ul_color16-bits RGB color.

References pio_set_pin_high(), and spi_write().

Referenced by ili9488_copy_pixels_to_screen(), ili9488_duplicate_pixel(), ili9488_fill(), and ili9488_write_gram().

static void ili9488_write_ram_buffer ( const ili9488_color_t p_ul_buf,
uint32_t  ul_size 
)
static

Write multiple data in buffer to LCD controller.

Parameters
p_ul_bufdata buffer.
ul_sizesize in pixels.

References pio_set_pin_high(), and spi_write_packet().

Referenced by ili9488_draw_filled_rectangle(), and ili9488_draw_pixel().

static void ili9488_write_register ( uint8_t  uc_reg,
const ili9488_color_t us_data,
uint32_t  size 
)
static

struct ili9488_font gfont = {10, 14}
ili9488_coord_t limit_end_x
static
ili9488_coord_t limit_end_y
static
ili9488_coord_t limit_start_x
static
ili9488_coord_t limit_start_y
static
const uint8_t p_uc_charset10x14[]

Character set table for font 10x14 Coding format: Char height is 14 bits, which is coded using 2 bytes per column (2 unused bits).

Char width is 10 bits.