pdf-icon

Arduino入門

2. デバイス&サンプル

6. アプリケーション

Fire Display ディスプレイ表示

Fire ディスプレイ出力に関連する API とサンプルプログラム。

サンプルプログラム

コンパイル要件

  • M5Stack ボードマネージャ バージョン >= 3.2.2
  • ボードオプション = M5Fire
  • M5Unified ライブラリ バージョン >= 0.2.8
  • M5GFX ライブラリ バージョン >= 0.2.11
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
#include "M5Unified.h"

void setup() {
  M5.begin();

  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);
}

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);
}

実行結果:

API

Fire ディスプレイ表示は M5GFX ライブラリをドライバとして使用しています。関連する API の詳細については、以下のドキュメントを参照してください:

On This Page