upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
Public Member Functions

API for the ILI9342 LCD. More...

Detailed Description

This module defines the interface for the ILI9341 display library

ili9341.jpg
// Pins (Edison)
// CS_LCD GP44 (MRAA 31)
// CS_SD GP43 (MRAA 38) unused
// DC GP12 (MRAA 20)
// RESEST GP13 (MRAA 14)
upm::ILI9341 lcd(31, 38, 20, 14);
// Fill the screen with a solid color
lcd.fillScreen(lcd.color565(0, 40, 16));
// Draw some shapes
lcd.drawFastVLine(10, 10, 100, ILI9341_RED);
lcd.drawFastHLine(20, 10, 50, ILI9341_CYAN);
lcd.drawLine(160, 30, 200, 60, ILI9341_GREEN);
lcd.fillRect(20, 30, 75, 60, ILI9341_ORANGE);
lcd.drawCircle(70, 50, 20, ILI9341_PURPLE);
lcd.fillCircle(120, 50, 20, ILI9341_PURPLE);
lcd.drawTriangle(50, 100, 10, 140, 90, 140, ILI9341_YELLOW);
lcd.fillTriangle(150, 100, 110, 140, 190, 140, ILI9341_YELLOW);
lcd.drawRoundRect(20, 150, 50, 30, 10, ILI9341_RED);
lcd.drawRoundRect(130, 150, 50, 30, 10, ILI9341_RED);
lcd.fillRoundRect(75, 150, 50, 30, 10, ILI9341_RED);
// Write some text
lcd.setCursor(0, 200);
lcd.setTextColor(ILI9341_LIGHTGREY);
lcd.setTextWrap(true);
lcd.setTextSize(1);
lcd.print("Text 1\n");
lcd.setTextSize(2);
lcd.print("Text 2\n");
lcd.setTextSize(3);
lcd.print("Text 3\n");
lcd.setTextSize(4);
lcd.print("Text 4\n");
// Test screen rotation
for (int r = 0; r < 4; r++) {
lcd.setRotation(r);
lcd.fillRect(0, 0, 5, 5, ILI9341_WHITE);
upm_delay(1);
}
// Invert colors, wait, then revert back
lcd.invertDisplay(true);
upm_delay(2);
lcd.invertDisplay(false);
// Don't forget to free up that memory!

Public Member Functions

 ILI9341 (int csLCD, int csSD, int dc, int rst)
 
std::string name ()
 
void initModule ()
 
void configModule ()
 
void setAddrWindow (uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1)
 
void drawPixel (int16_t x, int16_t y, uint16_t color)
 
void drawFastVLine (int16_t x, int16_t y, int16_t h, uint16_t color)
 
void drawFastHLine (int16_t x, int16_t y, int16_t w, uint16_t color)
 
void fillRect (int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color)
 
void fillScreen (uint16_t color)
 
void setRotation (uint8_t r)
 
void invertDisplay (bool i)
 
uint16_t color565 (uint8_t r, uint8_t g, uint8_t b)
 
void executeCMDList (const uint8_t *addr)
 
void writecommand (uint8_t c)
 
void writedata (uint8_t d)
 
mraa::Result lcdCSOn ()
 
mraa::Result lcdCSOff ()
 
mraa::Result sdCSOn ()
 
mraa::Result sdCSOff ()
 
mraa::Result dcHigh ()
 
mraa::Result dcLow ()
 
mraa::Result rstHigh ()
 
mraa::Result rstLow ()
 
- Public Member Functions inherited from GFX
 GFX (int16_t w, int16_t h)
 
virtual ~GFX ()
 
virtual void drawLine (int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color)
 
virtual void drawRect (int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color)
 
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 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 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)
 

Additional Inherited Members

- Data Fields inherited from GFX
uint8_t * m_map
 
- Protected Attributes inherited from GFX
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 inherited from GFX
static const unsigned char font []
 

Constructor & Destructor Documentation

ILI9341 ( int  csLCD,
int  csSD,
int  dc,
int  rst 
)

Instantiates an ILI9341 object

Parameters
csLCDLCD chip select pin
csSDSD card select pin
dcData/command pin
rstReset pin

Here is the call graph for this function:

Member Function Documentation

std::string name ( )
inline

Returns the name of the component

Here is the call graph for this function:

void initModule ( )

Initializes GPIOs used to talk to the LCD

Here is the call graph for this function:

Here is the caller graph for this function:

void configModule ( )

Configures the LCD driver chip via SPI

Here is the call graph for this function:

Here is the caller graph for this function:

void setAddrWindow ( uint16_t  x0,
uint16_t  y0,
uint16_t  x1,
uint16_t  y1 
)

Sets the window size inside the screen where pixel data is written. Concrete implementation from GFX interface.

Parameters
x0First coordinate
y0First coordinate
x1Second coordinate
y1Second coordinate

Here is the call graph for this function:

Here is the caller graph for this function:

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

Sends a pixel color (RGB) to the driver chip. Concrete implementation from GFX interface.

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

Implements GFX.

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 from GFX.

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 from GFX.

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 from GFX.

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 from GFX.

Here is the call graph for this function:

Here is the caller graph for this function:

void setRotation ( uint8_t  r)

Sets the screen to one of four 90 deg rotations.

Parameters
rRotation setting: 0, 1, 2, 3

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 from GFX.

Here is the call graph for this function:

Here is the caller graph for this function:

uint16_t color565 ( uint8_t  r,
uint8_t  g,
uint8_t  b 
)

Pass 8-bit R, G, B values and get back 16-bit packed color.

Parameters
rRed color 0-31
gGreen color 0-63
bblue color 0-31
Returns
16-bit packed color (RGB) value

Here is the caller graph for this function:

void executeCMDList ( const uint8_t *  addr)

Executes a set of commands and data.

Parameters
addrPointer to the start of the commands/data section

Here is the call graph for this function:

Here is the caller graph for this function:

void writecommand ( uint8_t  c)

Sends a command to the display driver via SPI.

Parameters
cCommand to be written

Here is the call graph for this function:

Here is the caller graph for this function:

void writedata ( uint8_t  d)

Sends data to the display driver via SPI

Parameters
dData to be written

Here is the call graph for this function:

Here is the caller graph for this function:

mraa::Result lcdCSOn ( )

Set LCD chip select to LOW

Here is the caller graph for this function:

mraa::Result lcdCSOff ( )

Set LCD chip select to HIGH

Here is the caller graph for this function:

mraa::Result sdCSOn ( )

Set SD card chip select to LOW

Here is the caller graph for this function:

mraa::Result sdCSOff ( )

Set SD card chip select to HIGH

Here is the caller graph for this function:

mraa::Result dcHigh ( )

Set data/command line to HIGH

Here is the caller graph for this function:

mraa::Result dcLow ( )

Set data/command line to LOW

Here is the caller graph for this function:

mraa::Result rstHigh ( )

Set reset line to HIGH

Here is the caller graph for this function:

mraa::Result rstLow ( )

Set reset line to LOW

Here is the caller graph for this function:

Inheritance diagram for ILI9341:
Inheritance graph
[legend]
Collaboration diagram for ILI9341:
Collaboration graph
[legend]

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