pdf-icon

Arduino Quick Start

2. Devices & Examples

6. Applications

Dial Touch

APIs and example programs related to the Dial Touch screen.

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
#include <M5Dial.h>

m5::touch_detail_t touchDetail;

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

  M5Dial.Display.setTextColor(GREEN);
  M5Dial.Display.setTextDatum(middle_center);
  M5Dial.Display.setTextFont(&fonts::FreeMono12pt7b);
  M5Dial.Display.setTextSize(1);

  M5Dial.Display.drawString("Touch Test", M5Dial.Display.width() / 2, M5Dial.Display.height() / 2);
}

void loop() {
  M5Dial.update();
  touchDetail = M5Dial.Touch.getDetail();

  if (touchDetail.isPressed()) {
    M5.Display.fillCircle(touchDetail.x, touchDetail.y, 2, SKYBLUE);
  }
}

Running Effect:

API

The M5Dial library is built on top of the M5Unified library. The touch screen functionality uses the Touch_Class from M5Unified. For more related APIs, please refer to the following document:

On This Page