upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
Public Member Functions | Data Fields | Protected Attributes | Static Protected Attributes
GFX Class Referenceabstract

GFX helper class. More...

Detailed Description

This file is used by the screen.

Public Member Functions

 GFX (int16_t w, int16_t h)
 
virtual ~GFX ()
 
virtual void drawPixel (int16_t x, int16_t y, uint16_t color)=0
 
virtual void drawLine (int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color)
 
virtual void drawFastVLine (int16_t x, int16_t y, int16_t h, uint16_t color)
 
virtual void drawFastHLine (int16_t x, int16_t y, int16_t w, uint16_t color)
 
virtual void drawRect (int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color)
 
virtual void fillRect (int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color)
 
virtual void fillScreen (uint16_t color)
 
virtual void invertDisplay (bool i)
 
void drawCircle (int16_t x0, int16_t y0, int16_t r, uint16_t color)
 
void drawCircleHelper (int16_t x0, int16_t y0, int16_t r, uint8_t cornername, uint16_t color)
 
void fillCircle (int16_t x0, int16_t y0, int16_t r, uint16_t color)
 
void fillCircleHelper (int16_t x0, int16_t y0, int16_t r, uint8_t cornername, int16_t delta, uint16_t color)
 
void drawTriangle (int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color)
 
void fillTriangle (int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color)
 
void drawRoundRect (int16_t x0, int16_t y0, int16_t w, int16_t h, int16_t radius, uint16_t color)
 
void fillRoundRect (int16_t x0, int16_t y0, int16_t w, int16_t h, int16_t radius, uint16_t color)
 
void drawChar (int16_t x, int16_t y, unsigned char c, uint16_t color, uint16_t bg, uint8_t size)
 
int16_t getCursorX (void) const
 
int16_t getCursorY (void) const
 
void setCursor (int16_t x, int16_t y)
 
void setTextColor (uint16_t c)
 
void setTextColor (uint16_t c, uint16_t bg)
 
void setTextSize (uint8_t s)
 
void setTextWrap (bool w)
 
uint8_t getRotation (void) const
 
void setRotation (uint8_t r)
 
void cp437 (bool x)
 
virtual void write (uint8_t c)
 
void print (std::string msg)
 
int16_t width (void) const
 
int16_t height (void) const
 
 GFX (int width, int height)
 
virtual ~GFX ()
 
virtual void drawPixel (int16_t x, int16_t y, uint16_t color)=0
 
virtual void refresh ()=0
 
void drawChar (int16_t x, int16_t y, uint8_t data, uint16_t color, uint16_t bg, uint8_t size)
 
void print (std::string msg)
 
void fillScreen (uint16_t color)
 
void fillRect (int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color)
 
void drawFastVLine (int16_t x, int16_t y, int16_t h, uint16_t color)
 
void drawLine (int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color)
 
void drawTriangle (int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color)
 
void drawCircle (int16_t x, int16_t y, int16_t r, uint16_t color)
 
void setCursor (int16_t x, int16_t y)
 
void setTextColor (uint16_t textColor, uint16_t textBGColor)
 
void setTextSize (uint8_t size)
 
void setTextWrap (uint8_t wrap)
 
 GFX (int width, int height, uint8_t *screenBuffer, const unsigned char *font)
 
virtual ~GFX ()
 
virtual void setAddrWindow (uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1)=0
 
virtual void drawPixel (int16_t x, int16_t y, uint16_t color)=0
 
virtual void refresh ()=0
 
void drawChar (int16_t x, int16_t y, uint8_t data, uint16_t color, uint16_t bg, uint8_t size)
 
void print (std::string msg)
 
mraa::Result setPixel (int x, int y, uint16_t color)
 
void fillScreen (uint16_t color)
 
void fillRect (int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color)
 
void drawFastVLine (int16_t x, int16_t y, int16_t h, uint16_t color)
 
void drawLine (int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color)
 
void drawTriangle (int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color)
 
void drawCircle (int16_t x, int16_t y, int16_t r, uint16_t color)
 
void setCursor (int16_t x, int16_t y)
 
void setTextColor (uint16_t textColor, uint16_t textBGColor)
 
void setTextSize (uint8_t size)
 
void setTextWrap (uint8_t wrap)
 

Data Fields

uint8_t * m_map
 

Protected Attributes

const int16_t WIDTH
 
const int16_t HEIGHT
 
int16_t _width
 
int16_t _height
 
uint8_t rotation
 
uint16_t textcolor
 
uint16_t textbgcolor
 
int16_t cursor_x
 
int16_t cursor_y
 
uint8_t textsize
 
bool wrap
 
bool _cp437
 
int m_width
 
int m_height
 
int m_textSize
 
int m_textColor
 
int m_textBGColor
 
int m_cursorX
 
int m_cursorY
 
int m_wrap
 
const unsigned char * m_font
 

Static Protected Attributes

static const unsigned char font []
 

Constructor & Destructor Documentation

GFX ( int16_t  w,
int16_t  h 
)

Creates a GFX object

Parameters
wScreen width
hScreen height
~GFX ( )
inlinevirtual

Empyt virtual destructor

Here is the call graph for this function:

Here is the caller graph for this function:

GFX ( int  width,
int  height 
)

Instantiates a GFX object

Parameters
widthScreen width
heightScreen height

Here is the call graph for this function:

virtual ~GFX ( )
virtual

GFX object destructor

GFX ( int  width,
int  height,
uint8_t *  screenBuffer,
const unsigned char *  font 
)

Instantiates a GFX object

Parameters
widthScreen width
heightScreen height
screenBufferPointer to the screen buffer
fontPointer to the font map

Here is the call graph for this function:

virtual ~GFX ( )
virtual

GFX object destructor

Member Function Documentation

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

Sends a pixel color (RGB) to the driver chip. This must be defined by the subclass (pure virtual function).

Parameters
xAxis on the horizontal scale
yAxis on the vertical scale
colorRGB (16-bit) color (R[0-4], G[5-10], B[11-15]

Implemented in ST7735, ILI9341, and SSD1351.

Here is the caller graph for this function:

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

Draw a line.

Parameters
x0Start of line x coordinate
y0Start of line y coordinate
x1End of line x coordinate
y1End of line y coordinate
colorRGB (16-bit) color (R[0-4], G[5-10], B[11-15]

Here is the call graph for this function:

Here is the caller graph for this function:

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

Draws a vertical line using minimal SPI writes.

Parameters
xAxis on the horizontal scale to begin line
yAxis on the vertical scale to begin line
hHeight of line in pixels
colorRGB (16-bit) color (R[0-4], G[5-10], B[11-15]

Reimplemented in ILI9341.

Here is the call graph for this function:

Here is the caller graph for this function:

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

Draws a horizontal line using minimal SPI writes.

Parameters
xAxis on the horizontal scale to begin line
yAxis on the vertical scale to begin line
wWidth of line in pixels
colorRGB (16-bit) color (R[0-4], G[5-10], B[11-15]

Reimplemented in ILI9341.

Here is the call graph for this function:

Here is the caller graph for this function:

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

Draws a rectangle (not filled).

Parameters
xPosition of upper left corner on horizontal axis
yPosition of upper left corner on vertical axis
wWidth of rectangle
hHeight of rectangle RGB (16-bit) color (R[0-4], G[5-10], B[11-15]

Here is the call graph for this function:

Here is the caller graph for this function:

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

Draw a filled rectangle.

Parameters
xAxis on the horizontal scale of upper-left corner
yAxis on the vertical scale of upper-left corner
wWidth of rectangle in pixels
hHeight of rectangle in pixels
colorRGB (16-bit) color (R[0-4], G[5-10], B[11-15]

Reimplemented in ILI9341.

Here is the call graph for this function:

Here is the caller graph for this function:

void fillScreen ( uint16_t  color)
virtual

Fill the screen with a single color.

Parameters
colorRGB (16-bit) color (R[0-4], G[5-10], B[11-15]

Reimplemented in ILI9341.

Here is the call graph for this function:

Here is the caller graph for this function:

void invertDisplay ( bool  i)
virtual

Invert colors on the display.

Parameters
iTrue or false to invert colors

Reimplemented in ILI9341.

Here is the caller graph for this function:

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

Draw a circle outline.

Parameters
x0Center point of circle on x-axis
y0Center point of circle on y-axis
rRadius of circle
colorRGB (16-bit) color (R[0-4], G[5-10], B[11-15]

Here is the call graph for this function:

Here is the caller graph for this function:

void drawCircleHelper ( int16_t  x0,
int16_t  y0,
int16_t  r,
uint8_t  cornername,
uint16_t  color 
)

Used to draw rounded corners.

Parameters
x0Center point of circle on x-axis
y0Center point of circle on y-axis
rRadius of circle
cornernameMask of corner number (1, 2, 4, 8)
colorRGB (16-bit) color (R[0-4], G[5-10], B[11-15]

Here is the call graph for this function:

Here is the caller graph for this function:

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

Draws a filled circle.

Parameters
x0Center point of circle on x-axis
y0Center point of circle on y-axis
rRadius of circle
colorRGB (16-bit) color (R[0-4], G[5-10], B[11-15]

Here is the call graph for this function:

Here is the caller graph for this function:

void fillCircleHelper ( int16_t  x0,
int16_t  y0,
int16_t  r,
uint8_t  cornername,
int16_t  delta,
uint16_t  color 
)

Used to draw a filled circle and rounded rectangles.

Parameters
x0Center point of circle on x-axis
y0Center point of circle on y-axis
rRadius of circle
cornernameMask of corner number (1, 2, 4, 8)
deltaLine offset
colorRGB (16-bit) color (R[0-4], G[5-10], B[11-15]

Here is the call graph for this function:

Here is the caller graph for this function:

void drawTriangle ( int16_t  x0,
int16_t  y0,
int16_t  x1,
int16_t  y1,
int16_t  x2,
int16_t  y2,
uint16_t  color 
)

Draw a triangle.

Parameters
x0First point coordinate on x-axis
y0First point coordinate on y-axis
x1Second point coordinate on x-axis
y1Second point coordinate on y-axis
x2Third point coordinate on x-axis
y2Third point coordinate on y-axis
colorRGB (16-bit) color (R[0-4], G[5-10], B[11-15]

Here is the call graph for this function:

Here is the caller graph for this function:

void fillTriangle ( int16_t  x0,
int16_t  y0,
int16_t  x1,
int16_t  y1,
int16_t  x2,
int16_t  y2,
uint16_t  color 
)

Draw a filled triangle.

Parameters
x0First point coordinate on x-axis
y0First point coordinate on y-axis
x1Second point coordinate on x-axis
y1Second point coordinate on y-axis
x2Third point coordinate on x-axis
y2Third point coordinate on y-axis
colorRGB (16-bit) color (R[0-4], G[5-10], B[11-15]

Here is the call graph for this function:

Here is the caller graph for this function:

void drawRoundRect ( int16_t  x0,
int16_t  y0,
int16_t  w,
int16_t  h,
int16_t  radius,
uint16_t  color 
)

Draw a rectangle with rounded corners

Parameters
x0X-axis coordinate of top-left corner
y0Y-axis coordinate of top-left corner
wWidth of rectangle
hheight of rectangle
radiusRadius of rounded corners
colorRGB (16-bit) color (R[0-4], G[5-10], B[11-15]

Here is the call graph for this function:

Here is the caller graph for this function:

void fillRoundRect ( int16_t  x0,
int16_t  y0,
int16_t  w,
int16_t  h,
int16_t  radius,
uint16_t  color 
)

Draw a filled rectangle with rounded corners

Parameters
x0X-axis coordinate of top-left corner
y0Y-axis coordinate of top-left corner
wWidth of rectangle
hheight of rectangle
radiusRadius of rounded corners
colorRGB (16-bit) color (R[0-4], G[5-10], B[11-15]

Here is the call graph for this function:

Here is the caller graph for this function:

void drawChar ( int16_t  x,
int16_t  y,
unsigned char  c,
uint16_t  color,
uint16_t  bg,
uint8_t  size 
)

Draw a character at the specified point.

Parameters
xX-axis coordinate of the top-left corner
yY-axis coordinate of the top-left corner
cCharacter to draw
colorRGB (16-bit) color (R[0-4], G[5-10], B[11-15]
bgBackground color (16-bit RGB)
sizeFont size

Here is the call graph for this function:

Here is the caller graph for this function:

int16_t getCursorX ( void  ) const

Get the x-axis coordinate of the upper-left corner of the cursor.

Returns
X-axis coordinate of the cursor

Here is the caller graph for this function:

int16_t getCursorY ( void  ) const

Get the y-axis coordinate of the upper-left corner of the cursor.

Returns
Y-axis coordinate of the cursor

Here is the caller graph for this function:

void setCursor ( int16_t  x,
int16_t  y 
)

Set the cursor for writing text.

Parameters
xX-axis coordinate of the top-left corner of the cursor
yY-axis coordinate of the top-left corner of the cursor

Here is the caller graph for this function:

void setTextColor ( uint16_t  c)

Set the color for text.

Parameters
cRGB (16-bit) color (R[0-4], G[5-10], B[11-15]

Here is the caller graph for this function:

void setTextColor ( uint16_t  c,
uint16_t  bg 
)

Set the color for text and text background (highlight).

Parameters
cText color (RGB, 16-bit)
bgBackground text color (RGB, 16-bit)
void setTextSize ( uint8_t  s)

Set the size of the text.

Parameters
sFont size (multiples of 8 pixel text height)

Here is the caller graph for this function:

void setTextWrap ( bool  w)

Enable or disable text wrapping.

Parameters
wTrue to wrap text. False to truncate.

Here is the caller graph for this function:

uint8_t getRotation ( void  ) const

Get the current rotation configuration of the screen.

Returns
current rotation 0-3

Here is the caller graph for this function:

void setRotation ( uint8_t  r)

Sets the rotation of the screen. Can be overridden with another screen-specific definition.

Parameters
rRotation 0-3

Here is the caller graph for this function:

void cp437 ( bool  x)

Enable (or disable) Code Page 437-compatible charset.

Parameters
xTrue to enable CP437 charset. False to disable.

Here is the caller graph for this function:

void write ( uint8_t  c)
virtual

Write a character at the current cursor position. Definition can be overridden with board-specific code.

Parameters
cCharacter to draw

Reimplemented in ST7735.

Here is the call graph for this function:

Here is the caller graph for this function:

void print ( std::string  msg)

Prints a string to the screen.

Parameters
msgMessage to print

Here is the call graph for this function:

Here is the caller graph for this function:

int16_t width ( void  ) const

Get the current width of the screen.

Returns
the width in pixels

Here is the caller graph for this function:

int16_t height ( void  ) const

Get the current height of the screen.

Returns
the height in pixels

Here is the caller graph for this function:

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

Sends a pixel color (RGB) to the chip. Must be implemented by the inherited class.

Parameters
xAxis on the horizontal scale
yAxis on the vertical scale
colorRGB value

Implemented in ST7735, ILI9341, and SSD1351.

virtual void refresh ( )
pure virtual

Copies the buffer to the chip via the SPI.

Implemented in ST7735, and SSD1351.

void drawChar ( int16_t  x,
int16_t  y,
uint8_t  data,
uint16_t  color,
uint16_t  bg,
uint8_t  size 
)
Parameters
xAxis on the horizontal scale
yAxis on the vertical scale
dataCharacter to write
colorCharacter color
bgCharacter background color
sizeSize of the font

Here is the call graph for this function:

void print ( std::string  msg)

Prints a message on the screen

Parameters
msgMessage to print
void fillScreen ( uint16_t  color)

Fills the screen with a selected color

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

Fills a rectangle with a selected color

Parameters
xAxis on the horizontal scale (top-left corner)
yAxis on the vertical scale (top-left corner)
wDistanse from x
hDistanse from y
colorSelected color
void drawFastVLine ( int16_t  x,
int16_t  y,
int16_t  h,
uint16_t  color 
)

Draws a line on the vertical scale

Parameters
xAxis on the horizontal scale
yAxis on the vertical scale
hDistanse from y
colorSelected color
void drawLine ( int16_t  x0,
int16_t  y0,
int16_t  x1,
int16_t  y1,
uint16_t  color 
)

Draws a line from coordinate C0 to coordinate C1

Parameters
x0First coordinate
y0First coordinate
x1Second coordinate
y1Second coordinate
colorselected color
void drawTriangle ( int16_t  x0,
int16_t  y0,
int16_t  x1,
int16_t  y1,
int16_t  x2,
int16_t  y2,
uint16_t  color 
)

Draws a triangle

Parameters
x0First coordinate
y0First coordinate
x1Second coordinate
y1Second coordinate
x2Third coordinate
y2Third coordinate
colorSelected color
void drawCircle ( int16_t  x,
int16_t  y,
int16_t  r,
uint16_t  color 
)

Draws a circle

Parameters
xCenter of the circle on the horizontal scale
yCenter of the circle on the vertical scale
rRadius of the circle
colorColor of the circle
void setCursor ( int16_t  x,
int16_t  y 
)

Sets the cursor for a text message

Parameters
xAxis on the horizontal scale
yAxis on the vertical scale
void setTextColor ( uint16_t  textColor,
uint16_t  textBGColor 
)

Sets a text color for a message

Parameters
textColorFont color
textBGColorBackground color
void setTextSize ( uint8_t  size)

Sets the size of the font

Parameters
sizeFont size
void setTextWrap ( uint8_t  wrap)

Wraps a printed message

Parameters
wrapTrue (0x1) or false (0x0)
virtual void setAddrWindow ( uint8_t  x0,
uint8_t  y0,
uint8_t  x1,
uint8_t  y1 
)
pure virtual

Sets the window address

Parameters
x0First coordinate
y0First coordinate
x1Second coordinate
y1Second coordinate

Implemented in ST7735.

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

Sends a pixel color (RGB) to the chip. Must be implemented by the inherited class.

Parameters
xAxis on the horizontal scale
yAxis on the vertical scale
colorRGB value

Implemented in ST7735, ILI9341, and SSD1351.

virtual void refresh ( )
pure virtual

Copies the buffer to the chip via the SPI.

Implemented in ST7735, and SSD1351.

void drawChar ( int16_t  x,
int16_t  y,
uint8_t  data,
uint16_t  color,
uint16_t  bg,
uint8_t  size 
)
Parameters
xAxis on the horizontal scale
yAxis on the vertical scale
dataCharacter to write
colorCharacter color
bgCharacter background color
sizeSize of the font
void print ( std::string  msg)

Prints a message on the screen

Parameters
msgMessage to print
mraa::Result setPixel ( int  x,
int  y,
uint16_t  color 
)

Prints a message on the screen

Parameters
xAxis on the horizontal scale
yAxis on the vertical scale
colorPixel color

Here is the call graph for this function:

Here is the caller graph for this function:

void fillScreen ( uint16_t  color)

Fills the screen with a selected color

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

Fills a rectangle with a selected color

Parameters
xAxis on the horizontal scale (top-left corner)
yAxis on the vertical scale (top-left corner)
wDistanse from x
hDistanse from y
colorSelected color
void drawFastVLine ( int16_t  x,
int16_t  y,
int16_t  h,
uint16_t  color 
)

Draws a line on the vertical scale

Parameters
xAxis on the horizontal scale
yAxis on the vertical scale
hDistanse from y
colorSelected color
void drawLine ( int16_t  x0,
int16_t  y0,
int16_t  x1,
int16_t  y1,
uint16_t  color 
)

Draws a line from coordinate C0 to coordinate C1

Parameters
x0First coordinate
y0First coordinate
x1Second coordinate
y1Second coordinate
colorselected color
void drawTriangle ( int16_t  x0,
int16_t  y0,
int16_t  x1,
int16_t  y1,
int16_t  x2,
int16_t  y2,
uint16_t  color 
)

Draws a triangle

Parameters
x0First coordinate
y0First coordinate
x1Second coordinate
y1Second coordinate
x2Third coordinate
y2Third coordinate
colorSelected color
void drawCircle ( int16_t  x,
int16_t  y,
int16_t  r,
uint16_t  color 
)

Draws a circle

Parameters
xCenter of the circle on the horizontal scale
yCenter of the circle on the vertical scale
rRadius of the circle
colorColor of the circle
void setCursor ( int16_t  x,
int16_t  y 
)

Sets the cursor for a text message

Parameters
xAxis on the horizontal scale
yAxis on the vertical scale
void setTextColor ( uint16_t  textColor,
uint16_t  textBGColor 
)

Sets a text color for a message

Parameters
textColorFont color
textBGColorBackground color
void setTextSize ( uint8_t  size)

Sets the size of the font

Parameters
sizeFont size
void setTextWrap ( uint8_t  wrap)

Wraps a printed message

Parameters
wrapTrue (0x1) or false (0x0)

Field Documentation

int m_width
protected

Screen width

int m_height
protected

Screen height

int m_textSize
protected

Printed text size

int m_textColor
protected

Printed text color

int m_textBGColor
protected

Printed text background color

int m_cursorX
protected

Cursor X coordinate

int m_cursorY
protected

Cursor Y coordinate

int m_wrap
protected

Wrapper flag (true or false)

uint8_t* m_map

Screens buffer

Inheritance diagram for GFX:
Inheritance graph
[legend]

The documentation for this class was generated from the following files: