pyupm_ili9341 module

class pyupm_ili9341.GFX(*args, **kwargs)[source]

Bases: object

GFX helper class.

This file is used by the screen.

C++ includes: ili9341_gfx.hpp

cp437(x)[source]

void cp437(bool x)

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

x: True to enable CP437 charset. False to disable.

drawChar(x, y, c, color, bg, size)[source]

void drawChar(int16_t x, int16_t y, uint8_t data, uint16_t color, uint16_t bg, uint8_t size)

x: Axis on the horizontal scale

y: Axis on the vertical scale

data: Character to write

color: Character color

bg: Character background color

size: Size of the font

drawCircle(x0, y0, r, color)[source]

void drawCircle(int16_t x, int16_t y, int16_t r, uint16_t color)

Draws a circle

x: Center of the circle on the horizontal scale

y: Center of the circle on the vertical scale

r: Radius of the circle

color: Color of the circle

drawCircleHelper(x0, y0, r, cornername, color)[source]

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

Used to draw rounded corners.

x0: Center point of circle on x-axis

y0: Center point of circle on y-axis

r: Radius of circle

cornername: Mask of corner number (1, 2, 4, 8)

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

drawFastHLine(x, y, w, color)[source]

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

Draws a horizontal line using minimal SPI writes.

x: Axis on the horizontal scale to begin line

y: Axis on the vertical scale to begin line

w: Width of line in pixels

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

drawFastVLine(x, y, h, color)[source]

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

Draws a line on the vertical scale

x: Axis on the horizontal scale

y: Axis on the vertical scale

h: Distanse from y

color: Selected color

drawLine(x0, y0, x1, y1, color)[source]

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

x0: First coordinate

y0: First coordinate

x1: Second coordinate

y1: Second coordinate

color: selected color

drawPixel(x, y, color)[source]

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

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

x: Axis on the horizontal scale

y: Axis on the vertical scale

color: RGB value

drawRect(x, y, w, h, color)[source]

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

Draws a rectangle (not filled).

x: Position of upper left corner on horizontal axis

y: Position of upper left corner on vertical axis

w: Width of rectangle

h: Height of rectangle RGB (16-bit) color (R[0-4], G[5-10], B[11-15]

drawRoundRect(x0, y0, w, h, radius, color)[source]

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

x0: X-axis coordinate of top-left corner

y0: Y-axis coordinate of top-left corner

w: Width of rectangle

h: height of rectangle

radius: Radius of rounded corners

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

drawTriangle(x0, y0, x1, y1, x2, y2, color)[source]

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

x0: First coordinate

y0: First coordinate

x1: Second coordinate

y1: Second coordinate

x2: Third coordinate

y2: Third coordinate

color: Selected color

fillCircle(x0, y0, r, color)[source]

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

Draws a filled circle.

x0: Center point of circle on x-axis

y0: Center point of circle on y-axis

r: Radius of circle

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

fillCircleHelper(x0, y0, r, cornername, delta, color)[source]

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.

x0: Center point of circle on x-axis

y0: Center point of circle on y-axis

r: Radius of circle

cornername: Mask of corner number (1, 2, 4, 8)

delta: Line offset

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

fillRect(x, y, w, h, color)[source]

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

Fills a rectangle with a selected color

x: Axis on the horizontal scale (top-left corner)

y: Axis on the vertical scale (top-left corner)

w: Distanse from x

h: Distanse from y

color: Selected color

fillRoundRect(x0, y0, w, h, radius, color)[source]

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

x0: X-axis coordinate of top-left corner

y0: Y-axis coordinate of top-left corner

w: Width of rectangle

h: height of rectangle

radius: Radius of rounded corners

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

fillScreen(color)[source]

void fillScreen(uint16_t color)

Fills the screen with a selected color

color: Selected color

fillTriangle(x0, y0, x1, y1, x2, y2, color)[source]

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.

x0: First point coordinate on x-axis

y0: First point coordinate on y-axis

x1: Second point coordinate on x-axis

y1: Second point coordinate on y-axis

x2: Third point coordinate on x-axis

y2: Third point coordinate on y-axis

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

getCursorX()[source]

int16_t getCursorX(void) const

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

X-axis coordinate of the cursor

getCursorY()[source]

int16_t getCursorY(void) const

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

Y-axis coordinate of the cursor

getRotation()[source]

uint8_t getRotation(void) const

Get the current rotation configuration of the screen.

current rotation 0-3

height()[source]

int16_t height(void) const

Get the current height of the screen.

the height in pixels

invertDisplay(i)[source]

void invertDisplay(bool i)

Invert colors on the display.

i: True or false to invert colors

setCursor(x, y)[source]

void setCursor(int16_t x, int16_t y)

Sets the cursor for a text message

x: Axis on the horizontal scale

y: Axis on the vertical scale

setRotation(r)[source]

void setRotation(uint8_t r)

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

r: Rotation 0-3

setTextColor(*args)[source]

void setTextColor(uint16_t textColor, uint16_t textBGColor)

Sets a text color for a message

textColor: Font color

textBGColor: Background color

setTextSize(s)[source]

void setTextSize(uint8_t size)

Sets the size of the font

size: Font size

setTextWrap(w)[source]

void setTextWrap(uint8_t wrap)

Wraps a printed message

wrap: True (0x1) or false (0x0)

width()[source]

int16_t width(void) const

Get the current width of the screen.

the width in pixels

write(c)[source]

void write(uint8_t c)

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

c: Character to draw

class pyupm_ili9341.ILI9341(csLCD, csSD, dc, rst)[source]

Bases: pyupm_ili9341.GFX

API for the ILI9342 LCD.

ID: ili9341

Name: SPI Based LCD

Category: display

Manufacturer: adafruit

Link:http://www.adafruit.com/product/2090

Connection: spi This module defines the interface for the ILI9341 display library

C++ includes: ili9341.hpp

color565(r, g, b)[source]

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.

r: Red color 0-31

g: Green color 0-63

b: blue color 0-31

16-bit packed color (RGB) value

configModule()[source]

void configModule()

Configures the LCD driver chip via SPI

dcHigh()[source]

mraa::Result dcHigh()

Set data/command line to HIGH

dcLow()[source]

mraa::Result dcLow()

Set data/command line to LOW

drawFastHLine(x, y, w, color)[source]

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

Draws a horizontal line using minimal SPI writes.

x: Axis on the horizontal scale to begin line

y: Axis on the vertical scale to begin line

w: Width of line in pixels

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

drawFastVLine(x, y, h, color)[source]

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

Draws a vertical line using minimal SPI writes.

x: Axis on the horizontal scale to begin line

y: Axis on the vertical scale to begin line

h: Height of line in pixels

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

drawPixel(x, y, color)[source]

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

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

x: Axis on the horizontal scale

y: Axis on the vertical scale

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

executeCMDList(addr)[source]

void executeCMDList(const uint8_t *addr)

Executes a set of commands and data.

addr: Pointer to the start of the commands/data section

fillRect(x, y, w, h, color)[source]

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

Draw a filled rectangle.

x: Axis on the horizontal scale of upper-left corner

y: Axis on the vertical scale of upper-left corner

w: Width of rectangle in pixels

h: Height of rectangle in pixels

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

fillScreen(color)[source]

void fillScreen(uint16_t color)

Fill the screen with a single color.

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

initModule()[source]

void initModule()

Initializes GPIOs used to talk to the LCD

invertDisplay(i)[source]

void invertDisplay(bool i)

Invert colors on the display.

i: True or false to invert colors

lcdCSOff()[source]

mraa::Result lcdCSOff()

Set LCD chip select to HIGH

lcdCSOn()[source]

mraa::Result lcdCSOn()

Set LCD chip select to LOW

name()[source]

std::string name()

Returns the name of the component

rstHigh()[source]

mraa::Result rstHigh()

Set reset line to HIGH

rstLow()[source]

mraa::Result rstLow()

Set reset line to LOW

sdCSOff()[source]

mraa::Result sdCSOff()

Set SD card chip select to HIGH

sdCSOn()[source]

mraa::Result sdCSOn()

Set SD card chip select to LOW

setAddrWindow(x0, y0, x1, y1)[source]

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.

x0: First coordinate

y0: First coordinate

x1: Second coordinate

y1: Second coordinate

setRotation(r)[source]

void setRotation(uint8_t r)

Sets the screen to one of four 90 deg rotations.

r: Rotation setting: 0, 1, 2, 3

writecommand(c)[source]

void writecommand(uint8_t c)

Sends a command to the display driver via SPI.

c: Command to be written

writedata(d)[source]

void writedata(uint8_t d)

Sends data to the display driver via SPI

d: Data to be written