pdf-icon

TFT Screen

The M5StickC screen has a resolution of 80x160, with the top left corner as the origin (0,0)

ScreenBreath()

Function:

Adjusts screen backlight brightness

Function Prototype:

void ScreenBreath(uint8_t brightness)

Parameter Description
brightness Backlight value (Value: 7 - 16)

Usage Example:

#include <M5StickC.h>

uint8_t i = 7;

void setup() {
  M5.begin();
  M5.Lcd.fillScreen(WHITE);
}
void loop() {
  M5.Axp.ScreenBreath(i++);
  if (i > 15) i = 7;
  delay(500);
}

fillScreen()

Function:

Fills the entire screen with a specified color

Function Prototype:

fillScreen(uint16_t color)

Parameter Description
color Color value

Usage Example:

#include <M5StickC.h>

void setup() {
  M5.begin();
  M5.Lcd.fillScreen(BLUE);
}
void loop() {}

setTextColor()

Function:

Sets the foreground and background color for the displayed text

Function Prototype:

setTextColor(uint16_t color, uint16_t backgroundcolor)

Parameter Description
color Text foreground color
backgroundcolor Text background color

If the function's backgroundcolor value is not given, the current background color is used

Usage Example:

#include <M5StickC.h>

void setup() {
  M5.begin();
  M5.Lcd.setTextColor(RED, WHITE);
  M5.Lcd.println("Hello, M5Stack world!!");
}
void loop() {
}

setCursor()

Function:

Moves the cursor to the position (x0, y0)

Function Prototype:

setCursor(int16_t x0, int16_t y0, uint8_t font)

Usage Example:

#include <M5StickC.h>

void setup() {
  M5.begin();
  M5.Lcd.setCursor(7, 20, 2);
  M5.Lcd.println("scan done");
  M5.Lcd.setCursor(5, 60, 4);
  M5.Lcd.printf("50 AP");
}
void loop(){}

drawPixel()

Function:

Draws a pixel at position (x,y)

Function Prototype:

drawPixel(int16_t x, int16_t y, uint16_t color)

Parameter Description
color Color value

If the function's color value is not given, the current background color is used

Usage Example:

#include <M5StickC.h>

void setup() {
  M5.begin();
  M5.Lcd.drawPixel(22, 22, RED);
}
void loop() {}

drawLine()

Function:

Draws a straight line in a specified color from point (x,y) to point (x1,y1)

Function Prototype:

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

Parameter Description
color Color value

Usage Example:

#include <M5StickC.h>

void setup() {
  M5.begin();
  M5.Lcd.drawLine(0, 0, 12, 12, BLUE);
}
void loop() {}

drawTriangle()

Function:

Draws a triangle with specified color, vertices at (x,y), (x1,y1), and (x2,y2)

Function Prototype:

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

Parameter Description
color Color value

If the function's color value is not given, the current background color is used

Usage Example:

#include <M5StickC.h>

void setup() {
  M5.begin();
  M5.Lcd.drawTriangle(22, 22, 69, 98, 51, 22, RED);
}
void loop() {}

fillTriangle()

Function:

Draws a filled triangle in a specified color, vertices at (x,y), (x1,y1), and (x2,y2)

Function Prototype:

`

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

Parameter Description
color Color value

If the function's color value is not given, the current background color is used

Usage Example:

#include <M5StickC.h>

void setup() {
  M5.begin();
  M5.Lcd.fillTriangle(22, 22, 69, 98, 51, 22, RED);
}
void loop() {}

drawRect()

Function:

Draws a rectangle in a specified color, top-left corner at (x,y), width w, and height h

Function Prototype:

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

Parameter Description
w Width (in pixels)
h Height (in pixels)
color Color value

If the function's color value is not given, the current background color is used

Usage Example:

#include <M5StickC.h>

void setup() {
  M5.begin();
  M5.Lcd.drawRect(50, 100, 30, 10, BLUE);
}
void loop() {}

fillRect()

Function: Draws a filled rectangle in a specified color, top-left corner at (x,y), width w, and height h Function Prototype:

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

Parameter Description
w Width (in pixels)
h Height (in pixels)
color Color value

If the function's color value is not given, the current background color is used

Usage Example:

#include <M5StickC.h>

void setup() {
  M5.begin();
  M5.Lcd.fillRect(50, 100, 20, 10, BLUE);
}
void loop() {}

drawRoundRect()

Function:

Draws a rounded rectangle in a specified color, top-left corner at (x,y), width w, height h, and radius for the corners

Function Prototype:

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

Parameter Description
w Width (in pixels)
h Height (in pixels)
radius Corner radius
color Color value

If the function's color value is not given, the current background color is used

Usage Example:

#include <M5StickC.h>

void setup() {
  M5.begin();
  M5.Lcd.fillRoundRect(40, 70, 20, 10, 4, BLUE);
}
void loop() {}

print()

Function:

Begins printing text (string) text at the current screen position

Function Prototype:

size_t print(const String &s)

Default printed content style is white text on black background

Usage Example:

#include <M5StickC.h>

void setup() {
  M5.begin();
  M5.Lcd.print("print text");
}
void loop() {}

Usage

#include <M5StickC.h>

void setup() {
  M5.begin();

  M5.Lcd.fillScreen(WHITE); //Set the default background color.  Set the default background color
  M5.Lcd.drawLine(0, 0, 100, 100, WHITE);
  M5.Lcd.drawTriangle(22, 22, 69, 98, 51, 22, RED);
  M5.Lcd.fillTriangle(22, 22, 69, 98, 51, 22, RED);
  M5.Lcd.drawRect(50, 100, 30, 10, BLUE);
  M5.Lcd.fillRect(50, 100, 30, 10, BLUE);
  M5.Lcd.drawRoundRect(40, 70, 20, 10, 4, BLUE);
  M5.Lcd.fillRoundRect(40, 70, 20, 10, 4, BLUE);
  M5.Lcd.print("print text");
}
void loop() {}
On This Page