Low-level driver for the HX8347A LCD controller.
This driver provides access to the main features of the HX8347A controller.
Macros | |
#define | LCD_DATA_CACHE_SIZE HX8347A_LCD_WIDTH |
Functions | |
static void | hx8347a_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... | |
static void | hx8347a_delay (uint32_t ul_ms) |
Delay function. More... | |
void | hx8347a_disable_scroll (void) |
Disables the scrolling. More... | |
void | hx8347a_display_off (void) |
Turn off the LCD. More... | |
void | hx8347a_display_on (void) |
Turn on the LCD. More... | |
static void | hx8347a_draw_char (uint32_t ul_x, uint32_t ul_y, uint8_t uc_c) |
Draw an ASCII character on LCD. More... | |
uint32_t | hx8347a_draw_circle (uint32_t ul_x, uint32_t ul_y, uint32_t ul_r) |
Draw a circle on LCD. More... | |
uint32_t | hx8347a_draw_filled_circle (uint32_t ul_x, uint32_t ul_y, uint32_t ul_r) |
Draw a filled circle on LCD. More... | |
void | hx8347a_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 | hx8347a_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 | hx8347a_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 | hx8347a_draw_pixel (uint32_t ul_x, uint32_t ul_y) |
Draw a pixel on LCD. More... | |
void | hx8347a_draw_pixmap (uint32_t ul_x, uint32_t ul_y, uint32_t ul_width, uint32_t ul_height, const hx8347a_color_t *p_ul_pixmap) |
Draw a pixmap on LCD. More... | |
void | hx8347a_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 | hx8347a_draw_string (uint32_t ul_x, uint32_t ul_y, const uint8_t *p_str) |
Draw a string on LCD. More... | |
void | hx8347a_enable_scroll (void) |
Enables the scrolling feature. More... | |
void | hx8347a_fill (hx8347a_color_t us_color) |
Fill the LCD buffer with the specified color. More... | |
hx8347a_color_t | hx8347a_get_pixel (uint32_t ul_x, uint32_t ul_y) |
Get a pixel from LCD. More... | |
uint32_t | hx8347a_init (struct hx8347a_opt_t *p_opt) |
Initialize the HX8347A lcd driver. More... | |
static hx8347a_color_t | hx8347a_read_ram (void) |
Read data to LCD GRAM. More... | |
static void | hx8347a_read_ram_prepare (void) |
Prepare to read GRAM data. More... | |
static uint16_t | hx8347a_read_register (uint8_t uc_reg) |
Read data from LCD Register. More... | |
void | hx8347a_scroll (int32_t ul_lines) |
Scroll up/down for the number of specified lines. More... | |
void | hx8347a_set_cursor_position (uint16_t us_x, uint16_t us_y) |
Set cursor of LCD screen. More... | |
void | hx8347a_set_display_direction (display_direction_t dd) |
Set display direction. More... | |
void | hx8347a_set_foreground_color (hx8347a_color_t us_color) |
Set foreground color. More... | |
void | hx8347a_set_window (uint32_t ul_x, uint32_t ul_y, uint32_t ul_width, uint32_t ul_height) |
Set display window. More... | |
static void | hx8347a_write_ram (hx8347a_color_t us_color) |
Write data to LCD GRAM. More... | |
static void | hx8347a_write_ram_buffer (const hx8347a_color_t *p_ul_buf, uint32_t ul_size) |
Write multiple data in buffer to LCD controller. More... | |
static void | hx8347a_write_ram_prepare (void) |
Prepare to write GRAM data. More... | |
static void | hx8347a_write_register (uint8_t uc_reg, uint16_t us_data) |
Write data to LCD Register. More... | |
Variables | |
static hx8347a_color_t | g_ul_pixel_cache [LCD_DATA_CACHE_SIZE] |
struct font | gfont = {10, 14} |
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 HX8347A_LCD_WIDTH |
Referenced by hx8347a_draw_filled_rectangle(), and hx8347a_set_foreground_color().
|
static |
Check box coordinates.
p_ul_x1 | X coordinate of upper-left corner on LCD. |
p_ul_y1 | Y coordinate of upper-left corner on LCD. |
p_ul_x2 | X coordinate of lower-right corner on LCD. |
p_ul_y2 | Y coordinate of lower-right corner on LCD. |
References HX8347A_LCD_HEIGHT, and HX8347A_LCD_WIDTH.
Referenced by hx8347a_draw_filled_rectangle(), hx8347a_draw_pixmap(), and hx8347a_draw_rectangle().
|
static |
Delay function.
Referenced by hx8347a_display_on(), and hx8347a_init().
void hx8347a_disable_scroll | ( | void | ) |
Disables the scrolling.
References HX8347A_GATE_SCAN_CTRL, and hx8347a_write_register().
void hx8347a_display_off | ( | void | ) |
Turn off the LCD.
References HX8347A_DISP_CTRL1, HX8347A_DISP_CTRL8, and hx8347a_write_register().
void hx8347a_display_on | ( | void | ) |
Turn on the LCD.
References hx8347a_delay(), HX8347A_DISP_CTRL1, HX8347A_DISP_CTRL1_D, HX8347A_DISP_CTRL1_DTE, HX8347A_DISP_CTRL1_GON, HX8347A_DISP_CTRL8, HX8347A_DISP_CTRL8_SAP, and hx8347a_write_register().
|
static |
Draw an ASCII character on LCD.
ul_x | X coordinate of character upper-left corner. |
ul_y | Y coordinate of character upper-left corner. |
uc_c | character to print. |
References hx8347a_draw_pixel().
Referenced by hx8347a_draw_string().
uint32_t hx8347a_draw_circle | ( | uint32_t | ul_x, |
uint32_t | ul_y, | ||
uint32_t | ul_r | ||
) |
Draw a circle on LCD.
ul_x | X coordinate of circle center. |
ul_y | Y coordinate of circle center. |
ul_r | circle radius. |
References hx8347a_draw_pixel().
uint32_t hx8347a_draw_filled_circle | ( | uint32_t | ul_x, |
uint32_t | ul_y, | ||
uint32_t | ul_r | ||
) |
Draw a filled circle on LCD.
ul_x | X coordinate of circle center. |
ul_y | Y coordinate of circle center. |
ul_r | circle radius. |
References hx8347a_draw_filled_rectangle().
void hx8347a_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.
ul_x1 | X coordinate of upper-left corner on LCD. |
ul_y1 | Y coordinate of upper-left corner on LCD. |
ul_x2 | X coordinate of lower-right corner on LCD. |
ul_y2 | Y coordinate of lower-right corner on LCD. |
References hx8347a_check_box_coordinates(), HX8347A_LCD_HEIGHT, HX8347A_LCD_WIDTH, hx8347a_set_cursor_position(), hx8347a_set_window(), hx8347a_write_ram_buffer(), hx8347a_write_ram_prepare(), and LCD_DATA_CACHE_SIZE.
Referenced by hx8347a_draw_filled_circle(), hx8347a_draw_line(), and hx8347a_draw_rectangle().
void hx8347a_draw_line | ( | uint32_t | ul_x1, |
uint32_t | ul_y1, | ||
uint32_t | ul_x2, | ||
uint32_t | ul_y2 | ||
) |
Draw a line on LCD.
ul_x1 | X coordinate of line start. |
ul_y1 | Y coordinate of line start. |
ul_x2 | X coordinate of line end. |
ul_y2 | Y coordinate of line end. |
References hx8347a_draw_filled_rectangle(), and hx8347a_draw_line_bresenham().
|
static |
Draw a line on LCD, which is not horizontal or vertical.
ul_x1 | X coordinate of line start. |
ul_y1 | Y coordinate of line start. |
ul_x2 | X coordinate of line end. |
ul_y2 | Y coordinate of line endl. |
References hx8347a_draw_pixel().
Referenced by hx8347a_draw_line().
uint32_t hx8347a_draw_pixel | ( | uint32_t | ul_x, |
uint32_t | ul_y | ||
) |
Draw a pixel on LCD.
ul_x | X coordinate of pixel. |
ul_y | Y coordinate of pixel. |
References HX8347A_LCD_HEIGHT, HX8347A_LCD_WIDTH, hx8347a_set_cursor_position(), hx8347a_write_ram(), and hx8347a_write_ram_prepare().
Referenced by hx8347a_draw_char(), hx8347a_draw_circle(), and hx8347a_draw_line_bresenham().
void hx8347a_draw_pixmap | ( | uint32_t | ul_x, |
uint32_t | ul_y, | ||
uint32_t | ul_width, | ||
uint32_t | ul_height, | ||
const hx8347a_color_t * | p_ul_pixmap | ||
) |
Draw a pixmap on LCD.
ul_x | X coordinate of upper-left corner on LCD. |
ul_y | Y coordinate of upper-left corner on LCD. |
ul_width | width of the picture. |
ul_height | height of the picture. |
p_ul_pixmap | pixmap of the image. |
References hx8347a_check_box_coordinates(), HX8347A_LCD_HEIGHT, HX8347A_LCD_WIDTH, hx8347a_set_cursor_position(), hx8347a_set_window(), hx8347a_write_ram_buffer(), and hx8347a_write_ram_prepare().
void hx8347a_draw_rectangle | ( | uint32_t | ul_x1, |
uint32_t | ul_y1, | ||
uint32_t | ul_x2, | ||
uint32_t | ul_y2 | ||
) |
Draw a rectangle on LCD.
ul_x1 | X coordinate of upper-left corner on LCD. |
ul_y1 | Y coordinate of upper-left corner on LCD. |
ul_x2 | X coordinate of lower-right corner on LCD. |
ul_y2 | Y coordinate of lower-right corner on LCD. |
References hx8347a_check_box_coordinates(), and hx8347a_draw_filled_rectangle().
void hx8347a_draw_string | ( | uint32_t | ul_x, |
uint32_t | ul_y, | ||
const uint8_t * | p_str | ||
) |
Draw a string on LCD.
ul_x | X coordinate of string top-left corner. |
ul_y | Y coordinate of string top-left corner. |
p_str | String to display. |
References font::height, hx8347a_draw_char(), and font::width.
void hx8347a_enable_scroll | ( | void | ) |
Enables the scrolling feature.
References HX8347A_GATE_SCAN_CTRL, HX8347A_GATE_SCAN_CTRL_SCROLL_ON, and hx8347a_write_register().
void hx8347a_fill | ( | hx8347a_color_t | us_color | ) |
Fill the LCD buffer with the specified color.
us_color | fill color. |
References HX8347A_LCD_HEIGHT, HX8347A_LCD_WIDTH, hx8347a_set_cursor_position(), hx8347a_write_ram(), and hx8347a_write_ram_prepare().
hx8347a_color_t hx8347a_get_pixel | ( | uint32_t | ul_x, |
uint32_t | ul_y | ||
) |
Get a pixel from LCD.
ul_x | X coordinate of pixel. |
ul_y | Y coordinate of pixel. |
References Assert, HX8347A_LCD_HEIGHT, HX8347A_LCD_WIDTH, hx8347a_read_ram(), hx8347a_read_ram_prepare(), and hx8347a_set_cursor_position().
uint32_t hx8347a_init | ( | struct hx8347a_opt_t * | p_opt | ) |
Initialize the HX8347A lcd driver.
p_opt | pointer to HX8347A option structure. |
References hx8347a_opt_t::foreground_color, HX8347A_COL_ADDR_END1, HX8347A_COL_ADDR_END1_EC, HX8347A_COL_ADDR_END2, HX8347A_COL_ADDR_END2_EC, HX8347A_COL_ADDR_START1, HX8347A_COL_ADDR_START1_SC, HX8347A_COL_ADDR_START2, HX8347A_COL_ADDR_START2_SC, HX8347A_CYCLE_CTRL1, HX8347A_CYCLE_CTRL1_N_NW, HX8347A_CYCLE_CTRL2, HX8347A_CYCLE_CTRL2_PI_NW, HX8347A_CYCLE_CTRL3, HX8347A_CYCLE_CTRL3_I_RTN, HX8347A_CYCLE_CTRL4, HX8347A_CYCLE_CTRL5, HX8347A_CYCLE_CTRL5_SON, HX8347A_CYCLE_CTRL6, HX8347A_CYCLE_CTRL6_GDON, HX8347A_CYCLE_CTRL7, HX8347A_CYCLE_CTRL7_GDOF, HX8347A_CYCLE_CTRL_1, HX8347A_CYCLE_CTRL_1_N_DC, HX8347A_CYCLE_CTRL_2, HX8347A_CYCLE_CTRL_2_PI_DC, HX8347A_CYCLE_CTRL_3, HX8347A_CYCLE_CTRL_3_I_DC, hx8347a_delay(), HX8347A_DEVICE_CODE, HX8347A_DISP_CTRL2, HX8347A_DISP_CTRL2_N_BP, HX8347A_DISP_CTRL3, HX8347A_DISP_CTRL3_N_FP, HX8347A_DISP_CTRL4, HX8347A_DISP_CTRL4_PI_BP, HX8347A_DISP_CTRL5, HX8347A_DISP_CTRL5_PI_FP, HX8347A_DISP_CTRL6, HX8347A_DISP_CTRL6_I_BP, HX8347A_DISP_CTRL7, HX8347A_DISP_CTRL7_I_FP, HX8347A_DISP_MODE_CTRL, HX8347A_DISP_MODE_CTRL_INVON, HX8347A_DISP_MODE_CTRL_NORON, HX8347A_HIMAX_ID_CODE, HX8347A_MEMORY_ACCESS_CTRL, HX8347A_MEMORY_ACCESS_CTRL_BGR, HX8347A_MEMORY_ACCESS_CTRL_MX, HX8347A_MEMORY_ACCESS_CTRL_MY, HX8347A_OSC_CTRL1, HX8347A_OSC_CTRL1_CADJ, HX8347A_OSC_CTRL1_CUADJ, HX8347A_OSC_CTRL1_OSC_EN, HX8347A_OSC_CTRL3, HX8347A_OSC_CTRL3_RADJ, HX8347A_POWER_CTRL1, HX8347A_POWER_CTRL1_PON, HX8347A_POWER_CTRL2, HX8347A_POWER_CTRL2_AP, HX8347A_POWER_CTRL3, HX8347A_POWER_CTRL3_VC1, HX8347A_POWER_CTRL4, HX8347A_POWER_CTRL4_VC3, HX8347A_POWER_CTRL5, HX8347A_POWER_CTRL5_VRH, HX8347A_POWER_CTRL6, HX8347A_POWER_CTRL6_BT, HX8347A_R_CTRL1, HX8347A_R_CTRL10, HX8347A_R_CTRL10_CGMP2, HX8347A_R_CTRL10_OP12, HX8347A_R_CTRL10_OP13, HX8347A_R_CTRL11, HX8347A_R_CTRL11_CGMN10, HX8347A_R_CTRL11_ON01, HX8347A_R_CTRL11_ON02, HX8347A_R_CTRL12, HX8347A_R_CTRL12_CGMN2, HX8347A_R_CTRL12_ON11, HX8347A_R_CTRL12_ON12, HX8347A_R_CTRL1_CP00, HX8347A_R_CTRL1_CP02, HX8347A_R_CTRL1_CP10, HX8347A_R_CTRL1_GSEL, HX8347A_R_CTRL2, HX8347A_R_CTRL2_CN00, HX8347A_R_CTRL2_CN10, HX8347A_R_CTRL2_CN12, HX8347A_R_CTRL3, HX8347A_R_CTRL4, HX8347A_R_CTRL4_NP21, HX8347A_R_CTRL4_NP22, HX8347A_R_CTRL4_NP30, HX8347A_R_CTRL4_NP31, HX8347A_R_CTRL5, HX8347A_R_CTRL5_NP40, HX8347A_R_CTRL5_NP50, HX8347A_R_CTRL6, HX8347A_R_CTRL6_NN01, HX8347A_R_CTRL6_NN02, HX8347A_R_CTRL6_NN11, HX8347A_R_CTRL6_NN12, HX8347A_R_CTRL7, HX8347A_R_CTRL7_NN22, HX8347A_R_CTRL7_NN30, HX8347A_R_CTRL8, HX8347A_R_CTRL8_NN40, HX8347A_R_CTRL8_NN41, HX8347A_R_CTRL8_NN42, HX8347A_R_CTRL8_NN50, HX8347A_R_CTRL8_NN51, HX8347A_R_CTRL8_NN52, HX8347A_R_CTRL9, HX8347A_R_CTRL9_CGMP00, HX8347A_R_CTRL9_OP00, HX8347A_R_CTRL9_OP01, hx8347a_read_register(), HX8347A_ROW_ADDR_END1, HX8347A_ROW_ADDR_END1_EP, HX8347A_ROW_ADDR_END2, HX8347A_ROW_ADDR_END2_EP, HX8347A_ROW_ADDR_START1, HX8347A_ROW_ADDR_START1_SP, HX8347A_ROW_ADDR_START2, HX8347A_ROW_ADDR_START2_SP, hx8347a_set_cursor_position(), hx8347a_set_foreground_color(), hx8347a_set_window(), HX8347A_VCOM_CTRL1, HX8347A_VCOM_CTRL1_VCOMG, HX8347A_VCOM_CTRL2, HX8347A_VCOM_CTRL2_VCM, HX8347A_VCOM_CTRL3, HX8347A_VCOM_CTRL3_VDV, hx8347a_write_register(), hx8347a_opt_t::ul_height, and hx8347a_opt_t::ul_width.
|
static |
Read data to LCD GRAM.
Referenced by hx8347a_get_pixel().
|
static |
|
static |
Read data from LCD Register.
uc_reg | register address. |
Referenced by hx8347a_init().
void hx8347a_scroll | ( | int32_t | ul_lines | ) |
Scroll up/down for the number of specified lines.
ul_lines | number of lines to scroll. |
References HX8347A_VERTICAL_SCROLL_START_ADDR1, HX8347A_VERTICAL_SCROLL_START_ADDR1_VSP, HX8347A_VERTICAL_SCROLL_START_ADDR2, HX8347A_VERTICAL_SCROLL_START_ADDR2_VSP, and hx8347a_write_register().
void hx8347a_set_cursor_position | ( | uint16_t | us_x, |
uint16_t | us_y | ||
) |
Set cursor of LCD screen.
us_x | X coordinate of upper-left corner on LCD. |
us_y | Y coordinate of upper-left corner on LCD. |
References HX8347A_COL_ADDR_START1, HX8347A_COL_ADDR_START2, HX8347A_ROW_ADDR_START1, HX8347A_ROW_ADDR_START2, and hx8347a_write_register().
Referenced by hx8347a_draw_filled_rectangle(), hx8347a_draw_pixel(), hx8347a_draw_pixmap(), hx8347a_fill(), hx8347a_get_pixel(), and hx8347a_init().
void hx8347a_set_display_direction | ( | display_direction_t | dd | ) |
Set display direction.
dd | 0: horizontal direction, 1: vertical direction |
References HX8347A_MEMORY_ACCESS_CTRL, HX8347A_MEMORY_ACCESS_CTRL_BGR, HX8347A_MEMORY_ACCESS_CTRL_MV, HX8347A_MEMORY_ACCESS_CTRL_MX, HX8347A_MEMORY_ACCESS_CTRL_MY, hx8347a_write_register(), and LANDSCAPE.
void hx8347a_set_foreground_color | ( | hx8347a_color_t | us_color | ) |
Set foreground color.
us_color | foreground color. |
References LCD_DATA_CACHE_SIZE.
Referenced by hx8347a_init().
void hx8347a_set_window | ( | uint32_t | ul_x, |
uint32_t | ul_y, | ||
uint32_t | ul_width, | ||
uint32_t | ul_height | ||
) |
Set display window.
ul_x | Horizontal address start position |
ul_y | Vertical address start position |
ul_width | The width of the window. |
ul_height | The height of the window. |
References Assert, HX8347A_COL_ADDR_END1, HX8347A_COL_ADDR_END2, HX8347A_COL_ADDR_START1, HX8347A_COL_ADDR_START2, HX8347A_ROW_ADDR_END1, HX8347A_ROW_ADDR_END2, HX8347A_ROW_ADDR_START1, HX8347A_ROW_ADDR_START2, and hx8347a_write_register().
Referenced by hx8347a_draw_filled_rectangle(), hx8347a_draw_pixmap(), and hx8347a_init().
|
static |
Write data to LCD GRAM.
us_color | 16-bits RGB color. |
Referenced by hx8347a_draw_pixel(), hx8347a_fill(), and hx8347a_write_ram_buffer().
|
static |
Write multiple data in buffer to LCD controller.
p_ul_buf | data buffer. |
ul_size | size in pixels. |
References addr, and hx8347a_write_ram().
Referenced by hx8347a_draw_filled_rectangle(), and hx8347a_draw_pixmap().
|
static |
Prepare to write GRAM data.
References HX8347A_SRAM_WRITE_CTRL.
Referenced by hx8347a_draw_filled_rectangle(), hx8347a_draw_pixel(), hx8347a_draw_pixmap(), and hx8347a_fill().
|
static |
Write data to LCD Register.
uc_reg | register address. |
us_data | data to be written. |
Referenced by hx8347a_disable_scroll(), hx8347a_display_off(), hx8347a_display_on(), hx8347a_enable_scroll(), hx8347a_init(), hx8347a_scroll(), hx8347a_set_cursor_position(), hx8347a_set_display_direction(), and hx8347a_set_window().
|
static |
struct font gfont = {10, 14} |
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.