AmebaILI9341 Class
AmebaILI9341 Class
Description
A class to use ILI9341 TFT SPI display for Ameba.
Syntax
class AmebaILI9341
Members
Public Constructors | |
AmebaILI9341::AmebaILI9341 | Constructs an AmebaILI9341 object. |
Public Methods | |
AmebaILI9341::begin | Initialize SPI, pin mapping and screen configuration. |
AmebaILI9341::setAddress | Initialize image size and position. |
AmebaILI9341::writecommand | SPI transfer a command. |
AmebaILI9341::writedata | SPI transfer a piece of data. |
AmebaILI9341::setRotation | Set screen orientation. |
AmebaILI9341::fillScreen | Fill the screen with a color. |
AmebaILI9341::clr | Clear screen. |
AmebaILI9341::fillRectangle | Fill a rectangle shape with color and display on the screen. |
AmebaILI9341::drawPixel | Draw a pixel by coordinates on the screen. |
AmebaILI9341::drawChar | Draw a character in the frame buffer but does not refresh. |
AmebaILI9341::drawLine | Draw a line and display on the screen. |
AmebaILI9341::drawRectangle | Draw a rectangular shape and display on the screen. |
AmebaILI9341::drawCircle | Draw a circle shape and display on the screen. |
AmebaILI9341::write | Display a character and display on the screen. |
AmebaILI9341::getWidth | Get the width of the image. |
AmebaILI9341::getHeight | Get the height of the image. |
AmebaILI9341::setCursor | Set the cursor to a specific position on the screen. |
AmebaILI9341::setForeground | Set foreground color. |
AmebaILI9341::setBackground | Set background color. |
AmebaILI9341::setFontSize | Set character font size. |
AmebaILI9341::reset | Reset the module. |
AmebaILI9341::AmebaILI9341
Description
Constructs an AmebaILI9341 object and set CS, DC and RESET pins.
Syntax
AmebaILI9341::AmebaILI9341(int csPin, int dcPin, int resetPin);
Parameters
csPin: pin for Chip Select
dcPin: pin for Data/Command
resetPin: pin for Reset
Returns
NA
Example Code
Example: PM25_on_ILI9341_TFT_LCD
(https://github.com/ambiot/amb1_arduino/blob/dev/Arduino_package/hardware/libraries/SPI/examples/PM25_on_ILI9341_TFT_LCD/PM25_on_ILI9341_TFT_LCD.ino)
Notes and Warnings
“AmebaILI9341.h” must be included to use the class function.
AmebaILI9341::begin
Description
Initialize hardware SPI, pin mapping and screen configuration.
Syntax
void begin(void);
Parameters
NA
Returns
NA
Example Code
Example: PM25_on_ILI9341_TFT_LCD
(https://github.com/ambiot/amb1_arduino/blob/dev/Arduino_package/hardware/libraries/SPI/examples/PM25_on_ILI9341_TFT_LCD/PM25_on_ILI9341_TFT_LCD.ino)
Notes and Warnings
“AmebaILI9341.h” must be included to use the class function.
This method is required to run first before other operations on the display.
AmebaILI9341::setAddress
Description
Initialize image size and positioning on the display.
Syntax
void setAddress(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1);
Parameters
x0: leftmost coordinate of the image
y0: top coordinate of the image
x1: rightmost coordinate of the image
y1: bottom coordinate of the image
Returns
NA
Example Code
NA
Notes and Warnings
Do not use this to set the cursor, use “setCursor” method instead. “AmebaILI9341.h” must be included to use the class function.
AmebaILI9341::writecommand
Description
Transfer a command via SPI.
Syntax
void writecommand(uint8_t command);
Parameters
command: a single byte command
Returns
NA
Example Code
NA
Notes and Warnings
“AmebaILI9341.h” must be included to use the class function.
AmebaILI9341::writedata
Description
Transfer a piece of data via SPI.
Syntax
void writedata(uint8_t data);
Parameters
data: a single byte data
Returns
NA
Example Code
NA
Notes and Warnings
Only use this method to write 1 byte at a time. “AmebaILI9341.h” must be included to use the class function.
AmebaILI9341::setRotation
Description
Setting screen orientation, “0” for no rotation, “1” for 90 degrees rotation, “2” for 180 degrees rotation, “3” for 270 degrees rotation.
Syntax
void setRotation(uint8_t m);
Parameters
m: select desired screen orientation, expressing it as an integer.
Returns
NA
Example Code
Example: PM25_on_ILI9341_TFT_LCD
(https://github.com/ambiot/amb1_arduino/blob/dev/Arduino_package/hardware/libraries/SPI/examples/PM25_on_ILI9341_TFT_LCD/PM25_on_ILI9341_TFT_LCD.ino)
Notes and Warnings
Although “0” for no rotation, “1” for 90 degrees rotation, “2” for 180 degrees rotation, “3” for 270 degrees rotation, but if m is more than 3, for example, m = 4: there will be no rotation, m= 5: 90 degrees rotation and so on.
“AmebaILI9341.h” must be included to use the class function.
AmebaILI9341::fillScreen
Description
Fill the entire screen with one color.
Syntax
void fillScreen(uint16_t color);
Parameters
color: a 16-bit color reference defined in AmebaILI9341.h
Returns
NA
Example Code
NA
Notes and Warnings
Refer to AmebaILI9341.h for available colors. “AmebaILI9341.h” must be included to use the class function.
AmebaILI9341::clr
Description
Clear the screen.
Syntax
void clr(void);
Parameters
NA
Returns
NA
Example Code
Example: PM25_on_ILI9341_TFT_LCD
(https://github.com/ambiot/amb1_arduino/blob/dev/Arduino_package/hardware/libraries/SPI/examples/PM25_on_ILI9341_TFT_LCD/PM25_on_ILI9341_TFT_LCD.ino)
Notes and Warnings
Background color can be set by calling setBackground method. ”AmebaILI9341.h” must be included to use the class function.
AmebaILI9341::fillRectangle
Description
Fill a rectangle shape with color and display on the screen.
Syntax
void fillRectangle(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color);
Parameters
x: leftmost coordinate of the image
y: top coordinate of the image
w: width of the image
h: height of the image
color: the color of the image
Returns
NA
Example Code
Example: PM25_on_ILI9341_TFT_LCD
(https://github.com/ambiot/amb1_arduino/blob/dev/Arduino_package/hardware/libraries/SPI/examples/PM25_on_ILI9341_TFT_LCD/PM25_on_ILI9341_TFT_LCD.ino)
Notes and Warnings
”AmebaILI9341.h” must be included to use the class function.
AmebaILI9341::drawPixel
Description
Draw a pixel by coordinates on the screen.
Syntax
void drawPixel(int16_t x, int16_t y, uint16_t color);
Parameters
x: leftmost coordinate of the image
y: top coordinate of the image
color: the color of the image
Returns
NA
Example Code
NA
Notes and Warnings
”AmebaILI9341.h” must be included to use the class function.
AmebaILI9341::drawChar
Description
Draw a character in the frame buffer but does not refresh.
Syntax
void drawChar(unsigned char c);
void drawChar(int16_t x, int16_t y, unsigned char c, uint16_t _fontcolor, uint16_t _background, uint8_t _fontsize);
Parameters
x: leftmost coordinate of the image
y: top coordinate of the image
c: a character
_fontcolor: font color
_background: background color
_fontsize: font size
Returns
NA
Example Code
NA
Notes and Warnings
By using this method only stores the string of character in a buffer frame. The Print/Println method have to be called in order to display a string of character on the screen. ”AmebaILI9341.h” must be included to use the class function.
AmebaILI9341::drawLine
Description
Draw a line and display on the screen.
Syntax
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);
Parameters
x0: leftmost coordinate of the image
y0: top coordinate of the image
x1: leftmost coordinate of the image
y1: top coordinate of the image
color: the color of the image
Returns
NA
Example Code
NA
Notes and Warnings
”AmebaILI9341.h” must be included to use the class function.
AmebaILI9341::drawRectangle
Description
Draw a rectangular shape and display on the screen.
Syntax
void drawRectangle(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color);
void drawRectangle(int16_t x, int16_t y, int16_t w, int16_t h);
Parameters
x: leftmost coordinate of the image
y: top coordinate of the image
w: width of the image
h: height of the image
color: the color of the image
Returns
NA
Example Code
NA
Notes and Warnings
”AmebaILI9341.h” must be included to use the class function.
AmebaILI9341::drawCircle
Description
Draw a circle shape and display on the screen.
Syntax
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);
Parameters
x0: leftmost coordinate of the image
y0: top coordinate of the image
r: radius of the image
color: the color of the image
Returns
NA
Example Code
NA
Notes and Warnings
”AmebaILI9341.h” must be included to use the class function.
AmebaILI9341::write
Description
Display a character and display on the screen.
Syntax
virtual size_t write(uint8_t);
Parameters
c: a character to be written on the screen.
Returns
This function returns the number of bytes written.
Example Code
NA
Notes and Warnings
This an inherited method from Print class and is seldom used. ”AmebaILI9341.h” must be included to use the class function.
AmebaILI9341::getWidth
Description
Get the width of the image.
Syntax
int16_t getWidth(void);
Parameters
NA
Returns
This function returns the width of the image.
Example Code
NA
Notes and Warnings
The width is defined in” AmebaILI9341.h”. ” AmebaILI9341.h” must be included to use the class function.
AmebaILI9341::getHeight
Description
Get the height of the image.
Syntax
int16_t getHeight(void);
Parameters
NA
Returns
This function returns the height of the image.
Example Code
NA
Notes and Warnings
The height is defined in” AmebaILI9341.h”. ”AmebaILI9341.h” must be included to use the class function.
AmebaILI9341::setCursor
Description
Set the cursor to a specific position on the screen.
Syntax
void setCursor(int16_t x, int16_t y);
Parameters
x: coordinates on the x-axis
y: coordinates on the y-axis
Returns
NA
Example Code
Example: PM25_on_ILI9341_TFT_LCD
(https://github.com/ambiot/amb1_arduino/blob/dev/Arduino_package/hardware/libraries/SPI/examples/PM25_on_ILI9341_TFT_LCD/PM25_on_ILI9341_TFT_LCD.ino)
Notes and Warnings
”AmebaILI9341.h” must be included to use the class function.
AmebaILI9341::setForeground
Description
Set foreground color.
Syntax
void setForeground(uint16_t color);
Parameters
color: desired colors for foreground
Returns
NA
Example Code
Example: PM25_on_ILI9341_TFT_LCD
(https://github.com/ambiot/amb1_arduino/blob/dev/Arduino_package/hardware/libraries/SPI/examples/PM25_on_ILI9341_TFT_LCD/PM25_on_ILI9341_TFT_LCD.ino)
Notes and Warnings
Refer to AmebaILI9341.h for available colors. “AmebaILI9341.h” must be included to use the class function.
AmebaILI9341::setBackground
Description
Set background color.
Syntax
void setBackground(uint16_t color);
Parameters
_background: desired background color
Returns
NA
Example Code
Example: PM25_on_ILI9341_TFT_LCD
(https://github.com/ambiot/amb1_arduino/blob/dev/Arduino_package/hardware/libraries/SPI/examples/PM25_on_ILI9341_TFT_LCD/PM25_on_ILI9341_TFT_LCD.ino)
Notes and Warnings
Refer to AmebaILI9341.h for available colors. “AmebaILI9341.h” must be included to use the class function.
AmebaILI9341::setFontSize
Description
Set the font size of the characters to be printed on the screen.
Syntax
void setFontSize(uint8_t size);
Parameters
size: desired font size. Default values:1 (smallest) to 5 (largest).
Returns
NA
Example Code
Example: PM25_on_ILI9341_TFT_LCD
(https://github.com/ambiot/amb1_arduino/blob/dev/Arduino_package/hardware/libraries/SPI/examples/PM25_on_ILI9341_TFT_LCD/PM25_on_ILI9341_TFT_LCD.ino)
Notes and Warnings
“AmebaILI9341.h” must be included to use the class function.
AmebaILI9341::reset
Description
Reset the module.
Syntax
void reset(void);
Parameters
NA
Returns
NA
Example Code
NA
Notes and Warnings
“AmebaILI9341.h” must be included to use the class function.