pdf-icon

Arduino入門

2. デバイス&サンプル

5. 拡張モジュール&サンプル

アクセサリー

6. アプリケーション

CoreS3 Display ディスプレイ

説明
CoreS3 は M5GFX ライブラリをディスプレイドライバーとして使用しています。以下の API およびサンプルを参照して簡単な表示を実装できます。より多くの API 内容については M5GFX ドキュメントを参照してください。

サンプルプログラム

コンパイル要件

  • M5Stack ボード マネージャー バージョン >= 3.2.2
  • ボード選択 = M5CoreS3
  • M5Unified ライブラリ バージョン >= 0.2.11
  • M5GFX ライブラリ バージョン >= 0.2.14
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
#include <M5Unified.h>

void draw_function(LovyanGFX* gfx) {
    int x      = rand() % gfx->width();
    int y      = rand() % gfx->height();
    int r      = (gfx->width() >> 4) + 2;
    uint16_t c = rand();
    gfx->fillRect(x - r, y - r, r * 2, r * 2, c);
}

void setup() {
    auto cfg = M5.config();
    M5.begin(cfg);
    int textsize = M5.Display.height() / 60;
    if (textsize == 0) {
        textsize = 1;
    }
    M5.Display.setTextSize(textsize);
}

void loop() {
    int x      = rand() % M5.Display.width();
    int y      = rand() % M5.Display.height();
    int r      = (M5.Display.width() >> 4) + 2;
    uint16_t c = rand();
    M5.Display.fillCircle(x, y, r, c);
    draw_function(&M5.Display);
}

サンプルの結果は以下のようになります。プログラムは画面上のランダムな位置にさまざまな色の円と矩形を描画します:

On This Page