Arduino入門
Cardputer Display 画面表示に関する API とサンプルプログラムです。Cardputer および Cardputer-Adv に対応しています。
#include "M5Cardputer.h"
void setup() {
auto cfg = M5.config();
M5Cardputer.begin(cfg);
int textsize = M5Cardputer.Display.height() / 60;
if (textsize == 0) {
textsize = 1;
}
M5Cardputer.Display.setTextSize(textsize);
}
void loop() {
int x = rand() % M5Cardputer.Display.width();
int y = rand() % M5Cardputer.Display.height();
int r = (M5Cardputer.Display.width() >> 4) + 2;
uint16_t c = rand();
M5Cardputer.Display.fillCircle(x, y, r, c);
draw_function(&M5Cardputer.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);
}
実行結果:
Cardputer の画面表示機能は、M5GFX
ライブラリをドライバとして使用しています。詳細な API については以下のドキュメントを参照してください: