pdf-icon

Arduino Quick Start

2. Devices & Examples

6. Applications

Dial Display

APIs and example programs related to the Dial Display.

Example Program

Build Requirements

  • M5Stack board manager version >= 3.2.2
  • Board option = M5Dial
  • M5Dial library version >= 1.0.3
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
#include "M5Dial.h"

void setup() {
  auto cfg = M5.config();
  M5Dial.begin(cfg, false, false);  // encoder, RFID

  int textsize = M5Dial.Display.height() / 60;
  if (textsize == 0) {
    textsize = 1;
  }
  M5Dial.Display.setTextSize(textsize);
}

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

  draw_function(&M5Dial.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);
}

Running Effect:

API

The Dial display uses the M5GFX library as its driver. For more related APIs, please refer to the following documents:

On This Page