Skip to content
rudidl edited this page Nov 21, 2016 · 11 revisions

XGLCD Arduino Library Function Reference

Graphic Primitives

Draw a single pixel

Draws a single Pixel of 'color' at coordinates 'x,y'

void drawPixel(int16_t x, int16_t y, uint16_t color)

void drawPixel(int16_t x, int16_t y)

  • x: horizontal position (0 -> MAX_WIDTH-1)
  • y: vertical position (0 -> MAX_HEIGHT-1)
  • color: RGB565 or RGB332 or active color

Draw a series of pixels

Draw a series of pixels with the pixel colors stored in an array. The first pixel is drawn at coordinate 'x,y'.

void drawPixels(uint16_t p[], uint16_t count, int16_t x, int16_t y)

  • p: array which contains the colors of the subsequent pixels, either in RGB565 (65k color configuration) or RGB232 (256 color configuration)
  • count: number of pixels in the array
  • x: horizontal position (0 -> MAX_WIDTH-1)
  • y: vertical position (0 -> MAX_HEIGHT-1)

Get a pixel color

Returns the color of the pixel at coordinate 'x,y' in RGB565 or RGB332 format.

uint16_t getPixel(int16_t x, int16_t y)

  • x: horizontal position (0 -> MAX_WIDTH-1)
  • y: vertical position (0 -> MAX_HEIGHT-1)

Draw a line

Draws a line between two coordinates in 'color'

void drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color)

void drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1)

  • x0: first coordinate horizontal position (0 -> MAX_WIDTH-1)
  • y0: first coordinate vertical position (0 -> MAX_HEIGHT-1)
  • x1: second coordinate horizontal position (0 -> MAX_WIDTH-1)
  • y1: second coordinate vertical position (0 -> MAX_HEIGHT-1)
  • color: RGB565 or RGB332 or active color

Mind the number of pixels drawn because this function draws from point x0/y0 up until point x1/y1. For example drawLine(0,0,2,0,COLOR_RED); will draw a 3 pixel long line.

Draw a line based on an angle and a length

Draws a line of 'length' in 'color' starting from coordinate 'x,y' with an 'angle'

void drawLineAngle(int16_t x, int16_t y, int16_t angle, uint16_t length, uint16_t color, int offset)

void drawLineAngle(int16_t x, int16_t y, int16_t angle, uint16_t start, uint16_t length, uint16_t color, int offset)

  • x: horizontal position (0 -> MAX_WIDTH-1)
  • y: vertical position (0 -> MAX_HEIGHT-1)
  • angle: the angle in degrees (0 -> 359), counter clockwise, 0 degrees is East
  • start: tbd
  • length: length of the line in pixels
  • color: RGB565 or RGB332 or active color
  • offset: tbd

Draw a horizontal line

Draws a horizontal line of 'length' in 'color' starting at coordinate 'x/y'.

void drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color)

  • x: starting point horizontal position (0 -> MAX_WIDTH-1)
  • y: starting point vertical position (0 -> MAX_HEIGHT-1)
  • w: width of the horizontal line
  • color: RGB565 or RGB332 or active color

Draw a vertical line

Draws a vertical line of 'height' in 'color' starting at coordinate 'x/y'.

void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color)

  • x: starting point horizontal position (0 -> MAX_WIDTH-1)
  • y: starting point vertical position (0 -> MAX_HEIGHT-1)
  • h: height of the horizontal line
  • color: RGB565 or RGB332 or active color

Draw a rectangle

Draws an open or filled rectangle of 'height' and 'width' in 'color' starting at coordinate 'x/y'.

void drawRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color)

void fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color)

  • x: starting point horizontal position (0 -> MAX_WIDTH-1)
  • y: starting point vertical position (0 -> MAX_HEIGHT-1)
  • w: width of the rectangle
  • h: width of the rectangle
  • color: RGB565 or RGB332

Draws an open or filled rectangle in the active color between the coordinates 'x0/y0' and 'x1/y1'.

void XGLCD::drawRect(int16_t x0, int16_t y0, int16_t x1, int16_t y1)

void fillRect(int16_t x0, int16_t y0, int16_t x1, int16_t y1)

  • x0: first coordinate horizontal position (0 -> MAX_WIDTH-1)
  • y0: first coordinate vertical position (0 -> MAX_HEIGHT-1)
  • x1: second coordinate horizontal position (0 -> MAX_WIDTH-1)
  • y1: second coordinate vertical position (0 -> MAX_HEIGHT-1)
  • color: active color

Draw a circle

Draws an open or filled circle in 'color' with a given center point 'x/y' and radius 'r'.

void drawCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color)

void drawCircle(int16_t x0, int16_t y0, int16_t r)

void fillCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color)

void fillCircle(int16_t x0, int16_t y0, int16_t r)

  • x0: center point horizontal position (0 -> MAX_WIDTH-1)
  • y0: center point vertical position (0 -> MAX_HEIGHT-1)
  • r: radius of the circle in pixels
  • color: RGB565 or RGB332 or active color

clearMemory()

Clears independent of the selected LCD resolution or color depth the complete video memory. The video memory might contain several video buffers, all of them are cleared.

// SYNTAX tft.clearMemory(bool stop);

Argument: stop : TRUE or FALSE

Return value: none

Home

Clone this wiki locally