pdf-icon

Arduino Quick Start

2. Devices & Examples

StamPLC Display

StamPLC uses the M5GFX library as its display driver. Refer to the API & example below for simple display functions. For more API details, please refer to the M5GFX source code.

Example Program

cpp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
/*
 * SPDX-FileCopyrightText: 2025 M5Stack Technology CO LTD
 *
 * SPDX-License-Identifier: MIT
 */
#include <Arduino.h>
#include <M5StamPLC.h>

void setup()
{
    /* Init M5StamPLC */
    M5StamPLC.begin();
}

void loop()
{
    /* Fill screen with colors */
    M5StamPLC.Display.fillScreen(TFT_WHITE);
    delay(800);
    M5StamPLC.Display.fillScreen(TFT_RED);
    delay(800);
    M5StamPLC.Display.fillScreen(TFT_GREEN);
    delay(800);
    M5StamPLC.Display.fillScreen(TFT_BLUE);
    delay(800);
    M5StamPLC.Display.fillScreen(TFT_BLACK);
    delay(800);

    /* Set cursor and print text */
    M5StamPLC.Display.setCursor(10, 10);
    M5StamPLC.Display.setTextColor(TFT_WHITE);
    M5StamPLC.Display.setTextSize(1);
    M5StamPLC.Display.printf("Display Test!");
    delay(800);

    /* Draw shapes */
    M5StamPLC.Display.drawRect(100, 50, 50, 50, BLUE);
    delay(800);
    M5StamPLC.Display.fillRect(100, 50, 50, 50, BLUE);
    delay(800);
    M5StamPLC.Display.drawCircle(100, 50, 50, RED);
    delay(800);
    M5StamPLC.Display.fillCircle(100, 50, 50, RED);
    delay(800);
    M5StamPLC.Display.drawTriangle(30, 30, 180, 50, 80, 100, YELLOW);
    delay(800);
    M5StamPLC.Display.fillTriangle(30, 30, 180, 50, 80, 100, YELLOW);
    delay(800);

    /* Draw random triangles */
    for (int i = 0; i < 1000; i++) {
        M5StamPLC.Display.fillTriangle(random(M5StamPLC.Display.width() - 1), random(M5StamPLC.Display.height() - 1),
                                       random(M5StamPLC.Display.width() - 1), random(M5StamPLC.Display.height() - 1),
                                       random(M5StamPLC.Display.width() - 1), random(M5StamPLC.Display.height() - 1),
                                       random(0xfffe));
    }
    delay(800);
}
On This Page